Now loading libraries before -version, pacifier for -add

master
Thomas Schmitt 15 years ago
parent e947087b0d
commit e24cfbbe9c

@ -193,6 +193,26 @@ LIBBURN_MISCONFIGURATION_ = 0;
}
/* API @since 0.1.0 */
int isoburn_libisofs_req(int *major, int *minor, int *micro)
{
*major= iso_lib_header_version_major;
*minor= iso_lib_header_version_minor;
*micro= iso_lib_header_version_micro;
return(1);
}
/* API @since 0.1.0 */
int isoburn_libburn_req(int *major, int *minor, int *micro)
{
*major= burn_header_version_major;
*minor= burn_header_version_minor;
*micro= burn_header_version_micro;
return(1);
}
/** Examine the media and sets appropriate emulation if needed.
*/
static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,

@ -160,17 +160,37 @@ int isoburn_is_compatible(int major, int minor, int micro, int flag);
void isoburn_version(int *major, int *minor, int *micro);
/** The minimum version of libisofs to be used with this version of libisoburn
at compile time.
*/
#define isoburn_libisofs_req_major 0
#define isoburn_libisofs_req_minor 6
#define isoburn_libisofs_req_micro 1
/** The minimum version of libburn to be used with this version of libisoburn
at compile time.
*/
#define isoburn_libburn_req_major 0
#define isoburn_libburn_req_minor 4
#define isoburn_libburn_req_micro 2
/** The minimum version of libisofs to be used with this version of libisoburn
at runtime. This is checked already in isoburn_initialize() which will
refuse on outdated version. So this call is for information purposes after
successful startup only.
*/
int isoburn_libisofs_req(int *major, int *minor, int *micro);
/** The minimum version of libburn to be used with this version of libisoburn
at runtime. This is checked already in isoburn_initialize() which will
refuse on outdated version. So this call is for information purposes after
successful startup only.
*/
int isoburn_libburn_req(int *major, int *minor, int *micro);
/** These three release version numbers tell the revision of this header file
and of the API it describes. They are memorized by applications at build
time.

@ -2920,6 +2920,11 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->insert_count= 0;
m->insert_bytes= 0;
m->error_count= 0;
m->pacifier_interval= 1.0;
m->pacifier_count= 0;
m->pacifier_total= 0;
m->start_time= 0.0;
m->last_update_time= 0.0;
m->result_line[0]= 0;
m->result_line_counter= 0;
m->result_page_counter= 0;
@ -3356,14 +3361,67 @@ int Xorriso_restxt(struct XorrisO *xorriso, char *text)
}
int Xorriso_reset_counters(struct XorrisO *xorriso, int flag)
/*
bit0= reset xorriso->found to -1
int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag)
{
xorriso->start_time= Sfile_microtime(0);
xorriso->last_update_time= xorriso->start_time;
xorriso->pacifier_count= 0;
xorriso->pacifier_total= 0;
return(1);
}
/* This call is to be issued by long running workers in short intervals.
It will check whether enough time has elapsed since the last pacifier
message and eventually issue an update message.
@param what_done A sparse description of the action, preferrably in past
tense. E.g. "done" , "files added".
@param count The number of objects processed so far.
Is ignored if <=0.
@param todo The number of objects to be done in total.
Is ignored if <=0.
@param current_object A string telling the object currently processed.
Ignored if "".
@param flag Bitfield. Unused yet. Submit 0.
*/
int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done,
off_t count, off_t todo, char *current_object,
int flag)
{
double current_time, since;
current_time= Sfile_microtime(0);
if(current_time - xorriso->last_update_time < xorriso->pacifier_interval)
return(1);
xorriso->last_update_time= Sfile_microtime(0);
since= current_time - xorriso->start_time;
if(count<=0.0) {
if(current_object[0]==0)
sprintf(xorriso->info_text,
"%s since %.f seconds", what_done, since);
else
sprintf(xorriso->info_text,
"Thank you for being patient since %.f seconds", since);
} else if(todo<=0.0) {
sprintf(xorriso->info_text,
"%.f %s in %.f seconds", (double) count, what_done, since);
} else {
sprintf(xorriso->info_text, "%.f of %.f %s in %.f seconds",
(double) count, (double) todo, what_done, since);
}
if(current_object[0]!=0)
sprintf(xorriso->info_text+strlen(xorriso->info_text),
", now at %s", current_object);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
return(1);
}
int Xorriso_reset_counters(struct XorrisO *xorriso, int flag)
{
xorriso->error_count= 0;
xorriso->insert_count= 0;
xorriso->insert_bytes= 0;
Xorriso_pacifier_reset(xorriso, 0);
return(1);
}
@ -6012,7 +6070,9 @@ int Xorriso_option_abort_on(struct XorrisO *xorriso, char *severity, int flag)
/* Option -add */
/* @param flag bit0=do not report the added item */
/* @param flag bit0=do not report the added item
bit1=do not reset pacifier
*/
int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag)
{
@ -6025,6 +6085,8 @@ int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv,
if(ret<=0)
goto ex;
if(!(flag&2))
Xorriso_pacifier_reset(xorriso, 0);
for(i= 0; i<optc; i++) {
if(Sfile_str(target,optv[i],0)<=0)
{ret= -1; goto ex;}
@ -6609,7 +6671,9 @@ int Xorriso_option_cpri(struct XorrisO *xorriso, int argc, char **argv,
is_dir= 1;
strcpy(dest_dir, eff_dest);
}
/* Perform graft-ins */
Xorriso_pacifier_reset(xorriso, 0);
for(i= 0; i<optc && !xorriso->request_to_abort; i++) {
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, optv[i], eff_origin,
2|4);
@ -7300,6 +7364,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Give up any unejected drive afterwards.",
" -close \"on\"|\"off\"",
" If \"on\" then mark the written media as not appendable.",
" -padding number[\"k\"|\"m\"]",
" Append extra bytes to image stream. (Default is 300k)",
" -dummy \"on\"|\"off\"",
" If \"on\" simulate burning. Refuse if media cannot simulate.",
" -speed number[\"k\"|\"m\"|\"[x]CD\"|\"[x]DVD\"]",
@ -7855,7 +7921,7 @@ problem_handler:;
goto ex;
}
ex:;
Xorriso_reset_counters(xorriso,1);
Xorriso_reset_counters(xorriso,0);
if(fp!=NULL)
fclose(fp);
if(ret<=0) {
@ -7930,6 +7996,7 @@ int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag)
FILE *fp= NULL;
char *argpt, sfe[5*SfileadrL],line[SfileadrL];
Xorriso_pacifier_reset(xorriso, 0);
if(adr[0]==0) {
sprintf(xorriso->info_text,"Empty file name given with -path-list");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
@ -7950,7 +8017,7 @@ int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag)
continue;
argpt= line;
null= 0;
ret= Xorriso_option_add(xorriso, 1, &argpt, &null, 1);
ret= Xorriso_option_add(xorriso, 1, &argpt, &null, 1|2);
if(ret<=0 || xorriso->request_to_abort)
goto problem_handler;
insertcount++;
@ -8412,11 +8479,15 @@ int Xorriso_option_version(struct XorrisO *xorriso, int flag)
"xorriso %s : RockRidge filesystem manipulator\n", PROG_VERSION);
sprintf(xorriso->result_line+strlen(xorriso->result_line),
"Copyright (C) 2008, Thomas Schmitt <scdbackup@gmx.net>, libburnia project\n");
Xorriso_result(xorriso, 0);
sprintf(xorriso->result_line,
"xorriso version : %s\n", PROG_VERSION);
sprintf(xorriso->result_line+strlen(xorriso->result_line),
"Version timestamp : %s\n",Xorriso_timestamP);
sprintf(xorriso->result_line+strlen(xorriso->result_line),
"Build timestamp : %s\n",Xorriso_build_timestamP);
Xorriso_result(xorriso, 0);
Xorriso_report_lib_versions(xorriso, 0);
return(1);
}
@ -8917,7 +8988,7 @@ int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag)
struct timezone tz;
gettimeofday(&tv,&tz);
Xorriso_reset_counters(xorriso,1);
Xorriso_reset_counters(xorriso,0);
xorriso->idle_time= 0.0;
tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec);
@ -8951,7 +9022,7 @@ int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag)
Xorriso_info(xorriso,0);
xorriso->bar_is_fresh= 1;
}
Xorriso_reset_counters(xorriso,1);
Xorriso_reset_counters(xorriso,0);
ex:;
Sfile_make_argv("", "", &argc, &argv, 2); /* release memory */
return(ret);
@ -9048,10 +9119,14 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
Xorriso_option_help(xorriso,0);
xorriso->did_something_useful= 1;
return(0);
#ifdef NIX
} else if(strcmp(cmd,"version")==0) {
Xorriso_option_version(xorriso, 0);
xorriso->did_something_useful= 1;
return(0);
#endif
}
} else if(i==1 && strcmp(cmd,"no_rc")==0) {
ret= Xorriso_option_no_rc(xorriso, 0);
@ -9152,8 +9227,7 @@ int Xorriso_main(int argc, char **argv)
}
/* The prescan of arguments performs actions which have to happen before
the normal processing of startup files and arguments. Currently:
-no_rc and single-argument runs like -help or -version.
the normal processing of startup files and arguments.
*/
ret= Xorriso_prescan_args(xorriso,argc,argv,0);
if(ret==0)

@ -178,6 +178,14 @@ struct XorrisO { /* the global context of xorriso */
double insert_bytes;
double error_count; /* double will not roll over */
/* pacifiers */
double pacifier_interval;
double start_time;
double last_update_time;
/* optional global counters for brain reduced callback functions */
off_t pacifier_count;
off_t pacifier_total;
/* result (stdout, R: ) */
char result_line[5*SfileadrL];
int result_line_counter;
@ -271,6 +279,24 @@ int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag);
int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free,
int flag);
int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag);
/* This call is to be issued by long running workers in short intervals.
It will check whether enough time has elapsed since the last pacifier
message and eventually issue an update message.
@param what_done A sparse description of the action, preferrably in past
tense. E.g. "done" , "files added".
@param count The number of objects processed so far.
Is ignored if <=0.
@param todo The number of objects to be done in total.
Is ignored if <=0.
@param current_object A string telling the object currently processed.
Ignored if "".
@param flag Bitfield. Unused yet. Submit 0.
*/
int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done,
off_t count, off_t todo, char *current_object,
int flag);
int Sfile_str(char target[SfileadrL], char *source, int flag);

@ -1 +1 @@
#define Xorriso_timestamP "2008.02.05.191456"
#define Xorriso_timestamP "2008.02.06.131028"

@ -291,12 +291,13 @@ int Xorriso__sev_to_text(int severity, char **severity_name,
/* @param flag bit0=report libisofs error text */
int Xorriso_report_iso_error(struct XorrisO *xorriso,
int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim,
int iso_error_code, char msg_text[], int os_errno,
char min_severity[], int flag)
{
int error_code, iso_sev, min_sev, ret;
char *sev_text_pt, *msg_text_pt= NULL;
char sfe[6*SfileadrL];
error_code= 0x00050000;
@ -315,8 +316,12 @@ int Xorriso_report_iso_error(struct XorrisO *xorriso,
if(min_sev < iso_sev)
/* >>> with libburn-0.4.4 do: burn_sev_to_text(iso_sev, &sev_text_pt, 0); */
Xorriso__sev_to_text(iso_sev, &sev_text_pt, 0);
ret= Xorriso_msgs_submit(xorriso, error_code, msg_text_pt,
os_errno, sev_text_pt, 0);
strcpy(sfe, msg_text_pt);
if(victim[0]) {
strcat(sfe, ": ");
Text_shellsafe(victim, sfe+strlen(sfe), 0);
}
ret= Xorriso_msgs_submit(xorriso, error_code, sfe, os_errno, sev_text_pt, 0);
return(ret);
}
@ -384,7 +389,8 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
isoburn_ropt_destroy(&ropts, 0);
if(ret<=0) {
sprintf(xorriso->info_text, "Failed to create new empty ISO image object");
Xorriso_report_iso_error(xorriso, ret, xorriso->info_text, 0, "FATAL", 0);
Xorriso_report_iso_error(xorriso, "", ret, xorriso->info_text, 0, "FATAL",
0);
return(-1);
}
xorriso->in_volset_handle= (void *) volset;
@ -868,6 +874,9 @@ ex:;
}
/* This loop watches burn runs until they end.
It issues pacifying update messages to the user.
*/
int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
int flag)
{
@ -1115,7 +1124,7 @@ int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir,
int ret, target_is_dir, source_is_dir, source_is_link, fret, was_failure= 0;
int do_not_dive;
struct DirseQ *dirseq= NULL;
char *name, *img_name, *srcpt;
char *name, *img_name, *srcpt, *stbuf_src= "";
struct stat stbuf, hstbuf;
dev_t dir_dev;
struct LinkiteM *own_link_stack;
@ -1148,12 +1157,14 @@ int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir,
if(ret<=0)
goto ex;
stbuf_src= disk_dir_path;
if(lstat(disk_dir_path, &stbuf)==-1)
goto cannot_open_dir;
dir_dev= stbuf.st_dev;
if(S_ISLNK(stbuf.st_mode)) {
if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1))))
{ret= 2; goto ex;}
stbuf_src= disk_dir_path;
if(stat(disk_dir_path, &stbuf)==-1)
goto cannot_open_dir;
if(dir_dev != stbuf.st_dev &&
@ -1186,6 +1197,7 @@ cannot_open_dir:;
img_name= img_path+strlen(img_path);
while(1) { /* loop over directory content */
stbuf_src= "";
Linkitem_reset_stack(&own_link_stack, link_stack, 0);
srcpt= disk_path;
Xorriso_process_msg_queues(xorriso,0);
@ -1202,6 +1214,7 @@ cannot_open_dir:;
{ret= 0; goto was_problem;}
if(Xorriso_much_too_long(xorriso, strlen(srcpt), 0)<=0)
{ret= 0; goto was_problem;}
stbuf_src= srcpt;
if(lstat(srcpt, &stbuf)==-1) {
cannot_lstat:;
sprintf(xorriso->info_text,
@ -1222,6 +1235,7 @@ cannot_lstat:;
if(ret<=0)
goto was_problem;
srcpt= link_target;
stbuf_src= srcpt;
if(lstat(srcpt, &stbuf)==-1)
goto cannot_lstat;
} else {
@ -1295,15 +1309,15 @@ cannot_lstat:;
if(ret<=0)
goto was_problem;
} else {
Xorriso_report_iso_error(xorriso, ret, "Cannot create symbolic link",
0, "SORRY", 1);
Xorriso_report_iso_error(xorriso, stbuf_src, ret,
"Cannot create symbolic link", 0, "SORRY", 1);
{ret= 0; goto was_problem;}
}
} else {
ret= iso_tree_add_node(volume, dir, srcpt, &node);
if(ret<0) {
Xorriso_report_iso_error(xorriso, ret, "Cannot add node to tree",
0, "SORRY", 1);
Xorriso_report_iso_error(xorriso, stbuf_src, ret,
"Cannot add node to tree", 0, "SORRY", 1);
goto was_problem;
}
}
@ -1315,6 +1329,12 @@ cannot_lstat:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret=0; goto was_problem;
}
xorriso->pacifier_count++;
if(xorriso->pacifier_count%100)
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
xorriso->pacifier_total, "", 0);
xorriso->volset_change_pending= 1;
if(source_is_dir) {
if(do_not_dive) {
@ -1501,8 +1521,8 @@ handle_path_node:;
ret= iso_tree_add_new_dir(dir, apt, &hdir);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, ret, "Cannot create directory",
0, "SORRY", 1);
Xorriso_report_iso_error(xorriso, img_path, ret,
"Cannot create directory", 0, "SORRY", 1);
sprintf(xorriso->info_text,
"While grafting '%s' : could not insert '%s'", img_path, path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
@ -1520,6 +1540,11 @@ handle_path_node:;
}
if(done) {
attach_source:;
xorriso->pacifier_count++;
if(xorriso->pacifier_count%100)
Xorriso_pacifier_callback(xorriso, "files added",
xorriso->pacifier_count,
xorriso->pacifier_total, "", 0);
if(flag&1) {
/* directory node was created above */;
@ -1533,7 +1558,7 @@ attach_source:;
ret= iso_tree_add_node(volume, dir, disk_path, &node);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, ret, "Cannot create node",
Xorriso_report_iso_error(xorriso, img_path, ret, "Cannot create node",
0, "SORRY", 1);
sprintf(xorriso->info_text, "Grafting failed: %s = %s",
Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0));
@ -2011,7 +2036,7 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag)
{
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, iso_error, "Cannot create iter", 0,
Xorriso_report_iso_error(xorriso, "", iso_error, "Cannot create iter", 0,
"FATAL", 1);
sprintf(xorriso->info_text, "Cannot create IsoDirIter object");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
@ -2207,7 +2232,8 @@ dir_not_removed:;
ret= iso_node_remove(victim_node);
Xorriso_process_msg_queues(xorriso,0);
if(ret<0) {
Xorriso_report_iso_error(xorriso, ret, "Cannot remove node", 0, "FATAL", 1);
Xorriso_report_iso_error(xorriso, path, ret, "Cannot remove node", 0,
"FATAL", 1);
sprintf(xorriso->info_text,
"Internal failure to remove %s from loaded ISO image",
Text_shellsafe(path, sfe, 0));
@ -2926,7 +2952,7 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
ret= iso_node_take(node);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, 0, "Cannot take", 0, "FATAL", 1);
Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot take", 0, "FATAL",1);
sprintf(xorriso->info_text,
"Internal error on rename: failed to take node");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
@ -2935,7 +2961,7 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
ret= iso_dir_add_node(dest_dir, node, 0);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, 0, "Cannot add", 0, "FATAL", 1);
Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot add", 0, "FATAL", 1);
sprintf(xorriso->info_text,
"Internal error on rename: failed to insert node");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
@ -2954,7 +2980,8 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
ret= 1;
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, 0, "Cannot set name", 0, "FATAL", 1);
Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot set name", 0,
"FATAL", 1);
sprintf(xorriso->info_text, "Internal error on rename: failed to set name");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
@ -3494,3 +3521,31 @@ int Xorriso_set_abort_severity(struct XorrisO *xorriso, int flag)
return(ret>=0);
}
int Xorriso_report_lib_versions(struct XorrisO *xorriso, int flag)
{
int major, minor, micro;
int req_major, req_minor, req_micro;
iso_lib_version(&major, &minor, &micro);
isoburn_libisofs_req(&req_major, &req_minor, &req_micro);
sprintf(xorriso->result_line,
"libisofs in use : %d.%d.%d (min. %d.%d.%d)\n",
major, minor, micro, req_major, req_minor, req_micro);
Xorriso_result(xorriso, 0);
burn_version(&major, &minor, &micro);
isoburn_libburn_req(&req_major, &req_minor, &req_micro);
sprintf(xorriso->result_line,
"libburn in use : %d.%d.%d (min. %d.%d.%d)\n",
major, minor, micro, req_major, req_minor, req_micro);
Xorriso_result(xorriso, 0);
isoburn_version(&major, &minor, &micro);
sprintf(xorriso->result_line,
"libisoburn in use : %d.%d.%d (min. %d.%d.%d)\n",
major, minor, micro,
isoburn_header_version_major, isoburn_header_version_minor,
isoburn_header_version_micro);
Xorriso_result(xorriso, 0);
return(1);
}

@ -143,6 +143,8 @@ int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag);
int Xorriso_set_abort_severity(struct XorrisO *xorriso, int flag);
int Xorriso_report_lib_versions(struct XorrisO *xorriso, int flag);
#endif /* Xorrisoburn_includeD */

Loading…
Cancel
Save