sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description: connectors for re-entrant system calls
|
sl@0
|
15 |
*/
|
sl@0
|
16 |
|
sl@0
|
17 |
|
sl@0
|
18 |
// connectors for re-entrant system calls
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "sysif.h"
|
sl@0
|
21 |
#include "lposix.h"
|
sl@0
|
22 |
#include <unistd.h>
|
sl@0
|
23 |
#include <fcntl.h> // for open()
|
sl@0
|
24 |
#include <sys/ioctl.h>
|
sl@0
|
25 |
#include <stdarg.h>
|
sl@0
|
26 |
#include <sys/errno.h>
|
sl@0
|
27 |
#include <sys/stat.h>
|
sl@0
|
28 |
#include <utf.h>
|
sl@0
|
29 |
#include <string.h>
|
sl@0
|
30 |
#include <unistd.h>
|
sl@0
|
31 |
#include <sys/types.h>
|
sl@0
|
32 |
#include "sysreent.h"
|
sl@0
|
33 |
#include <sys/aeselect.h>
|
sl@0
|
34 |
#include "aeselectreent.h"
|
sl@0
|
35 |
#include "fdesc.h"
|
sl@0
|
36 |
#include "stdio_r.h" // for popen3
|
sl@0
|
37 |
#include "stdlib_r.h" // for system
|
sl@0
|
38 |
|
sl@0
|
39 |
#if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__)))
|
sl@0
|
40 |
#include "libc_wsd_defs.h"
|
sl@0
|
41 |
#endif
|
sl@0
|
42 |
#define MAXPATHLEN 260 /* E32STD.H: KMaxFullName + 4 to avoid data loss */
|
sl@0
|
43 |
|
sl@0
|
44 |
extern "C" {
|
sl@0
|
45 |
|
sl@0
|
46 |
/*
|
sl@0
|
47 |
Opens the file which name is stored in the file string.
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
EXPORT_C int open (const char *file, int flags, ...)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
va_list argList;
|
sl@0
|
52 |
register int perms;
|
sl@0
|
53 |
|
sl@0
|
54 |
if(!file)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
errno = EFAULT ;
|
sl@0
|
57 |
return -1 ; //null file pointer
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
va_start (argList, flags);
|
sl@0
|
61 |
perms = va_arg(argList,int);
|
sl@0
|
62 |
va_end (argList);
|
sl@0
|
63 |
|
sl@0
|
64 |
//If mode is invalid
|
sl@0
|
65 |
if( perms > (S_IRWXU | S_IRWXG | S_IRWXO ) )
|
sl@0
|
66 |
{
|
sl@0
|
67 |
//make it read-write for all
|
sl@0
|
68 |
perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
sl@0
|
69 |
}
|
sl@0
|
70 |
wchar_t _widename[MAXPATHLEN+1];
|
sl@0
|
71 |
|
sl@0
|
72 |
if ((size_t)-1 != mbstowcs(_widename, file, MAXPATHLEN))
|
sl@0
|
73 |
{
|
sl@0
|
74 |
return _open_r (&errno, _widename, flags, perms);
|
sl@0
|
75 |
}
|
sl@0
|
76 |
else
|
sl@0
|
77 |
{
|
sl@0
|
78 |
errno = EILSEQ;
|
sl@0
|
79 |
return -1; // Illegal Sequence of wide characeters
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
/*
|
sl@0
|
85 |
A wide_character version of a open().
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
EXPORT_C int wopen (const wchar_t *file, int flags, ...)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
va_list ap;
|
sl@0
|
90 |
int ret;
|
sl@0
|
91 |
register int perms;
|
sl@0
|
92 |
|
sl@0
|
93 |
if(!file)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
errno = EFAULT ;
|
sl@0
|
96 |
return -1 ;
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
va_start (ap, flags);
|
sl@0
|
100 |
perms = va_arg(ap,int);
|
sl@0
|
101 |
va_end (ap);
|
sl@0
|
102 |
|
sl@0
|
103 |
//If mode is invalid
|
sl@0
|
104 |
if( perms > (S_IRWXU | S_IRWXG | S_IRWXO ) )
|
sl@0
|
105 |
{
|
sl@0
|
106 |
//make it read-write for all
|
sl@0
|
107 |
perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
ret = _wopen_r (&errno, file, flags, perms);
|
sl@0
|
111 |
|
sl@0
|
112 |
return ret;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
|
sl@0
|
116 |
/*
|
sl@0
|
117 |
Reads a block of data of the length specified by cnt.
|
sl@0
|
118 |
*/
|
sl@0
|
119 |
EXPORT_C int read (int fd, void *buf, size_t cnt)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
if((int)cnt == 0)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
return 0 ;
|
sl@0
|
124 |
}
|
sl@0
|
125 |
if((int)cnt < 0)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
errno = EINVAL ;
|
sl@0
|
128 |
return -1 ;
|
sl@0
|
129 |
}
|
sl@0
|
130 |
if(!buf)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
errno = EFAULT ;
|
sl@0
|
133 |
return -1 ;
|
sl@0
|
134 |
}
|
sl@0
|
135 |
|
sl@0
|
136 |
//If the fd corresponding to STDIN
|
sl@0
|
137 |
if(fd == STDIN_FILENO && (Backend()->GetDesc(STDIN_FILENO))->Attributes() == KConsoleFd)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
int len = 0;
|
sl@0
|
140 |
char ch = '\0';
|
sl@0
|
141 |
int ret = -1;
|
sl@0
|
142 |
do
|
sl@0
|
143 |
{
|
sl@0
|
144 |
ret = _read_r(&errno, STDIN_FILENO, &ch, 1);
|
sl@0
|
145 |
|
sl@0
|
146 |
//Copy requested count of data, ignore the rest
|
sl@0
|
147 |
if(ret > 0 && len < cnt )
|
sl@0
|
148 |
{
|
sl@0
|
149 |
((char*)buf)[len] = ch;
|
sl@0
|
150 |
len++;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
else if(ret < 0)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
break;
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
}while(ch != '\n');
|
sl@0
|
158 |
|
sl@0
|
159 |
//Handle error case.
|
sl@0
|
160 |
if(ret == -1)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
return ret;
|
sl@0
|
163 |
}
|
sl@0
|
164 |
|
sl@0
|
165 |
return len;
|
sl@0
|
166 |
}
|
sl@0
|
167 |
else
|
sl@0
|
168 |
{
|
sl@0
|
169 |
return _read_r(&errno, fd, (char*)buf, cnt);
|
sl@0
|
170 |
}
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
|
sl@0
|
174 |
/*
|
sl@0
|
175 |
Writes a block of data of the length specified by cnt.
|
sl@0
|
176 |
*/
|
sl@0
|
177 |
EXPORT_C int write (int fd, const void *buf, size_t cnt)
|
sl@0
|
178 |
{
|
sl@0
|
179 |
if((int)cnt == 0)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
return 0;
|
sl@0
|
182 |
}
|
sl@0
|
183 |
if((int)cnt < 0)
|
sl@0
|
184 |
{
|
sl@0
|
185 |
errno = EINVAL;
|
sl@0
|
186 |
return -1;
|
sl@0
|
187 |
}
|
sl@0
|
188 |
if(!buf)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
errno = EFAULT ;
|
sl@0
|
191 |
return -1 ;
|
sl@0
|
192 |
}
|
sl@0
|
193 |
return _write_r(&errno, fd, (char*)buf, cnt);
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
|
sl@0
|
197 |
/*
|
sl@0
|
198 |
Close a file.
|
sl@0
|
199 |
*/
|
sl@0
|
200 |
EXPORT_C int close (int fd)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
return _close_r(&errno, fd);
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
|
sl@0
|
206 |
|
sl@0
|
207 |
/*
|
sl@0
|
208 |
Synchronizes a file's in-memory state with that on the physical medium.
|
sl@0
|
209 |
*/
|
sl@0
|
210 |
EXPORT_C int fsync (int fd)
|
sl@0
|
211 |
{
|
sl@0
|
212 |
return _fsync_r(&errno, fd);
|
sl@0
|
213 |
}
|
sl@0
|
214 |
|
sl@0
|
215 |
/*
|
sl@0
|
216 |
Repositions the read/write file offset.
|
sl@0
|
217 |
*/
|
sl@0
|
218 |
EXPORT_C off_t lseek (int fd, off_t pos, int whence)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
return _lseek_r(&errno, fd, pos, whence);
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
|
sl@0
|
224 |
/*
|
sl@0
|
225 |
Gets information about the named file and writes it to the area that buf points to.
|
sl@0
|
226 |
The system must be able to search all directories leading to the file;
|
sl@0
|
227 |
however, read, write, or execute permission of the file is not required.
|
sl@0
|
228 |
*/
|
sl@0
|
229 |
EXPORT_C int fstat (int fd, struct stat *st)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
if(!st)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
errno = EFAULT ;
|
sl@0
|
234 |
return -1 ;
|
sl@0
|
235 |
}
|
sl@0
|
236 |
return _fstat_r(&errno, fd, st);
|
sl@0
|
237 |
}
|
sl@0
|
238 |
|
sl@0
|
239 |
|
sl@0
|
240 |
/*
|
sl@0
|
241 |
Gets the size of a file.
|
sl@0
|
242 |
*/
|
sl@0
|
243 |
EXPORT_C int stat (const char *name, struct stat *st)
|
sl@0
|
244 |
{
|
sl@0
|
245 |
if(!st)
|
sl@0
|
246 |
{
|
sl@0
|
247 |
errno = EFAULT ;
|
sl@0
|
248 |
return -1 ;
|
sl@0
|
249 |
}
|
sl@0
|
250 |
|
sl@0
|
251 |
wchar_t tmpbuf[MAXPATHLEN+1];
|
sl@0
|
252 |
if ((size_t)-1 != mbstowcs(tmpbuf, name, MAXPATHLEN))
|
sl@0
|
253 |
{
|
sl@0
|
254 |
return _stat_r(&errno, tmpbuf, st);
|
sl@0
|
255 |
}
|
sl@0
|
256 |
errno = EILSEQ;
|
sl@0
|
257 |
return -1;
|
sl@0
|
258 |
}
|
sl@0
|
259 |
|
sl@0
|
260 |
|
sl@0
|
261 |
EXPORT_C int utime (const char *name, const struct utimbuf *filetimes)
|
sl@0
|
262 |
{
|
sl@0
|
263 |
if(!name)
|
sl@0
|
264 |
{
|
sl@0
|
265 |
errno = EFAULT ;
|
sl@0
|
266 |
return -1 ;
|
sl@0
|
267 |
}
|
sl@0
|
268 |
|
sl@0
|
269 |
wchar_t tmpbuf[MAXPATHLEN+1];
|
sl@0
|
270 |
if ((size_t)-1 != mbstowcs(tmpbuf, name, MAXPATHLEN))
|
sl@0
|
271 |
{
|
sl@0
|
272 |
return _utime_r (&errno, tmpbuf, filetimes);
|
sl@0
|
273 |
}
|
sl@0
|
274 |
|
sl@0
|
275 |
errno = EILSEQ;
|
sl@0
|
276 |
return -1;
|
sl@0
|
277 |
}
|
sl@0
|
278 |
|
sl@0
|
279 |
|
sl@0
|
280 |
|
sl@0
|
281 |
/*
|
sl@0
|
282 |
A wide_character version of a stat().
|
sl@0
|
283 |
*/
|
sl@0
|
284 |
EXPORT_C int wstat (const wchar_t *name, struct stat *st)
|
sl@0
|
285 |
{
|
sl@0
|
286 |
if( !name || !st )
|
sl@0
|
287 |
{
|
sl@0
|
288 |
errno = EFAULT;
|
sl@0
|
289 |
return -1;
|
sl@0
|
290 |
}
|
sl@0
|
291 |
return _wstat_r (&errno, name, st);
|
sl@0
|
292 |
}
|
sl@0
|
293 |
|
sl@0
|
294 |
|
sl@0
|
295 |
/*
|
sl@0
|
296 |
duplicates an open file descriptor.
|
sl@0
|
297 |
*/
|
sl@0
|
298 |
EXPORT_C int dup (int aFid)
|
sl@0
|
299 |
{
|
sl@0
|
300 |
return _dup_r(&errno, aFid);
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
|
sl@0
|
304 |
/*
|
sl@0
|
305 |
function duplicates an open file descriptor.
|
sl@0
|
306 |
*/
|
sl@0
|
307 |
EXPORT_C int dup2 (int aFid1, int aFid2)
|
sl@0
|
308 |
{
|
sl@0
|
309 |
return _dup2_r(&errno, aFid1, aFid2);
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
|
sl@0
|
313 |
/*
|
sl@0
|
314 |
sorms a variety of device-specific control functions on device special files.
|
sl@0
|
315 |
*/
|
sl@0
|
316 |
EXPORT_C int ioctl (int aFid, unsigned long aCmd, ...)
|
sl@0
|
317 |
{
|
sl@0
|
318 |
void* aParam ;
|
sl@0
|
319 |
va_list Vlist ;
|
sl@0
|
320 |
int ret;
|
sl@0
|
321 |
va_start(Vlist , aCmd ) ;
|
sl@0
|
322 |
aParam = va_arg(Vlist , void *) ;
|
sl@0
|
323 |
if(!aParam)
|
sl@0
|
324 |
{
|
sl@0
|
325 |
errno = EFAULT ;
|
sl@0
|
326 |
return -1 ;
|
sl@0
|
327 |
}
|
sl@0
|
328 |
|
sl@0
|
329 |
ret = _ioctl_r(&errno, aFid, aCmd, aParam);
|
sl@0
|
330 |
|
sl@0
|
331 |
va_end(Vlist) ;
|
sl@0
|
332 |
return ret;
|
sl@0
|
333 |
}
|
sl@0
|
334 |
|
sl@0
|
335 |
|
sl@0
|
336 |
|
sl@0
|
337 |
/*
|
sl@0
|
338 |
Gets the path name of the current working directory.
|
sl@0
|
339 |
If a buffer is specified, the path name is placed in that buffer,
|
sl@0
|
340 |
and the address of the buffer is returned.
|
sl@0
|
341 |
*/
|
sl@0
|
342 |
|
sl@0
|
343 |
/*
|
sl@0
|
344 |
A wide_character version of a getcwd().
|
sl@0
|
345 |
*/
|
sl@0
|
346 |
EXPORT_C wchar_t* wgetcwd (wchar_t *_buf, size_t _size)
|
sl@0
|
347 |
{
|
sl@0
|
348 |
return _wgetcwd_r(&errno, _buf, _size);
|
sl@0
|
349 |
}
|
sl@0
|
350 |
|
sl@0
|
351 |
|
sl@0
|
352 |
/*
|
sl@0
|
353 |
Changes the current working directory to be pathname.
|
sl@0
|
354 |
The current directory is the beginning point for file
|
sl@0
|
355 |
searches when path names are not absolute.
|
sl@0
|
356 |
If the chdir() function fails, the current working directory remains unchanged.
|
sl@0
|
357 |
*/
|
sl@0
|
358 |
EXPORT_C int chdir (const char *_path)
|
sl@0
|
359 |
{
|
sl@0
|
360 |
if(!_path)
|
sl@0
|
361 |
{
|
sl@0
|
362 |
errno = EFAULT;
|
sl@0
|
363 |
return -1;
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
//we need to use a wide buffer and convert
|
sl@0
|
367 |
wchar_t tmpbuf[MAXPATHLEN+1]; //use the max path length possible
|
sl@0
|
368 |
if ((size_t)-1 != mbstowcs(tmpbuf, _path, MAXPATHLEN))
|
sl@0
|
369 |
{
|
sl@0
|
370 |
return _chdir_r(&errno, tmpbuf);
|
sl@0
|
371 |
}
|
sl@0
|
372 |
errno = EILSEQ;
|
sl@0
|
373 |
return -1;
|
sl@0
|
374 |
}
|
sl@0
|
375 |
|
sl@0
|
376 |
|
sl@0
|
377 |
/* A wide-character version of chdir().
|
sl@0
|
378 |
*/
|
sl@0
|
379 |
EXPORT_C int wchdir (const wchar_t *_path)
|
sl@0
|
380 |
{
|
sl@0
|
381 |
|
sl@0
|
382 |
if(!_path)
|
sl@0
|
383 |
{
|
sl@0
|
384 |
errno = EFAULT;
|
sl@0
|
385 |
return -1;
|
sl@0
|
386 |
}
|
sl@0
|
387 |
|
sl@0
|
388 |
return _wchdir_r(&errno, _path);
|
sl@0
|
389 |
}
|
sl@0
|
390 |
|
sl@0
|
391 |
|
sl@0
|
392 |
/*
|
sl@0
|
393 |
Removes an empty directory whose name is given by pathname.
|
sl@0
|
394 |
The directory must not have any entries other than dot (.) and dot-dot (..).
|
sl@0
|
395 |
*/
|
sl@0
|
396 |
EXPORT_C int rmdir (const char *_path)
|
sl@0
|
397 |
{
|
sl@0
|
398 |
if(!_path)
|
sl@0
|
399 |
{
|
sl@0
|
400 |
errno = EFAULT ;
|
sl@0
|
401 |
return -1 ;
|
sl@0
|
402 |
}
|
sl@0
|
403 |
|
sl@0
|
404 |
if(!strcmp((_path + strlen(_path) -1 ) , ".") )
|
sl@0
|
405 |
{
|
sl@0
|
406 |
errno = EINVAL ;
|
sl@0
|
407 |
return -1 ;
|
sl@0
|
408 |
}
|
sl@0
|
409 |
|
sl@0
|
410 |
wchar_t tmpbuf[MAXPATHLEN+1]; //use the max path length possible
|
sl@0
|
411 |
if ((size_t)-1 != mbstowcs(tmpbuf, _path, MAXPATHLEN))
|
sl@0
|
412 |
{
|
sl@0
|
413 |
return _rmdir_r(&errno, tmpbuf);
|
sl@0
|
414 |
}
|
sl@0
|
415 |
errno = EILSEQ;
|
sl@0
|
416 |
return -1;
|
sl@0
|
417 |
}
|
sl@0
|
418 |
|
sl@0
|
419 |
|
sl@0
|
420 |
|
sl@0
|
421 |
/* A wide-character version of rmdir().
|
sl@0
|
422 |
*/
|
sl@0
|
423 |
EXPORT_C int wrmdir (const wchar_t *_path)
|
sl@0
|
424 |
{
|
sl@0
|
425 |
if( !_path )
|
sl@0
|
426 |
{
|
sl@0
|
427 |
errno = EFAULT;
|
sl@0
|
428 |
return -1;
|
sl@0
|
429 |
}
|
sl@0
|
430 |
return _wrmdir_r(&errno, _path);
|
sl@0
|
431 |
}
|
sl@0
|
432 |
|
sl@0
|
433 |
|
sl@0
|
434 |
/*
|
sl@0
|
435 |
Creates a new directory with the specified path name.
|
sl@0
|
436 |
The file permissions of the new directory are initialized from the specified mode.
|
sl@0
|
437 |
*/
|
sl@0
|
438 |
EXPORT_C int mkdir (const char *_path, mode_t _mode)
|
sl@0
|
439 |
{
|
sl@0
|
440 |
if(!_path)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
errno = EFAULT ;
|
sl@0
|
443 |
return -1 ;
|
sl@0
|
444 |
}
|
sl@0
|
445 |
|
sl@0
|
446 |
//we need to use a wide buffer and convert
|
sl@0
|
447 |
wchar_t tmpbuf[MAXPATHLEN+1]; //use the max path length possible
|
sl@0
|
448 |
if ((size_t)-1 != mbstowcs(tmpbuf, _path, MAXPATHLEN))
|
sl@0
|
449 |
{
|
sl@0
|
450 |
return _mkdir_r(&errno, tmpbuf, _mode);
|
sl@0
|
451 |
}
|
sl@0
|
452 |
errno = EILSEQ;
|
sl@0
|
453 |
return -1;
|
sl@0
|
454 |
}
|
sl@0
|
455 |
|
sl@0
|
456 |
|
sl@0
|
457 |
|
sl@0
|
458 |
/* A wide-character version of mkdir().
|
sl@0
|
459 |
*/
|
sl@0
|
460 |
EXPORT_C int wmkdir (const wchar_t *_path, mode_t _mode)
|
sl@0
|
461 |
{
|
sl@0
|
462 |
|
sl@0
|
463 |
if(!_path)
|
sl@0
|
464 |
{
|
sl@0
|
465 |
errno = EFAULT ;
|
sl@0
|
466 |
return -1 ;
|
sl@0
|
467 |
}
|
sl@0
|
468 |
|
sl@0
|
469 |
return _wmkdir_r(&errno, _path, _mode);
|
sl@0
|
470 |
}
|
sl@0
|
471 |
|
sl@0
|
472 |
|
sl@0
|
473 |
/*
|
sl@0
|
474 |
Sets the access permissions for the file
|
sl@0
|
475 |
whose name is given by pathname to the bit pattern contained in mode.
|
sl@0
|
476 |
For this call to succeed, the effective user ID of the process must match
|
sl@0
|
477 |
the owner of the file, or the process must have appropriate privileges.
|
sl@0
|
478 |
The owner of the file pathname always has privileges to change permission modes
|
sl@0
|
479 |
and file attributes.
|
sl@0
|
480 |
*/
|
sl@0
|
481 |
EXPORT_C int chmod (const char *_path, mode_t _mode)
|
sl@0
|
482 |
{
|
sl@0
|
483 |
if(!_path)
|
sl@0
|
484 |
{
|
sl@0
|
485 |
errno = EFAULT ;
|
sl@0
|
486 |
return -1 ;
|
sl@0
|
487 |
}
|
sl@0
|
488 |
|
sl@0
|
489 |
wchar_t tmpbuf[MAXPATHLEN+1];
|
sl@0
|
490 |
if ((size_t)-1 != mbstowcs(tmpbuf, _path, MAXPATHLEN))
|
sl@0
|
491 |
{
|
sl@0
|
492 |
return _chmod_r(&errno, tmpbuf, _mode);
|
sl@0
|
493 |
}
|
sl@0
|
494 |
errno = EILSEQ;
|
sl@0
|
495 |
return -1;
|
sl@0
|
496 |
}
|
sl@0
|
497 |
/*
|
sl@0
|
498 |
Sets the access permissions for the file specifed by file descriptor
|
sl@0
|
499 |
whose name is given by pathname to the bit pattern contained in mode.
|
sl@0
|
500 |
For this call to succeed, the effective user ID of the process must match
|
sl@0
|
501 |
the owner of the file, or the process must have appropriate privileges.
|
sl@0
|
502 |
The owner of the file pathname always has privileges to change permission modes
|
sl@0
|
503 |
and file attributes.
|
sl@0
|
504 |
*/
|
sl@0
|
505 |
EXPORT_C int fchmod (int fd , mode_t _mode)
|
sl@0
|
506 |
{
|
sl@0
|
507 |
|
sl@0
|
508 |
return _fchmod_r(&errno, fd, _mode);
|
sl@0
|
509 |
}
|
sl@0
|
510 |
|
sl@0
|
511 |
|
sl@0
|
512 |
|
sl@0
|
513 |
/* A wide-character version of chmod().
|
sl@0
|
514 |
*/
|
sl@0
|
515 |
EXPORT_C int wchmod (const wchar_t *_path, mode_t _mode)
|
sl@0
|
516 |
{
|
sl@0
|
517 |
|
sl@0
|
518 |
if(!_path)
|
sl@0
|
519 |
{
|
sl@0
|
520 |
errno = EFAULT ;
|
sl@0
|
521 |
return -1 ;
|
sl@0
|
522 |
}
|
sl@0
|
523 |
|
sl@0
|
524 |
return _wchmod_r(&errno, _path, _mode);
|
sl@0
|
525 |
}
|
sl@0
|
526 |
|
sl@0
|
527 |
|
sl@0
|
528 |
|
sl@0
|
529 |
/* A wide-character version of unlink().
|
sl@0
|
530 |
*/
|
sl@0
|
531 |
EXPORT_C int wunlink (const wchar_t *_path)
|
sl@0
|
532 |
{
|
sl@0
|
533 |
if( !_path )
|
sl@0
|
534 |
{
|
sl@0
|
535 |
errno = EFAULT;
|
sl@0
|
536 |
return -1;
|
sl@0
|
537 |
}
|
sl@0
|
538 |
return _wunlink_r(&errno, _path);
|
sl@0
|
539 |
}
|
sl@0
|
540 |
|
sl@0
|
541 |
|
sl@0
|
542 |
/*
|
sl@0
|
543 |
Renames a file.
|
sl@0
|
544 |
*/
|
sl@0
|
545 |
EXPORT_C int rename (const char *oldpath, const char *newpath)
|
sl@0
|
546 |
{
|
sl@0
|
547 |
if((!oldpath) ||(!newpath))
|
sl@0
|
548 |
{
|
sl@0
|
549 |
errno = EFAULT ;
|
sl@0
|
550 |
return -1 ;
|
sl@0
|
551 |
}
|
sl@0
|
552 |
|
sl@0
|
553 |
wchar_t _old[MAXPATHLEN+1];
|
sl@0
|
554 |
wchar_t _new[MAXPATHLEN+1];
|
sl@0
|
555 |
if ((size_t)-1 != mbstowcs(_old, oldpath, MAXPATHLEN))
|
sl@0
|
556 |
{
|
sl@0
|
557 |
if ((size_t)-1 != mbstowcs(_new, newpath, MAXPATHLEN))
|
sl@0
|
558 |
{
|
sl@0
|
559 |
return _rename_r(&errno, _old, _new);
|
sl@0
|
560 |
}
|
sl@0
|
561 |
}
|
sl@0
|
562 |
errno = EILSEQ;
|
sl@0
|
563 |
return -1;
|
sl@0
|
564 |
}
|
sl@0
|
565 |
|
sl@0
|
566 |
|
sl@0
|
567 |
/* A wide-character version of rename().
|
sl@0
|
568 |
*/
|
sl@0
|
569 |
EXPORT_C int wrename (const wchar_t *oldpath, const wchar_t *newpath)
|
sl@0
|
570 |
{
|
sl@0
|
571 |
|
sl@0
|
572 |
if((!oldpath) ||(!newpath))
|
sl@0
|
573 |
{
|
sl@0
|
574 |
errno = EFAULT ;
|
sl@0
|
575 |
return -1 ;
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
return _wrename_r(&errno, oldpath, newpath);
|
sl@0
|
579 |
}
|
sl@0
|
580 |
|
sl@0
|
581 |
|
sl@0
|
582 |
/*
|
sl@0
|
583 |
Takes a specified path name, pathname and resolves all symbolic links,
|
sl@0
|
584 |
extra slashes (/), and references to /./ and /../.
|
sl@0
|
585 |
The resulting absolute path name is placed in the memory location
|
sl@0
|
586 |
pointed to by the resolved_path argument.
|
sl@0
|
587 |
*/
|
sl@0
|
588 |
|
sl@0
|
589 |
/* A wide-character version of realpath().
|
sl@0
|
590 |
*/
|
sl@0
|
591 |
EXPORT_C wchar_t* wrealpath (const wchar_t* path, wchar_t* resolved)
|
sl@0
|
592 |
{
|
sl@0
|
593 |
return _wrealpath_r(&errno, path, resolved);
|
sl@0
|
594 |
}
|
sl@0
|
595 |
|
sl@0
|
596 |
|
sl@0
|
597 |
/*
|
sl@0
|
598 |
Gives access to the client's stdin
|
sl@0
|
599 |
*/
|
sl@0
|
600 |
EXPORT_C FILE* popen (const char* command, const char* mode)
|
sl@0
|
601 |
{
|
sl@0
|
602 |
// Check for the validity of command.
|
sl@0
|
603 |
// On Linux, the shell would return cannot find command to execute
|
sl@0
|
604 |
if (command == NULL)
|
sl@0
|
605 |
{
|
sl@0
|
606 |
errno = ENOENT;
|
sl@0
|
607 |
return NULL;
|
sl@0
|
608 |
}
|
sl@0
|
609 |
|
sl@0
|
610 |
if(strlen(command) > KMaxPath)
|
sl@0
|
611 |
{
|
sl@0
|
612 |
errno = ENAMETOOLONG;
|
sl@0
|
613 |
return NULL;
|
sl@0
|
614 |
}
|
sl@0
|
615 |
// Check for the validity of Mode.
|
sl@0
|
616 |
if( (!mode) || mode[0] != 'r' && mode[0] != 'w' )
|
sl@0
|
617 |
{
|
sl@0
|
618 |
// Invalid mode
|
sl@0
|
619 |
errno = EINVAL;
|
sl@0
|
620 |
return NULL;
|
sl@0
|
621 |
}
|
sl@0
|
622 |
|
sl@0
|
623 |
wchar_t wcmd[KMaxPath+1];
|
sl@0
|
624 |
|
sl@0
|
625 |
// Widen command
|
sl@0
|
626 |
if ((size_t)-1 != mbstowcs(wcmd, command, KMaxPath))
|
sl@0
|
627 |
{
|
sl@0
|
628 |
int fd = _wpopen_r(&errno, wcmd, mode);
|
sl@0
|
629 |
if (fd > 0)
|
sl@0
|
630 |
{
|
sl@0
|
631 |
// return value is a valid fd
|
sl@0
|
632 |
return fdopen(fd, mode);
|
sl@0
|
633 |
}
|
sl@0
|
634 |
}
|
sl@0
|
635 |
else
|
sl@0
|
636 |
{
|
sl@0
|
637 |
errno = EILSEQ;
|
sl@0
|
638 |
}
|
sl@0
|
639 |
|
sl@0
|
640 |
return NULL;
|
sl@0
|
641 |
}
|
sl@0
|
642 |
|
sl@0
|
643 |
|
sl@0
|
644 |
EXPORT_C FILE* wpopen (const wchar_t* command, const wchar_t* wmode)
|
sl@0
|
645 |
{
|
sl@0
|
646 |
char mode[2];
|
sl@0
|
647 |
size_t sz;
|
sl@0
|
648 |
|
sl@0
|
649 |
mode[0] = '\0';
|
sl@0
|
650 |
sz = wcstombs(mode, wmode, 2);
|
sl@0
|
651 |
//Check for the validity of Mode.
|
sl@0
|
652 |
if (sz <= 0 || (mode[0] != 'r' && mode[0] != 'w'))
|
sl@0
|
653 |
{
|
sl@0
|
654 |
//If its neither "r" nor "w", its undefined behavior
|
sl@0
|
655 |
errno = EINVAL;
|
sl@0
|
656 |
return NULL;
|
sl@0
|
657 |
}
|
sl@0
|
658 |
|
sl@0
|
659 |
if(command)
|
sl@0
|
660 |
{
|
sl@0
|
661 |
if(wcslen(command) > KMaxPath)
|
sl@0
|
662 |
{
|
sl@0
|
663 |
errno = ENAMETOOLONG;
|
sl@0
|
664 |
return NULL;
|
sl@0
|
665 |
}
|
sl@0
|
666 |
|
sl@0
|
667 |
int fd = _wpopen_r(&errno, command, mode );
|
sl@0
|
668 |
//If return Value is valid fd
|
sl@0
|
669 |
if (fd > 0)
|
sl@0
|
670 |
{
|
sl@0
|
671 |
return fdopen(fd, mode);
|
sl@0
|
672 |
}
|
sl@0
|
673 |
}
|
sl@0
|
674 |
else
|
sl@0
|
675 |
{
|
sl@0
|
676 |
errno = ENOENT;
|
sl@0
|
677 |
}
|
sl@0
|
678 |
return NULL;
|
sl@0
|
679 |
}
|
sl@0
|
680 |
|
sl@0
|
681 |
|
sl@0
|
682 |
EXPORT_C int pclose(FILE* stream)
|
sl@0
|
683 |
{
|
sl@0
|
684 |
TInt fd;
|
sl@0
|
685 |
if (!stream || ((fd = fileno(stream)) == -1))
|
sl@0
|
686 |
{
|
sl@0
|
687 |
errno = EINVAL;
|
sl@0
|
688 |
return -1;
|
sl@0
|
689 |
}
|
sl@0
|
690 |
|
sl@0
|
691 |
TInt err = _pclose_r(&errno, fd);
|
sl@0
|
692 |
|
sl@0
|
693 |
if (err != 0)
|
sl@0
|
694 |
{
|
sl@0
|
695 |
if (errno == ECHILD)
|
sl@0
|
696 |
{
|
sl@0
|
697 |
fclose(stream);
|
sl@0
|
698 |
// reset errno just in case it has been modified by fclose
|
sl@0
|
699 |
errno = ECHILD;
|
sl@0
|
700 |
}
|
sl@0
|
701 |
|
sl@0
|
702 |
return -1;
|
sl@0
|
703 |
}
|
sl@0
|
704 |
|
sl@0
|
705 |
return fclose(stream);
|
sl@0
|
706 |
}
|
sl@0
|
707 |
|
sl@0
|
708 |
/* A wide-character version of popen3().
|
sl@0
|
709 |
*/
|
sl@0
|
710 |
EXPORT_C int wpopen3 (const wchar_t* file, const wchar_t* cmd, wchar_t** env, int fids[3])
|
sl@0
|
711 |
{
|
sl@0
|
712 |
if (file == NULL)
|
sl@0
|
713 |
{
|
sl@0
|
714 |
errno = ENOENT;
|
sl@0
|
715 |
return -1;
|
sl@0
|
716 |
}
|
sl@0
|
717 |
|
sl@0
|
718 |
if(wcslen(file) > KMaxPath)
|
sl@0
|
719 |
{
|
sl@0
|
720 |
errno = ENAMETOOLONG;
|
sl@0
|
721 |
return -1;
|
sl@0
|
722 |
}
|
sl@0
|
723 |
|
sl@0
|
724 |
return _wpopen3_r(&errno, file, cmd, env, fids);
|
sl@0
|
725 |
}
|
sl@0
|
726 |
|
sl@0
|
727 |
|
sl@0
|
728 |
EXPORT_C int popen3 (const char* file, const char* cmd, char** env, int fids[3])
|
sl@0
|
729 |
{
|
sl@0
|
730 |
if (file == NULL)
|
sl@0
|
731 |
{
|
sl@0
|
732 |
errno = ENOENT;
|
sl@0
|
733 |
return -1;
|
sl@0
|
734 |
}
|
sl@0
|
735 |
|
sl@0
|
736 |
if(strlen(file) > KMaxPath)
|
sl@0
|
737 |
{
|
sl@0
|
738 |
errno = ENAMETOOLONG;
|
sl@0
|
739 |
return -1;
|
sl@0
|
740 |
}
|
sl@0
|
741 |
|
sl@0
|
742 |
wchar_t wfile[KMaxPath+1];
|
sl@0
|
743 |
wchar_t wcmd[KMaxPath+1];
|
sl@0
|
744 |
|
sl@0
|
745 |
wchar_t** wenv = NULL;
|
sl@0
|
746 |
|
sl@0
|
747 |
TInt ret = mbstowcs(wfile, file, KMaxPath);
|
sl@0
|
748 |
TInt cmdlen = mbstowcs(wcmd, cmd, KMaxPath);
|
sl@0
|
749 |
|
sl@0
|
750 |
if (ret != (size_t)-1 && cmdlen != (size_t)-1)
|
sl@0
|
751 |
{
|
sl@0
|
752 |
//OK, we've widened the first 2 args
|
sl@0
|
753 |
//now for the environment
|
sl@0
|
754 |
|
sl@0
|
755 |
//env will be an array of char pointers with a NULL as the last one
|
sl@0
|
756 |
if (env)
|
sl@0
|
757 |
{
|
sl@0
|
758 |
TInt count = 0;
|
sl@0
|
759 |
|
sl@0
|
760 |
for (; env[count]; ++count) { }
|
sl@0
|
761 |
|
sl@0
|
762 |
//coverity[alloc_fn]
|
sl@0
|
763 |
//coverity[assign]
|
sl@0
|
764 |
|
sl@0
|
765 |
wenv = (wchar_t **)malloc((count+1) * sizeof(wchar_t*));
|
sl@0
|
766 |
if (!wenv)
|
sl@0
|
767 |
{
|
sl@0
|
768 |
errno = ENOMEM;
|
sl@0
|
769 |
return -1;
|
sl@0
|
770 |
}
|
sl@0
|
771 |
|
sl@0
|
772 |
for (int i = 0; i < count; ++i)
|
sl@0
|
773 |
{
|
sl@0
|
774 |
int len = strlen(env[i]) + 1;
|
sl@0
|
775 |
wenv[i] = (wchar_t *)malloc(len * sizeof(wchar_t));
|
sl@0
|
776 |
if (wenv[i] == NULL)
|
sl@0
|
777 |
{
|
sl@0
|
778 |
//coverity[leave_without_push]
|
sl@0
|
779 |
|
sl@0
|
780 |
errno = ENOMEM;
|
sl@0
|
781 |
goto bailout;
|
sl@0
|
782 |
}
|
sl@0
|
783 |
if (mbstowcs(wenv[i], env[i], len) == (size_t)-1)
|
sl@0
|
784 |
{
|
sl@0
|
785 |
//coverity[leave_without_push]
|
sl@0
|
786 |
errno = EILSEQ;
|
sl@0
|
787 |
wenv[i+1] = NULL;
|
sl@0
|
788 |
goto bailout;
|
sl@0
|
789 |
}
|
sl@0
|
790 |
}
|
sl@0
|
791 |
|
sl@0
|
792 |
wenv[count] = 0;
|
sl@0
|
793 |
}
|
sl@0
|
794 |
|
sl@0
|
795 |
if (cmdlen)
|
sl@0
|
796 |
{
|
sl@0
|
797 |
//coverity[leave_without_push]
|
sl@0
|
798 |
ret = wpopen3(wfile, wcmd, wenv, fids);
|
sl@0
|
799 |
}
|
sl@0
|
800 |
else
|
sl@0
|
801 |
{
|
sl@0
|
802 |
//coverity[leave_without_push]
|
sl@0
|
803 |
ret = wpopen3(wfile, NULL, wenv, fids);
|
sl@0
|
804 |
}
|
sl@0
|
805 |
|
sl@0
|
806 |
}
|
sl@0
|
807 |
else
|
sl@0
|
808 |
{
|
sl@0
|
809 |
errno = EILSEQ;
|
sl@0
|
810 |
return -1;
|
sl@0
|
811 |
}
|
sl@0
|
812 |
|
sl@0
|
813 |
bailout:
|
sl@0
|
814 |
if (wenv)
|
sl@0
|
815 |
{
|
sl@0
|
816 |
for (int i = 0; wenv[i]; ++i)
|
sl@0
|
817 |
{
|
sl@0
|
818 |
free(wenv[i]);
|
sl@0
|
819 |
}
|
sl@0
|
820 |
free(wenv);
|
sl@0
|
821 |
}
|
sl@0
|
822 |
|
sl@0
|
823 |
return ret;
|
sl@0
|
824 |
}
|
sl@0
|
825 |
|
sl@0
|
826 |
/*
|
sl@0
|
827 |
Lets the calling process obtain status information about one of its child processes.
|
sl@0
|
828 |
If status information is available for two or more child processes,
|
sl@0
|
829 |
the order in which their status is reported is unspecified.
|
sl@0
|
830 |
*/
|
sl@0
|
831 |
EXPORT_C int waitpid (int pid, int* status, int options)
|
sl@0
|
832 |
{
|
sl@0
|
833 |
return _waitpid_r(&errno, pid, status, options);
|
sl@0
|
834 |
}
|
sl@0
|
835 |
|
sl@0
|
836 |
|
sl@0
|
837 |
/*
|
sl@0
|
838 |
Calls reentrant version of waitpid().
|
sl@0
|
839 |
*/
|
sl@0
|
840 |
EXPORT_C int wait (int* status)
|
sl@0
|
841 |
{
|
sl@0
|
842 |
return _wait_r(&errno, status);
|
sl@0
|
843 |
}
|
sl@0
|
844 |
|
sl@0
|
845 |
|
sl@0
|
846 |
|
sl@0
|
847 |
/*
|
sl@0
|
848 |
Execute command.
|
sl@0
|
849 |
*/
|
sl@0
|
850 |
|
sl@0
|
851 |
/* A wide-character version of a system().
|
sl@0
|
852 |
*/
|
sl@0
|
853 |
EXPORT_C int wsystem (const wchar_t* cmd)
|
sl@0
|
854 |
{
|
sl@0
|
855 |
if (cmd==0)
|
sl@0
|
856 |
{
|
sl@0
|
857 |
return 1; // special case, says that we do support system().
|
sl@0
|
858 |
}
|
sl@0
|
859 |
|
sl@0
|
860 |
if(wcslen(cmd) > KMaxPath)
|
sl@0
|
861 |
{
|
sl@0
|
862 |
errno = ENAMETOOLONG;
|
sl@0
|
863 |
return -1;
|
sl@0
|
864 |
}
|
sl@0
|
865 |
|
sl@0
|
866 |
return _wsystem_r(&errno, cmd);
|
sl@0
|
867 |
}
|
sl@0
|
868 |
|
sl@0
|
869 |
|
sl@0
|
870 |
// -----------------------------------------------------------------------------
|
sl@0
|
871 |
// Select() : Implementation of Select for I/O multiplexing
|
sl@0
|
872 |
// This API is used for waiting on multiple descriptors to become ready
|
sl@0
|
873 |
// Maximum timeout to wait can also be specified
|
sl@0
|
874 |
// Returns: System wide error code
|
sl@0
|
875 |
// -----------------------------------------------------------------------------
|
sl@0
|
876 |
//
|
sl@0
|
877 |
EXPORT_C int select(int maxfd, fd_set *readfds, fd_set *writefds,
|
sl@0
|
878 |
fd_set *exceptfds, struct timeval *tvptr)
|
sl@0
|
879 |
{
|
sl@0
|
880 |
return _select_r(&errno, maxfd, readfds, writefds, exceptfds, tvptr);
|
sl@0
|
881 |
}
|
sl@0
|
882 |
} // extern "C"
|
sl@0
|
883 |
|
sl@0
|
884 |
// -----------------------------------------------------------------------------
|
sl@0
|
885 |
// aselect() : Implementation of Select for asynchronous I/O multiplexing
|
sl@0
|
886 |
// This API is used for waiting on multiple descriptors to become ready
|
sl@0
|
887 |
// Maximum timeout to wait can also be specified
|
sl@0
|
888 |
// Returns: System wide error code
|
sl@0
|
889 |
// This api does not provide C Linkage
|
sl@0
|
890 |
// -----------------------------------------------------------------------------
|
sl@0
|
891 |
//
|
sl@0
|
892 |
EXPORT_C int aselect(int maxfd, fd_set *readfds, fd_set *writefds,
|
sl@0
|
893 |
fd_set *exceptfds, struct timeval *tvptr,
|
sl@0
|
894 |
TRequestStatus* requeststatus)
|
sl@0
|
895 |
{
|
sl@0
|
896 |
return _aselect_r(&errno, maxfd, readfds, writefds, exceptfds, tvptr, requeststatus);
|
sl@0
|
897 |
}
|
sl@0
|
898 |
|
sl@0
|
899 |
// -----------------------------------------------------------------------------
|
sl@0
|
900 |
// cancelaselect() : Implementation of Select for asynchronous I/O multiplexing
|
sl@0
|
901 |
// This API is used for cancelling the aselect issued on requeststatus
|
sl@0
|
902 |
// Returns: System wide error code
|
sl@0
|
903 |
// This api does not provide C Linkage
|
sl@0
|
904 |
// -----------------------------------------------------------------------------
|
sl@0
|
905 |
//
|
sl@0
|
906 |
EXPORT_C int cancelaselect(TRequestStatus* requeststatus)
|
sl@0
|
907 |
{
|
sl@0
|
908 |
return _cancelaselect_r(&errno, requeststatus);
|
sl@0
|
909 |
}
|
sl@0
|
910 |
|
sl@0
|
911 |
// -----------------------------------------------------------------------------
|
sl@0
|
912 |
// eselect() : Implementation of Select for I/O multiplexing
|
sl@0
|
913 |
// This API is used for waiting on multiple descriptors to become ready,
|
sl@0
|
914 |
// or for any of the TRequestStatus object in the TRequestStatus array passed
|
sl@0
|
915 |
// to be signalled
|
sl@0
|
916 |
// Maximum timeout to wait can also be specified
|
sl@0
|
917 |
// Returns: System wide error code
|
sl@0
|
918 |
// This api does not provide C Linkage
|
sl@0
|
919 |
// -----------------------------------------------------------------------------
|
sl@0
|
920 |
//
|
sl@0
|
921 |
EXPORT_C int eselect(int maxfd, fd_set *readfds, fd_set *writefds,
|
sl@0
|
922 |
fd_set *exceptfds, struct timeval *tvptr, int numreqs,
|
sl@0
|
923 |
TRequestStatus* waitarray)
|
sl@0
|
924 |
{
|
sl@0
|
925 |
return _eselect_r(&errno, maxfd, readfds, writefds, exceptfds, tvptr, numreqs, waitarray);
|
sl@0
|
926 |
}
|
sl@0
|
927 |
|
sl@0
|
928 |
// -----------------------------------------------------------------------------
|
sl@0
|
929 |
// fcntl() : Implementation of fcntl for supporting Non-Blocking I/O
|
sl@0
|
930 |
// This API is used for setting a file descriptor as non-blocking
|
sl@0
|
931 |
// Returns: System wide error code
|
sl@0
|
932 |
// -----------------------------------------------------------------------------
|
sl@0
|
933 |
//
|
sl@0
|
934 |
EXPORT_C int fcntl (int aFid, int aCmd, ...)
|
sl@0
|
935 |
{
|
sl@0
|
936 |
va_list ap;
|
sl@0
|
937 |
va_start(ap, aCmd);
|
sl@0
|
938 |
|
sl@0
|
939 |
int ret;
|
sl@0
|
940 |
ret = _fcntl_r(&errno, aFid,aCmd, va_arg(ap, long));
|
sl@0
|
941 |
|
sl@0
|
942 |
va_end(ap);
|
sl@0
|
943 |
return ret ;
|
sl@0
|
944 |
}
|
sl@0
|
945 |
|
sl@0
|
946 |
// -----------------------------------------------------------------------------
|
sl@0
|
947 |
//int setecho(int fd, unsigned int echoval)
|
sl@0
|
948 |
//
|
sl@0
|
949 |
//Sets the echo flag for this fd.
|
sl@0
|
950 |
// -----------------------------------------------------------------------------
|
sl@0
|
951 |
|
sl@0
|
952 |
extern "C" {
|
sl@0
|
953 |
EXPORT_C int setecho(int fd, uint8_t echoval)
|
sl@0
|
954 |
{
|
sl@0
|
955 |
return _setecho_r(&errno, fd, echoval);
|
sl@0
|
956 |
}
|
sl@0
|
957 |
} //extern "C"
|
sl@0
|
958 |
|
sl@0
|
959 |
|
sl@0
|
960 |
|