source: trunk/include/stdlib.h @ 1151

Revision 1151, 7.9 KB checked in by reyalP, 2 years ago (diff)

increase size of buffer for readder on dryos R39 (and later) cams

  • Property svn:eol-style set to native
Line 
1#include "camera.h"
2
3#ifndef STDLIB_H
4#define STDLIB_H
5
6#define NULL            ((void*)0)
7
8#define SEEK_SET        0
9#define SEEK_CUR        1
10#define SEEK_END        2
11
12#define O_RDONLY        0
13#define O_WRONLY        1
14#define O_RDWR          2
15
16
17#if !CAM_DRYOS
18
19#define O_TRUNC         0x400
20#define O_CREAT         0x200
21
22struct  stat
23    {
24    unsigned long       st_dev;         /* device ID number */
25    unsigned long       st_ino;         /* file serial number */
26    unsigned short      st_mode;        /* file mode (see below) */
27    short               st_nlink;       /* number of links to file */
28    short               st_uid;         /* user ID of file's owner */
29    short               st_gid;         /* group ID of file's group */
30    unsigned long       st_rdev;        /* device ID, only if special file */
31    unsigned long       st_size;        /* size of file, in bytes */
32    unsigned long       st_atime;       /* time of last access */
33    unsigned long       st_mtime;       /* time of last modification */
34    unsigned long       st_ctime;       /* time of last change of file status */
35    long                st_blksize;
36    long                st_blocks;
37    unsigned char       st_attrib;      /* file attribute byte (dosFs only) */
38    int                 reserved1;      /* reserved for future use */
39    int                 reserved2;      /* reserved for future use */
40    int                 reserved3;      /* reserved for future use */
41    int                 reserved4;      /* reserved for future use */
42    int                 reserved5;      /* reserved for future use */
43    int                 reserved6;      /* reserved for future use */
44};
45
46#else
47
48#define O_APPEND        0x8 // ok for dryos, vx?
49#define O_TRUNC         0x200
50#define O_CREAT         0x100
51
52#ifndef CAM_DRYOS_2_3_R39
53struct  stat
54    {
55    unsigned long       st_dev;         //?
56    unsigned long       st_ino;         //?
57    unsigned short      st_mode;        //?
58    short               st_nlink;       //?
59    short               st_uid;         //?
60    short               st_gid;         //?
61    unsigned long       st_atime;       //?
62    unsigned long       st_mtime;       //?
63    unsigned long       st_ctime;       //?
64    unsigned long       st_size;
65    long                st_blksize;     //?
66    long                st_blocks;      //?
67    unsigned char       st_attrib;
68    int                 reserved1;      //
69    int                 reserved2;      //
70    int                 reserved3;      //
71    int                 reserved4;      //
72    int                 reserved5;      //
73    int                 reserved6;      //
74};
75
76#else
77struct  stat
78    {
79    unsigned long       st_unknown_1;
80    unsigned long       st_attrib;
81    unsigned long       st_size;
82    unsigned long       st_ctime;
83    unsigned long       st_mtime;
84    unsigned long       st_unknown_2;
85};
86#endif//CAM_DRYOS_2_3_R39
87
88#endif
89
90extern int rand(void);
91extern void* srand(unsigned int seed);
92
93extern void qsort (void *__base, int __nelem, int __size, int (*__cmp)(const void *__e1, const void *__e2));
94
95extern int isdigit(int c);
96extern int isspace(int c);
97extern int isalpha(int c);
98extern int isupper(int c);
99extern int islower(int c);
100extern int ispunct(int c);
101extern int isxdigit(int c);
102extern int iscntrl(int c);
103extern int isalnum(int c);
104
105extern long sprintf(char *s, const char *st, ...);
106
107extern long strlen(const char *s);
108extern int strcmp(const char *s1, const char *s2);
109extern int strncmp(const char *s1, const char *s2, long n);
110extern char *strchr(const char *s, int c);
111extern char *strcpy(char *dest, const char *src);
112extern char *strncpy(char *dest, const char *src, long n);
113extern char *strcat(char *dest, const char *app);
114extern char *strrchr(const char *s, int c);
115extern char *strpbrk(const char *s, const char *accept);
116
117extern long strtol(const char *nptr, char **endptr, int base);
118extern unsigned long strtoul(const char *nptr, char **endptr, int base);
119#define atoi(n) strtol((n),NULL,0)
120
121extern int tolower(int c);
122extern int toupper(int c);
123
124extern void *malloc(long size);
125extern void free(void *p);
126extern void *umalloc(long size);
127extern void ufree(void *p);
128
129extern void *memcpy(void *dest, const void *src, long n);
130extern void *memset(void *s, int c, int n);
131extern int memcmp(const void *s1, const void *s2, long n);
132extern void *memchr(const void *s, int c, int n);
133
134
135extern void SleepTask(long msec);
136extern long taskLock();
137extern long taskUnlock();
138
139extern int creat (const char *name, int flags);
140extern int open (const char *name, int flags, int mode );
141extern int close (int fd);
142extern int write (int fd, const void *buffer, long nbytes);
143extern int read (int fd, void *buffer, long nbytes);
144extern int lseek (int fd, long offset, int whence);
145extern long mkdir(const char *dirname);
146extern int rename(const char *oldname, const char *newname);
147extern int chdir(char *pathname);
148extern int remove(const char *name);
149
150// reverse engineered file struct. Appears to be valid for both vxworks and dryos
151// don't use this directly unless you absolutely need to
152// don't EVER try to create one yourself, as this isn't the full structure.
153typedef struct FILE_S {
154    int fd;         // used by Read/Write
155    unsigned len;   // +4 verfied in Fseek_FileStream
156    int unk0;       // +8
157    unsigned pos;   // +0xC verified in Fseek_FileStream
158    // unk1;        // +0x10
159    // unk2;        // +0x14
160    // io_buf;      // +0x18 32k uncached allocated in Fopen_FileStream
161    // unk3;        // +0x20 related to StartFileAccess_Sem
162    // ...name
163} FILE;
164
165extern FILE *fopen(const char *filename, const char *mode);
166extern long fclose(FILE *f);
167extern long fread(void *buf, long elsize, long count, FILE *f);
168extern long fwrite(const void *buf, long elsize, long count, FILE *f);
169extern long fseek(FILE *file, long offset, long whence);
170extern long fflush(FILE *file);
171extern long feof(FILE *file);
172extern long ftell(FILE *file);
173extern char *fgets(char *buf, int n, FILE *f);
174
175/**
176 * No STUBS!
177 * You can't use these two directly from THUMB code (core), only from platform.
178 */
179extern int fprintf(FILE *fd, char*buf, ...);
180extern int printf(char *buf, ...);
181
182extern void msleep(long msec);
183extern long task_lock();
184extern long task_unlock();
185extern const char *task_name(int id);
186int task_id_list_get(int *idlist,int size);
187extern const char *strerror(int num);
188// on vxworks we could find the actual errno, but this is easier to automate sig
189// doesn't exist on dryos, but we stub it
190extern int errnoOfTaskGet(int tid);
191#define errno (errnoOfTaskGet(0))
192
193#define DOS_ATTR_RDONLY         0x01            /* read-only file */
194#define DOS_ATTR_HIDDEN         0x02            /* hidden file */
195#define DOS_ATTR_SYSTEM         0x04            /* system file */
196#define DOS_ATTR_VOL_LABEL      0x08            /* volume label (not a file) */
197#define DOS_ATTR_DIRECTORY      0x10            /* entry is a sub-directory */
198#define DOS_ATTR_ARCHIVE        0x20            /* file subject to archiving */
199
200#if !CAM_DRYOS
201struct dirent {
202    char                d_name[100];
203};
204#else
205struct dirent {
206    char                d_name[13];
207    unsigned long       unk1;
208    unsigned char       attrib;
209    unsigned long       size;
210    unsigned long       time1;
211    unsigned long       time2;
212    unsigned long       time3;
213};
214#endif
215
216// NOTE this is NOT the actual structure returned by dryos opendir!
217typedef struct {
218    unsigned int        fd; // first member is an fd from Open in dryos
219    unsigned int        loc;
220    struct dirent       dir;
221} DIR;
222
223
224extern DIR*           opendir (const char* name);
225extern struct dirent* readdir (DIR*);
226extern int            closedir (DIR*);
227extern void           rewinddir (DIR*);
228extern int            stat (const char *name, struct stat *pStat);
229
230
231struct tm
232        {
233        int tm_sec;     /* seconds after the minute     - [0, 59] */
234        int tm_min;     /* minutes after the hour       - [0, 59] */
235        int tm_hour;    /* hours after midnight         - [0, 23] */
236        int tm_mday;    /* day of the month             - [1, 31] */
237        int tm_mon;     /* months since January         - [0, 11] */
238        int tm_year;    /* years since 1900     */
239        int tm_wday;    /* days since Sunday            - [0, 6] */
240        int tm_yday;    /* days since January 1         - [0, 365] */
241        int tm_isdst;   /* Daylight Saving Time flag */
242        };
243
244typedef unsigned long time_t;
245
246extern struct tm * localtime(const unsigned long *_tod);
247
248struct utimbuf {
249    unsigned long actime;       /* set the access time */
250    unsigned long modtime;      /* set the modification time */
251};
252
253extern int utime(const char *file, struct utimbuf *newTimes);
254extern unsigned long time(unsigned long *timer);
255extern long strftime(char *s, unsigned long maxsize, const char *format, const struct tm *timp);
256extern time_t mktime(struct tm *timp);
257
258extern int abs( int v );
259
260#endif
Note: See TracBrowser for help on using the repository browser.