Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line 194... Line 194...
194
 * <stdio.h>.  If the standard library is not ANSI compliant and no value is
194
 * <stdio.h>.  If the standard library is not ANSI compliant and no value is
195
 * provided, then ``0'', ``1'' and ``2'' will be used.
195
 * provided, then ``0'', ``1'' and ``2'' will be used.
196
 *
196
 *
197
 * This file also requires that one external function be provided:
197
 * This file also requires that one external function be provided:
198
 *
198
 *
199
 *	void				E_assertion_failed
-
 
200
 *			PROTO_S ((CStringP, CStringP, unsigned))
199
 *	void E_assertion_failed(CStringP, CStringP, unsigned)
201
 *
200
 *
202
 * This function will be called if an assertion fails.  It will be called with
201
 * This function will be called if an assertion fails.  It will be called with
203
 * the text of the assertion, the name of the file in which the assertion was
202
 * the text of the assertion, the name of the file in which the assertion was
204
 * written, and line on which it occured.
203
 * written, and line on which it occured.
205
 *
204
 *
206
 ***=== FROM ANSI ============================================================
205
 ***=== FROM ANSI ============================================================
207
 *
206
 *
208
 * The following ANSI C functions are declared:
207
 * The following ANSI C functions are declared:
209
 *
208
 *
210
 *	NoReturnT			abort
209
 *	NoReturnT			abort
211
 *			PROTO_S ((void))
210
 *			(void)
212
 *	GenericP			calloc
211
 *	GenericP			calloc
213
 *			PROTO_S ((SizeT length, SizeT size))
212
 *			(SizeT length, SizeT size)
214
 *	GenericP			malloc
213
 *	GenericP			malloc
215
 *			PROTO_S ((SizeT size))
214
 *			(SizeT size)
216
 *	NoReturnT			exit
215
 *	NoReturnT			exit
217
 *			PROTO_S ((int exit_code))
216
 *			(int exit_code)
218
 *	void				free
217
 *	void				free
219
 *			PROTO_S ((GenericP pointer))
218
 *			(GenericP pointer)
220
 *	CStringP			getenv
219
 *	CStringP			getenv
221
 *			PROTO_S ((CStringP name))
220
 *			(CStringP name)
222
 *	int				memcmp
221
 *	int				memcmp
223
 *			PROTO_S ((GenericP ptr1, GenericP ptr2, SizeT length))
222
 *			(GenericP ptr1, GenericP ptr2, SizeT length)
224
 *	GenericP			memcpy
223
 *	GenericP			memcpy
225
 *			PROTO_S ((GenericP to, GenericP from, SizeT length))
224
 *			(GenericP to, GenericP from, SizeT length)
226
 *	GenericP			memset
225
 *	GenericP			memset
227
 *			PROTO_S ((GenericP ptr, int val, SizeT length))
226
 *			(GenericP ptr, int val, SizeT length)
228
 *	GenericP			memchr
227
 *	GenericP			memchr
229
 *			PROTO_S ((GenericP ptr, int val, SizeT length))
228
 *			(GenericP ptr, int val, SizeT length)
230
 *	SizeT				strlen
229
 *	SizeT				strlen
231
 *			PROTO_S ((CStringP string))
230
 *			(CStringP string)
232
 *	int				strcmp
231
 *	int				strcmp
233
 *			PROTO_S ((CStringP string1, CStringP string2))
232
 *			(CStringP string1, CStringP string2)
234
 *	CStringP			strcpy
233
 *	CStringP			strcpy
235
 *			PROTO_S ((CStringP to, CStringP from))
234
 *			(CStringP to, CStringP from)
236
 *	CStringP			strchr
235
 *	CStringP			strchr
237
 *			PROTO_S ((CStringP string, int c))
236
 *			(CStringP string, int c)
238
 *	CStringP			strrchr
237
 *	CStringP			strrchr
239
 *			PROTO_S ((CStringP string, int c))
238
 *			(CStringP string, int c)
240
 *
239
 *
241
 * Also everything in <setjmp.h> and <stdio.h> is included (hopefully this is
240
 * Also everything in <setjmp.h> and <stdio.h> is included (hopefully this is
242
 * sufficiently common to be used even on non-ANSI platforms).  Where features
241
 * sufficiently common to be used even on non-ANSI platforms).  Where features
243
 * are absent on non-ANSI systems, support for them will need to be added.
242
 * are absent on non-ANSI systems, support for them will need to be added.
244
 *
243
 *
245
 ***=== FUNCTIONS ============================================================
244
 ***=== FUNCTIONS ============================================================
246
 *
245
 *
247
 ** Function:	int			mkdir
246
 ** Function:	int			mkdir
248
 *			PROTO_S ((CStringP path, int mode))
247
 *			(CStringP path, int mode)
249
 ** Exceptions:
248
 ** Exceptions:
250
 *
249
 *
251
 * This function is only declared if the ``FS_MKDIR'' macro is defined.  This
250
 * This function is only declared if the ``FS_MKDIR'' macro is defined.  This
252
 * macro should also be tested before the function is used anywhere.  It is
251
 * macro should also be tested before the function is used anywhere.  It is
253
 * the POSIX directory creation function.
252
 * the POSIX directory creation function.
254
 *
253
 *
255
 ** Function:	CStringP		strerror
254
 ** Function:	CStringP		strerror
256
 *			PROTO_S ((int error))
255
 *			(int error)
257
 ** Exceptions:
256
 ** Exceptions:
258
 *
257
 *
259
 * This function is only declared if the ``FS_STRERROR'' macro is defined.
258
 * This function is only declared if the ``FS_STRERROR'' macro is defined.
260
 * This macro should also be tested before the function is used anywhere.  It
259
 * This macro should also be tested before the function is used anywhere.  It
261
 * is the ANSI function for obtaining a textual description of a system error
260
 * is the ANSI function for obtaining a textual description of a system error
Line 400... Line 399...
400
 ** Macro:	NIL(type)
399
 ** Macro:	NIL(type)
401
 ** Exceptions:
400
 ** Exceptions:
402
 *
401
 *
403
 * This is the null pointer macro.  The argument is the type for which a null
402
 * This is the null pointer macro.  The argument is the type for which a null
404
 * pointer is required.
403
 * pointer is required.
405
 *
-
 
406
 ** Macro:	PROTO_S (prototype)
-
 
407
 ** Exceptions:
-
 
408
 *
-
 
409
 * If prototypes are supported, this expands to the prototyped function
-
 
410
 * argument declaration provided.  If they are not supported, it expands to an
-
 
411
 * empty argument list.  It is necessary to use two sets of parentheses, as
-
 
412
 * the prototype may contain commas.  This macro should be used to declare all
-
 
413
 * functions within the program (see the function declarations later on in the
-
 
414
 * file for some examples of its use).
-
 
415
 *
-
 
416
 ** Macro:	PROTO_N (names)
-
 
417
 ** Macro:	PROTO_T (types)
-
 
418
 ** Macro:	X
-
 
419
 ** Macro:	PROTO_Z ()
-
 
420
 ** Exceptions:
-
 
421
 *
-
 
422
 * The "PROTO_N" and "PROTO_T" macros should be used for argument
-
 
423
 * specifications when defining functions.  If prototypes are supported, these
-
 
424
 * macros expand to a prototyped argument specification; if they are not
-
 
425
 * supported, the macros expand to an unprototyped argument specification.
-
 
426
 * The "PROTO_N" macro takes a comma separated list of argument names (in a
-
 
427
 * similar manner to the "PROTO_S" macro).  The "PROTO_T" macro takes a list
-
 
428
 * of declarations for those names, separated by an "X" macro.  If the
-
 
429
 * function takes no parameters, then the "PROTO_Z" macro should be used
-
 
430
 * instead.  An example of the definition of the ``main'' function in a
-
 
431
 * program is:
-
 
432
 *
-
 
433
 *	int
-
 
434
 *	main PROTO_N ((argc, argv))
-
 
435
 *	     PROTO_T (int argc X char **argv)
-
 
436
 *	{
-
 
437
 *	}
-
 
438
 *
-
 
439
 * An example of the definition of a function with no parameters is:
-
 
440
 *
-
 
441
 *	void
-
 
442
 *	no_args_proc PROTO_Z ()
-
 
443
 *	{
-
 
444
 *	}
-
 
445
 * 
-
 
446
 * Other functions should be defined in a similar manner.
-
 
447
 *
404
 *
448
 ** Macro:	UNION
405
 ** Macro:	UNION
449
 ** Exceptions:
406
 ** Exceptions:
450
 *
407
 *
451
 * This macro should be used to define union types that need initialisation.
408
 * This macro should be used to define union types that need initialisation.
Line 579... Line 536...
579
# endif /* defined (FS_NO_FILE_INFO) */
536
# endif /* defined (FS_NO_FILE_INFO) */
580
 
537
 
581
# ifdef FS_NO_STDC_HASH
538
# ifdef FS_NO_STDC_HASH
582
#  undef FS_STDC_HASH
539
#  undef FS_STDC_HASH
583
# endif /* defined (FS_NO_STDC_HASH) */
540
# endif /* defined (FS_NO_STDC_HASH) */
584
 
-
 
585
# ifdef FS_NO_PROTOTYPES
-
 
586
#  undef FS_PROTOTYPES
-
 
587
# endif /* defined (FS_NO_PROTOTYPES) */
-
 
588
# ifdef FS_PROTOTYPES
-
 
589
#  define PROTO_S(ansi) ansi
-
 
590
#  define PROTO_N(names)
-
 
591
#  define PROTO_T(types) (types)
-
 
592
#  define PROTO_X ,
-
 
593
#  define PROTO_Z() (void)
-
 
594
# else
-
 
595
#  ifdef __TenDRA__
-
 
596
#   pragma TenDRA weak prototype analysis on
-
 
597
#   pragma TenDRA keyword KW_WEAK for weak
-
 
598
#   define PROTO_S(ansi) KW_WEAK ansi
-
 
599
#   define PROTO_N(names) names
-
 
600
#   define PROTO_T(types) types;
-
 
601
#   define PROTO_X ;
-
 
602
#   define PROTO_Z() ()
-
 
603
#  else
-
 
604
#   define PROTO_S(ansi) ()
-
 
605
#   define PROTO_N(names) names
-
 
606
#   define PROTO_T(types) types;
-
 
607
#   define PROTO_X ;
-
 
608
#   define PROTO_Z() ()
-
 
609
#  endif /* defined (__TenDRA__) */
-
 
610
# endif /* defined (FS_PROTOTYPES) */
-
 
611
 
541
 
612
# ifdef FS_NO_VOID_PTR
542
# ifdef FS_NO_VOID_PTR
613
#  undef FS_VOID_PTR
543
#  undef FS_VOID_PTR
614
# endif /* defined (FS_NO_VOID_PTR) */
544
# endif /* defined (FS_NO_VOID_PTR) */
615
# ifdef FS_VOID_PTR
545
# ifdef FS_VOID_PTR
Line 655... Line 585...
655
# endif /* !defined (FS_ENUM) */
585
# endif /* !defined (FS_ENUM) */
656
 
586
 
657
# ifdef FS_NO_ANSI_ENVIRON
587
# ifdef FS_NO_ANSI_ENVIRON
658
#  undef FS_ANSI_ENVIRON
588
#  undef FS_ANSI_ENVIRON
659
# endif /* defined (FS_NO_ANSI_ENVIRON) */
589
# endif /* defined (FS_NO_ANSI_ENVIRON) */
660
 
590
 
661
# ifdef FS_ANSI_ENVIRON
591
# ifdef FS_ANSI_ENVIRON
662
#  define FS_BINARY_STDIO
592
#  define FS_BINARY_STDIO
663
#  define FS_STRERROR
593
#  define FS_STRERROR
664
# endif /* defined (FS_ANSI_ENVIRON) */
594
# endif /* defined (FS_ANSI_ENVIRON) */
665
# ifdef FS_NO_BINARY_STDIO
595
# ifdef FS_NO_BINARY_STDIO
666
#  undef FS_BINARY_STDIO
596
#  undef FS_BINARY_STDIO
Line 674... Line 604...
674
# ifdef FS_NO_MKDIR
604
# ifdef FS_NO_MKDIR
675
#  undef FS_MKDIR
605
#  undef FS_MKDIR
676
# endif /* defined (FS_NO_MKDIR) */
606
# endif /* defined (FS_NO_MKDIR) */
677
 
607
 
678
# ifdef __GNUC__
608
# ifdef __GNUC__
679
typedef __volatile__ void NoReturnT;
609
typedef void NoReturnT;
680
# else
610
# else
681
#  ifdef __TenDRA__
611
#  ifdef __TenDRA__
682
#   pragma TenDRA type NoReturnT for bottom
612
#   pragma TenDRA type NoReturnT for bottom
683
#  else
613
#  else
684
#   define NoReturnT void
614
#   define NoReturnT void
685
#  endif /* defined (__TenDRA__) */
615
#  endif /* defined (__TenDRA__) */
Line 704... Line 634...
704
    CMP_LT,
634
    CMP_LT,
705
    CMP_EQ,
635
    CMP_EQ,
706
    CMP_GT
636
    CMP_GT
707
} CmpT, *CmpP;
637
} CmpT, *CmpP;
708
# endif /* defined (FS_NO_ENUM) */
638
# endif /* defined (FS_NO_ENUM) */
709
 
639
 
710
# define NIL(type) ((type) (0))
640
# define NIL(type) ((type) (0))
711
 
641
 
712
# define FALSE (0)
642
# define FALSE (0)
713
# define TRUE (1)
643
# define TRUE (1)
714
 
644
 
Line 718... Line 648...
718
#  define INLINE
648
#  define INLINE
719
# endif /* defined (__GNUC__) */
649
# endif /* defined (__GNUC__) */
720
 
650
 
721
# ifdef FS_MKDIR
651
# ifdef FS_MKDIR
722
extern int			mkdir
652
extern int			mkdir
723
	PROTO_S ((CStringP, int));
653
	(CStringP, int);
724
# endif /* defined (FS_MKDIR) */
654
# endif /* defined (FS_MKDIR) */
725
 
655
 
726
# ifdef FS_ASSERT
656
# ifdef FS_ASSERT
727
extern void			E_assertion_failed
657
extern void			E_assertion_failed
728
	PROTO_S ((CStringP, CStringP, unsigned));
658
	(CStringP, CStringP, unsigned);
729
#  ifdef FS_STDC_HASH
659
#  ifdef FS_STDC_HASH
730
#   define ASSERT(a) \
660
#   define ASSERT(a) \
731
if (!(a)) { \
661
if (!(a)) { \
732
    E_assertion_failed (#a, __FILE__, (unsigned) __LINE__); \
662
    E_assertion_failed (#a, __FILE__, (unsigned) __LINE__); \
733
    abort (); \
663
    abort (); \
Line 768... Line 698...
768
typedef PO_SIZE_T_TYPE SizeT, *SizeP;
698
typedef PO_SIZE_T_TYPE SizeT, *SizeP;
769
#  else
699
#  else
770
typedef unsigned SizeT, *SizeP;
700
typedef unsigned SizeT, *SizeP;
771
#  endif /* defined (PO_SIZE_T_TYPE) */
701
#  endif /* defined (PO_SIZE_T_TYPE) */
772
 
702
 
773
extern NoReturnT		abort
703
extern NoReturnT abort(void);
774
	PROTO_S ((void));
-
 
775
extern GenericP			calloc
704
extern GenericP calloc(SizeT, SizeT);
776
	PROTO_S ((SizeT, SizeT));
-
 
777
extern GenericP			malloc
705
extern GenericP	malloc(SizeT);
778
	PROTO_S ((SizeT));
-
 
779
extern NoReturnT		exit
706
extern NoReturnT exit(int);
780
	PROTO_S ((int));
-
 
781
extern void			free
707
extern void free(GenericP);
782
	PROTO_S ((GenericP));
-
 
783
extern CStringP			getenv
708
extern CStringP	getenv(CStringP);
784
	PROTO_S ((CStringP));
-
 
785
#  ifndef __GNUC__
709
#  ifndef __GNUC__
786
extern int			memcmp
-
 
787
	PROTO_S ((GenericP, GenericP, SizeT));
710
extern int memcmp(GenericP, GenericP, SizeT);
788
#  endif /* defined (__GNUC__) */
711
#  endif /* defined (__GNUC__) */
789
#  ifndef __GNUC__
712
#  ifndef __GNUC__
790
extern GenericP			memcpy
-
 
791
	PROTO_S ((GenericP, GenericP, SizeT));
713
extern GenericP	memcpy(GenericP, GenericP, SizeT);
792
#  endif /* defined (__GNUC__) */
714
#  endif /* defined (__GNUC__) */
793
extern GenericP			memset
-
 
794
	PROTO_S ((GenericP, int, SizeT));
715
extern GenericP	memset(GenericP, int, SizeT);
795
extern GenericP			memchr
-
 
796
	PROTO_S ((GenericP, int, SizeT));
716
extern GenericP memchr(GenericP, int, SizeT);
797
#  ifndef __GNUC__
717
#  ifndef __GNUC__
798
extern SizeT			strlen
718
extern SizeT strlen(CStringP);
799
	PROTO_S ((CStringP));
-
 
800
#  endif /* defined (__GNUC__) */
719
#  endif /* defined (__GNUC__) */
801
#  ifndef __GNUC__
720
#  ifndef __GNUC__
802
extern int			strcmp
-
 
803
	PROTO_S ((CStringP, CStringP));
721
extern int strcmp(CStringP, CStringP);
804
#  endif /* defined (__GNUC__) */
722
#  endif /* defined (__GNUC__) */
805
#  ifndef __GNUC__
723
#  ifndef __GNUC__
806
extern CStringP			strcpy
-
 
807
	PROTO_S ((CStringP, CStringP));
724
extern CStringP strcpy(CStringP, CStringP);
808
#  endif /* defined (__GNUC__) */
725
#  endif /* defined (__GNUC__) */
809
extern CStringP			strchr
726
extern CStringP strchr(CStringP, int);
810
	PROTO_S ((CStringP, int));
-
 
811
extern CStringP			strrchr
727
extern CStringP	strrchr(CStringP, int);
812
	PROTO_S ((CStringP, int));
-
 
813
extern int			errno;
728
extern int errno;
814
#  ifdef FS_STRERROR
729
#  ifdef FS_STRERROR
815
extern CStringP			strerror
730
extern CStringP strerror(int);
816
	PROTO_S ((int));
-
 
817
#  endif /* defined (FS_STRERROR) */
731
#  endif /* defined (FS_STRERROR) */
818
 
732
 
819
#  include <setjmp.h>
733
#  include <setjmp.h>
820
#  include <stdio.h>
734
#  include <stdio.h>
821
 
735
 
Line 879... Line 793...
879
 
793
 
880
# ifdef FS_SYS_ERRLIST
794
# ifdef FS_SYS_ERRLIST
881
extern int			sys_nerr;
795
extern int			sys_nerr;
882
extern CStringP			sys_errlist [];
796
extern CStringP			sys_errlist [];
883
# endif /* defined (FS_SYS_ERRLIST) */
797
# endif /* defined (FS_SYS_ERRLIST) */
884
 
-
 
885
# ifdef X
-
 
886
# undef X
-
 
887
# endif
-
 
888
# define X PROTO_X
-
 
889
 
798
 
890
#endif /* !defined (H_OS_INTERFACE) */
799
#endif /* !defined (H_OS_INTERFACE) */