Implemented core of option -toc

This commit is contained in:
Thomas Schmitt 2007-10-17 18:30:37 +00:00
parent 97b8b45483
commit c7c4499411
5 changed files with 135 additions and 4 deletions

View File

@ -4305,8 +4305,10 @@ int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag)
/* Option -toc */ /* Option -toc */
int Xorriso_option_toc(struct XorrisO *xorriso, int flag) int Xorriso_option_toc(struct XorrisO *xorriso, int flag)
{ {
fprintf(stderr, ">>> LIBISOBURN : -toc\n"); int ret;
return(1);
ret= Xorriso_toc(xorriso, 0);
return(ret);
} }

View File

@ -167,8 +167,13 @@ struct XorrisO { /* the global context of xorriso */
int Xorriso_destroy(struct XorrisO **xorriso, int flag); int Xorriso_destroy(struct XorrisO **xorriso, int flag);
int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag); int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag);
int Xorriso_result(struct XorrisO *xorriso, int flag);
int Xorriso_info(struct XorrisO *xorriso, int flag); int Xorriso_info(struct XorrisO *xorriso, int flag);
int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv, int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
int flag); int flag);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.10.17.165352" #define Xorriso_timestamP "2007.10.17.183024"

View File

@ -302,7 +302,6 @@ int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
struct burn_progress progress; struct burn_progress progress;
char *status_text; char *status_text;
while(burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING) while(burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING)
usleep(100002); usleep(100002);
@ -500,3 +499,125 @@ int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag)
return(1); return(1);
} }
int Xorriso_toc(struct XorrisO *xorriso, int flag)
{
int num_sessions= 0 , num_tracks= 0 , lba= 0, nwa, pmin, psec, pframe, ret;
int track_count= 0, session_no, track_no, profile_no= -1;
int last_track_start= 0, last_track_size= -1;
char profile_name[80],*respt;
struct burn_disc *disc= NULL;
struct burn_session **sessions;
struct burn_track **tracks;
struct burn_toc_entry toc_entry;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
enum burn_disc_status s;
dinfo= (struct burn_drive_info *) xorriso->in_drive_handle;
if(dinfo==NULL) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,
"No drive aquired on attempt to print Table Of Content");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
drive= dinfo[0].drive;
respt= xorriso->result_line;
sprintf(respt, "Media current: ");
ret= burn_disc_get_profile(drive, &profile_no, profile_name);
if (profile_no > 0 && ret > 0) {
if (profile_name[0])
sprintf(respt+strlen(respt), "%s\n", profile_name);
else
sprintf(respt+strlen(respt), "%4.4Xh\n", profile_no);
} else
sprintf(respt+strlen(respt), "is not recognizable\n");
Xorriso_result(xorriso,0);
sprintf(respt, "Media status : ");
s= isoburn_disc_get_status(drive);
if (s == BURN_DISC_FULL) {
sprintf(respt+strlen(respt), "is written , is closed\n");
} else if (s == BURN_DISC_APPENDABLE) {
sprintf(respt+strlen(respt), "is written , is appendable\n");
} else if (s == BURN_DISC_BLANK) {
sprintf(respt+strlen(respt), "is blank\n");
} else if (s == BURN_DISC_EMPTY)
sprintf(respt+strlen(respt), "is not present\n");
else
sprintf(respt+strlen(respt), "is not recognizable\n");
Xorriso_result(xorriso,0);
if(s != BURN_DISC_FULL && s!= BURN_DISC_APPENDABLE)
return(1);
disc= burn_drive_get_disc(drive);
if (disc==NULL) {
Xorriso_process_msg_queues(xorriso,0);
ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa);
if(ret<=0) {
sprintf(xorriso->info_text, "Cannot obtain Table Of Content");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
/* fabricate TOC */
sprintf(respt, "Media content: session %2d ", 1);
sprintf(respt+strlen(respt), "track %2d %s lba: %9d\n", 1, "data ", 0);
Xorriso_result(xorriso,0);
last_track_start= lba;
sprintf(respt, "Media content: session %2d ", 1);
sprintf(respt+strlen(respt), "leadout lba: %9d\n", nwa);
Xorriso_result(xorriso,0);
last_track_size= nwa;
} else {
sessions= burn_disc_get_sessions(disc, &num_sessions);
for (session_no= 0; session_no<num_sessions; session_no++) {
tracks = burn_session_get_tracks(sessions[session_no], &num_tracks);
if (tracks==NULL)
continue;
for(track_no= 0; track_no<num_tracks; track_no++) {
track_count++;
burn_track_get_entry(tracks[track_no], &toc_entry);
if (toc_entry.extensions_valid & 1) {
/* DVD extension valid */
lba= toc_entry.start_lba;
} else {
lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, toc_entry.pframe);
}
sprintf(respt, "Media content: session %2d ", session_no+1);
sprintf(respt+strlen(respt), "track %2d %s lba: %9d\n",
track_count, ((toc_entry.control&7)<4?"audio":"data "), lba);
Xorriso_result(xorriso,0);
last_track_start= lba;
}
burn_session_get_leadout_entry(sessions[session_no], &toc_entry);
if (toc_entry.extensions_valid & 1) {
lba= toc_entry.start_lba;
burn_lba_to_msf(lba, &pmin, &psec, &pframe);
} else {
lba= burn_msf_to_lba(pmin, psec, pframe);
lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, toc_entry.pframe);
}
sprintf(respt, "Media content: session %2d ", session_no+1);
Xorriso_result(xorriso,0);
sprintf(respt, "leadout lba: %9d\n", lba);
Xorriso_result(xorriso,0);
last_track_size= lba - last_track_start;
}
}
if (s == BURN_DISC_APPENDABLE) {
/* >>> tell nwa */;
}
if (disc!=NULL)
burn_disc_free(disc);
Xorriso_process_msg_queues(xorriso,0);
return(1);
}

View File

@ -33,5 +33,8 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
int Xorriso__text_to_sev(char *severity_name, int *severity_number,int flag); int Xorriso__text_to_sev(char *severity_name, int *severity_number,int flag);
int Xorriso_toc(struct XorrisO *xorriso, int flag);
#endif /* Xorrisoburn_includeD */ #endif /* Xorrisoburn_includeD */