annotate lib-src/gnuserv.h @ 441:72a7cfa4a488

Added tag r21-2-28 for changeset 8de8e3f6228a
author cvs
date Mon, 13 Aug 2007 11:33:40 +0200
parents 84b14dcb0985
children abe6d1db359e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* -*-C-*-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Header file for the GNU Emacs server and client C code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of GNU Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 Copying is permitted under those conditions described by the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 General Public License.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 Copyright (C) 1989 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 Author: Andy Norman (ange@hplb.hpl.hp.com), based on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 Emacs distribution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 Please mail bugs and suggestions to the author at the above address.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 /* HISTORY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 * 11-Nov-1990 bristor@simba
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 * Added EOT stuff.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 * This file incorporates new features added by Bob Weiner <weiner@mot.com>,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 * Please see the note at the end of the README file for details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 * (If gnuserv came bundled with your emacs, the README file is probably
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 * ../etc/gnuserv.README relative to the directory containing this file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup alpha !";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #define USE_TMPDIR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #define NO_SHORTNAMES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #define PATCHLEVEL 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #define NO_SHORTNAMES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 /* gnuserv should not be compiled using SOCKS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #define DO_NOT_SOCKSIFY
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
46 #include <config.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #undef read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #undef write
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #undef open
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #undef close
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #undef signal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 /* Define the communication method between server and clients:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 * You can have either or both kinds of sockets, but you can't mix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 * sockets with sysv ipc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #define INTERNET_DOMAIN_SOCKETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 #ifdef HAVE_SYS_UN_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 #define UNIX_DOMAIN_SOCKETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 /* #define SYSV_IPC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 * Define additional authentication protocols to be used. These methods will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 * be tried before falling back to the default gnuserv protocol (based on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 * the GNU_SECURE environment variable). Currently, only MIT-MAGIC-COOKIE-1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 * is also supported.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 * Comment out the next line(s) if you don't want to enable the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 * appropriate authentication protocol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 #if defined (HAVE_XAUTH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 #define AUTH_MAGIC_COOKIE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 #endif /* HAVE_XAUTH */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 * stuff related to supporting MIT-MAGIC-COOKIE-1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #define MCOOKIE_SCREEN "999" /* screen # to use as the gnuserv cookie */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #define MCOOKIE_NAME "MAGIC-1" /* authentication protocol name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #define MCOOKIE_X_NAME "MIT-MAGIC-COOKIE-1" /* as needed by X */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 #define DEFAUTH_NAME "GNU-SECURE" /* name of default auth protocol */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 #define AUTH_TIMEOUT 15 /* # seconds to wait for auth data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #define AUTH_NAMESZ 15 /* max allows auth protocol name size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 * Pick a default communication scheme, if none was specified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 #ifdef HAVE_SYSVIPC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 #define SYSV_IPC /* SYSV systems use SYSV IPC by default */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 #endif /* HAVE_SYSVIPC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 #ifdef BSD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 #define UNIX_DOMAIN_SOCKETS /* BSD systems use Unix Domain sockets by default */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 #endif /* BSD */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 #endif /* No communication method pre-defined */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 #include <sys/types.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 #include <sys/param.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 #include <sys/stat.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 #include <signal.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 #include <errno.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 #ifdef HAVE_UNISTD_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 #include <unistd.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 #ifdef HAVE_SYS_TIME_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 #include <sys/time.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 * If you are using SYSV_IPC, you might want to make the buffer size bigger
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 * since it limits the size of requests and responses. Don't make it bigger
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 * than your system's max message size though (usually a couple of k) or else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 * msgsend will start failing. For sockets, using the system BUFSIZ is usually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 * what you want.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 # define GSERV_BUFSZ BUFSIZ
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 #ifdef SYSV_IPC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 #include <sys/ipc.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 #include <sys/msg.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 #define send_string(s,str) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 if (strlen(msgp->mtext) + strlen(str) < GSERV_BUFSZ) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 strcat(msgp->mtext,str); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 else \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 fprintf(stderr,"%s: not enough message buffer space\n",progname); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 exit(1); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 #endif /* SYSV_IPC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 #include <sys/socket.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 #ifdef INTERNET_DOMAIN_SOCKETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 #include <netdb.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 #include <netinet/in.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 #include <arpa/inet.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 #define TABLE_SIZE 101 /* The number of entries in the hash table */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 #define HASH(host) host /* Rather simplistic hash function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 #define DEFAULT_PORT 21490 /* default port number to use is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 * DEFAULT_PORT + uid */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 #endif /* INTERNET_DOMAIN_SOCKETS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 #ifdef UNIX_DOMAIN_SOCKETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 #include <sys/un.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 #define HIDE_UNIX_SOCKET /* put the unix socket in a protected dir */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 #endif /* UNIX_DOMAIN_SOCKETS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 /* On some platforms, we need to do the equivalent of "stty litout" to get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 * characters like ^D to pass through to emacs. This problem has only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 * been observed under emacs18; fsf19 and lemacs are probably okay without it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 #ifndef DONT_USE_LITOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 #if !defined(HAVE_TERMIO) && !defined(HAVE_TERMIOS) && !defined(VMS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 #if !defined(MSDOS) && !defined(BSD4_1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 #define USE_LITOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 #define HOSTNAMSZ 255 /* max size of a hostname */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 #define REPLYSIZ 300 /* max size of reply from server to client */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 #undef FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 #define FALSE 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 #undef TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 #define TRUE 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 extern char *optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 extern int optind;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 extern char *progname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 extern char *tmpdir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 /* The casts shut Sun's compiler up and are safe in the context these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 are actually used. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 #define max2(x,y) (((int) (x) > (int) (y)) ? (x) : (y))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 #define min2(x,y) (((int) (x) < (int) (y)) ? (x) : (y))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 #ifndef _NFILE /* rough guess at maximum number of open files */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 #define _NFILE 20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 #define EOT_STR "\004"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 #define EOT_CHR '\004'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 /* connection types */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 #define CONN_UNIX 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 #define CONN_INTERNET 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 #define CONN_IPC 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 /* function declarations */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 int make_connection (char *hostarg, int portarg, int *s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 #ifdef SYSV_IPC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 void disconnect_from_ipc_server();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 void send_string (int s, CONST char *msg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 void disconnect_from_server (int s, int echo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 int read_line (int s, char *dest);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 #ifdef INTERNET_DOMAIN_SOCKETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 int internet_addr (char *host);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 #endif