6 * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
9 * This file is part of kBuild.
11 * kBuild is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * kBuild is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #if K_OS == K_OS_WINDOWS
43 int shfile_open(shfdtab
*pfdtab
, const char *name
, unsigned flags
, mode_t mode
)
45 #ifdef SH_PURE_STUB_MODE
47 #elif defined(SH_STUB_MODE)
48 return open(name
, flags
, mode
);
53 int shfile_pipe(shfdtab
*pfdtab
, int fds
[2])
55 #ifdef SH_PURE_STUB_MODE
57 #elif defined(SH_STUB_MODE)
59 return _pipe(fds
, PIPE_BUF
, O_BINARY
);
67 int shfile_dup(shfdtab
*pfdtab
, int fd
)
69 #ifdef SH_PURE_STUB_MODE
71 #elif defined(SH_STUB_MODE)
77 int shfile_close(shfdtab
*pfdtab
, unsigned fd
)
79 #ifdef SH_PURE_STUB_MODE
81 #elif defined(SH_STUB_MODE)
87 long shfile_read(shfdtab
*pfdtab
, int fd
, void *buf
, size_t len
)
89 #ifdef SH_PURE_STUB_MODE
91 #elif defined(SH_STUB_MODE)
93 return read(fd
, buf
, (unsigned)len
);
95 return read(fd
, buf
, len
);
101 long shfile_write(shfdtab
*pfdtab
, int fd
, const void *buf
, size_t len
)
103 #ifdef SH_PURE_STUB_MODE
105 #elif defined(SH_STUB_MODE)
107 return write(fd
, buf
, (unsigned)len
);
109 return write(fd
, buf
, len
);
115 long shfile_lseek(shfdtab
*pfdtab
, int fd
, long off
, int whench
)
117 #ifdef SH_PURE_STUB_MODE
119 #elif defined(SH_STUB_MODE)
120 return lseek(fd
, off
, whench
);
125 int shfile_fcntl(shfdtab
*pfdtab
, int fd
, int cmd
, int arg
)
127 #ifdef SH_PURE_STUB_MODE
129 #elif defined(SH_STUB_MODE)
133 return fcntl(fd
, cmd
, arg
);
139 int shfile_stat(shfdtab
*pfdtab
, const char *path
, struct stat
*pst
)
141 #ifdef SH_PURE_STUB_MODE
143 #elif defined(SH_STUB_MODE)
144 return stat(path
, pst
);
149 int shfile_lstat(shfdtab
*pfdtab
, const char *link
, struct stat
*pst
)
151 #ifdef SH_PURE_STUB_MODE
153 #elif defined(SH_STUB_MODE)
155 return stat(link
, pst
);
157 return lstat(link
, pst
);
163 int shfile_chdir(shfdtab
*pfdtab
, const char *path
)
165 #ifdef SH_PURE_STUB_MODE
167 #elif defined(SH_STUB_MODE)
168 # ifdef _MSC_VER //???
177 char *shfile_getcwd(shfdtab
*pfdtab
, char *buf
, int len
)
179 #ifdef SH_PURE_STUB_MODE
181 #elif defined(SH_STUB_MODE)
182 return getcwd(buf
, len
);
187 int shfile_access(shfdtab
*pfdtab
, const char *path
, int type
)
189 #ifdef SH_PURE_STUB_MODE
191 #elif defined(SH_STUB_MODE)
194 return access(path
, type
);
196 return access(path
, type
);
202 int shfile_isatty(shfdtab
*pfdtab
, int fd
)
204 #ifdef SH_PURE_STUB_MODE
206 #elif defined(SH_STUB_MODE)
213 int shfile_cloexec(shfdtab
*pfdtab
, int fd
, int closeit
)
215 #ifdef SH_PURE_STUB_MODE
217 #elif defined(SH_STUB_MODE)
221 int rc
= fcntl(fd
, F_SETFD
, fcntl(fd
, F_GETFD
, 0)
222 | (closeit
? FD_CLOEXEC
: 0));
223 //fprintf(stderr, "shfile_cloexec(%d, %d) -> %d\n", fd, closeit, rc);
232 int shfile_ioctl(shfdtab
*pfdtab
, int fd
, unsigned long request
, void *buf
)
234 #ifdef SH_PURE_STUB_MODE
236 #elif defined(SH_STUB_MODE)
240 int rc
= ioctl(fd
, request
, buf
);
241 //fprintf(stderr, "ioctl(%d, %#x, %p) -> %d\n", fd, request, buf, rc);
249 mode_t
shfile_get_umask(shfdtab
*pfdtab
)
251 #ifdef SH_PURE_STUB_MODE
253 #elif defined(SH_STUB_MODE)
260 shdir
*shfile_opendir(shfdtab
*pfdtab
, const char *dir
)
262 #ifdef SH_PURE_STUB_MODE
264 #elif defined(SH_STUB_MODE)
268 return (shdir
*)opendir(dir
);
274 shdirent
*shfile_readdir(struct shdir
*pdir
)
276 #ifdef SH_PURE_STUB_MODE
278 #elif defined(SH_STUB_MODE)
282 struct dirent
*pde
= readdir((DIR *)pdir
);
283 return pde
? (shdirent
*)&pde
->d_name
[0] : NULL
;
289 void shfile_closedir(struct shdir
*pdir
)
291 #ifdef SH_PURE_STUB_MODE
293 #elif defined(SH_STUB_MODE)
295 closedir((DIR *)pdir
);