1 /*
2 * unixfunc.c - only required for the Maxon compiler
3 *
4 * Copyright (c) 2000 Sebastian Bauer
5 * Copyright (c) 2000-2003 Atari800 development team (see DOC/CREDITS)
6 *
7 * This file is part of the Atari800 emulator project which emulates
8 * the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
9 *
10 * Atari800 is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * Atari800 is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Atari800; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25 #ifdef __MAXON__
26
27 #include <string.h>
28 #include <stdlib.h>
29 #include <fcntl.h>
30
31 #include <pragma/dos_lib.h>
32 #include <pragma/exec_lib.h>
33
__open(const char * name,int mode,...)34 int __open(const char *name, int mode,...)
35 {
36 BPTR fh;
37
38 if( mode & O_RDONLY )
39 {
40 fh = Open((STRPTR)name,MODE_OLDFILE);
41 } else
42 {
43 if(mode & O_WRONLY)
44 {
45 fh = Open((STRPTR)name,MODE_NEWFILE);
46 } else fh = Open((STRPTR)name, MODE_OLDFILE);
47 }
48
49 if(!fh) fh = (BPTR)-1;
50
51 return (int)fh;
52 }
53
__close(int fh)54 int __close(int fh)
55 {
56 if(fh && fh != -1 ) Close((BPTR)fh);
57 return 0;
58 }
59
__write(int fh,const void * buffer,unsigned int length)60 int __write(int fh, const void *buffer, unsigned int length)
61 {
62 return Write((BPTR)fh,(APTR)buffer,length);
63 }
64
__read(int fh,void * buffer,unsigned int length)65 int __read(int fh, void *buffer, unsigned int length)
66 {
67 int count;
68
69 if (fh == -1) return 0;
70
71 count = Read((BPTR)fh,buffer,length);
72 /* if(!count) count = - 1;*/
73 return count;
74 }
75
unlink(const char * name)76 int unlink(const char *name)
77 {
78 DeleteFile((STRPTR)name);
79 return 0;
80 }
81
lseek(int fh,long rpos,int mode)82 long lseek(int fh, long rpos, int mode)
83 {
84 long origin = mode;
85 Seek((BPTR)fh,rpos,origin);
86
87 return Seek((BPTR)fh,0,OFFSET_CURRENT);
88 }
89
strdup(const char * s)90 char *strdup(const char *s)
91 {
92 char *p = malloc(strlen(s)+1);
93 if(p)
94 {
95 strcpy(p,s);
96 }
97 return p;
98 }
99
getcwd(char * b,int size)100 char *getcwd(char *b, int size)
101 {
102 struct Process *p = (struct Process*)FindTask(NULL);
103 NameFromLock(p->pr_CurrentDir, b, size);
104 return b;
105 }
106
stat()107 int stat()
108 {
109 return -1;
110 }
111
readdir()112 int readdir()
113 {
114 return -1;
115 }
116
closedir()117 int closedir()
118 {
119 return -1;
120 }
121
opendir()122 int opendir()
123 {
124 return -1;
125 }
126
127
128 #endif
129
130