summaryrefslogtreecommitdiff
path: root/apps/JAWS/clients/WebSTONE/src/sysdep.h
blob: 5b6e533291ebbd8e6b4a8ee05a67f694883826af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef __SYSDEP_H__
#define __SYSDEP_H__
/**************************************************************************
 * $Header$                                                                *
 *               Copyright (C) 1995 Silicon Graphics, Inc.                *
 *                                                                        *
 *  These coded instructions, statements, and computer programs were      *
 *  developed by SGI for public use.  If any changes are made to this code*
 *  please try to get the changes back to the author.  Feel free to make  *
 *  modifications and changes to the code and release it.                 *
 *                                                                        *
 **************************************************************************/

/* include config.h, output from autoconf */
#ifdef HAVE_CONFIG_H
#ifndef __CONFIG_H__
#define __CONFIG_H__
#include "config.h"
#endif
#endif

#ifdef WIN32
#include <windows.h>
#include <winsock.h>
#endif /* WIN32 */

/* MAXHOSTNAMELEN is undefined on some systems */
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif

/* SunOS doesn't define NULL */
#ifndef NULL
#define NULL 0
#endif

/* encapsulation of minor UNIX/WIN NT differences */
#ifdef WIN32
#define NETREAD(sock, buf, len)         recv(sock, buf, len, 0)
#define NETWRITE(sock, buf, len)        send(sock, buf, len, 0)
#define NETCLOSE(sock)                  closesocket(sock)
#define BADSOCKET(sock)                 ((sock) == INVALID_SOCKET)
#define BADSOCKET_ERRNO(sock)           BADSOCKET(sock)
#define BADSOCKET_VALUE                 INVALID_SOCKET
#define S_ADDR                          S_un.S_addr

#ifdef USE_TIMEZONE
#error  NT gettimeofday() doesn't support USE_TIMEZONE (yet)
#else
#define GETTIMEOFDAY(timeval, tz)       gettimeofday(timeval)
#endif /* USE_TIMEZONE */

typedef unsigned short                  NETPORT;
#define SRANDOM                         srand
#define RANDOM_R                        rand_r
#define RANDOM                          rand
#define THREAD                          __declspec ( thread )
#define PROGPATH                        "c:\\webstone\\webclient"
#define FILENAME_SIZE                   256
#define HAVE_VPRINTF                    1

#define SIGCHLD                         0       /* dummy value */
#define SIGALRM                         0       /* dummy value */
typedef int                             pid_t;
typedef unsigned short                  ushort;
#define MAXPATHLEN                      512



#else /* not WIN32 */
#define NETREAD(sock, buf, len)         read(sock, buf, len)
#define NETWRITE(sock, buf, len)        write(sock, buf, len)
#define NETCLOSE(sock)                  close(sock)
#define BADSOCKET(sock)                 ((sock) < 0)
#define BADSOCKET_ERRNO(sock)           (BADSOCKET(sock) || errno)
#define BADSOCKET_VALUE                 (-1)
#define S_ADDR                          s_addr

#ifdef USE_TIMEZONE
#define GETTIMEOFDAY(timeval,tz)        gettimeofday(timeval, NULL)
#else
#define GETTIMEOFDAY(timeval,tz)        gettimeofday(timeval, tz)
#endif /* USE_TIMEZONE */

typedef unsigned short                  NETPORT;
#define SRANDOM                         srandom
#define RANDOM                          random
#define THREAD
#define PROGPATH                        "/tmp/webclient" /* "/usr/local/bin/webclient" */
#define FILENAME_SIZE                   1024
#define HAVE_VPRINTF                    1

typedef int                             SOCKET;
#define min(a,b)                        (((a) < (b)) ? a : b)
#define max(a,b)                        (((a) > (b)) ? a : b)
#endif /* WIN32 */


/* function prototypes */

#ifdef WIN32
int     getopt(int argc, char ** argv, char *opts);
int     getpid(void);
int     gettimeofday(struct timeval *curTimeP);
int     random_number(int max);
SOCKET  rexec(const char **hostname, NETPORT port, char *username, char *password,
                char *command, SOCKET *sockerr);
void    sleep(int secs);

#else
#ifdef NO_REXEC
extern int      rexec(char **, int, char *, char *, char *, int *);
#endif
#endif /* WIN32 */


#ifndef HAVE_STRERROR
/* strerror() is not available on SunOS 4.x and others */
char *strerror(int errnum);

#endif
/* strerror() */


#ifndef INADDR_NONE
#define INADDR_NONE -1
#endif

/* !__SYSDEP_H__ */
#endif