home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p064 / 3.ddi / MSLIB.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-01  |  13.0 KB  |  570 lines

  1. /****************************************************************************/
  2. /*        Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991                  */
  3. /*          By MicroSim Corporation, All Rights Reserved                    */
  4. /****************************************************************************/
  5. /* mslib.h
  6.  *   $Revision:   1.86  $
  7.  *   $Author:   gtr  $
  8.  *   $Date:   22 Apr 1991 11:33:40  $ */
  9.  
  10. /******************* USERS OF DEVICE EQUATIONS OPTION ***********************/
  11. /********         Do not change this file           **********/
  12.  
  13. /* MSLIB.H */
  14.  
  15. #include "cpudefs.h"
  16. #include "demo.h"
  17. #include "version.h"
  18.  
  19. #if CTYPE & WINDOWS
  20.  
  21. #define GETMEM(a) new char[a]
  22. #define FREEMEM(a) delete (a)
  23.  
  24. #else
  25.  
  26. /* set Microsoft pointer types */
  27. #if CTYPE & (OS2 | D16)
  28. #define USE_HUGE
  29. #endif
  30.  
  31. #ifdef    USE_HUGE        /* use huge versions */
  32. #define    GETMEM(a)    GetHugeMem((unsigned long)(a))
  33. #define    FREEMEM(a)    freehugemem((char huge *)(a))
  34. #else
  35. #define    GETMEM(a)    GetMem((unsigned int)(a))
  36. #define    FREEMEM(a)    FreeMem(a)
  37. #endif
  38.  
  39. #endif
  40.  
  41. #ifdef    USE_HUGE
  42. #define    HGE    huge        /* "HGE" since "HUGE" is an ANSI item */
  43. #else
  44. #define    HGE
  45. #endif
  46.  
  47. /* set use of function declaration arguments */
  48.  
  49. #if CTYPE & (PC | APOLLO | VAX | PMAX | WINDOWS)
  50. #define  USE_DECL_ARGS
  51. #else
  52. #ifdef    USE_DECL_ARGS
  53. #undef    USE_DECL_ARGS
  54. #endif
  55. #endif
  56.  
  57. /* ascii special character definitions    */
  58.  
  59. #define TAB        '\t'
  60. #define CTRL_C        '\003'
  61. #define BELL        '\007'
  62. #define BS        '\010'
  63. #define LF        '\012'
  64. #define FF        '\014'
  65. #define CR        '\015'
  66. #define ESC        '\033'
  67. #define ST        '\234'
  68. #define GS        '\035'
  69. #define US        '\037'
  70. #define DEL        '\177'
  71. #define EOS        '\0'
  72.  
  73. /* useful symbol definitions */
  74.  
  75. #define YES 1
  76. #define  ON 1
  77. #define  NO 0
  78. #define OFF 0
  79.  
  80. #define MAXEXP    30
  81. #define MAXREAL 1e30
  82. #define MINREAL 1e-30
  83.  
  84. /* limiting functions.  EXP() not only prevents overflow, but also avoids
  85.    denormalize exceptions which the 287 does not handle correctly */
  86.  
  87. #define EXP(a) Expn(a)        /*( (a < -50.) ? 0.0 : exp(MIN(a,50.)) )*/
  88. #define LOG(a) Ln(a)        /*(a < 1.928752e-22) ? -50. : log(a) )*/
  89.  
  90. /* Format types for FmtFlt() */
  91.  
  92. #define FMTE    0
  93. #define FMTF    1
  94. #define FMTS    2
  95. #define FMTSF    3
  96. #define FMTT    4
  97. #define FMTTF    5
  98. #define FMTU    6
  99. #define FMTUF    7
  100. #define FMTEP    8
  101. #define FMTN    9
  102. #define FMTNF    10
  103.  
  104. #define BATCH        2
  105. #define INTERACTIVE    3
  106.  
  107. #define NEC_NRM_ATTRIB    0xe1    /* normal video with white text */
  108. #define NEC_REV_ATTRIB    0xe5    /* reverse video with white text */
  109.  
  110. /* Standard string lengths */
  111.  
  112. #define MBUFF    133
  113.  
  114. #ifndef NO_TYPEDEFS    /* for MAC precompiled .h files */
  115.  
  116. /* for ReadOpt() options' structure */
  117.  
  118. /* note, `present' field is last so don't bother initializing */
  119. struct oneopt {
  120.   char *name;    /* eg. "Wp" */
  121.   int nargs;    /* # args expected */
  122.   char **args;    /* must be space for `nargs' pointers */
  123.   int present;    /* 1 if seen, 0 otherwise */
  124.   };
  125.  
  126. /* complex typedef (more understandable components than the one in UNIX) */
  127.  
  128. typedef struct {
  129.   double re, im;
  130.   } _complex;
  131. #endif
  132.  
  133. /* Macro definitions */
  134.  
  135. #define MAX(A,B)    ((A) > (B) ? (A) : (B))
  136. #define MIN(A,B)    ((A) < (B) ? (A) : (B))
  137. #define ABS(A)        ((A) >= 0  ? (A) :-(A))
  138. #define NINT(A) ((int)(floor((A)+.5)))    /* Nearest integer for A >= 0.0*/
  139.  
  140. /*
  141.  * These two macros set and clear the nth bit of the given value
  142.  */
  143. #define SetBit( v_p,  n ) ( (*v_p) |= ( (unsigned long)1 << n ))
  144. #define ClearBit( v_p,n ) ( (*v_p) &= ~( (unsigned long)1 << n ))
  145.  
  146. #if CTYPE & MWIN
  147.  
  148. #include <stdio.h>
  149. #include <stdlib.h>
  150. #include <string.h>
  151. #include <math.h>
  152. #include <time.h>
  153. #include <ctype.h>
  154.  
  155. #endif
  156. #if CTYPE & PC
  157. #include "stdio.h"
  158. #include "stdlib.h"
  159. #include "string.h"
  160. #include "math.h"
  161. #include "time.h"
  162. #include "conio.h"
  163. #include "ctype.h"
  164. #include "memory.h"
  165. #include "dos.h"
  166. #endif
  167. #if CTYPE & D16
  168. #include "dos16.h"
  169. #include "vmuser.h"
  170. #endif
  171. #if CTYPE & VAX
  172. #include stdio
  173. #include stdlib
  174. #include math
  175. #include time
  176. #include curses
  177. #include ctype
  178. #include descrip
  179. /*#include memory*/
  180. #endif
  181. #if CTYPE & SUN
  182. #include <stdio.h>
  183. #include <string.h>
  184. #include <math.h>
  185. #include "sunctype.h"
  186. #include <malloc.h>
  187. #include <memory.h>
  188. /* would like to include time.h but window_hs.h includes sys/time.h */
  189. #endif
  190. #if CTYPE & PMAX
  191. #include <stdio.h>
  192. #include <string.h>
  193. #include <math.h>
  194. #include <time.h>
  195. #include <ctype.h>
  196. #include <malloc.h>
  197. #include <memory.h>
  198. #endif
  199. #if CTYPE & XWIN & UNIX
  200. #include <X11/Xlib.h>
  201. #include <X11/Xutil.h>
  202. #endif
  203. #if CTYPE & VAX
  204. #undef UNIX
  205.   /* These files use "#ifdef UNIX" which should never evaluate to true on VAX */
  206. #include <decw$include/Xlib.h>
  207. #include <decw$include/Xutil.h>
  208. #include <decw$include/Xatom.h>
  209. #define UNIX    (SUN    | APOLLO  | PMAX)    /* ... ?case sensitive input */
  210. #endif
  211. #if CTYPE & APOLLO
  212. #include <apollo/builtins.h>
  213. #include <stdio.h>
  214. #include <strings.h>
  215. #include <math.h>
  216. #include <time.h>
  217. #include <ctype.h>
  218. #undef toupper
  219. #define toupper(c)    (islower(c) ? (c)-'a'+'A' : (c))
  220. #undef tolower
  221. #define tolower(c)    (isupper(c) ? (c)-'A'+'a' : (c))
  222. #include <memory.h>  /* so we can proto memset() */
  223. #include <sys/types.h>
  224. #include <sys/stat.h>    /* so we can proto stat() */
  225. #endif
  226.  
  227. /*
  228.  * These symbols from the Microsoft definitions and are repeated here
  229.  *   for other compilers
  230.  */
  231. #if CTYPE & ~APOLLO
  232. #ifndef    THINK_C
  233. #define SEEK_SET    0
  234. #define SEEK_CUR    1
  235. #define SEEK_END    2
  236. #endif
  237. #endif
  238.  
  239. #define EXIT    exit
  240.  
  241. /*
  242.  * This definition assures that global variables are defined in
  243.  *   main and declared everywhere else
  244.  */
  245. #ifdef Main_Pgm
  246. #if CTYPE & VAX
  247. #define GLOBAL    globaldef
  248. #else
  249. #define GLOBAL
  250. #endif
  251. #else
  252. #if CTYPE & VAX
  253. #define GLOBAL    globalref
  254. #else
  255. #define GLOBAL    extern
  256. #endif
  257. #endif
  258.  
  259. /* Global variable for FmtFlt routine replacement character.  If set to other
  260.    than 0, it contains the character that will replace the least non-zero
  261.    digit of every formatted floating point number. */
  262. GLOBAL char Fmt_rplc_char;
  263.  
  264. #define USEARG(a)    a++;a--;
  265.  
  266. #if CTYPE & ( PC | MWIN )
  267. #define DELETE_FILE(f)    remove(f)
  268. #endif
  269. #if CTYPE & VAX
  270. #define DELETE_FILE(f)    vxdltfl(f)
  271. #endif
  272. #if CTYPE & ( MAC | UNIX )
  273. #define DELETE_FILE(f)    unlink(f)
  274. #endif
  275.  
  276. /* include these here because they might need GLOBAL etc */
  277.  
  278. #if CTYPE & MAC
  279. #include "mac.h"
  280. #endif
  281.  
  282. #if CTYPE & ( PC | MWIN )
  283. #define sysint(i,in,out)    int86(i,in,out)
  284. #endif
  285.  
  286. #if CTYPE & ( PC_DOS | PC_D16 )
  287. #ifdef Main_Pgm
  288. unsigned short
  289.   BIOS_DATA = 0x0040,        /* these values will be reset for DOS/16M */
  290.   VID_xA000 = 0xA000,
  291.   VID_xA800 = 0xA800,
  292.   VID_xB000 = 0xB000,
  293.   VID_xB800 = 0xB800;
  294. #else
  295. extern unsigned short
  296.   BIOS_DATA,
  297.   VID_xA000,
  298.   VID_xA800,
  299.   VID_xB000,
  300.   VID_xB800;
  301. #endif
  302. #define FAR_PTR(paragraph,offset)    \
  303.     ( (void *)( (long)(paragraph)<<16 | (unsigned)(offset) ) )
  304. #endif
  305.  
  306. #if CTYPE & APOLLO
  307. #include "msapollo.h"
  308. #endif
  309.  
  310. #if CTYPE & ( VAX | UNIX | NEC_DOS | NEC_D16 )
  311. GLOBAL    int        cursor_col;
  312. GLOBAL    int        cursor_row;
  313. #endif
  314.  
  315. #if CTYPE & ( VAX | UNIX | APOLLO )
  316. GLOBAL    int        ResizeOK;
  317. #endif
  318.  
  319. #if CTYPE & VAX
  320. GLOBAL    int        DISPLAY_TYPE;
  321. GLOBAL    int        VAXKbChan ;       /* Assigned in InitVAXKb */
  322. GLOBAL  int        VAXSMGKeyboard;   /* Assigned in InitVAXKb */
  323. GLOBAL  int        VAXAutoRefresh ;  /* Causes refresh()ing in DsxxVd */
  324. #endif
  325.  
  326. #if CTYPE & NEC
  327. GLOBAL    unsigned int    textbase_nec;    /* beginning of text display memory */
  328. #endif
  329.  
  330. #if CTYPE & ( PC | MWIN )
  331. #define OPEN_RB         "rb"    /* read binary */
  332. #ifndef DIOCHK
  333. #define OPEN_RT         "rb"    /* read text NOTE: b not t for  control-z bug */
  334. #else
  335. #define OPEN_RT         "rt"    /* read text for DIOCHK.C only */
  336. #endif
  337. #define OPEN_WB         "wb"    /* write binary */
  338. #define OPEN_WT         "wt"    /* write text */
  339. #define OPEN_AB         "ab"    /* append binary */
  340. #define OPEN_AT         "at"    /* append text */
  341. #define OPEN_RWB        "r+b"    /* write/read binary (fails if file not exist) */
  342. #define OPEN_WRB        "w+b"    /* write/read binary */
  343. #define OPEN_WRT        "w+t"    /* write/read text */
  344. #endif
  345.  
  346. #if CTYPE & ( MAC | UNIX )
  347. #define OPEN_RB         "r"    /* read binary */
  348. #define OPEN_RT         "r"    /* read text */
  349. #define OPEN_WB         "w"    /* write binary */
  350. #define OPEN_WT         "w"    /* write text */
  351. #define OPEN_AB         "a"    /* append binary */
  352. #define OPEN_AT         "a"    /* append text */
  353. #define OPEN_RWB        "r+"    /* write/read binary */
  354. #define OPEN_WRB        "w+"    /* write/read binary */
  355. #define OPEN_WRT        "w+"    /* write/read text */
  356. #endif
  357.  
  358. #if CTYPE & VAX
  359. #define OPEN_RB         "r"             /* read binary */
  360. #define OPEN_RT         "r"             /* read text */
  361. #define OPEN_WB         "w"             /* write binary */
  362. #define OPEN_WT         "w","rfm=var","rat=cr"     /* write text */
  363. #define OPEN_AB         "a"             /* append binary */
  364. #define OPEN_AT         "a","rfm=var","rat=cr"     /* append text */
  365. #define OPEN_RWB        "r+"             /* write/read binary */
  366. #define OPEN_WRB        "w+"             /* write/read binary */
  367. #define OPEN_WRT        "w+"             /* write/read text */
  368. #endif
  369.  
  370. #if CTYPE & ~VAX
  371. #define EXE_PATH_ENV "PATH"
  372. #else
  373. #define EXE_PATH_ENV "PSPICE_EXE"
  374. #endif
  375.  
  376. /* auto-update (marching waveforms) flag */
  377. #if CTYPE & (OS2 | PMAX)
  378. #define AUTOUPDATE
  379. #endif
  380.  
  381.     /* signed characters */
  382. #if CTYPE & (MAC | VAX)
  383. #define    SIGNED
  384. #else
  385. #define    SIGNED    signed
  386. #endif
  387.  
  388.     /* debugging */
  389. #if CTYPE & PC
  390. /*#define    DEBUGGER_ENABLED*/
  391. #ifdef    DEBUGGER_ENABLED
  392. #undef    printf
  393. #define    printf    DebugPrintf
  394. #define    WHERE    DebugPrintf("\n(File %-12s; Line %d)",__FILE__,__LINE__);
  395. int    DebugPrintf(char *, ...);
  396. extern    int    DebugEnabled;    /* YES: write to file, NO: return immediately */
  397. extern    int    DebugAppend;    /* YES: reopen file each call; NO: just write */
  398. #endif    /* DEBUGGER_ENABLED */
  399. #endif    /* CTYPE & DOS */
  400.  
  401. #if __cplusplus
  402. extern "C" {
  403. #endif
  404.  
  405. /* function declarations */
  406.  
  407. #ifdef USE_DECL_ARGS
  408.     /* BELL.C */
  409. void Bell(void);
  410.     /* CLRSCR.C */
  411. void ClrScr(void );
  412. #if CTYPE & D16
  413. int SetLowMemSelectors(void);
  414. #endif
  415.     /* CMATH */
  416. _complex cadd(_complex ,_complex );
  417. _complex cadi(_complex ,_complex );
  418. _complex csub(_complex ,_complex );
  419. _complex cmul(_complex ,_complex );
  420.     /* DELIM.C */
  421. int Delim(char *,char *,char * *);
  422.     /* DSNMVD.C */
  423. void DsNmVd(char *,int);
  424.     /* DSRVVD.C */
  425. void DsRvVd(char *,int,int);
  426.     /* FILATR.C */
  427. int FilAtr(char *,char *,char *,long *,char *,char *);
  428.     /* FILESIZE.C */
  429. long FileSize(char *,char *);
  430. FILE *fopenEnv(char *, char *, char *, char *, int);
  431. long FindFileSize(char *, char *, char *, int);
  432.     /* FMTDSK.C */
  433. void FmtDsk(int ,int (*)[2]);
  434.     /* FMTFLT.C */
  435. char *FmtFlt(double,int,int);
  436.     /* GETMSG.C */
  437. char *GetMsg(char *);
  438. int  InitMsg(char *);
  439. int  TermMsg(void);
  440.     /* IPC.C */
  441. int  CreateSemaphore(char *);
  442. int  OpenSemaphore(char *);
  443. int  ClearSemaphore(void);
  444. int  RequestSemaphore(long);
  445.     /* MSSTRREV.C */
  446. void MSstrrev( char * );
  447.     /* POSCRS.C */
  448. void PosCrs(int ,int );
  449.     /* PTRTOABS.C */
  450. long ptrtoabs(char *);
  451.     /* READOPT.C */
  452. int  ReadOpt(int *,char * *,int ,struct oneopt *);
  453.     /* SCRLDS.C */
  454. void ScrlDs(int );
  455.     /* INT13.ASM */
  456. char INT13(unsigned int, unsigned int, unsigned int, char *);
  457.     /* SAFEMATH.C */
  458. double Expn(double);
  459. double Exp2(double,double);
  460. double Ln(double);
  461.     /* SQZBLN.C */
  462. void SqzBln(char *);
  463. void SqzWSp(char *);
  464.     /* STRBLN.C */
  465. void StrBln(char *);
  466.     /* STRDIFF.C */
  467. int strdiff(char *,char *);
  468. int strdiff2(char *,char *);
  469.     /* STRUCMP.C */
  470. int StrUCmp(char *,char *);
  471.     /* STRUNCMP.C */
  472. int StrUNCmp(char *,char *,int );
  473.     /* STRUP.C */
  474. void Strup(char *);
  475.     /* STRZERO.C*/
  476. void StrZero( char * );
  477.         /* TELLUSER.C */
  478. void wflush(void);
  479. void TellUser( char * );
  480. #if CTYPE & MWIN
  481. int  printf(char* format, ... );
  482. #endif
  483.         /* TIMEDIFF.C */
  484. #if CTYPE & PC
  485. int MsTimeDiff(struct timeb *, struct timeb *);
  486. #else
  487. int MsTimeDiff(struct timeval *, struct timeval *);
  488. #endif
  489.  
  490.     /* WAITSEC.C */
  491. double WaitSec(double );
  492. #if CTYPE & ( NEC_DOS | NEC_D16 )
  493.     /* MISCNEC.ASM */
  494. void CLRSCR_NEC(unsigned int);
  495. void DSPTXT_NEC(char *, int, int, int, unsigned int);
  496. void CRTIO_NEC(char *, int, unsigned int);
  497. void MOVDSP_NEC(int, unsigned int);
  498. void CRSON_NEC(void);
  499. int  WHICHDOS_NEC(void);
  500. #endif
  501.  
  502. #if CTYPE & UNIX
  503. void DrwBdr(int, int, int, int, int);
  504. #endif
  505.  
  506. #if CTYPE & VAX
  507.     /* MISCVX.C */
  508. void     vxdltfl(char *);
  509. int     getlog(char *, char *);
  510. int     kbhit();
  511. int     getchVAX();
  512. #define  getch() getchVAX()
  513. void     InitVAXKb();
  514. void     EndVAXKb();
  515. long     GetVAXType();
  516.         /* GETTIME.C */
  517. double   GetTime();
  518. #endif
  519.  
  520. #else /* not USE_DECL_ARGS */
  521.  
  522. void     Bell();
  523. void    ClrScr();
  524. _complex cadd();
  525. _complex cadi();
  526. _complex csub();
  527. _complex cmul();
  528. int    Delim();
  529. void    DsNmVd();
  530. void    DsRvVd();
  531. long    FileSize();
  532. FILE     *fopenEnv();
  533. char    *FmtFlt();
  534. int     CreateSemaphore();
  535. int     OpenSemaphore();
  536. int     ClearSemaphore();
  537. int     RequestSemaphore();
  538. char    *GetMsg();
  539. int     InitMsg();
  540. int     TermMsg();
  541. void     MSstrrev();
  542. void    PosCrs();
  543. int    ReadOpt();
  544. void    ScrlDs();
  545. void    SqzBln();
  546. void    SqzWSp();
  547. void    StrBln();
  548. double    Expn();
  549. double    Exp2();
  550. double    Ln();
  551. int    strdiff();
  552. int    strdiff2();
  553. int    StrUCmp();
  554. int    StrUNCmp();
  555. void    Strup();
  556. void    TellUser();
  557. int    MSTimeDiff();
  558. double    WaitSec();
  559. void    wflush();
  560.     /* STRZERO.C*/
  561. void     StrZero();
  562.  
  563. #endif /* not USE_DECL_ARGS */
  564.  
  565. #if __cplusplus
  566. }
  567. #endif
  568.  
  569.  
  570.