"Fossies" - the Fresh Open Source Software Archive

Member "xorriso-1.5.4/xorriso/base_obj.c" (30 Jan 2021, 20721 Bytes) of package /linux/misc/xorriso-1.5.4.pl02.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 "base_obj.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.5.2_vs_1.5.4.

    1 
    2 
    3 
    4 /* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
    5 
    6    Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
    7 
    8    Provided under GPL version 2 or later.
    9 
   10    This file contains functions which are needed to read data
   11    from ISO image.
   12 */
   13 
   14 #ifdef HAVE_CONFIG_H
   15 #include "../config.h"
   16 #endif
   17 
   18 #include <ctype.h>
   19 #include <sys/types.h>
   20 #include <unistd.h>
   21 #include <stdlib.h>
   22 #include <stdio.h>
   23 #include <string.h>
   24 #include <sys/stat.h>
   25 #include <sys/time.h>
   26 #include <time.h>
   27 #include <errno.h>
   28 #include <pthread.h>
   29 
   30 #ifdef HAVE_STDINT_H
   31 #include <stdint.h>
   32 #else
   33 #ifdef HAVE_INTTYPES_H
   34 #include <inttypes.h>
   35 #endif
   36 #endif
   37 
   38 #ifdef Xorriso_standalonE
   39 
   40 #ifdef Xorriso_with_libjtE
   41 #include "../libjte/libjte.h"
   42 #endif
   43 
   44 #else
   45 
   46 #ifdef Xorriso_with_libjtE
   47 #include <libjte/libjte.h>
   48 #endif
   49 
   50 #endif /* ! Xorriso_standalonE */
   51 
   52 #include "xorriso.h"
   53 #include "xorriso_private.h"
   54 
   55 #include "base_obj.h"
   56 #include "lib_mgt.h"
   57 
   58 
   59 
   60 /* See Xorriso__preset_signal_behavior() */
   61 static int Xorriso_signal_behavioR= 1;
   62 
   63 
   64 void Xorriso__version(int *major, int *minor, int *micro)
   65 {
   66  *major= Xorriso_header_version_majoR;
   67  *minor= Xorriso_header_version_minoR;
   68  *micro= Xorriso_header_version_micrO;
   69 }
   70 
   71 
   72 int Xorriso__is_compatible(int major, int minor, int micro, int flag)
   73 {
   74  int own_major, own_minor, own_micro;
   75 
   76  Xorriso__version(&own_major, &own_minor, &own_micro);
   77  return(own_major > major ||
   78         (own_major == major && (own_minor > minor ||
   79          (own_minor == minor && own_micro >= micro))));
   80 }
   81 
   82 
   83 char *Xorriso__get_patch_level_text(int flag)
   84 {
   85  return(Xorriso_program_patch_leveL);
   86 }
   87 
   88 
   89 /** The list of startup file names */
   90 #define Xorriso_rc_nuM 4
   91 
   92 static char Xorriso_sys_rc_nameS[Xorriso_rc_nuM][80]= {
   93  "/etc/default/xorriso",
   94  "/etc/opt/xorriso/rc",
   95  "/etc/xorriso/xorriso.conf",
   96  "placeholder for $HOME/.xorrisorc"
   97 };
   98 
   99 
  100 int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
  101 {
  102  int i, ret;
  103  struct XorrisO *m;
  104  char *leafname= NULL;
  105 
  106  leafname= TSOB_FELD(char, SfileadrL);
  107  if(leafname == NULL)
  108    return(-1); 
  109  *xorriso= m= TSOB_FELD(struct XorrisO,1);
  110  if(m==NULL) {
  111    free(leafname);
  112    return(-1);
  113  }
  114 
  115  /* Base initialization by actions which must not fail */
  116 
  117  m->libs_are_started= 0;
  118  strncpy(m->progname,progname,sizeof(m->progname)-1);
  119  m->progname[sizeof(m->progname)-1]= 0;
  120  if(getcwd(m->initial_wdx,sizeof(m->initial_wdx)-1)==NULL)
  121    m->initial_wdx[0]= 0;
  122  m->no_rc= 0;
  123  m->argument_emulation= 0;
  124 
  125  m->rc_filename_count= Xorriso_rc_nuM;
  126  for(i=0;i<m->rc_filename_count-1;i++)
  127    strcpy(m->rc_filenames[i],Xorriso_sys_rc_nameS[i]);
  128  m->rc_filenames[m->rc_filename_count-1][0]= 0;
  129  m->arrange_args= 0;
  130  m->mkisofsrc_done= 0;
  131 
  132  m->wdi[0]= 0;
  133  strcpy(m->wdx, m->initial_wdx);
  134  m->did_something_useful= 0;
  135  m->add_plainly= 0;
  136  m->split_size= 0;
  137  strcpy(m->list_delimiter, "--");
  138  m->ino_behavior= 1 | 2 | 4 | 32;      /* off:no_lsl_count */
  139  m->iso_level= 3;
  140  m->iso_level_is_default= 1;
  141  m->do_joliet= 0;
  142  m->do_hfsplus= 0;
  143  m->do_fat= 0;
  144  m->do_rockridge= 1;
  145  m->do_iso1999= 0;
  146  m->ecma119_map= 1;
  147  m->joliet_map= 1;
  148  m->do_aaip= 0;
  149  m->do_md5= 64;
  150  m->no_emul_toc= 0;
  151  m->do_old_empty= 0;
  152  m->scdbackup_tag_name[0]= 0;
  153  m->scdbackup_tag_time[0]= 0;
  154  m->scdbackup_tag_written[0]= 0;
  155  m->scdbackup_tag_listname[0]= 0;
  156  m->relax_compliance= 0;
  157  m->allow_dir_id_ext_dflt= 1;
  158  m->rr_reloc_dir[0]= 0;
  159  m->rr_reloc_flags= 1;
  160  m->untranslated_name_len= 0;
  161  m->do_follow_pattern= 1;
  162  m->do_follow_param= 0;
  163  m->do_follow_links= 0;
  164  m->follow_link_limit= 100;
  165  m->resolve_link_rec_count= 0;
  166  m->resolve_link_rec_limit= 100;
  167  m->do_follow_concat= 0;
  168  m->do_follow_mount= 1;
  169  m->do_global_uid= 0;
  170  m->global_uid= 0;
  171  m->isofs_size= 0;
  172  m->isofs_has_what= 0;
  173  m->tree_loaded= 0;
  174  m->rr_loaded= 0;
  175  strcpy(m->volid, "ISOIMAGE");
  176  m->volid_default= 1;
  177  m->loaded_volid[0]= 0;
  178  m->assert_volid[0]= 0;
  179  m->assert_volid_sev[0]= 0;
  180  m->preparer_id[0]= 0;
  181  m->publisher[0]= 0;
  182  m->application_id[0]= 0;
  183  m->system_id[0]= 0;
  184  m->volset_id[0]= 0;
  185  m->copyright_file[0]= 0;
  186  m->biblio_file[0]= 0;
  187  m->abstract_file[0]= 0;
  188  strcpy(m->application_use, " ");
  189  m->session_logfile[0]= 0;
  190  m->session_lba= -1;
  191  m->session_blocks= 0;
  192  m->do_global_gid= 0;
  193  m->global_gid= 0;
  194  m->do_global_mode= 0;
  195  m->global_dir_mode= 0555;
  196  m->global_file_mode= 0444;
  197  m->do_tao= 0;
  198  m->filters= NULL;
  199  m->filter_list_closed= 0;
  200  m->zlib_level_default= m->zlib_level= 6;
  201  m->zisofs_block_size= m->zisofs_block_size_default= (1 << 15);
  202  m->zisofs_by_magic= 0;
  203  m->zisofs_v2_enabled= 0;
  204  m->zisofs_max_total_blocks= m->zisofs_max_total_blocks_default= 0x2000000;
  205  m->zisofs_max_file_blocks= m->zisofs_max_file_blocks_default= 0x2000000;
  206  m->zisofs_block_size= m->zisofs_block_size_default= (1 << 15);
  207  m->zisofs_v2_block_size= m->zisofs_v2_block_size_default= (1 << 17);
  208  m->zisofs_block_number_target= -1;
  209  m->zisofs_bpt_discard_free_ratio= m->zisofs_bpt_discard_free_ratio_default=
  210                                                                           -1.0;
  211  m->zisofs_susp_z2= m->zisofs_susp_z2_default= 0;
  212  m->do_overwrite= 2;
  213  m->do_reassure= 0;
  214  m->drive_blacklist= NULL;
  215  m->drive_greylist= NULL;
  216  m->drive_whitelist= NULL;
  217  m->toc_emulation_flag= 0;
  218  m->image_start_mode= 0;
  219  m->image_start_value[0]= 0;
  220  m->displacement= 0;
  221  m->displacement_sign= 0;
  222  m->read_fs= 0;
  223  m->drives_exclusive= 1;
  224  m->drives_access= 1;
  225  m->linux_scsi_dev_family= 0;
  226  m->early_stdio_test= 0;
  227  m->cache_num_tiles= 0;
  228  m->cache_tile_blocks= 0;
  229  m->cache_default= 1 | 2;
  230  m->do_calm_drive= 1;
  231  m->indev[0]= 0;
  232  m->in_drive_handle= NULL;
  233  m->in_volset_handle= NULL;
  234  m->in_charset= NULL;
  235  m->isofs_st_out= time(0) - 1;
  236  m->indev_is_exclusive= 1;
  237  m->indev_access= 1;
  238  m->indev_off_adr[0]= 0;
  239  m->isofs_st_in= 0;
  240  m->volset_change_pending= 0;
  241  m->no_volset_present= 0;
  242  m->in_sector_map= NULL;
  243  m->check_media_default= NULL;
  244  m->check_media_bad_limit= Xorriso_read_quality_invaliD;
  245  m->outdev[0]= 0;
  246  m->out_drive_handle= NULL;
  247  m->out_charset= NULL;
  248  m->dev_fd_1= -1;
  249  m->outdev_is_exclusive= 1;
  250  m->outdev_access= 1;
  251  m->outdev_off_adr[0]= 0;
  252  m->grow_blindly_msc2= -1;
  253  m->ban_stdio_write= 0;
  254  m->do_dummy= 0;
  255  m->do_close= 0;
  256  m->auto_close= 0;
  257  m->write_speed= 0;  /* max */
  258  m->read_speed= -2;  /* do not set */
  259  m->read_speed_force= 0;
  260  m->read_speed_corr= 250000; /* look back at most 0.25 seconds with _force */
  261  m->fs= 4*512; /* 4 MiB */
  262  m->padding= 300*1024;
  263  m->do_padding_by_libisofs= 0;
  264  m->alignment= 0;
  265  m->do_stream_recording= 0;
  266  m->dvd_obs= 0;
  267  m->modesty_on_drive= 0;
  268  m->min_buffer_usec= 5000;
  269  m->max_buffer_usec= 25000;
  270  m->buffer_timeout_sec= 120;
  271  m->min_buffer_percent= 90;
  272  m->max_buffer_percent= 95;
  273  m->use_immed_bit= 0;
  274  m->use_immed_bit_default= 0;
  275  m->stdio_sync= 0;
  276  m->stdio_sync_is_default= 1;
  277  m->keep_boot_image= 0;
  278  m->boot_image_cat_path[0]= 0;
  279  m->boot_image_cat_hidden= 0;
  280  m->boot_count= 0;
  281  m->boot_platform_id= 0x00; /* El Torito Boot Catalog Platform ID: 0 = 80x86 */
  282  m->patch_isolinux_image= 0;
  283  m->boot_image_bin_path[0]= 0;
  284  m->boot_image_bin_form[0]= 0;
  285  m->boot_image_emul= 0;
  286  m->boot_emul_default= 1;
  287  m->boot_image_load_size= 4 * 512;     /* hearsay out of libisofs/demo/iso.c */
  288  m->boot_img_size_default= 1;
  289  m->boot_img_full_size= 0;
  290  memset(m->boot_id_string, 0, sizeof(m->boot_id_string));
  291  memset(m->boot_selection_crit, 0, sizeof(m->boot_selection_crit));
  292 
  293 #ifdef Xorriso_with_isohybriD
  294  m->boot_image_isohybrid= 1;
  295 #else
  296  m->boot_image_isohybrid= 0;
  297 #endif
  298 
  299  m->boot_efi_default= 0;
  300  m->system_area_disk_path[0]= 0;
  301  m->system_area_clear_loaded= 0;
  302  m->system_area_options= 0;
  303  m->patch_system_area= 0;
  304  m->partition_offset= 0;
  305  m->partition_secs_per_head= 0;
  306  m->partition_heads_per_cyl= 0;
  307  m->prep_partition[0]= 0;
  308  m->efi_boot_partition[0]= 0;
  309  for(i= 0; i < Xorriso_max_appended_partitionS; i++) {
  310    m->appended_partitions[i]= NULL;
  311    m->appended_part_types[i]= 0;
  312    memset(m->appended_part_type_guids[i], 0, 16);
  313    m->appended_part_gpt_flags[i]= 0;
  314  }
  315  m->appended_as_gpt= 0;
  316  m->appended_as_apm= 0;
  317  m->part_like_isohybrid= 0;
  318  m->iso_mbr_part_type= -1;
  319  memset(m->iso_gpt_type_guid, 0, 16);
  320  m->iso_mbr_part_flag= 0;
  321  memset(m->gpt_guid, 0, 16);
  322  m->gpt_guid_mode= 0;
  323  m->ascii_disc_label[0]= 0;
  324  m->grub2_sparc_core[0]= 0;
  325  memset(m->hfsp_serial_number, 0, 8);
  326  m->hfsp_block_size= 0;
  327  m->apm_block_size= 0;
  328  m->vol_creation_time= 0;
  329  m->vol_modification_time= 0;
  330  m->vol_expiration_time= 0;
  331  m->vol_effective_time= 0;
  332  m->vol_uuid[0]= 0;
  333  m->all_file_dates[0]= 0;
  334  m->do_override_now_time= 0;
  335  m->now_time_override= 0;
  336 
  337 #ifdef Xorriso_with_libjtE
  338  m->libjte_handle= NULL;
  339 #endif
  340 
  341  m->jigdo_params= NULL;
  342  m->jigdo_values= NULL;
  343  m->libjte_params_given= 0;
  344  m->loaded_boot_bin_lba= 0;
  345  m->loaded_boot_cat_path[0]= 0;
  346  m->allow_graft_points= 0;
  347  m->allow_restore= 0;
  348  m->do_concat_split= 1;
  349  m->do_auto_chmod= 0;
  350  m->do_restore_sort_lba= 0;
  351  m->do_strict_acl= 0;
  352  m->dialog= 0;
  353  m->buffered_dialog= NULL;
  354  m->bsl_interpretation= 0;
  355  m->sh_style_result= 0;
  356  m->search_mode= 0;
  357  m->structured_search= 1;
  358  m->do_iso_rr_pattern= 1;
  359  m->do_disk_pattern= 2;
  360  m->temp_mem_limit= 16*1024*1024;
  361  m->file_size_limit= Xorriso_default_file_size_limiT;
  362  m->file_name_limit= 255;
  363  m->disk_exclusions= NULL;
  364  m->iso_rr_hidings= NULL;
  365  m->joliet_hidings= NULL;
  366  m->hfsplus_hidings= NULL;
  367  m->disk_excl_mode= 1;
  368  m->use_stdin= 0;
  369  m->tolerate_stdin_eof= 0;
  370  m->result_page_length= 0;
  371  m->result_page_width= 80;
  372  m->mark_text[0]= 0;
  373  m->packet_output= 0;
  374  for(i=0; i<4; i++) {
  375    m->logfile[i][0]= 0;
  376    m->logfile_fp[i]= NULL;
  377  }
  378  m->pktlog_fp= NULL;
  379  m->stderr_fp= NULL;
  380  for(i= 0; i < Xorriso_max_outlist_stacK; i++) {
  381    m->result_msglists[i]= NULL;
  382    m->info_msglists[i]= NULL;
  383    m->msglist_flags[i]= 0;
  384  }
  385  m->lib_msg_queue_lock_ini= 0;
  386  m->result_msglists_lock_ini= 0;
  387  m->write_to_channel_lock_ini= 0;
  388  m->msg_watcher_lock_ini= 0;
  389  m->msg_watcher_state= 0;
  390  m->msgw_result_handler= NULL;
  391  m->msgw_result_handle= NULL;
  392  m->msgw_info_handler= NULL;
  393  m->msgw_info_handle= NULL;
  394  m->msgw_stack_handle= -1;
  395  m->msgw_msg_pending= 0;
  396  m->msgw_fetch_lock_ini= 0;
  397  m->msg_sieve= NULL;
  398  m->msg_sieve_disabled= 0;
  399  m->msglist_stackfill= 0;
  400  m->status_history_max= Xorriso_status_history_maX;
  401  m->scsi_log= 0;
  402  strcpy(m->report_about_text, "UPDATE");
  403  Xorriso__text_to_sev(m->report_about_text, &m->report_about_severity, 0);
  404  m->library_msg_direct_print= 0;
  405  strcpy(m->abort_on_text,"FAILURE");
  406  Xorriso__text_to_sev(m->abort_on_text, &m->abort_on_severity, 0);
  407  m->abort_on_is_default= 1;
  408  m->problem_status= 0;
  409  m->problem_status_lock_ini= 0;
  410  m->problem_status_text[0]= 0;
  411  m->errfile_log[0]= 0;
  412  m->errfile_mode= 0;
  413  m->errfile_fp= NULL;
  414  
  415  m->img_read_error_mode= 1;       /* abort faulty image reading with FAILURE */
  416  m->extract_error_mode= 1;          /* keep extracted files after read error */
  417  strcpy(m->return_with_text, "SORRY");
  418  Xorriso__text_to_sev(m->return_with_text, &m->return_with_severity, 0);
  419  m->return_with_value= 32;
  420  m->eternal_problem_status= 0;
  421  m->eternal_problem_status_text[0]= 0;
  422  m->re= NULL;
  423  /* >>> ??? how to initialize m->match[0] ? */
  424  m->re_constants= NULL;
  425  m->re_count= 0;
  426  m->re_fill= 0;
  427  m->reg_expr[0]= 0;
  428  m->run_state= 0;
  429  m->is_dialog= 0;
  430  m->bar_is_fresh= 0;
  431  m->pending_option[0]= 0;
  432  m->request_to_abort= 0;
  433  m->request_not_to_ask= 0;
  434  m->idle_time= 0.0;
  435  m->re_failed_at= -1;
  436  m->prepended_wd= 0;
  437  m->insert_count= 0;
  438  m->insert_bytes= 0;
  439  m->error_count= 0;
  440  m->launch_frontend_banned= 0;
  441  m->pacifier_style= 0;
  442  m->pacifier_interval= 1.0;
  443  m->pacifier_count= 0;
  444  m->pacifier_prev_count= 0;
  445  m->pacifier_total= 0;
  446  m->pacifier_byte_count= 0;
  447  m->pacifier_fifo= NULL;
  448  m->start_time= 0.0;
  449  m->last_update_time= 0.0;
  450  m->find_compare_result= 1;
  451  m->find_check_md5_result= 0;
  452  m->last_abort_file_time= 0.0;
  453 
  454  m->node_counter= 0;
  455  m->node_array_size= 0;
  456  m->node_array= NULL;
  457  m->node_disk_prefixes= NULL;
  458  m->node_img_prefixes= NULL;
  459 
  460  m->hln_count= 0;
  461  m->hln_array= NULL; 
  462  m->hln_targets= NULL;
  463  m->hln_change_pending= 0;
  464  m->di_do_widen= NULL;
  465  m->di_disk_paths= NULL;
  466  m->di_iso_paths= NULL;
  467 
  468  m->node_targets_availmem= 0;
  469 
  470  m->di_count= 0;
  471  m->di_array= NULL;
  472 
  473  m->perm_stack= NULL;
  474 
  475  m->update_flags= 0;
  476 
  477  m->show_hfs_cmd_flag= 0;
  478  m->show_hfs_cmd_count= 0;
  479  m->show_hfs_cmds= NULL;
  480 
  481  m->sparse_min_gap= 0;
  482 
  483  m->result_line[0]= 0;
  484  m->result_line_counter= 0;
  485  m->result_page_counter= 0;
  486  m->result_open_line_len= 0;
  487 
  488  m->info_text[0]= 0;
  489 
  490 
  491  /* Here begin actions which might fail */
  492 
  493  ret= Sfile_leafname(progname, leafname, 0);
  494  if(ret<=0)
  495    goto failure;
  496  if(strcmp(leafname, "osirrox")==0) {
  497    m->allow_restore= 1;
  498    m->drives_exclusive= 0;
  499    m->drives_access= 0;
  500  } else if(strcmp(leafname, "xorrisofs")==0 || strcmp(leafname, "genisofs")==0 ||
  501         strcmp(leafname, "mkisofs")==0 || strcmp(leafname, "genisoimage")==0) {
  502    m->argument_emulation= 1;
  503    m->pacifier_style= 1;
  504    Xorriso_protect_stdout(*xorriso, 0);
  505  } else if(strcmp(leafname, "xorrecord")==0 || strcmp(leafname, "wodim")==0 ||
  506            strcmp(leafname, "cdrecord")==0 || strcmp(leafname, "cdrskin")==0) {
  507    m->argument_emulation= 2;
  508    m->pacifier_style= 2;
  509  }
  510  ret= Exclusions_new(&(m->disk_exclusions), 0);
  511  if(ret<=0)
  512    goto failure;
  513  ret= Exclusions_new(&(m->iso_rr_hidings), 0);
  514  if(ret<=0)
  515    goto failure;
  516  ret= Exclusions_new(&(m->joliet_hidings), 0);
  517  if(ret<=0)
  518    goto failure;
  519  ret= Exclusions_new(&(m->hfsplus_hidings), 0);
  520  if(ret<=0)
  521    goto failure;
  522  Xorriso_relax_compliance(m, "default", 0);
  523  ret= Xorriso_lst_new(&(m->drive_greylist), "/dev", m->drive_greylist, 1);
  524  if(ret <= 0)
  525    goto failure;
  526  Xorriso_preparer_string(m, m->preparer_id, 1); /* avoids library calls */
  527  ret= pthread_mutex_init(&(m->lib_msg_queue_lock), NULL);
  528  if(ret != 0)
  529    goto failure;
  530  m->lib_msg_queue_lock_ini= 1;
  531  ret= pthread_mutex_init(&(m->result_msglists_lock), NULL);
  532  if(ret != 0)
  533    goto failure;
  534  m->result_msglists_lock_ini= 1;
  535  ret= pthread_mutex_init(&(m->write_to_channel_lock), NULL);
  536  if(ret != 0)
  537    goto failure;
  538  m->result_msglists_lock_ini= 1;
  539  ret= pthread_mutex_init(&(m->problem_status_lock), NULL);
  540  if(ret != 0)
  541    goto failure;
  542  m->problem_status_lock_ini= 1;
  543  ret= pthread_mutex_init(&(m->msg_watcher_lock), NULL);
  544  if(ret != 0)
  545    goto failure;
  546  m->msg_watcher_lock_ini= 1;
  547  ret= pthread_mutex_init(&(m->msgw_fetch_lock), NULL);
  548  if(ret != 0)
  549    goto failure;
  550  m->msgw_fetch_lock_ini= 1;
  551 
  552  if(leafname != NULL)
  553    free(leafname);
  554  return(1);
  555 failure:;
  556  Xorriso_destroy(xorriso, 0);
  557  if(leafname != NULL)
  558    free(leafname);
  559  return(-1);
  560 }
  561 
  562 
  563 int Xorriso_destroy_re(struct XorrisO *m, int flag)
  564 {
  565  int i;
  566 
  567  if(m->re!=NULL) {
  568    for(i=0;i<m->re_fill;i++) {
  569      if(m->re_constants!=NULL)
  570        if(m->re_constants[i]!=NULL)
  571    continue; /* ,->re[i] was never subject to regcomp() */
  572      regfree(&(m->re[i]));
  573    }
  574    free((char *) m->re);
  575    m->re= NULL;
  576  }
  577 
  578  if(m->re_constants!=NULL) {
  579    for(i=0;i<m->re_fill;i++)
  580      if(m->re_constants[i]!=NULL)
  581        free(m->re_constants[i]);
  582    free((char *) m->re_constants);
  583    m->re_constants= NULL;
  584  }
  585  m->re_count= 0;
  586  m->re_fill= 0;
  587  return(1);
  588 }
  589 
  590 
  591 /* @param flag bit0= global shutdown of libraries */
  592 int Xorriso_destroy(struct XorrisO **xorriso, int flag)
  593 {
  594  struct XorrisO *m;
  595  int i;
  596 
  597  m= *xorriso;
  598  if(m==NULL)
  599    return(0);
  600 
  601  /* Give up drives and image to unref all connected xorriso objects */
  602  Xorriso_give_up_drive(m, 3);
  603 
  604  if(m->in_charset!=NULL)
  605    free(m->in_charset);
  606  if(m->out_charset!=NULL)
  607    free(m->out_charset);
  608  Checkmediajob_destroy(&(m->check_media_default), 0);
  609  Sectorbitmap_destroy(&(m->in_sector_map), 0);
  610  Xorriso_destroy_re(m,0);
  611  Exclusions_destroy(&(m->disk_exclusions), 0);
  612  Exclusions_destroy(&(m->iso_rr_hidings), 0);
  613  Exclusions_destroy(&(m->joliet_hidings), 0);
  614  Exclusions_destroy(&(m->hfsplus_hidings), 0);
  615  Xorriso_destroy_all_extf(m, 0);
  616  Xorriso_lst_destroy_all(&(m->drive_blacklist), 0);
  617  Xorriso_lst_destroy_all(&(m->drive_greylist), 0);
  618  Xorriso_lst_destroy_all(&(m->drive_whitelist), 0);
  619  Xorriso_destroy_node_array(m, 0);
  620  Xorriso_destroy_hln_array(m, 0);
  621  Xorriso_destroy_di_array(m, 0);
  622 
  623 #ifdef Xorriso_with_libjtE
  624  if(m->libjte_handle)
  625    libjte_destroy(&(m->libjte_handle));
  626 #endif
  627 
  628  Xorriso_lst_destroy_all(&(m->jigdo_params), 0);
  629  Xorriso_lst_destroy_all(&(m->jigdo_values), 0);
  630  for(i= 0; i < Xorriso_max_appended_partitionS; i++)
  631    if(m->appended_partitions[i] != NULL)
  632      free(m->appended_partitions[i]);
  633 
  634  Xorriso_detach_libraries(m, flag&1);
  635 
  636  if(m->lib_msg_queue_lock_ini)
  637    pthread_mutex_destroy(&(m->lib_msg_queue_lock));
  638  if(m->result_msglists_lock_ini)
  639    pthread_mutex_destroy(&(m->result_msglists_lock));
  640  if(m->write_to_channel_lock_ini)
  641    pthread_mutex_destroy(&(m->write_to_channel_lock));
  642  if(m->problem_status_lock_ini)
  643    pthread_mutex_destroy(&(m->problem_status_lock));
  644  if(m->msg_watcher_lock_ini)
  645    pthread_mutex_destroy(&(m->msg_watcher_lock));
  646  if(m->msgw_fetch_lock_ini)
  647    pthread_mutex_destroy(&(m->msgw_fetch_lock));
  648  Xorriso_sieve_dispose(m, 0);
  649  
  650  free((char *) m);
  651  *xorriso= NULL;
  652  return(1);
  653 }
  654 
  655 
  656 int Xorriso_destroy_node_array(struct XorrisO *xorriso, int flag)
  657 {
  658  int i;
  659 
  660  if(xorriso->node_array != NULL) {
  661    for(i= 0; i < xorriso->node_counter; i++)
  662      iso_node_unref((IsoNode *) xorriso->node_array[i]);
  663    free(xorriso->node_array);
  664  }
  665  xorriso->node_array= NULL;
  666  xorriso->node_counter= xorriso->node_array_size= 0;
  667  Xorriso_lst_destroy_all(&(xorriso->node_disk_prefixes), 0);
  668  Xorriso_lst_destroy_all(&(xorriso->node_img_prefixes), 0);
  669  return(1);
  670 }
  671 
  672 
  673 /* @param flag bit0= do not destroy hln_array but only hln_targets
  674 */
  675 int Xorriso_destroy_hln_array(struct XorrisO *xorriso, int flag)
  676 {
  677  int i;
  678 
  679  
  680  if(xorriso->hln_array != NULL && !(flag & 1)) {
  681    for(i= 0; i < xorriso->hln_count; i++)
  682      iso_node_unref((IsoNode *) xorriso->hln_array[i]);
  683    free(xorriso->hln_array);
  684    xorriso->hln_array= NULL;
  685    xorriso->hln_count= 0;
  686  }
  687  if(xorriso->hln_targets != NULL) {
  688    for(i= 0; i < xorriso->hln_count; i++)
  689      if(xorriso->hln_targets[i] != NULL)
  690        free(xorriso->hln_targets[i]);
  691    free(xorriso->hln_targets);
  692    xorriso->hln_targets= NULL;
  693  }
  694  xorriso->node_targets_availmem= 0;
  695  return(1);
  696 }
  697 
  698 
  699 int Xorriso_destroy_di_array(struct XorrisO *xorriso, int flag)
  700 {
  701  int i;
  702 
  703  if(xorriso->di_array != NULL) {
  704    for(i= 0; i < xorriso->di_count; i++)
  705      if(xorriso->di_array[i] != NULL)
  706        iso_node_unref((IsoNode *) xorriso->di_array[i]);
  707    free(xorriso->di_array);
  708    xorriso->di_array= NULL;
  709  }
  710  if(xorriso->di_do_widen != NULL) {
  711    free(xorriso->di_do_widen);
  712    xorriso->di_do_widen= NULL;
  713  }
  714  Xorriso_lst_destroy_all(&(xorriso->di_disk_paths), 0);
  715  Xorriso_lst_destroy_all(&(xorriso->di_iso_paths), 0);
  716  xorriso->di_count= 0;
  717 
  718 #ifdef NIX
  719  /* <<< */
  720  fprintf(stderr, "xorriso_DEBUG: get_di_count= %lu\n",
  721          Xorriso_get_di_counteR);
  722 #endif /* NIX */
  723 
  724  return(1);
  725 }
  726 
  727 
  728 int Xorriso_new_node_array(struct XorrisO *xorriso, off_t mem_limit,
  729                            int addon_nodes, int flag)
  730 {
  731  int i;
  732 
  733  if(xorriso->node_counter <= 0)
  734    return(1);
  735 
  736  xorriso->node_array= calloc(xorriso->node_counter + addon_nodes,
  737                              sizeof(IsoNode *));
  738  if(xorriso->node_array == NULL) {
  739    Xorriso_no_malloc_memory(xorriso, NULL, 0);
  740    return(-1);
  741  }
  742  for(i= 0; i < xorriso->node_counter + addon_nodes; i++)
  743    xorriso->node_array[i]= NULL;
  744  xorriso->node_array_size= xorriso->node_counter + addon_nodes;
  745  xorriso->node_counter= 0;
  746  return(1);
  747 }
  748 
  749 
  750 /* @param flag bit0= do not allocate hln_array but only hln_targets
  751 */
  752 int Xorriso_new_hln_array(struct XorrisO *xorriso, off_t mem_limit, int flag)
  753 {
  754  int i;
  755 
  756  Xorriso_destroy_hln_array(xorriso, flag & 1);
  757  if(xorriso->hln_count <= 0)
  758    return(1);
  759 
  760  if(!(flag & 1)) {
  761    xorriso->hln_array= calloc(xorriso->hln_count, sizeof(char *));
  762    if(xorriso->hln_array == NULL) {
  763      Xorriso_no_malloc_memory(xorriso, NULL, 0);
  764      return(-1);
  765    }
  766    for(i= 0; i < xorriso->hln_count; i++)
  767      xorriso->hln_array[i]= NULL;
  768  }
  769 
  770  xorriso->hln_targets= calloc(xorriso->hln_count, sizeof(char *));
  771  if(xorriso->hln_targets == NULL) {
  772    if(!(flag & 1)) {
  773      free(xorriso->hln_array);
  774      xorriso->hln_array= NULL;
  775    }
  776    Xorriso_no_malloc_memory(xorriso, NULL, 0);
  777    return(-1);
  778  }
  779  for(i= 0; i < xorriso->hln_count; i++)
  780    xorriso->hln_targets[i]= NULL;
  781  xorriso->node_targets_availmem= mem_limit
  782                                  - xorriso->hln_count * sizeof(void *)
  783                                  - xorriso->hln_count * sizeof(char *);
  784  if(xorriso->node_targets_availmem < 0)
  785    xorriso->node_targets_availmem= 0;
  786  return(1);
  787 }
  788 
  789 
  790 int Xorriso__preset_signal_behavior(int behavior, int flag)
  791 {
  792  if(behavior < 0 || behavior > 3)
  793    return(0);
  794  Xorriso_signal_behavioR= behavior;
  795  return(1);
  796 }
  797 
  798 
  799 int Xorriso__get_signal_behavior(int flag)
  800 {
  801  return(Xorriso_signal_behavioR);
  802 }
  803