source: SH_SHM/trunk/source/sysbase.h @ 341

Revision 341, 8.2 KB checked in by marcus, 8 years ago (diff)

r180 | walther | 2011-03-09 16:27:03 +0100 (Mi, 09 Mär 2011) | 3 lines

Merging most of the changes from marcus' branch. For full details please see
http://www.seismic-handler.org/portal/log/SH_SHM/branches/marcus?revs=101-106,123-171

Line 
1
2/* file SYSBASE.H
3 *      =========
4 *
5 * version 24, 22-May-2006
6 *
7 * v 21: 28-Nov-94, K. Stammler: new naming conventions on sun
8 *
9 * machine dependent definitions
10 * this file conatins all available implementations
11 * K. Stammler, 2-MAY-90
12 */
13
14
15/*
16 *
17 *  SeismicHandler, seismic analysis software
18 *  Copyright (C) 1996,  Klaus Stammler, Federal Institute for Geosciences
19 *                                       and Natural Resources (BGR), Germany
20 *
21 *  This program is free software; you can redistribute it and/or modify
22 *  it under the terms of the GNU General Public License as published by
23 *  the Free Software Foundation; either version 2 of the License, or
24 *  (at your option) any later version.
25 *
26 *  This program is distributed in the hope that it will be useful,
27 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
28 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29 *  GNU General Public License for more details.
30 *
31 *  You should have received a copy of the GNU General Public License
32 *  along with this program; if not, write to the Free Software
33 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
34 *
35 */
36
37
38#ifndef __SYSBASE
39#define __SYSBASE
40
41#ifndef __BASECNST
42#include "basecnst.h"
43#endif
44
45/* short integer */
46#define BYTE unsigned char
47#define TSyByte BYTE
48#define TSyWord short int
49#define TSyUword unsigned short int
50
51/* boolean type */
52#define BOOLEAN int
53#define TSyBoolean BOOLEAN
54
55/* boolean values TRUE & FALSE */
56#ifdef BC_DEFINE_TRUE_FALSE
57#define TRUE (1)
58#define FALSE (0)
59#endif
60#define cSyTrue (1)
61#define cSyFalse (0)
62
63/* infinite loop declaration */
64#define FOREVER for(;;)
65#define TSyForever FOREVER
66
67/* status type */
68#ifndef STATUS
69#define STATUS int
70#define Severe(s) (*(s) != 0)
71#define TSyStatus STATUS
72#define SySevere(s) (*(s) != 0)
73#endif /* TSyStatus */
74
75/* nearest integer number to floating number */
76#define Nint(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
77#define Nint32(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
78#define SyNint(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
79
80/* nearest long number to floating number */
81#define Nlong(x) ((x)>0 ? (long)((x)+0.5) : (long)((x)-0.5))
82#define SyNlong(x) ((x)>0 ? (long)((x)+0.5) : (long)((x)-0.5))
83
84/* capitalize character */
85#define Cap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))
86#define SyCap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))
87#define Uncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))
88#define SyUncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))
89
90/* absolute value of number */
91#define Abs(x) ((x)<0?-(x):(x))
92#define SyAbs(x) ((x)<0?-(x):(x))
93
94/* binary file type, here the same as text file */
95typedef FILE *BFILE;
96#define TSyBfile BFILE
97
98/* sy_findfile parameter */
99#define SYC_FF_NAME 1
100#define SYC_FF_DIR 2
101#define SYC_FF_EXT 4
102#define cSyFfName 1
103#define cSyFfDir 2
104#define cSyFfExt 4
105
106/* deallocate memory */
107#define sy_deallocmem(p) free(p)
108#define SyDeallocMem(p) free(p)
109
110/* read logical name table */
111#define sy_lognames(f,s) fo_readtable(f,s)
112#define SyLogNames(f,s) fo_readtable(f,s)
113
114/* open text file */
115/* #define sy_fopen(f,a) fo_fopen(f,a) */
116/* routine implemented for it */
117
118/* close text file */
119#define sy_fclose(f) fclose(f)
120#define SyFclose(f) fclose(f)
121
122/* read from text file */
123#define sy_fread(b,s,n,f) fread(b,s,n,f)
124#define SyFread(b,s,n,f) fread(b,s,n,f)
125
126/* write to text file */
127#define sy_fwrite(b,s,n,f) fwrite(b,s,n,f)
128#define SyFwrite(b,s,n,f) fwrite(b,s,n,f)
129
130/* read from binary file */
131#define sy_fbread(b,s,n,f) fread(b,s,n,f)
132#define SyFbread(b,s,n,f) fread(b,s,n,f)
133
134/* write to binary file */
135#define sy_fbwrite(b,s,n,f) fwrite(b,s,n,f)
136#define SyFbwrite(b,s,n,f) fwrite(b,s,n,f)
137
138/* seek on binary file */
139#define sy_fbseek(f,p,m) fseek(f,p,m)
140#define SyFbseek(f,p,m) fseek(f,p,m)
141
142/* open binary file */
143#define sy_fbopen(f,a) sy_fopen(f,a)
144#define SyFbopen(f,a) sy_fopen(f,a)
145
146/* close binary file */
147#define sy_fbclose(f) fclose(f)
148#define SyFbclose(f) fclose(f)
149
150/* binary file operation failed */
151#define sy_fbfailed(f) ((f)==NULL)
152#define SyFbfailed(f) ((f)==NULL)
153
154/* call to operating system */
155#define sy_system(c,s) system(c)
156#define SySystem(c,s) system(c)
157
158/* delete file */
159#define sy_fdelete(f) unlink(f)
160#define SyFdelete(f) unlink(f)
161
162/* rename file */
163#define sy_frename(f,t) rename(f,t)
164#define SyFrename(f,t) rename(f,t)
165
166/* difference time, not implemented */
167#define sy_difftime() 1.0
168#define SyDifftime() 1.0
169
170
171/* system constants */
172/* ---------------- */
173
174/* maximum unsigned */
175#define SYC_MAXUNSG 0xffffffffL
176#define cSyMaxUnsg SYC_MAXUNSG
177
178/* maximum integer */
179#define SYC_MAXINT 0x7fffffffL
180#define cSyMaxInt SYC_MAXINT
181
182/* minimum integer */
183#define SYC_MININT 0x80000000L
184#define cSyMinInt SYC_MININT
185
186/* maximum long */
187#define SYC_MAXLONG 0x7fffffffL
188#define cSyMaxLong SYC_MAXLONG
189
190/* minimum long */
191#define SYC_MINLONG 0x80000000L
192#define cSyMinLong SYC_MINLONG
193
194/* open existing file to overwrite */
195#define SYC_OPEN_OVWR "r+"
196#define cSyOpenOvwr SYC_OPEN_OVWR
197
198
199/* system specific types */
200/* --------------------- */
201
202/* difference time */
203typedef float DIFFTIME;
204typedef float TSyDifftime;
205
206
207/* not implemented routines */
208#define sy_gettime(s) strcpy(s,SHC_TIMEDEFAULT)
209#define SyGetTime(s) strcpy(s,SHC_TIMEDEFAULT)
210#define sy_sharecpu()
211#define SyShareCpu()
212#define sy_alert(t) printf("%s",t)
213#define SyAlert(t) printf("%s",t)
214#define sy_initprocess()
215#define SyInitProcess()
216
217
218/* include fileopen */
219#ifndef __FOUSRDEF
220#include BC_FOUSRDEF
221#endif
222
223
224/*------------------------------------------------------------------------*/
225/*    prototypes of routines of module SYSCALL.C                          */
226/*------------------------------------------------------------------------*/
227
228
229#define SyAllocMem sy_allocmem
230
231void *sy_allocmem( long cnt, int size, STATUS *status );
232
233/* allocates memory ("cnt" objects of size "size)
234 *
235 * parameters of routine
236 * long     cnt;            input; number of objects
237 * int      size;           input; size of each object
238 * STATUS   *status;        output; return status
239 */
240
241
242/*------------------------------------------------------------------------*/
243
244
245#define SyFindFile sy_findfile
246
247void sy_findfile( int request, char wild[], char filename[] );
248
249/* looks for files matching wild card string "wild". Returns filename of
250 * file found or "\0" if not found.  "request" controls the returned
251 * elements.  For example the value (SYC_FF_DIR|SYC_FF_NAME|SYC_FF_EXT)
252 * means, that the returned string contains directory, file name and
253 * extension.
254 *
255 * parameters of routine
256 * int      request;        input; what elements (name,dir,extension)
257 * char     *wild;          input; wild card string
258 * char     *filename;      output; next file found
259 */
260
261
262/*------------------------------------------------------------------------*/
263
264
265#define SyFopen sy_fopen
266
267FILE *sy_fopen( char file[], char access[] );
268
269/* opens file.  Backslashes "\" in the filename are converted to slashes "/"
270 *
271 * parameters of routine
272 * char       file[];        input; filename of file to be opened
273 * char       access[];      input; access string
274 *                           returns pointer to file or NULL
275 */
276
277
278/*------------------------------------------------------------------------*/
279
280
281#define SyRandom sy_random
282
283double sy_random( double ampl );
284
285/* creates random number with absolute value less than (or equal to)
286 * "amp"
287 *
288 * parameters of routine
289 * double               ampl;           input; max. amplitude; if zero, a new random
290 *                                                                       series is started
291 */
292
293
294/*------------------------------------------------------------------------*/
295
296
297#define SyRandomStr sy_randomstr
298
299void sy_randomstr( int lth, char str[] );
300
301/* creates random string of length "lth"
302 *
303 * parameters of routine
304 * int        lth;      input; length of output string
305 * char       str[];    output; random string
306 */
307
308
309/*------------------------------------------------------------------------*/
310
311
312#define SyLocalInf sy_localinf
313
314void sy_localinf( char item[], char value[], STATUS *status );
315
316/* returns local info in "value"
317 *
318 * parameters of routine
319 * char       item[];     input; info item
320 * char       value[];    output; return value
321 * STATUS     *status;    output; return status
322 */
323
324
325/*------------------------------------------------------------------------*/
326
327
328#endif /* __SYSBASE */
329
Note: See TracBrowser for help on using the repository browser.