/* %Src=tu.h %Dir=\rltraynh/c/stuff/ %Date=94/01/18-8:30pm | | The var "TU_H" tells your programs that you have included this file | | NOTE: An important var is __UNIX__ if defined, then we do NOT print | C/R's to a file on fprintf and we LIMIT the amount of memory | | Note: MANY of the funcs here depend upon your MAIN file to have a | proc called Exunt (int Err_num) by which you will EXIT and | never return. They should do a exit(Err_num); close files, etc. +--------------------------------------------------------------------------*/ #ifndef TU_H #define TU_H 1 extern void Exunt (short Err_num, char *Msg); #define YES 1 #define NO 0 #define TRUE 1 #define FALSE 0 /*---- NOTE: On DOS machines there are TWO kinds of pointers FAR for ones */ /* whose address is possibly further than +/- 32K bytes away. */ /* We dummy these out for unix machines, for which ALL are far. */ /************************************************************************** | The CR and LF problem.... (carriage return 0x0D and line feed 0x0A) | | The following are flags for use with the Writeln_() funcs | | Usually dos: CR/LF (mode=2) & unix: lf only (mode = 0) | | CR-ONLY is usually for over-print or plotter stuff | arcane if not archaic. | | Note that functions in tf.c use these a lot */ | +--------------------------------------------------------------------------------*/ #define CRLF_MODE_NL_ONLY 0 #define CRLF_MODE_CR_ONLY 1 #define CRLF_MODE_CRLF 2 int GG_writeln_crlf_mode = CRLF_MODE_CRLF; /* set to DOS as std */ /* and its older form - still used here and there */ #define CRLF_MODE 1 /*********************************** | Which operating system??? +---------------------------------*/ #define BOS_OS 0 #define DOS_OS 1 #define UNIX_OS 2 #define VAX_OS 3 int GG_operating_system = DOS_OS; /* Take DOS as standard - see also osy.c */ /******************************************************** | TUBRO C -- specific compiler limitations | +----------------------------------------------------------*/ /* #define __TURBOC__ 1 **/ #ifdef __TURBOC__ /* You must change this for other C compilers on PC */ /* However, you "should" define it anyway */ #ifdef __UNIX__ #undef __UNIX__ #endif #define FAR_PTR (char far *) #define INT long int #define ATOI atol #define STRING_SIZE 133 #define STRING_LENGTH 133 #define STRING_SIZE_LESS_ONE 132 #define MAX_ELEMENTS 32000 char *SYS_NAME_ID = "NON-UNIX"; char *OS_NAME = "DOS"; short OS_designation = DOS_OS; #define INT long int /******************** UNIX ******************/ #else /*----------------------------------- UNIX ------------------------*/ #define __UNIX__ 1 #define FAR_PTR (char *) #define far #define INT int #define ATOI atoi #define STRING_SIZE 256 #define STRING_LENGTH 256 #define STRING_SIZE_LESS_ONE 255 #define MAX_ELEMENTS 320000 char *SYS_NAME_ID = "UNIX-SYS"; char *OS_NAME = "UNIX"; short OS_designation = UNIX_OS; #endif /******************************* END OF TURBO C and UNIX interworking *****/ FILE *Std_out, *Err_out; /* For routines that require sep file ptrs */ FILE *Std_in; /* Normally, these are JUST place-holders */ int GG_test_mode = 0; /* Use the -t or -T option for tracing */ #define SKIP_EOS(XS) while (*XS != '\0') XS++ /************************************************************************** | F I L E A C C E S S | ============ ================== | | FILE ACCESS - always tricky between systems (esp: "rb" or "wb" access on unix) | | The following #define's are used for the values for Access_mode: | | This is used to imply either ACCESS to a FILE or to a STRING | That is, a string that is READ_ONLY is alloc'd with a fixed size other | wise, we alloc it at STRING_SIZE (255 bytes on Unix, 133 on Dos). +--------------------------------------------------------------------------*/ #define READ_ACCESS_UNDEFINED 0 #define READ_ONLY_ACCESS 1 #define READ_WRITE_ACCESS 2 #define OK 1 #define NOT_OK 0 #define ERROR -1 #define EOF_FOUND -1 #define TRUE 1 #define FALSE 0 #define ERR_EMPTY_LIST -1 /*----------------------- Special ascii-control codes ------------------*/ #define FORM_FEED \014 char PERCENT_SIGN = '\045'; /* Stupid C can NOT represent '%' simply */ char PER_CENT_SIGN = '\045'; /* I tried \% but that just goes bonkers */ #define ESC_CHAR \033 char *GG_comment = NULL; char *GG_command_upper, *GG_command_lower; /* scratch strings for cmnds */ int Verbose = 0; /* Turned on, for full response reporting */ /* In "most" cases, stderr == stdout, so keep it off */ #ifdef DUPLICATED_ENV_VARS /*----------------------------------------------------------------------- | | The following is used to give all apps -- not just Init_app() | access to the argv[] and env[] arrays (well sort of)... | | Full access to the argc,argv stuff is usually pretty standard, | however, a pgm CAN access the results of SET command (either in | DOS or UNIX). The decl of main looks like this: | | int main (int argc, | char *argv[], | char *env[] ) <--- Most people don't even know this | exists and simply call with arc, argv[] | (The Garden of Hacker Delights) | | And of course the "standard" argv[] array is accessed in C's typically | sloppy manner: | | printf ("--- argc = %d\n", argc); | for (i=0; i <> %s ",MSG);\ BUG;\ } while (1==0) /* DO once */ #define SHOW_ERR_MSG fprintf (Err_out, "%s\n", GG_msg); #define SHOW_ERROR_MSG fprintf (Err_out, "%s\n", GG_msg); #define SHOW_MSG fprintf (Std_out, "%s\n", GG_msg); int GG_bug_count = 0; /* used with DEBUG; and BUG; macros */ int DEBUG_lines = 0; /* Used to paginate DEBUGING || TESTING output */ int Window_height = 12; char *GG_run_msg = NULL; /*-------- Function prototypes -------------------------------------------*/ extern void Init_tu (short argc, char *argv[]); char *Alloc_str (char *Xs); char *Alloc_256 (char *Caller, char *String_name); char *Alloc_str_error (char *Caller, char *Var_name, char *Out_buffer); void Alloc_error (char *Caller, char *Var_name, char *App_err_msg); void Abort_not_enough_memory (char *Msg, char *Var_name); void Abort_LL_exploded (char *Pgm, char *Caller); void Show_msg (char *Msg); short Check_for_numeric_appended_value (char *Xs); void Input ( char *Xd); char *Pos (char *Needle, char *Haystack ); int Quit (char *Xs); int Length (char *Xs); char *Subst (char *This, char *For_this, char *Xs); char *Subst_all (char *This, char *For_this, char *Xs); void Remove_all_white_space (char *Xs); void Trim (char *Xs); void Upper (char *Xs); #endif /* ifndef TU_H */