home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchek284.zip / iokeywds.h < prev    next >
C/C++ Source or Header  |  1994-07-10  |  5KB  |  137 lines

  1. /* iokeywds.h:
  2.       Contains definitions of I/O control-list specifier keywords
  3.       and their properties.  If VMS or VMS_IO is defined, supports
  4.       many VMS-specific keywords needed to deal with VMS files.
  5.       (Suppressed if NO_VMS_IO is defined.)  You may add other
  6.       locally supported specifiers as appropriate (order is not
  7.       important).
  8.  
  9.     Copyright (C) 1993 by Robert K. Moniot.
  10.     This program is free software.  Permission is granted to
  11.     modify it and/or redistribute it, retaining this notice.
  12.     No guarantees accompany this software.
  13.  
  14.  
  15. */
  16.  
  17.  
  18.  
  19.     /* Define bit flag for each I/O command */
  20. #define RD  0x1            /* read */
  21. #define WR  0x2            /* write */
  22. #define OP  0x4            /* open */
  23. #define CL  0x8            /* close */
  24. #define INQ 0x10        /* inquire */
  25. #define BSP 0x20        /* backspace */
  26. #define ENF 0x40        /* endfile */
  27. #define REW 0x80        /* rewind */
  28. #define ANYSTMT (RD|WR|OP|CL|INQ|BSP|ENF|REW)
  29.  
  30.     /* Define bit flag for each type of specifier value.  All types
  31.        (see symtab.h) are < 16 so these values will fit in a short.*/
  32. #define LAB (1<<type_LABEL)    /* label */
  33. #define CHR (1<<type_STRING)    /* character */
  34. #define INT (1<<type_INTEGER)    /* integer */
  35. #define LOG (1<<type_LOGICAL)    /* logical */
  36. #define STAR (1<<type_UNDECL)    /* does duty for '*' */
  37. #define FID (LAB|CHR|STAR)    /* format ID */
  38. #define UID (INT|CHR|STAR)    /* unit ID */
  39. #define NML (1<<type_NAMELIST)    /* namelist name */
  40. #define ANYTYPE (unsigned short)(~0) /* used for unknown keywords */
  41.  
  42. struct {
  43.     char *name;            /* Name of keyword */
  44.     unsigned short allowed_stmts, /* Where keyword can occur */
  45.                allowed_types; /* datatypes allowed for value */
  46.     unsigned        /* Flags for handling the specifier value */
  47.       implies_use: 1,        /* Value is used */
  48.       implies_set: 1,        /* Var is set (except INQUIRE) */
  49.       inquire_set: 1,        /* Var is set by INQUIRE */
  50.       nonstandard: 1,        /* not Fortran 77 standard keyword */
  51.       special:       1;        /* Indicates special cases */
  52. } io_keywords[]={
  53.             /* List has commonest ones first for fast lookup */
  54. /*Name           Stmts   Types   UseSetInqStdSpcl */
  55. {"END",        RD,    LAB,    1, 0, 0, 0, 0},
  56. {"ERR",        ANYSTMT,LAB,    1, 0, 0, 0, 0},
  57. {"FILE",    OP|INQ,    CHR,    1, 0, 0, 0, 0},
  58. {"UNIT",    ANYSTMT,UID,    1, 0, 0, 0, 0},
  59. {"STATUS",    OP|CL,    CHR,    1, 0, 0, 0, 0},
  60.             /* The rest are alphabetical. */
  61. {"ACCESS",    OP|INQ,    CHR,    1, 0, 1, 0, 0},
  62. {"BLANK",    OP|INQ,    CHR,    1, 0, 1, 0, 0},
  63. {"DIRECT",    INQ,    CHR,    0, 0, 1, 0, 0},
  64. {"EXIST",    INQ,    LOG,    0, 0, 1, 0, 0},
  65. {"FMT",        RD|WR,    FID,    1, 0, 0, 0, 0},
  66. {"FORM",    OP|INQ,    CHR,    1, 0, 1, 0, 0},
  67. {"FORMATTED",    INQ,    CHR,    0, 0, 1, 0, 0},
  68. {"IOSTAT",    ANYSTMT,INT,    0, 1, 1, 0, 0},
  69. {"NAMED",    INQ,    LOG,    0, 0, 1, 0, 0},
  70. {"NEXTREC",    INQ,    INT,    0, 0, 1, 0, 0},
  71. {"NML",        RD|WR,    NML,    1, 0, 0, 1, 0},
  72. {"NUMBER",    INQ,    INT,    0, 0, 1, 0, 0},
  73. {"OPENED",    INQ,    LOG,    0, 0, 1, 0, 0},
  74. {"REC",        RD|WR,    INT,    1, 0, 0, 0, 0},
  75. {"RECL",    OP|INQ,    INT,    1, 0, 1, 0, 0},
  76. {"SEQUENTIAL",    INQ,    CHR,    0, 0, 1, 0, 0},
  77. {"UNFORMATTED",    INQ,    CHR,    0, 0, 1, 0, 0},
  78.             /* NAME is a special case for VMS */
  79. #ifndef VMS_IO
  80. {"NAME",    INQ,    CHR,    0, 0, 1, 0, 0}, /* normal definition */
  81. #else
  82. {"NAME",    OP|INQ,    CHR,    1, 0, 1, 0, 1}, /* VMS definition */
  83. #endif /*VMS_IO*/
  84.             /* Other simple VMS-isms go here. */
  85. #ifdef VMS_IO
  86. {"BLOCKSIZE",    OP,    INT,    1, 0, 0, 1, 0},
  87. {"BUFFERCOUNT",    OP,    INT,    1, 0, 0, 1, 0},
  88. {"CARRIAGECONTROL",OP|INQ,CHR,    1, 0, 1, 1, 0},
  89. {"DEFAULTFILE",    OP,    CHR,    1, 0, 0, 1, 0},
  90. {"DISP",    OP|CL,    CHR,    1, 0, 0, 1, 0},
  91. {"DISPOSE",    OP|CL,    CHR,    1, 0, 0, 1, 0},
  92. {"EXTENDSIZE",    OP,    INT,    1, 0, 0, 1, 0},
  93. {"INITIALSIZE",    OP,    INT,    1, 0, 0, 1, 0},
  94. {"MAXREC",    OP,    INT,    1, 0, 0, 1, 0},
  95. {"ORGANIZATION",OP|INQ,    CHR,    1, 0, 1, 1, 0},
  96. {"RECORDSIZE",    OP,    INT,    1, 0, 0, 1, 0},
  97. {"RECORDTYPE",    OP|INQ,    CHR,    1, 0, 1, 1, 0},
  98. {"TYPE",    OP,    CHR,    1, 0, 0, 1, 0},
  99. #endif /*VMS_IO*/
  100.             /* Last entry (for not-founds) has defns that should
  101.                do the right thing most of the time. */
  102. {NULL,         ANYSTMT,ANYTYPE,    1, 0, 1, 1, 0},
  103. };
  104.  
  105.     /* Lookup table which maps statement classes into
  106.        the corresponding bit fields of io_keywords table.
  107.        Order: commonest first for faster lookup. */
  108. struct {
  109.     short stmt_class, stmt_flag;
  110. } local_class[]= {
  111. {tok_READ,     RD},
  112. {tok_WRITE,     WR},
  113. {tok_OPEN,     OP},
  114. {tok_CLOSE,     CL},
  115. {tok_BACKSPACE,     BSP},
  116. {tok_ENDFILE,     ENF},
  117. {tok_REWIND,     REW},
  118. {tok_INQUIRE,     INQ},
  119. };
  120. #define NUM_IO_STMTS (sizeof(local_class)/sizeof(local_class[0]))
  121.  
  122.  
  123.     /* The following table contains special keywords for the VMS
  124.        form of OPEN statement.  These keywords occur alone, i.e.
  125.        without the =value normally required for I/O control list
  126.        keywords. */
  127. #ifdef VMS_IO
  128. char *special_open_keywds[]={
  129. "NOSPANBLOCKS",
  130. "READONLY",
  131. "SHARED",
  132. };
  133. #define NUM_SPECIAL_OPEN_KEYWDS (sizeof(special_open_keywds) \
  134.                    / sizeof(special_open_keywds[0]))
  135.  
  136. #endif /*VMS_IO*/
  137.