1 /*
2  * Copyright 1993 Network Computing Devices, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation for any purpose is hereby granted without fee, provided
6  * that the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name Network Computing Devices, Inc. not be
9  * used in advertising or publicity pertaining to distribution of this
10  * software without specific, written prior permission.
11  *
12  * THIS SOFTWARE IS PROVIDED 'AS-IS'.  NETWORK COMPUTING DEVICES, INC.,
13  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
14  * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15  * PARTICULAR PURPOSE, OR NONINFRINGEMENT.  IN NO EVENT SHALL NETWORK
16  * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
17  * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
18  * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
19  * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  *
22  * $NCDId: @(#)fileutil.h,v 1.7 1994/09/01 01:14:27 greg Exp $
23  */
24 
25 #ifndef	_FILEUTIL_H_
26 #define	_FILEUTIL_H_
27 
28 #include <audio/audio.h>	/* for AuInt32 and AuUint32 */
29 
30 #ifndef _FileConst
31 #define _FileConst const
32 #endif				/* _FileConst */
33 
34 #ifndef _FUNCPROTOBEGIN
35 #ifdef __cplusplus			/* for C++ V2.0 */
36 #define _FUNCPROTOBEGIN extern "C" {	/* do not leave open across includes */
37 #define _FUNCPROTOEND }
38 #else
39 #define _FUNCPROTOBEGIN
40 #define _FUNCPROTOEND
41 #endif
42 #endif /* _FUNCPROTOBEGIN */
43 
44 #define NAS_LITTLE_ENDIAN 		(*(char *) &endian)
45 #define NAS_BIG_ENDIAN 		(!NAS_LITTLE_ENDIAN)
46 static int      endian = 1;
47 
48 /* byte swap a AuInt32 */
49 #define swapl(x, n) { n = ((char *) (x))[0];\
50 	     ((char *) (x))[0] = ((char *) (x))[3];\
51 	     ((char *) (x))[3] = n;\
52 	     n = ((char *) (x))[1];\
53 	     ((char *) (x))[1] = ((char *) (x))[2];\
54 	     ((char *) (x))[2] = n; }
55 
56 
57 /* byte swap a short */
58 #define swaps(x, n) { n = ((char *) (x))[0];\
59 		 ((char *) (x))[0] = ((char *) (x))[1];\
60 		 ((char *) (x))[1] = n; }
61 
62 _FUNCPROTOBEGIN
63 
64 #ifndef mips
65 extern unsigned short
66 FileSwapS(
67 			unsigned short
68 );
69 #endif	/* mips */
70 
71 extern AuUint32
72 FileSwapL(
73 			AuUint32
74 );
75 
76 extern unsigned short
77 FileReadS(
78 			FILE	*,
79                         int			/* swap? */
80 );
81 
82 extern AuUint32
83 FileReadL(
84 			FILE	*,
85                         int			/* swap? */
86 );
87 
88 #ifndef mips
89 extern int
90 FileWriteS(
91                         unsigned short,
92 			FILE	*,
93                         int			/* swap? */
94 );
95 #endif
96 
97 extern int
98 FileWriteL(
99                         AuUint32,
100 			FILE	*,
101                         int			/* swap? */
102 );
103 
104 extern char	*
105 FileCommentFromFilename(
106                         const char	*		/* file name */
107 );
108 
109 _FUNCPROTOEND
110 
111 #endif				/* _FILEUTIL_H_ */
112