1/*************************************************************************** 2 * LPRng - An Extended Print Spooler System 3 * 4 * Copyright 1988-2003, Patrick Powell, San Diego, CA 5 * papowell@lprng.com 6 * See LICENSE for conditions of use. 7 * $Id: portable.h,v 1.1.1.1 2008/10/15 03:28:27 james26_jang Exp $ 8 ***************************************************************************/ 9 10#ifndef _PLP_PORTABLE_H 11#define _PLP_PORTABLE_H 1 12 13/*************************************************************************** 14 * MODULE: portable.h 15 * PURPOSE: 16 * The configure program generates config.h, which defines various 17 * macros indicating the presence or abscence of include files, etc. 18 * However, there are some systems which pass the tests, but things 19 * do not work correctly on them. This file will try and fix 20 * these things up for the user. 21 * 22 * NOTE: if there were no problems, this file would be: 23 * #include "config.h" 24 * 25 * Sigh. Patrick Powell Thu Apr 6 07:00:48 PDT 1995 <papowell@sdsu.edu> 26 * NOTE: thanks to all the folks who worked on the PLP software, 27 * Justin Mason <jmason@iona.ie> especially. Some of the things 28 * that you have to do to get portability are truely bizzare. 29 * 30 * portable.h,v 3.14 1998/03/24 02:43:22 papowell Exp 31 **************************************************************************/ 32 33#if !defined(EXTERN) 34#define EXTERN extern 35#define DEFINE(X) 36#undef DEFS 37#endif 38 39#ifndef __STDC__ 40LPRng requires ANSI Standard C compiler 41#endif 42 43#include "config.h" 44 45#ifdef HAVE_CTYPE_H 46#include <ctype.h> 47#endif 48 49/************************************************************************* 50 * ARGH: some things that "configure" can't get right. 51*************************************************************************/ 52 53/*************************************************************************** 54 * porting note: if you port PLP and you get some errors 55 * caused by autoconf guessing the wrong set of functions/headers/structs, 56 * add or change the entry for your system in the ARGH section below. 57 * You might want to try and determine how your system is identified 58 * by the C preprocessor and use this informaton rather than trying 59 * to look for information in various f1les. 60 * Patrick Powell and Justin Mason 61 ***************************************************************************/ 62 63/************************************************************************* 64 * APOLLO Ports 65 * Thu Apr 6 07:01:51 PDT 1995 Patrick Powell 66 * This appears to be historical. 67 *************************************************************************/ 68#ifdef apollo 69# define IS_APOLLO OSVERSION 70/* #undef __STDC__ */ 71/* # define CONFLICTING_PROTOS */ 72#endif 73 74/************************************************************************* 75 * ULTRIX. 76 * Patrick Powell Thu Apr 6 07:17:34 PDT 1995 77 * 78 * Take a chance on using the standard calls 79 *************************************************************************/ 80#ifdef ultrix 81# define IS_ULTRIX OSVERSION 82#endif 83 84 85/************************************************************************* 86 * AIX. 87 *************************************************************************/ 88#ifdef _AIX32 89# define IS_AIX32 OSVERSION 90#endif 91 92/************************************************************************* 93 * Sun 94 *************************************************************************/ 95 96#if defined(sun) 97#endif 98 99/************************************************************************* 100 * SCO OpenServer 5.0.5 101 *************************************************************************/ 102/* normal include files do not define MAXPATHLEN - rather PATHSIZE in 103 sys/param.h */ 104#ifdef sco 105#ifndef MAXPATHLEN 106#define MAXPATHLEN PATHSIZE 107#endif 108/* SCO doesn't define the S_ISSOCK POSIX macro to use in testing the 109 stat.st_mode structure member - it appears as though a socket has 110 st_mode = 0020000 (same as character special) */ 111#ifndef S_ISSOCK 112#define S_IFSOCK 0020000 113#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 114#endif 115#endif 116 117/************************************************************************* 118 * Cray 119 *************************************************************************/ 120 121#if defined(cray) 122#define MAXPATHLEN 1023 123#define HAVE_SIGLONGJMP 1 124 125/* configure incorrectly chooses STATVFS */ 126#if defined(USE_STATFS_TYPE) 127#undef USE_STATFS_TYPE 128#endif 129 130#define USE_STATFS_TYPE SRV3_STATFS 131#endif 132 133 134/*************************************************************************/ 135#if defined(NeXT) 136# define IS_NEXT OSVERSION 137# define __STRICT_BSD__ 138#endif 139 140/*************************************************************************/ 141#if defined(__sgi) && defined(_SYSTYPE_SVR4) 142# define IS_IRIX5 OSVERSION 143#endif 144 145/*************************************************************************/ 146#if defined(__sgi) && defined(_SYSTYPE_SYSV) 147#define IS_IRIX4 OSVERSION 148#endif 149 150/*************************************************************************/ 151#if defined(__linux__) || defined (__linux) || defined (LINUX) 152# define IS_LINUX OSVERSION 153#endif 154 155/*************************************************************************/ 156 157#if defined(__convex__) /* Convex OS 11.0 - from w_stef */ 158# define IS_CONVEX OSVERSION 159# define LPASS8 (L004000>>16) 160#endif 161 162/*************************************************************************/ 163 164#ifdef _AUX_SOURCE 165# define IS_AUX OSVERSION 166# define _POSIX_SOURCE 167 168# undef SETPROCTITLE 169 170#endif 171 172/*************************************************************************/ 173 174#if defined(SNI) && defined(sinix) 175# define IS_SINIX OSVERSION 176#endif 177 178 179/*************************************************************************/ 180#if defined(__svr4__) && !defined(SVR4) 181# define SVR4 __svr4__ 182#endif 183 184/*************************************************************************** 185 * Solaris SUNWorks CC compiler 186 * man page indicates __SVR4 is defined, as is __unix, __sun 187 ***************************************************************************/ 188#if (defined(__SVR4) || defined(_SVR4_)) && !defined(SVR4) 189# define SVR4 1 190#endif 191 192/*************************************************************************/ 193#if defined(__bsdi__) 194# define IS_BSDI OSVERSION 195#endif 196 197/*************************************************************************/ 198 199/************************************************************************* 200 * we also need some way of spotting IS_DATAGEN (Data Generals), 201 * and IS_SEQUENT (Sequent machines). Any suggestions? 202 * these ports probably don't work anymore... 203 *************************************************************************/ 204 205/************************************************************************* 206 * END OF ARGH SECTION; next: overrides from the Makefile. 207 *************************************************************************/ 208/************************* 209 * STTY functions to use * 210 *************************/ 211#define SGTTYB 0 212#define TERMIO 1 213#define TERMIOS 2 214 215/************************* 216 * FSTYPE functions to use * 217 *************************/ 218 219#define SVR3_STATFS 0 220#define ULTRIX_STATFS 1 221#define STATFS 2 222#define STATVFS 3 223 224#if defined(MAKE_USE_STATFS) 225# undef USE_STATFS 226# define USE_STATFS MAKE_USE_STATFS 227#endif 228 229#if defined(MAKE_USE_STTY) 230# undef USE_STTY 231# define USE_STTY MAKE_USE_STTY 232#endif 233 234 235/********************************************************************* 236 * GET STANDARD INCLUDE FILES 237 * This is the one-size-fits-all include that should grab everthing. 238 * This has a horrible impact on compilation speed, but then, do you 239 * want compilation speed or portability? 240 * 241 * Patrick Powell Thu Apr 6 07:21:10 PDT 1995 242 ********************************************************************* 243 * If you do not have the following, you are doomed. Or at least 244 * going to have an uphill hard time. 245 * NOTE: string.h might also be strings.h on some very very odd systems 246 * 247 * Patrick Powell Thu Apr 6 07:21:10 PDT 1995 248 *********************************************************************/ 249 250/********************************************************************* 251 * yuck -- this is a nightmare! half-baked-ANSI systems are poxy (jm) 252 * 253 * Note that configure checks for absolute compliance, i.e.- 254 * older versions of SUNOS, HP-UX, do not meet this. 255 * 256 * Patrick Powell Thu Apr 6 07:21:10 PDT 1995 257 *********************************************************************/ 258 259 260#ifdef HAVE_UNISTD_H 261# include <unistd.h> 262#else 263 extern int dup2 (); 264 extern int execve (); 265 extern uid_t geteuid (), getegid (); 266 extern int setgid (), getgid (); 267#endif 268 269 270#ifdef HAVE_STDLIB_H 271# include <stdlib.h> 272#else 273 char *getenv( char * ); 274 void abort(void); 275#endif 276 277#include <sys/types.h> 278#include <stdio.h> 279#include <string.h> 280#if defined(HAVE_STRINGS_H) 281# include <strings.h> 282#endif 283#include <sys/param.h> 284#include <sys/socket.h> 285#include <netinet/in.h> 286#include <netdb.h> 287#include <arpa/inet.h> 288#include <sys/un.h> 289 290#include <sys/stat.h> 291#include <pwd.h> 292#if defined(HAVE_SYS_SIGNAL_H) 293# include <sys/signal.h> 294#endif 295#include <signal.h> 296#include <sys/wait.h> 297#include <ctype.h> 298 299#include <errno.h> 300#include <grp.h> 301 302#ifdef HAVE_MEMORY_H 303#include <memory.h> 304#endif 305 306#ifndef HAVE_STRCHR 307# define strchr index 308# define strrchr rindex 309#endif 310 311/* case insensitive compare for OS without it */ 312#if !defined(HAVE_STRCASECMP) 313 int strcasecmp (const char *s1, const char *s2); 314#endif 315#if !defined(HAVE_STRNCASECMP) 316 int strncasecmp (const char *s1, const char *s2, int len ); 317#endif 318#if !defined(HAVE_STRCASECMP_DEF) 319 int strcasecmp (const char *s1, const char *s2 ); 320#endif 321 322 323/********************************************************************* 324 * directory management is nasty. There are two standards: 325 * struct directory and struct dirent. 326 * Solution: macros + a typedef. 327 * Patrick Powell Thu Apr 6 07:44:50 PDT 1995 328 * 329 *See GNU autoconf documentation for this little AHEM gem... and others 330 * too obnoxious to believe 331 *********************************************************************/ 332 333#if HAVE_DIRENT_H 334# include <dirent.h> 335# define NLENGTH(dirent) strlen((dirent)->d_name) 336#else 337# define dirent direct 338# define NLENGTH(dirent) (dirent)->d_namlen 339# if HAVE_SYS_NDIR_H 340# include <sys/ndir.h> 341# endif 342# if HAVE_SYS_DIR_H 343# include <sys/dir.h> 344# endif 345# if HAVE_NDIR_H 346# include <ndir.h> 347# endif 348#endif 349 350typedef struct dirent plp_dir_t; 351 352/********************************************************************* 353 * malloc strikes again. Definition is a la ANSI C. However, 354 * You may need to edit this on historical systems. 355 * Patrick Powell Thu Apr 6 07:47:54 PDT 1995 356 *********************************************************************/ 357 358#if !defined(HAVE_STDLIB_H) 359# ifdef HAVE_MALLOC_H 360# include <malloc.h> 361# else 362 void *malloc(size_t); 363 void free(void *); 364# endif 365#endif 366 367#ifndef HAVE_ERRNO_DECL 368 extern int errno; 369#endif 370 371/********************************************************************* 372 * Note the <time.h> may already be included by some previous 373 * lines. You may need to edit this by hand. 374 * Better solution is to put include guards in all of the include files. 375 * Patrick Powell Thu Apr 6 07:55:58 PDT 1995 376 *********************************************************************/ 377 378#ifdef TIME_WITH_SYS_TIME 379# include <sys/time.h> 380# include <time.h> 381#else 382# ifdef HAVE_SYS_TIME_H 383# include <sys/time.h> 384# else 385# include <time.h> 386# endif 387#endif 388 389#ifdef HAVE_SYS_FILE_H 390# include <sys/file.h> 391#endif 392 393#ifdef HAVE_SYS_RESOURCE_H 394# include <sys/resource.h> 395#endif 396 397#ifdef HAVE_SYS_FCNTL_H 398# include <sys/fcntl.h> 399#endif 400#ifdef HAVE_FCNTL_H 401# include <fcntl.h> 402#endif 403 404/* 405 * we use the FCNTL code if we have it 406 * We want you to define F_SETLK, etc. If they are not defined, 407 * Then you better put a system dependent configuration 408 * in and define them. 409 */ 410#if defined(HAVE_FCNTL) && ! defined(F_SETLK) 411/*ABORT: "defined(HAVE_FCNTL) && ! defined(F_SETLK)"*/ 412#undef HAVE_FCNTL 413#endif 414 415#if defined(HAVE_LOCKF) && ! defined(F_LOCK) 416/*ABORT: "defined(HAVE_LOCKF) && ! defined(F_LOCK)"*/ 417/* You must fix this up */ 418#undef HAVE_LOCKF 419#endif 420 421#if defined(HAVE_FLOCK) && ! defined(LOCK_EX) 422/*AB0RT: "defined(HAVE_FLOCK) && ! defined(LOCK_EX)"*/ 423/* You must fix this up */ 424#undef HAVE_FLOCK 425#endif 426 427#ifdef HAVE_LIMITS_H 428#include <limits.h> 429#endif 430 431/* 4.2 BSD systems */ 432#ifndef S_IRUSR 433# define S_IRUSR S_IREAD 434# define S_IWUSR S_IWRITE 435# define S_IXUSR S_IEXEC 436# define S_IXGRP (S_IEXEC >> 3) 437# define S_IXOTH (S_IEXEC >> 6) 438#endif 439 440#ifndef S_ISLNK 441# define S_ISLNK(mode) (((mode) & S_IFLNK) == S_IFLNK) 442#endif 443#ifndef S_ISREG 444# define S_ISREG(mode) (((mode) & S_IFREG) == S_IFREG) 445#endif 446#ifndef S_ISDIR 447# define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR) 448#endif 449 450 451/* 4.2 BSD systems */ 452#ifndef SEEK_SET 453# define SEEK_SET 0 454# define SEEK_CUR 1 455# define SEEK_END 2 456#endif 457 458#ifndef HAVE_KILLPG 459# define killpg(pg,sig) ((int) kill ((pid_t)(-(pg)), (sig))) 460#else 461extern int killpg(pid_t pgrp, int sig); 462#endif 463 464/*********************************************************************** 465 * wait() stuff: most recent systems support a compatability version 466 * of "union wait", but it's not as fully-featured as the recent stuff 467 * that uses an "int *". However, we want to keep support for the 468 * older BSD systems as much as possible, so it's still supported; 469 * however, if waitpid() exists, we're POSIX.1 compliant, and we should 470 * not use "union wait". (hack hack hack) (jm) 471 * 472 * I agree. See the waitchild.c code for a tour through the depths of 473 * portability hell. 474 * 475 * Patrick Powell Thu Apr 6 08:03:58 PDT 1995 476 * 477 ***********************************************************************/ 478 479#ifdef HAVE_WAITPID 480# undef HAVE_UNION_WAIT /* and good riddance */ 481#endif 482 483/*************************************************************************** 484 * HAVE_UNION_WAIT will be def'd by configure if it's in <sys/wait.h>, 485 * and isn't just there for compatibility (like it is on HP/UX). 486 ***************************************************************************/ 487 488#ifdef HAVE_UNION_WAIT 489typedef union wait plp_status_t; 490/* 491 * with some BSDish systems, there are already #defines for this, 492 * so we should use them if they're there. 493 */ 494# ifndef WCOREDUMP 495# define WCOREDUMP(x) ((x).w_coredump) 496# endif 497# ifndef WEXITSTATUS 498# define WEXITSTATUS(x) ((x).w_retcode) 499# endif 500# ifndef WTERMSIG 501# define WTERMSIG(x) ((x).w_termsig) 502# endif 503# ifndef WIFSTOPPED 504# define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) 505# endif 506# ifndef WIFEXITED 507# define WIFEXITED(x) ((x).w_stopval == WEXITED) 508# endif 509 510#else 511 typedef int plp_status_t; 512/* The POSIX defaults for these macros. (this is cheating!) */ 513# ifndef WTERMSIG 514# define WTERMSIG(x) ((x) & 0x7f) 515# endif 516# ifndef WCOREDUMP 517# define WCOREDUMP(x) ((x) & 0x80) 518# endif 519# ifndef WEXITSTATUS 520# define WEXITSTATUS(x) ((((unsigned) x) >> 8) & 0xff) 521# endif 522# ifndef WIFSIGNALED 523# define WIFSIGNALED(x) (WTERMSIG (x) != 0) 524# endif 525# ifndef WIFEXITED 526# define WIFEXITED(x) (WTERMSIG (x) == 0) 527# endif 528#endif /* HAVE_UNION_WAIT */ 529 530/*********************************************************************** 531 * SVR4: SIGCHLD is really SIGCLD; #define it here. 532 * PLP lpd _does_ handle the compatibility semantics properly 533 * (Advanced UNIX Programming p. 281). 534 ***********************************************************************/ 535 536#if !defined(SIGCHLD) && defined(SIGCLD) 537# define SIGCHLD SIGCLD 538#endif 539 540 541/*********************************************************************** 542 * configure will set RETSIGTYPE to the type returned by signal() 543 ***********************************************************************/ 544 545typedef RETSIGTYPE plp_signal_t; 546typedef plp_signal_t (*plp_sigfunc_t)(int) ; 547 548#ifndef HAVE_GETDTABLESIZE 549# ifdef NOFILE 550# define getdtablesize() NOFILE 551# else 552# ifdef NOFILES_MAX 553# define getdtablesize() NOFILES_MAX 554# endif 555# endif 556#endif 557 558#ifndef HAVE_STRDUP 559# ifdef __STDC__ 560 char *strdup(const char*); 561# else 562 char *strdup(); 563# endif 564#endif 565 566#ifndef IPPORT_RESERVED 567#define IPPORT_RESERVED 1024 568#endif 569 570 571/* varargs declarations: */ 572 573#if defined(HAVE_STDARG_H) 574# include <stdarg.h> 575# define HAVE_STDARGS /* let's hope that works everywhere (mj) */ 576# define VA_LOCAL_DECL va_list ap; 577# define VA_START(f) va_start(ap, f) 578# define VA_SHIFT(v,t) ; /* no-op for ANSI */ 579# define VA_END va_end(ap) 580#else 581# if defined(HAVE_VARARGS_H) 582# include <varargs.h> 583# undef HAVE_STDARGS 584# define VA_LOCAL_DECL va_list ap; 585# define VA_START(f) va_start(ap) /* f is ignored! */ 586# define VA_SHIFT(v,t) v = va_arg(ap,t) 587# define VA_END va_end(ap) 588# else 589XX ** NO VARARGS ** XX 590# endif 591#endif 592 593#if !defined(IS_ULTRIX) && defined(HAVE_SYSLOG_H) 594# include <syslog.h> 595#endif 596#if defined(HAVE_SYS_SYSLOG_H) 597# include <syslog.h> 598#endif 599# if !(defined(LOG_PID) && defined(LOG_NOWAIT) && defined(HAVE_OPENLOG)) 600# undef HAVE_OPENLOG 601# endif /* LOG_PID && LOG_NOWAIT */ 602 603/* 604 * Priorities (these are ordered) 605 */ 606#ifndef LOG_ERR 607# define LOG_EMERG 0 /* system is unusable */ 608# define LOG_ALERT 1 /* action must be taken immediately */ 609# define LOG_CRIT 2 /* critical conditions */ 610# define LOG_ERR 3 /* error conditions */ 611# define LOG_WARNING 4 /* warning conditions */ 612# define LOG_NOTICE 5 /* normal but signification condition */ 613# define LOG_INFO 6 /* informational */ 614# define LOG_DEBUG 7 /* debug-level messages */ 615#endif 616 617#ifdef LOG_LPR 618# define SYSLOG_FACILITY LOG_LPR 619#else 620# ifdef LOG_LOCAL0 621# define SYSLOG_FACILITY LOCAL0 622# else 623# define SYSLOG_FACILITY (0) /* for Ultrix -- facilities aren't supported */ 624# endif 625#endif 626 627/************************************************************************* 628 * If we have SVR4 and no setpgid() then we need getpgrp() 629 *************************************************************************/ 630#if defined(SVR4) || defined(__alpha__) 631# undef HAVE_SETPGRP_0 632#endif 633 634/* 635 * NONBLOCKING Open and IO - different flags for 636 * different systems 637 */ 638 639#define NONBLOCK (O_NDELAY|O_NONBLOCK) 640#if defined(HPUX) && HPUX<110 641# undef NONBLOCK 642# define NONBLOCK (O_NONBLOCK) 643#endif 644 645/* fix for HPUX systems with no fd_set values */ 646#undef FD_SET_FIX 647#if !defined(HAVE_FD_SET) && defined(HPUX) 648# define FD_SET_FIX(X) (int *) 649#endif 650 651 652/********************************************************************* 653 * AIX systems need this 654 *********************************************************************/ 655 656#if defined(HAVE_SYS_SELECT_H) 657# include <sys/select.h> 658#endif 659 660/********************************************************************** 661 * Signal blocking 662 **********************************************************************/ 663#ifdef HAVE_SIGPROCMASK 664/* a signal set */ 665#define plp_block_mask sigset_t 666#else 667/* an integer */ 668#define plp_block_mask int 669#endif 670 671/********************************************************************** 672 * Select() problems 673 **********************************************************************/ 674#ifdef HAVE_SELECT_H 675#include <select.h> 676#endif 677#if !defined(FD_SET_FIX) 678# define FD_SET_FIX(X) X 679#endif 680 681/********************************************************************** 682 * IPV6 and newer versions 683 **********************************************************************/ 684#if !defined(HAVE_INET_PTON) 685int inet_pton( int family, const char *strptr, void *addr ); 686#endif 687#if !defined(HAVE_INET_NTOP) 688const char *inet_ntop( int family, const void *addr, char *strptr, size_t len ); 689#endif 690 691 692/***************************************************** 693 * Internationalisation of messages, using GNU gettext 694 *****************************************************/ 695 696#if HAVE_LOCALE_H 697# include <locale.h> 698#endif 699 700#if ENABLE_NLS 701# include <libintl.h> 702# define _(Text) gettext(Text) 703# ifdef gettext_noop 704# define N_(Text) gettext_noop(Text) 705# else 706# define N_(Text) Text 707# endif 708#else 709# define _(Text) Text 710# define N_(Text) Text 711# define textdomain(Domain) 712# define bindtextdomain(Package, Directory) 713#endif 714 715 716/********************************************************************** 717 * Cygwin Definitions 718 **********************************************************************/ 719#ifdef __CYGWIN__ 720#define ROOTUID 18 721#else 722#define ROOTUID 0 723#endif 724 725#ifndef HAVE_FLOCK_DEF 726extern int flock( int fd, int operation ); 727#endif 728 729/********************************************************************** 730 * SUNOS Definitions 731 **********************************************************************/ 732#ifdef SUNOS 733extern int _flsbuf(int, FILE *); 734extern int _filbuf(FILE *); 735extern int accept(int s, struct sockaddr *name, int *namelen); 736extern int bind(int s, struct sockaddr *name, int namelen); 737extern int connect(int s, struct sockaddr *name, int namelen); 738extern void bzero(void *s, size_t n); 739extern void endgrent( void ); 740extern int fflush( FILE *stream ); 741extern int fclose( FILE *stream ); 742extern int flock( int fd, int operation ); 743extern int fprintf(FILE *, const char *, ...); 744extern int fputs( const char *, FILE *stream ); 745extern int fstat(int fd, struct stat *buf ); 746extern int fseek( FILE *stream, long offset, int ptrname ); 747extern int ftruncate( int fd, off_t length ); 748extern int fwrite( char *ptr, int size, int nitems, FILE *stream); 749extern int getdtablesize( void ); 750extern int getpeername(int s, struct sockaddr *name, int *namelen); 751extern int getsockname(int s, struct sockaddr *name, int *namelen); 752extern int getsockopt(int s, int level, int optname, char *optval,int *optlen); 753extern int ioctl(int fd, int request, caddr_t arg ); 754extern int killpg(int pgrp, int sig ); 755extern int listen(int s, int backlog ); 756extern int lockf(int fd, int cmd, long size ); 757/*extern int lseek(int fd, off_t pos, int how ); */ 758extern int lstat(const char *path, struct stat *buf ); 759#define memmove(dest,src,len) bcopy(src,dest,len) 760extern void bcopy(const void *src,void *dest,size_t len); 761extern int mkstemp(char *s ); 762extern int openlog( const char *ident, int logopt, int facility ); 763extern int perror(const char *); 764extern int printf( const char *, ...); 765extern int rename(const char *, const char *); 766extern int select (int width, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); 767extern void setgrent(void); 768extern int seteuid( int euid ); 769extern int setreuid( int ruid, int euid ); 770extern int setsockopt(int s, int level, int optname, const char *optval,int optlen); 771extern int socket( int domain, int type, int protocol ); 772extern int socketpair(int, int, int, int *); 773extern int sscanf( char *s, char *format, ... ); 774extern int stat(const char *path, struct stat *buf ); 775extern int strcasecmp( const char *, const char * ); 776extern char *strerror( int ); 777extern int strncasecmp( const char *, const char *, int n ); 778extern long strtol( const char *str, char **ptr, int base ); 779extern double strtod( const char *str, char **ptr ); 780extern int shutdown( int sock, int how ); 781extern int gettimeofday(struct timeval *tp, struct timezone *tzp); 782extern int getrlimit(int resource, struct rlimit *rlp); 783extern char * sbrk(int incr); 784extern int fchmod(int fd, int mode); 785extern int strftime(char *buf, int bufsize, const char *fmt, struct tm *tm); 786extern void syslog(int, const char *, ...); 787extern int system( const char *str ); 788extern time_t time( time_t *t ); 789extern int tolower( int ); 790extern int toupper( int ); 791extern int tputs( const char *cp, int affcnt, int (*outc)() ); 792extern int vfprintf(FILE *, const char *, ...); 793extern int vprintf(FILE *, const char *, va_list ap); 794#endif 795 796 797#ifdef SOLARIS 798extern int setreuid( uid_t ruid, uid_t euid ); 799extern int mkstemp(char *s ); 800#ifdef HAVE_GETDTABLESIZE 801extern int getdtablesize(void); 802#endif 803#endif 804 805#if !defined(HAVE_SYSLOG_DEF) 806extern void syslog(int, const char *, ...); 807#endif 808#if !defined(HAVE_OPENLOG_DEF) 809extern int openlog( const char *ident, int logopt, int facility ); 810#endif 811 812#ifdef IS_AIX32 813extern int seteuid(uid_t); 814extern int setruid(uid_t); 815extern int setenv(char *, char *, int); 816#endif 817 818 819/* IPV6 structures define */ 820 821#if defined(AF_INET6) 822# if defined(IN_ADDR6) 823# define in6_addr in_addr6 824# endif 825#endif 826 827#if defined(HAVE_ARPA_NAMESER_H) 828# include <arpa/nameser.h> 829#endif 830#if defined(HAVE_RESOLV_H) 831# include <resolv.h> 832#endif 833 834#ifdef HAVE_INNETGR 835#if !defined(HAVE_INNETGR_DEF) 836extern int innetgr(const char *netgroup, 837 const char *machine, const char *user, const char *domain); 838#endif 839#endif 840 841 842#define Cast_int_to_voidstar(v) ((void *)(long)(v)) 843#define Cast_ptr_to_int(v) ((int)(long)(v)) 844#define Cast_ptr_to_long(v) ((long)(v)) 845 846/* for testing, set -Wall -Wformat and then make */ 847 848#if defined(FORMAT_TEST) 849# define FPRINTF fprintf 850# define PRINTF printf 851# define STDOUT stdout 852# define STDERR stderr 853# define SNPRINTF(X,Y) printf( 854# define VSNPRINTF(X,Y) vprintf( 855# define SETSTATUS(X) printf( 856#else 857# define FPRINTF safefprintf 858# define PRINTF safeprintf 859# define STDOUT 1 860# define STDERR 2 861# define SNPRINTF(X,Y) plp_snprintf(X,Y, 862# define VSNPRINTF(X,Y) plp_vsnprintf(X,Y, 863# define SETSTATUS(X) setstatus(X, 864#endif 865 866#endif 867 868#ifdef JYDEBUG//JYWeng 869FILE *aaaaaa; 870#endif 871