Changeset 732
- Timestamp:
- Sep 26, 2003, 4:41:32 AM (22 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 1 added
- 51 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/Makefile
-
Property cvs2svn:cvs-rev
changed from
1.33
to1.34
r731 r732 77 77 # The C compiler flags 78 78 CFLAGS.INC += -Iinclude -Isrc/include 79 CFLAGS = -Wall - mstack-arg-probe $(CFLAGS.INC) $(CFLAGS.$(MODE)) $(CFLAGS.KIND)79 CFLAGS = -Wall -Wmissing-prototypes -mstack-arg-probe $(CFLAGS.INC) $(CFLAGS.$(MODE)) $(CFLAGS.KIND) 80 80 # The additional C compiler flags for different build modes 81 81 CFLAGS.opt = -g -O3 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/bsd/db/include/sys/mman.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r731 r732 83 83 __BEGIN_DECLS 84 84 /* Some of these int's should probably be size_t's */ 85 #ifndef _MMAP_DECLARED 86 #define _MMAP_DECLARED 85 87 caddr_t mmap __P((caddr_t, size_t, int, int, int, off_t)); 88 #endif 86 89 int mprotect __P((caddr_t, int, int)); 87 90 int munmap __P((caddr_t, int)); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/386/_limits.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r731 r732 90 90 91 91 /* bird: our off_t is 32 bit signed at the moment. */ 92 #if 092 #if 1 93 93 #define __OFF_MAX __LLONG_MAX /* max value for an off_t */ 94 94 #define __OFF_MIN __LLONG_MIN /* min value for an off_t */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/386/ansi.h
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 75 75 */ 76 76 #define _BSD_CT_RUNE_T_ int /* arg type for ctype funcs */ 77 #if 077 #if 1 78 78 #define _BSD_OFF_T_ __int64_t /* file offset */ 79 79 #else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/dirent.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r731 r732 1 /* dirent.h (emx+gcc) */ 1 /*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)dirent.h 8.2 (Berkeley) 7/28/94 34 * $FreeBSD: src/include/dirent.h,v 1.13 2002/09/10 18:12:16 mike Exp $ 35 */ 2 36 3 #ifndef _DIRENT_H 4 #define _DIRENT_H 37 /** @file 38 * FreeBSD 5.1 39 * @changes bird: Merged in EMX stuff and internal LIBC stuff. 40 */ 5 41 6 #if !defined (_SYS_TYPES_H) 7 #warning <dirent.h> requires <sys/types.h> 8 #include <sys/types.h> 42 #ifndef _DIRENT_H_ 43 #define _DIRENT_H_ 44 45 /* 46 * The kernel defines the format of directory entries returned by 47 * the getdirentries(2) system call. 48 */ 49 #include <sys/cdefs.h> 50 #include <sys/dirent.h> 51 52 #if __BSD_VISIBLE || __XSI_VISIBLE 53 /* 54 * XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer 55 * to the specification. 56 */ 57 #define d_ino d_fileno /* backward and XSI compatibility */ 9 58 #endif 10 59 11 #i nclude <sys/dirent.h>60 #if __BSD_VISIBLE 12 61 13 #if defined (__cplusplus) 14 extern "C" { 62 /* definitions for library routines operating on directories. */ 63 #define DIRBLKSIZ 1024 64 65 struct _telldir; /* see telldir.h */ 66 67 /* bird: EMX internal structure. */ 68 struct _dircontents 69 { 70 struct _dircontents * _d_next; 71 char * _d_entry; 72 __off_t _d_size; 73 unsigned short _d_time; 74 unsigned short _d_date; 75 unsigned short _d_attr; 76 unsigned char _d_type; 77 }; 78 79 /* structure describing an open directory. */ 80 typedef struct _dirdesc { 81 #if 0 82 int dd_fd; /* file descriptor associated with directory */ 83 long dd_loc; /* offset in current buffer */ 84 long dd_size; /* amount of data returned by getdirentries */ 85 char *dd_buf; /* data buffer */ 86 int dd_len; /* size of data buffer */ 87 long dd_seek; /* magic cookie returned by getdirentries */ 88 long dd_rewind; /* magic cookie for rewinding */ 89 int dd_flags; /* flags for readdir */ 90 void *dd_lock; /* hack to avoid including <pthread.h> */ 91 struct _telldir *dd_td; /* telldir position recording */ 92 #else 93 int dd_id; 94 long dd_loc; 95 struct _dircontents * dd_contents; 96 struct _dircontents * dd_cp; 97 struct dirent dd_dirent; 98 #endif 99 } DIR; 100 101 #define dirfd(dirp) ((dirp)->dd_fd) 102 103 /* flags for opendir2 */ 104 #define DTF_HIDEW 0x0001 /* hide whiteout entries */ 105 #define DTF_NODUP 0x0002 /* don't return duplicate names */ 106 #define DTF_REWIND 0x0004 /* rewind after reading union stack */ 107 #define __DTF_READALL 0x0008 /* everything has been read */ 108 109 #ifndef NULL 110 #define NULL 0 15 111 #endif 16 112 17 struct _dirdesc; 113 #else /* !__BSD_VISIBLE */ 18 114 19 typedef struct _dirdescDIR;115 typedef void * DIR; 20 116 21 DIR *opendir (__const__ char *); 22 struct dirent *readdir (DIR *); 23 int closedir (DIR *); 24 void rewinddir (DIR *); 117 #endif /* __BSD_VISIBLE */ 25 118 26 #if !defined (_POSIX_SOURCE) 27 void seekdir (DIR *, long); 28 long telldir (DIR *); 119 #ifndef _KERNEL 120 121 __BEGIN_DECLS 122 #if __BSD_VISIBLE 123 /** @todo DIR *__opendir2(const char *, int); */ 124 /** @todo int alphasort(const void *, const void *); */ 125 /** @todo int getdents(int, char *, int); */ 126 /** @todo int getdirentries(int, char *, int, long *); */ 29 127 #endif 128 DIR *opendir(const char *); 129 struct dirent * 130 readdir(DIR *); 131 #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500 132 int readdir_r(DIR *, struct dirent *, struct dirent **); 133 #endif 134 void rewinddir(DIR *); 135 #if __BSD_VISIBLE 136 int scandir(const char *, struct dirent ***, 137 int (*)(struct dirent *), int (*)(const void *, const void *)); 138 #endif 139 #if __XSI_VISIBLE 140 void seekdir(DIR *, long); 141 long telldir(DIR *); 142 #endif 143 int closedir(DIR *); 30 144 145 146 /* bird: EMX extra - start */ 31 147 DIR *_opendir (__const__ char *); 32 148 struct dirent *_readdir (DIR *); … … 35 151 int _closedir (DIR *); 36 152 void _rewinddir (DIR *); 153 /* bird: EMX extra - end */ 37 154 38 #if defined (__cplusplus) 39 } 40 #endif 155 __END_DECLS 41 156 42 #endif /* not _DIRENT_H */ 157 #endif /* !_KERNEL */ 158 159 #endif /* !_DIRENT_H_ */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/io.h
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 7 7 extern "C" { 8 8 #endif 9 10 #include <sys/types.h> 9 11 10 12 #if !defined (NULL) … … 14 16 #define NULL ((void *)0) 15 17 #endif 16 #endif17 18 #if !defined (_SIZE_T)19 #define _SIZE_T20 typedef unsigned long size_t;21 18 #endif 22 19 … … 217 214 void _closestream (struct _FILE *); 218 215 int _fflush_nolock (struct _FILE *); 219 int _fseek_nolock (struct _FILE *, long, int);220 long_ftell_nolock (struct _FILE *);216 int _fseek_nolock (struct _FILE *, off_t, int); 217 off_t _ftell_nolock (struct _FILE *); 221 218 size_t _fwrite_nolock (const void *, size_t, size_t, struct _FILE *); 222 219 int _input (struct _FILE *, __const__ char *, char *); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/syscalls.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r731 r732 3 3 #ifndef _EMX_SYSCALLS_H 4 4 #define _EMX_SYSCALLS_H 5 6 #include <sys/types.h> 5 7 6 8 #if defined (__cplusplus) … … 37 39 typedef unsigned long sigset_t; 38 40 #endif 39 40 #if !defined (_SIZE_T)41 #define _SIZE_T42 typedef unsigned long size_t;43 #endif44 45 41 46 42 struct hostent; … … 54 50 struct timeval; 55 51 52 #pragma pack(1) 56 53 struct _find 57 54 { 58 char reserved[21]; 59 unsigned char attr; 60 unsigned short time; 61 unsigned short date; 62 unsigned short size_lo; /* split due to alignment problems */ 63 unsigned short size_hi; 64 char name[257]; /* Big buffer for OS/2 */ 65 }; 55 /** Size of file, in number of bytes. */ 56 off_t cbFile; 57 /** Last written (OS/2 & DOS time). */ 58 unsigned short time; 59 /** Last written (OS/2 & DOS date). */ 60 unsigned short date; 61 /** File attributes. */ 62 unsigned char attr; 63 /** File name */ 64 char szName[257]; 65 }; 66 #pragma pack() 66 67 67 68 struct _new_proc … … 128 129 int __chmod (__const__ char *name, int flag, int attr); 129 130 int __chdrive (char drive); 130 int __chsize (int handle, longlength);131 int __chsize (int handle, off_t length); 131 132 long long __clock (void); 132 133 int __close (int handle); … … 146 147 int __fsync (int handle); 147 148 void __ftime (struct timeb *ptr); 148 int __ftruncate (int handle, longlength);149 int __ftruncate (int handle, off_t length); 149 150 int __getcwd (char *buffer, char drive); 150 151 char __getdrive (void); … … 175 176 int __kill (int pid, int sig); 176 177 int __listen (int handle, int backlog); 177 int __lseek (int handle, longoffset, int origin);178 off_t __lseek (int handle, off_t offset, int origin); 178 179 int __memavail (void); 179 180 int __mkdir (__const__ char *name); 180 181 int __newthread (int tid); 181 int __open (__const__ char *name, int flags, unsigned longsize);182 int __open (__const__ char *name, int flags, off_t size); 182 183 int __pause (void); 183 184 int __pipe (int *two_handles, int pipe_size); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/io.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r731 r732 49 49 int access (__const__ char *, int); 50 50 int chmod (__const__ char *, int); 51 int chsize (int, long);51 int chsize (int, off_t); 52 52 int close (int); 53 53 int creat (const char *, mode_t); … … 55 55 int dup2 (int, int); 56 56 int eof (int); 57 longfilelength (int);57 off_t filelength (int); 58 58 int fstat (int, struct stat *); 59 59 int fsync (int); … … 77 77 int sopen (__const__ char *, int, int, ...); 78 78 int stat (__const__ char *, struct stat *); 79 longtell (int);79 off_t tell (int); 80 80 #ifndef _TRUNCATE_DECLARED 81 81 #define _TRUNCATE_DECLARED … … 91 91 int _access (__const__ char *, int); 92 92 int _chmod (__const__ char *, int); 93 int _chsize (int, long);93 int _chsize (int, off_t); 94 94 int _close (int); 95 95 int _creat (__const__ char *, int); … … 98 98 int _dup2 (int, int); 99 99 int _eof (int); 100 long_filelength (int);100 off_t _filelength (int); 101 101 int _fstat (int, struct stat *); 102 102 int _fsync (int); … … 123 123 int _sopen (__const__ char *, int, int, ...); 124 124 int _stat (__const__ char *, struct stat *); 125 long_tell (int);126 int _truncate (char *, long);125 off_t _tell (int); 126 int _truncate (char *, off_t); 127 127 int _umask (int); 128 128 int _unlink (__const__ char *); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/os2emx.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r731 r732 1268 1268 #define FIL_QUERYEASIZEL 12 1269 1269 #define FIL_QUERYEASFROMLISTL 13 1270 #define FIL_QUERYFULLNAME 5 /* DosQueryPathInfo */1270 #define FIL_QUERYFULLNAME 5 1271 1271 1272 1272 #define FILE_BEGIN 0 … … 1589 1589 typedef FILEFINDBUF4 *PFILEFINDBUF4; 1590 1590 1591 typedef struct _FILEFINDBUF3L 1592 { 1593 ULONG oNextEntryOffset; 1594 FDATE fdateCreation; 1595 FTIME ftimeCreation; 1596 FDATE fdateLastAccess; 1597 FTIME ftimeLastAccess; 1598 FDATE fdateLastWrite; 1599 FTIME ftimeLastWrite; 1600 LONGLONG cbFile; 1601 LONGLONG cbFileAlloc; 1602 ULONG attrFile; 1603 UCHAR cchName; 1604 CHAR achName[CCHMAXPATHCOMP]; 1605 } FILEFINDBUF3L; 1606 typedef FILEFINDBUF3L *PFILEFINDBUF3L; 1607 1608 typedef struct _FILEFINDBUF4L 1609 { 1610 ULONG oNextEntryOffset; 1611 FDATE fdateCreation; 1612 FTIME ftimeCreation; 1613 FDATE fdateLastAccess; 1614 FTIME ftimeLastAccess; 1615 FDATE fdateLastWrite; 1616 FTIME ftimeLastWrite; 1617 LONGLONG cbFile; 1618 LONGLONG cbFileAlloc; 1619 ULONG attrFile; 1620 ULONG cbList; 1621 UCHAR cchName; 1622 CHAR achName[CCHMAXPATHCOMP]; 1623 } FILEFINDBUF4L; 1624 typedef FILEFINDBUF4L *PFILEFINDBUF4L; 1625 1591 1626 typedef struct _FILELOCK 1592 1627 { … … 1596 1631 typedef FILELOCK *PFILELOCK; 1597 1632 1598 typedef struct _FILELOCKL /* flock */1633 typedef struct _FILELOCKL 1599 1634 { 1600 1635 LONGLONG lOffset; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/stdio.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r731 r732 1 /* stdio.h (emx+gcc) */ 2 3 #ifndef _STDIO_H 4 #define _STDIO_H 5 6 #if defined (__cplusplus) 7 extern "C" { 8 #endif 1 /*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by the University of 19 * California, Berkeley and its contributors. 20 * 4. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)stdio.h 8.5 (Berkeley) 4/29/95 37 * $FreeBSD: src/include/stdio.h,v 1.51 2003/01/13 08:41:47 tjr Exp $ 38 */ 39 40 /** @file 41 * FreeBSD 5.1 42 * @changed bird: EMX isms + LIBC implementation specifics. 43 * @chagned bird: Made quite a few @todos on function which aren't implemented. 44 */ 45 46 #ifndef _STDIO_H_ 47 #define _STDIO_H_ 9 48 10 49 #include <sys/cdefs.h> 11 50 #include <sys/_types.h> 12 51 13 #if !defined(_VA_LIST_DECLARED) && !defined(_VA_LIST) /* bird: emx */ 52 typedef __off_t fpos_t; 53 54 #ifndef _SIZE_T_DECLARED 55 typedef __size_t size_t; 56 #define _SIZE_T_DECLARED 57 #define _SIZE_T /* bird: emx */ 58 #endif 59 60 #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE 61 #ifndef _VA_LIST_DECLARED 62 typedef __va_list va_list; 14 63 #define _VA_LIST_DECLARED 15 64 #define _VA_LIST /* bird: emx */ 16 typedef __va_list va_list; 17 #endif 18 19 #if !defined (_SIZE_T) 20 #define _SIZE_T 21 typedef unsigned long size_t; 22 #endif 23 24 #if !defined (NULL) 25 #if defined (__cplusplus) 26 #define NULL 0 27 #else 28 #define NULL ((void *)0) 29 #endif 30 #endif 31 32 #if !defined (BUFSIZ) 33 #define BUFSIZ 5120 34 #endif 35 36 #if !defined (_FILE_T) 65 #endif 66 #endif 67 68 #ifndef NULL 69 #define NULL 0 70 #endif 71 72 #define _FSTDIO /* Define for new stdio with functions. */ 73 74 #if 0 /* bird: emx */ 75 76 /* 77 * NB: to fit things in six character monocase externals, the stdio 78 * code uses the prefix `__s' for stdio objects, typically followed 79 * by a three-character attempt at a mnemonic. 80 */ 81 82 /* stdio buffers */ 83 struct __sbuf { 84 unsigned char *_base; 85 int _size; 86 }; 87 88 /* hold a buncha junk that would grow the ABI */ 89 struct __sFILEX; 90 91 /* 92 * stdio state variables. 93 * 94 * The following always hold: 95 * 96 * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), 97 * _lbfsize is -_bf._size, else _lbfsize is 0 98 * if _flags&__SRD, _w is 0 99 * if _flags&__SWR, _r is 0 100 * 101 * This ensures that the getc and putc macros (or inline functions) never 102 * try to write or read from a file that is in `read' or `write' mode. 103 * (Moreover, they can, and do, automatically switch from read mode to 104 * write mode, and back, on "r+" and "w+" files.) 105 * 106 * _lbfsize is used only to make the inline line-buffered output stream 107 * code as compact as possible. 108 * 109 * _ub, _up, and _ur are used when ungetc() pushes back more characters 110 * than fit in the current _bf, or when ungetc() pushes back a character 111 * that does not match the previous one in _bf. When this happens, 112 * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff 113 * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. 114 * 115 * NB: see WARNING above before changing the layout of this structure! 116 */ 117 typedef struct __sFILE { 118 unsigned char *_p; /* current position in (some) buffer */ 119 int _r; /* read space left for getc() */ 120 int _w; /* write space left for putc() */ 121 short _flags; /* flags, below; this FILE is free if 0 */ 122 short _file; /* fileno, if Unix descriptor, else -1 */ 123 struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ 124 int _lbfsize; /* 0 or -_bf._size, for inline putc */ 125 126 /* operations */ 127 void *_cookie; /* cookie passed to io functions */ 128 int (*_close)(void *); 129 int (*_read)(void *, char *, int); 130 fpos_t (*_seek)(void *, fpos_t, int); 131 int (*_write)(void *, const char *, int); 132 133 /* separate buffer for long sequences of ungetc() */ 134 struct __sbuf _ub; /* ungetc buffer */ 135 struct __sFILEX *_extra; /* additions to FILE to not break ABI */ 136 int _ur; /* saved _r when _r is counting ungetc data */ 137 138 /* tricks to meet minimum requirements even when malloc() fails */ 139 unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ 140 unsigned char _nbuf[1]; /* guarantee a getc() buffer */ 141 142 /* separate buffer for fgetln() when line crosses buffer boundary */ 143 struct __sbuf _lb; /* buffer for fgetln() */ 144 145 /* Unix stdio files get aligned to block boundaries on fseek() */ 146 int _blksize; /* stat.st_blksize (may be != _bf._size) */ 147 fpos_t _offset; /* current lseek offset (see WARNING) */ 148 } FILE; 149 150 __BEGIN_DECLS 151 extern FILE *__stdinp; 152 extern FILE *__stdoutp; 153 extern FILE *__stderrp; 154 __END_DECLS 155 156 #define __SLBF 0x0001 /* line buffered */ 157 #define __SNBF 0x0002 /* unbuffered */ 158 #define __SRD 0x0004 /* OK to read */ 159 #define __SWR 0x0008 /* OK to write */ 160 /* RD and WR are never simultaneously asserted */ 161 #define __SRW 0x0010 /* open for reading & writing */ 162 #define __SEOF 0x0020 /* found EOF */ 163 #define __SERR 0x0040 /* found error */ 164 #define __SMBF 0x0080 /* _buf is from malloc */ 165 #define __SAPP 0x0100 /* fdopen()ed in append mode */ 166 #define __SSTR 0x0200 /* this is an sprintf/snprintf string */ 167 #define __SOPT 0x0400 /* do fseek() optimization */ 168 #define __SNPT 0x0800 /* do not do fseek() optimization */ 169 #define __SOFF 0x1000 /* set iff _offset is in fact correct */ 170 #define __SMOD 0x2000 /* true => fgetln modified _p text */ 171 #define __SALC 0x4000 /* allocate string space dynamically */ 172 #define __SIGN 0x8000 /* ignore this file in _fwalk */ 173 174 #else /* bird: EMX specific FILE stuff starts. */ 175 37 176 #define _FILE_T 38 177 #define _FILE_MEMBERS_HAVE_UNDERSCORE 39 178 struct _file2; 40 struct _FILE179 typedef struct _FILE 41 180 { 42 181 char * _ptr; … … 54 193 int (*_flush)(struct _FILE *, int); 55 194 struct _file2 *_more; 56 }; 57 58 typedef struct _FILE FILE; 59 195 } FILE; 196 197 __BEGIN_DECLS 60 198 extern FILE _streamv[]; 61 62 #define stdin (&_streamv[0]) 63 #define stdout (&_streamv[1]) 64 #define stderr (&_streamv[2]) 65 66 #endif 67 68 #if !defined (SEEK_SET) 69 #define SEEK_SET 0 70 #define SEEK_CUR 1 71 #define SEEK_END 2 72 #endif 73 74 #if !defined (EOF) 75 #define EOF (-1) 76 #endif 199 __END_DECLS 200 201 #define __stdinp (&_streamv[0]) 202 #define __stdoutp (&_streamv[1]) 203 #define __stderrp (&_streamv[2]) 204 205 #endif /* bird: EMX specific FILE stuff ends. */ 206 207 208 /* 209 * The following three definitions are for ANSI C, which took them 210 * from System V, which brilliantly took internal interface macros and 211 * made them official arguments to setvbuf(), without renaming them. 212 * Hence, these ugly _IOxxx names are *supposed* to appear in user code. 213 * 214 * Although numbered as their counterparts above, the implementation 215 * does not rely on this. 216 */ 217 #define _IOFBF 0 /* setvbuf should set fully buffered */ 218 #define _IOLBF 0x20 /* bird: emx, was 1 */ /* setvbuf should set line buffered */ 219 #define _IONBF 0x40 /* bird: emx, was 2 */ /* setvbuf should set unbuffered */ 220 221 #define BUFSIZ 5120 /* bird: emx, was 1024 */ /* size of buffer used by setbuf */ 222 #define EOF (-1) 223 224 /* 225 * FOPEN_MAX is a minimum maximum, and is the number of streams that 226 * stdio can provide without attempting to allocate further resources 227 * (which could fail). Do not use this for anything. 228 */ 229 /* must be == _POSIX_STREAM_MAX <limits.h> */ 230 #define FOPEN_MAX 14 /* bird: emx, was 20 */ /* must be <= OPEN_MAX <sys/syslimits.h> */ 231 #define FILENAME_MAX 260 /* bird: emx, was 1024 */ /* must be <= PATH_MAX <sys/syslimits.h> */ 232 233 /* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ 234 #if __XSI_VISIBLE 235 #define P_tmpdir "." /* bird: emx, was "/var/tmp/" */ 236 #endif 237 #define L_tmpnam 260 /* bird: emx, was 1024 */ /* XXX must be == PATH_MAX */ 238 #define TMP_MAX 1000 /* bird: emx, was 308915776 */ 239 240 #ifndef SEEK_SET 241 #define SEEK_SET 0 /* set file offset to offset */ 242 #endif 243 #ifndef SEEK_CUR 244 #define SEEK_CUR 1 /* set file offset to current plus offset */ 245 #endif 246 #ifndef SEEK_END 247 #define SEEK_END 2 /* set file offset to EOF plus offset */ 248 #endif 249 250 #define stdin __stdinp 251 #define stdout __stdoutp 252 #define stderr __stderrp 253 254 __BEGIN_DECLS 255 /* 256 * Functions defined in ANSI C standard. 257 */ 258 void clearerr(FILE *); 259 int fclose(FILE *); 260 int feof(FILE *); 261 int ferror(FILE *); 262 int fflush(FILE *); 263 int fgetc(FILE *); 264 int fgetpos(FILE * __restrict, fpos_t * __restrict); 265 char *fgets(char * __restrict, int, FILE * __restrict); 266 FILE *fopen(const char * __restrict, const char * __restrict); 267 int fprintf(FILE * __restrict, const char * __restrict, ...); 268 int fputc(int, FILE *); 269 int fputs(const char * __restrict, FILE * __restrict); 270 size_t fread(void * __restrict, size_t, size_t, FILE * __restrict); 271 FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict); 272 int fscanf(FILE * __restrict, const char * __restrict, ...); 273 int fseek(FILE *, long, int); 274 int fsetpos(FILE *, const fpos_t *); 275 long ftell(FILE *); 276 size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict); 277 #if 0 /* bird: emx */ 278 int getc(FILE *); 279 #else /* bird: emx */ 280 /** @todo: Check the standard, if this is correct or not. declaration might be required. */ 281 #define getc(s) fgetc(s) /* bird: emx */ 282 #endif /* bird: emx */ 283 int getchar(void); 284 char *gets(char *); 285 void perror(const char *); 286 int printf(const char * __restrict, ...); 287 #if 0 /* bird: emx */ 288 int putc(int, FILE *); 289 #else /* bird: emx */ 290 /** @todo: Check the standard, if this is correct or not. declaration might be required. */ 291 #define putc(c,s) fputc(c,s) /* bird: emx */ 292 #endif /* bird: emx */ 293 int putchar(int); 294 int puts(const char *); 295 int remove(const char *); 296 int rename(const char *, const char *); 297 void rewind(FILE *); 298 int scanf(const char * __restrict, ...); 299 void setbuf(FILE * __restrict, char * __restrict); 300 int setvbuf(FILE * __restrict, char * __restrict, int, size_t); 301 int sprintf(char * __restrict, const char * __restrict, ...); 302 int sscanf(const char * __restrict, const char * __restrict, ...); 303 FILE *tmpfile(void); 304 char *tmpnam(char *); 305 int ungetc(int, FILE *); 306 int vfprintf(FILE * __restrict, const char * __restrict, 307 __va_list); 308 int vprintf(const char * __restrict, __va_list); 309 int vsprintf(char * __restrict, const char * __restrict, 310 __va_list); 311 312 #if __ISO_C_VISIBLE >= 1999 313 int snprintf(char * __restrict, size_t, const char * __restrict, 314 ...) __printflike(3, 4); 315 int vfscanf(FILE * __restrict, const char * __restrict, __va_list) 316 __scanflike(2, 0); 317 int vscanf(const char * __restrict, __va_list) __scanflike(1, 0); 318 int vsnprintf(char * __restrict, size_t, const char * __restrict, 319 __va_list) __printflike(3, 0); 320 int vsscanf(const char * __restrict, const char * __restrict, __va_list) 321 __scanflike(2, 0); 322 #endif 323 324 /* 325 * Functions defined in all versions of POSIX 1003.1. 326 */ 327 #if __BSD_VISIBLE || __POSIX_VISIBLE <= 199506 328 /* size for cuserid(3); UT_NAMESIZE + 1, see <utmp.h> */ 329 #define L_cuserid 9 /* bird: emx, was 17 */ /* legacy */ 330 #endif 331 332 #if __POSIX_VISIBLE 333 #define L_ctermid 260 /* bird: emx, was 1024 */ /* size for ctermid(3); PATH_MAX */ 334 335 /** @todo char *ctermid(char *); */ 336 FILE *fdopen(int, const char *); 337 int fileno(FILE *); 338 #endif /* __POSIX_VISIBLE */ 339 340 #if __POSIX_VISIBLE >= 199209 341 int pclose(FILE *); 342 FILE *popen(const char *, const char *); 343 #endif 344 345 #if __POSIX_VISIBLE >= 199506 346 /** @todo int ftrylockfile(FILE *); */ 347 /** @todo void flockfile(FILE *); */ 348 /** @todo void funlockfile(FILE *); */ 349 350 /* 351 * These are normally used through macros as defined below, but POSIX 352 * requires functions as well. 353 */ 354 /** @todo int getc_unlocked(FILE *); */ 355 /** @todo int getchar_unlocked(void); */ 356 /** @todo int putc_unlocked(int, FILE *); */ 357 /** @todo int putchar_unlocked(int); */ 358 #endif 359 #if __BSD_VISIBLE 360 /** @todo void clearerr_unlocked(FILE *); */ 361 /** @todo int feof_unlocked(FILE *); */ 362 /** @todo int ferror_unlocked(FILE *); */ 363 /** @todo int fileno_unlocked(FILE *); */ 364 #endif 365 366 #if __POSIX_VISIBLE >= 200112 367 int fseeko(FILE *, __off_t, int); 368 __off_t ftello(FILE *); 369 #endif 370 371 #if __BSD_VISIBLE || __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600 372 int getw(FILE *); 373 int putw(int, FILE *); 374 #endif /* BSD or X/Open before issue 6 */ 375 376 #if __XSI_VISIBLE 377 char *tempnam(const char *, const char *); 378 #endif 379 380 /* 381 * Routines that are purely local. 382 */ 383 #if __BSD_VISIBLE 384 /** @todo int asprintf(char **, const char *, ...) __printflike(2, 3); */ 385 /** @todo char *ctermid_r(char *); */ 386 /** @todo char *fgetln(FILE *, size_t *); */ 387 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3 388 #define __ATTR_FORMAT_ARG __attribute__((__format_arg__(2))) 389 #else 390 #define __ATTR_FORMAT_ARG 391 #endif 392 /** @todo __const char *fmtcheck(const char *, const char *) __ATTR_FORMAT_ARG; */ 393 /** @todo int fpurge(FILE *); */ 394 void setbuffer(FILE *, char *, int); 395 /** @todo int setlinebuf(FILE *); */ 396 /** @todo int vasprintf(char **, const char *, __va_list) 397 __printflike(2, 0); */ 398 399 /* 400 * The system error table contains messages for the first sys_nerr 401 * positive errno values. Use strerror() or strerror_r() from <string.h> 402 * instead. 403 */ 404 extern __const int sys_nerr; 405 extern __const char *__const sys_errlist[]; 406 407 /* 408 * Stdio function-access interface. 409 */ 410 /** @todo FILE *funopen(const void *, 411 int (*)(void *, char *, int), 412 int (*)(void *, const char *, int), 413 fpos_t (*)(void *, fpos_t, int), 414 int (*)(void *)); */ 415 /** @todo #define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) */ 416 /** @todo #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) */ 417 418 /* 419 * Portability hacks. See <sys/types.h>. 420 */ 421 #ifndef _FTRUNCATE_DECLARED 422 #define _FTRUNCATE_DECLARED 423 int ftruncate(int, __off_t); 424 #endif 425 #ifndef _LSEEK_DECLARED 426 #define _LSEEK_DECLARED 427 __off_t lseek(int, __off_t, int); 428 #endif 429 #ifndef _MMAP_DECLARED 430 #define _MMAP_DECLARED 431 void *mmap(void *, size_t, int, int, int, __off_t); 432 #endif 433 #ifndef _TRUNCATE_DECLARED 434 #define _TRUNCATE_DECLARED 435 int truncate(const char *, __off_t); 436 #endif 437 #endif /* __BSD_VISIBLE */ 438 439 #if 0 /* bird: Skip FreeBSD sepcific LIBC stuff. */ 440 /* 441 * Functions internal to the implementation. 442 */ 443 int __srget(FILE *); 444 int __swbuf(int, FILE *); 445 446 /* 447 * The __sfoo macros are here so that we can 448 * define function versions in the C library. 449 */ 450 #define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) 451 #if defined(__GNUC__) && defined(__STDC__) 452 static __inline int __sputc(int _c, FILE *_p) { 453 if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) 454 return (*_p->_p++ = _c); 455 else 456 return (__swbuf(_c, _p)); 457 } 458 #else 459 /* 460 * This has been tuned to generate reasonable code on the vax using pcc. 461 */ 462 #define __sputc(c, p) \ 463 (--(p)->_w < 0 ? \ 464 (p)->_w >= (p)->_lbfsize ? \ 465 (*(p)->_p = (c)), *(p)->_p != '\n' ? \ 466 (int)*(p)->_p++ : \ 467 __swbuf('\n', p) : \ 468 __swbuf((int)(c), p) : \ 469 (*(p)->_p = (c), (int)*(p)->_p++)) 470 #endif 471 472 #define __sfeof(p) (((p)->_flags & __SEOF) != 0) 473 #define __sferror(p) (((p)->_flags & __SERR) != 0) 474 #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) 475 #define __sfileno(p) ((p)->_file) 476 477 #if __BSD_VISIBLE 478 /* 479 * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12 480 * B.8.2.7 for the rationale behind the *_unlocked() macros. 481 */ 482 #define feof_unlocked(p) __sfeof(p) 483 #define ferror_unlocked(p) __sferror(p) 484 #define clearerr_unlocked(p) __sclearerr(p) 485 #define fileno_unlocked(p) __sfileno(p) 486 #endif 487 #if __POSIX_VISIBLE >= 199506 488 #define getc_unlocked(fp) __sgetc(fp) 489 #define putc_unlocked(x, fp) __sputc(x, fp) 490 491 #define getchar_unlocked() getc_unlocked(stdin) 492 #define putchar_unlocked(x) putc_unlocked(x, stdout) 493 #endif 494 495 #endif /* bird: Skip FreeBSD sepcific LIBC stuff. */ 496 497 498 /* bird: start of EMX isms. */ 77 499 78 500 #if !defined (_IOREAD) 501 /** @todo change to double underscore prefix to prevent confusion with 502 * setvbuf() constants. See the short rant about it above. */ 79 503 #define _IOREAD 0x01 80 504 #define _IOWRT 0x02 … … 82 506 #define _IOEOF 0x08 83 507 #define _IOERR 0x10 84 #define _IOFBF 0x00 85 #define _IOLBF 0x20 86 #define _IONBF 0x40 87 #endif 88 89 #if !defined (FOPEN_MAX) 90 #define FOPEN_MAX 14 91 #endif 92 93 #if !defined (FILENAME_MAX) 94 #define FILENAME_MAX 260 95 #endif 96 97 #if !defined (TMP_MAX) 98 #define TMP_MAX 1000 99 #endif 100 101 #if !defined (P_tmpdir) 102 #define P_tmpdir "." 103 #define L_tmpnam (sizeof (P_tmpdir) + 13) 104 #endif 105 106 #if !defined (L_cuserid) 107 #define L_cuserid 9 108 #endif 109 110 #if !defined (_FPOS_T) 111 #define _FPOS_T 112 typedef struct 113 { 114 long _pos; 115 long _reserved1; 116 short _mbstate; 117 short _reserved2; 118 } fpos_t; 119 #endif 120 121 122 void clearerr (FILE *); 123 int fclose (FILE *); 124 int feof (FILE *); 125 int ferror (FILE *); 126 int fflush (FILE *); 127 int fgetc (FILE *); 128 int fgetpos (FILE *, fpos_t *); 129 char *fgets (char *, int, FILE *); 130 FILE *fopen (__const__ char *, __const__ char *); 131 int fprintf (FILE *, __const__ char *, ...); 132 int fputc (int, FILE *); 133 int fputs (__const__ char *, FILE *); 134 size_t fread (void *, size_t, size_t, FILE *); 135 FILE *freopen (__const__ char *, __const__ char *, FILE *); 136 int fscanf (FILE *, __const__ char *, ...); 137 int fseek (FILE *, long, int); 138 int fsetpos (FILE *, __const__ fpos_t *); 139 long ftell (FILE *); 140 size_t fwrite (__const__ void *, size_t, size_t, FILE *); 141 int getchar (void); 142 char *gets (char *); 143 void perror (__const__ char *); 144 int printf (__const__ char *, ...); 145 int putchar (int); 146 int puts (__const__ char *); 147 int remove (__const__ char *); 148 int rename (__const__ char *, __const__ char *); 149 void rewind (FILE *); 150 int scanf (__const__ char *, ...); 151 int setbuf (FILE *, char *); 152 int setvbuf (FILE *, char *, int, size_t); 153 int sprintf (char *, __const__ char *, ...); 154 int sscanf (__const__ char *, __const__ char *, ...); 155 FILE *tmpfile (void); 156 char *tmpnam (char *); 157 int ungetc (int, FILE *); 158 int vfprintf (FILE *, __const__ char *, va_list); 159 int vprintf (__const__ char *, va_list); 160 int vsprintf (char *, __const__ char *, va_list); 508 #endif 161 509 162 510 int _fill (FILE *); … … 174 522 } 175 523 176 #define getc(s) fgetc(s)177 #define putc(c,s) fputc(c,s)178 179 524 extern __inline__ int getchar (void) { return getc (stdin); } 180 525 extern __inline__ int putchar (int _c) { return putc (_c, stdout); } 181 526 182 183 #if !defined (__STRICT_ANSI__)184 185 /* POSIX.1 */186 187 /* ctermid() */188 FILE *fdopen (int, __const__ char *);189 int fileno (FILE *);190 191 extern __inline__ int fileno (FILE *_s) { return _s->_handle; }192 193 #endif194 195 196 527 #if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) 197 528 198 529 char *cuserid (char *); 199 int getw (FILE *);200 530 int fcloseall (void); 201 531 int fgetchar (void); 202 532 int flushall (void); 203 533 int fputchar (int); 204 int pclose (FILE *);205 FILE *popen (__const__ char *, __const__ char *);206 int putw (int, FILE *);207 int setbuffer (FILE *, char *, size_t);208 int snprintf (char *, size_t, __const__ char *, ...);209 char *tempnam (__const__ char *, __const__ char *);210 int vfscanf (FILE *, __const__ char *, va_list);211 int vscanf (__const__ char *, va_list);212 int vsnprintf (char *, size_t, __const__ char *, va_list);213 int vsscanf (__const__ char *, __const__ char *, va_list);214 534 215 535 #endif … … 234 554 FILE *_popen (__const__ char *, __const__ char *); 235 555 int _putw (int, FILE *); 236 int _setbuffer (FILE *, char *, size_t);556 void _setbuffer (FILE *, char *, int); 237 557 int _snprintf (char *, size_t, __const__ char *, ...); 238 558 char *_tempnam (__const__ char *, __const__ char *); … … 240 560 241 561 #endif 242 243 244 #if defined (__cplusplus) 245 } 246 #endif 247 248 #endif /* not _STDIO_H */ 562 /* bird: end of EMX isms. */ 563 564 __END_DECLS 565 #endif /* !_STDIO_H_ */ 566 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/_types.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r731 r732 57 57 typedef int __nl_item; 58 58 typedef __uint16_t __nlink_t; /* link count */ 59 #if 1/* bird: emx */59 #if 0 /* bird: emx */ 60 60 typedef __int32_t __off_t; /* file offset */ 61 61 #else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/dir.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r731 r732 1 /* sys/dir.h (emx+gcc) */ 1 /* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)dir.h 8.2 (Berkeley) 1/4/94 34 * $FreeBSD: src/sys/sys/dir.h,v 1.6 1999/08/28 00:51:39 peter Exp $ 35 */ 2 36 3 #ifndef _SYS_DIR_H 4 #define _SYS_DIR_H 37 /** @file 38 * FreeBSD 5.1 39 */ 5 40 6 #if !defined (_SYS_TYPES_H) 7 #warning <sys/dir.h> requires <sys/types.h> 8 #include <sys/types.h> 41 #ifndef _SYS_DIR_H_ 42 #define _SYS_DIR_H_ 43 44 #if __GNUC__ 45 #warning "The information in this file should be obtained from <dirent.h>" 46 #warning "and is provided solely (and temporarily) for backward compatibility." 9 47 #endif 10 48 11 #if defined (__cplusplus) 12 extern "C" { 13 #endif 49 #include <dirent.h> 14 50 15 #if !defined (MAXNAMLEN) 16 #define MAXNAMLEN 260 17 #endif 51 /* 52 * Backwards compatibility. 53 */ 54 #define direct dirent 55 #define DIRSIZ(dp) _GENERIC_DIRSIZ(dp) 18 56 19 #if !defined (MAXPATHLEN) 20 #define MAXPATHLEN 260 21 #endif 22 23 #if !defined (A_RONLY) 24 #define A_RONLY 0x01 25 #define A_HIDDEN 0x02 26 #define A_SYSTEM 0x04 27 #define A_LABEL 0x08 28 #define A_DIR 0x10 29 #define A_ARCHIVE 0x20 30 #endif 31 32 #define _DIRECT_D_MODE_RENAMED_D_ATTR 33 34 struct direct 35 { 36 ino_t d_ino; /* Almost not used */ 37 int d_reclen; /* Almost not used */ 38 int d_namlen; /* Length of d_name */ 39 char d_name[MAXNAMLEN + 1]; /* File name, 0 terminated */ 40 long d_size; /* File size (bytes) */ 41 unsigned short d_attr; /* OS file attributes */ 42 unsigned short d_time; /* OS file modification time */ 43 unsigned short d_date; /* OS file modification date */ 44 }; 45 46 struct _dircontents 47 { 48 char * _d_entry; 49 long _d_size; 50 unsigned short _d_attr; 51 unsigned short _d_time; 52 unsigned short _d_date; 53 struct _dircontents * _d_next; 54 }; 55 56 struct _dirdesc 57 { 58 int dd_id; 59 long dd_loc; 60 struct _dircontents * dd_contents; 61 struct _dircontents * dd_cp; 62 }; 63 64 typedef struct _dirdesc DIR; 65 66 DIR *opendir (__const__ char *name); 67 struct direct *readdir (DIR *dirp); 68 void seekdir (DIR *dirp, long off); 69 long telldir (DIR *dirp); 70 int closedir (DIR *dirp); 71 void rewinddir (DIR *dirp); 72 73 #if defined (__cplusplus) 74 } 75 #endif 76 77 #endif /* not SYS_DIR_H */ 57 #endif /* !_SYS_DIR_H_ */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/dirent.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r731 r732 1 /* sys/dirent.h (emx+gcc) */ 1 /*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)dirent.h 8.3 (Berkeley) 8/10/94 34 * $FreeBSD: src/sys/sys/dirent.h,v 1.13 2002/09/10 18:12:16 mike Exp $ 35 */ 2 36 3 #ifndef _SYS_DIRENT_H 4 #define _SYS_DIRENT_H 37 /** @file 38 * FreeBSD 5.1 39 * @changed bird: Merged in all the EMX stuff. 40 */ 5 41 6 #if !defined (_SYS_TYPES_H) 7 #warning <sys/dirent.h> requires <sys/types.h> 8 #include <sys/types.h> 42 #ifndef _SYS_DIRENT_H_ 43 #define _SYS_DIRENT_H_ 44 45 #include <sys/cdefs.h> 46 #include <sys/_types.h> 47 48 /* 49 * The dirent structure defines the format of directory entries returned by 50 * the getdirentries(2) system call. 51 * 52 * A directory entry has a struct dirent at the front of it, containing its 53 * inode number, the length of the entry, and the length of the name 54 * contained in the entry. These are followed by the name padded to a 4 55 * byte boundary with null bytes. All names are guaranteed null terminated. 56 * The maximum length of a name in a directory is MAXNAMLEN. 57 */ 58 59 struct dirent { 60 __uint32_t d_fileno; /* file number of entry */ 61 __uint16_t d_reclen; /* length of this record */ 62 __uint8_t d_type; /* file type, see below */ 63 __uint8_t d_namlen; /* length of string in d_name */ 64 #if __BSD_VISIBLE 65 #ifndef MAXNAMLEN /* bird: emx */ 66 #define MAXNAMLEN 260 /* bird: changed from 255. */ 67 #endif /* bird: emx */ 68 char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ 69 #else 70 char d_name[260 + 1]; /* bird: changed from 255. */ /* name must be no longer than this */ 71 #endif 72 /* bird: Extra EMX fields - start */ 73 __uint8_t d_attr; /* OS file attributes */ 74 __uint16_t d_time; /* OS file modification time */ 75 __uint16_t d_date; /* OS file modification date */ 76 __off_t d_size; /* File size (bytes) */ 77 /* bird: Extra EMX fields - end */ 78 }; 79 80 #if __BSD_VISIBLE 81 /* 82 * File types 83 */ 84 #define DT_UNKNOWN 0 85 #define DT_FIFO 1 86 #define DT_CHR 2 87 #define DT_DIR 4 88 #define DT_BLK 6 89 #define DT_REG 8 90 #define DT_LNK 10 91 #define DT_SOCK 12 92 #define DT_WHT 14 93 94 /* 95 * Convert between stat structure types and directory types. 96 */ 97 #define IFTODT(mode) (((mode) & 0170000) >> 12) 98 #define DTTOIF(dirtype) ((dirtype) << 12) 99 100 /* 101 * The _GENERIC_DIRSIZ macro gives the minimum record length which will hold 102 * the directory entry. This requires the amount of space in struct direct 103 * without the d_name field, plus enough space for the name with a terminating 104 * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. 105 * 106 * XXX although this macro is in the implementation namespace, it requires 107 * a manifest constant that is not. 108 */ 109 #define _GENERIC_DIRSIZ(dp) \ 110 ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) 111 #endif /* __BSD_VISIBLE */ 112 113 #ifdef _KERNEL 114 #define GENERIC_DIRSIZ(dp) _GENERIC_DIRSIZ(dp) 9 115 #endif 10 116 11 #if !defined (MAXNAMLEN) 12 #define MAXNAMLEN 260 13 # endif117 118 /* bird: EMX stuff */ 119 #define _DIRENT_D_MODE_RENAMED_D_ATTR 14 120 15 121 #if !defined (MAXPATHLEN) … … 26 132 #endif 27 133 28 #define _DIRENT_D_MODE_RENAMED_D_ATTR29 30 struct dirent31 {32 ino_t d_ino; /* Almost not used */33 int d_reclen; /* Almost not used */34 int d_namlen; /* Length of d_name */35 char d_name[MAXNAMLEN + 1]; /* File name, 0 terminated */36 long d_size; /* File size (bytes) */37 unsigned short d_attr; /* OS file attributes */38 unsigned short d_time; /* OS file modification time */39 unsigned short d_date; /* OS file modification date */40 };41 42 134 #endif /* not SYS_DIRENT_H */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/dirtree.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r731 r732 4 4 #define _SYS_DIRTREE_H 5 5 6 #if defined (__cplusplus) 7 extern "C" { 6 #include <sys/cdefs.h> 7 #include <sys/_types.h> 8 9 #if !defined(_TIME_T_DECLARED) && !defined(_TIME_T) 10 typedef __time_t time_t; 11 #define _TIME_T_DECLARED 12 #define _TIME_T 8 13 #endif 9 14 10 #if !defined (_TIME_T) 11 #define _TIME_T 12 typedef unsigned long time_t; 15 #if !defined(_OFF_T_DECLARED) && !defined(_OFF_T) 16 typedef __off_t off_t; /* file offset */ 17 #define _OFF_T_DECLARED 18 #define _OFF_T 13 19 #endif 14 20 … … 18 24 struct _dt_node *sub; /* Pointer to next level (child) */ 19 25 char *name; /* Name */ 20 long size;/* File size */26 off_t size; /* File size */ 21 27 long user; /* Available for user */ 22 28 time_t mtime; /* Timestamp for last update */ 23 29 unsigned char attr; /* Attributes */ 24 30 }; 25 26 31 27 32 struct _dt_tree … … 34 39 #define _DT_NOCPDIR 0x8000 35 40 36 void _dt_free (struct _dt_tree *dt); 41 __BEGIN_DECLS 42 void _dt_free (struct _dt_tree *dt); 37 43 struct _dt_tree *_dt_read (__const__ char *dir, __const__ char *mask, 38 44 unsigned flags); 39 void _dt_sort (struct _dt_tree *dt, __const__ char *spec); 40 int _dt_split (__const__ char *src, char *dir, char *mask); 45 void _dt_sort (struct _dt_tree *dt, __const__ char *spec); 46 int _dt_split (__const__ char *src, char *dir, char *mask); 47 __END_DECLS 41 48 42 #if defined (__cplusplus) 43 } 44 #endif 45 46 #endif /* not _SYS_DIRTREE_H */ 49 #endif /* !_SYS_DIRTREE_H */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_flushst.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 52 52 w = 0; 53 53 if (pflags != NULL && (*pflags & O_APPEND)) 54 lseek (fh, 0 L, SEEK_END);54 lseek (fh, 0, SEEK_END); 55 55 } 56 56 stream->_ptr = stream->_buffer; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_seekhdr.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 22 22 unsigned short hdr_loc_hi; 23 23 } patch; 24 longoriginal_pos;24 off_t original_pos; 25 25 int saved_errno; 26 26 … … 37 37 goto failure; 38 38 if (lseek (handle, original_pos + patch.hdr_loc_lo 39 + 65536 L* patch.hdr_loc_hi, SEEK_SET) == -1)39 + 65536 * patch.hdr_loc_hi, SEEK_SET) == -1) 40 40 goto failure; 41 41 return 0; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_vsopen.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 14 14 /* O_TEXT|O_WRONLY does/can not overwrite Ctrl-Z */ 15 15 16 #define FALSE 017 #define TRUE 118 19 16 int _fmode_bin; /* Set non-zero to make binary mode default */ 20 17 21 18 #define SH_MASK 0x70 22 19 23 /* This function may be called as follows (assuming that oflag does 24 not include O_CREAT nor O_SIZE): 20 /** 21 * This function may be called as follows (assuming that fOpen does 22 * not include O_CREAT nor O_SIZE): 23 * 24 * _vsopen(pszName, fOpen, fShare) 25 * _vsopen(pszName, fOpen | O_CREAT, fShare, pmode) 26 * _vsopen(pszName, fOpen | O_SIZE, fShare, off_t size) 27 * _vsopen(pszName, fOpen | O_CREAT | O_SIZE, fShare, pmode, off_t size) 28 * 29 * @remark O_SIZE means a off_t sized argument not unsigned long as emxlib say. 30 */ 31 int _vsopen(const char *pszName, int fOpen, int fShare, va_list va) 32 { 33 int hFile; 34 /** Flags is for __open. 35 * 0 - 1 Access mode (O_RDONLY, O_WRONLY, O_RDWR). 36 * 4 - 6 Shared (SH_*) 37 * 8 - 15 File attributes (DOS style). 38 * 16 - 23 __open flags, _SO_* 39 */ 40 int fFlags; 41 int *pfFlags; 42 int saved_errno; 43 int bits; 44 char chDummy; 45 int fCtrlZKludge = 0; 46 off_t cbInitial; 25 47 26 _vsopen (name, oflag, shflag) 27 _vsopen (name, oflag | O_CREAT, shflag, pmode) 28 _vsopen (name, oflag | O_SIZE, shflag, size) 29 _vsopen (name, oflag | O_CREAT | O_SIZE, shflag, pmode, size) */ 30 31 int _vsopen (const char *name, int oflag, int shflag, va_list va) 32 { 33 int handle, flags, *pflags, saved_errno; 34 int bits; 35 char dummy, ctrlz_kludge = FALSE; 36 unsigned long initial_size; 37 38 if ((oflag & O_ACCMODE) == O_RDONLY && (oflag & (O_TRUNC|O_CREAT))) 48 /* 49 * Validate input 50 */ 51 if ((fOpen & O_ACCMODE) == O_RDONLY && (fOpen & (O_TRUNC|O_CREAT))) 39 52 { 40 errno = EINVAL; 41 return -1; 42 } 43 44 bits = oflag & (O_ACCMODE|O_NDELAY|O_APPEND); 45 if (oflag & O_BINARY) 46 /* do nothing */; 47 else if (oflag & O_TEXT) 48 bits |= O_TEXT; 49 else if (_fmode_bin == 0) /* neither O_TEXT nor O_BINARY given */ 50 bits |= O_TEXT; 51 52 if ((bits & O_TEXT) && (oflag & O_APPEND) && (oflag & O_ACCMODE) == O_WRONLY) 53 { 54 /* The caller requests to open a text file for appending in 55 write-only. To remove the Ctrl-Z (if there is any), we have 56 to temporarily open the file in read/write mode. */ 57 58 flags = O_RDWR | (shflag & SH_MASK); 59 ctrlz_kludge = TRUE; 60 } 61 else 62 flags = (oflag & O_ACCMODE) | (shflag & SH_MASK); 63 64 if (oflag & O_CREAT) 65 { 66 int attr, pmode; 67 68 attr = 0; 69 pmode = va_arg (va, int); 70 if (!(pmode & S_IWRITE)) 71 attr |= _A_RDONLY; 72 flags |= (attr << 8) | _SO_CREAT; 73 if (oflag & O_EXCL) 74 flags |= _SO_EXCL; 75 } 76 77 if (oflag & O_TRUNC) 78 flags |= _SO_TRUNC; 79 80 if (oflag & O_NOINHERIT) 81 flags |= _SO_NOINHERIT; 82 83 if (oflag & O_SYNC) 84 flags |= _SO_SYNC; 85 86 initial_size = 0; 87 if (oflag & O_SIZE) 88 { 89 initial_size = va_arg (va, unsigned long); 90 flags |= _SO_SIZE; 91 } 92 93 saved_errno = errno; 94 handle = __open (name, flags, initial_size); 95 if (handle < 0 && ctrlz_kludge && errno == EACCES) 96 { 97 /* Perhaps read access is denied. Try again. */ 98 errno = saved_errno; 99 ctrlz_kludge = FALSE; 100 flags = (flags & ~O_ACCMODE) | (oflag & O_ACCMODE); 101 handle = __open (name, flags, initial_size); 102 } 103 if (handle < 0) 104 return -1; 105 106 if (__ioctl1 (handle, 0) & 0x80) 107 { 108 bits |= F_DEV; 109 oflag &= ~O_APPEND; 110 } 111 112 if (!(bits & F_DEV) && (bits & O_TEXT)) 113 { 114 long size; 115 116 /* Remove the last character of the file if it is a Ctrl-Z. Do 117 this even if O_SIZE is given as we don't know whether the 118 file existed before; removing a spurious Ctrl-Z due to O_SIZE 119 should be harmless. */ 120 121 /* DEC Pathworks seems to treat the offset as unsigned number. 122 Therefore we do not use __lseek (handle, -1L, SEEK_END). */ 123 124 size = __lseek (handle, 0L, SEEK_END); 125 if (size > 0 && __lseek (handle, size - 1, SEEK_SET) != -1L 126 && __read (handle, &dummy, 1) == 1 && dummy == 0x1a) 127 __ftruncate (handle, size - 1); /* Remove Ctrl-Z */ 128 __lseek (handle, 0L, SEEK_SET); 129 } 130 131 if (ctrlz_kludge) 132 { 133 /* Reopen the handle in write-only mode. */ 134 135 __close (handle); 136 flags = (flags & ~O_ACCMODE) | (oflag & O_ACCMODE); 137 flags &= ~_SO_EXCL; /* Ignore O_EXCL */ 138 handle = __open (name, flags, initial_size); 139 if (handle < 0) 53 errno = EINVAL; 140 54 return -1; 141 55 } 142 56 143 pflags = _fd_init (handle); 144 if (pflags == NULL) 57 /* 58 * Build fFlags. 59 */ 60 bits = fOpen & (O_ACCMODE|O_NDELAY|O_APPEND); 61 if (fOpen & O_BINARY) 62 /* do nothing */; 63 else if (fOpen & O_TEXT) 64 bits |= O_TEXT; 65 else if (_fmode_bin == 0) /* neither O_TEXT nor O_BINARY given */ 66 bits |= O_TEXT; 67 68 if ((bits & O_TEXT) && (fOpen & O_APPEND) && (fOpen & O_ACCMODE) == O_WRONLY) 145 69 { 146 __close (handle); 147 errno = EMFILE; 148 return -1; 70 /* The caller requests to open a text file for appending in 71 write-only. To remove the Ctrl-Z (if there is any), we have 72 to temporarily open the file in read/write mode. */ 73 74 fFlags = O_RDWR | (fShare & SH_MASK); 75 fCtrlZKludge = 1; 76 } 77 else 78 fFlags = (fOpen & O_ACCMODE) | (fShare & SH_MASK); 79 80 /* pmode(=attr) - attr is 2nd byte of flags. */ 81 if (fOpen & O_CREAT) 82 { 83 int attr, pmode; 84 85 attr = 0; 86 pmode = va_arg(va, int); 87 if (!(pmode & S_IWRITE)) 88 attr |= _A_RDONLY; 89 fFlags |= (attr << 8) | _SO_CREAT; 90 if (fOpen & O_EXCL) 91 fFlags |= _SO_EXCL; 149 92 } 150 93 151 *pflags = bits; 94 if (fOpen & O_TRUNC) 95 fFlags |= _SO_TRUNC; 152 96 153 /* When opening a file for appending, move to the end of the file.154 This is required for passing the handle to a child process. */97 if (fOpen & O_NOINHERIT) 98 fFlags |= _SO_NOINHERIT; 155 99 156 if (!(bits & F_DEV) && (bits & O_APPEND)) 157 __lseek (handle, 0L, SEEK_END); 158 errno = saved_errno; 100 if (fOpen & O_SYNC) 101 fFlags |= _SO_SYNC; 159 102 160 return handle; 103 /* Initial file size */ 104 cbInitial = 0; 105 if (fOpen & O_SIZE) 106 { 107 cbInitial = va_arg(va, off_t); 108 fFlags |= _SO_SIZE; 109 } 110 111 /* 112 * Open - note Ctrl-Z hack. 113 */ 114 saved_errno = errno; 115 hFile = __open(pszName, fFlags, cbInitial); 116 if (hFile < 0 && fCtrlZKludge && errno == EACCES) 117 { 118 /* Perhaps read access is denied. Try again. */ 119 errno = saved_errno; 120 fCtrlZKludge = 0; 121 fFlags = (fFlags & ~O_ACCMODE) | (fOpen & O_ACCMODE); 122 hFile = __open(pszName, fFlags, cbInitial); 123 } 124 if (hFile < 0) 125 return -1; 126 127 /* 128 * Check what we got a handle to. 129 */ 130 if (__ioctl1(hFile, 0) & 0x80) 131 { 132 bits |= F_DEV; 133 fOpen &= ~O_APPEND; 134 } 135 136 /* 137 * For text files we shall remove eventual ending Ctrl-Z. 138 */ 139 if (!(bits & F_DEV) && (bits & O_TEXT)) 140 { 141 off_t cbSize; 142 143 /* Remove the last character of the file if it is a Ctrl-Z. Do 144 this even if O_SIZE is given as we don't know whether the 145 file existed before; removing a spurious Ctrl-Z due to O_SIZE 146 should be harmless. */ 147 148 cbSize = __lseek(hFile, -1, SEEK_END); 149 if (cbSize >= 0) 150 { 151 if (__read(hFile, &chDummy, 1) == 1 && chDummy == 0x1a) 152 __ftruncate(hFile, cbSize); /* Remove Ctrl-Z */ 153 __lseek(hFile, 0L, SEEK_SET); 154 } 155 } 156 157 /* 158 * Reopen the file in write-only mode if Ctrl-Z hack applied. 159 */ 160 if (fCtrlZKludge) 161 { 162 __close(hFile); 163 fFlags = (fFlags & ~O_ACCMODE) | (fOpen & O_ACCMODE); 164 fFlags &= ~_SO_EXCL; /* Ignore O_EXCL */ 165 hFile = __open(pszName, fFlags, cbInitial); 166 if (hFile < 0) 167 return -1; 168 } 169 170 /* 171 * Set file bits. 172 */ 173 pfFlags = _fd_init(hFile); 174 if (!pfFlags) 175 { 176 __close(hFile); 177 errno = EMFILE; 178 return -1; 179 } 180 *pfFlags = bits; 181 182 /* 183 * When opening a file for appending, move to the end of the file. 184 * This is required for passing the file to a child process. 185 */ 186 if (!(bits & F_DEV) && (bits & O_APPEND)) 187 __lseek(hFile, 0L, SEEK_END); 188 errno = saved_errno; 189 190 return hFile; 161 191 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/chsize.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 8 8 #include <emx/syscalls.h> 9 9 10 int _STD(chsize) (int handle, longlength)10 int _STD(chsize) (int handle, off_t length) 11 11 { 12 long n; 13 int i, j, *pflags; 12 off_t n; 13 off_t i; 14 int j, *pflags; 14 15 char zeros[4096]; 15 16 … … 19 20 return -1; 20 21 } 21 n = (long)__lseek (handle, 0L, SEEK_END);22 if (n == -1 L)22 n = __lseek (handle, 0, SEEK_END); 23 if (n == -1) 23 24 return -1; 24 25 if (__chsize (handle, length) != 0) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/eof.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r731 r732 9 9 { 10 10 int *pflags; 11 longcur, len;11 off_t cur, len; 12 12 13 13 if ((pflags = _fd_flags (handle)) == NULL) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fflush.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 15 15 { 16 16 int result, n, ft, saved_errno; 17 longpos;17 off_t pos; 18 18 19 19 result = 0; … … 52 52 write error occurs, otherwise zero." */ 53 53 pos = _ftell_nolock (stream); 54 if (pos != -1 L)54 if (pos != -1) 55 55 lseek (stream->_handle, pos, SEEK_SET); 56 56 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fgetpos.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 6 6 int _STD(fgetpos) (FILE *stream, fpos_t *pos) 7 7 { 8 long n; 9 10 if ((n = ftell (stream)) == (long)EOF) 8 __off_t off; 9 *pos = EOF; /* crash test */ 10 off = ftello (stream); 11 if (off == EOF) 11 12 return EOF; 12 pos->_pos = n; 13 pos->_reserved1 = 0; 14 pos->_mbstate = stream->_mbstate; 15 pos->_reserved2 = 0; 13 *pos = (fpos_t)off; 16 14 return 0; 17 15 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fileleng.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 5 5 #include <emx/syscalls.h> 6 6 7 long_STD(filelength) (int handle)7 off_t _STD(filelength) (int handle) 8 8 { 9 long cur, n;9 off_t offcur, offend; 10 10 11 cur = (long)__lseek (handle, 0L, SEEK_CUR);12 if ( cur == -1L)11 offcur = __lseek (handle, 0L, SEEK_CUR); 12 if (offcur == -1) 13 13 return -1; 14 n = (long)__lseek (handle, 0L, SEEK_END);15 __lseek (handle, cur, SEEK_SET);16 return n;14 offend = __lseek (handle, 0L, SEEK_END); 15 __lseek (handle, offcur, SEEK_SET); 16 return offend; 17 17 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fseek.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 11 11 #include <emx/io.h> 12 12 13 int _fseek_nolock (FILE *stream, longoffset, int origin)13 int _fseek_nolock (FILE *stream, off_t offset, int origin) 14 14 { 15 longcur_pos;15 off_t cur_pos; 16 16 int fflush_result, *pflags; 17 17 … … 35 35 && bbuf (stream) && stream->_ungetc_count == 0) 36 36 { 37 longfile_pos, end_pos, buf_pos;37 off_t file_pos, end_pos, buf_pos; 38 38 int text_mode, n; 39 39 … … 48 48 else if (origin == SEEK_END) 49 49 { 50 end_pos = lseek (stream->_handle, 0 L, SEEK_END);50 end_pos = lseek (stream->_handle, 0, SEEK_END); 51 51 lseek (stream->_handle, file_pos, SEEK_SET); 52 52 if (end_pos == -1) … … 96 96 if (offset >= buf_pos) 97 97 { 98 longtmp_pos;98 off_t tmp_pos; 99 99 100 100 /* The new position is within the buffer. Adjust … … 179 179 180 180 181 int _STD(fseeko) (FILE *stream, off_t offset, int origin) 182 { 183 int result; 184 185 STREAM_LOCK (stream); 186 result = _fseek_nolock (stream, offset, origin); 187 STREAM_UNLOCK (stream); 188 return result; 189 } 190 181 191 int _STD(fseek) (FILE *stream, long offset, int origin) 182 192 { 183 int result; 184 185 STREAM_LOCK (stream); 186 result = _fseek_nolock (stream, offset, origin); 187 STREAM_UNLOCK (stream); 188 return result; 193 return fseeko (stream, (off_t)offset, origin); 189 194 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fsetpos.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 6 6 int _STD(fsetpos) (FILE *stream, const fpos_t *pos) 7 7 { 8 if (fseek (stream, pos->_pos, SEEK_SET) != 0)8 if (fseeko (stream, (__off_t)*pos, SEEK_SET) != 0) 9 9 return -1; 10 stream->_mbstate = pos->_mbstate;11 10 return 0; 12 11 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/ftell.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 11 11 #include <emx/io.h> 12 12 13 long_ftell_nolock (FILE *stream)13 off_t _ftell_nolock (FILE *stream) 14 14 { 15 longpos;16 int * pflags;15 off_t pos; 16 int * pflags; 17 17 18 18 if (stream->_flags & _IOSPECIAL) … … 98 98 } 99 99 100 __off_t _STD(ftello) (FILE *stream) 101 { 102 off_t off; 103 104 STREAM_LOCK (stream); 105 off = _ftell_nolock (stream); 106 STREAM_UNLOCK (stream); 107 return off; 108 } 100 109 101 110 long _STD(ftell) (FILE *stream) 102 111 { 103 long r; 104 105 STREAM_LOCK (stream); 106 r = _ftell_nolock (stream); 107 STREAM_UNLOCK (stream); 108 return r; 112 off_t off = ftello (stream); 113 #if OFF_MAX > LONG_MAX 114 if (off > LONG_MAX) 115 { 116 errno = EOVERFLOW; 117 return -1; 118 } 119 return (long)off; 120 #else 121 return off; 122 #endif 109 123 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/lseek.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r731 r732 10 10 { 11 11 int *pflags, *pla; 12 longn, cur;12 off_t n, cur; 13 13 14 14 if ((pflags = _fd_flags (handle)) == NULL … … 28 28 return -1; 29 29 } 30 cur = (long)__lseek (handle, 0L, SEEK_CUR);30 cur = __lseek (handle, 0, SEEK_CUR); 31 31 if (cur == -1L) 32 32 return -1; 33 n = (long)__lseek (handle, 0L, origin);33 n = __lseek (handle, 0, origin); 34 34 if (n + offset < 0) 35 35 { … … 40 40 offset += n; origin = SEEK_SET; 41 41 } 42 n = (long)__lseek (handle, offset, origin);43 if (n == -1 L)42 n = __lseek (handle, offset, origin); 43 if (n == -1) 44 44 return -1; 45 45 else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/open.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 7 7 #include <emx/io.h> 8 8 9 /** 10 * @remark O_SIZE means a off_t sized argument not unsigned long as emxlib say. 11 */ 9 12 int _STD(open) (const char *name, int oflag, ...) 10 13 { -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/rewind.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 13 13 STREAM_LOCK (stream); 14 14 _fflush_nolock (stream); 15 _fseek_nolock (stream, 0 L, SEEK_SET);15 _fseek_nolock (stream, 0, SEEK_SET); 16 16 stream->_flags &= ~_IOERR; 17 17 STREAM_UNLOCK (stream); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/setbuf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 4 4 #include <stdio.h> 5 5 6 int_STD(setbuf) (FILE *stream, char *buffer)6 void _STD(setbuf) (FILE *stream, char *buffer) 7 7 { 8 returnsetvbuf (stream, buffer, (buffer != NULL ? _IOFBF : _IONBF), BUFSIZ);8 setvbuf (stream, buffer, (buffer != NULL ? _IOFBF : _IONBF), BUFSIZ); 9 9 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/setbuffe.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 4 4 #include <stdio.h> 5 5 6 int _STD(setbuffer) (FILE *stream, char *buffer, size_t size)6 void _STD(setbuffer) (FILE *stream, char *buffer, int size) 7 7 { 8 return setvbuf (stream, buffer, (buffer != NULL ? _IOFBF : _IONBF),size);8 setvbuf (stream, buffer, (buffer != NULL ? _IOFBF : _IONBF), (size_t)size); 9 9 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/sopen.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r731 r732 6 6 #include <emx/io.h> 7 7 8 /** 9 * @remark O_SIZE means a off_t sized argument not unsigned long as emxlib say. 10 */ 8 11 int _STD(sopen) (const char *name, int oflag, int shflag, ...) 9 12 { -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/tell.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 7 7 #include <emx/syscalls.h> 8 8 9 long_STD(tell) (int handle)9 off_t _STD(tell) (int handle) 10 10 { 11 11 int *pflags, *pla; 12 longn;12 off_t n; 13 13 14 14 if ((pflags = _fd_flags (handle)) == NULL … … 18 18 return -1; 19 19 } 20 n = (long)__lseek (handle, 0L, SEEK_CUR);20 n = __lseek (handle, 0L, SEEK_CUR); 21 21 if (n == -1) 22 22 return n; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/write.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 122 122 else 123 123 { 124 longpos;124 off_t pos; 125 125 int saved_errno; 126 126 127 127 saved_errno = errno; 128 pos = __lseek (handle, -1 L, SEEK_CUR);128 pos = __lseek (handle, -1, SEEK_CUR); 129 129 if (pos != -1) 130 130 __ftruncate (handle, pos); … … 148 148 } 149 149 if ((*pflags & (F_DEV|F_SOCKET|F_PIPE|O_APPEND)) == O_APPEND) 150 __lseek (handle, 0 L, SEEK_END);150 __lseek (handle, 0, SEEK_END); 151 151 if (nbyte == 0) /* Avoid truncation of file */ 152 152 return 0; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.16
to1.17
r731 r732 73 73 "___locale_time" @53 74 74 "__sys_virtual_address_limit" @54 75 "___pfnDosOpenL" @55 76 "___pfnDosSetFileLocksL" @56 77 "___pfnDosSetFilePtrL" @57 78 "___pfnDosSetFileSizeL" @58 75 79 76 80 ; code … … 808 812 "__std_unsetenv" @831 809 813 "__std_lockf" @832 814 "___init_largefileio" @833 815 "__std_fseeko" @834 816 "__std_ftello" @835 817 "__std_readdir_r" @836 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/dirent.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r731 r732 12 12 #include <emx/syscalls.h> 13 13 14 struct _dircontents15 {16 char * _d_entry;17 long _d_size;18 unsigned short _d_attr;19 unsigned short _d_time;20 unsigned short _d_date;21 struct _dircontents * _d_next;22 };23 24 struct _dirdesc25 {26 int dd_id;27 long dd_loc;28 struct _dircontents * dd_contents;29 struct _dircontents * dd_cp;30 struct dirent dd_dirent;31 };32 33 14 34 15 static int _readdir_ino = 31415926; 35 16 36 static void free_dircontents (struct _dircontents *dp); 37 static char *getdirent (const char *dir, struct _find *pfind, 38 const char *base); 39 40 int _STD(closedir) (DIR *dirp) 41 { 42 free_dircontents (dirp->dd_contents); 43 free (dirp); 44 return 0; 45 } 46 47 48 struct dirent *_STD(readdir) (DIR *dirp) 49 { 50 if (dirp->dd_cp == NULL) 17 /******************************************************************************* 18 * Internal Functions * 19 *******************************************************************************/ 20 static void free_dircontents(struct _dircontents *dp); 21 static char *getdirent(const char *dir, struct _find *pfind, const char *base); 22 23 24 static void free_dircontents(struct _dircontents *dp) 25 { 26 while (dp != NULL) 27 { 28 void *pv = dp; 29 dp = dp->_d_next; 30 free(pv); 31 } 32 } 33 34 static char *getdirent(const char *dir, struct _find *pfind, const char *base) 35 { 36 int rc; 37 38 if (dir != NULL) 39 rc = __findfirst(dir, A_DIR | A_HIDDEN | A_SYSTEM, pfind); 40 else 41 rc = __findnext(pfind); 42 if (rc) 43 return NULL; 44 45 _fnlwr2(pfind->szName, base); 46 return pfind->szName; 47 } 48 49 DIR *_STD(opendir)(const char *name) 50 { 51 struct stat statb; 52 struct _find find; 53 DIR * pdir; 54 char * psz; 55 char nbuf[MAXPATHLEN+1]; 56 int cchname; 57 int saved_errno = errno; 58 59 /* 60 * Put directory name in nbuf. 61 */ 62 cchname = strlen(name); 63 memcpy(nbuf, name, cchname + 1); 64 psz = nbuf + cchname; 65 if (_trslash (nbuf, cchname, 0)) 66 { 67 nbuf[cchname++] = '.'; /* psz now points to '.' */ 68 nbuf[cchname] = 0; 69 } 70 71 /* 72 * Check that the directory exists and is a directory. 73 */ 74 if (stat(nbuf, &statb) < 0) 75 return NULL; 76 if ((statb.st_mode & S_IFMT) != S_IFDIR) 77 { 78 errno = ENOTDIR; 79 return NULL; 80 } 81 82 /* 83 * Start enumeration. 84 * We're reading _everything_ now, which isn't such an good idea for 85 * large directories actually. (I wouldn't try this on the FreeDB tree.) 86 */ 87 pdir = malloc(sizeof(DIR)); 88 if (pdir == NULL) 89 { 90 errno = ENOMEM; 91 return NULL; 92 } 93 if (!*psz) /* If dot was added. */ 94 *psz++ = '\\'; 95 strcpy(psz, "*.*"); 96 pdir->dd_loc = 0; 97 pdir->dd_contents = NULL; 98 pdir->dd_cp = NULL; 99 psz = getdirent(nbuf, &find, name); 100 if (psz == NULL) 101 { 102 errno = ENOMEM; 103 return pdir; /* why no free and return? */ 104 } 105 106 do 107 { 108 struct _dircontents * dp; 109 int cch; 110 111 /* 112 * Allocate memory for the directory entry. 113 * To limit number of heap blocks and malloc+free calls, we allocate 114 * on chunk of memory, placing the name after the struct. 115 */ 116 cch = strlen(psz) + 1; 117 dp = malloc(sizeof(struct _dircontents) + cch); 118 if (dp == NULL) 119 { 120 free_dircontents(pdir->dd_contents); 121 errno = ENOMEM; 122 return NULL; 123 } 124 dp->_d_entry = (char*)(dp + 1); 125 126 /* 127 * Enter the data. 128 */ 129 memcpy(dp->_d_entry, psz, cch); 130 if (pdir->dd_contents != NULL) 131 pdir->dd_cp->_d_next = dp; 132 else 133 pdir->dd_contents = dp; 134 pdir->dd_cp = dp; 135 dp->_d_next = NULL; 136 dp->_d_size = find.cbFile; 137 dp->_d_attr = find.attr; 138 dp->_d_time = find.time; 139 dp->_d_date = find.date; 140 141 /* 142 * Next entry. 143 */ 144 psz = getdirent(NULL, &find, name); 145 } while (psz != NULL); 146 147 /* 148 * Position at start 149 */ 150 pdir->dd_cp = pdir->dd_contents; 151 errno = saved_errno; /* getdirent/findnext sets errno when done */ 152 return pdir; 153 } 154 155 156 int _STD(readdir_r)(DIR *dirp, struct dirent *pdent, struct dirent **ppdent) 157 { 158 int cch; 159 /* done? */ 160 if (dirp->dd_cp == NULL) 161 { 162 errno = ENOENT; 163 *ppdent = NULL; 164 return -1; 165 } 166 167 /* 168 * Copy the data over to the entry. 169 */ 170 cch = strlen(dirp->dd_cp->_d_entry); 171 memcpy(pdent->d_name, dirp->dd_cp->_d_entry, cch + 1); 172 pdent->d_namlen = cch; 173 pdent->d_reclen = pdent->d_namlen; 174 pdent->d_ino = _readdir_ino++; 175 if (_readdir_ino == 0) 176 _readdir_ino = 1; 177 pdent->d_type = (pdent->d_attr & A_DIR) ? DT_DIR : DT_REG; 178 pdent->d_size = dirp->dd_cp->_d_size; 179 pdent->d_attr = dirp->dd_cp->_d_attr; 180 pdent->d_time = dirp->dd_cp->_d_time; 181 pdent->d_date = dirp->dd_cp->_d_date; 182 183 /* 184 * Advance the stream and return successfully. 185 */ 186 dirp->dd_cp = dirp->dd_cp->_d_next; 187 dirp->dd_loc++; 188 *ppdent = pdent; 189 return 0; 190 } 191 192 193 struct dirent *_STD(readdir)(DIR *dirp) 194 { 195 struct dirent *p = &dirp->dd_dirent; 196 if (!readdir_r(dirp, p, &p)) 197 return p; 51 198 return NULL; 52 strcpy (dirp->dd_dirent.d_name, dirp->dd_cp->_d_entry); 53 dirp->dd_dirent.d_namlen = strlen (dirp->dd_dirent.d_name); 54 dirp->dd_dirent.d_reclen = dirp->dd_dirent.d_namlen; 55 dirp->dd_dirent.d_ino = _readdir_ino++; 56 if (_readdir_ino == 0) 57 _readdir_ino = 1; 58 dirp->dd_dirent.d_size = dirp->dd_cp->_d_size; 59 dirp->dd_dirent.d_attr = dirp->dd_cp->_d_attr; 60 dirp->dd_dirent.d_time = dirp->dd_cp->_d_time; 61 dirp->dd_dirent.d_date = dirp->dd_cp->_d_date; 62 dirp->dd_cp = dirp->dd_cp->_d_next; 63 ++dirp->dd_loc; 64 return &dirp->dd_dirent; 65 } 66 67 68 void _STD(seekdir) (DIR *dirp, long off) 69 { 70 long i; 71 struct _dircontents *dp; 72 73 if (off >= 0) 74 { 75 i = 0; 76 for (dp = dirp->dd_contents; i < off && dp != NULL; dp = dp->_d_next) 77 ++i; 78 dirp->dd_loc = i; 79 dirp->dd_cp = dp; 80 } 81 else 82 errno = EINVAL; 83 } 84 85 86 void _STD(rewinddir) (DIR *dirp) 87 { 88 _seekdir (dirp, 0L); 89 } 90 91 92 long _STD(telldir) (DIR *dirp) 93 { 94 return dirp->dd_loc; 95 } 96 97 98 DIR *_STD(opendir) (const char *name) 99 { 100 struct stat statb; 101 struct _find find; 102 DIR *dirp; 103 char *s; 104 struct _dircontents *dp; 105 char nbuf[MAXPATHLEN+1]; 106 int len; 107 108 len = strlen (name); 109 memcpy (nbuf, name, len + 1); 110 s = nbuf + len; 111 if (_trslash (nbuf, len, 0)) 112 { 113 nbuf[len++] = '.'; /* s now points to '.' */ 114 nbuf[len] = 0; 115 } 116 if (stat (nbuf, &statb) < 0) 117 return NULL; 118 if ((statb.st_mode & S_IFMT) != S_IFDIR) 119 { 120 errno = ENOTDIR; 121 return NULL; 122 } 123 dirp = malloc (sizeof (DIR)); 124 if (dirp == NULL) 125 { 126 errno = ENOMEM; 127 return NULL; 128 } 129 if (*s == 0) 130 *s++ = '\\'; 131 strcpy (s, "*.*"); 132 dirp->dd_loc = 0; 133 dirp->dd_contents = NULL; 134 dirp->dd_cp = NULL; 135 s = getdirent (nbuf, &find, name); 136 if (s == NULL) 137 { 138 errno = ENOMEM; 139 return dirp; 140 } 141 do 142 { 143 dp = malloc (sizeof (struct _dircontents)); 144 if (dp == NULL) 145 { 146 free_dircontents (dirp->dd_contents); 147 errno = ENOMEM; 148 return NULL; 149 } 150 dp->_d_entry = malloc (strlen (s) + 1); 151 if (dp->_d_entry == NULL) 152 { 153 free (dp); 154 free_dircontents (dirp->dd_contents); 155 errno = ENOMEM; 156 return NULL; 157 } 158 if (dirp->dd_contents != NULL) 159 dirp->dd_cp->_d_next = dp; 160 else 161 dirp->dd_contents = dp; 162 dirp->dd_cp = dp; 163 strcpy (dp->_d_entry, s); 164 dp->_d_next = NULL; 165 dp->_d_size = ((unsigned long)find.size_hi << 16) + find.size_lo; 166 dp->_d_attr = find.attr; 167 dp->_d_time = find.time; 168 dp->_d_date = find.date; 169 s = getdirent (NULL, &find, name); 170 } while (s != NULL); 171 dirp->dd_cp = dirp->dd_contents; 172 return dirp; 173 } 174 175 176 static void free_dircontents (struct _dircontents *dp) 177 { 178 struct _dircontents *odp; 179 180 while (dp != NULL) 181 { 182 if (dp->_d_entry != NULL) 183 free(dp->_d_entry); 184 odp = dp; 185 dp = dp->_d_next; 186 free (odp); 187 } 188 } 189 190 191 static char *getdirent (const char *dir, struct _find *pfind, const char *base) 192 { 193 int rc; 194 195 if (dir != NULL) 196 rc = __findfirst (dir, A_DIR|A_HIDDEN|A_SYSTEM, pfind); 197 else 198 rc = __findnext (pfind); 199 if (rc == 0) 200 { 201 _fnlwr2 (pfind->name, base); 202 return pfind->name; 203 } 204 else 205 return NULL; 206 } 199 } 200 201 202 void _STD(seekdir)(DIR *dirp, long off) 203 { 204 if (off >= 0) 205 { 206 long i; 207 struct _dircontents *dp; 208 209 i = 0; 210 for (dp = dirp->dd_contents; i < off && dp != NULL; dp = dp->_d_next) 211 ++i; 212 dirp->dd_loc = i; 213 dirp->dd_cp = dp; 214 } 215 else 216 errno = EINVAL; 217 } 218 219 220 void _STD(rewinddir)(DIR *dirp) 221 { 222 _seekdir(dirp, 0); 223 } 224 225 226 long _STD(telldir)(DIR *dirp) 227 { 228 return dirp->dd_loc; 229 } 230 231 232 int _STD(closedir)(DIR *dirp) 233 { 234 free_dircontents(dirp->dd_contents); 235 free(dirp); 236 return 0; 237 } 238 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/dtread.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r731 r732 57 57 static int _dt_match (struct _dt_rdata *dp) 58 58 { 59 if ((dp->flags & _DT_NOCPDIR) && (strcmp (dp->find. name, ".") == 0 ||60 strcmp (dp->find. name, "..") == 0))59 if ((dp->flags & _DT_NOCPDIR) && (strcmp (dp->find.szName, ".") == 0 || 60 strcmp (dp->find.szName, "..") == 0)) 61 61 return 0; 62 62 return 1; … … 66 66 static struct _dt_node *_dt_add (struct _dt_rdata *dp) 67 67 { 68 struct _dt_node * new;68 struct _dt_node *pnew; 69 69 struct tm tm; 70 70 71 new = malloc (sizeof (*new));72 if ( new == NULL)71 pnew = malloc (sizeof (*pnew)); 72 if (pnew == NULL) 73 73 { 74 74 errno = ENOMEM; 75 75 return NULL; 76 76 } 77 new->next = NULL;78 new->sub = NULL;79 new->name = strdup (dp->find.name);80 if ( new->name == NULL)77 pnew->next = NULL; 78 pnew->sub = NULL; 79 pnew->name = strdup (dp->find.szName); 80 if (pnew->name == NULL) 81 81 { 82 82 errno = ENOMEM; 83 83 return NULL; 84 84 } 85 _fnlwr2 ( new->name, dp->dir);86 new->size = dp->find.size_lo + ((long)dp->find.size_hi << 16);87 new->user = 0;88 new->attr = dp->find.attr;85 _fnlwr2 (pnew->name, dp->dir); 86 pnew->size = dp->find.cbFile; 87 pnew->user = 0; 88 pnew->attr = dp->find.attr; 89 89 tm.tm_sec = (dp->find.time & 0x1f) * 2; 90 90 tm.tm_min = (dp->find.time >> 5) & 0x3f; … … 94 94 tm.tm_year = ((dp->find.date >> 9) & 0x7f) + 1980 - 1900; 95 95 tm.tm_isdst = -1; /* unknown */ 96 new->mtime = _mktime (&tm);97 _loc2gmt (& new->mtime, -1);98 return new;96 pnew->mtime = _mktime (&tm); 97 _loc2gmt (&pnew->mtime, -1); 98 return pnew; 99 99 } 100 100 … … 103 103 int path_len) 104 104 { 105 struct _dt_node * new, **add;105 struct _dt_node *pnew, **add; 106 106 int r, len2; 107 107 … … 114 114 if (!(dp->dir_pass && (dp->find.attr & A_DIR)) && _dt_match (dp)) 115 115 { 116 new = _dt_add (dp);117 if ( new == NULL)116 pnew = _dt_add (dp); 117 if (pnew == NULL) 118 118 return -1; 119 *add = new;120 add = & new->next;119 *add = pnew; 120 add = &pnew->next; 121 121 } 122 122 r = __findnext (&dp->find); … … 132 132 if ((dp->find.attr & A_DIR) && _dt_match (dp)) 133 133 { 134 new = _dt_add (dp);135 if ( new == NULL)134 pnew = _dt_add (dp); 135 if (pnew == NULL) 136 136 return -1; 137 *add = new;138 add = & new->next;137 *add = pnew; 138 add = &pnew->next; 139 139 } 140 140 r = __findnext (&dp->find); … … 144 144 } 145 145 if (dp->flags & _DT_TREE) 146 for ( new = *dst; new != NULL; new =new->next)147 if (( new->attr & A_DIR) && strcmp (new->name, ".") != 0148 && strcmp ( new->name, "..") != 0)146 for (pnew = *dst; pnew != NULL; pnew = pnew->next) 147 if ((pnew->attr & A_DIR) && strcmp (pnew->name, ".") != 0 148 && strcmp (pnew->name, "..") != 0) 149 149 { 150 len2 = strlen ( new->name);151 strcpy (dp->path + path_len, new->name);150 len2 = strlen (pnew->name); 151 strcpy (dp->path + path_len, pnew->name); 152 152 dp->path[path_len+len2] = '/'; 153 if (_dt_read_recurse (dp, & new->sub, path_len+len2+1) < 0)153 if (_dt_read_recurse (dp, &pnew->sub, path_len+len2+1) < 0) 154 154 return -1; 155 155 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/fnexplod.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 32 32 do 33 33 { 34 if (strcmp (find.name, ".") != 0 && 35 strcmp (find.name, "..") != 0) 34 if ( find.szName[0] != '.' 35 || ( find.szName[1] != '\0' 36 && (find.szName[1] != '.' || find.szName[2] != '\0'))) 36 37 { 37 38 if (n + 1 >= a) … … 46 47 list = tmp; 47 48 } 48 strcpy (p, find. name);49 strcpy (p, find.szName); 49 50 _fnlwr2 (name, name); 50 51 q = strdup (name); … … 61 62 return list; 62 63 63 failure: 64 failure: 64 65 if (list != NULL) 65 66 { -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/wildcard.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 52 52 do 53 53 { 54 if (strcmp (find.name, ".") != 0 && 55 strcmp (find.name, "..") != 0) 54 if ( find.szName[0] != '.' 55 || ( find.szName[1] != '\0' 56 && (find.szName[1] != '.' || find.szName[2] != '\0'))) 56 57 { 57 strcpy (p, find. name);58 strcpy (p, find.szName); 58 59 _fnlwr2 (p, line+1); 59 60 q = strdup (line); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__chsize.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 1 /* sys/chsize.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 1 /* sys/chsize.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 Copyright (c) 2003 Dimitry Froloff 3 Copyright (c) 2003 knut st. osmundsen 4 */ 2 5 3 6 #include "libc-alias.h" 4 7 #include <os2emx.h> 5 8 #include <emx/syscalls.h> 9 #include <limits.h> 10 #include <errno.h> 6 11 #include "syscalls.h" 7 12 8 int __chsize (int handle, long length) 13 14 int __chsize (int hFile, __off_t cbFile) 9 15 { 10 ULONG rc;16 ULONG rc; 11 17 12 rc = DosSetFileSize (handle, length); 13 if (rc != 0) 18 #if OFF_MAX > LONG_MAX 19 if (__pfnDosSetFileSizeL) 20 rc = __pfnDosSetFileSizeL(hFile, cbFile); 21 else 14 22 { 15 _sys_set_errno (rc); 16 return -1; 23 if (cbFile > LONG_MAX) 24 { 25 errno = EOVERFLOW; 26 return -1; 27 } 28 rc = DosSetFileSize(hFile, cbFile); 17 29 } 18 return 0; 30 #else 31 rc = DosSetFileSize(hFile, cbFile); 32 #endif 33 34 if (rc) 35 { 36 _sys_set_errno(rc); 37 return -1; 38 } 39 return 0; 19 40 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__endthread.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 14 14 { 15 15 tp = _sys_thread_table[tid]; 16 if (tp->fd.find_handle != HDIR_CREATE) 17 DosFindClose (tp->fd.find_handle); 16 if (tp->fd.hdir != HDIR_CREATE) 17 { 18 DosFindClose (tp->fd.hdir); 19 tp->fd.hdir = HDIR_CREATE; 20 } 18 21 DosSubFreeMem (_sys_private_heap, tp, sizeof (thread_data)); 19 22 _sys_thread_table[tid] = NULL; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__fcntl.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r731 r732 69 69 it's take from elsewhere. */ 70 70 71 static int __fcntl_locking (int h andle, int request, struct flock *pflock)71 static int __fcntl_locking (int hFile, int request, struct flock *pflock) 72 72 { 73 73 APIRET rc; 74 FILESTATUS3 fsts3; 74 union 75 { 76 FILESTATUS3 fsts3; 77 FILESTATUS3L fsts3L; 78 } info; 79 #if OFF_MAX > LONG_MAX 80 int fLarge = 0; 81 #endif 75 82 76 83 /* check input */ … … 82 89 } 83 90 84 /* check handle & get filesize. */ 85 rc = DosQueryFileInfo (handle, FIL_STANDARD, &fsts3, sizeof(fsts3)); 91 /* check hFile & get filesize. */ 92 #if OFF_MAX > LONG_MAX 93 if (__pfnDosOpenL) 94 { 95 rc = DosQueryFileInfo(hFile, FIL_STANDARDL, &info, sizeof(info.fsts3L)); 96 fLarge = 1; 97 } 98 else 99 #endif 100 rc = DosQueryFileInfo(hFile, FIL_STANDARD, &info, sizeof(info.fsts3)); 86 101 if (!rc) 87 102 { 88 FILELOCK FileLockDummy = {0, 0}; 89 FILELOCK FileLock; 90 PFILELOCK pFLLock; 91 PFILELOCK pFLUnlock; 92 ULONG fAccess; 93 ULONG ulTimeout; 103 ULONG fAccess; 104 int fLock; 105 ULONG ulTimeout; 106 off_t cbFile; 107 off_t offStart; 108 off_t cbRange; 109 #if OFF_MAX > LONG_MAX 110 if (fLarge) 111 cbFile = info.fsts3L.cbFile; 112 else 113 #endif 114 cbFile = info.fsts3.cbFile; 115 116 /* range */ 117 cbRange = pflock->l_len ? pflock->l_len : OFF_MAX; 94 118 95 119 /* offset */ 96 120 switch (pflock->l_whence) 97 121 { 98 case SEEK_SET: FileLock.lOffset = pflock->l_start; break;99 case SEEK_CUR: FileLock.lOffset = tell (handle) + pflock->l_start; break;100 case SEEK_END: FileLock.lOffset = fsts3.cbFile - pflock->l_start; break;122 case SEEK_SET: offStart = pflock->l_start; break; 123 case SEEK_CUR: offStart = tell(hFile) + pflock->l_start; break; 124 case SEEK_END: offStart = cbFile - pflock->l_start; break; 101 125 default: 102 126 errno = EINVAL; 103 127 return -1; 104 128 } 105 if (FileLock.lOffset < 0) 129 if ( offStart < 0 130 || cbRange + offStart < 0 ) 106 131 { 107 132 errno = EINVAL; 108 133 return -1; 109 134 } 110 111 /* range */112 FileLock.lRange = pflock->l_len ? pflock->l_len : LONG_MAX;113 135 114 136 /* flags and order */ … … 117 139 { 118 140 case F_UNLCK: 119 pFLLock = &FileLockDummy; 120 pFLUnlock = &FileLock; 141 fLock = 0; 121 142 break; 122 143 … … 124 145 fAccess = 1; /* shared */ 125 146 case F_WRLCK: 126 pFLLock = &FileLock; 127 pFLUnlock = &FileLockDummy; 147 fLock = 1; 128 148 break; 129 149 … … 140 160 141 161 /* Do work. */ 142 rc = DosSetFileLocks (handle, pFLUnlock, pFLLock, ulTimeout, fAccess); 162 #if OFF_MAX > LONG_MAX 163 if (__pfnDosSetFileLocksL) 164 { 165 FILELOCKL aflock[2]; 166 memset(&aflock[(fLock + 1) & 1], 0, sizeof(aflock[0])); 167 aflock[fLock].lOffset = offStart; 168 aflock[fLock].lRange = cbRange; 169 rc = __pfnDosSetFileLocksL(hFile, &aflock[0], &aflock[1], ulTimeout, fAccess); 170 } 171 else 172 #endif 173 { 174 FILELOCK aflock[2]; 175 #if OFF_MAX > LONG_MAX 176 if ( offStart > LONG_MAX 177 || cbRange > LONG_MAX 178 || offStart + cbRange > LONG_MAX 179 ) 180 { 181 errno = EOVERFLOW; 182 return -1; 183 } 184 #endif 185 memset(&aflock[(fLock + 1) & 1], 0, sizeof(aflock[0])); 186 aflock[fLock].lOffset = offStart; 187 aflock[fLock].lRange = cbRange; 188 189 rc = DosSetFileLocks(hFile, &aflock[0], &aflock[1], ulTimeout, fAccess); 190 } 143 191 } 144 192 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__fstat.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 1 /* sys/fstat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 1 /* sys/fstat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 sys/__fstat.c (libc) -- Copyright (c) 2003 by knut st. osmundsen 3 */ 2 4 3 5 #include "libc-alias.h" … … 9 11 #include "syscalls.h" 10 12 11 int __fstat (int handle, struct stat *buf)13 int __fstat(int hFile, struct stat *pStat) 12 14 { 13 ULONG rc;14 ULONG htype, hflags;15 FILESTATUS3 info;15 ULONG rc; 16 ULONG ulType; 17 ULONG flFlags; 16 18 17 memset (buf, 0, sizeof (*buf)); 18 rc = DosQueryHType (handle, &htype, &hflags); 19 if (rc != 0) 19 /* 20 * Use query handle type to figure out the file type. 21 */ 22 memset(pStat, 0, sizeof(*pStat)); 23 rc = DosQueryHType(hFile, &ulType, &flFlags); 24 if (rc) 20 25 { 21 _sys_set_errno(rc);22 return -1;26 _sys_set_errno(rc); 27 return -1; 23 28 } 24 switch (htype & 0xff)29 switch (ulType & 0xff) 25 30 { 26 case 1:27 buf->st_mode = S_IFCHR;28 break;29 case 2:30 buf->st_mode = S_IFSOCK;31 break;32 default:33 buf->st_mode = S_IFREG;34 break;31 case FHT_CHRDEV: 32 pStat->st_mode = S_IFCHR; 33 break; 34 case FHT_PIPE: 35 pStat->st_mode = S_IFSOCK; 36 break; 37 default: 38 pStat->st_mode = S_IFREG; 39 break; 35 40 } 36 if (buf->st_mode == S_IFREG) 41 42 if (pStat->st_mode == S_IFREG) 37 43 { 38 rc = DosQueryFileInfo (handle, FIL_STANDARD, &info, sizeof (info)); 39 if (rc != 0) 44 union 40 45 { 41 _sys_set_errno (rc); 42 return -1; 46 FILESTATUS3 fsts3; 47 FILESTATUS3L fsts3L; 48 } info; 49 #if OFF_MAX > LONG_MAX 50 int fLarge = 0; 51 #endif 52 53 /* 54 * Get file info. 55 */ 56 #if OFF_MAX > LONG_MAX 57 if (__pfnDosOpenL) 58 { 59 rc = DosQueryFileInfo(hFile, FIL_STANDARDL, &info, sizeof(info.fsts3L)); 60 fLarge = 1; 43 61 } 44 buf->st_attr = info.attrFile; 45 buf->st_size = info.cbFile; 46 buf->st_reserved = 0; 47 buf->st_mtime = _sys_p2t (info.ftimeLastWrite, info.fdateLastWrite); 48 if (FTIMEZEROP (info.ftimeCreation) && 49 FDATEZEROP (info.fdateCreation)) 50 buf->st_ctime = buf->st_mtime; 51 else 52 buf->st_ctime = _sys_p2t (info.ftimeCreation, info.fdateCreation); 53 if (FTIMEZEROP (info.ftimeLastAccess) && 54 FDATEZEROP (info.fdateLastAccess)) 55 buf->st_atime = buf->st_mtime; 56 else 57 buf->st_atime = _sys_p2t (info.ftimeLastAccess, info.fdateLastAccess); 58 if (info.attrFile & 1) 59 buf->st_mode |= (S_IREAD >> 6) * 0111; 60 else 61 buf->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 62 else 63 #endif 64 rc = DosQueryFileInfo(hFile, FIL_STANDARD, &info, sizeof(info.fsts3)); 65 if (rc) 66 { 67 _sys_set_errno (rc); 68 return -1; 69 } 70 71 /* 72 * Format stats struct. 73 * We know the info struct layouts! 74 * Only cbFile, cbFileAlloc and attrFile need be accessed 75 * using the specific structure. 76 */ 77 /* Times: FAT might not return create and access time. */ 78 pStat->st_mtime = _sys_p2t(info.fsts3.ftimeLastWrite, info.fsts3.fdateLastWrite); 79 if ( FTIMEZEROP(info.fsts3.ftimeCreation) 80 && FDATEZEROP(info.fsts3.fdateCreation)) 81 pStat->st_ctime = pStat->st_mtime; 82 else 83 pStat->st_ctime = _sys_p2t(info.fsts3.ftimeCreation, info.fsts3.fdateCreation); 84 if ( FTIMEZEROP(info.fsts3.ftimeLastAccess) 85 && FDATEZEROP(info.fsts3.fdateLastAccess)) 86 pStat->st_atime = pStat->st_mtime; 87 else 88 pStat->st_atime = _sys_p2t(info.fsts3.ftimeLastAccess, info.fsts3.fdateLastAccess); 89 90 #if OFF_MAX > LONG_MAX 91 if (fLarge) 92 { 93 pStat->st_size = info.fsts3L.cbFile; 94 rc = info.fsts3L.attrFile; 95 } 96 else 97 #endif 98 { 99 pStat->st_size = info.fsts3.cbFile; 100 rc = info.fsts3.attrFile; 101 } 102 pStat->st_attr = rc; 103 if (rc & FILE_READONLY) 104 pStat->st_mode |= (S_IREAD >> 6) * 0111; 105 else 106 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 62 107 } 63 else108 else 64 109 { 65 buf->st_size = 0;66 rc = DosQueryFHState (handle, &hflags);67 if (rc != 0)110 pStat->st_size = 0; 111 rc = DosQueryFHState(hFile, &flFlags); 112 if (rc) 68 113 { 69 _sys_set_errno (rc);70 return -1;114 _sys_set_errno (rc); 115 return -1; 71 116 } 72 if ((hflags & 7) == 0)73 buf->st_mode |= (S_IREAD >> 6) * 0111;74 else75 buf->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111;117 if ((flFlags & 7) == OPEN_ACCESS_READONLY) 118 pStat->st_mode |= (S_IREAD >> 6) * 0111; 119 else 120 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 76 121 } 77 buf->st_uid = 0; 78 buf->st_gid = 0; 79 buf->st_ino = _sys_ino++; 80 if (_sys_ino == 0) 81 _sys_ino = 1; 82 buf->st_dev = 0; 83 buf->st_rdev = 0; 84 buf->st_nlink = 1; 85 return 0; 122 123 /* default fake stuff */ 124 pStat->st_uid = 0; 125 pStat->st_gid = 0; 126 pStat->st_ino = _sys_ino++; 127 if (_sys_ino == 0) 128 _sys_ino = 1; 129 pStat->st_dev = 0; 130 pStat->st_rdev = 0; 131 pStat->st_nlink = 1; 132 pStat->st_reserved = 0; /* what is this good for?!? */ 133 return 0; 86 134 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__ftruncate.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 1 /* sys/ftruncat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 1 /* sys/ftruncat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 Copyright (c) 2003 Dimitry Froloff 3 Copyright (c) 2003 knut st. osmundsen 4 */ 2 5 3 6 #include "libc-alias.h" 4 7 #include <os2emx.h> 5 8 #include <emx/syscalls.h> 9 #include <limits.h> 10 #include <errno.h> 6 11 #include "syscalls.h" 7 12 8 int __ftruncate (int handle, long length)13 int __ftruncate(int hFile, off_t cbFile) 9 14 { 10 ULONG rc; 11 FILESTATUS3 info; 15 ULONG rc; 16 off_t cbCur; 17 union 18 { 19 FILESTATUS3 fsts3; 20 FILESTATUS3L fsts3L; 21 } info; 12 22 13 rc = DosQueryFileInfo (handle, FIL_STANDARD, &info, sizeof (info)); 14 if (rc != 0) 23 /* 24 * First step, figure out the current size. 25 */ 26 #if OFF_MAX > LONG_MAX 27 if (__pfnDosOpenL) 15 28 { 16 _sys_set_errno (rc);17 return -1;29 rc = DosQueryFileInfo(hFile, FIL_STANDARDL, &info, sizeof(info.fsts3L)); 30 cbCur = info.fsts3L.cbFile; 18 31 } 19 if (info.cbFile > length) 32 else 33 #endif 20 34 { 21 rc = DosSetFileSize (handle, length); 22 if (rc != 0) 35 rc = DosQueryFileInfo(hFile, FIL_STANDARD, &info, sizeof(info.fsts3)); 36 cbCur = info.fsts3.cbFile; 37 } 38 if (rc) 39 { 40 _sys_set_errno(rc); 41 return -1; 42 } 43 44 45 /* 46 * Is the file larger than the truncation size? 47 * Then set the desired file size. 48 */ 49 if (cbCur > cbFile) 50 { 51 #if OFF_MAX > LONG_MAX 52 if (__pfnDosSetFileSizeL) 53 rc = __pfnDosSetFileSizeL(hFile, cbFile); 54 else 23 55 { 24 _sys_set_errno (rc); 25 return -1; 56 if (cbFile > __LONG_MAX) 57 { 58 errno = EOVERFLOW; 59 return -1; 60 } 61 rc = DosSetFileSize(hFile, cbFile); 62 } 63 #else 64 rc = DosSetFileSize(hFile, cbFile); 65 #endif 66 if (rc != 0) 67 { 68 _sys_set_errno(rc); 69 return -1; 26 70 } 27 71 } 28 return 0;72 return 0; 29 73 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__init.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r731 r732 488 488 __sigemptyset (&tp->signals[n].sa_mask); 489 489 } 490 tp->fd.find_handle = HDIR_CREATE; 491 tp->fd.find_next = NULL; 492 tp->fd.find_count = 0; 493 } 490 tp->fd.hdir = HDIR_CREATE; 491 tp->fd.cFiles = 0; 492 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__initdll.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 1 /* 1 /* $Id$ */ 2 /** @file 3 2 4 Dynamic library low-level initialization routine. 3 5 … … 9 11 */ 10 12 13 14 /******************************************************************************* 15 * Defined Constants And Macros * 16 *******************************************************************************/ 17 #define SYS_PRIVATE_HEAP_SIZE 0x100000 18 19 /******************************************************************************* 20 * Header Files * 21 *******************************************************************************/ 11 22 #include "libc-alias.h" 12 23 #define INCL_DOS … … 21 32 #include "syscalls.h" 22 33 23 #define SYS_PRIVATE_HEAP_SIZE 0x100000 24 25 extern int __init_environ(const char *pszEnv); 34 /******************************************************************************* 35 * Global Variables * 36 *******************************************************************************/ 26 37 extern unsigned char _osminor; 27 38 extern unsigned char _osmajor; 39 40 41 /******************************************************************************* 42 * External Functions * 43 *******************************************************************************/ 44 extern int __init_environ(const char *pszEnv); 45 extern void __init_largefileio(void) __attribute__((weak)); 46 28 47 29 48 /** … … 85 104 * Let's try put it in high memory... 86 105 */ 106 /** @todo Redo this private heap stuff. */ 87 107 rc = DosAllocMem(&_sys_private_heap, SYS_PRIVATE_HEAP_SIZE, 88 108 _sys_virtual_address_limit … … 113 133 114 134 /* 135 * Init long file I/O functions. 136 * This is weak, so that it's only linked in when we're building with 137 * large file suppoort enabled. 138 */ 139 if (__init_largefileio) 140 __init_largefileio(); 141 142 /* 115 143 * Get current time for clock() for use as process startup time. 116 144 */ … … 118 146 return 0; 119 147 } 148 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__lseek.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 1 /* sys/lseek.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 1 /* sys/lseek.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 Copyright (c) 2003 Dimitry Froloff 3 Copyright (c) 2003 knut st. osmundsen 4 */ 2 5 3 6 #include "libc-alias.h" 4 7 #include <os2emx.h> 5 8 #include <emx/syscalls.h> 9 #include <limits.h> 10 #include <errno.h> 6 11 #include "syscalls.h" 7 12 8 int __lseek (int handle, long offset, int origin)13 off_t __lseek(int hFile, off_t off, int origin) 9 14 { 10 ULONGrc;11 ULONG new;15 ULONG rc; 16 off_t cbNew; 12 17 13 rc = DosSetFilePtr (handle, offset, origin, &new); 14 if (rc == 0) 15 return (int)new; 16 else 18 if (origin == FILE_SECTOR) 17 19 { 18 _sys_set_errno (rc);19 return -1;20 errno = EINVAL; 21 return -1; 20 22 } 23 24 #if OFF_MAX > LONG_MAX 25 if (__pfnDosSetFilePtrL) 26 { 27 LONGLONG cbNewTmp; 28 rc = __pfnDosSetFilePtrL(hFile, off, origin, &cbNewTmp); 29 cbNew = cbNewTmp; 30 } 31 else 32 { 33 ULONG cbNewTmp; 34 if (off > LONG_MAX || off < LONG_MIN) 35 { 36 errno = EOVERFLOW; 37 return -1; 38 } 39 rc = DosSetFilePtr(hFile, off, origin, &cbNewTmp); 40 cbNew = cbNewTmp; 41 } 42 #else 43 { 44 ULONG cbNewTmp; 45 rc = DosSetFilePtr(hFile, off, origin, &cbNewTmp); 46 cbNew = cbNewTmp; 47 } 48 #endif 49 50 if (rc) 51 { 52 _sys_set_errno (rc); 53 return -1; 54 } 55 56 return cbNew; 21 57 } 58 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__open.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 1 /* sys/open.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 1 /* sys/open.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 Copyright (c) 2003 Dimitry Froloff 3 Copyright (c) 2003 knut st. osmundsen 4 */ 2 5 3 6 #include "libc-alias.h" … … 6 9 #include <string.h> 7 10 #include <errno.h> 11 #include <limits.h> 8 12 #include <emx/syscalls.h> 9 13 #include "syscalls.h" 10 14 11 int __open (const char *name, int flags, unsigned long size)15 int __open(const char *pszFile, int flags, off_t cbInitial) 12 16 { 13 ULONG rc; 14 ULONG open_mode, attr, action, open_flag; 15 HFILE handle; 16 int fail_errno; 17 ULONG rc; 18 ULONG flOpenMode; 19 ULONG flOpenFlags; 20 ULONG flAttr; 21 ULONG ulAction; 22 HFILE hFile; 23 int failed_open_errno; 17 24 18 /* Interpret "/dev/null" as the name of the null device "NUL". 19 Interpret "/dev/tty" as the name of the console device "CON". */ 25 /* 26 * Interpret "/dev/null" as the pszFile of the null device "NUL". 27 * Interpret "/dev/tty" as the pszFile of the console device "CON". 28 */ 29 if (!strcmp(pszFile, "/dev/null")) 30 pszFile = "nul"; 31 else if (!strcmp(pszFile, "/dev/tty")) 32 pszFile = "con"; 20 33 21 if (strcmp (name, "/dev/null") == 0)22 name = "nul";23 else if (strcmp (name, "/dev/tty") == 0)24 name = "con";34 /* 35 * Extract the access mode and sharing mode bits. 36 */ 37 flOpenMode = flags & 0x77; 25 38 26 /* Extract the access mode and sharing mode bits. */ 39 /* 40 * File O_NOINHERIT and O_SYNC. 41 */ 42 if (flags & _SO_NOINHERIT) 43 flOpenMode |= OPEN_FLAGS_NOINHERIT; 44 if (flags & _SO_SYNC) 45 flOpenMode |= OPEN_FLAGS_WRITE_THROUGH; 27 46 28 open_mode = flags & 0x77; 47 /* 48 * Extract the file flAttribute bits. 49 */ 50 flAttr = (flags >> 8) & 0xff; 51 if (_sys_umask & 0200) 52 flAttr |= FILE_READONLY; 29 53 30 /* Handle O_NOINHERIT and O_SYNC. */ 54 /* 55 * Translate ERROR_OPEN_FAILED to ENOENT unless O_EXCL is set (see below). 56 */ 57 failed_open_errno = ENOENT; 31 58 32 if (flags & _SO_NOINHERIT) 33 open_mode |= OPEN_FLAGS_NOINHERIT; 34 if (flags & _SO_SYNC) 35 open_mode |= OPEN_FLAGS_WRITE_THROUGH; 59 /* 60 * Compute `flOpenFlags' depending on `flags'. Note that _SO_CREAT is 61 * set for O_CREAT. 62 */ 63 if (flags & _SO_CREAT) 64 { 65 if (flags & _SO_EXCL) 66 { 67 flOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 68 failed_open_errno = EEXIST; 69 } 70 else if (flags & _SO_TRUNC) 71 flOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 72 else 73 flOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 74 } 75 else if (flags & _SO_TRUNC) 76 flOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; 77 else 78 flOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; 36 79 37 /* Extract the file attribute bits. */ 80 if (!(flags & _SO_SIZE)) 81 cbInitial = 0; 38 82 39 attr = (flags >> 8) & 0xff; 40 if (_sys_umask & 0200) 41 attr |= 1; 83 /* 84 * Try to open the file. 85 */ 86 #if OFF_MAX > LONG_MAX 87 if (__pfnDosOpenL) 88 { 89 LONGLONG cbInitialTmp = cbInitial; 90 rc = __pfnDosOpenL(pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL); 91 } 92 else 93 { 94 ULONG cbInitialTmp = (ULONG)cbInitial; 95 if (cbInitial > LONG_MAX) 96 { 97 errno = EOVERFLOW; 98 return -1; 99 } 100 rc = DosOpen(pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL); 101 } 102 #else 103 { 104 ULONG cbInitialTmp = cbInitial; 105 rc = DosOpen(pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL); 106 } 107 #endif 42 108 43 /* Translate ERROR_OPEN_FAILED to ENOENT unless O_EXCL is set (see 44 below). */ 45 46 fail_errno = ENOENT; 47 48 /* Compute `open_flag' depending on `flags'. Note that _SO_CREAT is 49 set for O_CREAT. */ 50 51 if (flags & _SO_CREAT) 109 /* 110 * Handle any errors. 111 */ 112 if (rc) 52 113 { 53 if (flags & _SO_EXCL) 54 { 55 open_flag = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 56 fail_errno = EEXIST; 57 } 58 else if (flags & _SO_TRUNC) 59 open_flag = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 60 else 61 open_flag = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 114 if (rc == ERROR_OPEN_FAILED) 115 errno = failed_open_errno; 116 else 117 _sys_set_errno(rc); 118 return -1; 62 119 } 63 else if (flags & _SO_TRUNC) 64 open_flag = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; 65 else 66 open_flag = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; 67 68 if (!(flags & _SO_SIZE)) 69 size = 0; 70 71 /* Try to open the file and handle errors. */ 72 73 rc = DosOpen (name, &handle, &action, size, attr, open_flag, open_mode, 74 NULL); 75 if (rc == ERROR_OPEN_FAILED) 76 { 77 errno = fail_errno; 78 return -1; 79 } 80 if (rc != 0) 81 { 82 _sys_set_errno (rc); 83 return -1; 84 } 85 return handle; 120 return hFile; 86 121 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__stat.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 1 /* sys/stat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 1 /* sys/stat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 sys/__stat.c (libc) -- Copyright (c) 2003 by knut st. osmundsen 3 */ 2 4 3 5 #include "libc-alias.h" … … 10 12 #include "syscalls.h" 11 13 12 int __stat (const char *name, struct stat *buf)14 int __stat(const char *pszPath, struct stat *pStat) 13 15 { 14 ULONG rc; 15 FILESTATUS3 info; 16 ULONG rc; 17 union 18 { 19 FILESTATUS3 fsts3; 20 FILESTATUS3L fsts3L; 21 } info; 22 #if OFF_MAX > LONG_MAX 23 int fLarge = 0; 24 #endif 16 25 17 memset (buf, 0, sizeof (*buf)); 18 if ((name[0] == '/' || name[0] == '\\') && strlen (name) >= 6 && 19 memicmp (name+1, "pipe", 4) == 0 && (name[5] == '/' || name[5] == '\\')) 26 /* 27 * Validate input, refusing named pipes. 28 */ 29 memset(pStat, 0, sizeof(*pStat)); 30 if ( (pszPath[0] == '/' || pszPath[0] == '\\') 31 && !strnicmp(pszPath+1, "pipe", 4) 32 && (pszPath[5] == '/' || pszPath[5] == '\\')) 20 33 { 21 errno = ENOENT;22 return -1;34 errno = ENOENT; 35 return -1; 23 36 } 24 rc = DosQueryPathInfo (name, FIL_STANDARD, &info, sizeof (info)); 25 if (rc != 0) 37 38 /* 39 * Get path info. 40 */ 41 #if OFF_MAX > LONG_MAX 42 if (__pfnDosOpenL) 26 43 { 27 _sys_set_errno (rc);28 return -1;44 rc = DosQueryPathInfo(pszPath, FIL_STANDARDL, &info, sizeof(info.fsts3L)); 45 fLarge = 1; 29 46 } 30 buf->st_attr = info.attrFile; 31 buf->st_reserved = 0; 32 buf->st_mtime = _sys_p2t (info.ftimeLastWrite, info.fdateLastWrite); 33 if (FTIMEZEROP (info.ftimeCreation) && 34 FDATEZEROP (info.fdateCreation)) 35 buf->st_ctime = buf->st_mtime; 36 else 37 buf->st_ctime = _sys_p2t (info.ftimeCreation, info.fdateCreation); 38 if (FTIMEZEROP (info.ftimeLastAccess) && 39 FDATEZEROP (info.fdateLastAccess)) 40 buf->st_atime = buf->st_mtime; 41 else 42 buf->st_atime = _sys_p2t (info.ftimeLastAccess, info.fdateLastAccess); 43 if (info.attrFile & 0x10) /* directory */ 47 else 48 #endif 49 rc = DosQueryPathInfo(pszPath, FIL_STANDARD, &info, sizeof(info.fsts3)); 50 if (rc) 44 51 { 45 buf->st_mode = S_IFDIR; 46 buf->st_mode |= ((S_IREAD|S_IWRITE|S_IEXEC) >> 6) * 0111; 47 buf->st_size = 0; 52 _sys_set_errno(rc); 53 return -1; 48 54 } 49 else 55 56 /* 57 * Format stats struct. 58 * We know the info struct layouts! 59 * Only cbFile, cbFileAlloc and attrFile need be accessed 60 * using the specific structure. 61 */ 62 /* Times: FAT might not return create and access time. */ 63 pStat->st_mtime = _sys_p2t(info.fsts3.ftimeLastWrite, info.fsts3.fdateLastWrite); 64 if ( FTIMEZEROP(info.fsts3.ftimeCreation) 65 && FDATEZEROP(info.fsts3.fdateCreation)) 66 pStat->st_ctime = pStat->st_mtime; 67 else 68 pStat->st_ctime = _sys_p2t(info.fsts3.ftimeCreation, info.fsts3.fdateCreation); 69 if ( FTIMEZEROP(info.fsts3.ftimeLastAccess) 70 && FDATEZEROP(info.fsts3.fdateLastAccess)) 71 pStat->st_atime = pStat->st_mtime; 72 else 73 pStat->st_atime = _sys_p2t(info.fsts3.ftimeLastAccess, info.fsts3.fdateLastAccess); 74 75 #if OFF_MAX > LONG_MAX 76 rc = fLarge ? info.fsts3L.attrFile : info.fsts3.attrFile; 77 #else 78 rc = info.fsts3.attrFile; 79 #endif 80 pStat->st_attr = rc; 81 if (rc & FILE_DIRECTORY) 50 82 { 51 buf->st_size = info.cbFile; 52 buf->st_mode = S_IFREG; 53 if (info.attrFile & 1) 54 buf->st_mode |= (S_IREAD >> 6) * 0111; 55 else 56 buf->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 83 /* directory */ 84 pStat->st_mode = S_IFDIR; 85 pStat->st_mode |= ((S_IREAD|S_IWRITE|S_IEXEC) >> 6) * 0111; 86 pStat->st_size = 0; 57 87 } 58 buf->st_uid = 0; 59 buf->st_gid = 0; 60 buf->st_ino = _sys_ino++; 61 if (_sys_ino == 0) 62 _sys_ino = 1; 63 buf->st_dev = 0; 64 buf->st_rdev = 0; 65 buf->st_nlink = 1; 66 return 0; 88 else 89 { 90 #if OFF_MAX > LONG_MAX 91 if (fLarge) 92 pStat->st_size = info.fsf3L.cbFile; 93 else 94 #endif 95 pStat->st_size = info.fsts3.cbFile; 96 pStat->st_mode = S_IFREG; 97 if (rc & FILE_READONLY) 98 pStat->st_mode |= (S_IREAD >> 6) * 0111; 99 else 100 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 101 } 102 /* default fake stuff */ 103 pStat->st_uid = 0; 104 pStat->st_gid = 0; 105 pStat->st_ino = _sys_ino++; 106 if (_sys_ino == 0) 107 _sys_ino = 1; 108 pStat->st_dev = 0; 109 pStat->st_rdev = 0; 110 pStat->st_nlink = 1; 111 pStat->st_reserved = 0; /* what is this good for?!? */ 112 return 0; 67 113 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/filefind.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r731 r732 1 /* sys/filefind.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 1 /* sys/filefind.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 sys/filefind.c (libc) -- Copyright (c) 2003 by knut st. osmundsen 3 */ 2 4 3 5 #include "libc-alias.h" 4 6 #include <string.h> 5 7 #include <errno.h> 8 #include <limits.h> 9 #define INCL_BASE 6 10 #include <os2emx.h> 7 11 #include <emx/syscalls.h> 8 12 #include "syscalls.h" 9 13 10 /* Close the directory handle. */ 11 12 static void find_close (struct find_data *fd) 13 { 14 if (fd->find_handle != HDIR_CREATE) 15 { 16 DosFindClose (fd->find_handle); 17 fd->find_handle = HDIR_CREATE; 18 } 19 fd->find_count = 0; 20 fd->find_next = NULL; 14 /** 15 * Close a directory find session. 16 * @param pFD The directory find data. 17 */ 18 static void find_close(struct find_data *pFD) 19 { 20 if (pFD->hdir != HDIR_CREATE) 21 { 22 DosFindClose(pFD->hdir); 23 pFD->hdir = HDIR_CREATE; 24 } 25 pFD->cFiles = 0; 26 pFD->pchNext = NULL; 21 27 } 22 28 … … 24 30 move to the next one. */ 25 31 26 static int find_conv (struct find_data *fd, struct _find *fp) 27 { 28 const FILEFINDBUF3 *src; 29 30 /* Check if there are any entries. Close the handle and return 31 ENOENT if there are no entries. (Checking SRC is redundant.) */ 32 33 src = fd->find_next; 34 if (fd->find_count < 1 || src == NULL) 35 { 36 find_close (fd); 37 errno = ENOENT; 38 return -1; 39 } 40 41 /* Fill-in target object. */ 42 43 fp->attr = (unsigned char)src->attrFile; 44 fp->time = XUSHORT (src->ftimeLastWrite); 45 fp->date = XUSHORT (src->fdateLastWrite); 46 fp->size_lo = (unsigned short)(src->cbFile & 0xffff); 47 fp->size_hi = (unsigned short)(src->cbFile >> 16); 48 strcpy (fp->name, src->achName); 49 50 /* Move to the next entry. */ 51 52 if (src->oNextEntryOffset == 0) 53 { 54 fd->find_next = NULL; 55 fd->find_count = 0; 56 } 57 else 58 { 59 fd->find_next = (FILEFINDBUF3 *)((char *)src + src->oNextEntryOffset); 60 fd->find_count -= 1; 61 } 62 63 return 0; 64 } 65 66 67 int __findfirst (const char *name, int attr, struct _find *fp) 68 { 69 ULONG rc; 70 struct find_data *fd; 71 72 fd = &SYS_THREAD->fd; 73 74 if (fd->find_handle != HDIR_CREATE) 75 { 76 /* Closing the handle is not strictly required as DosFindFirst 77 can reuse an open handle. However, this simplifies error 78 handling below (will DosFindFirst close the handle on error 79 if it is open?). */ 80 81 DosFindClose (fd->find_handle); 82 fd->find_handle = HDIR_CREATE; 83 } 84 85 fd->find_count = FIND_COUNT; 86 rc = DosFindFirst (name, &fd->find_handle, attr & 0x37, 87 &fd->find_buf[0], sizeof (fd->find_buf), 88 &fd->find_count, FIL_STANDARD); 89 if (rc != 0) 90 { 91 fd->find_handle = HDIR_CREATE; /* Perhaps modified by DosFindFirst */ 92 fd->find_count = 0; 93 fd->find_next = NULL; 94 _sys_set_errno (rc); 95 return -1; 96 } 97 fd->find_next = &fd->find_buf[0]; 98 return find_conv (fd, fp); 99 } 100 101 102 int __findnext (struct _find *fp) 103 { 104 ULONG rc; 105 struct find_data *fd; 106 107 fd = &SYS_THREAD->fd; 108 if (fd->find_count < 1) 109 { 110 fd->find_count = FIND_COUNT; 111 rc = DosFindNext (fd->find_handle, &fd->find_buf[0], 112 sizeof (fd->find_buf), &fd->find_count); 113 if (rc != 0) 32 /** 33 * Build a 'struct _find' from the next file in the directory find data. 34 * @returns 0 on success. 35 * @returns -1 on failure, ENOENT as errno. 36 * @param pFD The directory find data. 37 */ 38 static int find_conv(struct find_data *pFD, struct _find *fp) 39 { 40 union 41 { 42 const char *pch; 43 const FILEFINDBUF3 *pFindbuf3; 44 const FILEFINDBUF3L *pFindbuf3L; 45 } u; 46 u.pch = pFD->pchNext; 47 48 /* 49 * If there ain't any entries, flag ENOENT error, clean up and 50 * return failure. 51 */ 52 if (!pFD->cFiles) 53 { 54 find_close(pFD); 55 errno = ENOENT; 56 return -1; 57 } 58 59 /* 60 * Fill-in target object. 61 * About the find structure we know that these fields are not the same 62 * in the two versions: 63 * cbFile, cbFileAlloc, attrFile, cchName, achName. 64 */ 65 fp->time = XUSHORT(u.pFindbuf3->ftimeLastWrite); 66 fp->date = XUSHORT(u.pFindbuf3->fdateLastWrite); 67 #if OFF_MAX > LONG_MAX 68 if (pFD->fType == FIL_STANDARDL) 69 { 70 fp->cbFile = u.pFindbuf3L->cbFile; 71 fp->attr = (unsigned char)u.pFindbuf3L->attrFile; 72 strcpy(fp->szName, &u.pFindbuf3L->achName[0]); 73 } 74 else 75 #endif 76 { 77 fp->cbFile = u.pFindbuf3->cbFile; 78 fp->attr = (unsigned char)u.pFindbuf3->attrFile; 79 strcpy(fp->szName, &u.pFindbuf3->achName[0]); 80 } 81 82 /* 83 * Next entry. 84 */ 85 if (pFD->cFiles && u.pFindbuf3->oNextEntryOffset) 86 { 87 pFD->pchNext = u.pch + u.pFindbuf3->oNextEntryOffset; 88 pFD->cFiles--; 89 } 90 else 91 pFD->cFiles = 0; 92 93 return 0; 94 } 95 96 97 /** 98 * Start a directory find session. 99 * It's only possible to perform one such session per thread. A call to this 100 * function will terminate the previous one. 101 * 102 * @returns 0 on success 103 * @returns -1 on failure and errno set appropriately. 104 * @param pszName Search pattern. Usually "<somepath>\\*" 105 * @param attr File attributes to include in the search. 106 * If 0 files with any attributes may be included. 107 * @param fp Where to put the data on the first file found. 108 */ 109 int __findfirst(const char *pszName, int attr, struct _find *fp) 110 { 111 ULONG rc; 112 struct find_data *pFD = &SYS_THREAD->fd; 113 114 /* 115 * Cleanup any open find sessions first. 116 */ 117 if (pFD->hdir != HDIR_CREATE) 118 { 119 /* Closing the handle is not strictly required as DosFindFirst 120 can reuse an open handle. However, this simplifies error 121 handling below (will DosFindFirst close the handle on error 122 if it is open?). */ 123 DosFindClose(pFD->hdir); 124 pFD->hdir = HDIR_CREATE; 125 } 126 127 /* 128 * Start file enumeration. 129 */ 130 pFD->cFiles = 30; /* !! Careful with this number! Wrong values can trigger stupid bugs. */ 131 #if OFF_MAX > LONG_MAX 132 pFD->fType = __pfnDosOpenL ? FIL_STANDARDL : FIL_STANDARD; 133 #else 134 pFD->fType = FIL_STANDARD; 135 #endif 136 rc = DosFindFirst(pszName, 137 &pFD->hdir, 138 attr & (FILE_NORMAL | FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED), 139 &pFD->achBuffer[0], 140 sizeof(pFD->achBuffer), 141 &pFD->cFiles, 142 pFD->fType); 143 if (rc) 144 { 145 pFD->hdir = HDIR_CREATE; /* Perhaps modified by DosFindFirst */ 146 pFD->cFiles = 0; 147 pFD->pchNext = NULL; 148 _sys_set_errno(rc); 149 return -1; 150 } 151 pFD->pchNext = &pFD->achBuffer[0]; 152 return find_conv(pFD, fp); 153 } 154 155 156 /** 157 * Get the next file in the current directory find session. 158 * It's only possible to perform one such session per thread. A call to this 159 * function will terminate the previous one. 160 * 161 * @returns 0 on success 162 * @returns -1 on failure and errno set appropriately. 163 * @param pszName Search pattern. Usually "<somepath>\\*" 164 * @param attr File attributes to include in the search. 165 * If 0 files with any attributes may be included. 166 * @param fp Where to put the data on the first file found. 167 */ 168 int __findnext(struct _find *fp) 169 { 170 ULONG rc; 171 struct find_data *pFD = &SYS_THREAD->fd; 172 173 /* 174 * Check incoming. 175 */ 176 if (pFD->hdir == HDIR_CREATE) 177 { 178 errno = EINVAL; 179 return -1; 180 } 181 182 /* 183 * Do we need to fetch more files? 184 */ 185 if (!pFD->cFiles) 186 { 187 pFD->cFiles = 30; /* !! Careful with this number! Wrong values can trigger stupid bugs. */ 188 rc = DosFindNext(pFD->hdir, &pFD->achBuffer[0], sizeof(pFD->achBuffer), &pFD->cFiles); 189 if (rc) 114 190 { 115 find_close (fd);116 _sys_set_errno(rc);117 return -1;191 find_close(pFD); 192 _sys_set_errno(rc); 193 return -1; 118 194 } 119 fd->find_next = &fd->find_buf[0]; 120 } 121 122 return find_conv (fd, fp); 123 } 195 pFD->pchNext = &pFD->achBuffer[0]; 196 } 197 198 return find_conv(pFD, fp); 199 } 200 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/syscalls.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r731 r732 1 /* sys/syscalls.h (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 1 /* sys/syscalls.h (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 sys/filefind.c (libc) -- Copyright (c) 2003 by Andrew Zabolotny 3 sys/filefind.c (libc) -- Copyright (c) 2003 by Knut St. Osmundsen 4 */ 2 5 3 6 #include "libc-alias.h" … … 24 27 25 28 #define XUSHORT(x) (*(USHORT *)&(x)) 26 27 /* Fetch this many FILEFINDBUF3 entries at once with DosFindFirst and28 DosFindNext. */29 30 #define FIND_COUNT 431 29 32 30 /* Maximum number of heap objects (16 = 512 / 32). */ … … 81 79 #if defined (_OS2EMX_H) 82 80 83 #define FTIMEZEROP(x) (*(USHORT *)&(x) == 0) 84 #define FDATEZEROP(x) (*(USHORT *)&(x) == 0) 81 /** @group Large File Support - API pointers. 82 * Test if the function pointer is set before calling it. 83 * For APIs which take a structure level parameter, check __pfnDosOpenL. 84 * @{ */ 85 extern ULONG (* _System __pfnDosOpenL)(PCSZ pszFileName, PHFILE phFile, 86 PULONG pulAction, LONGLONG llFileSize, ULONG ulAttribute, ULONG ulOpenFlags, 87 ULONG ulOpenMode, PEAOP2 pEABuf); 88 extern ULONG (* _System __pfnDosSetFilePtrL)(HFILE hFile, LONGLONG llOffset, 89 ULONG ulOrigin, PLONGLONG pllPos); 90 extern ULONG (* _System __pfnDosSetFileSizeL)(HFILE hFile, LONGLONG cbSize); 91 extern ULONG (* _System __pfnDosSetFileLocksL)(HFILE hFile, 92 __const__ FILELOCKL *pflUnlock, __const__ FILELOCKL *pflLock, 93 ULONG ulTimeout, ULONG flFlags); 94 /** @} */ 85 95 96 97 /** Test if a DOS/OS2 file time is zero. */ 98 #define FTIMEZEROP(x) (*(PUSHORT)&(x) == 0) 99 /** Test if a DOS/OS2 file date is zero. */ 100 #define FDATEZEROP(x) (*(PUSHORT)&(x) == 0) 101 102 /** Directory find data entry. 103 * Used by __findfirst() and __findnext(). */ 86 104 struct find_data 87 105 { 88 HDIR find_handle; 89 ULONG find_count; 90 FILEFINDBUF3 find_buf[FIND_COUNT]; 91 const FILEFINDBUF3 *find_next; 106 /** Directory handle. HDIR_CREATE if no session opened. */ 107 HDIR hdir; 108 /** Type of buffer content. FIL_STANDARDL or FIL_STANDARD, 109 * i.e. FILEFINDBUF3 or FILEFINDBUF3L. */ 110 ULONG fType; 111 /** Number of files left in the buffer. */ 112 ULONG cFiles; 113 /** Pointer to the next entry. Don't test on this, test on cFiles! */ 114 const char *pchNext; 115 /** Buffer. */ 116 char achBuffer[2048]; 92 117 }; 93 118 … … 152 177 ULONG _sys_shrink_heap_by (ULONG decr, ULONG sbrk_model); 153 178 ULONG _sys_shrink_heap_obj_by (ULONG decr); 179 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/version.smak
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r731 r732 4 4 VH = 0 5 5 # Middle part of version number 6 VM = 36 VM = 4 7 7 # Low part of version number 8 8 VL = 0 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.