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

Revision 16, 30.3 KB checked in by marcus, 14 years ago (diff)

r1 | svn | 2007-12-13 11:10:29 +0100 (Do, 13 Dez 2007) | 2 lines

Initial import

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
46
47/******************************************************************
48 ***                        ATARI version                       ***
49 ******************************************************************/
50
51
52
53#ifdef BC_ATARI
54
55
56/* one byte integer */
57#define BYTE char
58
59/* boolean type */
60#define BOOLEAN int
61
62/* boolean values TRUE & FALSE */
63#ifdef BC_DEFINE_TRUE_FALSE
64#define TRUE (1)
65#define FALSE (0)
66#endif
67
68/* infinite loop declaration   */
69#define FOREVER for(;;)
70
71/* status type */
72typedef int STATUS;    /* status value */
73#define Severe(s) (*(s) != 0)
74
75/* nearest integer number to floating number */
76#define Nint(x) (int)(((x)>0)?(x)+0.5:(x)-0.5)
77#define Nint32(x) (int)(((x)>0)?(x)+0.5:(x)-0.5)
78
79/* nearest long number to floating number */
80#define Nlong(x) (long)(((x)>0)?(x)+0.5:(x)-0.5)
81
82/* capitalize character */
83#define Cap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))
84#define Uncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))
85
86/* NULL address */
87/* #define NULL ( ( void * ) 0L ) */
88
89/* absolute value of number */
90#define Abs(x) ((x)<0?-(x):(x))
91
92/* sy_findfile parameter */
93#define SYC_FF_NAME 1
94#define SYC_FF_DIR 2
95#define SYC_FF_EXT 4
96
97/* binary file type, uses GEMDOS file handle, because of mistake in FILE */
98typedef int BFILE;
99
100/* open existing file for writing, is not yet used */
101#define SYC_OPEN_OVWR "w"
102
103/* read logical name table */
104#define sy_lognames(f,s) fo_readtable(f,s)
105
106/* open text file */
107#define sy_fopen(f,a) fo_fopen(f,a)
108
109/* close text file */
110#define sy_fclose(f) fclose(f)
111
112/* read from text file, is not yet used */
113#define sy_fread fread
114
115/* write to text file, is not yet used */
116#define sy_fwrite fwrite
117
118/* binary file operation failed */
119#define sy_fbfailed(f) ((f)<0)
120
121/* delete file                   */
122/* call: sy_fdelete( filename )  */
123/*       char   *filename;  input; file to be deleted */
124/* #define sy_fdelete(a) Fdelete(a) */
125/* int Fdelete( const char fname[] ); */
126/* is now implemented as routine: */
127void sy_fdelete( char fname[] );
128
129/* rename file                                     */
130/* call: sy_frename( from, to )                    */
131/*       char   *from;   input; file to be renamed */
132/*       char   *to;     input; new name of file   */
133/* #define sy_frename(a,b) Frename(0,a,b) */
134/* int Frename( int zero, const char oldname[], const char newname[] ); */
135/* is now implemented as routine: */
136void sy_frename( char from[], char to[] );
137
138/* random string generator, not implemented */
139#define sy_randomstr(l,s)
140
141
142/* system constants */
143/* ---------------- */
144
145/* maximum unsigned */
146#define SYC_MAXUNSG 0xffffL
147
148/* maximum integer */
149#define SYC_MAXINT 0x7fffL
150
151/* minimum integer */
152#define SYC_MININT 0x8000L
153
154/* maximum long */
155#define SYC_MAXLONG 0x7fffffffL
156
157/* minimum long */
158#define SYC_MINLONG 0x80000000L
159
160
161/* system specific types */
162/* --------------------- */
163
164/* difference time, to measure time differences */
165typedef float DIFFTIME;
166
167
168/* one global variable: Application ID */
169#ifndef __FROM_SYSCALL
170extern int syv_apid;
171#endif
172
173/* include fileopen */
174#ifndef __FOUSRDEF
175#include BC_FOUSRDEF
176#endif
177
178
179
180/*------------------------------------------------------------------------*/
181/*                                      prototypes of routines of module SYSCALL.C                                */
182/*------------------------------------------------------------------------*/
183
184
185void sy_initprocess( void );
186
187/* initialises process (ATARI AES, global memory area)
188 *
189 * no parameters
190 */
191
192
193/*------------------------------------------------------------------------*/
194
195
196#ifdef BC_SHARE_CPU
197
198
199/*------------------------------------------------------------------------*/
200
201
202
203void sy_sharecpu( void );
204
205/* let other process get some CPU time (call to evnt_timer)
206 *
207 * no parameters
208 */
209
210
211/*------------------------------------------------------------------------*/
212
213
214void sy_debuginfo( char info[] );
215
216/* transfers debug information
217 *
218 * parameters of routine
219 * char          info[];   input; info string
220 */
221
222
223/*------------------------------------------------------------------------*/
224
225
226char *sy_getmessage( void );
227
228/* returns message string from external source
229 *
230 * no parameters
231 */
232
233
234/*------------------------------------------------------------------------*/
235
236
237#else  /* BC_SHARE_CPU */
238
239
240#define sy_sharecpu()
241#define sy_debuginfo(i)
242#define sy_getmessage() NULL
243
244
245#endif /* BC_SHARE_CPU */
246
247
248/*------------------------------------------------------------------------*/
249
250
251void sy_gettime( char timstr[] );
252
253/* returns current time in time string.  The time string needs 25
254 * characters (including the termination byte)
255 *
256 * parameters of routine
257 */
258
259
260/*------------------------------------------------------------------------*/
261
262
263void sy_alert( char text[] );
264
265/* displays alert message text
266 *
267 * parameters of display
268 * char       text[];     input; text to be displayed
269 */
270
271
272/*------------------------------------------------------------------------*/
273
274
275void *sy_allocmem( long cnt, int size, STATUS *status );
276
277/* allocates memory ("cnt" objects of size "size)
278 *
279 * parameters of routine
280 * long     cnt;            input; number of objects
281 * int      size;           input; size of each object
282 * STATUS   *status;        output; return status
283 */
284
285
286/*------------------------------------------------------------------------*/
287
288
289void sy_deallocmem( void *ptr );
290
291/* deallocates memory, allocated by sy_allocmem
292 *
293 * parameter of routine
294 * void     *ptr;        input; pointer to be freed
295 */
296
297
298/*------------------------------------------------------------------------*/
299
300
301long sy_fbread( void *strbuf, int size, long n, BFILE fp );
302
303/* reads "n" objects of size "size" from binary file "fp"
304 *
305 * parameters of routine
306 * void     *strbuf;        output; buffer to read to
307 * int      size;           input; size of each object
308 * long     n;              input; number of objects
309 * BFILE    fp;             input; file descriptor
310 */
311
312
313/*------------------------------------------------------------------------*/
314
315
316long sy_fbwrite( void *strbuf, int size, long n, BFILE fp );
317
318/* writes "n" objects of size "size" to file "fp"
319 *
320 * parameters of routine
321 * void     *strbuf;        input; buffer to read to
322 * int      size;           input; size of each object
323 * long     n;              input; number of objects
324 * BFILE    fp;             input; file descriptor
325 */
326
327
328/*------------------------------------------------------------------------*/
329
330
331int sy_fbseek( BFILE fp, long pos, int mode );
332
333/* changes file position
334 *
335 * parameters of routine
336 * BFILE      fp;    input; file pointer
337 * long       pos;   input; new position
338 * int        mode;  input; search mode
339 */
340
341
342/*------------------------------------------------------------------------*/
343
344
345BFILE sy_fbopen( const char *file, const char *access );
346
347/* opens a binary file
348 *
349 * parameters of routine
350 * const char    *file;    input; filename
351 * const char    *access;  input; access mode
352 */
353
354
355/*------------------------------------------------------------------------*/
356
357
358int sy_fbclose( BFILE fp );
359
360/* closes binary file
361 *
362 * parameter of routine
363 * BFILE     fp;      input; file pointer
364 */
365
366
367/*------------------------------------------------------------------------*/
368
369
370void sy_findfile( int request, char wild[], char filename[] );
371
372/* looks for files matching wild card string "wild". Returns filename of
373 * file found or "\0" if not found.  "request" controls the returned
374 * elements.  For example the value (SYC_FF_DIR|SYC_FF_NAME|SYC_FF_EXT)
375 * means, that the returned string contains directory, file name and
376 * extension.
377 *
378 * parameters of routine
379 * int      request;        input; what elements (name,dir,extension)
380 * char     *wild;          input; wild card string
381 * char     *filename;      output; next file found
382 */
383
384
385/*------------------------------------------------------------------------*/
386
387
388void sy_system( char *cmd, STATUS *status );
389
390/* call to the operating system
391 *
392 * parameters of routine
393 * char     *cmd;           input; system command
394 * STATUS   *status;        output; return status
395 */
396
397
398/*------------------------------------------------------------------------*/
399
400
401
402double sy_random( double ampl );
403
404/* creates random number with absolute value less than (or equal to)
405 * "amp"
406 *
407 * parameters of routine
408 * double               ampl;           input; max. amplitude; if zero, a new random
409 *                                                                       series is started
410 */
411
412
413/*------------------------------------------------------------------------*/
414
415
416DIFFTIME sy_difftime( void );
417
418/* returns time since last sy_difftime call
419 */
420
421
422/*------------------------------------------------------------------------*/
423
424
425void sy_localinf( char item[], char value[], STATUS *status );
426
427/* machine dependend routine
428 *
429 * parameters of routine
430 * char       item[];     input; info item
431 * char       value[];    input/output; additional parameter
432 * STATUS     *status;    output; return status
433 */
434
435
436/*------------------------------------------------------------------------*/
437
438
439
440#endif /* BC_ATARI */
441
442
443
444/******************************************************************
445 ***                        IBM PC version                      ***
446 ******************************************************************/
447
448
449
450#ifdef BC_IBM
451
452
453
454/* includes */
455#include <alloc.h>
456
457/* short integer */
458#define BYTE unsigned char
459
460/* boolean type */
461#define BOOLEAN int
462
463/* boolean values TRUE & FALSE */
464#ifdef BC_DEFINE_TRUE_FALSE
465#define TRUE (1)
466#define FALSE (0)
467#endif
468
469/* infinite loop declaration */
470#define FOREVER for(;;)
471
472/* status type */
473#ifndef STATUS
474#define STATUS int    /* status value */
475#define Severe(s) (*(s) != 0)
476#endif /* STATUS */
477
478/* nearest integer number to floating number */
479#define Nint(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
480#define Nint32(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
481
482/* nearest long number to floating number */
483#define Nlong(x) ((x)>0 ? (long)((x)+0.5) : (long)((x)-0.5))
484
485/* capitalize character */
486#define Cap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))
487#define Uncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))
488
489/* absolute value of number */
490#define Abs(x) ((x)<0?-(x):(x))
491
492/* binary file type, here the same as text files */
493typedef FILE *BFILE;
494
495/* sy_findfile parameter */
496#define SYC_FF_NAME 1
497#define SYC_FF_DIR 2
498#define SYC_FF_EXT 4
499
500/* deallocate memory, allocated by sy_allocmem */
501#define sy_deallocmem(p) free(p)
502
503/* open text file */
504#define sy_fopen(f,a) fopen(f,a)
505
506/* close text file */
507#define sy_fclose(f) fclose(f)
508
509/* read from text file, this is not yet used */
510#define sy_fread(b,s,n,f) fread(b,s,n,f)
511
512/* write to text file, this is not yet used */
513#define sy_fwrite(b,s,n,f) fwrite(b,s,n,f)
514
515/* read from binary file */
516#define sy_fbread(b,s,n,f) fread(b,s,n,f)
517
518/* write to binary file */
519#define sy_fbwrite(b,s,n,f) fwrite(b,s,n,f)
520
521/* seek on binary file */
522#define sy_fbseek(f,p,m) fseek(f,p,m)
523
524/* open binary file */
525#define sy_fbopen(f,a) fopen(f,a)
526
527/* close binary file */
528#define sy_fbclose(f) fclose(f)
529
530/* binary file operation failed */
531#define sy_fbfailed(f) ((f)==NULL)
532
533/* routine doing machine dependend things, not used here */
534#define sy_localinf(a,b,c)
535
536/* call operating system */
537#define sy_system(c,s) system(c)
538
539/* delete file */
540#define sy_fdelete(f) unlink(f)
541
542/* rename file */
543#define sy_frename(f,t) rename(f,t)
544
545/* get time differences in sec, not implemented here */
546#define sy_difftime() 1.0
547
548/* system constants */
549/* ---------------- */
550
551/* maximum unsigned */
552#define SYC_MAXUNSG 0xffffffffL
553
554/* maximum integer */
555#define SYC_MAXINT 0x7fffffffL
556
557/* minimum integer */
558#define SYC_MININT 0x80000000L
559
560/* maximum long */
561#define SYC_MAXLONG 0x7fffffffL
562
563/* minimum long */
564#define SYC_MINLONG 0x80000000L
565
566/* open existing file to overwrite, not yet used */
567#define SYC_OPEN_OVWR "r+"
568
569/* system specific types */
570/* --------------------- */
571
572/* difference time, to measure difference times */
573typedef float DIFFTIME;
574
575
576#define sy_alert(t) printf("%s",t)
577#define sy_debuginfo(l)
578#define sy_initprocess()
579#define sy_sharecpu()
580#define sy_gettime(t)
581#define sy_getmessage() NULL
582
583
584/*------------------------------------------------------------------------*/
585/*    prototypes of routines of module SYSCALL.C                          */
586/*------------------------------------------------------------------------*/
587
588
589void *sy_allocmem( long cnt, int size, STATUS *status );
590
591/* allocates memory ("cnt" objects of size "size)
592 *
593 * parameters of routine
594 * long     cnt;            input; number of objects
595 * int      size;           input; size of each object
596 * STATUS   *status;        output; return status
597 */
598
599
600/*------------------------------------------------------------------------*/
601
602
603void sy_findfile( int request, char wild[], char filename[] );
604
605/* looks for files matching wild card string "wild". Returns filename of
606 * file found or "\0" if not found.  "request" controls the returned
607 * elements.  For example the value (SYC_FF_DIR|SYC_FF_NAME|SYC_FF_EXT)
608 * means, that the returned string contains directory, file name and
609 * extension.
610 *
611 * parameters of routine
612 * int      request;        input; what elements (name,dir,extension)
613 * char     *wild;          input; wild card string
614 * char     *filename;      output; next file found
615 */
616
617
618/*------------------------------------------------------------------------*/
619
620
621double sy_random( double ampl );
622
623/* creates random number with absolute value less than (or equal to)
624 * "amp"
625 *
626 * parameters of routine
627 * double               ampl;           input; max. amplitude; if zero, a new random
628 *                                                                       series is started
629 */
630
631
632/*------------------------------------------------------------------------*/
633
634
635void sy_randomstr( int lth, char str[] );
636
637/* creates random string of length "lth"
638 *
639 * parameters of routine
640 * int        lth;      input; length of output string
641 * char       str[];    output; random string
642 */
643
644
645/*------------------------------------------------------------------------*/
646
647
648
649#endif /* BC_IBM */
650
651
652
653/******************************************************************
654 ***                         VAX version                        ***
655 ******************************************************************/
656
657
658
659#ifdef BC_VAX
660
661
662
663/* short integer */
664#define BYTE char
665
666/* boolean type */
667#define BOOLEAN int
668
669/* boolean values TRUE & FALSE */
670#ifdef BC_DEFINE_TRUE_FALSE
671#define TRUE (1)
672#define FALSE (0)
673#endif
674
675/* infinite loop declaration */
676#define FOREVER for(;;)
677
678/* status type */
679#ifndef STATUS
680#define STATUS int
681#define Severe(s) (*(s) != 0)
682#endif /* STATUS */
683
684/* nearest integer number to floating number */
685#define Nint(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
686#define Nint32(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
687
688/* nearest long number to floating number */
689#define Nlong(x) ((x)>0 ? (long)((x)+0.5) : (long)((x)-0.5))
690
691/* capitalize character */
692#define Cap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))
693#define Uncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))
694
695/* absolute value of number */
696#define Abs(x) ((x)<0?-(x):(x))
697
698/* read logical name table, not implemented */
699#define sy_lognames(f,s)
700
701/* open text file */
702#define sy_fopen(f,a) fopen(f,a)
703
704/* close text file */
705#define sy_fclose(f) fclose(f)
706
707/* binary file type, here the same as text file */
708typedef FILE *BFILE;
709
710/* binary file operation failed */
711#define sy_fbfailed(f) ((f)==NULL)
712
713/* sy_findfile parameter */
714#define SYC_FF_NAME 1
715#define SYC_FF_DIR 2
716#define SYC_FF_EXT 4
717
718
719
720/* system constants */
721/* ---------------- */
722
723/* maximum unsigned */
724#define SYC_MAXUNSG 0xffffffffL
725
726/* maximum integer */
727#define SYC_MAXINT 0x7fffffffL
728
729/* minimum integer */
730#define SYC_MININT 0x80000000L
731
732/* maximum long */
733#define SYC_MAXLONG 0x7fffffffL
734
735/* minimum long */
736#define SYC_MINLONG 0x80000000L
737
738/* open existing file to overwrite */
739#define SYC_OPEN_OVWR "r+"
740
741/* system specific types */
742/* --------------------- */
743
744/* difference time */
745typedef float DIFFTIME;
746
747
748/* not implemented routines */
749#define sy_initprocess()
750#define sy_sharecpu()
751#define sy_debuginfo(s)
752#define sy_alert(t) printf( "\n%s\n", t )
753#define sy_getmessage() NULL
754#define sy_gettime(s) strcpy(s,SHC_TIMEDEFAULT)
755
756
757
758/*------------------------------------------------------------------------*/
759/*    prototypes of routines of module SYSCALL.C                          */
760/*------------------------------------------------------------------------*/
761
762
763void *sy_allocmem( long cnt, int size, STATUS *status );
764
765/* allocates memory ("cnt" objects of size "size)
766 *
767 * parameters of routine
768 * long     cnt;            input; number of objects
769 * int      size;           input; size of each object
770 * STATUS   *status;        output; return status
771 */
772
773
774/*------------------------------------------------------------------------*/
775
776
777void sy_deallocmem( void *ptr );
778
779/* deallocates memory
780 *
781 * parameter of routine
782 * void     *ptr;        input; pointer to be freed
783 */
784
785
786/*------------------------------------------------------------------------*/
787
788
789long sy_fread( void *strbuf, int size, long n, FILE *fp );
790
791/* reads "n" objects of size "size" from file "fp"
792 *
793 * parameters of routine
794 * void     *strbuf;        output; buffer to read to
795 * int      size;           input; size of each object
796 * long     n;              input; number of objects
797 * FILE     *fp;            input; file descriptor
798 */
799
800
801/*------------------------------------------------------------------------*/
802
803
804long sy_fwrite( void *strbuf, int size, long n, FILE *fp );
805
806/* writes "n" objects of size "size" to file "fp"
807 *
808 * parameters of routine
809 * void     *strbuf;        input; buffer to read to
810 * int      size;           input; size of each object
811 * long     n;              input; number of objects
812 * FILE     *fp;            input; file descriptor
813 */
814
815
816/*------------------------------------------------------------------------*/
817
818
819long sy_fbread( void *strbuf, int size, long n, BFILE fp );
820
821/* reads "n" objects of size "size" from binary file "fp"
822 *
823 * parameters of routine
824 * void     *strbuf;        output; buffer to read to
825 * int      size;           input; size of each object
826 * long     n;              input; number of objects
827 * BFILE    fp;             input; file descriptor
828 */
829
830
831/*------------------------------------------------------------------------*/
832
833
834long sy_fbwrite( void *strbuf, int size, long n, BFILE fp );
835
836/* writes "n" objects of size "size" to binary file "fp"
837 *
838 * parameters of routine
839 * void     *strbuf;        input; buffer to read to
840 * int      size;           input; size of each object
841 * long     n;              input; number of objects
842 * BFILE    fp;             input; file descriptor
843 */
844
845
846/*------------------------------------------------------------------------*/
847
848
849int sy_fbseek( BFILE fp, long pos, int mode );
850
851/* changes read/write position in binary file
852 *
853 * parameters of routine
854 * BFILE      fp;    input; file pointer
855 * long       pos;   input; new position
856 * int        mode;  input; search mode
857 */
858
859
860/*------------------------------------------------------------------------*/
861
862
863BFILE sy_fbopen( const char *file, const char *access );
864
865/* opens a binary file
866 *
867 * parameters of routine
868 * const char    *file;    input; filename
869 * const char    *access;  input; access mode
870 */
871
872
873/*------------------------------------------------------------------------*/
874
875
876int sy_fbclose( BFILE fp );
877
878/* closes binary file
879 *
880 * parameter of routine
881 * BFILE     fp;      input; file pointer
882 */
883
884
885/*------------------------------------------------------------------------*/
886
887
888void sy_findfile( int request, char wild[], char filename[] );
889
890/* looks for files matching wild card string "wild". Returns filename of
891 * file found or "\0" if not found.  "request" controls the returned
892 * elements.  For example the value (SYC_FF_DIR|SYC_FF_NAME|SYC_FF_EXT)
893 * means, that the returned string contains directory, file name and
894 * extension.
895 *
896 * parameters of routine
897 * int      request;        input; what elements (name,dir,extension)
898 * char     *wild;          input; wild card string
899 * char     *filename;      output; next file found
900 */
901
902
903/*------------------------------------------------------------------------*/
904
905
906void sy_system( char *cmd, STATUS *status );
907
908/* call to the operating system
909 *
910 * parameters of routine
911 * char     *cmd;           input; system command
912 * STATUS   *status;        output; return status
913 */
914
915
916/*------------------------------------------------------------------------*/
917
918
919
920double sy_random( double ampl );
921
922/* creates random number with absolute value less than (or equal to)
923 * "amp"
924 *
925 * parameters of routine
926 * double               ampl;           input; max. amplitude; if zero, a new random
927 *                                                                       series is started
928 */
929
930
931/*------------------------------------------------------------------------*/
932
933
934DIFFTIME sy_difftime( void );
935
936/* returns time since last sy_difftime call
937 */
938
939
940/*------------------------------------------------------------------------*/
941
942
943void sy_randomstr( int lth, char str[] );
944
945/* creates random string of length "lth"
946 *
947 * parameters of routine
948 * int        lth;      input; length of output string
949 * char       str[];    output; random string
950 */
951
952
953/*------------------------------------------------------------------------*/
954
955
956void sy_fdelete( char file[] );
957
958/* deletes file
959 *
960 * parameters of routine
961 * char       file[];    input; name of file to be deleted
962 */
963
964
965/*----------------------------------------------------------------------------*/
966
967
968void sy_frename( char from[], char to[] );
969
970/* renames filename from "from" to "to"
971 *
972 * parameters of routine
973 * char       from[];      input; old filename
974 * char       to[];        input; new filename
975 */
976
977
978/*------------------------------------------------------------------------*/
979
980
981void sy_localinf( char item[], char value[], STATUS *status );
982
983/* returns local info in "value"
984 *
985 * parameters of routine
986 * char       item[];     input; info item
987 * char       value[];    output; return value
988 * STATUS     *status;    output; return status
989 */
990
991
992/*------------------------------------------------------------------------*/
993
994
995
996#endif /* BC_VAX */
997
998
999
1000/******************************************************************
1001 ***                         SUN version                        ***
1002 ******************************************************************/
1003
1004
1005
1006#ifdef BC_SUN
1007
1008
1009
1010/* short integer */
1011#define BYTE unsigned char
1012#define TSyByte BYTE
1013#define TSyWord short int
1014#define TSyUword unsigned short int
1015
1016/* boolean type */
1017#define BOOLEAN int
1018#define TSyBoolean BOOLEAN
1019
1020/* boolean values TRUE & FALSE */
1021#ifdef BC_DEFINE_TRUE_FALSE
1022#define TRUE (1)
1023#define FALSE (0)
1024#endif
1025#define cSyTrue (1)
1026#define cSyFalse (0)
1027
1028/* infinite loop declaration */
1029#define FOREVER for(;;)
1030#define TSyForever FOREVER
1031
1032/* status type */
1033#ifndef STATUS
1034#define STATUS int
1035#define Severe(s) (*(s) != 0)
1036#define TSyStatus STATUS
1037#define SySevere(s) (*(s) != 0)
1038#endif /* TSyStatus */
1039
1040/* nearest integer number to floating number */
1041#define Nint(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
1042#define Nint32(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
1043#define SyNint(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
1044
1045/* nearest long number to floating number */
1046#define Nlong(x) ((x)>0 ? (long)((x)+0.5) : (long)((x)-0.5))
1047#define SyNlong(x) ((x)>0 ? (long)((x)+0.5) : (long)((x)-0.5))
1048
1049/* capitalize character */
1050#define Cap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))
1051#define SyCap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))
1052#define Uncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))
1053#define SyUncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))
1054
1055/* absolute value of number */
1056#define Abs(x) ((x)<0?-(x):(x))
1057#define SyAbs(x) ((x)<0?-(x):(x))
1058
1059/* binary file type, here the same as text file */
1060typedef FILE *BFILE;
1061#define TSyBfile BFILE
1062
1063/* sy_findfile parameter */
1064#define SYC_FF_NAME 1
1065#define SYC_FF_DIR 2
1066#define SYC_FF_EXT 4
1067#define cSyFfName 1
1068#define cSyFfDir 2
1069#define cSyFfExt 4
1070
1071/* deallocate memory */
1072#define sy_deallocmem(p) free(p)
1073#define SyDeallocMem(p) free(p)
1074
1075/* read logical name table */
1076#define sy_lognames(f,s) fo_readtable(f,s)
1077#define SyLogNames(f,s) fo_readtable(f,s)
1078
1079/* open text file */
1080/* #define sy_fopen(f,a) fo_fopen(f,a) */
1081/* routine implemented for it */
1082
1083/* close text file */
1084#define sy_fclose(f) fclose(f)
1085#define SyFclose(f) fclose(f)
1086
1087/* read from text file */
1088#define sy_fread(b,s,n,f) fread(b,s,n,f)
1089#define SyFread(b,s,n,f) fread(b,s,n,f)
1090
1091/* write to text file */
1092#define sy_fwrite(b,s,n,f) fwrite(b,s,n,f)
1093#define SyFwrite(b,s,n,f) fwrite(b,s,n,f)
1094
1095/* read from binary file */
1096#define sy_fbread(b,s,n,f) fread(b,s,n,f)
1097#define SyFbread(b,s,n,f) fread(b,s,n,f)
1098
1099/* write to binary file */
1100#define sy_fbwrite(b,s,n,f) fwrite(b,s,n,f)
1101#define SyFbwrite(b,s,n,f) fwrite(b,s,n,f)
1102
1103/* seek on binary file */
1104#define sy_fbseek(f,p,m) fseek(f,p,m)
1105#define SyFbseek(f,p,m) fseek(f,p,m)
1106
1107/* open binary file */
1108#define sy_fbopen(f,a) sy_fopen(f,a)
1109#define SyFbopen(f,a) sy_fopen(f,a)
1110
1111/* close binary file */
1112#define sy_fbclose(f) fclose(f)
1113#define SyFbclose(f) fclose(f)
1114
1115/* binary file operation failed */
1116#define sy_fbfailed(f) ((f)==NULL)
1117#define SyFbfailed(f) ((f)==NULL)
1118
1119/* call to operating system */
1120#define sy_system(c,s) system(c)
1121#define SySystem(c,s) system(c)
1122
1123/* delete file */
1124#define sy_fdelete(f) unlink(f)
1125#define SyFdelete(f) unlink(f)
1126
1127/* rename file */
1128#define sy_frename(f,t) rename(f,t)
1129#define SyFrename(f,t) rename(f,t)
1130
1131/* difference time, not implemented */
1132#define sy_difftime() 1.0
1133#define SyDifftime() 1.0
1134
1135
1136/* system constants */
1137/* ---------------- */
1138
1139/* maximum unsigned */
1140#define SYC_MAXUNSG 0xffffffffL
1141#define cSyMaxUnsg SYC_MAXUNSG
1142
1143/* maximum integer */
1144#define SYC_MAXINT 0x7fffffffL
1145#define cSyMaxInt SYC_MAXINT
1146
1147/* minimum integer */
1148#define SYC_MININT 0x80000000L
1149#define cSyMinInt SYC_MININT
1150
1151/* maximum long */
1152#define SYC_MAXLONG 0x7fffffffL
1153#define cSyMaxLong SYC_MAXLONG
1154
1155/* minimum long */
1156#define SYC_MINLONG 0x80000000L
1157#define cSyMinLong SYC_MINLONG
1158
1159/* open existing file to overwrite */
1160#define SYC_OPEN_OVWR "r+"
1161#define cSyOpenOvwr SYC_OPEN_OVWR
1162
1163
1164/* system specific types */
1165/* --------------------- */
1166
1167/* difference time */
1168typedef float DIFFTIME;
1169typedef float TSyDifftime;
1170
1171
1172/* not implemented routines */
1173#define sy_gettime(s) strcpy(s,SHC_TIMEDEFAULT)
1174#define SyGetTime(s) strcpy(s,SHC_TIMEDEFAULT)
1175#define sy_sharecpu()
1176#define SyShareCpu()
1177#define sy_alert(t) printf("%s",t)
1178#define SyAlert(t) printf("%s",t)
1179#define sy_initprocess()
1180#define SyInitProcess()
1181
1182
1183/* include fileopen */
1184#ifndef __FOUSRDEF
1185#include BC_FOUSRDEF
1186#endif
1187
1188
1189/*------------------------------------------------------------------------*/
1190/*    prototypes of routines of module SYSCALL.C                          */
1191/*------------------------------------------------------------------------*/
1192
1193
1194#define SyAllocMem sy_allocmem
1195
1196void *sy_allocmem( long cnt, int size, STATUS *status );
1197
1198/* allocates memory ("cnt" objects of size "size)
1199 *
1200 * parameters of routine
1201 * long     cnt;            input; number of objects
1202 * int      size;           input; size of each object
1203 * STATUS   *status;        output; return status
1204 */
1205
1206
1207/*------------------------------------------------------------------------*/
1208
1209
1210#define SyFindFile sy_findfile
1211
1212void sy_findfile( int request, char wild[], char filename[] );
1213
1214/* looks for files matching wild card string "wild". Returns filename of
1215 * file found or "\0" if not found.  "request" controls the returned
1216 * elements.  For example the value (SYC_FF_DIR|SYC_FF_NAME|SYC_FF_EXT)
1217 * means, that the returned string contains directory, file name and
1218 * extension.
1219 *
1220 * parameters of routine
1221 * int      request;        input; what elements (name,dir,extension)
1222 * char     *wild;          input; wild card string
1223 * char     *filename;      output; next file found
1224 */
1225
1226
1227/*------------------------------------------------------------------------*/
1228
1229
1230#define SyFopen sy_fopen
1231
1232FILE *sy_fopen( char file[], char access[] );
1233
1234/* opens file.  Backslashes "\" in the filename are converted to slashes "/"
1235 *
1236 * parameters of routine
1237 * char       file[];        input; filename of file to be opened
1238 * char       access[];      input; access string
1239 *                           returns pointer to file or NULL
1240 */
1241
1242
1243/*------------------------------------------------------------------------*/
1244
1245
1246#define SyRandom sy_random
1247
1248double sy_random( double ampl );
1249
1250/* creates random number with absolute value less than (or equal to)
1251 * "amp"
1252 *
1253 * parameters of routine
1254 * double               ampl;           input; max. amplitude; if zero, a new random
1255 *                                                                       series is started
1256 */
1257
1258
1259/*------------------------------------------------------------------------*/
1260
1261
1262#define SyRandomStr sy_randomstr
1263
1264void sy_randomstr( int lth, char str[] );
1265
1266/* creates random string of length "lth"
1267 *
1268 * parameters of routine
1269 * int        lth;      input; length of output string
1270 * char       str[];    output; random string
1271 */
1272
1273
1274/*------------------------------------------------------------------------*/
1275
1276
1277#define SyLocalInf sy_localinf
1278
1279void sy_localinf( char item[], char value[], STATUS *status );
1280
1281/* returns local info in "value"
1282 *
1283 * parameters of routine
1284 * char       item[];     input; info item
1285 * char       value[];    output; return value
1286 * STATUS     *status;    output; return status
1287 */
1288
1289
1290/*------------------------------------------------------------------------*/
1291
1292
1293
1294#endif /* BC_SUN */
1295
1296
1297
1298/******************************************************************
1299 ***                              END                           ***
1300 ******************************************************************/
1301
1302#endif /* __SYSBASE */
1303
Note: See TracBrowser for help on using the repository browser.