home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / msgapi38.zip / INCLUDE / PROG.H < prev    next >
C/C++ Source or Header  |  1995-06-06  |  10KB  |  308 lines

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *  MSGAPI Source Code, Version 2.00                                       *
  4.  *  Copyright 1989-1991 by Scott J. Dudley.  All rights reserved.          *
  5.  *                                                                         *
  6.  *  General include file.  Lots of machine-dependant stuff here.           *
  7.  *                                                                         *
  8.  *  For complete details of the licensing restrictions, please refer to    *
  9.  *  the licence agreement, which is published in its entirety in           *
  10.  *  README.1ST.                                                            *
  11.  *                                                                         *
  12.  *  USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE       *
  13.  *  MSGAPI LICENSING AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF THIS       *
  14.  *  AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO NOT HAVE    *
  15.  *  THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHOR AT ONE OF THE   *
  16.  *  ADDRESSES LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO USE THIS    *
  17.  *  FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE MSGAPI LICENSING         *
  18.  *  AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH THE   *
  19.  *  AUTHOR.                                                                *
  20.  *                                                                         *
  21.  *  You can contact the author at one of the address listed below:         *
  22.  *                                                                         *
  23.  *  Scott Dudley           FidoNet  1:249/106                              *
  24.  *  777 Downing St.        Internet f106.n249.z1.fidonet.org               *
  25.  *  Kingston, Ont.         BBS      (613) 389-8315   HST/14.4k, 24hrs      *
  26.  *  Canada - K7M 5N3                                                       *
  27.  *                                                                         *
  28.  ***************************************************************************/
  29.  
  30. /* $Id: prog.h_v 1.0 1991/11/16 16:16:51 sjd Rel sjd $ */
  31.  
  32. #ifndef __PROG_H_DEFINED
  33. #define __PROG_H_DEFINED
  34.  
  35. #include <stdio.h>
  36. #include <time.h>
  37. #include "compiler.h"
  38. #include "typedefs.h"
  39. #include "stamp.h"
  40.  
  41.  
  42. #ifdef __FARDATA__
  43.   #include "alc.h"
  44.  
  45.   #if !defined(ZREE)
  46.     #define malloc(n)     farmalloc(n)
  47.     #define calloc(n,u)   farcalloc(n,u)
  48.     #define free(p)       farfree(p)
  49.     #define realloc(p,n)  farrealloc(p,n)
  50.   #endif
  51.  
  52.   #ifdef __TURBOC__
  53.     #define coreleft()    farcoreleft()
  54.   #endif
  55. #else
  56.   unsigned cdecl coreleft(void);
  57.   unsigned long cdecl farcoreleft(void);
  58. #endif
  59.  
  60.  
  61. #if defined(__MSC__)
  62.  
  63.   #ifndef ZREE
  64.     #define farmalloc(n)    _fmalloc(n)
  65.     #define farfree(p)      _ffree(p)
  66.     #define farrealloc(p,n) _frealloc(p,n)
  67.     void far *farcalloc(int n,int m);
  68.  
  69.     #ifdef _MSC_VER
  70.       #if _MSC_VER >= 600
  71.         #define farcalloc(a,b) _fcalloc(a,b)
  72.       #endif /* _MSC_VER >= 600 */
  73.     #endif /* _MSC_VER */
  74.   #endif /* ZREE */
  75.  
  76.   #define da_year year
  77.   #define da_day day
  78.   #define da_mon month
  79.  
  80.   #define ti_min minute
  81.   #define ti_hour hour
  82.   #define ti_hund hsecond
  83.   #define ti_sec second
  84.  
  85.   #define getdate _dos_getdate
  86.   #define gettime _dos_gettime
  87.  
  88.   #define NO_STRFTIME
  89.  
  90.   #define NO_MKTIME
  91.  
  92. #elif defined(__TURBOC__)
  93.  
  94.   #define dosdate_t date
  95.   #define dostime_t time
  96.  
  97.   #if (__TURBOC__==0x0295)    /* TC++ includes a strftime() function */
  98.     #define NO_STRFTIME
  99.     #define NO_MKTIME
  100.   #endif
  101.  
  102. #endif
  103.  
  104. #if (1) /* defined(ZREE) || defined(__FLAT__) */
  105.     #undef farcalloc
  106.     #undef farmalloc
  107.     #undef farrealloc
  108.     #undef farfree
  109.     #undef _fmalloc
  110.  
  111.     #define farcalloc  calloc
  112.     #define farmalloc  malloc
  113.     #define farrealloc realloc
  114.     #define farfree    free
  115.     #define _fmalloc   malloc
  116. #endif
  117.  
  118. #if !defined(__TURBOC__) && !defined(__BCOS2__)
  119.  
  120.   /* For ERRNO definitions */
  121.   #define ENOTSAM EXDEV
  122.  
  123.   int _stdc fnsplit(const char *path,char *drive,char *dir,char *name,char *ext);
  124.   int _stdc getcurdir(int drive, char *directory);
  125.  
  126.   int fossil_wherex(void);
  127.   int fossil_wherey(void);
  128.   void fossil_getxy(char *row, char *col);
  129.  
  130.   #define textattr(attr)
  131.   #define getdisk()                  get_disk()
  132.   #define setdisk(drive)             set_disk(drive)
  133.  
  134.   #define getvect(int)            _dos_getvect(int)
  135.   #define setvect(int, func)      _dos_setvect(int, func)
  136.   #define inportb(port)           inp(port)
  137.   #define inport(port)            inpw(port)
  138.   #define outportb(port, byte)    outp(port, byte)
  139.   #define outport(port, byte)     outpw(port, byte)
  140.  
  141. #if 0
  142.   #ifndef MK_FP
  143.     #define MK_FP(seg, off)  (void far *)((unsigned long)(seg)<<16L | (off))
  144.   #endif
  145. #endif  
  146. #endif
  147.  
  148. #ifdef __MSC__
  149.   int _fast lock(int fh, long offset, long len);
  150.   int _fast unlock(int fh, long offset, long len);
  151.   #undef toupper
  152.   extern unsigned char _MyUprTab[256];      /* see _ctype.c */
  153.   #define toupper(c)  ((int)_MyUprTab[(c)])
  154. #endif
  155.  
  156. #ifdef OS_2
  157.   void _fast vbuf_flush(void);
  158.   void SnSetPipeName(char *pipename);
  159.   void SnWrite(char *str);
  160.  
  161.   #define  Start_Shadow()
  162.   #define  End_Shadow()
  163. #else
  164.   void pascal Start_Shadow(void);
  165.   void pascal End_Shadow(void);
  166. #endif
  167.  
  168.  
  169. #if !defined(offsetof) && !defined(_MSC_VER) && !defined(__TURBOC__)
  170. #define offsetof(typename,var) (size_t)(&(((typename *)0)->var))
  171. #endif
  172.  
  173. #ifdef __TURBOC__
  174. #if __TURBOC__ <= 0x0200
  175. #define offsetof(typename,var) (size_t)(&(((typename *)0)->var))
  176. #endif
  177. #endif
  178.  
  179.  
  180. typedef long timer_t;
  181.  
  182. #define REGISTER
  183.  
  184. #ifndef TRUE
  185. #define FALSE 0
  186. #define TRUE 1
  187. #endif
  188.  
  189. #ifdef PATHLEN
  190. #undef PATHLEN
  191. #endif
  192.  
  193. #define LITTLE_ENDIAN           /* If compiling on a "back-words" (Intel)  *
  194.                                  * Otherwise, #define BIG_ENDIAN           *//
  195.  
  196. #define PATH_DELIM       '\\'   /* Default separator for path specification */
  197. #define _PRIVS_NUM         12   /* Maximum priv levels for Maximus         */
  198. #define CHAR_BITS           8   /* Number of bits in a `char' variable     */
  199. #define PATHLEN           120   /* Max. length of a path                   */
  200. #define MAX_DRIVES         26   /* Maximum number of drives on system;     *
  201.                                  * for MS-DOS, A through Z.  Used by       *
  202.                                  * Save_Dir()...                           */
  203.  
  204. #define INTBIT_C        0x0001  /* Carry */
  205. #define INTBIT_P        0x0004  /* Parity */
  206. #define INTBIT_AUX      0x0010  /* Aux carry */
  207. #define INTBIT_Z        0x0040  /* Zero flag */
  208. #define INTBIT_SIG      0x0080  /* Sign flag */
  209. #define INTBIT_TRC      0x0100  /* Trace flag */
  210. #define INTBIT_INT      0x0200  /* Interrupt flag */
  211. #define INTBIT_D        0x0400  /* Direction flag */
  212. #define INTBIT_OVF      0x0800  /* Overflow flag */
  213.  
  214. #define ZONE_ALL  56685u
  215. #define NET_ALL   56685u
  216. #define NODE_ALL  56685u
  217. #define POINT_ALL 56685u
  218.  
  219.  
  220. #define THIS_YEAR "1991"
  221. #define Hello(prog,desc,version,year) printf("\n" prog "  " desc ", Version %s.\nCopyright " year " by Scott J. Dudley of 1:249/106.  All rights reserved.\n\n",version)
  222. #define shopen(path,access)   sopen(path,access,SH_DENYNONE,S_IREAD | S_IWRITE)
  223. #define GTdate(s1, s2) (GEdate(s1, s2) && (s1)->ldate != (s2)->ldate)
  224. #define carrier_flag          (prm.carrier_mask)
  225. #define BitOff(a,x)           ((void)((a)[(x)/CHAR_BITS] &= ~(1 << ((x) % CHAR_BITS))))
  226. #define BitOn(a,x)            ((void)((a)[(x)/CHAR_BITS] |= (1 << ((x) % CHAR_BITS))))
  227. #define IsBit(a,x)            ((a)[(x)/CHAR_BITS] & (1 << ((x) % CHAR_BITS)))
  228.  
  229. #define lputs(handle,string)  write(handle,string,strlen(string))
  230.  
  231. #define dim(a)                (sizeof(a)/sizeof(a[0]))
  232. #define eqstr(str1,str2)      (strcmp(str1,str2)==0)
  233. #define eqstri(str1,str2)     (stricmp(str1,str2)==0)
  234. #define eqstrn(str1,str2,n)   (strncmp(str1,str2,n)==0)
  235. #define eqstrni(str1,str2,n)  (strnicmp(str1,str2,n)==0)
  236. #define eqstrin(str1,str2,n)  eqstrni(str1,str2,n)
  237. #define divby(num,div)        ((num % div)==0)
  238. #define f_tolwr(c)            (_to_lwr[c])
  239. #define f_toupr(c)            (_to_upr[c])
  240.  
  241. /* Macro to propercase MS-DOS filenames.  If your OS is case-dependent,     *
  242.  * use "#define fancy_fn(s) (s)" instead.  Ditto for upper_fn().            */
  243.  
  244. #define fancy_fn(s)           fancy_str(s)
  245. #define upper_fn(s)           strupr(s)
  246.  
  247. #ifndef updcrc
  248. #define updcrc(cp, crc)       (crctab[((crc >> 8) & 255) ^ cp] ^ (crc << 8))
  249. #endif
  250.  
  251.  
  252. #ifndef max
  253. #define max(a,b)              (((a) > (b)) ? (a) : (b))
  254. #define min(a,b)              (((a) < (b)) ? (a) : (b))
  255. #endif
  256.  
  257.  
  258. /* Don't change this struct!  The code in win_pick.c and max_locl.c relies  *
  259.  * on it as being the same as PLIST...                                      */
  260.  
  261. struct __priv
  262. {
  263.   char *name;
  264.   int priv;
  265. };
  266.  
  267.  
  268.  
  269. extern char _stdc months[][10];
  270. extern char _stdc weekday[][10];
  271.  
  272. extern char _stdc months_ab[][4];
  273. extern char _stdc weekday_ab[][4];
  274.  
  275. extern struct __priv _stdc _privs[];
  276.  
  277.  
  278. #include "progprot.h"
  279.  
  280.  
  281. #ifndef NO_STRFTIME
  282.   /* If compiler doesn't include a strftime(), use our own */
  283.  
  284.   #include <time.h>
  285.   #include <sys/types.h>
  286.  
  287.   size_t _stdc strftime(char *,size_t,const char *,const struct tm *);
  288. #endif
  289.  
  290.  
  291. #ifndef NO_MKTIME
  292.   /* If compiler doesn't include a mktime(), use our own */
  293.  
  294.   #include <time.h>
  295.   #include <sys/types.h>
  296.  
  297.   time_t _stdc mktime(struct tm * tm_ptr);
  298. #endif
  299.  
  300. /* MS docs use both SH_DENYNONE and SH_DENYNO */
  301.  
  302. #if !defined(SH_DENYNONE) && defined(SH_DENYNO)
  303.   #define SH_DENYNONE SH_DENYNO
  304. #endif
  305.  
  306. #endif /* __PROG_H_DEFINED */
  307.  
  308.