home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / SQDEV200.ZIP / H / PROG.H < prev    next >
C/C++ Source or Header  |  1994-05-23  |  11KB  |  361 lines

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