home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_01 / 8n01045a < prev    next >
Text File  |  1990-02-19  |  11KB  |  410 lines

  1.      1    /*
  2.      2     *    e n v i r o n . h
  3.      3     *    -----------------
  4.      4     *    This module contains environment specific information.
  5.      5     *    It's used to make the programs more portable.
  6.      6     *
  7.      7     *    @(#)Copyrigth (C) by Rainer Gerhards. All rights reserved.
  8.      8     *
  9.      9     *    Include-file selection defines are:
  10.     10     *
  11.     11     *    Define        Class
  12.     12     *    ----------------------------------------------------------------------
  13.     13     *    INCL_ASSERT    assert macro and needed functions
  14.     14     *    INCL_CONIO    low-level console i/o
  15.     15     *    INCL_CONVERT    conversion and classification functions
  16.     16     *    INCL_CTYPE    ctype.h
  17.     17     *    INCL_CURSES    curses.h
  18.     18     *    INCL_LLIO    low-level i/o
  19.     19     *    INCL_MEMORY    memory acclocation/deallocation functions
  20.     20     *    INCL_MSDOS    MS-DOS support
  21.     21     *    INCL_PROCESS    process control
  22.     22     *    INCL_STDIO    stdio.h
  23.     23     *    INCL_STDLIB    standard library functions
  24.     24     *    INCL_STRING    string handling functions
  25.     25     */
  26.     26    #ifndef    ENVIRON_H
  27.     27    #define ENVIRON_H
  28.        
  29.     28    #undef    MSDOS
  30.     29    #undef    OS2
  31.     30    #undef    UNIX
  32.     31    #undef    STARSYS
  33.        
  34.     32    /*
  35.     33     *    configurable parameters.
  36.     34     *    modify the following parameters according to the target environment.
  37.     35     */
  38.        
  39.     36    /*
  40.     37     *    define target operating system
  41.     38     */
  42.     39    #define MSDOS        0
  43.     40    #define    UNIX        0
  44.     41    #define OS2        1
  45.     42    #define    STARSYS        0
  46.        
  47.     43    /*
  48.     44     *    define target machine
  49.     45     *
  50.     46     *    This is auxiluary data only needed for some operating
  51.     47     *    systems. Currently only needed if MS-DOS is active.
  52.     48     */
  53.     49    #define    IBM_PC        1        /* IBM PC, XT, AT & compatibels    */
  54.     50    #define    WANG_PC        0        /* Wang PC, APC ...        */
  55.        
  56.     51    /*
  57.     52     *    define target compiler (if neccessary)
  58.     53     */
  59.     54    #undef    MSC
  60.     55    #define    MSC        1        /* Microsoft C            */
  61.        
  62.     56    #define    AUTO_SEL    1
  63.     57    /*
  64.     58     * The above #define allowes an automatic language set selection. It is
  65.     59     * only functional if the used compiler identifies itself via a #define.
  66.     60     *
  67.     61     * Note: If AUTO_SEL is set, the parameters below are meaningless!
  68.     62     */
  69.        
  70.     63    #define    USE_FAR        0        /* use far keyword        */
  71.     64    #define    USE_NEAR    0        /* use near keyword        */
  72.     65    #define    USE_VOID    1        /* use void keyword        */
  73.     66    #define    USE_VOLA    0        /* use volatile keyword        */
  74.     67    #define    USE_CONST    0        /* use const keyword        */
  75.     68    #define    USE_PROTT    0        /* use function prototypes    */
  76.     69    #define    USE_INTR    0        /* use interrupt keyword    */
  77.        
  78.     70    /*    +----------------------------------------------------------------+
  79.     71     *    |                  End Of Configurable Parameters                |
  80.     72     *    +----------------------------------------------------------------+
  81.     73     *    Please do not make any changes below this point!
  82.     74     */
  83.        
  84.     75    #ifndef    SYMDEB
  85.     76    # define    SYMDEB        0
  86.     77    #endif
  87.        
  88.     78    /*
  89.     79     *    Check target compiler. Note that the MSC switch is overriden if
  90.     80     *    either __TURBOC__ or DLC are defined.
  91.     81     */
  92.     82    #ifdef    __TURBOC__
  93.     83    # undef    MSC
  94.     84    #endif
  95.     85    #ifdef    DLC
  96.     86    # undef    MSC
  97.     87    #endif
  98.     88    #if    STARSYS
  99.     89    # undef MSC
  100.     90    #endif
  101.        
  102.     91    #if    !(MSDOS || OS2)
  103.     92    # undef MSC
  104.     93    # undef    AUTO_SEL
  105.     94    # define    AUTO_SEL    0
  106.     95    #endif
  107.        
  108.     96    #if    OS2
  109.     97    # undef     MSC
  110.     98    # define    MSC        1
  111.     99    # undef     AUTO_SEL
  112.    100    # define    AUTO_SEL    1
  113.    101    #endif
  114.        
  115.    102    /*
  116.    103     * Compiler ANSI-compatible?
  117.    104     * (First we assume it's not!)
  118.    105     */
  119.    106    #define        ANSI_C        0
  120.    107    #ifdef    MSC
  121.    108    #  undef    ANSI_C
  122.    109    #  define    ANSI_C        1
  123.    110    #endif
  124.    111    #ifdef    TURBO_C
  125.    112    #  undef    ANSI_C
  126.    113    #  define    ANSI_C        1
  127.    114    #endif
  128.        
  129.    115    #if    AUTO_SEL
  130.    116    #  undef    USE_FAR
  131.    117    #  undef    USE_NEAR
  132.    118    #  undef    USE_VOID
  133.    119    #  undef    USE_VOLA
  134.    120    #  undef    USE_CONST
  135.    121    #  undef    USE_PROTT
  136.    122    #  undef    USE_INTR
  137.    123    #  ifdef    __TURBOC__
  138.    124    #    define    USE_FAR        1
  139.    125    #    define    USE_NEAR    1
  140.    126    #    define    USE_VOID    1
  141.    127    #    define    USE_VOLA    1
  142.    128    #    define    USE_CONST    1
  143.    129    #    define    USE_PROTT    1
  144.    130    #    define    USE_INTR    1
  145.    131    #  endif
  146.    132    #  ifdef    DLC
  147.    133    #    define    USE_FAR        1
  148.    134    #    define    USE_NEAR    1
  149.    135    #    define    USE_VOID    1
  150.    136    #    define    USE_VOLA    1
  151.    137    #    define    USE_CONST    1
  152.    138    #    define    USE_PROTT    1
  153.    139    #    define    USE_INTR    0
  154.    140    #  endif
  155.    141    #  ifdef    MSC
  156.    142    #    define    USE_FAR        1
  157.    143    #    define    USE_NEAR    1
  158.    144    #    define    USE_VOID    1
  159.    145    #    define    USE_VOLA    1
  160.    146    #    define    USE_CONST    1
  161.    147    #    define    USE_PROTT    1
  162.    148    #    define    USE_INTR    1
  163.    149    #  endif
  164.    150    #endif
  165.        
  166.        
  167.    151    #if    !USE_FAR
  168.    152    #define    far
  169.    153    #endif
  170.        
  171.    154    #if    !USE_NEAR
  172.    155    #define    near
  173.    156    #endif
  174.        
  175.    157    #if    !USE_VOID
  176.    158    #define    void
  177.    159    #endif
  178.        
  179.    160    #if    !USE_VOLA
  180.    161    #define    volatile
  181.    162    #endif
  182.        
  183.    163    #if    !USE_CONST
  184.    164    #define    const
  185.    165    #endif
  186.        
  187.    166    #if    USE_INTR
  188.    167    # ifdef    MSC
  189.    168    #   define    INTERRUPT interrupt far
  190.    169    # else
  191.    170    #   define    INTERRUPT interrupt
  192.    171    # endif
  193.    172    #else
  194.    173    # define    INTERRUPT
  195.    174    #endif
  196.        
  197.    175    #if    USE_PROTT
  198.    176    #  define    PROTT(x)    x
  199.    177    #  ifdef MSC
  200.    178    #    define    STATICPT(func, prott) static func prott
  201.    179    #  else
  202.    180    #    define    STATICPT(func, prott) extern func prott
  203.    181    #   endif
  204.    182    #else
  205.    183    #  define    PROTT(x)    ()
  206.    184    #  ifdef MSC
  207.    185    #    define    STATICPT(func, prott) static func ()
  208.    186    #  else
  209.    187    #    define    STATICPT(func, prott) extern func ()
  210.    188    #   endif
  211.    189    #endif
  212.        
  213.    190    #ifdef    MSC
  214.    191    # define    inportb(port) inp(port)
  215.    192    # define    outportb(port, val) outp(port, val)
  216.    193    #endif
  217.        
  218.    194    #ifdef    __TURBOC__
  219.    195    #  define    REGPKT    struct REGS
  220.    196    #else
  221.    197    #  define    REGPKT    union REGS
  222.    198    #endif
  223.        
  224.    199    #ifdef    DLC
  225.    200    #  define    defined(x)
  226.    201    #  define    inportb        inp
  227.    202    #  define    outportb    outp
  228.    203    #endif
  229.        
  230.    204    #if    !SYMDEB                /* symbolic debugging support    */
  231.    205    #  define    STATICATT    static
  232.    206    #endif
  233.        
  234.    207    #if    STARSYS
  235.    208    #  define    exit(x)        dx_exit(x)
  236.    209    #endif
  237.        
  238.    210    /*
  239.    211     * Define open modes according to selected operating system/compiler.
  240.    212     */
  241.    213    #if    MSDOS || OS2
  242.    214    #  define    OPM_WB        "wb"
  243.    215    #  define    OPM_WT        "wt"
  244.    216    #  define    OPM_RB        "rb"
  245.    217    #  define    OPM_RT        "rt"
  246.    218    #endif
  247.        
  248.    219    #if    UNIX
  249.    220    #  define    OPM_WB        "w"
  250.    221    #  define    OPM_WT        "w"
  251.    222    #  define    OPM_RB        "r"
  252.    223    #  define    OPM_RT        "r"
  253.    224    #endif
  254.        
  255.    225    #define    TRUE    1
  256.    226    #define    FALSE    0
  257.        
  258.    227    typedef unsigned char    uchar;
  259.    228    typedef int        bool;
  260.    229    typedef unsigned short    ushort;
  261.    230    typedef unsigned long    ulong;
  262.        
  263.    231    #define tonumber(x)    ((x) - '0')
  264.    232    #define    FOREVERL()    for(;;)
  265.        
  266.    233    /*
  267.    234     * Select #include-files depending on target compiler and OS.
  268.    235     *
  269.    236     * Phases:
  270.    237     * 1. Define all include selection constants to true or false.
  271.    238     * 2. Select actual include files and include them.
  272.    239     * 3. #Undef all include selection constants.
  273.    240     */
  274.    241    #ifndef    INCL_STDIO
  275.    242    #    define    INCL_STDIO    0
  276.    243    #else
  277.    244    #    undef    INCL_STDIO
  278.    245    #    define    INCL_STDIO    1
  279.    246    #endif
  280.    247    #ifndef    INCL_CURSES
  281.    248    #    define    INCL_CURSES    0
  282.    249    #else
  283.    250    #    undef    INCL_CURSES
  284.    251    #    define    INCL_CURSES    1
  285.    252    #endif
  286.    253    #ifndef    INCL_CTYPE
  287.    254    #    define    INCL_CTYPE    0
  288.    255    #else
  289.    256    #    undef    INCL_CTYPE
  290.    257    #    define    INCL_CTYPE    1
  291.    258    #endif
  292.    259    #ifndef    INCL_ASSERT
  293.    260    #    define    INCL_ASSERT    0
  294.    261    #else
  295.    262    #    undef    INCL_ASSERT
  296.    263    #    define    INCL_ASSERT    1
  297.    264    #endif
  298.    265    #ifndef    INCL_LLIO
  299.    266    #    define    INCL_LLIO    0
  300.    267    #else
  301.    268    #    undef    INCL_LLIO
  302.    269    #    define    INCL_LLIO    1
  303.    270    #endif
  304.    271    #ifndef    INCL_PROCESS
  305.    272    #    define    INCL_PROCESS    0
  306.    273    #else
  307.    274    #    undef    INCL_PROCESS
  308.    275    #    define    INCL_PROCESS    1
  309.    276    #endif
  310.    277    #ifndef    INCL_MEMORY
  311.    278    #    define    INCL_MEMORY    0
  312.    279    #else
  313.    280    #    undef    INCL_MEMORY
  314.    281    #    define    INCL_MEMORY    1
  315.    282    #endif
  316.    283    #ifndef    INCL_STRING
  317.    284    #    define    INCL_STRING    0
  318.    285    #else
  319.    286    #    undef    INCL_STRING
  320.    287    #    define    INCL_STRING    1
  321.    288    #endif
  322.    289    #ifndef    INCL_STDLIB
  323.    290    #    define    INCL_STDLIB    0
  324.    291    #else
  325.    292    #    undef    INCL_STDLIB
  326.    293    #    define    INCL_STDLIB    1
  327.    294    #endif
  328.    295    #ifndef    INCL_CONVERT
  329.    296    #    define    INCL_CONVERT    0
  330.    297    #else
  331.    298    #    undef    INCL_CONVERT
  332.    299    #    define    INCL_CONVERT    1
  333.    300    #endif
  334.    301    #ifndef    INCL_MSDOS
  335.    302    #    define    INCL_MSDOS    0
  336.    303    #else
  337.    304    #    undef    INCL_MSDOS
  338.    305    #    define    INCL_MSDOS    1
  339.    306    #endif
  340.    307    #ifndef    INCL_CONIO
  341.    308    #    define    INCL_CONIO    0
  342.    309    #else
  343.    310    #    undef    INCL_CONIO
  344.    311    #    define    INCL_CONIO    1
  345.    312    #endif
  346.        
  347.    313    #if    INCL_STDIO && !(INCL_CURSES && UNIX)
  348.    314    #    include <stdio.h>
  349.    315    #endif
  350.    316    #if    INCL_CURSES && UNIX
  351.    317    #    include <curses.h>
  352.    318    #endif
  353.    319    #if    INCL_CTYPE || INCL_CONVERT
  354.    320    #    include <ctype.h>
  355.    321    #endif
  356.    322    #if    INCL_ASSERT
  357.    323    #    include <assert.h>
  358.    324    # ifdef    MSC
  359.    325    #    undef    INCL_PROCESS
  360.    326    #    define    INCL_PROCESS    1
  361.    327    # endif
  362.    328    # ifdef    __TURBOC__
  363.    329    #    undef    INCL_PROCESS
  364.    330    #    define    INCL_PROCESS    1
  365.    331    # endif
  366.    332    #endif
  367.    333    #if    INCL_LLIO
  368.    334    # ifdef    MSC
  369.    335    #    include <fcntl.h>
  370.    336    #    include <io.h>
  371.    337    # endif
  372.    338    #endif
  373.    339    #if    INCL_PROCESS
  374.    340    # ifdef    MSC
  375.    341    #    include <process.h>
  376.    342    # endif
  377.    343    #endif
  378.    344    #if    INCL_MEMORY
  379.    345    #    include <malloc.h>
  380.    346    #endif
  381.    347    #if    INCL_STRING
  382.    348    # if    ANSI_C
  383.    349    #    include <string.h>
  384.    350    # endif
  385.    351    #endif
  386.    352    #if    INCL_STDLIB || INCL_CONVERT
  387.    353    # if    ANSI_C
  388.    354    #    include <stdlib.h>
  389.    355    # endif
  390.    356    #endif
  391.    357    #if    INCL_CONIO
  392.    358    #  ifdef     __TURBOC__
  393.    359    #    include <conio.h>
  394.    360    #  endif
  395.    361    #  ifdef     MSC
  396.    362    #    include <conio.h>
  397.    363    #  endif
  398.    364    #endif
  399.    365    #if    MSDOS && INCL_MSDOS
  400.    366    #    include <dos.h>
  401.    367    #endif
  402.        
  403.        
  404.    368    /*
  405.    369     * Purge utility #defines.
  406.    370     */
  407.    371    #undef    INCL_STDIO
  408.        
  409.    372    #endif
  410.