home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume24 / mkid2 / part01 / id.h < prev    next >
C/C++ Source or Header  |  1991-10-09  |  2KB  |  60 lines

  1. /* Copyright (c) 1986, Greg McGary */
  2. /* @(#)id.h    1.1 86/10/09 */
  3.  
  4. #define    IDFILE    "ID"
  5.  
  6. struct idhead {
  7.     char    idh_magic[2];    /* magic number */
  8. #define    IDH_MAGIC "\311\304"    /* magic-number ("ID" with hi bits) */
  9.     short    idh_vers;    /* id-file version number */
  10. #define    IDH_VERS    2    /* current version */
  11.     int    idh_argc;    /* # of args for mkid update */
  12.     int    idh_pthc;    /* # of paths for mkid update */
  13.     int    idh_namc;    /* # of identifiers */
  14.     int    idh_vecc;    /* # of bytes in a path vector entry */
  15.     int    idh_bsiz;    /* # of bytes in entry (bufsiz for lid) */
  16.     long    idh_argo;    /* file offset of args for mkid update */
  17.     long    idh_namo;    /* file offset of identifier names */
  18.     long    idh_endo;    /* file offset of EOF */
  19. };
  20.  
  21. struct idarg {
  22.     struct idarg    *ida_next;
  23.     char    *ida_arg;
  24.     int    ida_index;
  25.     char    ida_flags;
  26. #define    IDA_ADJUST    0x01
  27. #define    IDA_SCAN    0x02
  28. #define    IDA_PATH    0x04
  29. #define    IDA_ARG        0x08
  30. #define    IDA_BLANK    0x10
  31. };
  32.  
  33. struct idname {
  34.     char    *idn_name;
  35.     char    *idn_bitv;
  36.     char    idn_flags;
  37. #define    IDN_SOLO    0x01    /* occurs only once */
  38. #define    IDN_NUMBER    0x02    /* is a number */
  39. #define    IDN_NAME    0x04    /* is a name */
  40. #define    IDN_STRING    0x08    /* is a string */
  41. #define    IDN_LITERAL    0x10    /* occurs as a literal (not string) */
  42. #define    IDN_NOISE    0x20    /* occurs very frequently */
  43. };
  44.  
  45. /*
  46.     Extract the various logical fields of a name:
  47.  
  48.     NAME: null-terminated ascii string
  49.     TAG:  index of name within a sorted array of all names
  50.     SOLO: boolean indicating that this name occurs exactly once
  51. */
  52. #define    ID_PATHS(b) ((b)+strlen(b)+1)
  53. #define    ID_FLAGS(b) (*(b))
  54. #define    ID_STRING(b) ((b)+1)
  55.  
  56. #define    NEW(type)    ((type *)calloc(1, sizeof(type)))
  57.  
  58. #define    GETARG(argc, argv)    ((argc)--, *(argv)++)
  59. #define    UNGETARG(argc, argv)    ((argc)++, *--(argv))
  60.