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

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