00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <stdio.h>
00026 #include <errno.h>
00027
00028 #include <sys/param.h>
00029
00030
00031 #if defined(__hpux) && !defined(hpux)
00032 # define hpux
00033 #endif
00034
00035 #if defined(__bsdi__) || defined(__386BSD__) || defined(_CX_UX) || defined(hpux) || defined(_IBMR2) || defined(linux)
00036 # include <signal.h>
00037 #endif
00038
00039 #ifdef ISC
00040 # ifdef ENAMETOOLONG
00041 # undef ENAMETOOLONG
00042 # endif
00043 # ifdef ENOTEMPTY
00044 # undef ENOTEMPTY
00045 # endif
00046 # include <sys/bsdtypes.h>
00047 # include <net/errno.h>
00048 #endif
00049
00050 #ifdef sun
00051 # define getpgrp __getpgrp
00052 # define exit __exit
00053 #endif
00054 #ifdef POSIX
00055 # include <unistd.h>
00056 # if defined(__STDC__)
00057 # include <stdlib.h>
00058 # endif
00059 #endif
00060 #ifdef sun
00061 # undef getpgrp
00062 # undef exit
00063 #endif
00064
00065 #ifndef linux
00066 extern int errno;
00067 #endif
00068 #ifndef HAVE_STRERROR
00069
00070 #undef strerror
00071 #endif
00072
00073 #if !defined(SYSV) && !defined(linux)
00074 # ifdef NEWSOS
00075 # define strlen ___strlen___
00076 # include <strings.h>
00077 # undef strlen
00078 # else
00079 # include <strings.h>
00080 # endif
00081 #else
00082 # if defined(SVR4) || defined(NEWSOS)
00083 # define strlen ___strlen___
00084 # include <string.h>
00085 # undef strlen
00086 # if !defined(NEWSOS) && !defined(__hpux)
00087 extern size_t strlen(const char *);
00088 # endif
00089 # else
00090 # include <string.h>
00091 # endif
00092 #endif
00093
00094 #ifdef USEVARARGS
00095 # if defined(__STDC__)
00096 # include <stdarg.h>
00097 # define VA_LIST(var) va_list var;
00098 # define VA_DOTS ...
00099 # define VA_DECL
00100 # define VA_START(ap, fmt) va_start(ap, fmt)
00101 # define VA_ARGS(ap) ap
00102 # define VA_END(ap) va_end(ap)
00103 # else
00104 # include <varargs.h>
00105 # define VA_LIST(var) va_list var;
00106 # define VA_DOTS va_alist
00107 # define VA_DECL va_dcl
00108 # define VA_START(ap, fmt) va_start(ap)
00109 # define VA_ARGS(ap) ap
00110 # define VA_END(ap) va_end(ap)
00111 # endif
00112 #else
00113 # define VA_LIST(var)
00114 # define VA_DOTS p1, p2, p3, p4, p5, p6
00115 # define VA_DECL unsigned long VA_DOTS;
00116 # define VA_START(ap, fmt)
00117 # define VA_ARGS(ap) VA_DOTS
00118 # define VA_END(ap)
00119 # undef vsnprintf
00120 # define vsnprintf xsnprintf
00121 #endif
00122
00123 #if !defined(sun) && !defined(B43) && !defined(ISC) && !defined(pyr) && !defined(_CX_UX)
00124 # include <time.h>
00125 #endif
00126 #include <sys/time.h>
00127
00128 #ifdef M_UNIX
00129 # include <sys/stream.h>
00130 # include <sys/ptem.h>
00131 # define ftruncate(fd, s) chsize(fd, s)
00132 #endif
00133
00134 #ifdef SYSV
00135 # define index strchr
00136 # define rindex strrchr
00137 # define bzero(poi,len) memset(poi,0,len)
00138 # define bcmp memcmp
00139 # define killpg(pgrp,sig) kill( -(pgrp), sig)
00140 #endif
00141
00142 #ifndef HAVE_GETCWD
00143 # define getcwd(b,l) getwd(b)
00144 #endif
00145
00146 #ifndef USEBCOPY
00147 # ifdef USEMEMMOVE
00148 # define bcopy(s,d,len) memmove(d,s,len)
00149 # else
00150 # ifdef USEMEMCPY
00151 # define bcopy(s,d,len) memcpy(d,s,len)
00152 # else
00153 # define NEED_OWN_BCOPY
00154 # define bcopy xbcopy
00155 # endif
00156 # endif
00157 #endif
00158
00159 #ifdef hpux
00160 # define setreuid(ruid, euid) setresuid(ruid, euid, -1)
00161 # define setregid(rgid, egid) setresgid(rgid, egid, -1)
00162 #endif
00163
00164 #if defined(HAVE_SETEUID) || defined(HAVE_SETREUID)
00165 # define USE_SETEUID
00166 #endif
00167
00168 #if !defined(HAVE__EXIT) && !defined(_exit)
00169 #define _exit(x) exit(x)
00170 #endif
00171
00172 #ifndef HAVE_UTIMES
00173 # define utimes utime
00174 #endif
00175 #ifndef HAVE_VSNPRINTF
00176 # define vsnprintf xvsnprintf
00177 #endif
00178
00179 #ifdef BUILTIN_TELNET
00180 # include <netinet/in.h>
00181 # include <arpa/inet.h>
00182 #endif
00183
00184 #if defined(USE_LOCALE) && (!defined(HAVE_SETLOCALE) || !defined(HAVE_STRFTIME))
00185 # undef USE_LOCALE
00186 #endif
00187
00188
00189
00190
00191
00192 #ifdef POSIX
00193 # include <termios.h>
00194 # ifdef hpux
00195 # include <bsdtty.h>
00196 # endif
00197 # ifdef NCCS
00198 # define MAXCC NCCS
00199 # else
00200 # define MAXCC 256
00201 # endif
00202 #else
00203 # ifdef TERMIO
00204 # include <termio.h>
00205 # ifdef NCC
00206 # define MAXCC NCC
00207 # else
00208 # define MAXCC 256
00209 # endif
00210 # ifdef CYTERMIO
00211 # include <cytermio.h>
00212 # endif
00213 # else
00214 # include <sgtty.h>
00215 # endif
00216 #endif
00217
00218 #ifndef VDISABLE
00219 # ifdef _POSIX_VDISABLE
00220 # define VDISABLE _POSIX_VDISABLE
00221 # else
00222 # define VDISABLE 0377
00223 # endif
00224 #endif
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 #if defined(sgi) || defined(DGUX) || defined(_IBMR2)
00239 # undef TIOCPKT
00240 #endif
00241
00242
00243 #if defined(linux) && defined(TERMINFO)
00244 # define tputs xtputs
00245 #endif
00246
00247
00248 #ifdef __osf__
00249 # undef HAVE_SVR4_PTYS
00250 #endif
00251
00252
00253
00254
00255
00256 #ifdef GETUTENT
00257 typedef char *slot_t;
00258 #else
00259 typedef int slot_t;
00260 #endif
00261
00262 #if defined(UTMPOK) || defined(BUGGYGETLOGIN)
00263 # if defined(SVR4) && !defined(DGUX) && !defined(__hpux) && !defined(linux)
00264 # include <utmpx.h>
00265 # define UTMPFILE UTMPX_FILE
00266 # define utmp utmpx
00267 # define getutent getutxent
00268 # define getutid getutxid
00269 # define getutline getutxline
00270 # define pututline pututxline
00271 # define setutent setutxent
00272 # define endutent endutxent
00273 # define ut_time ut_xtime
00274 # else
00275 # include <utmp.h>
00276 # endif
00277 # ifdef apollo
00278
00279
00280
00281
00282
00283
00284 # define UTNOKEEP
00285 # endif
00286
00287 # ifndef UTMPFILE
00288 # ifdef UTMP_FILE
00289 # define UTMPFILE UTMP_FILE
00290 # else
00291 # ifdef _PATH_UTMP
00292 # define UTMPFILE _PATH_UTMP
00293 # else
00294 # define UTMPFILE "/etc/utmp"
00295 # endif
00296 # endif
00297 # endif
00298
00299 #endif
00300
00301 #if !defined(UTMPOK) && defined(USRLIMIT)
00302 # undef USRLIMIT
00303 #endif
00304
00305 #ifdef LOGOUTOK
00306 # ifndef LOGINDEFAULT
00307 # define LOGINDEFAULT 0
00308 # endif
00309 #else
00310 # ifdef LOGINDEFAULT
00311 # undef LOGINDEFAULT
00312 # endif
00313 # define LOGINDEFAULT 1
00314 #endif
00315
00316
00317
00318
00319
00320
00321 #ifndef F_OK
00322 #define F_OK 0
00323 #endif
00324 #ifndef X_OK
00325 #define X_OK 1
00326 #endif
00327 #ifndef W_OK
00328 #define W_OK 2
00329 #endif
00330 #ifndef R_OK
00331 #define R_OK 4
00332 #endif
00333
00334 #ifndef S_IFIFO
00335 #define S_IFIFO 0010000
00336 #endif
00337 #ifndef S_IREAD
00338 #define S_IREAD 0000400
00339 #endif
00340 #ifndef S_IWRITE
00341 #define S_IWRITE 0000200
00342 #endif
00343 #ifndef S_IEXEC
00344 #define S_IEXEC 0000100
00345 #endif
00346
00347 #if defined(S_IFIFO) && defined(S_IFMT) && !defined(S_ISFIFO)
00348 #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
00349 #endif
00350 #if defined(S_IFSOCK) && defined(S_IFMT) && !defined(S_ISSOCK)
00351 #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
00352 #endif
00353 #if defined(S_IFCHR) && defined(S_IFMT) && !defined(S_ISCHR)
00354 #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
00355 #endif
00356 #if defined(S_IFDIR) && defined(S_IFMT) && !defined(S_ISDIR)
00357 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
00358 #endif
00359 #if defined(S_IFLNK) && defined(S_IFMT) && !defined(S_ISLNK)
00360 #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
00361 #endif
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374 #if defined(sun) && !defined(SVR4)
00375 # undef O_NONBLOCK
00376 #endif
00377
00378 #if !defined(O_NONBLOCK) && defined(O_NDELAY)
00379 # define O_NONBLOCK O_NDELAY
00380 #endif
00381
00382 #if !defined(FNBLOCK) && defined(FNONBLOCK)
00383 # define FNBLOCK FNONBLOCK
00384 #endif
00385 #if !defined(FNBLOCK) && defined(FNDELAY)
00386 # define FNBLOCK FNDELAY
00387 #endif
00388 #if !defined(FNBLOCK) && defined(O_NONBLOCK)
00389 # define FNBLOCK O_NONBLOCK
00390 #endif
00391
00392 #ifndef POSIX
00393 #undef mkfifo
00394 #define mkfifo(n,m) mknod(n,S_IFIFO|(m),0)
00395 #endif
00396
00397 #if !defined(HAVE_LSTAT) && !defined(lstat)
00398 # define lstat stat
00399 #endif
00400
00401
00402
00403
00404
00405 #ifdef SIGVOID
00406 # define SIGRETURN
00407 # define sigret_t void
00408 #else
00409 # define SIGRETURN return 0;
00410 # define sigret_t int
00411 #endif
00412
00413
00414 #if defined(SVR4) || (defined(SYSV) && defined(ISC)) || defined(_AIX) || defined(linux) || defined(ultrix) || defined(__386BSD__) || defined(__bsdi__) || defined(POSIX) || defined(NeXT)
00415 # define SIGHASARG
00416 #endif
00417
00418 #ifdef SIGHASARG
00419 # define SIGPROTOARG (int)
00420 # define SIGDEFARG (sigsig) int sigsig;
00421 # define SIGARG 0
00422 #else
00423 # define SIGPROTOARG (void)
00424 # define SIGDEFARG ()
00425 # define SIGARG
00426 #endif
00427
00428 #ifndef SIGCHLD
00429 #define SIGCHLD SIGCLD
00430 #endif
00431
00432 #if defined(POSIX) || defined(hpux)
00433 # define signal xsignal
00434 #else
00435 # ifdef USESIGSET
00436 # define signal sigset
00437 # endif
00438 #endif
00439
00440
00441 #ifndef NSIG
00442 # define NSIG 32
00443 #endif
00444
00445
00446
00447
00448
00449
00450 #if (!defined(sysV68) && !defined(M_XENIX)) || defined(NeXT) || defined(M_UNIX)
00451 # include <sys/wait.h>
00452 #endif
00453
00454 #ifndef WTERMSIG
00455 # ifndef BSDWAIT
00456 # define WTERMSIG(status) (status & 0177)
00457 # else
00458 # define WTERMSIG(status) status.w_T.w_Termsig
00459 # endif
00460 #endif
00461
00462 #ifndef WSTOPSIG
00463 # ifndef BSDWAIT
00464 # define WSTOPSIG(status) ((status >> 8) & 0377)
00465 # else
00466 # define WSTOPSIG(status) status.w_S.w_Stopsig
00467 # endif
00468 #endif
00469
00470
00471 #if defined(WCOREDUMP) && !defined(WIFCORESIG)
00472 # define WIFCORESIG(status) WCOREDUMP(status)
00473 #endif
00474
00475 #ifndef WIFCORESIG
00476 # ifndef BSDWAIT
00477 # define WIFCORESIG(status) (status & 0200)
00478 # else
00479 # define WIFCORESIG(status) status.w_T.w_Coredump
00480 # endif
00481 #endif
00482
00483 #ifndef WEXITSTATUS
00484 # ifndef BSDWAIT
00485 # define WEXITSTATUS(status) ((status >> 8) & 0377)
00486 # else
00487 # define WEXITSTATUS(status) status.w_T.w_Retcode
00488 # endif
00489 #endif
00490
00491
00492
00493
00494
00495
00496 #if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_)
00497 #include <sys/select.h>
00498 #endif
00499
00500
00501
00502
00503
00504 #ifndef FD_SET
00505 # ifndef SUNOS3
00506 typedef struct fd_set { int fds_bits[1]; } fd_set;
00507 # endif
00508 # define FD_ZERO(fd) ((fd)->fds_bits[0] = 0)
00509 # define FD_SET(b, fd) ((fd)->fds_bits[0] |= 1 << (b))
00510 # define FD_ISSET(b, fd) ((fd)->fds_bits[0] & 1 << (b))
00511 # define FD_SETSIZE 32
00512 #endif
00513
00514
00515
00516
00517
00518
00519 #ifndef TERMCAP_BUFSIZE
00520 # define TERMCAP_BUFSIZE 2048
00521 #endif
00522
00523 #ifndef MAXPATHLEN
00524 # define MAXPATHLEN 1024
00525 #endif
00526
00527
00528
00529
00530
00531
00532 #define IOSIZE 4096
00533