home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991 */
- /* By MicroSim Corporation, All Rights Reserved */
- /****************************************************************************/
- /* mslib.h
- * $Revision: 1.86 $
- * $Author: gtr $
- * $Date: 22 Apr 1991 11:33:40 $ */
-
- /******************* USERS OF DEVICE EQUATIONS OPTION ***********************/
- /******** Do not change this file **********/
-
- /* MSLIB.H */
-
- #include "cpudefs.h"
- #include "demo.h"
- #include "version.h"
-
- #if CTYPE & WINDOWS
-
- #define GETMEM(a) new char[a]
- #define FREEMEM(a) delete (a)
-
- #else
-
- /* set Microsoft pointer types */
- #if CTYPE & (OS2 | D16)
- #define USE_HUGE
- #endif
-
- #ifdef USE_HUGE /* use huge versions */
- #define GETMEM(a) GetHugeMem((unsigned long)(a))
- #define FREEMEM(a) freehugemem((char huge *)(a))
- #else
- #define GETMEM(a) GetMem((unsigned int)(a))
- #define FREEMEM(a) FreeMem(a)
- #endif
-
- #endif
-
- #ifdef USE_HUGE
- #define HGE huge /* "HGE" since "HUGE" is an ANSI item */
- #else
- #define HGE
- #endif
-
- /* set use of function declaration arguments */
-
- #if CTYPE & (PC | APOLLO | VAX | PMAX | WINDOWS)
- #define USE_DECL_ARGS
- #else
- #ifdef USE_DECL_ARGS
- #undef USE_DECL_ARGS
- #endif
- #endif
-
- /* ascii special character definitions */
-
- #define TAB '\t'
- #define CTRL_C '\003'
- #define BELL '\007'
- #define BS '\010'
- #define LF '\012'
- #define FF '\014'
- #define CR '\015'
- #define ESC '\033'
- #define ST '\234'
- #define GS '\035'
- #define US '\037'
- #define DEL '\177'
- #define EOS '\0'
-
- /* useful symbol definitions */
-
- #define YES 1
- #define ON 1
- #define NO 0
- #define OFF 0
-
- #define MAXEXP 30
- #define MAXREAL 1e30
- #define MINREAL 1e-30
-
- /* limiting functions. EXP() not only prevents overflow, but also avoids
- denormalize exceptions which the 287 does not handle correctly */
-
- #define EXP(a) Expn(a) /*( (a < -50.) ? 0.0 : exp(MIN(a,50.)) )*/
- #define LOG(a) Ln(a) /*(a < 1.928752e-22) ? -50. : log(a) )*/
-
- /* Format types for FmtFlt() */
-
- #define FMTE 0
- #define FMTF 1
- #define FMTS 2
- #define FMTSF 3
- #define FMTT 4
- #define FMTTF 5
- #define FMTU 6
- #define FMTUF 7
- #define FMTEP 8
- #define FMTN 9
- #define FMTNF 10
-
- #define BATCH 2
- #define INTERACTIVE 3
-
- #define NEC_NRM_ATTRIB 0xe1 /* normal video with white text */
- #define NEC_REV_ATTRIB 0xe5 /* reverse video with white text */
-
- /* Standard string lengths */
-
- #define MBUFF 133
-
- #ifndef NO_TYPEDEFS /* for MAC precompiled .h files */
-
- /* for ReadOpt() options' structure */
-
- /* note, `present' field is last so don't bother initializing */
- struct oneopt {
- char *name; /* eg. "Wp" */
- int nargs; /* # args expected */
- char **args; /* must be space for `nargs' pointers */
- int present; /* 1 if seen, 0 otherwise */
- };
-
- /* complex typedef (more understandable components than the one in UNIX) */
-
- typedef struct {
- double re, im;
- } _complex;
- #endif
-
- /* Macro definitions */
-
- #define MAX(A,B) ((A) > (B) ? (A) : (B))
- #define MIN(A,B) ((A) < (B) ? (A) : (B))
- #define ABS(A) ((A) >= 0 ? (A) :-(A))
- #define NINT(A) ((int)(floor((A)+.5))) /* Nearest integer for A >= 0.0*/
-
- /*
- * These two macros set and clear the nth bit of the given value
- */
- #define SetBit( v_p, n ) ( (*v_p) |= ( (unsigned long)1 << n ))
- #define ClearBit( v_p,n ) ( (*v_p) &= ~( (unsigned long)1 << n ))
-
- #if CTYPE & MWIN
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <time.h>
- #include <ctype.h>
-
- #endif
- #if CTYPE & PC
- #include "stdio.h"
- #include "stdlib.h"
- #include "string.h"
- #include "math.h"
- #include "time.h"
- #include "conio.h"
- #include "ctype.h"
- #include "memory.h"
- #include "dos.h"
- #endif
- #if CTYPE & D16
- #include "dos16.h"
- #include "vmuser.h"
- #endif
- #if CTYPE & VAX
- #include stdio
- #include stdlib
- #include math
- #include time
- #include curses
- #include ctype
- #include descrip
- /*#include memory*/
- #endif
- #if CTYPE & SUN
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include "sunctype.h"
- #include <malloc.h>
- #include <memory.h>
- /* would like to include time.h but window_hs.h includes sys/time.h */
- #endif
- #if CTYPE & PMAX
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <time.h>
- #include <ctype.h>
- #include <malloc.h>
- #include <memory.h>
- #endif
- #if CTYPE & XWIN & UNIX
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #endif
- #if CTYPE & VAX
- #undef UNIX
- /* These files use "#ifdef UNIX" which should never evaluate to true on VAX */
- #include <decw$include/Xlib.h>
- #include <decw$include/Xutil.h>
- #include <decw$include/Xatom.h>
- #define UNIX (SUN | APOLLO | PMAX) /* ... ?case sensitive input */
- #endif
- #if CTYPE & APOLLO
- #include <apollo/builtins.h>
- #include <stdio.h>
- #include <strings.h>
- #include <math.h>
- #include <time.h>
- #include <ctype.h>
- #undef toupper
- #define toupper(c) (islower(c) ? (c)-'a'+'A' : (c))
- #undef tolower
- #define tolower(c) (isupper(c) ? (c)-'A'+'a' : (c))
- #include <memory.h> /* so we can proto memset() */
- #include <sys/types.h>
- #include <sys/stat.h> /* so we can proto stat() */
- #endif
-
- /*
- * These symbols from the Microsoft definitions and are repeated here
- * for other compilers
- */
- #if CTYPE & ~APOLLO
- #ifndef THINK_C
- #define SEEK_SET 0
- #define SEEK_CUR 1
- #define SEEK_END 2
- #endif
- #endif
-
- #define EXIT exit
-
- /*
- * This definition assures that global variables are defined in
- * main and declared everywhere else
- */
- #ifdef Main_Pgm
- #if CTYPE & VAX
- #define GLOBAL globaldef
- #else
- #define GLOBAL
- #endif
- #else
- #if CTYPE & VAX
- #define GLOBAL globalref
- #else
- #define GLOBAL extern
- #endif
- #endif
-
- /* Global variable for FmtFlt routine replacement character. If set to other
- than 0, it contains the character that will replace the least non-zero
- digit of every formatted floating point number. */
- GLOBAL char Fmt_rplc_char;
-
- #define USEARG(a) a++;a--;
-
- #if CTYPE & ( PC | MWIN )
- #define DELETE_FILE(f) remove(f)
- #endif
- #if CTYPE & VAX
- #define DELETE_FILE(f) vxdltfl(f)
- #endif
- #if CTYPE & ( MAC | UNIX )
- #define DELETE_FILE(f) unlink(f)
- #endif
-
- /* include these here because they might need GLOBAL etc */
-
- #if CTYPE & MAC
- #include "mac.h"
- #endif
-
- #if CTYPE & ( PC | MWIN )
- #define sysint(i,in,out) int86(i,in,out)
- #endif
-
- #if CTYPE & ( PC_DOS | PC_D16 )
- #ifdef Main_Pgm
- unsigned short
- BIOS_DATA = 0x0040, /* these values will be reset for DOS/16M */
- VID_xA000 = 0xA000,
- VID_xA800 = 0xA800,
- VID_xB000 = 0xB000,
- VID_xB800 = 0xB800;
- #else
- extern unsigned short
- BIOS_DATA,
- VID_xA000,
- VID_xA800,
- VID_xB000,
- VID_xB800;
- #endif
- #define FAR_PTR(paragraph,offset) \
- ( (void *)( (long)(paragraph)<<16 | (unsigned)(offset) ) )
- #endif
-
- #if CTYPE & APOLLO
- #include "msapollo.h"
- #endif
-
- #if CTYPE & ( VAX | UNIX | NEC_DOS | NEC_D16 )
- GLOBAL int cursor_col;
- GLOBAL int cursor_row;
- #endif
-
- #if CTYPE & ( VAX | UNIX | APOLLO )
- GLOBAL int ResizeOK;
- #endif
-
- #if CTYPE & VAX
- GLOBAL int DISPLAY_TYPE;
- GLOBAL int VAXKbChan ; /* Assigned in InitVAXKb */
- GLOBAL int VAXSMGKeyboard; /* Assigned in InitVAXKb */
- GLOBAL int VAXAutoRefresh ; /* Causes refresh()ing in DsxxVd */
- #endif
-
- #if CTYPE & NEC
- GLOBAL unsigned int textbase_nec; /* beginning of text display memory */
- #endif
-
- #if CTYPE & ( PC | MWIN )
- #define OPEN_RB "rb" /* read binary */
- #ifndef DIOCHK
- #define OPEN_RT "rb" /* read text NOTE: b not t for control-z bug */
- #else
- #define OPEN_RT "rt" /* read text for DIOCHK.C only */
- #endif
- #define OPEN_WB "wb" /* write binary */
- #define OPEN_WT "wt" /* write text */
- #define OPEN_AB "ab" /* append binary */
- #define OPEN_AT "at" /* append text */
- #define OPEN_RWB "r+b" /* write/read binary (fails if file not exist) */
- #define OPEN_WRB "w+b" /* write/read binary */
- #define OPEN_WRT "w+t" /* write/read text */
- #endif
-
- #if CTYPE & ( MAC | UNIX )
- #define OPEN_RB "r" /* read binary */
- #define OPEN_RT "r" /* read text */
- #define OPEN_WB "w" /* write binary */
- #define OPEN_WT "w" /* write text */
- #define OPEN_AB "a" /* append binary */
- #define OPEN_AT "a" /* append text */
- #define OPEN_RWB "r+" /* write/read binary */
- #define OPEN_WRB "w+" /* write/read binary */
- #define OPEN_WRT "w+" /* write/read text */
- #endif
-
- #if CTYPE & VAX
- #define OPEN_RB "r" /* read binary */
- #define OPEN_RT "r" /* read text */
- #define OPEN_WB "w" /* write binary */
- #define OPEN_WT "w","rfm=var","rat=cr" /* write text */
- #define OPEN_AB "a" /* append binary */
- #define OPEN_AT "a","rfm=var","rat=cr" /* append text */
- #define OPEN_RWB "r+" /* write/read binary */
- #define OPEN_WRB "w+" /* write/read binary */
- #define OPEN_WRT "w+" /* write/read text */
- #endif
-
- #if CTYPE & ~VAX
- #define EXE_PATH_ENV "PATH"
- #else
- #define EXE_PATH_ENV "PSPICE_EXE"
- #endif
-
- /* auto-update (marching waveforms) flag */
- #if CTYPE & (OS2 | PMAX)
- #define AUTOUPDATE
- #endif
-
- /* signed characters */
- #if CTYPE & (MAC | VAX)
- #define SIGNED
- #else
- #define SIGNED signed
- #endif
-
- /* debugging */
- #if CTYPE & PC
- /*#define DEBUGGER_ENABLED*/
- #ifdef DEBUGGER_ENABLED
- #undef printf
- #define printf DebugPrintf
- #define WHERE DebugPrintf("\n(File %-12s; Line %d)",__FILE__,__LINE__);
- int DebugPrintf(char *, ...);
- extern int DebugEnabled; /* YES: write to file, NO: return immediately */
- extern int DebugAppend; /* YES: reopen file each call; NO: just write */
- #endif /* DEBUGGER_ENABLED */
- #endif /* CTYPE & DOS */
-
- #if __cplusplus
- extern "C" {
- #endif
-
- /* function declarations */
-
- #ifdef USE_DECL_ARGS
- /* BELL.C */
- void Bell(void);
- /* CLRSCR.C */
- void ClrScr(void );
- #if CTYPE & D16
- int SetLowMemSelectors(void);
- #endif
- /* CMATH */
- _complex cadd(_complex ,_complex );
- _complex cadi(_complex ,_complex );
- _complex csub(_complex ,_complex );
- _complex cmul(_complex ,_complex );
- /* DELIM.C */
- int Delim(char *,char *,char * *);
- /* DSNMVD.C */
- void DsNmVd(char *,int);
- /* DSRVVD.C */
- void DsRvVd(char *,int,int);
- /* FILATR.C */
- int FilAtr(char *,char *,char *,long *,char *,char *);
- /* FILESIZE.C */
- long FileSize(char *,char *);
- FILE *fopenEnv(char *, char *, char *, char *, int);
- long FindFileSize(char *, char *, char *, int);
- /* FMTDSK.C */
- void FmtDsk(int ,int (*)[2]);
- /* FMTFLT.C */
- char *FmtFlt(double,int,int);
- /* GETMSG.C */
- char *GetMsg(char *);
- int InitMsg(char *);
- int TermMsg(void);
- /* IPC.C */
- int CreateSemaphore(char *);
- int OpenSemaphore(char *);
- int ClearSemaphore(void);
- int RequestSemaphore(long);
- /* MSSTRREV.C */
- void MSstrrev( char * );
- /* POSCRS.C */
- void PosCrs(int ,int );
- /* PTRTOABS.C */
- long ptrtoabs(char *);
- /* READOPT.C */
- int ReadOpt(int *,char * *,int ,struct oneopt *);
- /* SCRLDS.C */
- void ScrlDs(int );
- /* INT13.ASM */
- char INT13(unsigned int, unsigned int, unsigned int, char *);
- /* SAFEMATH.C */
- double Expn(double);
- double Exp2(double,double);
- double Ln(double);
- /* SQZBLN.C */
- void SqzBln(char *);
- void SqzWSp(char *);
- /* STRBLN.C */
- void StrBln(char *);
- /* STRDIFF.C */
- int strdiff(char *,char *);
- int strdiff2(char *,char *);
- /* STRUCMP.C */
- int StrUCmp(char *,char *);
- /* STRUNCMP.C */
- int StrUNCmp(char *,char *,int );
- /* STRUP.C */
- void Strup(char *);
- /* STRZERO.C*/
- void StrZero( char * );
- /* TELLUSER.C */
- void wflush(void);
- void TellUser( char * );
- #if CTYPE & MWIN
- int printf(char* format, ... );
- #endif
- /* TIMEDIFF.C */
- #if CTYPE & PC
- int MsTimeDiff(struct timeb *, struct timeb *);
- #else
- int MsTimeDiff(struct timeval *, struct timeval *);
- #endif
-
- /* WAITSEC.C */
- double WaitSec(double );
- #if CTYPE & ( NEC_DOS | NEC_D16 )
- /* MISCNEC.ASM */
- void CLRSCR_NEC(unsigned int);
- void DSPTXT_NEC(char *, int, int, int, unsigned int);
- void CRTIO_NEC(char *, int, unsigned int);
- void MOVDSP_NEC(int, unsigned int);
- void CRSON_NEC(void);
- int WHICHDOS_NEC(void);
- #endif
-
- #if CTYPE & UNIX
- void DrwBdr(int, int, int, int, int);
- #endif
-
- #if CTYPE & VAX
- /* MISCVX.C */
- void vxdltfl(char *);
- int getlog(char *, char *);
- int kbhit();
- int getchVAX();
- #define getch() getchVAX()
- void InitVAXKb();
- void EndVAXKb();
- long GetVAXType();
- /* GETTIME.C */
- double GetTime();
- #endif
-
- #else /* not USE_DECL_ARGS */
-
- void Bell();
- void ClrScr();
- _complex cadd();
- _complex cadi();
- _complex csub();
- _complex cmul();
- int Delim();
- void DsNmVd();
- void DsRvVd();
- long FileSize();
- FILE *fopenEnv();
- char *FmtFlt();
- int CreateSemaphore();
- int OpenSemaphore();
- int ClearSemaphore();
- int RequestSemaphore();
- char *GetMsg();
- int InitMsg();
- int TermMsg();
- void MSstrrev();
- void PosCrs();
- int ReadOpt();
- void ScrlDs();
- void SqzBln();
- void SqzWSp();
- void StrBln();
- double Expn();
- double Exp2();
- double Ln();
- int strdiff();
- int strdiff2();
- int StrUCmp();
- int StrUNCmp();
- void Strup();
- void TellUser();
- int MSTimeDiff();
- double WaitSec();
- void wflush();
- /* STRZERO.C*/
- void StrZero();
-
- #endif /* not USE_DECL_ARGS */
-
- #if __cplusplus
- }
- #endif
-
-