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 195... Line 195...
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
199
 *	void				E_assertion_failed
200
 *			PROTO_S ((CStringP, CStringP, unsigned))
200
 *			(CStringP, CStringP, unsigned)
201
 *
201
 *
202
 * This function will be called if an assertion fails.  It will be called with
202
 * 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
203
 * the text of the assertion, the name of the file in which the assertion was
204
 * written, and line on which it occured.
204
 * written, and line on which it occured.
205
 *
205
 *
206
 ***=== FROM ANSI ============================================================
206
 ***=== FROM ANSI ============================================================
207
 *
207
 *
208
 * The following ANSI C functions are declared:
208
 * The following ANSI C functions are declared:
209
 *
209
 *
210
 *	NoReturnT			abort
210
 *	NoReturnT			abort
211
 *			PROTO_S ((void))
211
 *			(void)
212
 *	GenericP			calloc
212
 *	GenericP			calloc
213
 *			PROTO_S ((SizeT length, SizeT size))
213
 *			(SizeT length, SizeT size)
214
 *	GenericP			malloc
214
 *	GenericP			malloc
215
 *			PROTO_S ((SizeT size))
215
 *			((SizeT size)
216
 *	NoReturnT			exit
216
 *	NoReturnT			exit
217
 *			PROTO_S ((int exit_code))
217
 *			(int exit_code)
218
 *	void				free
218
 *	void				free
219
 *			PROTO_S ((GenericP pointer))
219
 *			(GenericP pointer)
220
 *	CStringP			getenv
220
 *	CStringP			getenv
221
 *			PROTO_S ((CStringP name))
221
 *			(CStringP name)
222
 *	int				memcmp
222
 *	int				memcmp
223
 *			PROTO_S ((GenericP ptr1, GenericP ptr2, SizeT length))
223
 *			(GenericP ptr1, GenericP ptr2, SizeT length)
224
 *	GenericP			memcpy
224
 *	GenericP			memcpy
225
 *			PROTO_S ((GenericP to, GenericP from, SizeT length))
225
 *			(GenericP to, GenericP from, SizeT length)
226
 *	GenericP			memset
226
 *	GenericP			memset
227
 *			PROTO_S ((GenericP ptr, int val, SizeT length))
227
 *			(GenericP ptr, int val, SizeT length)
228
 *	GenericP			memchr
228
 *	GenericP			memchr
229
 *			PROTO_S ((GenericP ptr, int val, SizeT length))
229
 *			(GenericP ptr, int val, SizeT length)
230
 *	SizeT				strlen
230
 *	SizeT				strlen
231
 *			PROTO_S ((CStringP string))
231
 *			(CStringP string)
232
 *	int				strcmp
232
 *	int				strcmp
233
 *			PROTO_S ((CStringP string1, CStringP string2))
233
 *			(CStringP string1, CStringP string2)
234
 *	CStringP			strcpy
234
 *	CStringP			strcpy
235
 *			PROTO_S ((CStringP to, CStringP from))
235
 *			(CStringP to, CStringP from)
236
 *	CStringP			strchr
236
 *	CStringP			strchr
237
 *			PROTO_S ((CStringP string, int c))
237
 *			(CStringP string, int c)
238
 *	CStringP			strrchr
238
 *	CStringP			strrchr
239
 *			PROTO_S ((CStringP string, int c))
239
 *			(CStringP string, int c)
240
 *
240
 *
241
 * Also everything in <setjmp.h> and <stdio.h> is included (hopefully this is
241
 * 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
242
 * 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.
243
 * are absent on non-ANSI systems, support for them will need to be added.
244
 *
244
 *
245
 ***=== FUNCTIONS ============================================================
245
 ***=== FUNCTIONS ============================================================
246
 *
246
 *
247
 ** Function:	int			mkdir
247
 ** Function:	int			mkdir
248
 *			PROTO_S ((CStringP path, int mode))
248
 *			(CStringP path, int mode)
249
 ** Exceptions:
249
 ** Exceptions:
250
 *
250
 *
251
 * This function is only declared if the ``FS_MKDIR'' macro is defined.  This
251
 * 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
252
 * macro should also be tested before the function is used anywhere.  It is
253
 * the POSIX directory creation function.
253
 * the POSIX directory creation function.
254
 *
254
 *
255
 ** Function:	CStringP		strerror
255
 ** Function:	CStringP		strerror
256
 *			PROTO_S ((int error))
256
 *			(int error)
257
 ** Exceptions:
257
 ** Exceptions:
258
 *
258
 *
259
 * This function is only declared if the ``FS_STRERROR'' macro is defined.
259
 * 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
260
 * 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
261
 * is the ANSI function for obtaining a textual description of a system error
Line 400... Line 400...
400
 ** Macro:	NIL(type)
400
 ** Macro:	NIL(type)
401
 ** Exceptions:
401
 ** Exceptions:
402
 *
402
 *
403
 * This is the null pointer macro.  The argument is the type for which a null
403
 * This is the null pointer macro.  The argument is the type for which a null
404
 * pointer is required.
404
 * 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
 *
405
 *
448
 ** Macro:	UNION
406
 ** Macro:	UNION
449
 ** Exceptions:
407
 ** Exceptions:
450
 *
408
 *
451
 * This macro should be used to define union types that need initialisation.
409
 * This macro should be used to define union types that need initialisation.
Line 582... Line 540...
582
# endif /* defined (FS_NO_FILE_INFO) */
540
# endif /* defined (FS_NO_FILE_INFO) */
583
 
541
 
584
# ifdef FS_NO_STDC_HASH
542
# ifdef FS_NO_STDC_HASH
585
#  undef FS_STDC_HASH
543
#  undef FS_STDC_HASH
586
# endif /* defined (FS_NO_STDC_HASH) */
544
# endif /* defined (FS_NO_STDC_HASH) */
587
 
-
 
588
# ifdef FS_NO_PROTOTYPES
-
 
589
#  undef FS_PROTOTYPES
-
 
590
# endif /* defined (FS_NO_PROTOTYPES) */
-
 
591
# ifdef FS_PROTOTYPES
-
 
592
#  define PROTO_S(ansi) ansi
-
 
593
#  define PROTO_N(names)
-
 
594
#  define PROTO_T(types) (types)
-
 
595
#  define PROTO_X ,
-
 
596
#  define PROTO_Z() (void)
-
 
597
# else
-
 
598
#  ifdef __TenDRA__
-
 
599
#   pragma TenDRA weak prototype analysis on
-
 
600
#   pragma TenDRA keyword KW_WEAK for weak
-
 
601
#   define PROTO_S(ansi) KW_WEAK ansi
-
 
602
#   define PROTO_N(names) names
-
 
603
#   define PROTO_T(types) types;
-
 
604
#   define PROTO_X ;
-
 
605
#   define PROTO_Z() ()
-
 
606
#  else
-
 
607
#   define PROTO_S(ansi) ()
-
 
608
#   define PROTO_N(names) names
-
 
609
#   define PROTO_T(types) types;
-
 
610
#   define PROTO_X ;
-
 
611
#   define PROTO_Z() ()
-
 
612
#  endif /* defined (__TenDRA__) */
-
 
613
# endif /* defined (FS_PROTOTYPES) */
-
 
614
 
545
 
615
# ifdef FS_NO_VOID_PTR
546
# ifdef FS_NO_VOID_PTR
616
#  undef FS_VOID_PTR
547
#  undef FS_VOID_PTR
617
# endif /* defined (FS_NO_VOID_PTR) */
548
# endif /* defined (FS_NO_VOID_PTR) */
618
# ifdef FS_VOID_PTR
549
# ifdef FS_VOID_PTR
Line 677... Line 608...
677
# ifdef FS_NO_MKDIR
608
# ifdef FS_NO_MKDIR
678
#  undef FS_MKDIR
609
#  undef FS_MKDIR
679
# endif /* defined (FS_NO_MKDIR) */
610
# endif /* defined (FS_NO_MKDIR) */
680
 
611
 
681
# ifdef __GNUC__
612
# ifdef __GNUC__
682
typedef __volatile__ void NoReturnT;
613
typedef void NoReturnT;
683
# else
614
# else
684
#  ifdef __TenDRA__
615
#  ifdef __TenDRA__
685
#   pragma TenDRA type NoReturnT for bottom
616
#   pragma TenDRA type NoReturnT for bottom
686
#  else
617
#  else
687
#   define NoReturnT void
618
#   define NoReturnT void
Line 720... Line 651...
720
# else
651
# else
721
#  define INLINE
652
#  define INLINE
722
# endif /* defined (__GNUC__) */
653
# endif /* defined (__GNUC__) */
723
 
654
 
724
# ifdef FS_MKDIR
655
# ifdef FS_MKDIR
725
extern int			mkdir
-
 
726
	PROTO_S ((CStringP, int));
656
extern int	mkdir(CStringP, int);
727
# endif /* defined (FS_MKDIR) */
657
# endif /* defined (FS_MKDIR) */
728
 
658
 
729
# ifdef FS_ASSERT
659
# ifdef FS_ASSERT
730
extern void			E_assertion_failed
-
 
731
	PROTO_S ((CStringP, CStringP, unsigned));
660
extern void	E_assertion_failed(CStringP, CStringP, unsigned);
732
#  ifdef FS_STDC_HASH
661
#  ifdef FS_STDC_HASH
733
#   define ASSERT(a) \
662
#   define ASSERT(a) \
734
if (!(a)) { \
663
if (!(a)) { \
735
    E_assertion_failed (#a, __FILE__, (unsigned) __LINE__); \
664
    E_assertion_failed (#a, __FILE__, (unsigned) __LINE__); \
736
    abort (); \
665
    abort (); \
Line 771... Line 700...
771
typedef PO_SIZE_T_TYPE SizeT, *SizeP;
700
typedef PO_SIZE_T_TYPE SizeT, *SizeP;
772
#  else
701
#  else
773
typedef unsigned SizeT, *SizeP;
702
typedef unsigned SizeT, *SizeP;
774
#  endif /* defined (PO_SIZE_T_TYPE) */
703
#  endif /* defined (PO_SIZE_T_TYPE) */
775
 
704
 
776
extern NoReturnT		abort
705
extern NoReturnT	abort(void);
777
	PROTO_S ((void));
-
 
778
extern GenericP			calloc
706
extern GenericP		calloc(SizeT, SizeT);
779
	PROTO_S ((SizeT, SizeT));
-
 
780
extern GenericP			malloc
707
extern GenericP		malloc(SizeT);
781
	PROTO_S ((SizeT));
-
 
782
extern NoReturnT		exit
708
extern NoReturnT	exit(int);
783
	PROTO_S ((int));
-
 
784
extern void			free
709
extern void		free(GenericP);
785
	PROTO_S ((GenericP));
-
 
786
extern CStringP			getenv
710
extern CStringP		getenv(CStringP);
787
	PROTO_S ((CStringP));
-
 
788
#  ifndef __GNUC__
711
#  ifndef __GNUC__
789
extern int			memcmp
-
 
790
	PROTO_S ((GenericP, GenericP, SizeT));
712
extern int		memcmp(GenericP, GenericP, SizeT);
791
#  endif /* defined (__GNUC__) */
713
#  endif /* defined (__GNUC__) */
792
#  ifndef __GNUC__
714
#  ifndef __GNUC__
793
extern GenericP			memcpy
-
 
794
	PROTO_S ((GenericP, GenericP, SizeT));
715
extern GenericP		memcpy(GenericP, GenericP, SizeT);
795
#  endif /* defined (__GNUC__) */
716
#  endif /* defined (__GNUC__) */
796
extern GenericP			memset
-
 
797
	PROTO_S ((GenericP, int, SizeT));
717
extern GenericP		memset(GenericP, int, SizeT);
798
extern GenericP			memchr
-
 
799
	PROTO_S ((GenericP, int, SizeT));
718
extern GenericP		memchr(GenericP, int, SizeT);
800
#  ifndef __GNUC__
719
#  ifndef __GNUC__
801
extern SizeT			strlen
720
extern SizeT		strlen(CStringP);
802
	PROTO_S ((CStringP));
-
 
803
#  endif /* defined (__GNUC__) */
721
#  endif /* defined (__GNUC__) */
804
#  ifndef __GNUC__
722
#  ifndef __GNUC__
805
extern int			strcmp
-
 
806
	PROTO_S ((CStringP, CStringP));
723
extern int		strcmp(CStringP, CStringP);
807
#  endif /* defined (__GNUC__) */
724
#  endif /* defined (__GNUC__) */
808
#  ifndef __GNUC__
725
#  ifndef __GNUC__
809
extern int			strncmp
-
 
810
	PROTO_S ((CStringP, CStringP, SizeT));
726
extern int		strncmp(CStringP, CStringP, SizeT);
811
#  endif /* defined (__GNUC__) */
727
#  endif /* defined (__GNUC__) */
812
#  ifndef __GNUC__
728
#  ifndef __GNUC__
813
extern CStringP			strcpy
-
 
814
	PROTO_S ((CStringP, CStringP));
729
extern CStringP		strcpy(CStringP, CStringP);
815
#  endif /* defined (__GNUC__) */
730
#  endif /* defined (__GNUC__) */
816
extern CStringP			strchr
731
extern CStringP		strchr(CStringP, int);
817
	PROTO_S ((CStringP, int));
-
 
818
extern CStringP			strrchr
732
extern CStringP		strrchr(CStringP, int);
819
	PROTO_S ((CStringP, int));
-
 
820
extern int			errno;
733
extern int		errno;
821
#  ifdef FS_STRERROR
734
#  ifdef FS_STRERROR
822
extern CStringP			strerror
735
extern CStringP		strerror(int);
823
	PROTO_S ((int));
-
 
824
#  endif /* defined (FS_STRERROR) */
736
#  endif /* defined (FS_STRERROR) */
825
 
737
 
826
#  include <setjmp.h>
738
#  include <setjmp.h>
827
#  include <stdio.h>
739
#  include <stdio.h>
828
 
740
 
Line 837... Line 749...
837
# endif /* !defined (CHAR_BIT) */
749
# endif /* !defined (CHAR_BIT) */
838
 
750
 
839
# ifndef EXIT_SUCCESS
751
# ifndef EXIT_SUCCESS
840
#  ifdef PO_EXIT_SUCCESS
752
#  ifdef PO_EXIT_SUCCESS
841
#   define EXIT_SUCCESS PO_EXIT_SUCCESS
753
#   define EXIT_SUCCESS PO_EXIT_SUCCESS
842
#  else
754
#  else
843
#   define EXIT_SUCCESS (0)
755
#   define EXIT_SUCCESS (0)
844
#  endif /* defined (PO_EXIT_SUCCESS) */
756
#  endif /* defined (PO_EXIT_SUCCESS) */
845
# endif /* !defined (EXIT_SUCCESS) */
757
# endif /* !defined (EXIT_SUCCESS) */
846
 
758
 
847
# ifndef EXIT_FAILURE
759
# ifndef EXIT_FAILURE
Line 849... Line 761...
849
#   define EXIT_FAILURE PO_EXIT_FAILURE
761
#   define EXIT_FAILURE PO_EXIT_FAILURE
850
#  else
762
#  else
851
#   define EXIT_FAILURE (1)
763
#   define EXIT_FAILURE (1)
852
#  endif /* defined (PO_EXIT_FAILURE) */
764
#  endif /* defined (PO_EXIT_FAILURE) */
853
# endif /* !defined (EXIT_FAILURE) */
765
# endif /* !defined (EXIT_FAILURE) */
854
 
766
 
855
# ifndef UINT_MAX
767
# ifndef UINT_MAX
856
#  ifdef PO_UINT_MAX
768
#  ifdef PO_UINT_MAX
857
#   define UINT_MAX PO_UINT_MAX
769
#   define UINT_MAX PO_UINT_MAX
858
#  else
770
#  else
859
#   define UINT_MAX (~(unsigned) 0)
771
#   define UINT_MAX (~(unsigned) 0)
Line 883... Line 795...
883
#   define SEEK_END (2)
795
#   define SEEK_END (2)
884
#  endif /* defined (PO_SEEK_END) */
796
#  endif /* defined (PO_SEEK_END) */
885
# endif /* !defined (SEEK_END) */
797
# endif /* !defined (SEEK_END) */
886
 
798
 
887
# ifdef FS_SYS_ERRLIST
799
# ifdef FS_SYS_ERRLIST
888
extern int			sys_nerr;
800
extern int		sys_nerr;
889
extern CStringP			sys_errlist [];
801
extern CStringP		sys_errlist[];
890
# endif /* defined (FS_SYS_ERRLIST) */
802
# endif /* defined (FS_SYS_ERRLIST) */
891
 
-
 
892
# ifdef X
-
 
893
# undef X
-
 
894
# endif
-
 
895
# define X PROTO_X
-
 
896
 
803
 
897
#endif /* !defined (H_OS_INTERFACE) */
804
#endif /* !defined (H_OS_INTERFACE) */