patch: make *outfile extern
[platform/upstream/cdrkit.git] / genisoimage / genisoimage.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /* @(#)genisoimage.h    1.95 05/05/01 joerg */
14 /* Parts from @(#)      1.132 08/08/06 joerg */
15 /*
16  * Header file genisoimage.h - assorted structure definitions and typecasts.
17  *
18  * Written by Eric Youngdale (1993).
19  *
20  * Copyright 1993 Yggdrasil Computing, Incorporated
21  * Copyright (c) 1999,2000-2003 J. Schilling
22  *
23  * This program is free software; you can redistribute it and/or modify
24  * it under the terms of the GNU General Public License as published by
25  * the Free Software Foundation; either version 2, or (at your option)
26  * any later version.
27  *
28  * This program is distributed in the hope that it will be useful,
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31  * GNU General Public License for more details.
32  *
33  * You should have received a copy of the GNU General Public License
34  * along with this program; if not, write to the Free Software
35  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36  */
37
38 /* APPLE_HYB James Pearson j.pearson@ge.ucl.ac.uk 23/2/2000 */
39
40 #define APPID_DEFAULT "GENISOIMAGE ISO 9660/HFS FILESYSTEM CREATOR (C) 1993 E.YOUNGDALE (C) 1997-2006 J.PEARSON/J.SCHILLING (C) 2006-2007 CDRKIT TEAM"
41
42
43 #include <mconfig.h>    /* Must be before stdio.h for LARGEFILE support */
44 #include <stdio.h>
45 #include <statdefs.h>
46 #include <stdxlib.h>
47 #include <unixstd.h>    /* Needed for for LARGEFILE support */
48 #include <strdefs.h>
49 #include <dirdefs.h>
50 #include <utypes.h>
51 #include <standard.h>
52 #include <libport.h>
53 #include "scsi.h"
54 #ifdef JIGDO_TEMPLATE
55 #include "jte.h"
56 #endif
57
58 #ifdef  DVD_VIDEO
59 #ifndef UDF
60 #define UDF
61 #endif
62 #endif
63
64 #ifdef  USE_LARGEFILES
65 /*
66  * XXX Hack until fseeko()/ftello() are available everywhere or until
67  * XXX we know a secure way to let autoconf ckeck for fseeko()/ftello()
68  * XXX without defining FILE_OFFSETBITS to 64 in confdefs.h
69  */
70 #       define  fseek   fseeko
71 #       define  ftell   ftello
72 #endif
73
74 #ifndef HAVE_LSTAT
75 #ifndef VMS
76 #define lstat   stat
77 #endif
78 #endif
79
80 #include "iso9660.h"
81 #include "defaults.h"
82 #include <unls.h>
83
84 extern struct unls_table *in_nls;       /* input UNICODE conversion table */
85 extern struct unls_table *out_nls;      /* output UNICODE conversion table */
86 extern struct unls_table *hfs_inls;     /* input HFS UNICODE conversion table */
87 extern struct unls_table *hfs_onls;     /* output HFS UNICODE conversion table */
88
89 #ifdef APPLE_HYB
90 #include "mactypes.h"
91 #include "hfs.h"
92
93 struct hfs_info {
94         unsigned char   finderinfo[32];
95         char            name[HFS_MAX_FLEN + 1];
96         /* should have fields for dates here as well */
97         char            *keyname;
98         struct hfs_info *next;
99 };
100
101 #endif  /* APPLE_HYB */
102
103 struct directory_entry {
104         struct directory_entry *next;
105         struct directory_entry *jnext;
106         struct iso_directory_record isorec;
107         unsigned int    starting_block;
108         off_t           size;
109 #ifdef  USE_LARGEFILES
110         int             mxpart;         /* Extent number          */
111 #endif
112         unsigned short  priority;
113         unsigned char   jreclen;        /* Joliet record len */
114         char            *name;
115         char            *table;
116         char            *whole_name;
117         struct directory *filedir;
118         struct directory_entry *parent_rec;
119         struct directory_entry *mxroot; /* Pointer to orig entry */
120         unsigned int    de_flags;
121         ino_t           inode;          /* Used in the hash table */
122         dev_t           dev;            /* Used in the hash table */
123         unsigned char   *rr_attributes;
124         unsigned int    rr_attr_size;
125         unsigned int    total_rr_attr_size;
126         unsigned int    got_rr_name;
127 #ifdef APPLE_HYB
128         struct directory_entry *assoc;  /* entry has a resource fork */
129         hfsdirent       *hfs_ent;       /* HFS parameters */
130         off_t           hfs_off;        /* offset to real start of fork */
131         int             hfs_type;       /* type of HFS Unix file */
132 #endif  /* APPLE_HYB */
133 #ifdef SORTING
134         int             sort;           /* sort weight for entry */
135 #endif /* SORTING */
136 #ifdef UDF
137         int             udf_file_entry_sector;  /* also used as UDF unique ID */
138 #endif
139     uint64_t realsize;
140 };
141
142 struct file_hash {
143         struct file_hash *next;
144         ino_t           inode;          /* Used in the hash table */
145         dev_t           dev;            /* Used in the hash table */
146         nlink_t         nlink;          /* Used to compute new link count */
147         unsigned int    starting_block;
148         off_t           size;
149 #ifdef SORTING
150         struct directory_entry *de;
151 #endif /* SORTING */
152 };
153
154
155 /*
156  * This structure is used to control the output of fragments to the cdrom
157  * image.  Everything that will be written to the output image will eventually
158  * go through this structure.   There are two pieces - first is the sizing where
159  * we establish extent numbers for everything, and the second is when we actually
160  * generate the contents and write it to the output image.
161  *
162  * This makes it trivial to extend genisoimage to write special things in the image.
163  * All you need to do is hook an additional structure in the list, and the rest
164  * works like magic.
165  *
166  * The three passes each do the following:
167  *
168  * The 'size' pass determines the size of each component and assigns the extent number
169  * for that component.
170  *
171  * The 'generate' pass will adjust the contents and pointers as required now that extent
172  * numbers are assigned.  In some cases, the contents of the record are also generated.
173  *
174  * The 'write' pass actually writes the data to the disc.
175  */
176 struct output_fragment {
177         struct output_fragment *of_next;
178         int             (*of_size)(int);
179         int             (*of_generate)(void);
180         int             (*of_write)(FILE *);
181         char            *of_name;                       /* Textual description */
182         unsigned int    of_start_extent;                /* For consist check */
183 };
184
185 extern struct output_fragment *out_list;
186 extern struct output_fragment *out_tail;
187
188 extern struct output_fragment startpad_desc;
189 extern struct output_fragment voldesc_desc;
190 extern struct output_fragment xvoldesc_desc;
191 extern struct output_fragment joliet_desc;
192 extern struct output_fragment torito_desc;
193 extern struct output_fragment end_vol;
194 extern struct output_fragment version_desc;
195 extern struct output_fragment pathtable_desc;
196 extern struct output_fragment jpathtable_desc;
197 extern struct output_fragment dirtree_desc;
198 extern struct output_fragment dirtree_clean;
199 extern struct output_fragment jdirtree_desc;
200 extern struct output_fragment extension_desc;
201 extern struct output_fragment files_desc;
202 extern struct output_fragment interpad_desc;
203 extern struct output_fragment endpad_desc;
204 extern struct output_fragment sunboot_desc;
205 extern struct output_fragment sunlabel_desc;
206 extern struct output_fragment genboot_desc;
207 extern struct output_fragment strfile_desc;
208 extern struct output_fragment strdir_desc;
209 extern struct output_fragment strpath_desc;
210 extern struct output_fragment alphaboot_desc;
211 extern struct output_fragment hppaboot_desc;
212 extern struct output_fragment alpha_hppa_boot_desc;
213 extern struct output_fragment mipsboot_desc;
214 extern struct output_fragment mipselboot_desc;
215
216 #ifdef APPLE_HYB
217 extern struct output_fragment hfs_desc;
218
219 #endif  /* APPLE_HYB */
220 #ifdef DVD_VIDEO
221 /*
222  * This structure holds the information necessary to create a valid
223  * DVD-Video image. Basically it's how much to pad the files so the
224  * file offsets described in the video_ts.ifo and vts_xx_0.ifo are
225  * the correct one in the image that we create.
226  */
227 typedef struct {
228         int     realsize_ifo;
229         int     realsize_menu;
230         int     realsize_bup;
231         int     size_ifo;
232         int     size_menu;
233         int     size_title;
234         int     size_bup;
235         int     pad_ifo;
236         int     pad_menu;
237         int     pad_title;
238         int     pad_bup;
239         int     number_of_vob_files;
240         int     realsize_vob[10];
241 } title_set_t;
242
243 typedef struct {
244         int             num_titles;
245         title_set_t     *title_set;
246 } title_set_info_t;
247 #endif /* DVD_VIDEO */
248
249 /*
250  * This structure describes one complete directory.  It has pointers
251  * to other directories in the overall tree so that it is clear where
252  * this directory lives in the tree, and it also must contain pointers
253  * to the contents of the directory.  Note that subdirectories of this
254  * directory exist twice in this stucture.  Once in the subdir chain,
255  * and again in the contents chain.
256  */
257 struct directory {
258         struct directory *next;         /* Next directory at same level as this one */
259         struct directory *subdir;       /* First subdirectory in this directory */
260         struct directory *parent;
261         struct directory_entry *contents;
262         struct directory_entry *jcontents;
263         struct directory_entry *self;
264         char            *whole_name;    /* Entire path */
265         char            *de_name;       /* Entire path */
266         unsigned int    ce_bytes;       /* Number of bytes of CE entries read */
267                                         /* for this dir */
268         unsigned int    depth;
269         unsigned int    size;
270         unsigned int    extent;
271         unsigned int    jsize;
272         unsigned int    jextent;
273         unsigned int    path_index;
274         unsigned int    jpath_index;
275         unsigned short  dir_flags;
276         unsigned short  dir_nlink;
277 #ifdef APPLE_HYB
278         hfsdirent       *hfs_ent;       /* HFS parameters */
279         struct hfs_info *hfs_info;      /* list of info for all entries in dir */
280 #endif  /* APPLE_HYB */
281 #ifdef SORTING
282         int             sort;           /* sort weight for child files */
283 #endif /* SORTING */
284 };
285
286 struct deferred_write {
287         struct deferred_write *next;
288         char            *table;
289         unsigned int    extent;
290         off_t           size;
291         char            *name;
292         struct directory_entry *s_entry;
293         unsigned int    pad;
294         off_t           off;
295 };
296
297 struct eltorito_boot_entry_info {
298         struct eltorito_boot_entry_info *next;
299         char            *boot_image;
300         int             not_bootable;
301         int             no_emul_boot;
302         int             hard_disk_boot;
303         int             boot_info_table;
304         int             load_size;
305         int             load_addr;
306 };
307
308 extern int      goof;
309 extern struct directory *root;
310 extern struct directory *reloc_dir;
311 extern unsigned int next_extent;
312 extern unsigned int last_extent;
313 extern unsigned int last_extent_written;
314 extern unsigned int session_start;
315
316 extern unsigned int path_table_size;
317 extern unsigned int path_table[4];
318 extern unsigned int path_blocks;
319 extern char     *path_table_l;
320 extern char     *path_table_m;
321
322 extern unsigned int jpath_table_size;
323 extern unsigned int jpath_table[4];
324 extern unsigned int jpath_blocks;
325 extern char     *jpath_table_l;
326 extern char     *jpath_table_m;
327
328 extern struct iso_directory_record root_record;
329 extern struct iso_directory_record jroot_record;
330
331 extern int      check_oldnames;
332 extern int      check_session;
333 extern int      use_eltorito;
334 extern int      hard_disk_boot;
335 extern int      not_bootable;
336 extern int      no_emul_boot;
337 extern int      load_addr;
338 extern int      load_size;
339 extern int      boot_info_table;
340 extern int      use_RockRidge;
341 extern int      osecsize;
342 extern int      use_XA;
343 extern int      use_Joliet;
344 extern int      rationalize;
345 extern int      rationalize_uid;
346 extern int      rationalize_gid;
347 extern int      rationalize_filemode;
348 extern int      rationalize_dirmode;
349 extern uid_t    uid_to_use;
350 extern gid_t    gid_to_use;
351 extern int      filemode_to_use;
352 extern int      dirmode_to_use;
353 extern int      new_dir_mode;
354 extern int      follow_links;
355 extern int      cache_inodes;
356 extern int      verbose;
357 extern int      debug;
358 extern int      gui;
359 extern int      all_files;
360 extern int      generate_tables;
361 extern int      print_size;
362 extern int      split_output;
363 extern int      use_graft_ptrs;
364 extern int      jhide_trans_tbl;
365 extern int      hide_rr_moved;
366 extern int      omit_period;
367 extern int      omit_version_number;
368 extern int      no_rr;
369 extern int      transparent_compression;
370 extern Uint     RR_relocation_depth;
371 extern int      do_largefiles;
372 extern off_t    maxnonlarge;
373 extern int      iso9660_level;
374 extern int      iso9660_namelen;
375 extern int      full_iso9660_filenames;
376 extern int      relaxed_filenames;
377 extern int      allow_lowercase;
378 extern int      allow_multidot;
379 extern int      iso_translate;
380 extern int      allow_leading_dots;
381 extern int      use_fileversion;
382 extern int      split_SL_component;
383 extern int      split_SL_field;
384 extern char     *trans_tbl;
385 extern char     *outfile;
386
387 #define JMAX            64      /* maximum Joliet file name length (spec) */
388 #define JLONGMAX        103     /* out of spec Joliet file name length */
389 extern int      jlen;           /* selected maximum Joliet file name length */
390
391 #ifdef DVD_VIDEO
392 extern int      dvd_video;
393 #endif /* DVD_VIDEO */
394
395
396 #ifdef APPLE_HYB
397 extern int      apple_hyb;      /* create HFS hybrid */
398 extern int      apple_ext;      /* use Apple extensions */
399 extern int      apple_both;     /* common flag (for above) */
400 extern int      hfs_extra;      /* extra ISO extents (hfs_ce_size) */
401 extern hce_mem  *hce;           /* libhfs/genisoimage extras */
402 extern int      use_mac_name;   /* use Mac name for ISO9660/Joliet/RR */
403 extern int      create_dt;      /* create the Desktp files */
404 extern char     *hfs_boot_file; /* name of HFS boot file */
405 extern char     *magic_filename;        /* magic file for CREATOR/TYPE matching */
406 extern int      hfs_last;       /* order in which to process map/magic files */
407 extern char     *deftype;       /* default Apple TYPE */
408 extern char     *defcreator;    /* default Apple CREATOR */
409 extern int      gen_pt;         /* generate HFS partition table */
410 extern char     *autoname;      /* Autostart filename */
411 extern int      afe_size;       /* Apple File Exchange block size */
412 extern char     *hfs_volume_id; /* HFS volume ID */
413 extern int      icon_pos;       /* Keep Icon position */
414 extern int      hfs_lock;       /* lock HFS volume (read-only) */
415 extern char     *hfs_bless;     /* name of folder to 'bless' (System Folder) */
416 extern char     *hfs_parms;     /* low level HFS parameters */
417
418 #define MAP_LAST        1       /* process magic then map file */
419 #define MAG_LAST        2       /* process map then magic file */
420
421 #ifndef PREP_BOOT
422 #define PREP_BOOT
423 #endif  /* PREP_BOOT */
424
425 #ifdef PREP_BOOT
426 extern char     *prep_boot_image[4];
427 extern int      use_prep_boot;
428 extern int      use_chrp_boot;
429
430 #endif  /* PREP_BOOT */
431 #endif  /* APPLE_HYB */
432
433 #ifdef SORTING
434 extern int      do_sort;
435 #endif /* SORTING */
436
437 /* tree.c */
438 extern int stat_filter(char *, struct stat *);
439 extern int lstat_filter(char *, struct stat *);
440 extern int sort_tree(struct directory *);
441 extern struct directory *
442 find_or_create_directory(struct directory *, const char *,
443                          struct directory_entry *self,
444                          int,
445                          struct stat *stat_template);
446 extern void     finish_cl_pl_entries(void);
447 extern int      scan_directory_tree(struct directory *this_dir, char *path,
448                                                                                   struct directory_entry *self);
449
450 #ifdef APPLE_HYB
451 extern int      insert_file_entry(struct directory *, char *, char *, int);
452 #else
453 extern int      insert_file_entry(struct directory *, char *, char *);
454 #endif  /* APPLE_HYB */
455
456 extern  struct directory_entry *
457                 dup_directory_entry     __PR((struct directory_entry *s_entry));
458 extern void generate_iso9660_directories(struct directory *, FILE *);
459 extern void dump_tree(struct directory * node);
460 extern struct directory_entry *
461 search_tree_file(struct directory * node, char *filename);
462 extern void update_nlink_field(struct directory * node);
463 extern void init_fstatbuf(void);
464 extern struct stat root_statbuf;
465 extern struct stat fstatbuf;
466
467 /* eltorito.c */
468 extern void init_boot_catalog(const char *path);
469 extern void insert_boot_cat(void);
470 extern void get_boot_entry(void);
471 extern void new_boot_entry(void);
472
473 /* boot.c */
474 extern void sparc_boot_label(char *label);
475 extern void sunx86_boot_label(char *label);
476 extern void scan_sparc_boot(char *files);
477 extern void scan_sunx86_boot(char *files);
478 extern int make_sun_label(void);
479 extern int make_sunx86_label(void);
480
481 /* boot-alpha.c */
482 extern int add_boot_alpha_filename(char *filename);
483
484 /* boot-hppa.c */
485 extern int add_boot_hppa_cmdline(char *cmdline);
486 extern int add_boot_hppa_kernel_32(char *filename);
487 extern int add_boot_hppa_kernel_64(char *filename);
488 extern int add_boot_hppa_bootloader(char *filename);
489 extern int add_boot_hppa_ramdisk(char *filename);
490
491 /* boot-mips.c */
492 extern int add_boot_mips_filename(char *filename);
493
494 /* boot-mipsel.c */
495 extern int add_boot_mipsel_filename(char *filename);
496
497 /* rsync.c */
498 extern unsigned long long rsync64(unsigned char *mem, size_t size);
499
500 /* write.c */
501 extern int get_731(char *);
502 extern int get_732(char *);
503 extern int get_733(char *);
504 extern int isonum_733(unsigned char *);
505 extern void set_723(char *, unsigned int);
506 extern void set_731(char *, unsigned int);
507 extern void set_721(char *, unsigned int);
508 extern void set_733(char *, unsigned int);
509 extern int sort_directory(struct directory_entry **, int);
510 extern void generate_one_directory(struct directory *, FILE *);
511 extern void memcpy_max(char *, char *, int);
512 extern int oneblock_size(int starting_extent);
513 extern struct iso_primary_descriptor vol_desc;
514 extern void xfwrite(void *buffer, int size, int count, FILE *file, int submode,
515                                                   BOOL islast);
516 extern void set_732(char *pnt, unsigned int i);
517 extern void set_722(char *pnt, unsigned int i);
518 extern void outputlist_insert(struct output_fragment * frag);
519
520 #ifdef APPLE_HYB
521 extern Ulong get_adj_size(int Csize);
522 extern int adj_size(int Csize, int start_extent, int extra);
523 extern void adj_size_other(struct directory * dpnt);
524 extern int insert_padding_file(int size);
525 extern int gen_mac_label(struct deferred_write *);
526
527 #ifdef PREP_BOOT
528 extern void gen_prepboot_label(unsigned char *);
529
530 #endif  /* PREP_BOOT */
531 #endif  /* APPLE_HYB */
532
533 /* multi.c */
534
535 extern FILE     *in_image;
536 extern int open_merge_image(char *path);
537 extern int close_merge_image(void);
538 extern struct iso_directory_record *
539 merge_isofs(char *path);
540 extern unsigned char    *parse_xa(unsigned char *pnt, int *lenp,
541                                                                                  struct directory_entry *dpnt);
542 extern int      rr_flags(struct iso_directory_record *idr);
543 extern int merge_previous_session(struct directory *, 
544                                                                                          struct iso_directory_record *, 
545                                                                                          char *, char *);
546 extern int get_session_start(int *);
547
548 /* joliet.c */
549 #ifdef  UDF
550 #   ifdef USE_ICONV
551 extern  size_t  convert_to_unicode      (unsigned char *buffer,
552                         int size, char *source, struct unls_table *inls);
553 #   else
554 extern  void    convert_to_unicode      (unsigned char *buffer,
555                         int size, char *source, struct unls_table *inls);
556 #   endif
557 extern  int     joliet_strlen   (const char *string, struct unls_table *inls);
558 #endif
559 extern unsigned char conv_charset(unsigned char, struct unls_table *,
560                                                                                          struct unls_table *);
561 extern int joliet_sort_tree(struct directory * node);
562
563 /* match.c */
564 extern int matches(char *);
565 extern int add_match(char *);
566
567 /* files.c */
568 struct dirent   *readdir_add_files(char **, char *, DIR *);
569
570 /* name.c */
571
572 extern void iso9660_check(struct iso_directory_record *idr, 
573                                                                   struct directory_entry *ndr);
574 extern int iso9660_file_length(const char *name, 
575                                                                                  struct directory_entry *sresult, int flag);
576
577 /* various */
578 extern int iso9660_date(char *, time_t);
579 extern void add_hash(struct directory_entry *);
580 extern struct file_hash *find_hash(dev_t, ino_t);
581
582 extern void flush_hash(void);
583 extern void add_directory_hash(dev_t, ino_t);
584 extern struct file_hash *find_directory_hash(dev_t, ino_t);
585 extern void flush_file_hash(void);
586 extern int delete_file_hash(struct directory_entry *);
587 extern struct directory_entry *find_file_hash(char *);
588 extern void add_file_hash(struct directory_entry *);
589
590 extern int      generate_xa_rr_attributes(char *, char *, struct directory_entry *,
591                                                                                                   struct stat *, struct stat *, 
592                                                                                                   int deep_flag);
593 extern char     *generate_rr_extension_record(char *id, char *descriptor,
594                                                                                                                 char *source, int *size);
595
596 extern int      check_prev_session(struct directory_entry **, int len, 
597                                                                                  struct directory_entry *, struct stat *,
598                                                                                  struct stat *, struct directory_entry **);
599
600 extern void     match_cl_re_entries(void);
601 extern void     finish_cl_pl_for_prev_session(void);
602 extern char     *find_rr_attribute(unsigned char *pnt, int len, char *attr_type);
603
604 #ifdef APPLE_HYB
605 /* volume.c */
606 extern int make_mac_volume(struct directory * dpnt, int start_extent);
607 extern int write_fork(hfsfile * hfp, long tot);
608
609 /* apple.c */
610
611 extern void del_hfs_info(struct hfs_info *);
612 extern int get_hfs_dir(char *, char *, struct directory_entry *);
613 extern int get_hfs_info(char *, char *, struct directory_entry *);
614 extern int get_hfs_rname(char *, char *, char *);
615 extern int hfs_exclude(char *);
616 extern void print_hfs_info(struct directory_entry *);
617 extern void hfs_init(char *, unsigned short, unsigned int);
618 extern void delete_rsrc_ent(struct directory_entry *);
619 extern void clean_hfs(void);
620 extern void perr(char *);
621 extern void set_root_info(char *);
622
623 /* desktop.c */
624
625 extern int make_desktop(hfsvol *, int);
626
627 /* mac_label.c */
628
629 #ifdef  _MAC_LABEL_H
630 #ifdef PREP_BOOT
631 extern void     gen_prepboot_label(MacLabel * mac_label);
632 #endif
633 extern int      gen_mac_label(defer *);
634 #endif
635 extern int      autostart(void);
636
637 /* libfile */
638
639 extern char     *get_magic_match(const char *);
640 extern void     clean_magic(void);
641
642 #endif  /* APPLE_HYB */
643
644 extern char     *extension_record;
645 extern int      extension_record_extent;
646 extern int      n_data_extents;
647
648 /*
649  * These are a few goodies that can be specified on the command line, and are
650  * filled into the root record
651  */
652 extern char     *preparer;
653 extern char     *publisher;
654 extern char     *copyright;
655 extern char     *biblio;
656 extern char     *abstract;
657 extern char     *appid;
658 extern char     *volset_id;
659 extern char     *system_id;
660 extern char     *volume_id;
661 extern char     *boot_catalog;
662 extern char     *boot_image;
663 extern char     *genboot_image;
664 extern int      ucs_level;
665 extern int      volume_set_size;
666 extern int      volume_sequence_number;
667
668 extern struct eltorito_boot_entry_info *first_boot_entry;
669 extern struct eltorito_boot_entry_info *last_boot_entry;
670 extern struct eltorito_boot_entry_info *current_boot_entry;
671
672 extern char     *findgequal(char *);
673 extern void     *e_malloc(size_t);
674
675 /*
676  * Note: always use these macros to avoid problems.
677  *
678  * ISO_ROUND_UP(X)      may cause an integer overflow and thus give
679  *                      incorrect results. So avoid it if possible.
680  *
681  * ISO_BLOCKS(X)        is overflow safe. Prefer this when ever it is possible.
682  */
683 #define SECTOR_SIZE     (2048)
684 #define ISO_ROUND_UP(X) (((X) + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1))
685 #define ISO_BLOCKS(X)   (((X) / SECTOR_SIZE) + (((X)%SECTOR_SIZE)?1:0))
686
687 #define ROUND_UP(X, Y)  (((X + (Y - 1)) / Y) * Y)
688
689 #ifdef APPLE_HYB
690 /*
691  * ISO blocks == 2048, HFS blocks == 512
692  */
693 #define HFS_BLK_CONV    (SECTOR_SIZE/HFS_BLOCKSZ)
694
695 #define HFS_ROUND_UP(X) ISO_ROUND_UP(((X)*HFS_BLOCKSZ)) /* XXX ??? */
696 #define HFS_BLOCKS(X)   (ISO_BLOCKS(X) * HFS_BLK_CONV)
697
698 #define USE_MAC_NAME(E) (use_mac_name && ((E)->hfs_ent != NULL) && (E)->hfs_type)
699 #endif  /* APPLE_HYB */
700
701 /*
702  * Rock Ridge defines
703  */
704 #define NEED_RE         1       /* Need Relocated Direcotry     */
705 #define NEED_PL         2       /* Need Parent link             */
706 #define NEED_CL         4       /* Need Child link              */
707 #define NEED_CE         8       /* Need Continuation Area       */
708 #define NEED_SP         16      /* Need SUSP record             */
709
710 #define RR_FLAG_PX      1       /* POSIX attributes             */
711 #define RR_FLAG_PN      2       /* POSIX device number          */
712 #define RR_FLAG_SL      4       /* Symlink                      */
713 #define RR_FLAG_NM      8       /* Alternate Name               */
714 #define RR_FLAG_CL      16      /* Child link                   */
715 #define RR_FLAG_PL      32      /* Parent link                  */
716 #define RR_FLAG_RE      64      /* Relocated Direcotry          */
717 #define RR_FLAG_TF      128     /* Time stamp                   */
718
719 #define RR_FLAG_SP      1024    /* SUSP record                  */
720 #define RR_FLAG_AA      2048    /* Apple Signature record       */
721 #define RR_FLAG_XA      4096    /* XA signature record          */
722
723 #define RR_FLAG_CE      8192    /* SUSP Continuation aerea      */
724 #define RR_FLAG_ER      16384   /* Extension record for RR signature */
725 #define RR_FLAG_RR      32768   /* RR Signature in every file   */
726 #define RR_FLAG_ZF      65535   /* Linux compression extension  */
727
728
729 #define PREV_SESS_DEV   (sizeof (dev_t) >= 4 ? 0x7ffffffd : 0x7ffd)
730 #define TABLE_INODE     (sizeof (ino_t) >= 4 ? 0x7ffffffe : 0x7ffe)
731 #define UNCACHED_INODE  (sizeof (ino_t) >= 4 ? 0x7fffffff : 0x7fff)
732 #define UNCACHED_DEVICE (sizeof (dev_t) >= 4 ? 0x7fffffff : 0x7fff)
733
734 #ifdef VMS
735 #define STAT_INODE(X)   (X.st_ino[0])
736 #define PATH_SEPARATOR  ']'
737 #define SPATH_SEPARATOR ""
738 #else
739 #define STAT_INODE(X)   (X.st_ino)
740 #define PATH_SEPARATOR  '/'
741 #define SPATH_SEPARATOR "/"
742 #endif
743
744 /*
745  * When using multi-session, indicates that we can reuse the
746  * TRANS.TBL information for this directory entry. If this flag
747  * is set for all entries in a directory, it means we can just
748  * reuse the TRANS.TBL and not generate a new one.
749  */
750 #define SAFE_TO_REUSE_TABLE_ENTRY  0x01         /* de_flags only  */
751 #define DIR_HAS_DOT                0x02         /* dir_flags only */
752 #define DIR_HAS_DOTDOT             0x04         /* dir_flags only */
753 #define INHIBIT_JOLIET_ENTRY       0x08
754 #define INHIBIT_RR_ENTRY           0x10         /* not used       */
755 #define RELOCATED_DIRECTORY        0x20         /* de_flags only  */
756 #define INHIBIT_ISO9660_ENTRY      0x40
757 #define MEMORY_FILE                0x80         /* de_flags only  */
758 #define HIDDEN_FILE                0x100        /* de_flags only  */
759 #define DIR_WAS_SCANNED            0x200        /* dir_flags only */
760 #define MULTI_EXTENT               0x1000       /* de_flags only  */
761 #define INHIBIT_UDF_ENTRY          0x2000
762
763 /*
764  * Volume sequence number to use in all of the iso directory records.
765  */
766 #define DEF_VSN         1
767
768 /*
769  * Make sure we have a definition for this.  If not, take a very conservative
770  * guess.
771  * POSIX requires the max pathname component lenght to be defined in limits.h
772  * If variable, it may be undefined. If undefined, there should be
773  * a definition for _POSIX_NAME_MAX in limits.h or in unistd.h
774  * As _POSIX_NAME_MAX is defined to 14, we cannot use it.
775  * XXX Eric's wrong comment:
776  * XXX From what I can tell SunOS is the only one with this trouble.
777  */
778 #ifdef  HAVE_LIMITS_H
779 #include <limits.h>
780 #endif
781 #ifndef NAME_MAX
782 #ifdef FILENAME_MAX
783 #define NAME_MAX        FILENAME_MAX
784 #else
785 #define NAME_MAX        256
786 #endif
787 #endif
788
789 #ifndef PATH_MAX
790 #ifdef FILENAME_MAX
791 #define PATH_MAX        FILENAME_MAX
792 #else
793 #define PATH_MAX        1024
794 #endif
795 #endif
796
797 /*
798  * XXX JS: Some structures have odd lengths!
799  * Some compilers (e.g. on Sun3/mc68020) padd the structures to even length.
800  * For this reason, we cannot use sizeof (struct iso_path_table) or
801  * sizeof (struct iso_directory_record) to compute on disk sizes.
802  * Instead, we use offsetof(..., name) and add the name size.
803  * See iso9660.h
804  */
805 #ifndef offsetof
806 #define offsetof(TYPE, MEMBER)  ((size_t) &((TYPE *)0)->MEMBER)
807 #endif
808
809 /*
810  * EB: various shared stuff
811  */
812 extern char             *merge_warn_msg;