Subversion Repositories filter_foundry

Rev

Rev 193 | Rev 268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 193 Rev 259
Line 1... Line 1...
1
/*
1
/*
2
        This file is part of a common library
2
        This file is part of a common library
3
    Copyright (C) 2002-2010 Toby Thain, toby@telegraphics.com.au
3
    Copyright (C) 2002-2010 Toby Thain, toby@telegraphics.com.au
4
 
4
 
5
    This program is free software; you can redistribute it and/or modify
5
    This program is free software; you can redistribute it and/or modify
6
    it under the terms of the GNU General Public License as published by
6
    it under the terms of the GNU General Public License as published by
7
    the Free Software Foundation; either version 2 of the License, or
7
    the Free Software Foundation; either version 2 of the License, or
8
    (at your option) any later version.
8
    (at your option) any later version.
9
 
9
 
10
    This program is distributed in the hope that it will be useful,
10
    This program is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    GNU General Public License for more details.
13
    GNU General Public License for more details.
14
 
14
 
15
    You should have received a copy of the GNU General Public License
15
    You should have received a copy of the GNU General Public License
16
    along with this program; if not, write to the Free Software
16
    along with this program; if not, write to the Free Software
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
*/
18
*/
19
 
19
 
20
#ifndef FILE_COMPAT_H
20
#ifndef FILE_COMPAT_H
21
#define FILE_COMPAT_H
21
#define FILE_COMPAT_H
22
 
22
 
23
#ifdef macintosh
23
#ifdef macintosh
24
 
24
 
25
        #include <files.h>
25
        #include <files.h>
26
 
26
 
27
        #ifndef _INT16_T
27
        #ifndef _INT16_T
28
                typedef SInt16 int16_t;
28
                typedef SInt16 int16_t;
29
        #endif
29
        #endif
30
        #if !defined(_INT16_T) && !defined(_MACHTYPES_H_)
30
        #if !defined(_INT16_T) && !defined(_MACHTYPES_H_)
31
                typedef SInt32 int32_t;
31
                typedef SInt32 int32_t;
32
        #endif
32
        #endif
33
 
33
 
34
        #if defined(WANT_LARGE_FILES) && ! TARGET_CPU_68K
34
        #if defined(WANT_LARGE_FILES) && ! TARGET_CPU_68K
35
                // large file support (HFS+)
35
                // large file support (HFS+)
36
                typedef SInt16 FILEREF;
36
                typedef SInt16 FILEREF;
37
                typedef SInt64 FILEPOS;
37
                typedef SInt64 FILEPOS;
38
                typedef ByteCount FILECOUNT;
38
                typedef ByteCount FILECOUNT;
39
 
39
 
40
                #define FSPOPENDF fspopendf_large
40
                #define FSPOPENDF fspopendf_large
41
                #define FSCLOSE FSCloseFork
41
                #define FSCLOSE FSCloseFork
42
                #define FSREAD fsread_large
42
                #define FSREAD fsread_large
43
                #define FSWRITE fswrite_large
43
                #define FSWRITE fswrite_large
44
                #define GETFPOS getfpos_large
44
                #define GETFPOS getfpos_large
45
                #define SETFPOS setfpos_large
45
                #define SETFPOS setfpos_large
46
                #define GETEOF geteof_large
46
                #define GETEOF geteof_large
47
                #define SETEOF seteof_large
47
                #define SETEOF seteof_large
48
 
48
 
49
                Boolean host_has_forks(void);
49
                Boolean host_has_forks(void);
50
        #else
50
        #else
51
                // old-style HFS
51
                // old-style HFS
52
                typedef short FILEREF;
52
                typedef short FILEREF;
53
                typedef long FILEPOS,FILECOUNT;
53
                typedef long FILEPOS,FILECOUNT;
54
 
54
 
55
                #define FSPOPENDF FSpOpenDF
55
                #define FSPOPENDF FSpOpenDF
56
                #define FSCLOSE FSClose
56
                #define FSCLOSE FSClose
57
                #define FSREAD FSRead
57
                #define FSREAD FSRead
58
                #define FSWRITE FSWrite
58
                #define FSWRITE FSWrite
59
                #define GETFPOS GetFPos
59
                #define GETFPOS GetFPos
60
                #define SETFPOS SetFPos
60
                #define SETFPOS SetFPos
61
                #define GETEOF GetEOF
61
                #define GETEOF GetEOF
62
                #define SETEOF SetEOF
62
                #define SETEOF SetEOF
63
 
63
 
64
                #define host_has_forks() false
64
                #define host_has_forks() false
65
        #endif
65
        #endif
66
 
66
 
67
        extern Boolean has_forks;
67
        extern Boolean has_forks;
68
 
68
 
69
#else // not macintosh
69
#else // not macintosh
70
        /* allow for the situation where _WIN32 is defined BUT we are building a DOS executable
70
        /* allow for the situation where _WIN32 is defined BUT we are building a DOS executable
71
           and wish to use mingw's UNIX compatibility libraries such as stdio;
71
           and wish to use mingw's UNIX compatibility libraries such as stdio;
72
           check the variable CMDLINE defined for this purpose in such a Makefile. */
72
           check the variable CMDLINE defined for this purpose in such a Makefile. */
73
 
73
 
74
        #if defined(_WIN32) && ! defined(CMDLINE)
74
        #if defined(_WIN32) && ! defined(CMDLINE)
75
 
75
 
76
                #include "compat_win.h"
76
                #include "compat_win.h"
77
 
77
 
78
                typedef INT16 int16_t;
78
                typedef INT16 int16_t;
79
                typedef INT32 int32_t;
79
                typedef INT32 int32_t;
80
 
80
 
81
                #ifndef INVALID_SET_FILE_POINTER
81
                #ifndef INVALID_SET_FILE_POINTER
82
                        #define INVALID_SET_FILE_POINTER 0xffffffff
82
                        #define INVALID_SET_FILE_POINTER 0xffffffff
83
                #endif
83
                #endif
84
 
84
 
85
                typedef HANDLE FILEREF;
85
                typedef HANDLE FILEREF;
86
                typedef LONG FILECOUNT;
86
                typedef LONG FILECOUNT;
87
 
87
 
88
                #define FSPOPENDF FSpOpenDF
88
                #define FSPOPENDF FSpOpenDF
89
                #define FSREAD FSRead
89
                #define FSREAD FSRead
90
                #define FSWRITE FSWrite
90
                #define FSWRITE FSWrite
91
 
91
 
92
                #ifdef WANT_LARGE_FILES
92
                #ifdef WANT_LARGE_FILES
93
                        typedef UINT64 FILEPOS;
93
                        typedef UINT64 FILEPOS;
94
                        #define GETFPOS getfpos_large
94
                        #define GETFPOS getfpos_large
95
                        #define SETFPOS setfpos_large
95
                        #define SETFPOS setfpos_large
96
                        #define GETEOF geteof_large
96
                        #define GETEOF geteof_large
97
                #else
97
                #else
98
                        typedef DWORD FILEPOS;
98
                        typedef DWORD FILEPOS;
99
                        #define GETFPOS GetFPos
99
                        #define GETFPOS GetFPos
100
                        #define SETFPOS SetFPos
100
                        #define SETFPOS SetFPos
101
                        #define GETEOF GetEOF
101
                        #define GETEOF GetEOF
102
                #endif
102
                #endif
103
 
103
 
104
                OSErr FSpOpenDF(const FSSpec *spec, int permission, FILEREF *refNum);
104
                OSErr FSpOpenDF(const FSSpec *spec, int permission, FILEREF *refNum);
105
                OSErr FSpCreate(const FSSpec *spec, OSType creator, OSType fileType, ScriptCode scriptTag);
105
                OSErr FSpCreate(const FSSpec *spec, OSType creator, OSType fileType, ScriptCode scriptTag);
106
                OSErr FSpDelete(const FSSpec *spec);
106
                OSErr FSpDelete(const FSSpec *spec);
107
        #else
107
        #else
108
                // UNIX
108
                // UNIX
109
                #include <stdio.h>
109
                #include <stdio.h>
110
                #include <stdint.h>
110
                #include <stdint.h>
111
 
111
 
112
                typedef FILE *FILEREF;
112
                typedef FILE *FILEREF;
113
                #ifdef WANT_LARGE_FILES
113
                #ifdef WANT_LARGE_FILES
114
                        typedef fpos_t FILEPOS;
114
                        typedef fpos_t FILEPOS;
115
                #else
115
                #else
116
                        typedef long FILEPOS;
116
                        typedef long FILEPOS;
117
                #endif
117
                #endif
118
                typedef long FILECOUNT;
118
                typedef long FILECOUNT;
119
                typedef char *FSSpec;/*???*/
119
                typedef char *FSSpec;/*???*/
120
                typedef int OSErr;
120
                typedef int OSErr;
121
 
121
 
122
                #define noErr 0
122
                #define noErr 0
123
                #define ioErr                           (-36)
123
                #define ioErr                           (-36)
124
 
124
 
125
                #define FSREAD FSRead
125
                #define FSREAD FSRead
126
                #define FSWRITE FSWrite
126
                #define FSWRITE FSWrite
127
        #endif
127
        #endif
128
 
128
 
129
                enum {
129
                enum {
130
                        fsCurPerm                                       = 0,
130
                        fsCurPerm                                       = 0,
131
                        fsRdPerm                                        = 1,
131
                        fsRdPerm                                        = 1,
132
                        fsWrPerm                                        = 2,
132
                        fsWrPerm                                        = 2,
133
                        fsRdWrPerm                                      = 3,
133
                        fsRdWrPerm                                      = 3,
134
                };
134
                };
135
                enum {
135
                enum {
136
                  fsAtMark                      = 0,    /* positioning modes in ioPosMode */
136
                  fsAtMark                      = 0,    /* positioning modes in ioPosMode */
137
                  fsFromStart                   = 1,
137
                  fsFromStart                   = 1,
138
                  fsFromLEOF                    = 2,
138
                  fsFromLEOF                    = 2,
139
                  fsFromMark                    = 3
139
                  fsFromMark                    = 3
140
                };
140
                };
141
 
141
 
142
                OSErr FSClose(FILEREF f);
142
                OSErr FSClose(FILEREF f);
143
                OSErr FSRead(FILEREF f, FILECOUNT *count, void *buffPtr);
143
                OSErr FSRead(FILEREF f, FILECOUNT *count, void *buffPtr);
144
                OSErr FSWrite(FILEREF f, FILECOUNT *count, const void *buffPtr);
144
                OSErr FSWrite(FILEREF f, FILECOUNT *count, const void *buffPtr);
145
                OSErr GetFPos(FILEREF   refNum,FILEPOS *  filePos);
145
                OSErr GetFPos(FILEREF   refNum,FILEPOS *  filePos);
146
                OSErr SetFPos(FILEREF   refNum,short   posMode,long    posOff);
146
                OSErr SetFPos(FILEREF   refNum,short   posMode,long    posOff);
147
                OSErr GetEOF(FILEREF   refNum,FILEPOS *  logEOF);
147
                OSErr GetEOF(FILEREF   refNum,FILEPOS *  logEOF);
148
                OSErr SetEOF(FILEREF   refNum,FILEPOS logEOF);
148
                OSErr SetEOF(FILEREF   refNum,FILEPOS logEOF);
149
                /*
149
                /*
150
                HMODULE FSpOpenResFile(const FSSpec *  spec,SignedByte      permission);
150
                HMODULE FSpOpenResFile(const FSSpec *  spec,SignedByte      permission);
151
                void CloseResFile(HMODULE hmodule);
151
                void CloseResFile(HMODULE hmodule);
152
                HGLOBAL GetResource(ResType   theType,short     theID);
152
                HGLOBAL GetResource(ResType   theType,short     theID);
153
                */
153
                */
154
 
154
 
155
#endif
155
#endif
156
 
156
 
157
OSErr fspopendf_large(const FSSpec *spec, int perm, FILEREF *refNum);
157
OSErr fspopendf_large(const FSSpec *spec, int perm, FILEREF *refNum);
158
OSErr fsread_large(FILEREF refNum, FILECOUNT *count, void *buffPtr);
158
OSErr fsread_large(FILEREF refNum, FILECOUNT *count, void *buffPtr);
159
OSErr fswrite_large(FILEREF refNum, FILECOUNT *count, void *buffPtr);
159
OSErr fswrite_large(FILEREF refNum, FILECOUNT *count, void *buffPtr);
160
OSErr getfpos_large(FILEREF refNum, FILEPOS *filePos);
160
OSErr getfpos_large(FILEREF refNum, FILEPOS *filePos);
161
OSErr setfpos_large(FILEREF refNum, short posMode, FILEPOS posOff);
161
OSErr setfpos_large(FILEREF refNum, short posMode, FILEPOS posOff);
162
OSErr geteof_large(FILEREF refNum, FILEPOS *logEOF);
162
OSErr geteof_large(FILEREF refNum, FILEPOS *logEOF);
163
OSErr seteof_large(FILEREF refNum, FILEPOS logEOF);
163
OSErr seteof_large(FILEREF refNum, FILEPOS logEOF);
164
 
164
 
165
#endif
165
#endif