#include "../libburn/libburn.h"
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
Include dependency graph for libburner.c:
Go to the source code of this file.
Functions | |
int | libburner_aquire_by_adr (char *drive_adr) |
If the persistent drive address is known, then this approach is much more un-obtrusive to the systemwide livestock of drives. | |
int | libburner_aquire_by_driveno (int *driveno) |
This method demonstrates how to use libburn without knowing a persistent drive address in advance. | |
int | libburner_aquire_drive (char *drive_adr, int *driveno) |
You need to aquire a drive before burning. | |
int | libburner_blank_disc (struct burn_drive *drive, int blank_fast) |
Makes a previously used CD-RW ready for thorough re-usal. | |
int | libburner_format_row (struct burn_drive *drive) |
Persistently changes DVD-RW profile 0014h "Sequential Recording" to profile 0013h "Restricted Overwrite" which needs no blanking for re-use but is not capable of multi-session. | |
int | libburner_payload (struct burn_drive *drive, char source_adr[][4096], int source_adr_count, int multi, int simulate_burn, int all_tracks_type) |
Brings preformatted track images (ISO 9660, audio, . | |
int | libburner_setup (int argc, char **argv) |
Converts command line arguments into above setup parameters. | |
int | main (int argc, char **argv) |
Variables | |
static struct burn_drive_info * | drive_list |
This list will hold the drives known to libburn. | |
static unsigned int | drive_count |
If you start a long lasting operation with drive_count > 1 then you are not friendly to the users of other drives on those systems. | |
static int | drive_is_grabbed = 0 |
This variable indicates wether the drive is grabbed and must be finally released. | |
static int | current_profile = -1 |
A number and a text describing the type of media in aquired drive. | |
static char | current_profile_name [80] = {""} |
static char | drive_adr [BURN_DRIVE_ADR_LEN] = {""} |
The setup parameters of libburner. | |
static int | driveno = 0 |
static int | do_blank = 0 |
static char | source_adr [99][4096] |
static int | source_adr_count = 0 |
static int | do_multi = 0 |
static int | simulate_burn = 0 |
static int | all_tracks_type = BURN_MODE1 |
int libburner_aquire_by_adr | ( | char * | drive_adr | ) |
If the persistent drive address is known, then this approach is much more un-obtrusive to the systemwide livestock of drives.
Only the given drive device will be opened during this procedure.
Definition at line 121 of file libburner.c.
References BURN_DRIVE_ADR_LEN, burn_drive_convert_fs_adr(), burn_drive_scan_and_grab(), drive_is_grabbed, and drive_list.
Referenced by libburner_aquire_drive().
00122 { 00123 int ret; 00124 char libburn_drive_adr[BURN_DRIVE_ADR_LEN]; 00125 00126 /* This tries to resolve links or alternative device files */ 00127 ret = burn_drive_convert_fs_adr(drive_adr, libburn_drive_adr); 00128 if (ret<=0) { 00129 fprintf(stderr,"Address does not lead to a CD burner: '%s'\n", 00130 drive_adr); 00131 return ret; 00132 } 00133 00134 printf("Aquiring drive '%s' ...\n",libburn_drive_adr); 00135 ret = burn_drive_scan_and_grab(&drive_list,libburn_drive_adr,1); 00136 if (ret <= 0) { 00137 fprintf(stderr,"FAILURE with persistent drive address '%s'\n", 00138 libburn_drive_adr); 00139 } else { 00140 printf("Done\n"); 00141 drive_is_grabbed = 1; 00142 } 00143 return ret; 00144 }
int libburner_aquire_by_driveno | ( | int * | driveno | ) |
This method demonstrates how to use libburn without knowing a persistent drive address in advance.
It has to make sure that after assessing the list of available drives, all unwanted drives get closed again. As long as they are open, no other libburn instance can see them. This is an intended locking feature. The application is responsible for giving up the locks by either burn_drive_release() (only after burn_drive_grab() !), burn_drive_info_forget(), burn_drive_info_free(), or burn_finish().
driveno | the index number in libburn's drive list. This will get set to 0 on success and will then be the drive index to use in the further dourse of processing. |
Definition at line 159 of file libburner.c.
References BURN_DRIVE_ADR_LEN, burn_drive_get_adr(), burn_drive_grab(), burn_drive_info_forget(), burn_drive_scan(), burn_drive_info::drive, drive_count, drive_is_grabbed, drive_list, burn_drive_info::product, and burn_drive_info::vendor.
Referenced by libburner_aquire_drive().
00160 { 00161 char adr[BURN_DRIVE_ADR_LEN]; 00162 int ret, i; 00163 00164 printf("Beginning to scan for devices ...\n"); 00165 while (!burn_drive_scan(&drive_list, &drive_count)) 00166 usleep(1002); 00167 if (drive_count <= 0 && *driveno >= 0) { 00168 printf("FAILED (no drives found)\n"); 00169 return 0; 00170 } 00171 printf("Done\n"); 00172 00173 /* 00174 Interactive programs may choose the drive number at this moment. 00175 00176 drive[0] to drive[drive_count-1] are struct burn_drive_info 00177 as defined in libburn/libburn.h . This structure is part of API 00178 and thus will strive for future compatibility on source level. 00179 Have a look at the info offered. 00180 Caution: do not take .location for drive address. Always use 00181 burn_drive_get_adr() or you might become incompatible 00182 in future. 00183 Note: bugs with struct burn_drive_info - if any - will not be 00184 easy to fix. Please report them but also strive for 00185 workarounds on application level. 00186 */ 00187 printf("\nOverview of accessible drives (%d found) :\n", 00188 drive_count); 00189 printf("-----------------------------------------------------------------------------\n"); 00190 for (i = 0; i < drive_count; i++) { 00191 if (burn_drive_get_adr(&(drive_list[i]), adr) <=0) 00192 strcpy(adr, "-get_adr_failed-"); 00193 printf("%d --drive '%s' : '%s' '%s'\n", 00194 i,adr,drive_list[i].vendor,drive_list[i].product); 00195 } 00196 printf("-----------------------------------------------------------------------------\n\n"); 00197 00198 /* 00199 On multi-drive systems save yourself from sysadmins' revenge. 00200 00201 Be aware that you hold reserved all available drives at this point. 00202 So either make your choice quick enough not to annoy other system 00203 users, or set free the drives for a while. 00204 00205 The tested way of setting free all drives is to shutdown the library 00206 and to restart when the choice has been made. The list of selectable 00207 drives should also hold persistent drive addresses as obtained 00208 above by burn_drive_get_adr(). By such an address one may use 00209 burn_drive_scan_and_grab() to finally aquire exactly one drive. 00210 00211 A not yet tested shortcut should be to call burn_drive_info_free() 00212 and to call either burn_drive_scan() or burn_drive_scan_and_grab() 00213 before accessing any drives again. 00214 00215 In both cases you have to be aware that the desired drive might get 00216 aquired in the meantime by another user resp. libburn process. 00217 */ 00218 00219 /* We already made our choice via command line. (default is 0) 00220 So we just have to keep our desired drive and drop all others. 00221 No other libburn instance will have a chance to steal our drive. 00222 */ 00223 if (*driveno < 0) { 00224 printf("Pseudo-drive \"-\" given : bus scanning done.\n"); 00225 return 2; /* the program will end after this */ 00226 } 00227 if (drive_count <= *driveno) { 00228 fprintf(stderr, 00229 "Found only %d drives. Number %d not available.\n", 00230 drive_count, *driveno); 00231 return 0; /* the program will end after this */ 00232 } 00233 00234 /* Drop all drives which we do not want to use */ 00235 for (i = 0; i < drive_count; i++) { 00236 if (i == *driveno) /* the one drive we want to keep */ 00237 continue; 00238 ret = burn_drive_info_forget(&(drive_list[i]),0); 00239 if (ret != 1) 00240 fprintf(stderr, "Cannot drop drive %d. Please report \"ret=%d\" to libburn-hackers@pykix.org\n", 00241 i, ret); 00242 else 00243 printf("Dropped unwanted drive %d\n",i); 00244 } 00245 /* Make the one we want ready for blanking or burning */ 00246 ret= burn_drive_grab(drive_list[*driveno].drive, 1); 00247 if (ret != 1) 00248 return 0; 00249 drive_is_grabbed = 1; 00250 return 1; 00251 }
int libburner_aquire_drive | ( | char * | drive_adr, | |
int * | driveno | |||
) |
You need to aquire a drive before burning.
The API offers this as one compact call and alternatively as application controllable gestures of whitelisting, scanning for drives and finally grabbing one of them.
If you have a persistent address of the drive, then the compact call is to prefer because it only touches one drive. On modern Linux kernels, there should be no fatal disturbance of ongoing burns of other libburn instances with any of our approaches. We use open(O_EXCL) by default. On /dev/hdX it should cooperate with growisofs and some cdrecord variants. On /dev/sgN versus /dev/scdM expect it not to respect other programs.
Definition at line 99 of file libburner.c.
References burn_disc_get_profile(), current_profile, current_profile_name, burn_drive_info::drive, drive_list, libburner_aquire_by_adr(), and libburner_aquire_by_driveno().
Referenced by main().
00100 { 00101 int ret; 00102 00103 if(drive_adr != NULL && drive_adr[0] != 0) 00104 ret = libburner_aquire_by_adr(drive_adr); 00105 else 00106 ret = libburner_aquire_by_driveno(driveno); 00107 if (ret <= 0) 00108 return ret; 00109 burn_disc_get_profile(drive_list[0].drive, ¤t_profile, 00110 current_profile_name); 00111 if (current_profile_name[0]) 00112 printf("Detected media type: %s\n", current_profile_name); 00113 return 1; 00114 }
int libburner_blank_disc | ( | struct burn_drive * | drive, | |
int | blank_fast | |||
) |
Makes a previously used CD-RW ready for thorough re-usal.
To our knowledge it is hardly possible to abort an ongoing blank operation because after start it is entirely handled by the drive. So expect signal handling to wait the normal blanking timespan until it can allow the process to end. External kill -9 will not help the drive.
Definition at line 261 of file libburner.c.
References BURN_DISC_APPENDABLE, BURN_DISC_BLANK, BURN_DISC_EMPTY, burn_disc_erasable(), burn_disc_erase(), BURN_DISC_FULL, burn_disc_get_status(), burn_drive_get_status(), BURN_DRIVE_IDLE, current_profile, burn_progress::sector, and burn_progress::sectors.
Referenced by main().
00262 { 00263 enum burn_disc_status disc_state; 00264 struct burn_progress p; 00265 double percent = 1.0; 00266 00267 disc_state = burn_disc_get_status(drive); 00268 printf( 00269 "Drive media status: %d (see libburn/libburn.h BURN_DISC_*)\n", 00270 disc_state); 00271 if (current_profile == 0x13) { 00272 ; /* formatted DVD-RW will get blanked to sequential state */ 00273 } else if (disc_state == BURN_DISC_BLANK) { 00274 fprintf(stderr, 00275 "IDLE: Blank media detected. Will leave it untouched\n"); 00276 return 2; 00277 } else if (disc_state == BURN_DISC_FULL || 00278 disc_state == BURN_DISC_APPENDABLE) { 00279 ; /* this is what libburner is willing to blank */ 00280 } else if (disc_state == BURN_DISC_EMPTY) { 00281 fprintf(stderr,"FATAL: No media detected in drive\n"); 00282 return 0; 00283 } else { 00284 fprintf(stderr, 00285 "FATAL: Unsuitable drive and media state\n"); 00286 return 0; 00287 } 00288 if(!burn_disc_erasable(drive)) { 00289 fprintf(stderr, 00290 "FATAL : Media is not of erasable type\n"); 00291 return 0; 00292 } 00293 printf( 00294 "Beginning to %s-blank media.\n", (blank_fast?"fast":"full")); 00295 burn_disc_erase(drive, blank_fast); 00296 sleep(1); 00297 while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) { 00298 if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */ 00299 percent = 1.0 + ((double) p.sector+1.0) 00300 / ((double) p.sectors) * 98.0; 00301 printf("Blanking ( %.1f%% done )\n", percent); 00302 sleep(1); 00303 } 00304 printf("Done\n"); 00305 return 1; 00306 }
int libburner_format_row | ( | struct burn_drive * | drive | ) |
Persistently changes DVD-RW profile 0014h "Sequential Recording" to profile 0013h "Restricted Overwrite" which needs no blanking for re-use but is not capable of multi-session.
Expect a behavior similar to blanking with unusual noises from the drive.
Definition at line 315 of file libburner.c.
References burn_disc_format(), burn_disc_get_profile(), burn_drive_get_status(), BURN_DRIVE_IDLE, current_profile, current_profile_name, drive_list, burn_progress::sector, and burn_progress::sectors.
Referenced by main().
00316 { 00317 struct burn_progress p; 00318 double percent = 1.0; 00319 00320 if (current_profile == 0x13) { 00321 fprintf(stderr, "IDLE: DVD-RW media is already formatted\n"); 00322 return 2; 00323 } else if (current_profile != 0x14) { 00324 fprintf(stderr, "FATAL: Can only format DVD-RW\n"); 00325 return 0; 00326 } 00327 printf("Beginning to format media.\n"); 00328 burn_disc_format(drive, (off_t) 0, 0); 00329 00330 sleep(1); 00331 while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) { 00332 if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */ 00333 percent = 1.0 + ((double) p.sector+1.0) 00334 / ((double) p.sectors) * 98.0; 00335 printf("Formatting ( %.1f%% done )\n", percent); 00336 sleep(1); 00337 } 00338 burn_disc_get_profile(drive_list[0].drive, ¤t_profile, 00339 current_profile_name); 00340 printf("Media type now: %4.4xh \"%s\"\n", 00341 current_profile, current_profile_name); 00342 if (current_profile != 0x13) { 00343 fprintf(stderr, 00344 "FATAL: Failed to change media profile to desired value\n"); 00345 return 0; 00346 } 00347 return 1; 00348 }
int libburner_payload | ( | struct burn_drive * | drive, | |
char | source_adr[][4096], | |||
int | source_adr_count, | |||
int | multi, | |||
int | simulate_burn, | |||
int | all_tracks_type | |||
) |
Brings preformatted track images (ISO 9660, audio, .
..) onto media. To make sure a data image is fully readable on any Linux machine, this function adds 300 kiB of padding to the (usualy single) track. Audio tracks get padded to complete their last sector.
In case of external signals expect abort handling of an ongoing burn to last up to a minute. Wait the normal burning timespan before any kill -9.
For simplicity, this function allows memory leaks in case of failure. In apps which do not abort immediately, one should clean up better.
Definition at line 362 of file libburner.c.
References BURN_AUDIO, burn_disc_add_session(), BURN_DISC_APPENDABLE, BURN_DISC_BLANK, burn_disc_create(), BURN_DISC_EMPTY, burn_disc_erasable(), burn_disc_free(), BURN_DISC_FULL, burn_disc_get_status(), burn_disc_write(), burn_drive_get_status(), BURN_DRIVE_IDLE, burn_drive_set_speed(), BURN_DRIVE_SPAWNING, burn_fd_source_new(), BURN_MODE1, BURN_POS_END, BURN_REASONS_LEN, burn_session_add_track(), burn_session_create(), burn_session_free(), burn_source_free(), BURN_SOURCE_OK, burn_track_create(), burn_track_define_data(), burn_track_free(), burn_track_set_source(), BURN_WRITE_NONE, burn_write_opts_auto_write_type(), burn_write_opts_free(), burn_write_opts_new(), burn_write_opts_set_multi(), burn_write_opts_set_perform_opc(), burn_write_opts_set_simulate(), burn_write_opts_set_underrun_proof(), current_profile, burn_progress::sector, burn_progress::sectors, and burn_progress::track.
Referenced by main().
00365 { 00366 struct burn_source *data_src; 00367 struct burn_disc *target_disc; 00368 struct burn_session *session; 00369 struct burn_write_opts *burn_options; 00370 enum burn_disc_status disc_state; 00371 struct burn_track *track, *tracklist[99]; 00372 struct burn_progress progress; 00373 time_t start_time; 00374 int last_sector = 0, padding = 0, trackno, unpredicted_size = 0, fd; 00375 off_t fixed_size; 00376 char *adr, reasons[BURN_REASONS_LEN]; 00377 struct stat stbuf; 00378 00379 if (all_tracks_type != BURN_AUDIO) { 00380 all_tracks_type = BURN_MODE1; 00381 /* a padding of 300 kiB helps to avoid the read-ahead bug */ 00382 padding = 300*1024; 00383 } 00384 00385 target_disc = burn_disc_create(); 00386 session = burn_session_create(); 00387 burn_disc_add_session(target_disc, session, BURN_POS_END); 00388 00389 for (trackno = 0 ; trackno < source_adr_count; trackno++) { 00390 tracklist[trackno] = track = burn_track_create(); 00391 burn_track_define_data(track, 0, padding, 1, all_tracks_type); 00392 00393 adr = source_adr[trackno]; 00394 fixed_size = 0; 00395 if (adr[0] == '-' && adr[1] == 0) { 00396 fd = 0; 00397 } else { 00398 fd = open(adr, O_RDONLY); 00399 if (fd>=0) 00400 if (fstat(fd,&stbuf)!=-1) 00401 if((stbuf.st_mode&S_IFMT)==S_IFREG) 00402 fixed_size = stbuf.st_size; 00403 } 00404 if (fixed_size==0) 00405 unpredicted_size = 1; 00406 data_src = NULL; 00407 if (fd>=0) 00408 data_src = burn_fd_source_new(fd, -1, fixed_size); 00409 if (data_src == NULL) { 00410 fprintf(stderr, 00411 "FATAL: Could not open data source '%s'.\n",adr); 00412 if(errno!=0) 00413 fprintf(stderr,"(Most recent system error: %s )\n", 00414 strerror(errno)); 00415 return 0; 00416 } 00417 if (burn_track_set_source(track, data_src) != BURN_SOURCE_OK) { 00418 printf("FATAL: Cannot attach source object to track object\n"); 00419 return 0; 00420 } 00421 00422 burn_session_add_track(session, track, BURN_POS_END); 00423 printf("Track %d : source is '%s'\n", trackno+1, adr); 00424 burn_source_free(data_src); 00425 } /* trackno loop end */ 00426 00427 /* Evaluate drive and media */ 00428 disc_state = burn_disc_get_status(drive); 00429 if (disc_state != BURN_DISC_BLANK && 00430 disc_state != BURN_DISC_APPENDABLE) { 00431 if (disc_state == BURN_DISC_FULL) { 00432 fprintf(stderr, "FATAL: Closed media with data detected. Need blank or appendable media.\n"); 00433 if (burn_disc_erasable(drive)) 00434 fprintf(stderr, "HINT: Try --blank_fast\n\n"); 00435 } else if (disc_state == BURN_DISC_EMPTY) 00436 fprintf(stderr,"FATAL: No media detected in drive\n"); 00437 else 00438 fprintf(stderr, 00439 "FATAL: Cannot recognize state of drive and media\n"); 00440 return 0; 00441 } 00442 00443 burn_options = burn_write_opts_new(drive); 00444 burn_write_opts_set_perform_opc(burn_options, 0); 00445 burn_write_opts_set_multi(burn_options, !!multi); 00446 if(simulate_burn) 00447 printf("\n*** Will TRY to SIMULATE burning ***\n\n"); 00448 burn_write_opts_set_simulate(burn_options, simulate_burn); 00449 burn_drive_set_speed(drive, 0, 0); 00450 burn_write_opts_set_underrun_proof(burn_options, 1); 00451 if (burn_write_opts_auto_write_type(burn_options, target_disc, 00452 reasons, 0) == BURN_WRITE_NONE) { 00453 fprintf(stderr, "FATAL: Failed to find a suitable write mode with this media.\n"); 00454 fprintf(stderr, "Reasons given:\n%s\n", reasons); 00455 return 0; 00456 } 00457 00458 printf("Burning starts. With e.g. 4x media expect up to a minute of zero progress.\n"); 00459 start_time = time(0); 00460 burn_disc_write(burn_options, target_disc); 00461 00462 burn_write_opts_free(burn_options); 00463 while (burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING) 00464 usleep(1002); 00465 while (burn_drive_get_status(drive, &progress) != BURN_DRIVE_IDLE) { 00466 if( progress.sectors <= 0 || progress.sector == last_sector) 00467 printf( 00468 "Thank you for being patient since %d seconds.\n", 00469 (int) (time(0) - start_time)); 00470 else if(unpredicted_size) 00471 printf("Track %d : sector %d\n", progress.track+1, 00472 progress.sector); 00473 else 00474 printf("Track %d : sector %d of %d\n",progress.track+1, 00475 progress.sector, progress.sectors); 00476 last_sector = progress.sector; 00477 sleep(1); 00478 } 00479 printf("\n"); 00480 00481 for (trackno = 0 ; trackno < source_adr_count; trackno++) 00482 burn_track_free(tracklist[trackno]); 00483 burn_session_free(session); 00484 burn_disc_free(target_disc); 00485 if (multi && current_profile != 0x1a && current_profile != 0x13 && 00486 current_profile != 0x12) /* not with DVD+RW, DVD-RW, DVD-RAM */ 00487 printf("NOTE: Media left appendable.\n"); 00488 if (simulate_burn) 00489 printf("\n*** Did TRY to SIMULATE burning ***\n\n"); 00490 return 1; 00491 }
int libburner_setup | ( | int | argc, | |
char ** | argv | |||
) |
Converts command line arguments into above setup parameters.
Definition at line 507 of file libburner.c.
References all_tracks_type, BURN_AUDIO, BURN_DRIVE_ADR_LEN, do_blank, do_multi, drive_adr, driveno, simulate_burn, source_adr, and source_adr_count.
Referenced by main().
00508 { 00509 int i, insuffient_parameters = 0, print_help = 0; 00510 00511 for (i = 1; i < argc; ++i) { 00512 if (!strcmp(argv[i], "--audio")) { 00513 all_tracks_type = BURN_AUDIO; 00514 00515 } else if (!strcmp(argv[i], "--blank_fast")) { 00516 do_blank = 1; 00517 00518 } else if (!strcmp(argv[i], "--blank_full")) { 00519 do_blank = 2; 00520 00521 } else if (!strcmp(argv[i], "--burn_for_real")) { 00522 simulate_burn = 0; 00523 00524 } else if (!strcmp(argv[i], "--drive")) { 00525 ++i; 00526 if (i >= argc) { 00527 fprintf(stderr,"--drive requires an argument\n"); 00528 return 1; 00529 } else if (strcmp(argv[i], "-") == 0) { 00530 drive_adr[0] = 0; 00531 driveno = -1; 00532 } else if (isdigit(argv[i][0])) { 00533 drive_adr[0] = 0; 00534 driveno = atoi(argv[i]); 00535 } else { 00536 if(strlen(argv[i]) >= BURN_DRIVE_ADR_LEN) { 00537 fprintf(stderr,"--drive address too long (max. %d)\n", 00538 BURN_DRIVE_ADR_LEN-1); 00539 return 2; 00540 } 00541 strcpy(drive_adr, argv[i]); 00542 } 00543 } else if (!strcmp(argv[i], "--format_overwrite")) { 00544 do_blank = 101; 00545 00546 } else if (!strcmp(argv[i], "--multi")) { 00547 do_multi = 1; 00548 00549 } else if (!strcmp(argv[i], "--stdin_size")) { /* obsoleted */ 00550 i++; 00551 00552 } else if (!strcmp(argv[i], "--try_to_simulate")) { 00553 simulate_burn = 1; 00554 00555 } else if (!strcmp(argv[i], "--help")) { 00556 print_help = 1; 00557 00558 } else if (!strncmp(argv[i], "--",2)) { 00559 fprintf(stderr, "Unidentified option: %s\n", argv[i]); 00560 return 7; 00561 } else { 00562 if(strlen(argv[i]) >= 4096) { 00563 fprintf(stderr, "Source address too long (max. %d)\n", 4096-1); 00564 return 5; 00565 } 00566 if(source_adr_count >= 99) { 00567 fprintf(stderr, "Too many tracks (max. 99)\n"); 00568 return 6; 00569 } 00570 strcpy(source_adr[source_adr_count], argv[i]); 00571 source_adr_count++; 00572 } 00573 } 00574 insuffient_parameters = 1; 00575 if (driveno < 0) 00576 insuffient_parameters = 0; 00577 if (source_adr_count > 0) 00578 insuffient_parameters = 0; 00579 if (do_blank) 00580 insuffient_parameters = 0; 00581 if (print_help || insuffient_parameters ) { 00582 printf("Usage: %s\n", argv[0]); 00583 printf(" [--drive <address>|<driveno>|\"-\"] [--audio]\n"); 00584 printf(" [--blank_fast|--blank_full|--format_overwrite]\n"); 00585 printf(" [--try_to_simulate]\n"); 00586 printf(" [--multi] [<one or more imagefiles>|\"-\"]\n"); 00587 printf("Examples\n"); 00588 printf("A bus scan (needs rw-permissions to see a drive):\n"); 00589 printf(" %s --drive -\n",argv[0]); 00590 printf("Burn a file to drive chosen by number, leave appendable:\n"); 00591 printf(" %s --drive 0 --multi my_image_file\n", argv[0]); 00592 printf("Burn a file to drive chosen by persistent address, close:\n"); 00593 printf(" %s --drive /dev/hdc my_image_file\n", argv[0]); 00594 printf("Blank a used CD-RW (is combinable with burning in one run):\n"); 00595 printf(" %s --drive /dev/hdc --blank_fast\n",argv[0]); 00596 printf("Blank a used DVD-RW (is combinable with burning in one run):\n"); 00597 printf(" %s --drive /dev/hdc --blank_full\n",argv[0]); 00598 printf("Format a DVD-RW to avoid need for blanking before re-use:\n"); 00599 printf(" %s --drive /dev/hdc --format_overwrite\n", argv[0]); 00600 printf("Burn two audio tracks (to CD only):\n"); 00601 printf(" lame --decode -t /path/to/track1.mp3 track1.cd\n"); 00602 printf(" test/dewav /path/to/track2.wav -o track2.cd\n"); 00603 printf(" %s --drive /dev/hdc --audio track1.cd track2.cd\n", argv[0]); 00604 printf("Burn a compressed afio archive on-the-fly:\n"); 00605 printf(" ( cd my_directory ; find . -print | afio -oZ - ) | \\\n"); 00606 printf(" %s --drive /dev/hdc -\n", argv[0]); 00607 printf("To be read from *not mounted* media via: afio -tvZ /dev/hdc\n"); 00608 if (insuffient_parameters) 00609 return 6; 00610 } 00611 return 0; 00612 }
int main | ( | int | argc, | |
char ** | argv | |||
) |
Note: driveno might change its value in this call
Definition at line 615 of file libburner.c.
References all_tracks_type, burn_drive_release(), burn_finish(), burn_initialize(), burn_msgs_set_severities(), burn_set_signal_handling(), do_blank, do_multi, drive_adr, drive_is_grabbed, drive_list, driveno, libburner_aquire_drive(), libburner_blank_disc(), libburner_format_row(), libburner_payload(), libburner_setup(), simulate_burn, source_adr, and source_adr_count.
00616 { 00617 int ret; 00618 00619 ret = libburner_setup(argc, argv); 00620 if (ret) 00621 exit(ret); 00622 00623 printf("Initializing libburnia.pykix.org ...\n"); 00624 if (burn_initialize()) 00625 printf("Done\n"); 00626 else { 00627 printf("FAILED\n"); 00628 fprintf(stderr,"\nFATAL: Failed to initialize.\n"); 00629 exit(33); 00630 } 00631 00632 /* Print messages of severity SORRY or more directly to stderr */ 00633 burn_msgs_set_severities("NEVER", "SORRY", "libburner : "); 00634 00635 /* Activate the default signal handler which eventually will try to 00636 properly shutdown drive and library on aborting events. */ 00637 burn_set_signal_handling("libburner : ", NULL, 0); 00638 00639 /** Note: driveno might change its value in this call */ 00640 ret = libburner_aquire_drive(drive_adr, &driveno); 00641 if (ret<=0) { 00642 fprintf(stderr,"\nFATAL: Failed to aquire drive.\n"); 00643 { ret = 34; goto finish_libburn; } 00644 } 00645 if (ret == 2) 00646 { ret = 0; goto release_drive; } 00647 if (do_blank) { 00648 if (do_blank > 100) 00649 ret = libburner_format_row(drive_list[driveno].drive); 00650 else 00651 ret = libburner_blank_disc(drive_list[driveno].drive, 00652 do_blank == 1); 00653 if (ret<=0) 00654 { ret = 36; goto release_drive; } 00655 } 00656 if (source_adr_count > 0) { 00657 ret = libburner_payload(drive_list[driveno].drive, 00658 source_adr, source_adr_count, 00659 do_multi, simulate_burn, all_tracks_type); 00660 if (ret<=0) 00661 { ret = 38; goto release_drive; } 00662 } 00663 ret = 0; 00664 release_drive:; 00665 if (drive_is_grabbed) 00666 burn_drive_release(drive_list[driveno].drive, 0); 00667 00668 finish_libburn:; 00669 /* This app does not bother to know about exact scan state. 00670 Better to accept a memory leak here. We are done anyway. */ 00671 /* burn_drive_info_free(drive_list); */ 00672 00673 burn_finish(); 00674 exit(ret); 00675 }
int all_tracks_type = BURN_MODE1 [static] |
int current_profile = -1 [static] |
A number and a text describing the type of media in aquired drive.
Definition at line 76 of file libburner.c.
Referenced by libburner_aquire_drive(), libburner_blank_disc(), libburner_format_row(), and libburner_payload().
char current_profile_name[80] = {""} [static] |
Definition at line 77 of file libburner.c.
Referenced by libburner_aquire_drive(), and libburner_format_row().
int do_blank = 0 [static] |
int do_multi = 0 [static] |
char drive_adr[BURN_DRIVE_ADR_LEN] = {""} [static] |
The setup parameters of libburner.
Definition at line 495 of file libburner.c.
Referenced by libburner_setup(), and main().
unsigned int drive_count [static] |
If you start a long lasting operation with drive_count > 1 then you are not friendly to the users of other drives on those systems.
Beware.
Definition at line 69 of file libburner.c.
Referenced by libburner_aquire_by_driveno().
int drive_is_grabbed = 0 [static] |
This variable indicates wether the drive is grabbed and must be finally released.
Definition at line 73 of file libburner.c.
Referenced by libburner_aquire_by_adr(), libburner_aquire_by_driveno(), and main().
struct burn_drive_info* drive_list [static] |
This list will hold the drives known to libburn.
This might be all CD drives of the system and thus might impose severe impact on the system.
Definition at line 65 of file libburner.c.
Referenced by libburner_aquire_by_adr(), libburner_aquire_by_driveno(), libburner_aquire_drive(), libburner_format_row(), and main().
int driveno = 0 [static] |
int simulate_burn = 0 [static] |
char source_adr[99][4096] [static] |
int source_adr_count = 0 [static] |