"Fossies" - the Fresh Open Source Software Archive

Member "libisoburn-1.5.4/xorriso/opts_p_z.c" (3 Nov 2020, 74498 Bytes) of package /linux/misc/libisoburn-1.5.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "opts_p_z.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.5.0_vs_1.5.2.

    1 
    2 /* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
    3 
    4    Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
    5 
    6    Provided under GPL version 2 or later.
    7 
    8    This file contains the implementation of options -p* to -z* as mentioned
    9    in man page or info file derived from xorriso.texi.
   10 */
   11 
   12 #ifdef HAVE_CONFIG_H
   13 #include "../config.h"
   14 #endif
   15 
   16 #include <ctype.h>
   17 #include <sys/types.h>
   18 #include <unistd.h>
   19 #include <stdlib.h>
   20 #include <stdio.h>
   21 #include <string.h>
   22 #include <sys/stat.h>
   23 #include <sys/time.h>
   24 #include <time.h>
   25 #include <errno.h>
   26 
   27 
   28 #include "xorriso.h"
   29 #include "xorriso_private.h"
   30 #include "xorrisoburn.h"
   31 
   32 
   33 /* Option -pacifier */
   34 int Xorriso_option_pacifier(struct XorrisO *xorriso, char *style, int flag)
   35 {
   36 
   37 #define Xorriso_pacifier_min_intvL 0.1
   38 #define Xorriso_pacifier_max_intvL 60.0
   39 
   40  if(strcmp(style, "xorriso")==0 || strcmp(style, "default")==0)
   41    xorriso->pacifier_style= 0;
   42  else if(strcmp(style, "mkisofs")==0 || strcmp(style, "genisofs")==0 ||
   43          strcmp(style, "genisoimage")==0 || strcmp(style, "xorrisofs")==0)
   44    xorriso->pacifier_style= 1;
   45  else if(strcmp(style, "cdrecord")==0 || strcmp(style, "cdrskin")==0 ||
   46          strcmp(style, "wodim")==0 || strcmp(style, "xorrecord")==0)
   47    xorriso->pacifier_style= 2;
   48 
   49  else if(strncmp(style, "interval=", 9) == 0) {
   50    sscanf(style + 9, "%lf", &(xorriso->pacifier_interval));
   51    if(xorriso->pacifier_interval < Xorriso_pacifier_min_intvL) {
   52      sprintf(xorriso->info_text,
   53              "-pacifier: interval='%s' is too low. Min: %f",
   54              style, Xorriso_pacifier_min_intvL);
   55      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
   56      xorriso->pacifier_interval= Xorriso_pacifier_min_intvL;
   57    } else if(xorriso->pacifier_interval > Xorriso_pacifier_max_intvL) {
   58      sprintf(xorriso->info_text,
   59              "-pacifier: interval='%s' is too high. Max: %f",
   60              style, Xorriso_pacifier_max_intvL);
   61      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
   62      xorriso->pacifier_interval= Xorriso_pacifier_max_intvL;
   63    }
   64 
   65  } else {
   66    sprintf(xorriso->info_text, "-pacifier: unknown behavior code '%s'", style);
   67    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
   68    return(0);
   69  }
   70  return(1);
   71 }
   72 
   73 
   74 /* Option -padding */
   75 int Xorriso_option_padding(struct XorrisO *xorriso, char *size, int flag)
   76 {
   77  double num;
   78 
   79  if(strcmp(size, "included") == 0) {
   80    xorriso->do_padding_by_libisofs= 1;
   81    return(1);
   82  } else if(strcmp(size, "excluded") == 0 || strcmp(size, "appended") == 0) {
   83    xorriso->do_padding_by_libisofs= 0;
   84    return(1);
   85  } else if(size[0] < '0' || size[0] > '9') {
   86    sprintf(xorriso->info_text, "-padding: unrecognized non-numerical mode ");
   87    Text_shellsafe(size, xorriso->info_text, 1);
   88    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
   89    return(0);
   90  }
   91  num= Scanf_io_size(size, 0);
   92  if(num < 0 || num > 1024.0 * 1024.0 * 1024.0) {
   93    sprintf(xorriso->info_text, "-padding: wrong size %.f (allowed: %.f - %.f)",
   94            num, 0.0, 1024.0 * 1024.0 * 1024.0);
   95    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
   96    return(0);
   97  }
   98  xorriso->padding= num;
   99  if(xorriso->padding/2048 != num/2048.0)
  100    xorriso->padding++;
  101  return(1);
  102 }
  103 
  104 
  105 /* Option -page */
  106 int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag)
  107 {
  108  if(len<0 || width<=0) {
  109    sprintf(xorriso->info_text,
  110              "Improper numeric value of arguments of -page:  %d  %d",
  111              len, width);
  112    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
  113    return(0);
  114  }
  115  xorriso->result_page_length= len;
  116  xorriso->result_page_width= width;
  117  return(1);
  118 }
  119 
  120 
  121 /* Option -paste_in */
  122 int Xorriso_option_paste_in(struct XorrisO *xorriso, char *iso_rr_path,
  123                            char *disk_path, char *start, char *count, int flag)
  124 {
  125  int ret;
  126  double num;
  127  off_t startbyte, bytecount;
  128  
  129  num= Scanf_io_size(start, 0);
  130  if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */
  131    sprintf(xorriso->info_text,
  132         "-paste_in: startbyte address negative or much too large (%s)", start);
  133    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  134    return(0);
  135  }
  136  startbyte= num;
  137  num= Scanf_io_size(count, 0);
  138  if(num<=0 || num > 1.0e18) {
  139    sprintf(xorriso->info_text,
  140          "-paste_in : bytecount zero, negative or much too large (%s)", count);
  141    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  142    return(0);
  143  }
  144  bytecount= num;
  145  sprintf(xorriso->info_text, "-paste_in from %s to %s, byte %.f to %.f",
  146          disk_path, iso_rr_path,
  147          (double) startbyte, (double) (startbyte+bytecount));
  148  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
  149 
  150  Xorriso_pacifier_reset(xorriso, 0);
  151  ret= Xorriso_paste_in(xorriso, disk_path, startbyte, bytecount,
  152                        iso_rr_path, 0); 
  153  Xorriso_pacifier_callback(xorriso, "files restored",xorriso->pacifier_count,
  154                            xorriso->pacifier_total, "", 1 | 4 | 8 | 32);
  155  return(ret);
  156 }
  157 
  158 
  159 /* Option -path_list , -quoted_path_list */
  160 /* @param flag bit0= -quoted_path_list
  161                bit1= mkisofs mode: Use / as target for pathspecs without =
  162 */
  163 int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag)
  164 {
  165  int ret,linecount= 0, insertcount= 0, null= 0, was_failure= 0, fret= 0;
  166  int was_ferror= 0, argc= 0, i, allow_graft_points_mem;
  167  FILE *fp= NULL;
  168  char **argv= NULL, *pathspec= NULL;
  169 
  170  allow_graft_points_mem= xorriso->allow_graft_points;
  171  Xorriso_pacifier_reset(xorriso, 0);
  172  if(adr[0]==0) {
  173    sprintf(xorriso->info_text,"Empty file name given with %s",
  174            flag & 1 ? "-quoted_path_list" : "-path_list");
  175    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
  176    return(0);
  177  }
  178  ret= Xorriso_afile_fopen(xorriso, adr, "rb", &fp, 0);
  179  if(ret <= 0)
  180    return(0);
  181 
  182  Xorriso_alloc_meM(pathspec, char, 2 * SfileadrL);
  183  while(1) {
  184    ret= Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv,
  185                            4 | (flag & 1) );
  186    if(ret <= 0)
  187      goto ex;
  188    if(ret == 2)
  189  break;
  190    for(i= 0; i < argc; i++) {
  191      if(argv[i][0] == 0)
  192    continue;
  193      null= 0;
  194      if(flag & 2) {
  195        ret= Xorriso_graftable_pathspec(xorriso, argv[i], pathspec, 0);
  196        if(ret <= 0)
  197          goto problem_handler;
  198        xorriso->allow_graft_points= 3;
  199        ret= Xorriso_option_add(xorriso, 1, &pathspec, &null, 1 | 2);
  200        xorriso->allow_graft_points= allow_graft_points_mem;
  201      } else {
  202        ret= Xorriso_option_add(xorriso, 1, argv + i, &null, 1 | 2);
  203      }
  204      if(ret<=0 || xorriso->request_to_abort)
  205        goto problem_handler;
  206      insertcount++;
  207 
  208    continue; /* regular bottom of loop */
  209 problem_handler:;
  210      was_failure= 1;
  211      fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
  212      if(fret>=0)
  213    continue;
  214      if(ret > 0)
  215        ret= 0;
  216      goto ex;
  217    }
  218  }
  219  ret= 1;
  220 ex:;
  221  xorriso->allow_graft_points= allow_graft_points_mem;
  222  Sfile_make_argv("", "", &argc, &argv, 2);
  223  Xorriso_free_meM(pathspec);
  224  Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, 2);
  225 
  226  if(fp != NULL && fp != stdin)
  227    fclose(fp);
  228  Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
  229                            xorriso->pacifier_total, "", 1);
  230  if(ret<=0) {
  231    sprintf(xorriso->info_text, "Aborted reading of file ");
  232    Text_shellsafe(adr, xorriso->info_text, 1);
  233    sprintf(xorriso->info_text + strlen(xorriso->info_text),
  234            " in line number %d", linecount);
  235    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
  236                        (fret==-2 ? "NOTE" : "FAILURE"), 0);
  237  } else
  238    ret= !was_ferror;
  239  sprintf(xorriso->info_text, "Added %d items from file ", insertcount);
  240  Text_shellsafe(adr, xorriso->info_text, 1);
  241  strcat(xorriso->info_text, "\n");
  242  Xorriso_info(xorriso,0);
  243  if(ret<=0)
  244    return(ret);
  245  return(!was_failure);
  246 }
  247 
  248 
  249 /* Option -pathspecs */
  250 int Xorriso_option_pathspecs(struct XorrisO *xorriso, char *mode, int flag)
  251 {
  252  if(strcmp(mode, "off")==0)
  253    xorriso->allow_graft_points= 0;
  254  else if(strcmp(mode, "on")==0)
  255    xorriso->allow_graft_points= 1;
  256  else if(strcmp(mode, "as_mkisofs")==0)
  257    xorriso->allow_graft_points= 3;
  258  else {
  259    sprintf(xorriso->info_text, "-pathspecs: unknown mode '%s'", mode);
  260    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  261    return(0);
  262  }
  263  return(1);
  264 }
  265 
  266 
  267 /* Option -pkt_output */
  268 int Xorriso_option_pkt_output(struct XorrisO *xorriso, char *mode, int flag)
  269 {
  270  if(strcmp(mode,"off")==0)
  271    xorriso->packet_output= 0;
  272  else
  273    xorriso->packet_output= 1;
  274  return(1);
  275 }
  276 
  277 
  278 /* Option -preparer_id */
  279 int Xorriso_option_preparer_id(struct XorrisO *xorriso, char *name, int flag)
  280 {
  281  if(Xorriso_check_name_len(xorriso, name,
  282                            (int) sizeof(xorriso->preparer_id),
  283                            "-preparer_id", 0) <= 0)
  284    return(0);
  285  if(strcmp(name, "@xorriso@") == 0)
  286    Xorriso_preparer_string(xorriso, xorriso->preparer_id, 0);
  287  else
  288    strcpy(xorriso->preparer_id, name);
  289  Xorriso_set_change_pending(xorriso, 1);
  290  return(1);
  291 }
  292 
  293 
  294 /* Options -print , -print_info , -print_mark */
  295 /* @param flag bit0-1= channel: 0=result, 1=info, 2=mark */
  296 int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag)
  297 {
  298  int maxl, l, mode;
  299 
  300  l= strlen(text);
  301  mode= flag & 3;
  302  if(mode == 1)
  303    maxl= sizeof(xorriso->info_text);
  304  else if(mode == 2)
  305    maxl= sizeof(xorriso->mark_text);
  306  else
  307    maxl= sizeof(xorriso->result_line);
  308  if(l >= maxl) {
  309    sprintf(xorriso->info_text, "Output text too long for -print%s(%d > %d)",
  310            mode == 1 ? "_info" : mode == 2 ? "_mark" : "", l, maxl);
  311    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
  312    return(0);
  313  }
  314  if(mode == 1) {
  315    sprintf(xorriso->info_text,"%s\n", text);
  316    Xorriso_info(xorriso,0);
  317  } else if(mode == 2) {
  318    strcpy(xorriso->info_text, xorriso->mark_text);
  319    strcpy(xorriso->mark_text, text);
  320    Xorriso_mark(xorriso,0);
  321    strcpy(xorriso->mark_text, xorriso->info_text);
  322  } else {
  323    sprintf(xorriso->result_line,"%s\n",text);
  324    Xorriso_result(xorriso,1);
  325  }
  326  return(1);
  327 }
  328 
  329 
  330 /* Option -print_size
  331    @param flag bit0= report in mkisofs compatible form on real stdout
  332                      (resp. on result channel if xorriso->packet_output)
  333 */
  334 int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
  335 {
  336  int ret, fd;
  337 
  338  if(!Xorriso_change_is_pending(xorriso, 0)) {
  339    sprintf(xorriso->info_text,"-print_size: No image modifications pending");
  340    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
  341    if(!(flag & 1)) {
  342      sprintf(xorriso->result_line,"Image size   : 0s\n");
  343      Xorriso_result(xorriso,0);
  344    }
  345    return(2);
  346  }
  347  ret= Xorriso_write_session(xorriso, 1);
  348  if(ret<=0) {
  349    sprintf(xorriso->info_text,"-print_size: Failed to set up virtual -commit");
  350    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
  351    return(0);
  352  }
  353  if(flag&1) {
  354    sprintf(xorriso->result_line,"%d\n", ret);
  355    if(xorriso->packet_output) {
  356      Xorriso_result(xorriso,0);
  357    } else {
  358      fd= xorriso->dev_fd_1;
  359      if(fd<0)
  360        fd= 1;
  361      ret= write(fd, xorriso->result_line, strlen(xorriso->result_line));
  362      /* (result of write intentionally ignored) */
  363      fsync(fd);
  364    }
  365  } else {
  366    sprintf(xorriso->result_line,"Image size   : %ds\n", ret);
  367    Xorriso_result(xorriso,0);
  368  }
  369  return(1);
  370 }
  371 
  372 
  373 /* Option -prog */
  374 int Xorriso_option_prog(struct XorrisO *xorriso, char *name, int flag)
  375 {
  376  if(strlen(name)>=sizeof(xorriso->progname)) {
  377    sprintf(xorriso->info_text,
  378            "Name too long with option -prog (%d > %d)",
  379            (int) strlen(name), (int) sizeof(xorriso->progname)-1);
  380    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
  381    return(0);
  382  }
  383  if(Sfile_str(xorriso->progname,name,0)<=0)
  384    return(-1);
  385  return(1);
  386 }
  387 
  388 
  389 /* Option -prog_help */
  390 int Xorriso_option_prog_help(struct XorrisO *xorriso, char *name, int flag)
  391 {
  392  int ret;
  393 
  394  ret= Xorriso_option_prog(xorriso, name, 0);
  395  if(ret<=0)
  396    return(ret);
  397  ret= Xorriso_option_help(xorriso, 0);
  398  return(ret);
  399 }
  400 
  401 
  402 /* Option -prompt */
  403 int Xorriso_option_prompt(struct XorrisO *xorriso, char *text, int flag)
  404 {
  405  int ret;
  406  char line[80];
  407 
  408  strncpy(xorriso->result_line,text,sizeof(xorriso->result_line)-1);
  409  xorriso->result_line[sizeof(xorriso->result_line)-1]= 0;
  410  Xorriso_result(xorriso,0);
  411  ret= Xorriso_dialog_input(xorriso, line, sizeof(line),1);
  412  return(ret);
  413 }
  414 
  415 
  416 /* Option -publisher */
  417 int Xorriso_option_publisher(struct XorrisO *xorriso, char *name, int flag)
  418 {
  419   if(Xorriso_check_name_len(xorriso, name, (int) sizeof(xorriso->publisher),
  420                             "-publisher", 0) <= 0)
  421     return(0);
  422  strcpy(xorriso->publisher,name);
  423  Xorriso_set_change_pending(xorriso, 1);
  424  return(1);
  425 }
  426 
  427 
  428 /* Option -pvd_info */
  429 int Xorriso_option_pvd_info(struct XorrisO *xorriso, int flag)
  430 {
  431   return(Xorriso_pvd_info(xorriso, 0));
  432 }
  433 
  434 
  435 /* Option -pwd alias -pwdi */
  436 int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag)
  437 {
  438  sprintf(xorriso->info_text,"current working directory in ISO image:\n");
  439  Xorriso_info(xorriso,0);
  440  Xorriso_esc_filepath(xorriso, xorriso->wdi, xorriso->result_line, 0);
  441  if(xorriso->sh_style_result == 0 || xorriso->wdi[0] == 0)
  442    strcat(xorriso->result_line, "/");
  443  strcat(xorriso->result_line, "\n");
  444  Xorriso_result(xorriso,0);
  445  return(1);
  446 }
  447 
  448 
  449 /* Option -pwdx */
  450 int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag)
  451 {
  452  sprintf(xorriso->info_text,"current working directory on hard disk:\n");
  453  Xorriso_info(xorriso,0);
  454  Xorriso_esc_filepath(xorriso, xorriso->wdx, xorriso->result_line, 0);
  455  if(xorriso->sh_style_result == 0 || xorriso->wdx[0] == 0)
  456    strcat(xorriso->result_line, "/");
  457  strcat(xorriso->result_line, "\n");
  458  Xorriso_result(xorriso,0);
  459  return(1);
  460 }
  461 
  462 
  463 /* Command -read_fs */
  464 int Xorriso_option_read_fs(struct XorrisO *xorriso, char *mode, int flag)
  465 {
  466  if(strcmp(mode, "any") == 0) {
  467    xorriso->read_fs= 0;
  468  } else if(strcmp(mode, "norock") == 0) {
  469    xorriso->read_fs= 1;
  470  } else if(strcmp(mode, "nojoliet") == 0) {
  471    xorriso->read_fs= 2;
  472  } else if(strcmp(mode, "ecma119") == 0) {
  473    xorriso->read_fs= 3;
  474  } else {
  475    sprintf(xorriso->info_text, "-read_fs: unknown mode '%s'", mode);
  476    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  477    return(0);
  478  }
  479  return(1);
  480 }
  481 
  482 
  483 int Xorriso_option_read_mkisofsrc(struct XorrisO *xorriso, int flag)
  484 {
  485  int ret;
  486 
  487  ret= Xorriso_read_mkisofsrc(xorriso, 0);
  488  return(ret);
  489 }
  490 
  491 
  492 /* Option -reassure "on"|"tree"|"off" */
  493 int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag)
  494 {
  495  if(strcmp(mode, "off")==0)
  496    xorriso->do_reassure= 0;
  497  else if(strcmp(mode, "on")==0)
  498    xorriso->do_reassure= 1;
  499  else if(strcmp(mode, "tree")==0)
  500    xorriso->do_reassure= 2;
  501  else {
  502    sprintf(xorriso->info_text, "-reassure: unknown mode '%s'", mode);
  503    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
  504    return(0);
  505  }
  506  return(1);
  507 }
  508 
  509 
  510 /* Option -report_about */
  511 int Xorriso_option_report_about(struct XorrisO *xorriso, char *in_severity,
  512                                 int flag)
  513 {
  514  int ret, sev;
  515  char severity[20], *official;
  516 
  517  Xorriso__to_upper(in_severity, severity, (int) sizeof(severity), 0);
  518  ret= Xorriso__text_to_sev(severity, &sev, 0);
  519  if(ret<=0) {
  520    sprintf(xorriso->info_text, "-report_about: Not a known severity name : ");
  521    Text_shellsafe(in_severity, xorriso->info_text, 1);
  522    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
  523    return(ret);
  524  }
  525  ret= Xorriso__sev_to_text(sev, &official, 0);
  526  if(ret <= 0)
  527    official= severity;
  528  if(Sfile_str(xorriso->report_about_text, official, 0) <= 0)
  529    return(-1);
  530  xorriso->report_about_severity= sev;
  531  return(1);
  532 }
  533 
  534 
  535 /* Command -report_el_torito */
  536 int Xorriso_option_report_el_torito(struct XorrisO *xorriso,
  537                                     char *form, int flag)
  538 {
  539  int ret;
  540 
  541  ret= Xorriso_report_system_area(xorriso, form, 1);
  542  return(ret);
  543 }
  544 
  545 
  546 /* Command -report_system_area */
  547 int Xorriso_option_report_system_area(struct XorrisO *xorriso,
  548                                       char *form, int flag)
  549 {
  550  int ret;
  551 
  552  ret= Xorriso_report_system_area(xorriso, form, 0);
  553  return(ret);
  554 }
  555 
  556 
  557 /* Option -return_with */
  558 int Xorriso_option_return_with(struct XorrisO *xorriso, char *in_severity,
  559                                int exit_value, int flag)
  560 {
  561  int ret, sev;
  562  char severity[20], *official;
  563 
  564  Xorriso__to_upper(in_severity, severity, (int) sizeof(severity), 0);
  565  ret= Xorriso__text_to_sev(severity, &sev, 0);
  566  if(ret<=0) {
  567    sprintf(xorriso->info_text,
  568            "-return_with: Not a known severity name : ");
  569    Text_shellsafe(in_severity, xorriso->info_text, 1);
  570    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  571    return(ret);
  572  }
  573  ret= Xorriso__sev_to_text(sev, &official, 0);
  574  if(ret <= 0)
  575    official= severity;
  576  if(exit_value && (exit_value < 32 || exit_value > 63)) {
  577    sprintf(xorriso->info_text,
  578            "-return_with: Not an allowed exit_value. Use 0, or 32 to 63.");
  579    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  580    return(0);
  581  }
  582  if(Sfile_str(xorriso->return_with_text, official, 0) <= 0)
  583    return(-1);
  584  xorriso->return_with_severity= sev;
  585  xorriso->return_with_value= exit_value;
  586  return(1);
  587 }
  588 
  589 
  590 /* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */
  591 /* @param flag bit0=recursive , bit1= remove empty directory: rmdir */
  592 int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv,
  593                        int *idx, int flag)
  594 {
  595  int i, ret, end_idx, was_failure= 0, fret;
  596  char *path= NULL, *eff_path= NULL;
  597  int optc= 0;
  598  char **optv= NULL;
  599 
  600  ret= Xorriso_opt_args(xorriso, "-rm*i",
  601                        argc, argv, *idx, &end_idx, &optc, &optv, 0);
  602  if(ret<=0)
  603    goto ex; 
  604  Xorriso_alloc_meM(path, char, SfileadrL);
  605  Xorriso_alloc_meM(eff_path, char, SfileadrL);
  606 
  607  for(i= 0; i<optc; i++) {
  608    if(Sfile_str(path,optv[i],0)<=0)
  609      {ret= -1; goto problem_handler;}
  610    if(path[0]!='/') {
  611      ret= Sfile_prepend_path(xorriso->wdi, path, 0);
  612      if(ret<=0)
  613        goto problem_handler;
  614    }
  615    ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1);
  616    if(ret<0)
  617      goto problem_handler;
  618    if(ret==0) {
  619      sprintf(xorriso->info_text, "Cannot find path ");
  620      Text_shellsafe(path, xorriso->info_text, 1);
  621      strcat(xorriso->info_text, " in loaded ISO image for removal");
  622      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
  623      goto problem_handler;
  624    }
  625    strcpy(path, eff_path);
  626 
  627    ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, path, flag&(1|2));
  628    if(ret<=0 || xorriso->request_to_abort)
  629      goto problem_handler;
  630    if(ret<3) {
  631      sprintf(xorriso->info_text, "Removed from ISO image: %s '%s'\n",
  632              ((flag&2) ? "directory" : (ret>1 ? "subtree" : "file")), path);
  633      Xorriso_info(xorriso, 0);
  634    }
  635 
  636  continue; /* regular bottom of loop */
  637 problem_handler:;
  638    was_failure= 1;
  639    fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
  640    if(fret>=0)
  641  continue;
  642    goto ex;
  643  }
  644  ret= 1;
  645 ex:; 
  646  (*idx)= end_idx;
  647  Xorriso_free_meM(path);
  648  Xorriso_free_meM(eff_path);
  649  Xorriso_opt_args(xorriso, "-rm*i",
  650                   argc, argv, *idx, &end_idx, &optc, &optv, 256);
  651  if(ret<=0)
  652    return(ret);
  653  return(!was_failure);
  654 }
  655 
  656 
  657 /* Option -rockridge "on"|"off" */
  658 int Xorriso_option_rockridge(struct XorrisO *xorriso, char *mode, int flag)
  659 {
  660  if(strcmp(mode, "off")==0)
  661    xorriso->do_rockridge= 0;
  662  else if(strcmp(mode, "on")==0)
  663    xorriso->do_rockridge= 1;
  664  else {
  665    sprintf(xorriso->info_text, "-rockridge: unknown mode '%s'", mode);
  666    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  667    return(0);
  668  }
  669  return(1);
  670 }
  671 
  672 
  673 /* Option -rollback */
  674 /* @param flag bit0= do not -reassure
  675    @return <=0 error , 1 success, 2 revoked by -reassure
  676 */
  677 int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
  678 {
  679  int ret;
  680  char *indev= NULL, *which_will;
  681 
  682  Xorriso_alloc_meM(indev, char, SfileadrL);
  683  if(Xorriso_change_is_pending(xorriso, 0))
  684    which_will= "revoke the pending image changes";
  685  else
  686    which_will= "reload the image";
  687  if(!(flag&1)) {
  688    ret= Xorriso_reassure(xorriso, "-rollback", which_will, 0);
  689    if(ret<=0)
  690      {ret= 2; goto ex;}
  691  }
  692 
  693  if(Sfile_str(indev, xorriso->indev, 0)<=0)
  694    {ret= -1; goto ex;}
  695  xorriso->volset_change_pending= 0;
  696  ret= Xorriso_give_up_drive(xorriso, 1|8);
  697  if(ret<=0)
  698    goto ex;
  699  xorriso->image_start_mode&= ~(1u<<31); /* reactivate eventual -load address */
  700  ret= Xorriso_option_dev(xorriso, indev, 1|4);
  701 ex:;
  702  Xorriso_free_meM(indev);
  703  return(ret);
  704 }
  705 
  706 
  707 /* Option -rom_toc_scan */
  708 int Xorriso_option_rom_toc_scan(struct XorrisO *xorriso, char *mode, int flag)
  709 {
  710  int l;
  711  char *cpt, *npt;
  712 
  713  npt= cpt= mode;
  714  for(cpt= mode; npt != NULL; cpt= npt + 1) {
  715    npt= strchr(cpt,':');
  716    if(npt==NULL)
  717      l= strlen(cpt);
  718    else
  719      l= npt-cpt;
  720    if(l==0)
  721  continue;
  722    if(strncmp(cpt, "off", l) == 0)
  723      xorriso->toc_emulation_flag&= ~5;
  724    else if(strncmp(cpt, "on", l) == 0)
  725      xorriso->toc_emulation_flag= (xorriso->toc_emulation_flag & ~4) | 1;
  726    else if(strncmp(cpt, "force", l) == 0)
  727      xorriso->toc_emulation_flag|= 5;
  728    else if(strncmp(cpt, "emul_off", l) == 0)
  729      xorriso->toc_emulation_flag|= 2;
  730    else if(strncmp(cpt, "emul_on", l) == 0)
  731      xorriso->toc_emulation_flag&= ~2;
  732    else if(strncmp(cpt, "emul_wide", l) == 0)
  733      xorriso->toc_emulation_flag|= 8;
  734    else if(strncmp(cpt, "emul_narrow", l) == 0)
  735      xorriso->toc_emulation_flag&= ~8;
  736    else {
  737      sprintf(xorriso->info_text, "-rom_toc_scan: unknown mode in '%s'", mode);
  738      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  739      return(0);
  740    }
  741  }
  742  return(1);
  743 }
  744 
  745 
  746 /* Command -rr_reloc_dir */
  747 int Xorriso_option_rr_reloc_dir(struct XorrisO *xorriso, char *name, int flag)
  748 {
  749  if(strlen(name) > 255) {
  750    sprintf(xorriso->info_text,
  751            "Name too long with -rr_reloc_dir. Max. 255 bytes allowed.");
  752    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  753    return(0);
  754  }
  755  if(strchr(name, '/') != NULL) {
  756    sprintf(xorriso->info_text,
  757            "Name given with -rr_reloc_dir contains '/' character");
  758    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  759    return(0);
  760  }
  761  strcpy(xorriso->rr_reloc_dir, name);
  762  return(1);
  763 }
  764 
  765 
  766 /* Option -scdbackup_tag list_path record_name */
  767 int Xorriso_option_scdbackup_tag(struct XorrisO *xorriso, char *listname,
  768                                  char *recname, int flag)
  769 {
  770  if(strlen(recname) > 80) {
  771    sprintf(xorriso->info_text,
  772            "Unsuitable record name given with -scdbackup_tag");
  773    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  774    return(0);
  775  }
  776  strcpy(xorriso->scdbackup_tag_name, recname);
  777  xorriso->scdbackup_tag_time[0]= 0;
  778  if(Sfile_str(xorriso->scdbackup_tag_listname, listname, 0) <= 0)
  779    return(-1);
  780  return(1);
  781 }
  782 
  783 
  784 /* Command -scsi_dev_family */
  785 int Xorriso_option_scsi_dev_family(struct XorrisO *xorriso, char *mode,
  786                                    int flag)
  787 {
  788  if(strcmp(mode, "default") == 0)
  789    xorriso->linux_scsi_dev_family= 0;
  790  else if(strcmp(mode, "sr") == 0)
  791    xorriso->linux_scsi_dev_family= 1;
  792  else if(strcmp(mode, "scd") == 0)
  793    xorriso->linux_scsi_dev_family= 2;
  794  else if(strcmp(mode, "sg") == 0)
  795    xorriso->linux_scsi_dev_family= 4;
  796  else {
  797    sprintf(xorriso->info_text, "-scsi_dev_family: unknown family '%s'", mode);
  798    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  799    return(0);
  800  }
  801  Xorriso_scsi_dev_family(xorriso, 0);
  802  return(1);
  803 }
  804 
  805 
  806 /* Option -scsi_log */
  807 int Xorriso_option_scsi_log(struct XorrisO *xorriso, char *mode, int flag)
  808 {
  809  if(strcmp(mode, "on") == 0)
  810    xorriso->scsi_log= 1;
  811  else if(strcmp(mode, "off") == 0)
  812    xorriso->scsi_log= 0;
  813  else {
  814    sprintf(xorriso->info_text, "-scsi_log: unknown mode '%s'", mode);
  815    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  816    return(0);
  817  }
  818  Xorriso_scsi_log(xorriso, !!xorriso->scsi_log);
  819  return(1);
  820 }
  821 
  822 
  823 /* Option -session_log */
  824 int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag)
  825 {
  826  if(Sfile_str(xorriso->session_logfile, path, 0)<=0)
  827    return(-1);
  828  return(1);
  829 }
  830 
  831 
  832 /* Option -setfacl_list alias -setfacl_listi */
  833 int Xorriso_option_setfacl_listi(struct XorrisO *xorriso, char *path, int flag)
  834 {
  835  int ret, eaten, line_size;
  836  size_t buf_size= 0, buf_add, l, linecount= 0, diff_buf_wpt;
  837  char *line= NULL, *buf= NULL, *wpt, *new_buf, limit_text[80];
  838  char *file_path= NULL, *uid= NULL, *gid= NULL;
  839  FILE *fp= NULL;
  840 
  841  line_size= SfileadrL * 4;
  842  buf_add= line_size * 4;
  843  Xorriso_alloc_meM(line, char, line_size);
  844  Xorriso_alloc_meM(file_path, char, SfileadrL);
  845  Xorriso_alloc_meM(uid, char, 161);
  846  Xorriso_alloc_meM(gid, char, 161);
  847 
  848  Xorriso_pacifier_reset(xorriso, 0);
  849  if(path[0]==0) {
  850    sprintf(xorriso->info_text, "Empty file name given with -setfacl_list");
  851    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  852    {ret= 0; goto ex;}
  853  }
  854  ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 0);
  855  if(ret <= 0)
  856    {ret= 0; goto ex;}
  857 
  858  buf_size= buf_add;
  859  buf= calloc(buf_size, 1);
  860  if(buf == NULL)
  861    goto out_of_mem;
  862  wpt= buf;
  863  *wpt= 0;
  864  uid[0]= gid[0]= 0;
  865 
  866  while(1) {
  867    if(Sfile_fgets_n(line, line_size, fp, 0) == NULL)
  868  break;
  869    linecount++;
  870    if(strncmp(line, "# file: ", 8) ==0) {
  871       if(wpt != buf && file_path[0]) {
  872         /* Commit previous list */
  873         ret= Xorriso_perform_acl_from_list(xorriso, file_path,
  874                                            uid, gid, buf, 0);
  875         if(ret<=0)
  876           goto ex;
  877         wpt= buf;
  878         *wpt= 0;
  879         file_path[0]= uid[0]= gid[0]= 0;
  880       }
  881       /* Unescape line and register as file path */
  882       Sfile_bsl_interpreter(line + 8, strlen(line + 8), &eaten, 0);
  883       if(strlen(line + 8) >= SfileadrL) {
  884         sprintf(xorriso->info_text, "-setfacl_list: Oversized file path");
  885         Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  886         ret= 0; goto ex;
  887       }
  888       strcpy(file_path, line + 8);
  889  continue;
  890    } else if(strncmp(line, "# owner: ", 9) == 0) {
  891       if(strlen(line + 9) > 160) {
  892         sprintf(xorriso->info_text, "-setfacl_list: Oversized owner id");
  893         Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  894         ret= 0; goto ex;
  895       }
  896       strcpy(uid, line + 9);
  897  continue;
  898    } else if(strncmp(line, "# group: ", 9) == 0) {
  899       if(strlen(line + 9) > 160) {
  900         sprintf(xorriso->info_text, "-setfacl_list: Oversized group id");
  901         Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  902         ret= 0; goto ex;
  903       }
  904       strcpy(gid, line + 9);
  905  continue;
  906    } else if(line[0] == '#' || line[0] == 0) {
  907  continue;
  908    } else if(strcmp(line, "@") == 0) {
  909      Xorriso_msgs_submit(xorriso, 0,
  910                 "-setfacl_list input ended by '@'", 0, "NOTE", 0);
  911  break;
  912    } else if(strcmp(line, "@@@") == 0) {
  913      Xorriso_msgs_submit(xorriso, 0,
  914                 "-setfacl_list aborted by input line '@@@'", 0, "WARNING", 0);
  915      ret= 0; goto ex;
  916    }
  917 
  918    /* Register ACL entry */
  919    l= strlen(line);
  920    if(wpt + l + 2 - buf > (int) buf_size) {
  921      if((int) (buf_size + buf_add) > xorriso->temp_mem_limit) {
  922        Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1);
  923        sprintf(xorriso->info_text,
  924       "-setfacl_list: List entry for a single file exceeds -temp_mem_limit %s",
  925               limit_text);
  926        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  927        ret= 0; goto ex;
  928      }
  929      diff_buf_wpt= wpt - buf;
  930      buf_size+= buf_add;
  931      new_buf= realloc(buf, buf_size);
  932      if(new_buf == NULL)
  933        goto out_of_mem;
  934      buf= new_buf;
  935      wpt= buf + diff_buf_wpt;
  936    }
  937    memcpy(wpt, line, l);
  938    *(wpt + l)= '\n';
  939    wpt+= l + 1;
  940    *wpt= 0;
  941  }
  942  if(wpt != buf && file_path[0]) {
  943    /* Commit last list */
  944    ret= Xorriso_perform_acl_from_list(xorriso, file_path, uid, gid, buf, 0);
  945    if(ret<=0)
  946      goto ex;
  947  } else {
  948    sprintf(xorriso->info_text, "-setfacl_list: Unexpected end of file ");
  949    Text_shellsafe(path, xorriso->info_text, 1);
  950    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
  951  }
  952  ret= 1;
  953 ex:;
  954  if(buf != NULL)
  955    free(buf);
  956  if(fp != NULL && fp != stdin)
  957    fclose(fp);
  958  if(ret <= 0) {
  959    sprintf(xorriso->info_text, "-setfacl_list ");
  960    Text_shellsafe(path, xorriso->info_text, 1);
  961    sprintf(xorriso->info_text + strlen(xorriso->info_text),
  962            " aborted in line %.f\n", (double) linecount);
  963    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  964  }
  965  Xorriso_free_meM(line);
  966  Xorriso_free_meM(file_path);
  967  Xorriso_free_meM(uid);
  968  Xorriso_free_meM(gid);
  969  return(ret);
  970 out_of_mem:;
  971  Xorriso_no_malloc_memory(xorriso, &buf, 0);
  972  ret= -1;
  973  goto ex;
  974 }
  975 
  976 
  977 /* Options -setfacl alias -setfacli, -setfacl_r alias -setfacl_ri */
  978 /* @param flag   bit0=recursive -setfacl_r
  979 */
  980 int Xorriso_option_setfacli(struct XorrisO *xorriso, char *acl_text,
  981                             int argc, char **argv, int *idx, int flag)
  982 {
  983  int i, ret, was_failure= 0, end_idx, fret;
  984  int optc= 0;
  985  char **optv= NULL, *access_acl_text= NULL, *default_acl_text= NULL;
  986  struct FindjoB *job= NULL;
  987  struct stat dir_stbuf;
  988 
  989  ret= Xorriso_opt_args(xorriso, "-setfacl", argc, argv, *idx, &end_idx, &optc,
  990                        &optv, 0);
  991  if(ret <= 0)
  992    goto ex;
  993 
  994  ret= Xorriso_normalize_acl_text(xorriso, acl_text,
  995                                  &access_acl_text, &default_acl_text, 0);
  996  if(access_acl_text != NULL && default_acl_text != NULL) {
  997    strcpy(xorriso->info_text, "Access-ACL :\n");
  998    Xorriso_set_info_text(xorriso, access_acl_text, 2000, 1);
  999    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
 1000    strcpy(xorriso->info_text, "Default-ACL :\n");
 1001    Xorriso_set_info_text(xorriso, default_acl_text, 2000, 1);
 1002    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
 1003  } else if(access_acl_text == NULL && default_acl_text == NULL) {
 1004    sprintf(xorriso->info_text, "Will delete Access-ACL and Default-ACL");
 1005    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
 1006  }
 1007  if(ret <= 0)
 1008    goto ex;
 1009 
 1010  for(i= 0; i<optc; i++) {
 1011    if(flag&1) {
 1012      ret= Findjob_new(&job, optv[i], 0);
 1013      if(ret<=0) {
 1014        Xorriso_no_findjob(xorriso, "-setfacl_r", 0);
 1015        {ret= -1; goto ex;}
 1016      }
 1017      Findjob_set_action_text_2(job, 25, access_acl_text, default_acl_text, 0);
 1018      ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
 1019                         NULL, optv[i], &dir_stbuf, 0, 0);
 1020      Findjob_destroy(&job, 0);
 1021    } else {
 1022      ret= 1;
 1023      if(access_acl_text == NULL || access_acl_text[0] ||
 1024         default_acl_text == NULL || default_acl_text[0])
 1025        ret= Xorriso_setfacl(xorriso, NULL, optv[i],
 1026                             access_acl_text, default_acl_text, 0);
 1027    }
 1028    if(ret>0 && !xorriso->request_to_abort)
 1029  continue; /* regular bottom of loop */
 1030    was_failure= 1;
 1031    fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
 1032    if(fret>=0)
 1033  continue;
 1034    ret= 0; goto ex;
 1035  }
 1036  ret= 1;
 1037 ex:;
 1038  (*idx)= end_idx;
 1039  Xorriso_opt_args(xorriso, "-setfacl", argc, argv, *idx, &end_idx,
 1040                   &optc, &optv, 256);
 1041  Findjob_destroy(&job, 0);
 1042  if(access_acl_text != NULL)
 1043    free(access_acl_text);
 1044  if(default_acl_text != NULL)
 1045    free(default_acl_text);
 1046  if(ret<=0)
 1047    return(ret);
 1048  return(!was_failure);
 1049 }
 1050 
 1051 
 1052 /* Options -setfattr alias -setfattri, -setfattr_r alias -setfattr_ri */
 1053 /* @param flag   bit0=recursive -setfattr_r
 1054 */
 1055 int Xorriso_option_setfattri(struct XorrisO *xorriso, char *name, char *value,
 1056                             int argc, char **argv, int *idx, int flag)
 1057 {
 1058  int i, ret, was_failure= 0, end_idx, fret;
 1059  int optc= 0;
 1060  char **optv= NULL;
 1061  struct FindjoB *job= NULL;
 1062  struct stat dir_stbuf;
 1063 
 1064  ret= Xorriso_opt_args(xorriso, "-setfattr", argc, argv, *idx, &end_idx, &optc,
 1065                        &optv, 0);
 1066  if(ret <= 0)
 1067    goto ex;
 1068 
 1069  /* check input */
 1070  ret= Xorriso_path_setfattr(xorriso, NULL, "", name, strlen(value), value, 1);
 1071  if(ret <= 0)
 1072     goto ex;
 1073  
 1074  for(i= 0; i<optc; i++) {
 1075    if(flag&1) {
 1076      ret= Findjob_new(&job, optv[i], 0);
 1077      if(ret<=0) {
 1078        Xorriso_no_findjob(xorriso, "-setfattr_r", 0);
 1079        {ret= -1; goto ex;}
 1080      }
 1081      Findjob_set_action_text_2(job, 27, name, value, 0);
 1082      ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
 1083                         NULL, optv[i], &dir_stbuf, 0, 0);
 1084      Findjob_destroy(&job, 0);
 1085    } else {
 1086      ret= 1;
 1087      ret= Xorriso_path_setfattr(xorriso, NULL, optv[i],
 1088                                 name, strlen(value), value, 0);
 1089    }
 1090    if(ret>0 && !xorriso->request_to_abort)
 1091  continue; /* regular bottom of loop */
 1092    was_failure= 1;
 1093    fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
 1094    if(fret>=0)
 1095  continue;
 1096    ret= 0; goto ex;
 1097  }
 1098  ret= 1;
 1099 ex:;
 1100  (*idx)= end_idx;
 1101  Xorriso_opt_args(xorriso, "-setfattr", argc, argv, *idx, &end_idx,
 1102                   &optc, &optv, 256);
 1103  Findjob_destroy(&job, 0);
 1104  if(ret<=0)
 1105    return(ret);
 1106  return(!was_failure);
 1107 }
 1108 
 1109 
 1110 /* Option -setfattr_list alias -setfattr_listi */
 1111 int Xorriso_option_setfattr_listi(struct XorrisO *xorriso, char *path,
 1112                                   int flag)
 1113 {
 1114  int ret, eaten, line_size= SfileadrL * 4;
 1115  size_t linecount= 0, mem_used= 0, num_attr= 0, v_len;
 1116  char *line= NULL, limit_text[80], *ept, *valuept;
 1117  char *file_path= NULL;
 1118  FILE *fp= NULL;
 1119  struct Xorriso_lsT *lst_curr= NULL, *lst_start= NULL;
 1120 
 1121  Xorriso_alloc_meM(line, char, line_size);
 1122  Xorriso_alloc_meM(file_path, char, SfileadrL);
 1123 
 1124  Xorriso_pacifier_reset(xorriso, 0);
 1125  if(path[0]==0) {
 1126    sprintf(xorriso->info_text, "Empty file name given with -setfattr_list");
 1127    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1128    {ret= 0; goto ex;}
 1129  }
 1130  ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 0);
 1131  if(ret <= 0)
 1132    {ret= 0; goto ex;}
 1133 
 1134  while(1) {
 1135    if(Sfile_fgets_n(line, line_size, fp, 0) == NULL)
 1136  break;
 1137    linecount++;
 1138    if(strncmp(line, "# file: ", 8) ==0) {
 1139       if(num_attr > 0 && file_path[0]) {
 1140         /* Commit previous list */
 1141         ret= Xorriso_perform_attr_from_list(xorriso, file_path, lst_start, 0);
 1142         if(ret<=0)
 1143           goto ex;
 1144         num_attr= 0;
 1145         file_path[0]= 0;
 1146         Xorriso_lst_destroy_all(&lst_start, 0);
 1147         lst_curr= NULL;
 1148       }
 1149       /* Unescape line and register as file path */
 1150       Sfile_bsl_interpreter(line + 8, strlen(line + 8), &eaten, 0);
 1151       if(strlen(line + 8) >= SfileadrL) {
 1152         sprintf(xorriso->info_text, "-setfattr_list: Oversized file path");
 1153         Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1154         ret= 0; goto ex;
 1155       }
 1156       strcpy(file_path, line + 8);
 1157  continue;
 1158    } else if(line[0] == '#' || line[0] == 0) {
 1159  continue;
 1160    } else if(strcmp(line, "@") == 0) {
 1161      Xorriso_msgs_submit(xorriso, 0,
 1162                 "-setfattr_list input ended by '@'", 0, "NOTE", 0);
 1163  break;
 1164    } else if(strcmp(line, "@@@") == 0) {
 1165      Xorriso_msgs_submit(xorriso, 0,
 1166                 "-setfattr_list aborted by input line '@@@'", 0, "WARNING", 0);
 1167      ret= 1; goto ex;
 1168    }
 1169    mem_used+= strlen(line) + 1;
 1170    if(mem_used > (size_t) xorriso->temp_mem_limit) {
 1171      Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1);
 1172      sprintf(xorriso->info_text,
 1173      "-setfattr_list: List entry for a single file exceeds -temp_mem_limit %s",
 1174               limit_text);
 1175      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1176      ret= 0; goto ex;
 1177    }
 1178 
 1179    /* Register attr pair */
 1180 
 1181    ept= strchr(line, '=');
 1182    if(ept == NULL) {
 1183      sprintf(xorriso->info_text, "-setfattr_list: ");
 1184      Text_shellsafe(path, xorriso->info_text, 1);
 1185      sprintf(xorriso->info_text + strlen(xorriso->info_text),
 1186              " : Line %.f : No separator '=' found",
 1187              (double) linecount);
 1188      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
 1189  continue;
 1190    }
 1191    valuept= ept + 1;
 1192    v_len= strlen(valuept);
 1193    for(ept= valuept + v_len - 1; ept > valuept; ept--)
 1194      if(isspace(*ept))
 1195        *ept= 0;
 1196      else
 1197    break;
 1198    v_len= strlen(valuept);
 1199    if(v_len < 2 || *valuept != '"' || *(valuept + v_len -1) != '"') {
 1200      sprintf(xorriso->info_text, "-setfattr_list: ");
 1201      Text_shellsafe(path, xorriso->info_text, 1);
 1202      sprintf(xorriso->info_text + strlen(xorriso->info_text),
 1203              " : Line %.f : Value not enclosed in quotes",
 1204              (double) linecount);
 1205      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
 1206 
 1207  continue;
 1208    }
 1209 
 1210    ret= Xorriso_lst_new(&lst_curr, line, lst_curr, 0);
 1211    if(ret <= 0)
 1212      goto out_of_mem;
 1213    if(lst_start == NULL)
 1214      lst_start= lst_curr;
 1215    num_attr++;
 1216  }
 1217 
 1218  if(file_path[0]) {
 1219    /* Commit last list */
 1220    ret= Xorriso_perform_attr_from_list(xorriso, file_path, lst_start, 0);
 1221    if(ret<=0)
 1222      goto ex;
 1223  } else {
 1224    sprintf(xorriso->info_text, "-setfattr_list: Unexpected end of file ");
 1225    Text_shellsafe(path, xorriso->info_text, 1);
 1226    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
 1227  }
 1228  ret= 1;
 1229 ex:;
 1230  if(fp != NULL && fp != stdin)
 1231    fclose(fp);
 1232  Xorriso_lst_destroy_all(&lst_start, 0);
 1233  Xorriso_free_meM(line);
 1234  Xorriso_free_meM(file_path);
 1235  if(ret <= 0) {
 1236    sprintf(xorriso->info_text, "-setfattr_list ");
 1237    Text_shellsafe(path, xorriso->info_text, 1);
 1238    sprintf(xorriso->info_text + strlen(xorriso->info_text),
 1239            " aborted in line %.f\n", (double) linecount);
 1240    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1241  }
 1242  return(ret);
 1243 out_of_mem:;
 1244  Xorriso_no_malloc_memory(xorriso, NULL, 0);
 1245  ret= -1;
 1246  goto ex;
 1247 }
 1248 
 1249 
 1250 /* Options -set_filter , -set_filter_r , -show_stream , -show_stream_r */
 1251 /* @param flag   bit0=recursive -set_filter_r
 1252                  bit1= do not reset pacifier, no final pacifier message
 1253                  bit2= -show_stream rather than -set_filter
 1254 */
 1255 int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name,
 1256                               int argc, char **argv, int *idx, int flag)
 1257 {
 1258  int i, ret, was_failure= 0, end_idx, fret;
 1259  int optc= 0;
 1260  char **optv= NULL;
 1261  struct FindjoB *job= NULL;
 1262  struct stat dir_stbuf;
 1263  char *cmd= "-set_filter";
 1264 
 1265  switch(flag & 5) {
 1266  case 0: cmd= "-set_filter";
 1267  break; case 1: cmd= "-set_filter_r";
 1268  break; case 4: cmd= "-show_stream";
 1269  break; case 5: cmd= "-show_stream_r";
 1270  }
 1271 
 1272  ret= Xorriso_opt_args(xorriso, cmd,
 1273                        argc, argv, *idx, &end_idx, &optc, &optv, 0);
 1274  if(ret <= 0)
 1275    goto ex;
 1276  if(!(flag&2))
 1277    Xorriso_pacifier_reset(xorriso, 0);
 1278 
 1279  for(i= 0; i<optc; i++) {
 1280    if(flag&1) {
 1281      ret= Findjob_new(&job, optv[i], 0);
 1282      if(ret<=0) {
 1283        Xorriso_no_findjob(xorriso, cmd, 0);
 1284        {ret= -1; goto ex;}
 1285      }
 1286      Findjob_set_action_target(job, ((flag & 4) ? 29 : 28), name, 0);
 1287      Findjob_set_file_type(job, 'f', 0);
 1288      ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
 1289                         NULL, optv[i], &dir_stbuf, 0, 0);
 1290      Findjob_destroy(&job, 0);
 1291    } else {
 1292      ret= 1;
 1293      if(flag & 4)
 1294        ret= Xorriso_show_stream(xorriso, NULL, optv[i], 0);
 1295      else
 1296        ret= Xorriso_set_filter(xorriso, NULL, optv[i], name, 0);
 1297    }
 1298    if(ret>0 && !xorriso->request_to_abort)
 1299  continue; /* regular bottom of loop */
 1300    was_failure= 1;
 1301    fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
 1302    if(fret>=0)
 1303  continue;
 1304    ret= 0; goto ex;
 1305  }
 1306  if(!(flag&2))
 1307    Xorriso_pacifier_callback(xorriso, "file filters processed",
 1308                              xorriso->pacifier_count, 0, "", 1);
 1309  ret= 1;
 1310 ex:;
 1311  (*idx)= end_idx;
 1312  Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx,
 1313                   &optc, &optv, 256);
 1314  Findjob_destroy(&job, 0);
 1315  if(ret<=0)
 1316    return(ret);
 1317  return(!was_failure);
 1318 }
 1319 
 1320 
 1321 /* Option -sh_style_result */
 1322 int Xorriso_option_sh_style_result(struct XorrisO *xorriso, char *mode,
 1323                                    int flag)
 1324 {
 1325  if(strcmp(mode, "off") == 0) {
 1326    xorriso->sh_style_result= 0;
 1327  } else if(strcmp(mode, "on") == 0) {
 1328    xorriso->sh_style_result= 1;
 1329  } else {
 1330    sprintf(xorriso->info_text, "-sh_style_result: unknown mode '%s'", mode);
 1331    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1332    return(0);
 1333  }
 1334  return(1); 
 1335 }
 1336 
 1337 
 1338 /* Option -signal_handling */
 1339 /* @param flag bit0= prescan mode: do not yet install the eventual handler
 1340                      else: when switching from other modes to "off":
 1341                            activate mode "sig_dfl"
 1342 */
 1343 int Xorriso_option_signal_handling(struct XorrisO *xorriso, char *mode,
 1344                                    int flag)
 1345 {
 1346  int ret, behavior;
 1347 
 1348  if (strcmp(mode, "off") == 0) {
 1349    behavior= Xorriso__get_signal_behavior(0);
 1350    if(flag & 1) {
 1351      behavior= 0;
 1352    } else if(behavior != 0) {
 1353      sprintf(xorriso->info_text,
 1354     "Signal handling mode \"off\" comes too late. Defaulted to \"sig_dfl\"\n");
 1355      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
 1356      behavior= 2;
 1357    }
 1358  } else if(strcmp(mode, "libburn") == 0 || strcmp(mode, "on") == 0) {
 1359    behavior= 1;
 1360  } else if (strcmp(mode, "sig_dfl") == 0) {
 1361    behavior= 2;
 1362  } else if (strcmp(mode, "sig_ign") == 0) {
 1363    behavior= 3;
 1364  } else {
 1365    sprintf(xorriso->info_text, "-signal_handling: unknown mode '%s'", mode);
 1366    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1367    Xorriso_msgs_submit(xorriso, 0,
 1368            "Use one of: \"off\",\"on\",\"sig_dfl\",\"sig_ign\"", 0, "HINT", 0);
 1369    return(0);
 1370  }
 1371  Xorriso__preset_signal_behavior(behavior, 0);
 1372  if(flag & 1)
 1373    return(1);
 1374  ret= Xorriso_set_signal_handling(xorriso, 0);
 1375  return(ret);
 1376 }
 1377 
 1378 
 1379 /* Option -sleep */
 1380 int Xorriso_option_sleep(struct XorrisO *xorriso, char *duration, int flag)
 1381 {
 1382  double dur= 0.0, start_time, end_time, todo, granularity= 0.01;
 1383  unsigned long usleep_time; 
 1384 
 1385  sscanf(duration, "%lf", &dur);
 1386  start_time= Sfile_microtime(0);
 1387  end_time= start_time + dur;
 1388  Ftimetxt(time(NULL), xorriso->info_text, 6);
 1389  sprintf(xorriso->info_text + strlen(xorriso->info_text),
 1390          " : Will sleep for %f seconds", dur);
 1391  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
 1392  while(1) {
 1393    todo= end_time - Sfile_microtime(0);
 1394    if(todo <= 0)
 1395      usleep_time= 0;
 1396    else if(todo > granularity)
 1397      usleep_time= granularity * 1.0e6;
 1398    else
 1399      usleep_time= todo * 1.0e6;
 1400    if(usleep_time == 0)
 1401  break;
 1402    usleep(usleep_time);
 1403  }
 1404  sprintf(xorriso->info_text, "Slept for %f seconds",
 1405          Sfile_microtime(0) - start_time);
 1406  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
 1407  return(1);
 1408 }
 1409 
 1410 
 1411 /* Commands -speed , -read_speed */
 1412 /* @param flag bit0= -read_speed rather than -speed
 1413 */
 1414 int Xorriso_option_speed(struct XorrisO *xorriso, char *speed_in, int flag)
 1415 {
 1416  int is_cd= 1, unit_found= 0, ret, profile_number, intspeed= 1, for_force= 0;
 1417  double num= -2.0;
 1418  char *cpt, profile_name[80], *speed;
 1419 
 1420  speed= speed_in;
 1421 
 1422  if(strncmp(speed, "soft_corr:", 10) == 0 && (flag & 1)) {
 1423    sscanf(speed + 10, "%lf", &num);
 1424    if(num > 1.0e9 || num < 0.0) {
 1425      sprintf(xorriso->info_text,
 1426       "-read_speed soft_corr: Value too small or too large (0 to 1e9): '%s'",
 1427              speed + 10);
 1428      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
 1429      return(0);
 1430    } 
 1431    xorriso->read_speed_corr= num;
 1432    return(1);
 1433  }
 1434 
 1435  if(strncmp(speed, "soft_force:", 11) == 0 && (flag & 1)) {
 1436    for_force= 1;
 1437    speed+= 11;
 1438  }
 1439  if(speed[0] == 0 || strcmp(speed, "any") == 0 || strcmp(speed, "max") == 0) {
 1440    intspeed= 0;
 1441  } else if(strcmp(speed, "min") == 0) {
 1442    intspeed= -1;
 1443  } else if(strcmp(speed, "none") == 0) {
 1444    intspeed= -2;
 1445  } else {
 1446    sscanf(speed,"%lf",&num);
 1447    if(num <= 0)
 1448      intspeed= num;
 1449  }
 1450  if(intspeed <= 0)
 1451    goto set_speed_and_exit;
 1452 
 1453  for(cpt= speed+strlen(speed)-1; cpt>=speed; cpt--)
 1454    if(isdigit(*cpt) || *cpt=='.')
 1455  break;
 1456  cpt++;
 1457 
 1458  if(*cpt=='k' || *cpt=='K') {
 1459    /* is merchand kilobyte, stays merchand kilobyte */
 1460    unit_found= 1;
 1461  } else if(*cpt=='m' || *cpt=='M') {
 1462    num*= 1000;
 1463    unit_found= 1;
 1464  } else if(*cpt=='x' || *cpt=='X')
 1465    cpt++;
 1466 
 1467  if (unit_found) {
 1468    ;
 1469  } else if(*cpt=='c' || *cpt=='C') {
 1470 cd_speed:;
 1471    num*= 176.4;
 1472  } else if(*cpt=='d' || *cpt=='D') {
 1473 dvd_speed:;
 1474    num*= 1385;
 1475  } else if(*cpt=='b' || *cpt=='B') {
 1476 bd_speed:;
 1477    num*= 4495.625;
 1478  } else {
 1479    ret= Xorriso_get_profile(xorriso, &profile_number, profile_name,
 1480                             2 * !(flag & 1));
 1481    is_cd= (ret==2);
 1482    if(is_cd)
 1483      goto cd_speed;
 1484    else if (ret == 3)
 1485      goto bd_speed;
 1486    else
 1487      goto dvd_speed;
 1488  }
 1489 
 1490  if(num> 2.0e9) {
 1491    sprintf(xorriso->info_text,
 1492            "%s: Value too large or not recognizable: '%s'",
 1493            flag & 1 ? "-read_speed" : "-speed", speed);
 1494    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
 1495    return(0);
 1496  }
 1497  intspeed= num;
 1498  if(intspeed < num)
 1499    intspeed++;
 1500 
 1501 set_speed_and_exit:;
 1502  if(flag & 1) {
 1503    if(for_force)
 1504      xorriso->read_speed_force= intspeed;
 1505    else
 1506      xorriso->read_speed= intspeed;
 1507  } else {
 1508    xorriso->write_speed= intspeed;
 1509  }
 1510  return(1);
 1511 }
 1512 
 1513 
 1514 /* Option -split_size */
 1515 int Xorriso_option_split_size(struct XorrisO *xorriso, char *size, int flag)
 1516 {
 1517  double num;
 1518 
 1519  num= Scanf_io_size(size, 0);
 1520  if(num > xorriso->file_size_limit && xorriso->file_size_limit > 0) {
 1521    sprintf(xorriso->info_text, "-split_size: too large %.f (allowed: %.f)",
 1522            num, (double) xorriso->file_size_limit);
 1523    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1524    return(0);
 1525  } else if(num < 0)
 1526    num= 0.0;
 1527  xorriso->split_size= num;
 1528  return(1);
 1529 }
 1530 
 1531 
 1532 /* Option -status */
 1533 int Xorriso_option_status(struct XorrisO *xorriso, char *mode, int flag)
 1534 {
 1535  if(strcmp(mode,"short")==0)
 1536    Xorriso_status(xorriso,NULL,NULL,1);
 1537  else if(strcmp(mode,"long")==0)
 1538    Xorriso_status(xorriso,NULL,NULL,0);
 1539  else if(strcmp(mode,"long_history")==0)
 1540    Xorriso_status(xorriso,NULL,NULL,8);
 1541  else if(mode[0]=='-')
 1542    Xorriso_status(xorriso,mode,NULL,8);
 1543  else
 1544    Xorriso_status(xorriso,NULL,NULL,1);
 1545  return(1);
 1546 }
 1547 
 1548 
 1549 /* Option -status_history_max */
 1550 int Xorriso_option_status_history_max(struct XorrisO *xorriso, int num,
 1551                                       int flag)
 1552 {
 1553  if(num>=0 && num<1000000)
 1554    xorriso->status_history_max= num;
 1555  return(1);
 1556 }
 1557 
 1558 
 1559 /* Option -stdio_sync "on"|"off"|"end"|size */
 1560 int Xorriso_option_stdio_sync(struct XorrisO *xorriso, char *rhythm, int flag)
 1561 {
 1562  double num;
 1563 
 1564  if(strcmp(rhythm, "default") == 0 || strcmp(rhythm, "on") == 0) {
 1565    num= 0;
 1566  } else if(strcmp(rhythm, "off") == 0) {
 1567    num= -1;
 1568  } else if(strcmp(rhythm, "end") == 0) {
 1569    num= 1;
 1570  } else {
 1571    num = Scanf_io_size(rhythm, 0) / 2048;
 1572    if(num < 32 || num > 512 * 1024) {
 1573      sprintf(xorriso->info_text,
 1574            "-stdio_sync : Bad size. Use: 64k to 1g, \"on\", \"off\", \"end\"");
 1575      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
 1576      return(0);
 1577    }
 1578  }
 1579  xorriso->stdio_sync= num;
 1580  xorriso->stdio_sync_is_default= 0;
 1581  return(1);
 1582 }
 1583 
 1584 
 1585 /* Option -stream_recording */
 1586 int Xorriso_option_stream_recording(struct XorrisO *xorriso, char *mode,
 1587                                     int flag)
 1588 {
 1589  double num;
 1590 
 1591  if(strcmp(mode,"on")==0 || mode[0]==0)
 1592    xorriso->do_stream_recording= 32;
 1593  else if(strcmp(mode,"full")==0)
 1594    xorriso->do_stream_recording= 1;
 1595  else if(strcmp(mode,"data")==0)
 1596    xorriso->do_stream_recording= 2;
 1597  else if(mode[0] >= '0' && mode[0] <= '9') {
 1598    num= Scanf_io_size(mode, 0);
 1599    num/= 2048.0;
 1600    if(num >= 16 && num <= 0x7FFFFFFF)
 1601      xorriso->do_stream_recording= num;
 1602    else
 1603      xorriso->do_stream_recording= 0;
 1604  } else
 1605    xorriso->do_stream_recording= 0;
 1606  return(1);
 1607 }
 1608 
 1609 
 1610 /* Option -system_id */
 1611 int Xorriso_option_system_id(struct XorrisO *xorriso, char *name, int flag)
 1612 {
 1613   if(Xorriso_check_name_len(xorriso, name, (int) sizeof(xorriso->system_id),
 1614                             "-system_id", 0) <= 0)
 1615     return(0);
 1616  strcpy(xorriso->system_id, name);
 1617  Xorriso_set_change_pending(xorriso, 1);
 1618  return(1);
 1619 }
 1620 
 1621 
 1622 /* Option -tell_media_space */
 1623 int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag)
 1624 {
 1625  int ret, free_space= 0, media_space= 0;
 1626 
 1627  ret= Xorriso_tell_media_space(xorriso, &media_space, &free_space, 0);
 1628  if(ret<=0) {
 1629    sprintf(xorriso->info_text, "Cannot -tell_media_space");
 1630    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
 1631    return(0);
 1632  }
 1633  if(free_space<0) {
 1634    sprintf(xorriso->info_text,
 1635            "Pending image size larger than free space on medium");
 1636    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
 1637  }
 1638  sprintf(xorriso->result_line, "Media space  : %ds\n", media_space);
 1639  Xorriso_result(xorriso, 0);
 1640  sprintf(xorriso->result_line, "After commit : %ds\n", free_space);
 1641  Xorriso_result(xorriso, 0);
 1642  return(1);
 1643 }
 1644 
 1645 
 1646 /* Option -temp_mem_limit */
 1647 int Xorriso_option_temp_mem_limit(struct XorrisO *xorriso, char *size,
 1648                                   int flag)
 1649 {
 1650  double num;
 1651 
 1652  num= Scanf_io_size(size, 0);
 1653  if(num < 64.0 * 1024.0 || num > 1024.0 * 1024.0 * 1024.0) {
 1654    sprintf(xorriso->info_text,
 1655            "-temp_mem_limit: wrong size %.f (allowed: %.f - %.f)",
 1656            num, 64.0 * 1024.0, 1024.0 * 1024.0 * 1024.0);
 1657    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
 1658    return(0);
 1659  }
 1660  xorriso->temp_mem_limit= num;
 1661  return(1);
 1662 }
 1663 
 1664 
 1665 /* Option -toc */
 1666 /* @param flag   bit0= short report form as with -dev, no table-of-content
 1667 */
 1668 int Xorriso_option_toc(struct XorrisO *xorriso, int flag)
 1669 {
 1670  int ret, in_ret= 1000;
 1671 
 1672  if(strcmp(xorriso->indev,xorriso->outdev)==0)
 1673    ret= Xorriso_toc(xorriso, 0);
 1674  else {
 1675    if(xorriso->indev[0]!=0)
 1676      in_ret= Xorriso_toc(xorriso, 0);
 1677    if(xorriso->indev[0]!=0 && xorriso->outdev[0]!=0) {
 1678      strcpy(xorriso->result_line, "-------------: ---------------------------------------------------------------\n");
 1679      Xorriso_result(xorriso,0);
 1680    }
 1681    ret= 1;
 1682    if(xorriso->outdev[0]!=0)
 1683      ret= Xorriso_toc(xorriso, 2 | (flag & 1));
 1684    if(in_ret<ret)
 1685      ret= in_ret;
 1686  }
 1687  return(ret);
 1688 }
 1689 
 1690 
 1691 /* Option -toc_of */
 1692 int Xorriso_option_toc_of(struct XorrisO *xorriso, char *which, int flag)
 1693 {
 1694  int ret= 0, toc_flag= 0;
 1695 
 1696  if(strstr(which, ":short") != NULL)
 1697    toc_flag|= 1;
 1698  if(strncmp(which, "in", 2) == 0) {
 1699    if(xorriso->indev[0] == 0) {
 1700      Xorriso_msgs_submit(xorriso, 0, "-toc_of 'in' : No input drive acquired",
 1701                          0, "NOTE", 0);
 1702      return(2);
 1703    }
 1704    ret= Xorriso_toc(xorriso, toc_flag | 0);
 1705  } else if(strncmp(which, "out", 3) == 0) {
 1706    if(xorriso->outdev[0] == 0) {
 1707      Xorriso_msgs_submit(xorriso, 0,
 1708                          "-toc_of 'out' : No output drive acquired",
 1709                          0, "NOTE", 0);
 1710      return(2);
 1711    }
 1712    ret= Xorriso_toc(xorriso, toc_flag | 2);
 1713  } else if(strncmp(which, "all", 3) == 0) {
 1714    if(xorriso->indev[0] == 0 && xorriso->outdev[0] == 0) {
 1715      Xorriso_msgs_submit(xorriso, 0, "-toc_of 'all' : No drive acquired",
 1716                          0, "NOTE", 0);
 1717      return(2);
 1718    }
 1719    ret= Xorriso_option_toc(xorriso, toc_flag | 0);
 1720  } else {
 1721    sprintf(xorriso->info_text, "-toc_of: Unknown drive code ");
 1722    Text_shellsafe(which, xorriso->info_text, 1);
 1723    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
 1724    ret= 0;
 1725  }
 1726  return(ret);
 1727 }
 1728 
 1729 
 1730 /* Command -truncate_overwritable */
 1731 int Xorriso_option_truncate_overwritable(struct XorrisO *xorriso,
 1732                                          char *adr_mode, char *adr_value,
 1733                                          char *adjust, int flag)
 1734 {
 1735  int ret;
 1736 
 1737  ret= Xorriso_truncate_overwritable(xorriso, adr_mode, adr_value, adjust, 0);
 1738  return(ret);
 1739 }
 1740 
 1741 
 1742 /* Option -uid */
 1743 int Xorriso_option_uid(struct XorrisO *xorriso, char *uid, int flag)
 1744 {
 1745  int ret;
 1746 
 1747  xorriso->do_global_uid= 0;
 1748  if(uid[0]==0 || strcmp(uid,"-")==0)
 1749    return(1);
 1750  ret= Xorriso_convert_uidstring(xorriso, uid, &(xorriso->global_uid), 0);
 1751  if(ret>0) 
 1752    xorriso->do_global_uid= 1;
 1753  return(ret);
 1754 }
 1755 
 1756 
 1757 /* Option -unregister_filter */
 1758 int Xorriso_option_unregister_filter(struct XorrisO *xorriso, char *name,
 1759                                      int flag)
 1760 {
 1761  int ret;
 1762 
 1763  ret= Xorriso_external_filter(xorriso, name, "", "", 0, NULL, 1);
 1764  return(ret);
 1765 }
 1766 
 1767 
 1768 /* Options -update and -update_r
 1769    @param flag bit0= issue start and summary message
 1770                bit1= do not reset pacifier, no final pacifier message
 1771                bit2= do not issue pacifier messages at all
 1772                bit3= recursive: -update_r
 1773                bit4= do not establish and dispose xorriso->di_array
 1774                bit5= do not delete files which are not found under
 1775                      disk_path, but rather mark visited files and mark
 1776                      files which were found.
 1777 */
 1778 int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path,
 1779                           char *iso_path, int flag)
 1780 {
 1781  int ret, mem_pci, zero= 0, result, uret, follow_links, do_register= 0;
 1782  int not_in_iso= 0, not_on_disk= 0;
 1783  double mem_lut= 0.0, start_time;
 1784  char *ipth, *argv[6];
 1785  char *eff_origin= NULL, *eff_dest= NULL;
 1786  struct stat stbuf;
 1787 
 1788  Xorriso_alloc_meM(eff_origin, char, SfileadrL);
 1789  Xorriso_alloc_meM(eff_dest, char, SfileadrL);
 1790 
 1791  start_time= Sfile_microtime(0);
 1792 
 1793  ipth= iso_path;
 1794  if(ipth[0]==0)
 1795    ipth= disk_path;
 1796  if(disk_path[0]==0) {
 1797    sprintf(xorriso->info_text, "-update: Empty disk_path given");
 1798    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
 1799    {ret= 0; goto ex;}
 1800  }
 1801 
 1802  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_origin,
 1803                                  2|4|8);
 1804  if(ret<=0)
 1805    goto ex;
 1806  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_dest, 2|8);
 1807  if(ret<=0)
 1808    goto ex;
 1809 
 1810  if(!(flag&2)) {
 1811    Xorriso_pacifier_reset(xorriso, 0);
 1812    mem_lut= xorriso->last_update_time;
 1813  }
 1814  mem_pci= xorriso->pacifier_interval;
 1815  xorriso->pacifier_interval= 5.0;
 1816 
 1817  if(flag&1) {
 1818    sprintf(xorriso->info_text, "Updating ");
 1819    Text_shellsafe(eff_origin, xorriso->info_text, 1);
 1820    strcat(xorriso->info_text, " to ");
 1821    Text_shellsafe(eff_dest, xorriso->info_text, 1 | 2);
 1822    strcat(xorriso->info_text, "\n");
 1823    Xorriso_info(xorriso,0);
 1824  }
 1825  if(xorriso->disk_excl_mode&8)
 1826    ret= Xorriso_path_is_excluded(xorriso, eff_origin, 1);
 1827  else
 1828    ret= 0;
 1829  if(ret!=0)
 1830    goto report_outcome;
 1831 
 1832  if(!(xorriso->ino_behavior & 2)) {
 1833    if(!(xorriso->di_array != NULL || (flag & 16))) {
 1834      /* Create all-image node array sorted by isofs.di */
 1835      ret= Xorriso_make_di_array(xorriso, 0);
 1836      if(ret <= 0)
 1837        goto ex;
 1838    }
 1839    if(xorriso->di_array != NULL) {
 1840      do_register= 1;
 1841      if(!(flag & 8)) {
 1842        /* If directory with -update : do not register di_*_paths */
 1843        ret= lstat(eff_origin, &stbuf);
 1844        if(ret != -1)
 1845          if(S_ISDIR(stbuf.st_mode))
 1846            do_register= 0;
 1847      }
 1848    }
 1849  }
 1850 
 1851  if(flag&8) {
 1852    xorriso->find_compare_result= 1;
 1853    ret= Xorriso_iso_lstat(xorriso, eff_dest, &stbuf, 0);
 1854    if(ret >= 0) {
 1855      argv[0]= eff_dest;
 1856      argv[1]= "-exec";
 1857      if(flag & 32)
 1858        argv[2]= "update_merge";
 1859      else
 1860        argv[2]= "update";
 1861      argv[3]= eff_origin;
 1862      zero= 0;
 1863      ret= Xorriso_option_find(xorriso, 4, argv, &zero,
 1864                       2 | (8 * !((xorriso->do_aaip & 96) == 96))); /* -findi */
 1865    } else if(ret==-2) { /* severe error (e.g. lack of image) */
 1866      ret= -1;
 1867      goto report_outcome;
 1868    } else {
 1869      not_in_iso= 1;
 1870      ret= 1;
 1871    }
 1872    if(ret>0) {
 1873      ret= lstat(eff_origin, &stbuf);
 1874      if(ret != -1) {
 1875        argv[0]= eff_origin;
 1876        argv[1]= "-exec";
 1877        argv[2]= "add_missing";
 1878        argv[3]= eff_dest;
 1879        zero= 0;
 1880        ret= Xorriso_option_find(xorriso, 4, argv, &zero, 1|2); /* -findx */
 1881        if(ret>0 && (!xorriso->do_follow_mount) && !(flag & 32)) {
 1882 
 1883          /* >>> ??? what about mount points with (flag & 32) ?
 1884                 empty_iso_dir shall delete those which already existed
 1885                 and are freshly excluded. (E.g. by mounting at a non-empty
 1886                 directory, or by new follow rules.)
 1887                 This deletion does not match the idea of merging.
 1888                 For determining the foreign files in a directory which is
 1889                 target of a mount point, one would have to enter that mount
 1890                 point directory. Somewhat contrary to do-not-follow.
 1891          */
 1892 
 1893          argv[0]= eff_origin;
 1894          argv[1]= "-type";
 1895          argv[2]= "m";
 1896          argv[3]= "-exec";
 1897          argv[4]= "empty_iso_dir";
 1898          argv[5]= eff_dest;
 1899          zero= 0;
 1900          ret= Xorriso_option_find(xorriso, 6, argv, &zero, 1|2); /* -findx */
 1901        }
 1902        if(ret>0)
 1903          ret= xorriso->find_compare_result;
 1904        else
 1905          ret= -1;
 1906      } else {
 1907        ret= xorriso->find_compare_result;
 1908        not_on_disk= 1;
 1909      }
 1910    } else
 1911      ret= -1;
 1912    if(not_on_disk && not_in_iso) {
 1913      sprintf(xorriso->info_text, "Missing on disk and in ISO: disk_path ");
 1914      Text_shellsafe(disk_path, xorriso->info_text, 1);
 1915      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
 1916      ret= -1;
 1917    }
 1918  } else {
 1919    if(flag & 32)
 1920      xorriso->update_flags|= 1; /* Enter update_merge mode for node adding */
 1921    /* compare ctime too, no filename reporting, eventually silent */
 1922    follow_links= (xorriso->do_follow_links || xorriso->do_follow_param) <<28;
 1923    ret= Xorriso_compare_2_files(xorriso, eff_origin, eff_dest, "", &result,
 1924                                 2 | follow_links | ((flag&4)<<27) | (3<<30));
 1925    if(ret == 0 || (ret > 0 && (flag & 32))) {
 1926      if(ret > 0)
 1927        result= 0;
 1928      uret= Xorriso_update_interpreter(xorriso, NULL, NULL, result, eff_origin,
 1929                                       eff_dest, (!!(flag & 32)) << 1);
 1930      if(uret<=0)
 1931        ret= -1;
 1932      if(uret==3)
 1933        ret= -1;
 1934    }
 1935  }
 1936  xorriso->pacifier_interval= mem_pci;
 1937  if(mem_lut!=xorriso->last_update_time && !(flag & (2 | 4)))
 1938    Xorriso_pacifier_callback(xorriso, "content bytes read",
 1939                              xorriso->pacifier_count, 0, "", 1 | 8 | 32);
 1940 report_outcome:;
 1941  if(ret>0) {
 1942    sprintf(xorriso->info_text,
 1943            "No file object needed update.");
 1944    do_register= 0;
 1945  } else if(ret==0) {
 1946    sprintf(xorriso->info_text, "Differences detected and updated.");
 1947  } else {
 1948    sprintf(xorriso->info_text,
 1949            "Not ok. Comparison or update failed due to error.");
 1950    do_register= 0;
 1951  }
 1952 
 1953  if(do_register) {
 1954    ret= Xorriso_iso_lstat(xorriso, eff_dest, &stbuf, 0);
 1955    if(ret < 0)
 1956      do_register= 0;
 1957  }
 1958  if(do_register) {
 1959    ret= Xorriso_lst_new(&(xorriso->di_disk_paths), eff_origin,
 1960                         xorriso->di_disk_paths, 1);
 1961    if(ret <= 0)
 1962      goto ex;
 1963    ret= Xorriso_lst_new(&(xorriso->di_iso_paths), eff_dest,
 1964                         xorriso->di_iso_paths, 1);
 1965    if(ret <= 0)
 1966      goto ex;
 1967  }
 1968  sprintf(xorriso->info_text+strlen(xorriso->info_text),
 1969          " (runtime %.1f s)\n", Sfile_microtime(0)-start_time);
 1970  if(flag&1)
 1971    Xorriso_info(xorriso,0);
 1972 
 1973 ex:;
 1974  Xorriso_free_meM(eff_origin);
 1975  Xorriso_free_meM(eff_dest);
 1976  if(ret < 0)
 1977    return(ret);
 1978  return(1);
 1979 }
 1980 
 1981 
 1982 /* Command -use_immed_bit */
 1983 int Xorriso_option_use_immed_bit(struct XorrisO *xorriso, char *mode,
 1984                                  int flag)
 1985 {
 1986  int ret;
 1987 
 1988  if(strncmp(mode, "default", 7) == 0 || mode[0] == 0) {
 1989    xorriso->use_immed_bit= 0;
 1990  } else if(strcmp(mode, "on")==0) {
 1991    xorriso->use_immed_bit= 1;
 1992  } else if(strcmp(mode, "off")==0) {
 1993    xorriso->use_immed_bit= -1;
 1994  } else {
 1995    sprintf(xorriso->info_text, "-use_immed_bit: unknown mode '%s'", mode);
 1996    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1997    return(0);
 1998  }
 1999  ret= Xorriso_use_immed_bit(xorriso, 0);
 2000  return(ret);
 2001 }
 2002 
 2003 
 2004 /* Option -use_readline */
 2005 int Xorriso_option_use_readline(struct XorrisO *xorriso, char *mode, int flag)
 2006 {
 2007  if(strcmp(mode,"off")==0)
 2008    xorriso->use_stdin= 1;
 2009  else
 2010    xorriso->use_stdin= 0;
 2011  return(1);
 2012 }
 2013 
 2014 
 2015 /* Option -version */
 2016 int Xorriso_option_version(struct XorrisO *xorriso, int flag)
 2017 {
 2018  const char *license_text;
 2019 
 2020  sprintf(xorriso->result_line, "%sxorriso %d.%d.%d%s\n",
 2021 #ifdef Xorriso_GNU_xorrisO
 2022          "GNU ",
 2023 #else
 2024          "",
 2025 #endif /* ! Xorriso_GNU_xorrisO */
 2026          Xorriso_header_version_majoR, Xorriso_header_version_minoR,
 2027          Xorriso_header_version_micrO, Xorriso_program_patch_leveL);
 2028  Xorriso_result(xorriso, 0);
 2029  sprintf(xorriso->result_line,
 2030 "ISO 9660 Rock Ridge filesystem manipulator and CD/DVD/BD burn program\n");
 2031  sprintf(xorriso->result_line+strlen(xorriso->result_line),
 2032 "Copyright (C) 2019, Thomas Schmitt <scdbackup@gmx.net>, libburnia project.\n");
 2033  Xorriso_result(xorriso, 0);
 2034  sprintf(xorriso->result_line,
 2035          "xorriso version   :  %d.%d.%d%s\n",
 2036          Xorriso_header_version_majoR, Xorriso_header_version_minoR,
 2037          Xorriso_header_version_micrO, Xorriso_program_patch_leveL);
 2038  Xorriso_result(xorriso, 0);
 2039  sprintf(xorriso->result_line, "Version timestamp :  %s\n",Xorriso_timestamP);
 2040  Xorriso_result(xorriso, 0);
 2041  sprintf(xorriso->result_line,
 2042          "Build timestamp   :  %s\n",Xorriso_build_timestamP);
 2043  Xorriso_result(xorriso, 0);
 2044  Xorriso_report_lib_versions(xorriso, 0);
 2045 
 2046 #ifdef Xorriso_GNU_xorrisO
 2047 
 2048  license_text= "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.";
 2049  sprintf(xorriso->result_line, "%s\n", license_text);
 2050  Xorriso_result(xorriso, 0);
 2051  sprintf(xorriso->result_line,
 2052 "This is free software: you are free to change and redistribute it.\n");
 2053  Xorriso_result(xorriso, 0);
 2054 
 2055 #else
 2056 
 2057  license_text= "Provided under GNU GPL version 2 or later.";
 2058 
 2059 #ifdef Xorriso_with_readlinE
 2060  {
 2061    const char *readline_license;
 2062    readline_license= Xorriso__readline_license(0);
 2063    if(strcmp(readline_license, "GPLv3+") == 0)
 2064      license_text=
 2065       "Provided under GNU GPL version 3 or later, due to libreadline license.";
 2066  }
 2067 #endif /* Xorriso_with_readlinE */
 2068 
 2069  sprintf(xorriso->result_line, "%s\n", license_text);
 2070  Xorriso_result(xorriso, 0);
 2071 #endif /* ! Xorriso_GNU_xorrisO */
 2072 
 2073  sprintf(xorriso->result_line,
 2074 "There is NO WARRANTY, to the extent permitted by law.\n");
 2075  Xorriso_result(xorriso, 0);
 2076  return(1);
 2077 }
 2078 
 2079 
 2080 /* Option -volid */
 2081 /* @param flag bit0= do not warn of problematic volid
 2082 */
 2083 int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag)
 2084 {
 2085  int warn_shell= 0, warn_ecma= 0, i, ret;
 2086  static char shell_chars[]= {
 2087     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-+=:.,~@"};
 2088  static char ecma_chars[]= {"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"};
 2089 
 2090  for(i=0; volid[i]!=0; i++) {
 2091    if(strchr(shell_chars, volid[i])==NULL)
 2092      warn_shell= 1;
 2093    if(strchr(ecma_chars, volid[i])==NULL)
 2094      warn_ecma= 1;
 2095  }
 2096  if(i>32) {
 2097    sprintf(xorriso->info_text, "-volid: Text too long (%d > 32)", i);
 2098    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 2099    return(0);
 2100  }
 2101  if(warn_shell && !(flag & 1)) {
 2102    sprintf(xorriso->info_text,
 2103            "-volid text problematic as automatic mount point name");
 2104    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
 2105  }
 2106  if(xorriso->do_joliet && strlen(volid)>16 && !(flag & 1)) {
 2107    sprintf(xorriso->info_text,
 2108            "-volid text is too long for Joliet (%d > 16)",(int) strlen(volid));
 2109    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
 2110  }
 2111  if(warn_ecma && !(flag & 1)) {
 2112    sprintf(xorriso->info_text,
 2113           "-volid text does not comply to ISO 9660 / ECMA 119 rules");
 2114    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
 2115  }
 2116  strcpy(xorriso->volid, volid);
 2117  ret= Xorriso_set_volid(xorriso, volid, 0);
 2118  if(ret<=0)
 2119    return(ret);
 2120  xorriso->volid_default= (strcmp(xorriso->volid, "ISOIMAGE")==0 ||
 2121                           xorriso->volid[0]==0);
 2122  return(1);
 2123 }
 2124 
 2125 
 2126 /* Option -volset_id */
 2127 int Xorriso_option_volset_id(struct XorrisO *xorriso, char *name, int flag)
 2128 {
 2129   if(Xorriso_check_name_len(xorriso, name, (int) sizeof(xorriso->volset_id),
 2130                             "-volset_id", 0) <= 0)
 2131     return(0);
 2132  strcpy(xorriso->volset_id, name);
 2133  Xorriso_set_change_pending(xorriso, 1);
 2134  return(1);
 2135 }
 2136 
 2137 
 2138 /* Option -volume_date */
 2139 int Xorriso_option_volume_date(struct XorrisO *xorriso,
 2140                                char *time_type, char *timestring, int flag)
 2141 {
 2142  int ret, t_type= 0;
 2143  time_t t;
 2144  struct tm erg;
 2145 
 2146  if(timestring[0] == 0 || strcmp(timestring, "default") == 0 ||
 2147     strcmp(timestring, "overridden") == 0 ){
 2148    t= 0;
 2149  } else if(strcmp(time_type, "uuid") == 0 ||
 2150            (strcmp(time_type, "all_file_dates") == 0 &&
 2151             strcmp(timestring, "set_to_mtime") == 0)) {
 2152    t= time(NULL); /* Just to have some that is not 0 */
 2153  } else {
 2154    ret= Xorriso_convert_datestring(xorriso, "-volume_date",
 2155                                    "m", timestring, &t_type, &t, 0);
 2156    if(ret<=0)
 2157      goto ex;
 2158  }
 2159  if(strcmp(time_type, "uuid") == 0) {
 2160    if(t == 0) {
 2161      xorriso->vol_uuid[0]= 0;
 2162      ret= 1; goto ex;
 2163    }
 2164    ret= Decode_ecma119_format(&erg, timestring, 0);
 2165    if(ret <= 0 || strlen(timestring) != 16) {
 2166      sprintf(xorriso->info_text, "-volume_date uuid : Not an ECMA-119 time string. (16 decimal digits, range 1970... to 2999...)");
 2167      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 2168      ret= 0; goto ex;
 2169    }
 2170    strcpy(xorriso->vol_uuid, timestring);
 2171    if(erg.tm_year < 138) {
 2172      sprintf(xorriso->info_text,
 2173              "Understanding ECMA-119 timestring '%s' as:  %s",
 2174              timestring, asctime(&erg));
 2175      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
 2176    }
 2177 
 2178  } else if(strcmp(time_type, "all_file_dates") == 0) {
 2179    if(t == 0) {
 2180      xorriso->all_file_dates[0]= 0;
 2181      ret= 1; goto ex;
 2182    }
 2183    strncpy(xorriso->all_file_dates, timestring,
 2184            sizeof(xorriso->all_file_dates) - 1);
 2185    xorriso->all_file_dates[sizeof(xorriso->all_file_dates) - 1]= 0;
 2186 
 2187  } else if(strcmp(time_type, "c") == 0) {
 2188    xorriso->vol_creation_time= t;
 2189  } else if(strcmp(time_type, "m") == 0) {
 2190    xorriso->vol_modification_time= t;
 2191  } else if(strcmp(time_type, "x") == 0) {
 2192    xorriso->vol_expiration_time= t;
 2193  } else if(strcmp(time_type, "f") == 0) {
 2194    xorriso->vol_effective_time= t;
 2195  } else {
 2196 
 2197    /* >>> unknown time type */;
 2198 
 2199    ret= 0; goto ex;
 2200  }
 2201  ret= 1;
 2202 ex:;
 2203  return(ret);
 2204 }
 2205 
 2206 
 2207 /* Command -write_type */
 2208 int Xorriso_option_write_type(struct XorrisO *xorriso, char *mode, int flag)
 2209 {
 2210  if(strcmp(mode, "auto") == 0)
 2211    xorriso->do_tao = 0;
 2212  else if(strcmp(mode, "tao") == 0 || strcmp(mode, "TAO") == 0) 
 2213    xorriso->do_tao = 1;
 2214  else if(strcmp(mode, "sao") == 0 || strcmp(mode, "SAO") == 0 ||
 2215          strcmp(mode, "dao") == 0 || strcmp(mode, "DAO") == 0 ||
 2216          strcmp(mode, "sao/dao") == 0 || strcmp(mode, "SAO/DAO") == 0 ) 
 2217    xorriso->do_tao = -1;
 2218  else {
 2219    sprintf(xorriso->info_text, "-write_type: unknown mode '%s'", mode);
 2220    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 2221    return(0);
 2222  }
 2223  return(1);
 2224 }
 2225 
 2226 
 2227 /* Option -xattr "on"|"off" */
 2228 int Xorriso_option_xattr(struct XorrisO *xorriso, char *mode, int flag)
 2229 {
 2230  int ret;
 2231 
 2232  if(strcmp(mode, "off") == 0) {
 2233    xorriso->do_aaip&= ~(4 | 8 | 1024);
 2234  } else if(strcmp(mode, "on") == 0 || strcmp(mode, "user") == 0) {
 2235    xorriso->do_aaip&= ~1024;
 2236    xorriso->do_aaip|= (4 | 8);
 2237  } else if(strcmp(mode, "any") == 0) {
 2238    xorriso->do_aaip|= (4 | 8 | 1024);
 2239  } else {
 2240    sprintf(xorriso->info_text, "-xattr: unknown mode '%s'", mode);
 2241    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 2242    return(0);
 2243  }
 2244  ret= Xorriso_set_ignore_aclea(xorriso, 0);
 2245  if(ret <= 0)
 2246    return(ret);
 2247  return(1);
 2248 }
 2249 
 2250 
 2251 /* Option -zisofs */
 2252 int Xorriso_option_zisofs(struct XorrisO *xorriso, char *mode, int flag)
 2253 {
 2254  int was_level, was_blocksize, was_v2_enabled, was_blocksize_v2;
 2255  int was_zisofs_susp_z2;
 2256  uint64_t was_max_total_blocks, was_max_file_blocks, was_block_number_target;
 2257  int ret, l, i, sticky, set_isofs_params= 0;
 2258  double num, was_bpt_discard_free_ratio;
 2259  char *cpt, *npt;
 2260 
 2261  was_level= xorriso->zlib_level;
 2262  was_blocksize= xorriso->zisofs_block_size;
 2263  was_v2_enabled= xorriso->zisofs_v2_enabled;
 2264  was_max_total_blocks= xorriso->zisofs_max_total_blocks;
 2265  was_max_file_blocks= xorriso->zisofs_max_file_blocks;
 2266  was_blocksize_v2= xorriso->zisofs_v2_block_size;
 2267  was_block_number_target= xorriso->zisofs_block_number_target;
 2268  was_bpt_discard_free_ratio= xorriso->zisofs_bpt_discard_free_ratio;
 2269  was_zisofs_susp_z2= xorriso->zisofs_susp_z2;
 2270 
 2271  npt= cpt= mode;
 2272  for(cpt= mode; npt!=NULL; cpt= npt+1) {
 2273    npt= strchr(cpt,':');
 2274    if(npt==NULL)
 2275      l= strlen(cpt);
 2276    else
 2277      l= npt-cpt;
 2278    if(l==0)
 2279      goto unknown_mode;
 2280 
 2281    if(strncmp(cpt, "level=", 6) == 0) {
 2282      sscanf(cpt + 6, "%lf", &num);
 2283      if(num < 0 || num > 9) {
 2284        sprintf(xorriso->info_text,
 2285                "-zisofs: Wrong zlib compression level '%s' (allowed 0...9)",
 2286                cpt + 6);
 2287        goto sorry_ex;
 2288      }
 2289      xorriso->zlib_level= num;
 2290 
 2291    } else if(strncmp(cpt, "ziso_used=", 10) == 0 ||
 2292              strncmp(cpt, "osiz_used=", 10) == 0 ||
 2293              strncmp(cpt, "gzip_used=", 10) == 0 ||
 2294              strncmp(cpt, "gunzip_used=", 12) == 0 ||
 2295              strncmp(cpt, "bpt_ratio_used=", 15) == 0 ||
 2296              strncmp(cpt, "bpt_used=", 9) == 0) {
 2297      /* (ignored info from -status) */;
 2298 
 2299    } else if(strncmp(cpt, "block_size=", 11)==0) {
 2300      Xorriso__parse_size_param(cpt, 11, l, &num);
 2301      if (num != (1 << 15) && num != (1 << 16) && num != (1 << 17)) {
 2302        sprintf(xorriso->info_text,
 2303                "-zisofs: Unsupported block size (allowed 32k, 64k, 128k)");
 2304        goto sorry_ex;
 2305      }
 2306      xorriso->zisofs_block_size= num;
 2307 
 2308    } else if(strncmp(cpt, "by_magic=", 9)==0) {
 2309      if(strncmp(cpt + 9, "on", l - 9) == 0) {
 2310        xorriso->zisofs_by_magic= 1;
 2311      } else if(strncmp(cpt + 9, "v2", l - 9) == 0) {
 2312        xorriso->zisofs_by_magic= 2;
 2313      } else if(strncmp(cpt + 9, "off", l - 9) == 0) {
 2314        xorriso->zisofs_by_magic= 0;
 2315      } else {
 2316        sprintf(xorriso->info_text,
 2317          "-zisofs: Unrecognized by_magic mode (allowed: on, off, v2)");
 2318        goto sorry_ex;
 2319      }
 2320 
 2321    } else if(strncmp(cpt, "version_2=", 10) == 0) {
 2322      if(strncmp(cpt + 10, "off", l - 10) == 0) {
 2323        xorriso->zisofs_v2_enabled= 0;
 2324      } else if(strncmp(cpt + 10, "as_needed", l - 10) == 0) {
 2325        xorriso->zisofs_v2_enabled= 1;
 2326      } else if(strncmp(cpt + 10, "on", l - 10) == 0) {
 2327        xorriso->zisofs_v2_enabled= 2;
 2328      } else {
 2329        sprintf(xorriso->info_text,
 2330          "-zisofs: Unrecognized version_2 mode (allowed: on, off, as_needed)");
 2331        goto sorry_ex;
 2332      }
 2333 
 2334    } else if(strncmp(cpt, "max_bpt=", 8) == 0) {
 2335      Xorriso__parse_size_param(cpt, 8, l, &num);
 2336      if(num < 1024.0 || num > 128.0 * 1024.0 * 1024.0 * 1024.0) {
 2337        sprintf(xorriso->info_text,
 2338          "-zisofs: Unsupported block pointer pool size (allowed: 1k to 128g)");
 2339        goto sorry_ex;
 2340      }
 2341      sticky= 0;
 2342      if(xorriso->zisofs_max_total_blocks == xorriso->zisofs_max_file_blocks)
 2343        sticky= 1;
 2344      xorriso->zisofs_max_total_blocks= num / 8.0;
 2345      if(xorriso->zisofs_max_total_blocks < xorriso->zisofs_max_file_blocks ||
 2346         sticky)
 2347        xorriso->zisofs_max_file_blocks= xorriso->zisofs_max_total_blocks;
 2348 
 2349    } else if(strncmp(cpt, "max_bpt_f=", 10) == 0) {
 2350      Xorriso__parse_size_param(cpt, 10, l, &num);
 2351      if(num < 1024.0 || num > 128.0 * 1024.0 * 1024.0 * 1024.0) {
 2352        sprintf(xorriso->info_text,
 2353          "-zisofs: Unsupported block pointer list size (allowed: 1k to 128g)");
 2354        goto sorry_ex;
 2355      }
 2356      xorriso->zisofs_max_file_blocks= num / 8.0;
 2357      if(xorriso->zisofs_max_file_blocks > xorriso->zisofs_max_total_blocks)
 2358        xorriso->zisofs_max_total_blocks= xorriso->zisofs_max_file_blocks;
 2359 
 2360    } else if(strncmp(cpt, "block_size_v2=", 14) == 0) {
 2361      Xorriso__parse_size_param(cpt, 14, l, &num);
 2362      for(i= 15 ; i <= 20; i++)
 2363        if(num == (1 << i))
 2364      break;
 2365      if(i > 20) {
 2366        sprintf(xorriso->info_text,
 2367         "-zisofs: Unsupported block size (allowed 32k, 64k, 128k, ... 1024k)");
 2368        goto sorry_ex;
 2369      }
 2370      xorriso->zisofs_v2_block_size= num;
 2371 
 2372    } else if(strncmp(cpt, "bpt_target=", 11) == 0) {
 2373      Xorriso__parse_size_param(cpt, 11, l, &num);
 2374      xorriso->zisofs_block_number_target= num;
 2375 
 2376    } else if(strncmp(cpt, "bpt_free_ratio=", 15) == 0) {
 2377      Xorriso__parse_size_param(cpt, 15, l, &num);
 2378      /* 0 means to libisofs "do not change" */
 2379      if(num == 0.0)
 2380        num= -1.0;
 2381      if(num != -1.0 && (num <= 0.0 || num > 1.0)) {
 2382        sprintf(xorriso->info_text,
 2383   "-zisofs: Unsupported free blockpointer ratio (allowed -1 or 0.0 to 1.0)");
 2384        goto sorry_ex;
 2385      }
 2386      xorriso->zisofs_bpt_discard_free_ratio = num;
 2387 
 2388    } else if(strncmp(cpt, "susp_z2=", 8) == 0) {
 2389      if(strncmp(cpt + 8, "off", l - 8) == 0) {
 2390        xorriso->zisofs_susp_z2= 0;
 2391      } else if(strncmp(cpt + 8, "on", l - 8) == 0) {
 2392        xorriso->zisofs_susp_z2= 1;
 2393      } else {
 2394        sprintf(xorriso->info_text,
 2395          "-zisofs: Unrecognized susp_z2 mode (allowed: on, off)");
 2396        goto sorry_ex;
 2397      }
 2398      Xorriso_set_zisofs_params(xorriso, 2);
 2399 
 2400    } else if(strncmp(cpt, "default", l)==0) {
 2401      xorriso->zlib_level= xorriso->zlib_level_default;
 2402      xorriso->zisofs_block_size= xorriso->zisofs_block_size_default;
 2403      xorriso->zisofs_by_magic= 0;
 2404      xorriso->zisofs_v2_enabled= 0;
 2405      xorriso->zisofs_max_total_blocks= xorriso->zisofs_max_total_blocks_default;
 2406      xorriso->zisofs_max_file_blocks= xorriso->zisofs_max_file_blocks_default;
 2407      xorriso->zisofs_v2_block_size= xorriso->zisofs_v2_block_size_default;
 2408      xorriso->zisofs_block_number_target= -1;
 2409      xorriso->zisofs_bpt_discard_free_ratio=
 2410          xorriso->zisofs_bpt_discard_free_ratio_default;
 2411      xorriso->zisofs_susp_z2= xorriso->zisofs_susp_z2_default;
 2412      Xorriso_set_zisofs_params(xorriso, 2);
 2413 
 2414    } else {
 2415 unknown_mode:;
 2416      if(l<SfileadrL)
 2417        sprintf(xorriso->info_text, "-zisofs: unknown mode '%s'", cpt);
 2418      else
 2419        sprintf(xorriso->info_text, "-zisofs: oversized mode parameter (%d)",l);
 2420 sorry_ex:
 2421      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 2422      xorriso->zlib_level= was_level;
 2423      xorriso->zisofs_block_size= was_blocksize;
 2424      xorriso->zisofs_v2_enabled= was_v2_enabled;
 2425      xorriso->zisofs_max_total_blocks= was_max_total_blocks;
 2426      xorriso->zisofs_max_file_blocks= was_max_file_blocks;
 2427      xorriso->zisofs_v2_block_size= was_blocksize_v2;
 2428      xorriso->zisofs_block_number_target= was_block_number_target;
 2429      xorriso->zisofs_bpt_discard_free_ratio= was_bpt_discard_free_ratio;
 2430      xorriso->zisofs_susp_z2 = was_zisofs_susp_z2;
 2431      Xorriso_set_zisofs_params(xorriso, 2);
 2432      return(0);
 2433    }
 2434 
 2435    if(strncmp(cpt, "by_magic=", 9) != 0 &&
 2436       strncmp(cpt, "susp_z2=", 8) != 0)
 2437      set_isofs_params= 1;
 2438  }
 2439  ret= 1;
 2440  if(set_isofs_params)
 2441    ret= Xorriso_set_zisofs_params(xorriso, 1);
 2442  return(ret);
 2443 }
 2444 
 2445