home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / FTNCHK32.ZIP / iokeywds.h < prev    next >
C/C++ Source or Header  |  1993-02-16  |  5KB  |  136 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) 1992 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 ALL (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.  
  41. struct {
  42.     char *name;            /* Name of keyword */
  43.     unsigned short allowed_stmts, /* Where keyword can occur */
  44.                allowed_types; /* datatypes allowed for value */
  45.     unsigned        /* Flags for handling the specifier value */
  46.       implies_use: 1,        /* Value is used */
  47.       implies_set: 1,        /* Var is set (except INQUIRE) */
  48.       inquire_set: 1,        /* Var is set by INQUIRE */
  49.       nonstandard: 1,        /* not Fortran 77 standard keyword */
  50.       special:       1;        /* Indicates special cases */
  51. } io_keywords[]={
  52.             /* List has commonest ones first for fast lookup */
  53. /*Name           Stmts   Types   UseSetInqStdSpcl */
  54. {"END",        RD,    LAB,    1, 0, 0, 0, 0},
  55. {"ERR",        ALL,    LAB,    1, 0, 0, 0, 0},
  56. {"FILE",    OP|INQ,    CHR,    1, 0, 0, 0, 0},
  57. {"UNIT",    ALL,    UID,    1, 0, 0, 0, 0},
  58. {"STATUS",    OP|CL,    CHR,    1, 0, 0, 0, 0},
  59.             /* The rest are alphabetical. */
  60. {"ACCESS",    OP|INQ,    CHR,    1, 0, 1, 0, 0},
  61. {"BLANK",    OP|INQ,    CHR,    1, 0, 1, 0, 0},
  62. {"DIRECT",    INQ,    CHR,    0, 0, 1, 0, 0},
  63. {"EXIST",    INQ,    LOG,    0, 0, 1, 0, 0},
  64. {"FMT",        RD|WR,    FID,    1, 0, 0, 0, 0},
  65. {"FORM",    OP|INQ,    CHR,    1, 0, 1, 0, 0},
  66. {"FORMATTED",    INQ,    CHR,    0, 0, 1, 0, 0},
  67. {"IOSTAT",    ALL,    INT,    0, 1, 1, 0, 0},
  68. {"NAMED",    INQ,    LOG,    0, 0, 1, 0, 0},
  69. {"NEXTREC",    INQ,    INT,    0, 0, 1, 0, 0},
  70. {"NML",        RD|WR,    NML,    1, 0, 0, 1, 0},
  71. {"NUMBER",    INQ,    INT,    0, 0, 1, 0, 0},
  72. {"OPENED",    INQ,    LOG,    0, 0, 1, 0, 0},
  73. {"REC",        RD|WR,    INT,    1, 0, 0, 0, 0},
  74. {"RECL",    OP|INQ,    INT,    1, 0, 1, 0, 0},
  75. {"SEQUENTIAL",    INQ,    CHR,    0, 0, 1, 0, 0},
  76. {"UNFORMATTED",    INQ,    CHR,    0, 0, 1, 0, 0},
  77.             /* NAME is a special case for VMS */
  78. #ifndef VMS_IO
  79. {"NAME",    INQ,    CHR,    0, 0, 1, 0, 0}, /* normal definition */
  80. #else
  81. {"NAME",    OP|INQ,    CHR,    1, 0, 1, 0, 1}, /* VMS definition */
  82. #endif /*VMS_IO*/
  83.             /* Other simple VMS-isms go here. */
  84. #ifdef VMS_IO
  85. {"BLOCKSIZE",    OP,    INT,    1, 0, 0, 1, 0},
  86. {"BUFFERCOUNT",    OP,    INT,    1, 0, 0, 1, 0},
  87. {"CARRIAGECONTROL",OP|INQ,CHR,    1, 0, 1, 1, 0},
  88. {"DEFAULTFILE",    OP,    CHR,    1, 0, 0, 1, 0},
  89. {"DISP",    OP|CL,    CHR,    1, 0, 0, 1, 0},
  90. {"DISPOSE",    OP|CL,    CHR,    1, 0, 0, 1, 0},
  91. {"EXTENDSIZE",    OP,    INT,    1, 0, 0, 1, 0},
  92. {"INITIALSIZE",    OP,    INT,    1, 0, 0, 1, 0},
  93. {"MAXREC",    OP,    INT,    1, 0, 0, 1, 0},
  94. {"ORGANIZATION",OP|INQ,    CHR,    1, 0, 1, 1, 0},
  95. {"RECORDSIZE",    OP,    INT,    1, 0, 0, 1, 0},
  96. {"RECORDTYPE",    OP|INQ,    CHR,    1, 0, 1, 1, 0},
  97. {"TYPE",    OP,    CHR,    1, 0, 0, 1, 0},
  98. #endif /*VMS_IO*/
  99.             /* Last entry (for not-founds) has defns that should
  100.                do the right thing most of the time. */
  101. {NULL,        ALL,    (~0),    1, 0, 1, 1, 0},
  102. };
  103.  
  104.     /* Lookup table which maps statement classes into
  105.        the corresponding bit fields of io_keywords table.
  106.        Order: commonest first for faster lookup. */
  107. struct {
  108.     short stmt_class, stmt_flag;
  109. } local_class[]= {
  110. {tok_READ,     RD},
  111. {tok_WRITE,     WR},
  112. {tok_OPEN,     OP},
  113. {tok_CLOSE,     CL},
  114. {tok_BACKSPACE,     BSP},
  115. {tok_ENDFILE,     ENF},
  116. {tok_REWIND,     REW},
  117. {tok_INQUIRE,     INQ},
  118. };
  119. #define NUM_IO_STMTS (sizeof(local_class)/sizeof(local_class[0]))
  120.  
  121.  
  122.     /* The following table contains special keywords for the VMS
  123.        form of OPEN statement.  These keywords occur alone, i.e.
  124.        without the =value normally required for I/O control list
  125.        keywords. */
  126. #ifdef VMS_IO
  127. char *special_open_keywds[]={
  128. "NOSPANBLOCKS",
  129. "READONLY",
  130. "SHARED",
  131. };
  132. #define NUM_SPECIAL_OPEN_KEYWDS (sizeof(special_open_keywds) \
  133.                    / sizeof(special_open_keywds[0]))
  134.  
  135. #endif /*VMS_IO*/
  136.