1 /**************************************************************************** 2 * * 3 * The contents of this file are subject to the WebStone Public License * 4 * Version 1.0 (the "License"); you may not use this file except in * 5 * compliance with the License. You may obtain a copy of the License * 6 * at http://www.mindcraft.com/webstone/license10.html * 7 * * 8 * Software distributed under the License is distributed on an "AS IS" * 9 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * 10 * the License for the specific language governing rights and limitations * 11 * under the License. * 12 * * 13 * The Original Code is WebStone 2.5. * 14 * * 15 * The Initial Developer of the Original Code is Silicon Graphics, Inc. * 16 * and Mindcraft, Inc.. Portions created by Silicon Graphics. and * 17 * Mindcraft. are Copyright (C) 1995-1998 Silicon Graphics, Inc. and * 18 * Mindcraft, Inc. All Rights Reserved. * 19 * * 20 * Contributor(s): ______________________________________. * 21 * * 22 ***************************************************************************/ 23 24 #ifndef __SYSDEP_H__ 25 #define __SYSDEP_H__ 26 27 28 /* include config.h, output from autoconf */ 29 #ifdef HAVE_CONFIG_H 30 #ifndef __CONFIG_H__ 31 #define __CONFIG_H__ 32 #include "config.h" 33 #endif 34 #else 35 #define VERSION "2.5b" 36 #endif 37 38 #ifdef WIN32 39 #include <windows.h> 40 #include <winsock.h> 41 #endif /* WIN32 */ 42 43 /* MAXHOSTNAMELEN is undefined on some systems */ 44 #ifndef MAXHOSTNAMELEN 45 #define MAXHOSTNAMELEN 64 46 #endif 47 48 /* SunOS doesn't define NULL */ 49 #ifndef NULL 50 #define NULL 0 51 #endif 52 53 /* encapsulation of minor UNIX/WIN NT differences */ 54 #ifdef WIN32 55 #define NETREAD(sock, buf, len) recv(sock, buf, len, 0) 56 #define NETWRITE(sock, buf, len) send(sock, buf, len, 0) 57 #define NETCLOSE(sock) closesocket(sock) 58 #define BADSOCKET(sock) ((sock) == INVALID_SOCKET) 59 #define BADSOCKET_VALUE INVALID_SOCKET 60 #define SOCK_ERR(ret) ((ret) == SOCKET_ERROR) 61 #define CLEAR_SOCK_ERR WSASetLastError(0) 62 #define GET_NET_ERR WSAGetLastError() 63 #define S_ADDR S_un.S_addr 64 65 #ifdef USE_TIMEZONE 66 #error NT gettimeofday() does not support USE_TIMEZONE (yet) 67 #else 68 #define GETTIMEOFDAY(timeval, tz) gettimeofday(timeval) 69 #endif /* USE_TIMEZONE */ 70 71 typedef unsigned short NETPORT; 72 #define SRANDOM srand 73 #define RANDOM rand 74 #define THREAD __declspec ( thread ) 75 #define FILENAME_SIZE 256 76 #define HAVE_VPRINTF 1 77 78 #define SIGCHLD 0 /* dummy value */ 79 #define SIGALRM 0 /* dummy value */ 80 typedef int pid_t; 81 typedef unsigned short ushort; 82 #define MAXPATHLEN 512 83 84 85 86 #else /* not WIN32 */ 87 #define NETREAD(sock, buf, len) read(sock, buf, len) 88 #define NETWRITE(sock, buf, len) write(sock, buf, len) 89 #define NETCLOSE(sock) close(sock) 90 #define BADSOCKET(sock) ((sock) < 0) 91 #define BADSOCKET_VALUE (-1) 92 #define SOCK_ERR(ret) ((ret) < 0) 93 #define CLEAR_SOCK_ERR errno = 0 94 #define GET_NET_ERR errno 95 #define S_ADDR s_addr 96 97 #ifdef USE_TIMEZONE 98 #define GETTIMEOFDAY(timeval,tz) gettimeofday(timeval, NULL) 99 #else 100 #define GETTIMEOFDAY(timeval,tz) gettimeofday(timeval, tz) 101 #endif /* USE_TIMEZONE */ 102 103 typedef unsigned short NETPORT; 104 #define SRANDOM srand 105 #define RANDOM rand 106 #define THREAD 107 #define FILENAME_SIZE 1024 108 #define HAVE_VPRINTF 1 109 110 typedef int SOCKET; 111 #define min(a,b) (((a) < (b)) ? a : b) 112 #define max(a,b) (((a) > (b)) ? a : b) 113 #endif /* WIN32 */ 114 115 /* function prototypes */ 116 117 #ifdef WIN32 118 int getopt(int argc, char ** argv, char *opts); 119 int getpid(void); 120 int gettimeofday(struct timeval *curTimeP); 121 int random_number(int max); 122 SOCKET rexec(const char **hostname, NETPORT port, char *username, char *password, 123 char *command, SOCKET *sockerr); 124 void sleep(int secs); 125 126 #else 127 #ifdef NO_REXEC 128 extern int rexec(char **, int, char *, char *, char *, int *); 129 #endif 130 #endif /* WIN32 */ 131 132 133 #ifndef HAVE_STRERROR 134 /* strerror() is not available on SunOS 4.x and others */ 135 char *strerror(int errnum); 136 137 #endif 138 /* strerror() */ 139 140 141 #ifndef INADDR_NONE 142 #define INADDR_NONE -1 143 #endif 144 145 /* !__SYSDEP_H__ */ 146 #endif 147