Changeset 104
- Timestamp:
- 02/24/2009 08:40:00 AM (15 years ago)
- Location:
- SH_SHM/branches/marcus/source
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
SH_SHM/branches/marcus/source/basecnst.h
r103 r104 133 133 134 134 135 136 137 /******************************************************************138 *** IBM PC version ***139 ******************************************************************/140 141 142 143 #ifdef BC_IBM144 145 /* include files */146 #define BC_SYSBASE "d:\gast\SH\SYSBASE.H"147 #define BC_SYERRORS "d:\gast\SH\SYERRORS.H"148 #define BC_GCUSRDEF "d:\gast\SH\LOCAL\GCUSRDEF.H"149 /* #define BC_GCERRORS "LOCAL\GCERRORS.H" */150 #define BC_FOREIGN "d:\gast\SH\SHFRGN.H"151 #define BC_SHDIRS "d:\gast\SH\SHDIRS.H"152 #define BC_ASCII "d:\gast\SH\ASCII.H"153 #define BC_GRAPHBAS "d:\gast\SH\LOCAL\GRAPHBAS.H"154 #define BC_SHCONST "d:\gast\SH\SHCONST.H"155 #define BC_QFUSRDEF "d:\gast\sh\qfusrdef.h"156 #define BC_QFERRORS "d:\gast\sh\qferrors.h"157 #define BC_CPAR "d:\gast\util\cpar.h"158 #define BC_EARTHLOC "d:\gast\sh\earthloc.h"159 #define BC_UTUSRDEF "d:\gast\sh\utusrdef.h"160 #define BC_GLUSRDEF "d:\gast\sh\glusrdef.h"161 #define BC_INPFILES "d:\gast\util\inpfiles.h"162 #define BC_DFQENTRY "d:\gast\sh\dfqentry.h"163 #define BC_ERUSRDEF "d:\gast\sh\erusrdef.h"164 #define BC_FLERRORS "d:\gast\sh\flerrors.h"165 #define BC_READGRN "d:\gast\sh\readgrn.h"166 #define BC_PTUSRDEF "d:\gast\sh\ptusrdef.h"167 168 169 #endif /* BC_IBM */170 171 172 173 135 /****************************************************************** 174 136 *** SUN version *** -
SH_SHM/branches/marcus/source/seed_io/steim1.h
r16 r104 37 37 38 38 39 #ifdef IBM_PC40 #define XHUGE huge41 #define GM_ALLOC(NUM, SIZE) halloc(NUM, SIZE)42 #define GM_FREE hfree43 #else44 39 #define XHUGE 45 40 #define GM_ALLOC(NUM, SIZE) malloc((NUM)*(SIZE)) 46 41 #define GM_FREE free 47 #endif48 42 49 43 #ifdef ANSI_EXTENSIONS -
SH_SHM/branches/marcus/source/shmenu0.c
r102 r104 515 515 # ifdef BC_SUN 516 516 strcpy( str, "UNIX" ); 517 # endif518 # ifdef BC_IBM519 strcpy( str, "MS-DOS" );520 517 # endif 521 518 sl_setsymbol( str2, str, &locstat ); -
SH_SHM/branches/marcus/source/sysbase.h
r102 r104 43 43 #endif 44 44 45 46 47 /******************************************************************48 *** IBM PC version ***49 ******************************************************************/50 51 52 53 #ifdef BC_IBM54 55 56 57 /* includes */58 #include <alloc.h>59 60 /* short integer */61 #define BYTE unsigned char62 63 /* boolean type */64 #define BOOLEAN int65 66 /* boolean values TRUE & FALSE */67 #ifdef BC_DEFINE_TRUE_FALSE68 #define TRUE (1)69 #define FALSE (0)70 #endif71 72 /* infinite loop declaration */73 #define FOREVER for(;;)74 75 /* status type */76 #ifndef STATUS77 #define STATUS int /* status value */78 #define Severe(s) (*(s) != 0)79 #endif /* STATUS */80 81 /* nearest integer number to floating number */82 #define Nint(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))83 #define Nint32(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))84 85 /* nearest long number to floating number */86 #define Nlong(x) ((x)>0 ? (long)((x)+0.5) : (long)((x)-0.5))87 88 /* capitalize character */89 #define Cap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))90 #define Uncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))91 92 /* absolute value of number */93 #define Abs(x) ((x)<0?-(x):(x))94 95 /* binary file type, here the same as text files */96 typedef FILE *BFILE;97 98 /* sy_findfile parameter */99 #define SYC_FF_NAME 1100 #define SYC_FF_DIR 2101 #define SYC_FF_EXT 4102 103 /* deallocate memory, allocated by sy_allocmem */104 #define sy_deallocmem(p) free(p)105 106 /* open text file */107 #define sy_fopen(f,a) fopen(f,a)108 109 /* close text file */110 #define sy_fclose(f) fclose(f)111 112 /* read from text file, this is not yet used */113 #define sy_fread(b,s,n,f) fread(b,s,n,f)114 115 /* write to text file, this is not yet used */116 #define sy_fwrite(b,s,n,f) fwrite(b,s,n,f)117 118 /* read from binary file */119 #define sy_fbread(b,s,n,f) fread(b,s,n,f)120 121 /* write to binary file */122 #define sy_fbwrite(b,s,n,f) fwrite(b,s,n,f)123 124 /* seek on binary file */125 #define sy_fbseek(f,p,m) fseek(f,p,m)126 127 /* open binary file */128 #define sy_fbopen(f,a) fopen(f,a)129 130 /* close binary file */131 #define sy_fbclose(f) fclose(f)132 133 /* binary file operation failed */134 #define sy_fbfailed(f) ((f)==NULL)135 136 /* routine doing machine dependend things, not used here */137 #define sy_localinf(a,b,c)138 139 /* call operating system */140 #define sy_system(c,s) system(c)141 142 /* delete file */143 #define sy_fdelete(f) unlink(f)144 145 /* rename file */146 #define sy_frename(f,t) rename(f,t)147 148 /* get time differences in sec, not implemented here */149 #define sy_difftime() 1.0150 151 /* system constants */152 /* ---------------- */153 154 /* maximum unsigned */155 #define SYC_MAXUNSG 0xffffffffL156 157 /* maximum integer */158 #define SYC_MAXINT 0x7fffffffL159 160 /* minimum integer */161 #define SYC_MININT 0x80000000L162 163 /* maximum long */164 #define SYC_MAXLONG 0x7fffffffL165 166 /* minimum long */167 #define SYC_MINLONG 0x80000000L168 169 /* open existing file to overwrite, not yet used */170 #define SYC_OPEN_OVWR "r+"171 172 /* system specific types */173 /* --------------------- */174 175 /* difference time, to measure difference times */176 typedef float DIFFTIME;177 178 179 #define sy_alert(t) printf("%s",t)180 #define sy_debuginfo(l)181 #define sy_initprocess()182 #define sy_sharecpu()183 #define sy_gettime(t)184 #define sy_getmessage() NULL185 186 187 /*------------------------------------------------------------------------*/188 /* prototypes of routines of module SYSCALL.C */189 /*------------------------------------------------------------------------*/190 191 192 void *sy_allocmem( long cnt, int size, STATUS *status );193 194 /* allocates memory ("cnt" objects of size "size)195 *196 * parameters of routine197 * long cnt; input; number of objects198 * int size; input; size of each object199 * STATUS *status; output; return status200 */201 202 203 /*------------------------------------------------------------------------*/204 205 206 void sy_findfile( int request, char wild[], char filename[] );207 208 /* looks for files matching wild card string "wild". Returns filename of209 * file found or "\0" if not found. "request" controls the returned210 * elements. For example the value (SYC_FF_DIR|SYC_FF_NAME|SYC_FF_EXT)211 * means, that the returned string contains directory, file name and212 * extension.213 *214 * parameters of routine215 * int request; input; what elements (name,dir,extension)216 * char *wild; input; wild card string217 * char *filename; output; next file found218 */219 220 221 /*------------------------------------------------------------------------*/222 223 224 double sy_random( double ampl );225 226 /* creates random number with absolute value less than (or equal to)227 * "amp"228 *229 * parameters of routine230 * double ampl; input; max. amplitude; if zero, a new random231 * series is started232 */233 234 235 /*------------------------------------------------------------------------*/236 237 238 void sy_randomstr( int lth, char str[] );239 240 /* creates random string of length "lth"241 *242 * parameters of routine243 * int lth; input; length of output string244 * char str[]; output; random string245 */246 247 248 /*------------------------------------------------------------------------*/249 250 251 252 #endif /* BC_IBM */253 254 255 256 45 /****************************************************************** 257 46 *** SUN version *** 258 47 ******************************************************************/ 259 48 260 261 262 49 #ifdef BC_SUN 263 264 265 50 266 51 /* short integer */ -
SH_SHM/branches/marcus/source/syscall.c
r102 r104 36 36 #include "basecnst.h" 37 37 38 39 40 /******************************************************************41 *** IBM PC version ***42 ******************************************************************/43 44 45 46 #ifdef BC_IBM47 48 49 50 #include <stdio.h>51 #include <string.h>52 #include <time.h>53 #include <stdlib.h>54 #include "sysbase.h"55 #include "syerrors.h"56 #include "shvars.h"57 58 #define MAXFFCMDLTH 30059 60 /*------------------------------------------------------------------------*/61 62 63 64 void *sy_allocmem( long cnt, int size, STATUS *status )65 66 /* allocates memory ("cnt" objects of size "size)67 *68 * parameters of routine69 * long cnt; input; number of objects70 * int size; input; size of each object71 * STATUS *status; output; return status72 */73 {74 /* local variables */75 void *ptr; /* pointer to allocated memory */76 77 /* executable code */78 79 ptr = (void *)malloc( cnt*size );80 if (ptr == NULL) *status = SYE_MEMOVFL;81 return ptr;82 83 } /* end of sy_allocmem */84 85 86 87 /*------------------------------------------------------------------------*/88 89 90 91 void sy_findfile( int request, char wild[], char filename[] )92 93 /* looks for files matching wild card string "wild". Returns filename of94 * file found (with/without directory and/or extension, depending on "request") or95 * "\0" if not found.96 *97 * parameters of routine98 * int request; input; what elements (name,dir,ext)99 * char *wild; input; wild card string100 * char *filename; output; next file found101 */102 {103 /* local variables */104 static char currwild[BC_FILELTH+1]; /* current wild card string */105 static char dirfile[BC_FILELTH+1]; /* output filename */106 static char errfile[BC_FILELTH+1]; /* error output filename */107 static FILE *df; /* directory file */108 char cmd[MAXFFCMDLTH+1]; /* command string */109 int filpos; /* position of file name */110 int extpos; /* position of extension */111 char *c; /* moving pointer */112 113 /* executable code */114 115 if (*dirfile == '\0') {116 strcpy( dirfile, shd_scratch );117 strcat( dirfile, id_shv );118 strcpy( errfile, dirfile );119 strcat( dirfile, "DIR.TMP" );120 strcat( errfile, "ERR.TMP" );121 } /*endif*/122 123 if (*wild == '\0') {124 *currwild = '\0';125 if (df != NULL) fclose( df );126 df = NULL;127 return;128 } /*endif*/129 130 if (strcmp(currwild,wild) != 0) { /* new wild card string */131 if (df != NULL) fclose( df );132 strcpy( currwild, wild );133 strcpy( cmd, "dir " );134 strcat( cmd, wild );135 strcat( cmd, " >" );136 strcat( cmd, dirfile );137 strcat( cmd, " 2>" );138 strcat( cmd, errfile );139 system( cmd );140 df = fopen( dirfile, "r" );141 if (df == NULL) {142 *currwild = '\0';143 *filename = '\0';144 return;145 } /*endif*/146 } /*endif*/147 148 if (fgets(filename,BC_FILELTH,df) == NULL) {149 if (df != NULL) fclose( df );150 *currwild = '\0';151 *filename = '\0';152 return;153 } /*endif*/154 155 filpos = strlen( filename ) - 1;156 if (filename[filpos] == '\n') filename[filpos] = '\0';157 158 if (request == (SYC_FF_NAME|SYC_FF_EXT|SYC_FF_DIR)) return;159 160 filpos = extpos = 0;161 c = filename;162 while (*c != '\0') {163 if (*c == '.') {164 extpos = c-filename;165 } else if (*c == '\\') {166 filpos = c-filename;167 } /*endif*/168 c++;169 } /*endwhile*/170 171 if (!(SYC_FF_EXT & request) && extpos > 0)172 filename[extpos] = '\0';173 174 if (!(SYC_FF_DIR & request) && filpos > 0)175 strcpy( filename, filename+filpos+1 );176 177 } /* end of sy_findfile */178 179 180 181 /*------------------------------------------------------------------------*/182 183 184 185 double sy_random( double ampl )186 187 /* creates random number with absolute value less than (or equal to)188 * "amp"189 *190 * parameters of routine191 * double ampl; input; max. amplitude; if zero, a new random192 * series is started193 */194 {195 /* local constants */196 # define MAXRAND 32767.0197 198 /* local variables */199 int rdm; /* integer random result */200 201 /* executable code */202 203 if (ampl == 0.0) {204 srand( (unsigned)clock() );205 return 0.0;206 } else {207 rdm = rand();208 return ( (((double)rdm * 2.0) / MAXRAND - 1.0) * ampl );209 } /*endif*/210 211 } /* end of sy_random */212 213 214 215 /*------------------------------------------------------------------------*/216 217 218 219 void sy_randomstr( int lth, char str[] )220 221 /* creates random string of length "lth"222 *223 * parameters of routine224 * int lth; input; length of output string225 * char str[]; output; random string226 */227 {228 #ifdef XXX229 /* local variables */230 time_t timev; /* current time */231 struct tms ts;232 char minstr[6]; /* minimum length string */233 int i; /* counter */234 235 /* executable code */236 237 if (lth < 3) {238 *str = '\0';239 return;240 } /*endif*/241 *str++ = '_';242 lth -= 2;243 244 times(&ts);245 timev = ts.tms_utime;246 timev %= 10000;247 sprintf( minstr, "%04d", timev );248 if (lth < 4) {249 for (i=0;i<lth;i++)250 str[i] = minstr[i];251 } else {252 strcpy( str, minstr );253 for (i=4; i<lth; i++)254 str[i] = '0';255 } /*endif*/256 str[lth] = '_';257 str[lth+1] = '\0';258 #endif /* XXX */259 strncpy( str, "XXXXXXXXXXX", lth ); str[lth] = '\0';260 } /* end of sy_randomstr */261 262 263 264 /*------------------------------------------------------------------------*/265 266 267 268 #endif /* BC_IBM */269 38 270 39
Note: See TracChangeset
for help on using the changeset viewer.