2 /* Copyright Gerhard Rieger and contributors (see file CHANGES) */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 /* explicit system call and C library trace function, for those who miss strace
9 #include "xioconfig.h" /* what features are enabled */
11 #include "sysincludes.h"
26 #if HAVE_PROTOTYPE_LIB_posix_memalign
27 int Posix_memalign(void **memptr
, size_t alignment
, size_t size
) {
29 Debug3("posix_memalign(%p, "F_Zu
", "F_Zu
")", memptr
, alignment
, size
);
30 result
= posix_memalign(memptr
, alignment
, size
);
31 Debug1("posix_memalign(...) -> %d", result
);
34 #endif /* HAVE_PROTOTYPE_LIB_posix_memalign */
36 mode_t
Umask(mode_t mask
) {
39 Debug1("umask("F_mode
")", mask
);
42 Debug1("umask() -> "F_mode
, result
);
47 #endif /* WITH_SYCLS */
50 int Open(const char *pathname
, int flags
, mode_t mode
) {
52 if (!diag_in_handler
) diag_flush();
54 Debug3("open(\"%s\", 0%o, 0%03o)", pathname
, flags
, mode
);
55 #endif /* WITH_SYCLS */
56 result
= open(pathname
, flags
, mode
);
58 if (!diag_in_handler
) diag_flush();
60 Info4("open(\"%s\", 0%o, 0%03o) -> %d", pathname
, flags
, mode
, result
);
61 #endif /* WITH_SYCLS */
68 int Creat(const char *pathname
, mode_t mode
) {
70 Debug2("creat(\"%s\", 0%03o)", pathname
, mode
);
71 result
= creat(pathname
, mode
);
73 Info3("creat(\"%s\", 0%03o) -> %d", pathname
, mode
, result
);
78 off_t
Lseek(int fildes
, off_t offset
, int whence
) {
81 Debug3("lseek(%d, "F_off
", %d)", fildes
, offset
, whence
);
82 result
= lseek(fildes
, offset
, whence
);
84 Debug1("lseek() -> "F_off
, result
);
90 off64_t
Lseek64(int fildes
, off64_t offset
, int whence
) {
93 Debug3("lseek64(%d, "F_off64
", %d)", fildes
, offset
, whence
);
94 result
= lseek64(fildes
, offset
, whence
);
96 Debug1("lseek64() -> "F_off64
, result
);
100 #endif /* HAVE_LSEEK64 */
108 Debug1("getpid() -> "F_pid
, result
);
113 pid_t
Getppid(void) {
119 Debug1("getppid() -> "F_pid
, result
);
124 pid_t
Getpgrp(void) {
130 Debug1("getpgrp() -> "F_pid
, result
);
135 #if 0 /* does not compile for FreeBSD */
136 /* setpgrp() is not BSD compatible, needs setpgid(..., ...) instead */
142 Debug1("setpgrp() -> %d", result
);
149 int Getpgid(pid_t pid
) {
152 Debug1("getpgid("F_pid
")", pid
);
153 result
= getpgid(pid
);
155 Debug1("getpgid() -> "F_pid
, result
);
161 int Setpgid(pid_t pid
, pid_t pgid
) {
163 Debug2("setpgid("F_pid
", "F_pid
")", pid
, pgid
);
164 result
= setpgid(pid
, pgid
);
166 Debug1("setpgid() -> %d", result
);
171 pid_t
Tcgetpgrp(int fd
) {
173 Debug1("tcgetpgrp(%d)", fd
);
174 result
= tcgetpgrp(fd
);
176 Debug1("tcgetpgrp() -> %d", result
);
181 int Tcsetpgrp(int fd
, pid_t pgrpid
) {
183 Debug2("tcsetpgrp(%d, "F_pid
")", fd
, pgrpid
);
184 result
= tcsetpgrp(fd
, pgrpid
);
186 Debug1("tcsetpgrp() -> %d", result
);
192 pid_t
Getsid(pid_t pid
) {
194 Debug1("getsid("F_pid
")", pid
);
195 result
= getsid(pid
);
197 Debug1("getsid() -> "F_pid
, result
);
208 Debug1("setsid() -> "F_pid
, result
);
219 Debug1("getuid() -> "F_uid
, result
);
224 uid_t
Geteuid(void) {
230 Debug1("geteuid() -> "F_uid
, result
);
235 int Setuid(uid_t uid
) {
237 Debug1("setuid("F_uid
")", uid
);
238 result
= setuid(uid
);
240 Debug1("setuid() -> %d", result
);
251 Debug1("getgid() -> "F_gid
, result
);
256 gid_t
Getegid(void) {
262 Debug1("getegid() -> "F_gid
, result
);
267 int Setgid(gid_t gid
) {
269 Debug1("setgid("F_gid
")", gid
);
270 result
= setgid(gid
);
272 Debug1("setgid() -> %d", result
);
277 int Initgroups(const char *user
, gid_t group
) {
279 Debug2("initgroups(\"%s\", "F_gid
")", user
, group
);
280 result
= initgroups(user
, group
);
282 Debug1("initgroups() -> %d", result
);
287 int Getgroups(int size
, gid_t list
[]) {
289 Debug2("getgroups(%d, "F_gid
",...)", size
, list
[0]);
290 result
= getgroups(size
, list
);
292 Debug1("getgroups() -> %d", result
);
298 int Setgroups(size_t size
, const gid_t
*list
) {
301 case 0: Debug1("setgroups("F_Zu
", [])", size
); break;;
302 case 1: Debug2("setgroups("F_Zu
", ["F_gid
"])", size
, list
[0]); break;;
303 case 2: Debug3("setgroups("F_Zu
", ["F_gid
","F_gid
"])", size
, list
[0], list
[1]); break;;
304 default: Debug3("setgroups("F_Zu
", ["F_gid
","F_gid
",...])", size
, list
[0], list
[1]); break;;
306 result
= setgroups(size
, list
);
308 Debug1("setgroups() -> %d", result
);
314 #if HAVE_GETGROUPLIST
315 int Getgrouplist(const char *user
, gid_t group
, gid_t
*groups
, int *ngroups
) {
316 int n
= *ngroups
, result
;
317 Debug4("getgrouplist(\"%s\", "F_gid
", %p, [%d])", user
, group
, groups
, n
);
318 result
= getgrouplist(user
, group
, groups
, ngroups
);
319 switch (Min(n
,*ngroups
)) {
320 case 0: Debug2("getgrouplist(,, [], [%d]) -> %d", *ngroups
, result
); break;
321 case 1: Debug3("getgrouplist(,, ["F_gid
"], [%d]) -> %d", groups
[0], *ngroups
, result
); break;
322 case 2: Debug4("getgrouplist(,, ["F_gid
","F_gid
"], [%d]) -> %d", groups
[0], groups
[1], *ngroups
, result
); break;
323 default: Debug4("getgrouplist(,, ["F_gid
","F_gid
",...], [%d]) -> %d", groups
[0], groups
[1], *ngroups
, result
); break;
329 int Chdir(const char *path
) {
331 Debug1("chdir(\"%s\")", path
);
332 result
= chdir(path
);
334 Debug1("chdir() -> %d", result
);
339 int Chroot(const char *path
) {
341 Debug1("chroot(\"%s\")", path
);
342 result
= chroot(path
);
344 Debug1("chroot() -> %d", result
);
349 int Gettimeofday(struct timeval
*tv
, struct timezone
*tz
) {
351 #if WITH_MSGLEVEL <= E_DEBUG
353 Debug3("gettimeofday(%p, {%d,%d})",
354 tv
, tz
->tz_minuteswest
, tz
->tz_dsttime
);
356 Debug1("gettimeofday(%p, NULL)", tv
);
358 #endif /* WITH_MSGLEVEL <= E_DEBUG */
359 result
= gettimeofday(tv
, tz
);
360 #if WITH_MSGLEVEL <= E_DEBUG
363 Debug5("gettimeofday({%ld,%ld}, {%d,%d}) -> %d",
364 tv
->tv_sec
, tv
->tv_usec
, tz
->tz_minuteswest
, tz
->tz_dsttime
,
367 Debug3("gettimeofday({%ld,%ld},) -> %d",
368 tv
->tv_sec
, tv
->tv_usec
, result
);
371 #endif /* WITH_MSGLEVEL <= E_DEBUG */
375 int Mknod(const char *pathname
, mode_t mode
, dev_t dev
) {
377 Debug3("mknod(\"%s\", 0%o, "F_dev
")", pathname
, mode
, dev
);
378 result
= mknod(pathname
, mode
, dev
);
380 Debug1("mknod() -> %d", result
);
385 int Mkfifo(const char *pathname
, mode_t mode
) {
387 Debug2("mkfifo(\"%s\", 0%o)", pathname
, mode
);
388 result
= mkfifo(pathname
, mode
);
390 Debug1("mkfifo() -> %d", result
);
395 static void prtstat(const char *func
, struct stat
*buf
, int result
) {
396 char txt
[256], *t
= txt
;
398 t
+= sprintf(t
, "%s(, {"F_dev
","F_st_ino
","F_mode
","F_st_nlink
","F_uid
","F_gid
,
399 func
, buf
->st_dev
, buf
->st_ino
,
400 buf
->st_mode
, buf
->st_nlink
, buf
->st_uid
, buf
->st_gid
);
402 t
+= sprintf(t
, ","F_dev
, buf
->st_rdev
);
404 t
+= sprintf(t
, ","F_st_size
, buf
->st_size
);
406 t
+= sprintf(t
, ","F_st_blksize
, buf
->st_blksize
);
409 t
+= sprintf(t
, ","F_st_blocks
, buf
->st_blocks
);
411 sprintf(t
, ",...}) -> %d", result
);
415 #if defined(HAVE_STAT64) || defined(HAVE_FSTAT64) || defined(HAVE_LSTAT64)
416 static void prtstat64(const char *func
, struct stat64
*buf
, int result
) {
417 char txt
[256], *t
= txt
;
420 sprintf(t
, "%s(, {}) -> %d", func
, result
);
422 t
+= sprintf(t
, "%s(, {"F_dev
","F_st64_ino
","F_mode
","F_st_nlink
","F_uid
","F_gid
,
423 func
, buf
->st_dev
, buf
->st_ino
,
424 buf
->st_mode
, buf
->st_nlink
, buf
->st_uid
, buf
->st_gid
);
426 t
+= sprintf(t
, ","F_dev
, buf
->st_rdev
);
428 t
+= sprintf(t
, ","F_st64_size
, buf
->st_size
);
430 t
+= sprintf(t
, ","F_st_blksize
, buf
->st_blksize
);
433 t
+= sprintf(t
, ","F_st64_blocks
, buf
->st_blocks
);
435 sprintf(t
, ",...}) -> %d", result
);
439 #endif /* defined(HAVE_STAT64) || defined(HAVE_FSTAT64) || defined(HAVE_LSTAT64) */
441 int Stat(const char *file_name
, struct stat
*buf
) {
443 Debug2("stat(%s, %p)", file_name
, buf
);
444 result
= stat(file_name
, buf
);
446 prtstat("stat", buf
, result
);
452 int Stat64(const char *file_name
, struct stat64
*buf
) {
454 Debug2("stat64(%s, %p)", file_name
, buf
);
455 result
= stat64(file_name
, buf
);
457 prtstat64("stat64", buf
, result
);
461 #endif /* HAVE_STAT64 */
463 int Fstat(int filedes
, struct stat
*buf
) {
465 Debug2("fstat(%d, %p)", filedes
, buf
);
466 result
= fstat(filedes
, buf
);
468 prtstat("fstat", buf
, result
);
474 int Fstat64(int filedes
, struct stat64
*buf
) {
476 Debug2("fstat64(%d, %p)", filedes
, buf
);
477 result
= fstat64(filedes
, buf
);
479 prtstat64("fstat64", buf
, result
);
483 #endif /* HAVE_FSTAT64 */
485 int Lstat(const char *file_name
, struct stat
*buf
) {
487 Debug2("lstat(%s, %p)", file_name
, buf
);
488 result
= lstat(file_name
, buf
);
490 prtstat("lstat", buf
, result
);
496 int Lstat64(const char *file_name
, struct stat64
*buf
) {
498 Debug2("lstat64(%s, %p)", file_name
, buf
);
499 result
= lstat64(file_name
, buf
);
501 prtstat64("lstat64", buf
, result
);
505 #endif /* HAVE_LSTAT64 */
509 Debug1("dup(%d)", oldfd
);
512 Info2("dup(%d) -> %d", oldfd
, newfd
);
517 int Dup2(int oldfd
, int newfd
) {
519 Debug2("dup2(%d, %d)", oldfd
, newfd
);
520 result
= dup2(oldfd
, newfd
);
522 Info3("dup2(%d, %d) -> %d", oldfd
, newfd
, result
);
527 int Pipe(int filedes
[2]) {
529 Debug1("pipe(%p)", filedes
);
530 result
= pipe(filedes
);
532 Info3("pipe({%d,%d}) -> %d", filedes
[0], filedes
[1], result
);
537 #endif /* WITH_SYCLS */
539 ssize_t
Read(int fd
, void *buf
, size_t count
) {
542 if (!diag_in_handler
) diag_flush();
544 Debug3("read(%d, %p, "F_Zu
")", fd
, buf
, count
);
545 #endif /* WITH_SYCLS */
546 result
= read(fd
, buf
, count
);
548 if (!diag_in_handler
) diag_flush();
550 Debug1("read -> "F_Zd
, result
);
551 #endif /* WITH_SYCLS */
556 ssize_t
Write(int fd
, const void *buf
, size_t count
) {
559 if (!diag_in_handler
) diag_flush();
561 Debug3("write(%d, %p, "F_Zu
")", fd
, buf
, count
);
562 #endif /* WITH_SYCLS */
563 result
= write(fd
, buf
, count
);
565 if (!diag_in_handler
) diag_flush();
567 Debug1("write -> "F_Zd
, result
);
568 #endif /* WITH_SYCLS */
573 int Fcntl(int fd
, int cmd
) {
575 if (!diag_in_handler
) diag_flush();
577 Debug2("fcntl(%d, %d)", fd
, cmd
);
578 #endif /* WITH_SYCLS */
579 result
= fcntl(fd
, cmd
);
580 if (!diag_in_handler
) diag_flush();
583 Debug1("fcntl() -> %d", result
);
585 #endif /* WITH_SYCLS */
589 int Fcntl_l(int fd
, int cmd
, long arg
) {
591 if (!diag_in_handler
) diag_flush();
593 Debug3("fcntl(%d, %d, %ld)", fd
, cmd
, arg
);
594 #endif /* WITH_SYCLS */
595 result
= fcntl(fd
, cmd
, arg
);
597 if (!diag_in_handler
) diag_flush();
599 Debug1("fcntl() -> %d", result
);
600 #endif /* WITH_SYCLS */
605 int Fcntl_lock(int fd
, int cmd
, struct flock
*l
) {
607 if (!diag_in_handler
) diag_flush();
609 Debug7("fcntl(%d, %d, {type=%hd,whence=%hd,start="F_off
",len="F_off
",pid="F_pid
"})",
610 fd
, cmd
, l
->l_type
, l
->l_whence
, l
->l_start
, l
->l_len
, l
->l_pid
);
611 #endif /* WITH_SYCLS */
612 result
= fcntl(fd
, cmd
, l
);
614 if (!diag_in_handler
) diag_flush();
616 Debug1("fcntl() -> %d", result
);
617 #endif /* WITH_SYCLS */
624 int Ftruncate(int fd
, off_t length
) {
626 Debug2("ftruncate(%d, "F_off
")", fd
, length
);
627 retval
= ftruncate(fd
, length
);
629 Debug1("ftruncate() -> %d", retval
);
635 int Ftruncate64(int fd
, off64_t length
) {
637 Debug2("ftruncate64(%d, "F_off64
")", fd
, length
);
638 retval
= ftruncate64(fd
, length
);
640 Debug1("ftruncate64() -> %d", retval
);
644 #endif /* HAVE_FTRUNCATE64 */
646 #endif /* WITH_SYCLS */
649 int Flock(int fd
, int operation
) {
651 if (!diag_in_handler
) diag_flush();
653 Debug2("flock(%d, %d)", fd
, operation
);
654 #endif /* WITH_SYCLS */
655 retval
= flock(fd
, operation
);
657 if (!diag_in_handler
) diag_flush();
659 Debug1("flock() -> %d", retval
);
660 #endif /* WITH_SYCLS */
664 #endif /* HAVE_FLOCK */
666 int Ioctl(int d
, int request
, void *argp
) {
668 if (!diag_in_handler
) diag_flush();
670 if (argp
> (void *)0x10000) { /* fuzzy...*/
671 Debug4("ioctl(%d, 0x%x, %p{%lu})", d
, request
, argp
, *(unsigned long *)argp
);
673 Debug3("ioctl(%d, 0x%x, 0x%p)", d
, request
, argp
);
675 #endif /* WITH_SYCLS */
676 retval
= ioctl(d
, request
, argp
);
678 if (!diag_in_handler
) diag_flush();
680 Debug1("ioctl() -> %d", retval
);
681 #endif /* WITH_SYCLS */
686 int Ioctl_int(int d
, int request
, int arg
) {
688 if (!diag_in_handler
) diag_flush();
690 Debug3("ioctl(%d, 0x%x, %d)", d
, request
, arg
);
691 #endif /* WITH_SYCLS */
692 retval
= ioctl(d
, request
, arg
);
694 if (!diag_in_handler
) diag_flush();
696 Debug1("ioctl() -> %d", retval
);
697 #endif /* WITH_SYCLS */
706 Info1("close(%d)", fd
);
709 Debug1("close() -> %d", retval
);
714 int Fchown(int fd
, uid_t owner
, gid_t group
) {
716 Debug3("fchown(%d, "F_uid
", "F_gid
")", fd
, owner
, group
);
717 retval
= fchown(fd
, owner
, group
);
719 Debug1("fchown() -> %d", retval
);
724 int Fchmod(int fd
, mode_t mode
) {
726 Debug2("fchmod(%d, 0%o)", fd
, mode
);
727 retval
= fchmod(fd
, mode
);
729 Debug1("fchmod() -> %d", retval
);
734 int Unlink(const char *pathname
) {
736 Debug1("unlink(\"%s\")", pathname
);
737 retval
= unlink(pathname
);
739 Debug1("unlink() -> %d", retval
);
744 int Symlink(const char *oldpath
, const char *newpath
) {
746 Debug2("symlink(\"%s\", \"%s\")", oldpath
, newpath
);
747 retval
= symlink(oldpath
, newpath
);
749 Debug1("symlink() -> %d", retval
);
754 int Readlink(const char *path
, char *buf
, size_t bufsiz
) {
756 Debug3("readlink(\"%s\", %p, "F_Zu
")", path
, buf
, bufsiz
);
757 retval
= readlink(path
, buf
, bufsiz
);
759 Debug1("readlink() -> %d", retval
);
764 int Chown(const char *path
, uid_t owner
, gid_t group
) {
766 Debug3("chown(\"%s\", "F_uid
", "F_gid
")", path
, owner
, group
);
767 retval
= chown(path
, owner
, group
);
769 Debug1("chown() -> %d", retval
);
774 int Chmod(const char *path
, mode_t mode
) {
776 Debug2("chmod(\"%s\", 0%o)", path
, mode
);
777 retval
= chmod(path
, mode
);
779 Debug1("chmod() -> %d", retval
);
784 #endif /* WITH_SYCLS */
787 /* we only show the first struct pollfd; hope this is enough for most cases. */
788 int Poll(struct pollfd
*ufds
, unsigned int nfds
, int timeout
) {
790 if (!diag_in_handler
) diag_flush();
793 Debug10("poll({%d,0x%02hx,}{%d,0x%02hx,}{%d,0x%02hx,}{%d,0x%02hx,}, %u, %d)",
794 ufds
[0].fd
, ufds
[0].events
, ufds
[1].fd
, ufds
[1].events
,
795 ufds
[2].fd
, ufds
[2].events
, ufds
[3].fd
, ufds
[3].events
,
798 Debug4("poll({%d,0x%02hx,}, , %u, %d)", ufds
[0].fd
, ufds
[0].events
, nfds
, timeout
);
800 #endif /* WITH_SYCLS */
801 result
= poll(ufds
, nfds
, timeout
);
803 if (!diag_in_handler
) diag_flush();
806 Debug5("poll(, {,,0x%02hx}{,,0x%02hx}{,,0x%02hx}{,,0x%02hx}) -> %d",
807 ufds
[0].revents
, ufds
[1].revents
, ufds
[2].revents
, ufds
[3].revents
, result
);
809 Debug2("poll(, {,,0x%02hx}) -> %d", ufds
[0].revents
, result
);
811 #endif /* WITH_SYCLS */
815 #endif /* HAVE_POLL */
817 /* we only show the first word of the fd_set's; hope this is enough for most
819 int Select(int n
, fd_set
*readfds
, fd_set
*writefds
, fd_set
*exceptfds
,
820 struct timeval
*timeout
) {
822 if (!diag_in_handler
) diag_flush();
825 Debug7("select(%d, &0x%lx, &0x%lx, &0x%lx, %s%lu."F_tv_usec
")",
826 n
, readfds
?readfds
->fds_bits
[0]:0, writefds
?writefds
->fds_bits
[0]:0,
827 exceptfds
?exceptfds
->fds_bits
[0]:0,
828 timeout
?"&":"NULL/", timeout
?timeout
->tv_sec
:0,
829 timeout
?timeout
->tv_usec
:0);
831 Debug7("select(%d, &0x%lx, &0x%lx, &0x%lx, %s%lu.%06u)",
832 n
, readfds
?readfds
->__fds_bits
[0]:0, writefds
?writefds
->__fds_bits
[0]:0,
833 exceptfds
?exceptfds
->__fds_bits
[0]:0,
834 timeout
?"&":"NULL/", timeout
?timeout
->tv_sec
:0,
835 timeout
?timeout
->tv_usec
:0);
837 #endif /* WITH_SYCLS */
838 result
= select(n
, readfds
, writefds
, exceptfds
, timeout
);
840 if (!diag_in_handler
) diag_flush();
843 Debug7("select -> (, 0x%lx, 0x%lx, 0x%lx, %s%lu."F_tv_usec
"), %d",
844 readfds
?readfds
->fds_bits
[0]:0, writefds
?writefds
->fds_bits
[0]:0,
845 exceptfds
?exceptfds
->fds_bits
[0]:0,
846 timeout
?"&":"NULL/", timeout
?timeout
->tv_sec
:0,
847 timeout
?timeout
->tv_usec
:0, result
);
849 Debug7("select -> (, 0x%lx, 0x%lx, 0x%lx, %s%lu.%06u), %d",
850 readfds
?readfds
->__fds_bits
[0]:0, writefds
?writefds
->__fds_bits
[0]:0,
851 exceptfds
?exceptfds
->__fds_bits
[0]:0,
852 timeout
?"&":"NULL/", timeout
?timeout
->tv_sec
:0,
853 timeout
?timeout
->tv_usec
:0, result
);
855 #endif /* WITH_SYCLS */
862 /* we only show the first word of the fd_set's; hope this is enough for most
864 int Pselect(int n
, fd_set
*readfds
, fd_set
*writefds
, fd_set
*exceptfds
,
865 const struct timespec
*timeout
, const sigset_t
*sigmask
) {
867 if (!diag_in_handler
) diag_flush();
870 Debug8("pselect(%d, &0x%lx, &0x%lx, &0x%lx, %s%lu."F_tv_nsec
", "F_sigset
")",
871 n
, readfds
?readfds
->fds_bits
[0]:0, writefds
?writefds
->fds_bits
[0]:0,
872 exceptfds
?exceptfds
->fds_bits
[0]:0,
873 timeout
?"&":"NULL/", timeout
?timeout
->tv_sec
:0,
874 timeout
?timeout
->tv_nsec
:0, *(T_sigset
*)sigmask
);
876 Debug8("pselect(%d, &0x%lx, &0x%lx, &0x%lx, %s%lu.%06u)",
877 n
, readfds
?readfds
->__fds_bits
[0]:0, writefds
?writefds
->__fds_bits
[0]:0,
878 exceptfds
?exceptfds
->__fds_bits
[0]:0,
879 timeout
?"&":"NULL/", timeout
?timeout
->tv_sec
:0,
880 timeout
?timeout
->tv_nsec
:0);
882 #endif /* WITH_SYCLS */
883 result
= pselect(n
, readfds
, writefds
, exceptfds
, timeout
, sigmask
);
885 if (!diag_in_handler
) diag_flush();
888 Debug5("pselect -> (, 0x%lx, 0x%lx, 0x%lx), "F_sigset
", %d",
889 readfds
?readfds
->fds_bits
[0]:0, writefds
?writefds
->fds_bits
[0]:0,
890 exceptfds
?exceptfds
->fds_bits
[0]:0, *(T_sigset
*)sigmask
,
893 Debug6("pselect -> (, 0x%lx, 0x%lx, 0x%lx), %d",
894 readfds
?readfds
->__fds_bits
[0]:0, writefds
?writefds
->__fds_bits
[0]:0,
895 exceptfds
?exceptfds
->__fds_bits
[0]:0,
898 #endif /* WITH_SYCLS */
903 #endif /* HAVE_PSELECT */
913 Debug1("fork() -> %d", pid
); /* attention: called twice! */
918 #endif /* WITH_SYCLS */
920 pid_t
Waitpid(pid_t pid
, int *status
, int options
) {
923 if (!diag_in_handler
) diag_flush();
925 Debug3("waitpid("F_pid
", %p, %d)", pid
, status
, options
);
926 #endif /* WITH_SYCLS */
927 retval
= waitpid(pid
, status
, options
);
929 if (!diag_in_handler
) diag_flush();
931 Debug2("waitpid(, {%d}, ) -> "F_pid
, *status
, retval
);
932 #endif /* WITH_SYCLS */
939 sighandler_t
Signal(int signum
, sighandler_t handler
) {
942 Debug2("signal(%d, %p)", signum
, handler
);
943 retval
= signal(signum
, handler
);
945 Debug1("signal() -> %p", retval
);
951 int Sigaction(int signum
, const struct sigaction
*act
,
952 struct sigaction
*oldact
) {
954 Debug3("sigaction(%d, %p, %p)", signum
, act
, oldact
);
955 retval
= sigaction(signum
, act
, oldact
);
956 Debug1("sigaction() -> %d", retval
);
959 #endif /* HAVE_SIGACTION */
961 int Sigprocmask(int how
, const sigset_t
*set
, sigset_t
*oset
) {
964 Debug3("sigprocmask(%d, "F_sigset
", %p)", how
, *(T_sigset
*)set
, oset
);
966 Debug2("sigprocmask(%d, NULL, %p)", how
, oset
);
967 retval
= sigprocmask(how
, set
, oset
);
969 Debug2("sigprocmask() -> {,, "F_sigset
"} %d", *(T_sigset
*)oset
, retval
);
971 Debug1("sigprocmask() -> %d", retval
);
975 unsigned int Alarm(unsigned int seconds
) {
977 Debug1("alarm(%u)", seconds
);
978 retval
= alarm(seconds
);
979 Debug1("alarm() -> %u", retval
);
983 int Kill(pid_t pid
, int sig
) {
985 Debug2("kill("F_pid
", %d)", pid
, sig
);
986 retval
= kill(pid
, sig
);
988 Debug1("kill() -> %d", retval
);
993 int Link(const char *oldpath
, const char *newpath
) {
995 Debug2("link(\"%s\", \"%s\")", oldpath
, newpath
);
996 retval
= link(oldpath
, newpath
);
998 Debug1("link() -> %d", retval
);
1003 int Execvp(const char *file
, char *const argv
[]) {
1005 if (argv
[1] == NULL
)
1006 Debug2("execvp(\"%s\", \"%s\")", file
, argv
[0]);
1007 else if (argv
[2] == NULL
)
1008 Debug3("execvp(\"%s\", \"%s\" \"%s\")", file
, argv
[0], argv
[1]);
1009 else if (argv
[3] == NULL
)
1010 Debug4("execvp(\"%s\", \"%s\" \"%s\" \"%s\")", file
, argv
[0], argv
[1], argv
[2]);
1011 else if (argv
[4] == NULL
)
1012 Debug5("execvp(\"%s\", \"%s\" \"%s\" \"%s\" \"%s\")", file
, argv
[0], argv
[1], argv
[2], argv
[3]);
1013 else if (argv
[5] == NULL
)
1014 Debug6("execvp(\"%s\", \"%s\" \"%s\" \"%s\" \"%s\" \"%s\")", file
, argv
[0], argv
[1], argv
[2], argv
[3], argv
[4]);
1016 Debug6("execvp(\"%s\", \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" ...)", file
, argv
[0], argv
[1], argv
[2], argv
[3], argv
[4]);
1018 result
= execvp(file
, argv
);
1020 Debug1("execvp() -> %d", result
);
1025 #endif /* WITH_SYCLS */
1027 int System(const char *string
) {
1030 Debug1("system(\"%s\")", string
);
1031 #endif /* WITH_SYCLS */
1032 diag_immediate_exit
= 1;
1033 result
= system(string
);
1034 diag_immediate_exit
= 0;
1037 Debug1("system() -> %d", result
);
1039 #endif /* WITH_SYCLS */
1045 int Socketpair(int d
, int type
, int protocol
, int sv
[2]) {
1047 Debug4("socketpair(%d, %d, %d, %p)", d
, type
, protocol
, sv
);
1048 result
= socketpair(d
, type
, protocol
, sv
);
1050 Info6("socketpair(%d, %d, %d, {%d,%d}) -> %d", d
, type
, protocol
, sv
[0], sv
[1], result
);
1056 int Socket(int domain
, int type
, int protocol
) {
1058 Debug3("socket(%d, %d, %d)", domain
, type
, protocol
);
1059 result
= socket(domain
, type
, protocol
);
1061 Info4("socket(%d, %d, %d) -> %d", domain
, type
, protocol
, result
);
1065 #endif /* _WITH_SOCKET */
1068 int Bind(int sockfd
, struct sockaddr
*my_addr
, socklen_t addrlen
) {
1072 sockaddr_info(my_addr
, addrlen
, infobuff
, sizeof(infobuff
));
1073 Debug3("bind(%d, %s, "F_socklen
")", sockfd
, infobuff
, addrlen
);
1074 result
= bind(sockfd
, my_addr
, addrlen
);
1076 Debug1("bind() -> %d", result
);
1080 #endif /* _WITH_SOCKET */
1082 #endif /* WITH_SYCLS */
1085 int Connect(int sockfd
, const struct sockaddr
*serv_addr
, socklen_t addrlen
) {
1089 if (!diag_in_handler
) diag_flush();
1091 /*sockaddr_info(serv_addr, infobuff, sizeof(infobuff));
1092 Debug3("connect(%d, %s, "F_Zd")", sockfd, infobuff, addrlen);*/
1094 Debug18("connect(%d,{0x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x}, "F_Zd
")",
1096 ((unsigned char *)serv_addr
)[0], ((unsigned char *)serv_addr
)[1],
1097 ((unsigned char *)serv_addr
)[2], ((unsigned char *)serv_addr
)[3],
1098 ((unsigned char *)serv_addr
)[4], ((unsigned char *)serv_addr
)[5],
1099 ((unsigned char *)serv_addr
)[6], ((unsigned char *)serv_addr
)[7],
1100 ((unsigned char *)serv_addr
)[8], ((unsigned char *)serv_addr
)[9],
1101 ((unsigned char *)serv_addr
)[10], ((unsigned char *)serv_addr
)[11],
1102 ((unsigned char *)serv_addr
)[12], ((unsigned char *)serv_addr
)[13],
1103 ((unsigned char *)serv_addr
)[14], ((unsigned char *)serv_addr
)[15],
1106 Debug4("connect(%d, {%d,%s}, "F_socklen
")",
1107 sockfd
, serv_addr
->sa_family
,
1108 sockaddr_info(serv_addr
, addrlen
, infobuff
, sizeof(infobuff
)),
1111 #endif /* WITH_SYCLS */
1112 result
= connect(sockfd
, serv_addr
, addrlen
);
1114 if (!diag_in_handler
) diag_flush();
1116 Debug1("connect() -> %d", result
);
1117 #endif /* WITH_SYCLS */
1121 #endif /* _WITH_SOCKET */
1126 int Listen(int s
, int backlog
) {
1128 Debug2("listen(%d, %d)", s
, backlog
);
1129 result
= listen(s
, backlog
);
1131 Debug1("listen() -> %d", result
);
1135 #endif /* _WITH_SOCKET */
1137 #endif /* WITH_SYCLS */
1140 /* don't forget to handle EINTR when using Accept() ! */
1141 int Accept(int s
, struct sockaddr
*addr
, socklen_t
*addrlen
) {
1144 if (!diag_in_handler
) diag_flush();
1146 FD_SET(s
, &accept_s
);
1147 if (diag_select(s
+1, &accept_s
, NULL
, NULL
, NULL
) < 0) {
1151 Debug3("accept(%d, %p, %p)", s
, addr
, addrlen
);
1152 #endif /* WITH_SYCLS */
1153 result
= accept(s
, addr
, addrlen
);
1155 if (!diag_in_handler
) diag_flush();
1159 sockaddr_info(addr
, *addrlen
, infobuff
, sizeof(infobuff
));
1160 Info5("accept(%d, {%d, %s}, "F_socklen
") -> %d", s
,
1162 sockaddr_info(addr
, *addrlen
, infobuff
, sizeof(infobuff
)),
1165 Debug1("accept(,,) -> %d", result
);
1167 #endif /* WITH_SYCLS */
1171 #endif /* _WITH_SOCKET */
1176 int Getsockname(int s
, struct sockaddr
*name
, socklen_t
*namelen
) {
1180 Debug4("getsockname(%d, %p, %p{"F_socklen
"})", s
, name
, namelen
, *namelen
);
1181 result
= getsockname(s
, name
, namelen
);
1183 /*Debug2("getsockname(,, {"F_socklen"}) -> %d",
1184 *namelen, result);*/
1185 Debug3("getsockname(, {%s}, {"F_socklen
"}) -> %d",
1186 sockaddr_info(name
, *namelen
, infobuff
, sizeof(infobuff
)),
1191 #endif /* _WITH_SOCKET */
1194 int Getpeername(int s
, struct sockaddr
*name
, socklen_t
*namelen
) {
1198 Debug4("getpeername(%d, %p, %p{"F_socklen
"})", s
, name
, namelen
, *namelen
);
1199 result
= getpeername(s
, name
, namelen
);
1201 sockaddr_info(name
, *namelen
, infobuff
, sizeof(infobuff
));
1202 Debug3("getpeername(, {%s}, {"F_socklen
"}) -> %d",
1203 infobuff
, *namelen
, result
);
1207 #endif /* _WITH_SOCKET */
1210 int Getsockopt(int s
, int level
, int optname
, void *optval
, socklen_t
*optlen
) {
1212 Debug5("getsockopt(%d, %d, %d, %p, {"F_socklen
"})",
1213 s
, level
, optname
, optval
, *optlen
);
1214 result
= getsockopt(s
, level
, optname
, optval
, optlen
);
1216 Debug3("getsockopt() -> (,,, 0x%08x, %d), %d",
1217 *(int *)optval
, *optlen
, result
);
1221 #endif /* _WITH_SOCKET */
1224 int Setsockopt(int s
, int level
, int optname
, const void *optval
, int optlen
) {
1226 if (optlen
<= sizeof(int)) {
1227 Debug5("setsockopt(%d, %d, %d, {0x%x}, %d)",
1228 s
, level
, optname
, *(unsigned int *)optval
, optlen
);
1230 Debug6("setsockopt(%d, %d, %d, {0x%08x,%08x}, %d)",
1232 ((unsigned int *)optval
)[0], ((unsigned int *)optval
)[1],
1235 result
= setsockopt(s
, level
, optname
, optval
, optlen
);
1237 Debug1("setsockopt() -> %d", result
);
1241 #endif /* _WITH_SOCKET */
1243 #endif /* WITH_SYCLS */
1246 int Recv(int s
, void *buf
, size_t len
, int flags
) {
1248 if (!diag_in_handler
) diag_flush();
1250 Debug4("recv(%d, %p, "F_Zu
", %d)", s
, buf
, len
, flags
);
1251 #endif /* WITH_SYCLS */
1252 retval
= recv(s
, buf
, len
, flags
);
1254 if (!diag_in_handler
) diag_flush();
1256 Debug1("recv() -> %d", retval
);
1257 #endif /* WITH_SYCLS */
1261 #endif /* _WITH_SOCKET */
1264 int Recvfrom(int s
, void *buf
, size_t len
, int flags
, struct sockaddr
*from
,
1265 socklen_t
*fromlen
) {
1268 if (!diag_in_handler
) diag_flush();
1270 Debug6("recvfrom(%d, %p, "F_Zu
", %d, %p, "F_socklen
")",
1271 s
, buf
, len
, flags
, from
, *fromlen
);
1272 #endif /* WITH_SYCLS */
1273 retval
= recvfrom(s
, buf
, len
, flags
, from
, fromlen
);
1275 if (!diag_in_handler
) diag_flush();
1278 Debug4("recvfrom(,,,, {%d,%s}, "F_socklen
") -> %d",
1280 sockaddr_info(from
, *fromlen
, infobuff
, sizeof(infobuff
)),
1283 Debug1("recvfrom(,,,, NULL, NULL) -> %d", retval
);
1285 #endif /* WITH_SYCLS */
1289 #endif /* _WITH_SOCKET */
1292 int Recvmsg(int s
, struct msghdr
*msgh
, int flags
) {
1294 if (!diag_in_handler
) diag_flush();
1297 #if defined(HAVE_STRUCT_MSGHDR_MSGCONTROL) && defined(HAVE_STRUCT_MSGHDR_MSGCONTROLLEN) && defined(HAVE_STRUCT_MSGHDR_MSGFLAGS)
1298 Debug10("recvmsg(%d, %p{%p,%u,%p,"F_Zu
",%p,"F_Zu
",%d}, %d)", s
, msgh
,
1299 msgh
->msg_name
, msgh
->msg_namelen
, msgh
->msg_iov
, msgh
->msg_iovlen
,
1300 msgh
->msg_control
, msgh
->msg_controllen
, msgh
->msg_flags
, flags
);
1302 Debug7("recvmsg(%d, %p{%p,%u,%p,%u}, %d)", s
, msgh
,
1303 msgh
->msg_name
, msgh
->msg_namelen
, msgh
->msg_iov
, msgh
->msg_iovlen
,
1306 #endif /* WITH_SYCLS */
1307 retval
= recvmsg(s
, msgh
, flags
);
1309 if (!diag_in_handler
) diag_flush();
1311 #if defined(HAVE_STRUCT_MSGHDR_MSGCONTROLLEN)
1312 Debug5("recvmsg(, {%s,%u,,"F_Zu
",,"F_Zu
",}, ) -> %d",
1313 msgh
->msg_name
?sockaddr_info(msgh
->msg_name
, msgh
->msg_namelen
, infobuff
, sizeof(infobuff
)):"NULL",
1314 msgh
->msg_namelen
, msgh
->msg_iovlen
, msgh
->msg_controllen
,
1317 Debug4("recvmsg(, {%s,%u,,%u,,}, ) -> %d",
1318 msgh
->msg_name
?sockaddr_info(msgh
->msg_name
, msgh
->msg_namelen
, infobuff
, sizeof(infobuff
)):"NULL",
1319 msgh
->msg_namelen
, msgh
->msg_iovlen
,
1322 #endif /* WITH_SYCLS */
1326 #endif /* _WITH_SOCKET */
1329 int Send(int s
, const void *mesg
, size_t len
, int flags
) {
1331 if (!diag_in_handler
) diag_flush();
1333 Debug5("send(%d, %p[%08x...], "F_Zu
", %d)",
1334 s
, mesg
, ntohl(*(unsigned long *)mesg
), len
, flags
);
1335 #endif /* WITH_SYCLS */
1336 retval
= send(s
, mesg
, len
, flags
);
1338 if (!diag_in_handler
) diag_flush();
1340 Debug1("send() -> %d", retval
);
1341 #endif /* WITH_SYCLS */
1345 #endif /* _WITH_SOCKET */
1348 int Sendto(int s
, const void *mesg
, size_t len
, int flags
,
1349 const struct sockaddr
*to
, socklen_t tolen
) {
1353 if (!diag_in_handler
) diag_flush();
1355 sockaddr_info(to
, tolen
, infobuff
, sizeof(infobuff
));
1356 Debug7("sendto(%d, %p[%08x...], "F_Zu
", %d, {%s}, %d)",
1357 s
, mesg
, htonl(*(unsigned long *)mesg
), len
, flags
, infobuff
, tolen
);
1358 #endif /* WITH_SYCLS */
1359 retval
= sendto(s
, mesg
, len
, flags
, to
, tolen
);
1361 if (!diag_in_handler
) diag_flush();
1363 Debug1("sendto() -> %d", retval
);
1364 #endif /* WITH_SYCLS */
1368 #endif /* _WITH_SOCKET */
1373 int Shutdown(int fd
, int how
) {
1375 Info2("shutdown(%d, %d)", fd
, how
);
1376 retval
= shutdown(fd
, how
);
1378 Debug1("shutdown() -> %d", retval
);
1382 #endif /* _WITH_SOCKET */
1384 unsigned int Sleep(unsigned int seconds
) {
1385 unsigned int retval
;
1386 Debug1("sleep(%u)", seconds
);
1387 retval
= sleep(seconds
);
1388 Debug1("sleep() -> %u", retval
);
1393 unsigned int Nanosleep(const struct timespec
*req
, struct timespec
*rem
) {
1395 Debug3("nanosleep({"F_time
",%ld},%p)", req
->tv_sec
, req
->tv_nsec
, rem
);
1396 retval
= nanosleep(req
, rem
);
1399 Debug3("nanosleep(,{"F_time
",%ld}) -> %d",
1400 rem
->tv_sec
, rem
->tv_nsec
, retval
);
1402 Debug1("nanosleep() -> %d", retval
);
1407 #endif /* HAVE_NANOSLEEP */
1414 Debug1("pause() -> %d", retval
);
1419 #if ( _WITH_IP4 || _WITH_IP6 ) && HAVE_GETHOSTBYNAME
1420 struct hostent
*Gethostbyname(const char *name
) {
1421 struct hostent
*hent
;
1422 Debug1("gethostbyname(\"%s\")", name
);
1423 hent
= gethostbyname(name
);
1425 Debug("gethostbyname() -> NULL");
1427 Debug4("gethostbyname() -> %d.%d.%d.%d",
1428 ((unsigned char *)hent
->h_addr_list
[0])[0],
1429 ((unsigned char *)hent
->h_addr_list
[0])[1],
1430 ((unsigned char *)hent
->h_addr_list
[0])[2],
1431 ((unsigned char *)hent
->h_addr_list
[0])[3]);
1435 #endif /* ( _WITH_IP4 || _WITH_IP6 ) && HAVE_GETHOSTBYNAME */
1437 #if (_WITH_IP4 || _WITH_IP6) && HAVE_GETADDRINFO
1438 int Getaddrinfo(const char *node
, const char *service
,
1439 const struct addrinfo
*hints
, struct addrinfo
**res
) {
1441 Debug15("getaddrinfo(%s%s%s, %s%s%s, {%d,%d,%d,%d,"F_socklen
",%p,%p,%p}, %p)",
1442 node
?"\"":"", node
?node
:"NULL", node
?"\"":"",
1443 service
?"\"":"", service
?service
:"NULL", service
?"\"":"",
1444 hints
->ai_flags
, hints
->ai_family
, hints
->ai_socktype
,
1445 hints
->ai_protocol
, hints
->ai_addrlen
, hints
->ai_addr
,
1446 hints
->ai_canonname
, hints
->ai_next
, res
);
1447 result
= getaddrinfo(node
, service
, hints
, res
);
1450 sockaddr_info((*res
)->ai_addr
, hints
->ai_addrlen
, sockbuff
, sizeof(sockbuff
));
1451 Debug2("getaddrinfo(,,,{{%s, %s}) -> 0",
1453 (*res
)->ai_canonname
?(*res
)->ai_canonname
:"");
1455 Debug2("getaddrinfo(,,,{%p}) -> %d", *res
, result
);
1459 #endif /* (_WITH_IP4 || _WITH_IP6) && HAVE_GETADDRINFO */
1461 #if (WITH_IP4 || WITH_IP6) && HAVE_PROTOTYPE_LIB_getipnodebyname
1462 struct hostent
*Getipnodebyname(const char *name
, int af
, int flags
,
1464 struct hostent
*result
;
1465 Debug4("getipnodebyname(\"%s\", %d, %d, %p)", name
, af
, flags
, error_num
);
1466 result
= getipnodebyname(name
, af
, flags
, error_num
);
1467 if (result
== NULL
) {
1468 Debug1("getipnodebyname(,,, {%d}) -> NULL", *error_num
);
1470 Debug4("getipnodebyname() -> {\"%s\", %p, %d, %d, ???}",
1471 result
->h_name
, result
->h_aliases
, result
->h_addrtype
,
1476 #endif /* (WITH_IP4 || WITH_IP6) && HAVE_PROTOTYPE_LIB_getipnodebyname */
1478 void *Malloc(size_t size
) {
1480 Debug1("malloc("F_Zd
")", size
);
1481 result
= malloc(size
);
1482 Debug1("malloc() -> %p", result
);
1483 if (result
== NULL
) {
1484 Error1("malloc("F_Zd
"): out of memory", size
);
1490 void *Calloc(size_t nmemb
, size_t size
) {
1492 Debug2("calloc("F_Zd
", "F_Zd
")", nmemb
, size
);
1493 result
= calloc(nmemb
, size
);
1494 Debug1("calloc() -> %p", result
);
1495 if (result
== NULL
) {
1496 Error2("calloc("F_Zd
", "F_Zd
"): out of memory", nmemb
, size
);
1502 void *Realloc(void *ptr
, size_t size
) {
1504 Debug2("realloc(%p, "F_Zd
")", ptr
, size
);
1505 result
= realloc(ptr
, size
);
1506 Debug1("realloc() -> %p", result
);
1507 if (result
== NULL
) {
1508 Error2("realloc(%p, "F_Zd
"): out of memory", ptr
, size
);
1515 int Tcgetattr(int fd
, struct termios
*termios_p
) {
1516 int i
, result
, _errno
;
1517 char chars
[5*NCCS
], *cp
= chars
;
1519 Debug2("tcgetattr(%d, %p)", fd
, termios_p
);
1520 result
= tcgetattr(fd
, termios_p
);
1523 for (i
= 0; i
< NCCS
-1; ++i
) {
1524 cp
+= sprintf(cp
, "%02x,", termios_p
->c_cc
[i
]);
1526 sprintf(cp
, "%02x", termios_p
->c_cc
[i
]);
1527 #if HAVE_STRUCT_TERMIOS_C_ISPEED && HAVE_STRUCT_TERMIOS_C_OSPEED
1528 Debug8("tcgetattr(, {%08x,%08x,%08x,%08x, "F_speed
","F_speed
", %s}) -> %d",
1529 termios_p
->c_iflag
, termios_p
->c_oflag
,
1530 termios_p
->c_cflag
, termios_p
->c_lflag
,
1531 termios_p
->c_ispeed
, termios_p
->c_ospeed
,
1534 Debug6("tcgetattr(, {%08x,%08x,%08x,%08x,%s}) -> %d",
1535 termios_p
->c_iflag
, termios_p
->c_oflag
,
1536 termios_p
->c_cflag
, termios_p
->c_lflag
,
1542 #endif /* _WITH_TERMIOS */
1545 int Tcsetattr(int fd
, int optional_actions
, struct termios
*termios_p
) {
1546 int i
, result
, _errno
;
1547 char chars
[5*NCCS
], *cp
= chars
;
1549 for (i
= 0; i
< NCCS
-1; ++i
) {
1550 cp
+= sprintf(cp
, "%02x,", termios_p
->c_cc
[i
]);
1552 sprintf(cp
, "%02x", termios_p
->c_cc
[i
]);
1553 #if HAVE_STRUCT_TERMIOS_C_ISPEED && HAVE_STRUCT_TERMIOS_C_OSPEED
1554 Debug9("tcsetattr(%d, %d, {%08x,%08x,%08x,%08x, "F_speed
","F_speed
", %s})",
1555 fd
, optional_actions
,
1556 termios_p
->c_iflag
, termios_p
->c_oflag
,
1557 termios_p
->c_cflag
, termios_p
->c_lflag
,
1558 termios_p
->c_ispeed
, termios_p
->c_ospeed
,
1561 Debug7("tcsetattr(%d, %d, {%08x,%08x,%08x,%08x,%s})", fd
, optional_actions
,
1562 termios_p
->c_iflag
, termios_p
->c_oflag
,
1563 termios_p
->c_cflag
, termios_p
->c_lflag
, chars
);
1565 result
= tcsetattr(fd
, optional_actions
, termios_p
);
1567 Debug1("tcsetattr() -> %d", result
);
1571 #endif /* _WITH_TERMIOS */
1573 char *Ttyname(int fd
) {
1576 Debug1("ttyname(%d)", fd
);
1577 result
= ttyname(fd
);
1580 Debug1("ttyname() -> %s", result
);
1582 Debug("ttyname() -> NULL");
1587 int Isatty(int fd
) {
1589 Debug1("isatty(%d)", fd
);
1590 result
= isatty(fd
);
1592 Debug1("isatty() -> %d", result
);
1598 int Openpty(int *ptyfd
, int *ttyfd
, char *ptyname
, struct termios
*termp
,
1599 struct winsize
*winp
) {
1601 Debug5("openpty(%p, %p, %p, %p, %p)", ptyfd
, ttyfd
, ptyname
, termp
, winp
);
1602 result
= openpty(ptyfd
, ttyfd
, ptyname
, termp
, winp
);
1604 Info4("openpty({%d}, {%d}, {\"%s\"},,) -> %d", *ptyfd
, *ttyfd
, ptyname
,
1609 #endif /* HAVE_OPENPTY */
1612 int Grantpt(int fd
) {
1614 Debug1("grantpt(%d)", fd
);
1615 result
= grantpt(fd
);
1617 Debug1("grantpt() -> %d", result
);
1621 #endif /* HAVE_GRANTPT */
1624 int Unlockpt(int fd
) {
1626 Debug1("unlockpt(%d)", fd
);
1627 result
= unlockpt(fd
);
1629 Debug1("unlockpt() -> %d", result
);
1633 #endif /* HAVE_UNLOCKPT */
1635 #if HAVE_PROTOTYPE_LIB_ptsname /* AIX, not Linux */
1636 char *Ptsname(int fd
) {
1639 Debug1("ptsname(%d)", fd
);
1640 result
= ptsname(fd
);
1643 Debug1("ptsname() -> %s", result
);
1645 Debug("ptsname() -> NULL");
1649 #endif /* HAVE_PROTOTYPE_LIB_ptsname */
1651 int Uname(struct utsname
*buf
) {
1653 Debug1("uname(%p)", buf
);
1654 result
= uname(buf
);
1656 #if UNAME_DOMAINNAME
1657 Debug6("uname({%s, %s, %s, %s, %s, %s})",
1658 buf
->sysname
, buf
->nodename
, buf
->release
,
1659 buf
->version
, buf
->machine
, buf
->domainname
);
1661 Debug5("uname({%s, %s, %s, %s, %s})",
1662 buf
->sysname
, buf
->nodename
, buf
->release
,
1663 buf
->version
, buf
->machine
);
1669 int Gethostname(char *name
, size_t len
) {
1671 Debug2("gethostname(%p, "F_Zu
")", name
, len
);
1672 result
= gethostname(name
, len
);
1674 Debug2("gethostname(\"%s\", ) -> %d", name
, result
);
1679 /* due to Linux docu, it does not set errno */
1680 int Atexit(void (*func
)(void)) {
1682 Debug1("atexit(%p)", func
);
1683 result
= atexit(func
);
1684 Debug1("atexit() -> %d", result
);
1688 #endif /* WITH_SYCLS */
1690 void Exit(int status
) {
1691 if (!diag_in_handler
) diag_flush();
1693 Debug1("exit(%d)", status
);
1694 #endif /* WITH_SYCLS */
1705 int Mkstemp(char *template) {
1707 Debug1("mkstemp(\"%s\")", template);
1708 result
= mkstemp(template);
1710 Info2("mkstemp({%s}) -> %d", template, result
);
1715 int Setenv(const char *name
, const char *value
, int overwrite
) {
1717 Debug3("setenv(\"%s\", \"%s\", %d)", name
, value
, overwrite
);
1718 result
= setenv(name
, value
, overwrite
);
1720 Debug1("setenv() -> %d", result
);
1726 /* on Linux it returns int but on FreeBSD void.
1727 we do not expect many errors, so we take void which works on all systems. */
1728 void Unsetenv(const char *name
) {
1730 Debug1("unsetenv(\"%s\")", name
);
1733 Debug("unsetenv() ->");
1741 char *Readline(const char *prompt
) {
1745 Debug1("readline(\"%s\")", prompt
);
1747 Debug("readline(NULL)");
1749 result
= readline(prompt
);
1751 Debug("readline() -> \"...\"");
1753 Debug("readline() -> NULL");
1758 void Using_history(void) {
1759 Debug("using_history()");
1761 Debug("using_history() ->");
1764 int Read_history(const char *filename
) {
1768 Debug1("read_history(\"%s\")", filename
);
1770 Debug("read_history(NULL)");
1772 result
= read_history(filename
);
1774 Debug1("read_history() -> %d", result
);
1776 Debug("read_history() -> 0");
1781 int Write_history(const char *filename
) {
1785 Debug1("write_history(\"%s\")", filename
);
1787 Debug("write_history(NULL)");
1789 result
= write_history(filename
);
1791 Debug1("write_history() -> %d", result
);
1793 Debug("write_history() -> 0");
1798 int Append_history(int nelements
, const char *filename
) {
1802 Debug2("append_history(%d, \"%s\")", nelements
, filename
);
1804 Debug1("append_history(%d, NULL)", nelements
);
1806 result
= append_history(nelements
, filename
);
1808 Debug1("append_history() -> %d", result
);
1810 Debug("append_history() -> 0");
1815 int Where_history(void) {
1818 Debug("where_history()");
1819 result
= where_history();
1820 Debug1("where_history() -> %d", result
);
1824 void Add_history(const char *string
) {
1825 Debug1("add_history(\"%s\")", string
);
1826 add_history(string
);
1827 Debug("add_history() ->");
1830 #endif /* WITH_READLINE */
1832 #endif /* WITH_SYCLS */