Copyright (C) 1989 Free Software Foundation, Inc.
- Author: Andy Norman (ange@hplb.hpl.hp.com), based on
- 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
- Emacs distribution.
+ Author: Andy Norman (ange@hplb.hpl.hp.com), based on
+ 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
+ Emacs distribution.
Please mail bugs and suggestions to the author at the above address.
*/
-/* HISTORY
- * 11-Nov-1990 bristor@simba
+/* HISTORY
+ * 11-Nov-1990 bristor@simba
* Added EOT stuff.
*/
#endif
if (hostarg != NULL) {
- /* hostname was given explicitly, via cmd line arg or GNU_HOST,
+ /* hostname was given explicitly, via cmd line arg or GNU_HOST,
* so obey it. */
#ifdef UNIX_DOMAIN_SOCKETS
if (!strcmp(hostarg, "unix")) {
#ifdef SYSV_IPC
/*
connect_to_ipc_server -- establish connection with server process via SYSV IPC
- Returns msqid for server if successful.
+ Returns msqid for server if successful.
*/
static int connect_to_ipc_server(void)
{
key_t key; /* message key */
char buf[GSERV_BUFSZ + 1]; /* buffer for filename */
- int sz = snprintf(buf, sizeof(buf),
- "%s/gsrv%d", tmpdir, (int)geteuid());
- assert(sz>=0 && sz<sizeof(buf));
+ int sz;
+
+ SNPRINTF(sz, buf, sizeof(buf), "%s/gsrv%d", tmpdir, (int)geteuid());
creat(buf, 0600);
if ((key = ftok(buf, 1)) == -1) {
perror(progname);
/*
disconnect_from_ipc_server -- inform the server that sending has finished,
- and wait for its reply.
+ and wait for its reply.
*/
void disconnect_from_ipc_server(int s, struct msgbuf *msgp, int echo)
{
#ifdef UNIX_DOMAIN_SOCKETS
/*
connect_to_unix_server -- establish connection with server process via a unix-
- domain socket. Returns socket descriptor for server
+ domain socket. Returns socket descriptor for server
if successful.
*/
static int connect_to_unix_server(void)
server.sun_family = AF_UNIX;
#ifdef HIDE_UNIX_SOCKET
- sz = snprintf(server.sun_path, sizeof(server.sun_path),
- "%s/gsrvdir%d/gsrv", tmpdir, (int)geteuid());
+ SNPRINTF(sz, server.sun_path, sizeof(server.sun_path),
+ "%s/gsrvdir%d/gsrv", tmpdir, (int)geteuid());
#else /* HIDE_UNIX_SOCKET */
- sz = snprintf(server.sun_path, sizeof(server.sun_path),
- "%s/gsrv%d", tmpdir, (int)geteuid());
+ SNPRINTF(sz, server.sun_path, sizeof(server.sun_path),
+ "%s/gsrv%d", tmpdir, (int)geteuid());
#endif /* HIDE_UNIX_SOCKET */
- assert(sz>=0 && sz<sizeof(server.sun_path));
if (connect(s, (struct sockaddr *)&server, strlen(server.sun_path) + 2)
< 0) {
perror(progname);
#ifdef INTERNET_DOMAIN_SOCKETS
/*
internet_addr -- return the internet addr of the hostname or
- internet address passed. Return -1 on error.
+ internet address passed. Return -1 on error.
*/
int internet_addr(char *host)
{
#endif
/*
- connect_to_internet_server -- establish connection with server process via
- an internet domain socket. Returns socket
+ connect_to_internet_server -- establish connection with server process via
+ an internet domain socket. Returns socket
descriptor for server if successful.
*/
static int connect_to_internet_server(char *serverhost, unsigned short port)
strlen(MCOOKIE_X_NAME), MCOOKIE_X_NAME);
if (server_xauth && server_xauth->data) {
- len = snprintf(buf, sizeof(buf), "%s\n%d\n", MCOOKIE_NAME,
- server_xauth->data_length);
- assert( len >=0 && len < sizeof(buf));
+ SNPRINTF(len, buf, sizeof(buf),
+ "%s\n%d\n", MCOOKIE_NAME, server_xauth->data_length);
t = write(s, buf, len);
if(t != len) {
fprintf(stderr, "%s: unable to send auth", progname);
}
#endif /* AUTH_MAGIC_COOKIE */
- len = snprintf(buf, sizeof(buf), "%s\n", DEFAUTH_NAME);
- assert(len >= 0 && len < sizeof(buf));
+ SNPRINTF(len, buf, sizeof(buf), "%s\n", DEFAUTH_NAME);
t = write(s, buf, len);
if(t != len) {
fprintf(stderr, "%s: unable to send auth", progname);
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
/*
disconnect_from_server -- inform the server that sending has finished, and wait for
- its reply.
+ its reply.
*/
void disconnect_from_server(int s, int echo)
{