home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume28 / m0 / part02 / std.h < prev   
Encoding:
C/C++ Source or Header  |  1994-06-06  |  2.8 KB  |  120 lines

  1. /*
  2.     std.h
  3. */
  4. /*  Copyright (c) 1994 Christian F. Tschudin. All rights reserved.
  5.  
  6.     Distributed under the terms of the GNU General Public License
  7.     version 2 of june 1991 as published by the Free Software
  8.     Foundation, Inc.
  9.  
  10.              This file is part of M0.
  11.  
  12. M0 is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY.  No author or distributor accepts responsibility to anyone for
  14. the consequences of using it or for whether it serves any particular
  15. purpose or works at all, unless he says so in writing.  Refer to the GNU
  16. General Public License for full details. 
  17.  
  18. Everyone is granted permission to copy, modify and redistribute M0, but
  19. only under the conditions described in the GNU General Public License. 
  20. A copy of this license is supposed to have been given to you along with
  21. M0 so you can know your rights and responsibilities.  It should be in a
  22. file named LICENSE.  Among other things, the copyright notice and this
  23. notice must be preserved on all copies.  */
  24.  
  25. #ifndef STD_H
  26. #define STD_H
  27.  
  28. /* include files: ----------------------------------------------------------- */
  29.  
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <sys/types.h>
  34.  
  35. #ifdef __MSDOS__
  36. # include <alloc.h>
  37. # include <mem.h>
  38. #else
  39. # include <malloc.h>
  40. # include <memory.h>
  41. #endif
  42.  
  43.  
  44. /* data types: ------------------------------------------------------------- */
  45.  
  46. typedef unsigned char    byte;
  47.  
  48. #ifdef __MSDOS__
  49.   typedef byte huge    *byteptr;
  50.   #define malloc(n)    farmalloc(n)
  51.   #define realloc(s,n)    farrealloc(s,n)
  52.   #define calloc(n,s)    farcalloc(n,s)
  53.   #define free(p)    farfree(p)
  54. #else
  55.   typedef byte        *byteptr;
  56. #endif
  57.  
  58. typedef short        sshort;
  59.  
  60. /* we want signed and unsigned integers to be (at least) 32 bit wide: */
  61.  
  62. #ifdef __MSDOS__
  63.   typedef unsigned short    ushort;
  64.   typedef unsigned long        uint;
  65.   typedef long            sint;
  66.   typedef unsigned long        uint32;
  67. #else
  68.   typedef int            sint;
  69.   typedef unsigned int        uint32;
  70. #endif
  71.  
  72. #define swap_short(s)    *(s) =  (*(s)>>8) | (*(s)<<8)
  73. #define swap_int(l)    *(l) =  (*(l)<<24) | ((*(l)&0x0ff00L)<<8) | \
  74.                 ((*(l)&0x0ff0000L)>>8) | (0x0ffL&(*(l)>>24));    
  75.  
  76. /* compatibility issues: --------------------------------------------------- */
  77.  
  78. #ifdef __MSDOS__
  79. # define LITTLE_ENDIAN
  80. # define DIRDELIMIT    '\\'
  81.   extern long gethostid();        /* in l_compat.c */
  82. #endif
  83.  
  84. #ifdef unix
  85. # define DIRDELIMIT    '/'
  86. # define randomize()    srandom((long)time(NULL))
  87. #endif
  88.  
  89. #ifdef __ultrix
  90. # define LITTLE_ENDIAN
  91.   extern byteptr strdup(byteptr s);    /* in l_compat.c */
  92. #endif
  93.  
  94. #ifdef __alpha__
  95. # define LITTLE_ENDIAN
  96. #endif
  97.  
  98. /* available channels: ---------------------------------------------------- */
  99.  
  100. #define CHANNEL_CONSOLE        /* for all environments */
  101.  
  102. #ifdef SUNOS4
  103. # define CHANNEL_NIT
  104. # define CHANNEL_UDP
  105. #endif
  106.  
  107. #ifdef SUNOS5
  108. #endif
  109.  
  110. #ifdef __ultrix
  111. # define CHANNEL_UDP
  112. #endif
  113.  
  114. #ifdef __osf__
  115. # define CHANNEL_UDP
  116. #endif
  117.  
  118.  
  119. #endif
  120.