Supporting option -as cdrecord -waiti

This commit is contained in:
Thomas Schmitt 2008-07-04 06:59:31 +00:00
parent c9f3aefcf7
commit 73a02c1a07
2 changed files with 52 additions and 6 deletions

View File

@ -1388,6 +1388,30 @@ single_letters:;
} }
int Wait_for_input(int fd, int microsec, int flag)
{
struct timeval wt;
fd_set rds,wts,exs;
int ready;
FD_ZERO(&rds);
FD_ZERO(&wts);
FD_ZERO(&exs);
FD_SET(fd,&rds);
FD_SET(fd,&exs);
wt.tv_sec= microsec/1000000;
wt.tv_usec= microsec%1000000;
ready= select(fd+1,&rds,&wts,&exs,&wt);
if(ready<=0)
return(0);
if(FD_ISSET(fd,&exs))
return(-1);
if(FD_ISSET(fd,&rds))
return(1);
return(0);
}
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -7030,7 +7054,7 @@ int Xorriso_cdrskin(struct XorrisO *xorriso, char *whom, int argc, char **argv,
{ {
int ret, i, k, mem_do_close, aq_ret, eject_ret; int ret, i, k, mem_do_close, aq_ret, eject_ret;
int do_atip= 0, do_checkdrive= 0, do_eject= 0, do_scanbus= 0; int do_atip= 0, do_checkdrive= 0, do_eject= 0, do_scanbus= 0;
int do_toc= 0, do_verbous= 0, do_version= 0, do_help= 0; int do_toc= 0, do_verbous= 0, do_version= 0, do_help= 0, do_waiti= 0;
char track_source[SfileadrL], sfe[5*SfileadrL], dev_adr[SfileadrL], *cpt; char track_source[SfileadrL], sfe[5*SfileadrL], dev_adr[SfileadrL], *cpt;
char mem_report_about_text[80], *report_about= "SORRY", blank_mode[80]; char mem_report_about_text[80], *report_about= "SORRY", blank_mode[80];
char speed[80]; char speed[80];
@ -7062,7 +7086,7 @@ int Xorriso_cdrskin(struct XorrisO *xorriso, char *whom, int argc, char **argv,
"-scms", "-shorttrack", "-noshorttrack", "-packet", "-noclose", "-scms", "-shorttrack", "-noshorttrack", "-packet", "-noclose",
"-media-info", "-minfo", "-media-info", "-minfo",
"-isosize", "-load", "-lock", "-raw96r", "-sao", "-dao", "-swab", "-isosize", "-load", "-lock", "-raw96r", "-sao", "-dao", "-swab",
"-tao", "-waiti", "-force", "-format", "-tao", "-force", "-format",
"--adjust_speed_to_drive", "--allow_emulated_drives", "--allow_setuid", "--adjust_speed_to_drive", "--allow_emulated_drives", "--allow_setuid",
"--allow_untested_media", "--any_track", "--demand_a_drive", "--allow_untested_media", "--any_track", "--demand_a_drive",
@ -7091,6 +7115,7 @@ int Xorriso_cdrskin(struct XorrisO *xorriso, char *whom, int argc, char **argv,
"\t-eject\t\teject the disk after doing the work", "\t-eject\t\teject the disk after doing the work",
"\t-toc\t\tretrieve and print TOC/PMA data", "\t-toc\t\tretrieve and print TOC/PMA data",
"\t-atip\t\tretrieve media state, print \"Is *erasable\"", "\t-atip\t\tretrieve media state, print \"Is *erasable\"",
"\t-waiti\t\twait until input is available before opening SCSI",
"\tpadsize=#\tAmount of padding", "\tpadsize=#\tAmount of padding",
"\t-data\t\tSubsequent tracks are CD-ROM data mode 1 (default)", "\t-data\t\tSubsequent tracks are CD-ROM data mode 1 (default)",
"\t-pad\t\tpadsize=30k", "\t-pad\t\tpadsize=30k",
@ -7196,9 +7221,7 @@ no_volunteer:;
} else if(strncmp(argv[i], "-dev=", 5)==0 || } else if(strncmp(argv[i], "-dev=", 5)==0 ||
strncmp(argv[i], "dev=", 4)==0) { strncmp(argv[i], "dev=", 4)==0) {
cpt= strchr(argv[i], '=')+1; cpt= strchr(argv[i], '=')+1;
ret= Xorriso_option_dev(xorriso, cpt, 2|8); /* overwriteables as blank */ strcpy(dev_adr, cpt);
if(ret<=0)
goto ex;
} else if(strncmp(argv[i],"driveropts=", 11)==0 || } else if(strncmp(argv[i],"driveropts=", 11)==0 ||
strncmp(argv[i],"-driveropts=", 12)==0) { strncmp(argv[i],"-driveropts=", 12)==0) {
if(strcmp(argv[i]+11, "help")==0) { if(strcmp(argv[i]+11, "help")==0) {
@ -7265,6 +7288,8 @@ no_volunteer:;
do_verbous+= 3; do_verbous+= 3;
} else if(strcmp(argv[i], "-version")==0) { } else if(strcmp(argv[i], "-version")==0) {
do_version= 1; do_version= 1;
} else if(strcmp(argv[i], "-waiti")==0) {
do_waiti= 1;
} else if(strcmp(argv[i], "-help")==0) { } else if(strcmp(argv[i], "-help")==0) {
do_help= 1; do_help= 1;
} else if(argv[i][0]=='-' && argv[i][1]!=0) { } else if(argv[i][0]=='-' && argv[i][1]!=0) {
@ -7295,6 +7320,26 @@ no_volunteer:;
Xorriso_option_version(xorriso, 0); Xorriso_option_version(xorriso, 0);
ret= 1; goto ex; ret= 1; goto ex;
} }
if(do_waiti) {
sprintf(xorriso->info_text,
"xorriso: Option -waiti pauses program until input appears at stdin\n");
Xorriso_info(xorriso,0);
sprintf(xorriso->result_line, "Waiting for data on stdin...\n");
Xorriso_result(xorriso, 1);
for(ret= 0; ret==0; )
ret= Wait_for_input(0,1000000,0);
if(ret<0 || feof(stdin)) {
Xorriso_msgs_submit(xorriso, 0,
"stdin produces exception rather than data", 0, "NOTE", 0);
}
sprintf(xorriso->info_text, "xorriso: Option -waiti pausing is done.\n");
}
if(dev_adr[0]) {
ret= Xorriso_option_dev(xorriso, dev_adr, 2|8); /* overwriteables as blank */
if(ret<=0)
goto ex;
}
if(do_help) { if(do_help) {
for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) { for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) {
sprintf(xorriso->info_text, "%s\n", helptext[i]); sprintf(xorriso->info_text, "%s\n", helptext[i]);
@ -7326,6 +7371,7 @@ no_volunteer:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex; ret= 0; goto ex;
} }
if(speed[0]) { if(speed[0]) {
ret= Xorriso_option_speed(xorriso, speed, 0); ret= Xorriso_option_speed(xorriso, speed, 0);
if(ret<=0) if(ret<=0)

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.07.03.133023" #define Xorriso_timestamP "2008.07.04.070001"