home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11.lha / ccs-lib / include / stdef.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-16  |  7.0 KB  |  376 lines

  1. /*    stdef.h
  2. #
  3. %    Copyright (c)    Jin Guojun
  4. %
  5. %    Definitions for common types, NULL, and errno.
  6. %
  7. % AUTHOR:    Jin Guojun - LBL    10/01/1990
  8. */
  9.  
  10. #ifndef _STDDEF
  11. #define _STDDEF
  12.  
  13. #if __STDC__
  14. #define _Cdecl
  15. #else
  16. #define _Cdecl    cdecl
  17. #endif
  18.  
  19. #if    !defined FILE && !defined __STDIO_DEF_
  20. #include <stdio.h>
  21. #endif
  22. #ifndef    SEEK_SET
  23. #define    SEEK_SET    0
  24. #define    SEEK_CUR    1
  25. #define    SEEK_END    2
  26. #endif
  27. #define    SEEK_GETB    -1
  28. #define    SEEK_UGETB    -2
  29. #define    SEEK_PEEK    -3
  30.  
  31.  
  32. #ifdef    TC_Need
  33. #ifndef _PTRDIFF_T
  34. #define _PTRDIFF_T
  35. #if    defined(__LARGE__) | defined(__HUGE__) | defined(__COMPACT__)
  36. typedef long    ptrdiff_t;
  37. #else
  38. typedef int    ptrdiff_t;
  39. #endif
  40. #endif
  41. #ifndef NULL
  42. #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  43. #define NULL    0
  44. #else
  45. #define NULL    0L
  46. #endif
  47. #endif
  48.  
  49. extern    int    _Cdecl errno;
  50.  
  51. #else
  52.  
  53. # ifndef    coreleft
  54. #    define    coreleft()    (MType)-1
  55. # endif
  56.  
  57. extern    int    errno;
  58.  
  59. #endif    TC_Need
  60.  
  61. #ifdef    NO_CCSECL
  62. # define    msg(s,a)    fprintf(stderr, s, a)
  63. # define    message(s,a,b)    fprintf(stderr, s, a, b)
  64. #else
  65. # define    msg    message
  66. #endif
  67. #ifndef    mesg
  68. #define    mesg(s)        fprintf(stderr, s)
  69. #endif
  70.  
  71. #ifndef    VType
  72. #define    VType    void
  73. #endif
  74. typedef    void*    VPointer;
  75.  
  76. #ifndef    PrtCAST
  77. #define    PrtCAST    (VType *)
  78. #endif
  79.  
  80. #ifndef    MIN
  81. # define MIN(a,b)    ((a < b) ? a : b)
  82. #endif
  83.  
  84. #ifndef    isfloat
  85. #include <ctype.h>
  86. #define    isfloat(c)    (isdigit(c) || '+'<=c && c<='.' || toupper(c)=='E')
  87. #endif
  88.  
  89. #define    Stx    2
  90. #define    Heart    3
  91. #define    Diamond    4
  92. #define    Club    5
  93. #define    Spade    6
  94. #define    Ack    6
  95. #define    Bel    7
  96. #define    BS      8
  97. #define    Tab     9
  98. #define    LF      10
  99. #define    VT      11
  100. #define    FmFd    12
  101. #define    CR      13
  102. #define    SO    14
  103. #define    SI    15
  104. #define    Esc    0x1B
  105. #define    DC2    0x12
  106. #define    DC4    0x14
  107. #define    NAk    0x15
  108. #define    CTRL_Y    0x19
  109. #define    Space    0x20
  110. #define    Del    0x7F
  111. #define    GT_EQL    242
  112. #define    ST_EQL    243
  113. #define    RootS    251
  114.  
  115. #define    ByteMax    256
  116.  
  117. #define    TRUE    1
  118. #define    FALSE    0
  119. #define    Yes    1
  120. #define    No    0
  121.  
  122. #ifndef    True
  123. #define    True    1
  124. #define    False    0
  125. #endif
  126.  
  127.  
  128. #if    !defined HIPS2_HF
  129. typedef unsigned char    byte;
  130. #endif
  131.  
  132. #ifdef    COMMON_TOOL
  133. # ifndef    FITS_IMAGE
  134. #    define    FITS_IMAGE
  135. # endif
  136. # ifndef    RLE_IMAGE
  137. #    define    RLE_IMAGE
  138. # endif
  139. #endif
  140.  
  141. /*    standard TYPE definitions    */
  142. #ifndef    MType
  143. # if    defined    TC_Need | defined INT_16_BIT
  144. #   define    MType    long
  145. # else
  146. #   define    MType    int
  147. # endif
  148. #endif
  149.  
  150. #ifndef    cmap_t
  151. #define    cmap_t    byte
  152. #endif
  153.  
  154. typedef int        bool;
  155. typedef unsigned int    word;
  156. typedef unsigned int    Pointer_Mem;
  157. typedef    unsigned long    longword;
  158. typedef    short        coord_t;
  159.  
  160. /*    definition for display attributes.    */
  161. #define    NoDpyB    0
  162. #define    UnderLn    1
  163. #define    Normal    7
  164. #define    Reverse    0x70
  165. #define    Blink    0x80
  166. #define    HighLi    8
  167.  
  168. #define    ScrollUp    6
  169. #define    ScrollDown    7
  170.  
  171. /*    The foot of a letter is lower than y0 in XDrawString()    */
  172. #define    XStringBaseHigh    4
  173.  
  174. typedef    struct    {
  175.     coord_t    x0, y0,    /*    upper left corner position    */
  176.         cs, ls;    /*    Colunms and Lines        */
  177.     } Range;
  178.  
  179. typedef    struct    {
  180.     coord_t    x, y,        /* x & y are margin's offsets        */
  181.         width, height;    /* screen display area height & width    */
  182.     } Offset;
  183.  
  184. typedef    union    {
  185.     struct    {
  186.         char    line_w, fill, join, style;
  187.         short    angle1, angle2;
  188.     } draw;
  189.     struct    {
  190.         char    font_id, fw, fh, fbsh, *content;
  191.     } text;
  192. }    si_union;
  193.  
  194. typedef    struct    {
  195.     coord_t    x0, y0, w, h;
  196.     long    color;
  197.     char    e_type, hidden, cols, rows;
  198.     si_union    elem;
  199.     } superimpose_elems;
  200.  
  201. typedef    struct    {
  202.     short    stack_len, n_elems;
  203.     superimpose_elems*    stack;
  204.     } superimpose_stack;
  205.  
  206. typedef    struct    {
  207.     char    *base,    /* buffer pointer. It should not be changed    */
  208.         *ptr;    /* data pointer    */
  209.     MType    bsize,    /* buffer size    */
  210.         dlen;    /* data size    */
  211.     int    offset,    /* header length    */
  212.         flags;    /* buffer ID    */
  213.     } BUFFER;
  214.  
  215. #define    BUFFER_MAGIC    0xB99B5AA5    /* need to fit int and long    */
  216. #define    beof(bp)    ((bp)->ptr - ((bp)->base + (bp)->offset) >= (bp)->dlen)
  217.  
  218.  
  219. #ifndef    QSType
  220. #define    QSType    MType
  221. #endif
  222.  
  223. typedef    struct    {    /* for QuickSort */
  224.     QSType    value;    /*    sort dependent value    */
  225.     int    QsIndex;    /* can be any pointer    */
  226.     } QSCell;
  227.  
  228. #define    SoftInterface    int
  229. typedef    SoftInterface    TableInterface;
  230. typedef    SoftInterface    StdInterface();
  231.  
  232. typedef    enum    {
  233.     ARGU_NONE = -1,
  234.     ARGU_B0,    /* #0    */
  235.     ARGU_B1,
  236.     ARGU_B2,
  237.     ARGU_B3,
  238.     ARGU_B4,
  239.     ARGU_B5,
  240.     ARGU_B6,
  241.     ARGU_B7,
  242.     ARGU_B8,
  243.     ARGU_B9,
  244.     ARGU_B10,    /* #10    */
  245.     ARGU_BNEG =    '!',    /* reserve 0B - 1F for other Bxxx    */
  246.     ARGU_BNEGI =    '~',    /* 0 if input is set; otherwise 1.    */
  247.     ARGU_BPLUS =    '+',
  248.     ARGU_BNUM =    '#',    /*    True if input with number    */
  249.     ARGU_BMINUS =    '-',
  250.     ARGU_SCALE =    '*',
  251.     ARGU_BANDEF =    '&',    /* logic operation with default value    */
  252.     ARGU_BORDEF =    '|',
  253.     ARGU_BXORDEF =    '^',
  254.     ARGU_BEXTYPE =    'B',    /*    return extended argument type    */
  255.     ARGU_BEXT =    'E',    /*    return    extension value    */
  256.     ARGU_BDEF =    'N',    /*    reset default value    */
  257.     ARGU_BOOL =    'b',
  258.     ARGU_CHAR =    'c',
  259.     ARGU_SHORT =    'h',
  260.     ARGU_HEX =    'x',
  261.     ARGU_INT =    'i',
  262.     ARGU_FLOAT =    'f',
  263.     ARGU_DOUBLE =    'g',
  264.     ARGU_STRING =    's',
  265.     ARGU_ADDPARAM =    127    /*    flag should be "?-*" ;
  266.                     ? is any single character    */
  267. } argu_type;
  268.  
  269. typedef    union    {
  270.     argu_type    a;
  271.     bool    b;
  272.     char    c;
  273.     short    s;
  274.     int    i;
  275.     float    f;
  276.     double    d;
  277. } convs_v;
  278.  
  279. typedef    union    {
  280.     argu_type    *a_p;
  281.     bool    *b_p;
  282.     char    *c_p,
  283.     *    *stp;
  284.     short    *s_p;
  285.     int    *i_p;
  286.     float    *f_p;
  287.     double    *d_p;
  288.     void    *v_p;
  289. } convs_p;
  290.  
  291. typedef    struct    {
  292.     argu_type    type;
  293.     convs_p    p;
  294.     convs_v    v;
  295. } convs;
  296.  
  297. typedef    struct    {
  298.     char    *flag,        /* argument flag    */
  299.         *in_fmt;    /* input format.    */
  300. #ifdef    USE_STRING_ARGU_DEF
  301.     char*    def_val;    /* no defined variable can be passed    */
  302. #else
  303.     float    def_val;    /* no double value for default.    */
  304. #endif
  305.     int    num_vars,
  306.         min_inps;    /* min input(s) for above variables    */
  307.     char    *info;
  308.     bool    sscan;
  309. } arg_fmt_list_string;
  310.  
  311. typedef    struct    e_afls    {
  312.     arg_fmt_list_string    *fls;
  313.     int    flag_len,
  314.         u_l_s,
  315.         extended_flags,
  316.         ext_level;    /* root=0, 1st_ext=1, 2nd_ext=2, ...    */
  317.     convs    *v;
  318.     struct    e_afls    *extend;
  319. }    arg_fmt_lists;
  320.  
  321.  
  322. #ifdef    WINDOW_VER
  323.  
  324. #    include <dos.h>
  325. typedef    union    REGS    Regset;
  326. #    include <keycode.h>
  327. #    define    WaitKey()    while (!kbhit())
  328.  
  329. #endif
  330.  
  331. extern    bool    _debug, debug, prgmerr();
  332. extern    char    *strcpy(), *strncpy();
  333. extern    double    arget();
  334. extern    VType    *nzalloc(), *zalloc();
  335.  
  336. #define    Loop    while(1)
  337.  
  338. #ifndef    DEBUGANY
  339. #define    DEBUGANY    debug
  340. #endif
  341.  
  342. #define    DEBUG_L2    (DEBUGANY==2)
  343. #define    DEBUG_L3    (DEBUGANY==3)
  344. #define    DEBUG2OH    (DEBUGANY > 1)
  345. #define    DEBUG3OH    (DEBUGANY > 2)
  346. #define    DEBUGMESSAGE    if (DEBUGANY) message
  347. #define    DEBUG2MESSAGE    if (DEBUG2OH) message
  348.  
  349. #define    NS_TSET(r, c, type)    avset(argc, argv, r, c, type)
  350.  
  351. #define    Alloc_Mem(ahow, i, j, ms)    \
  352.     PrtCAST(i*j ? core_trace(coreleft(), ahow, i, j, ms) : 0)
  353. #define    NZALLOC(i, j, ms)    Alloc_Mem(malloc((i) * (j)), i, j, ms)
  354. #define    ZALLOC(i, j, ms)    Alloc_Mem(calloc(i, j), i, j, ms)
  355. #define    pointer_buffer_size(p)    (*((int *)p - 2) - (sizeof(int) << 1))
  356.  
  357. #ifndef    str_save
  358. #define    str_save(s)    strcpy(ZALLOC((MType)(strlen(s)+1), (MType)1, s), s)
  359. #endif
  360.  
  361. #if defined TC_Need & !defined _SIZE_T
  362. #    define    _SIZE_T
  363. typedef unsigned    size_t;
  364. #endif
  365. #ifdef    sparc
  366. extern    fclose(), fread(), fwrite();
  367. extern    int    fseek();
  368. #endif
  369.  
  370. /*    for reading a stream to work with fseek, fgetc, and ungetc    */
  371. #define    init_readpipe(i)    set_readpipe(i, True)
  372. #define    reset_readpipe(i)    set_readpipe(i, False)
  373. #define    pushpipe(buf, size, fp)    readpipe(buf, -1, size, fp)
  374.  
  375. #endif    _STDDEF
  376.