X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lib-src%2Fgnuslib.c;h=8951b265e8d7c5a45c4a4327c9ccf04ef0971bfc;hb=65e332fd1023bf6dc8ce09b6dab7c1659ee95161;hp=a30f9f95c216b384e89af8e4daac67c90aa54bb6;hpb=6883ee56ec887c2c48abe5b06b5e66aa74031910;p=chise%2Fxemacs-chise.git.1 diff --git a/lib-src/gnuslib.c b/lib-src/gnuslib.c index a30f9f9..8951b26 100644 --- a/lib-src/gnuslib.c +++ b/lib-src/gnuslib.c @@ -43,7 +43,7 @@ static int connect_to_ipc_server (void); static int connect_to_unix_server (void); #endif #ifdef INTERNET_DOMAIN_SOCKETS -static int connect_to_internet_server (char *serverhost, u_short port); +static int connect_to_internet_server (char *serverhost, unsigned short port); #endif /* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */ @@ -76,10 +76,8 @@ char *tmpdir = NULL; char *progname = NULL; -int make_connection(hostarg, portarg, s) - char *hostarg; - int portarg; - int *s; +int +make_connection (char *hostarg, int portarg, int *s) { #ifdef INTERNET_DOMAIN_SOCKETS char *ptr; @@ -130,7 +128,8 @@ int make_connection(hostarg, portarg, s) connect_to_ipc_server -- establish connection with server process via SYSV IPC Returns msqid for server if successful. */ -static int connect_to_ipc_server (void) +static int +connect_to_ipc_server (void) { int s; /* connected msqid */ key_t key; /* message key */ @@ -160,10 +159,8 @@ static int connect_to_ipc_server (void) disconnect_from_ipc_server -- inform the server that sending has finished, and wait for its reply. */ -void disconnect_from_ipc_server(s,msgp,echo) - int s; - struct msgbuf *msgp; - int echo; +void +disconnect_from_ipc_server (int s, struct msgbuf *msgp, int echo) { int len; /* length of received message */ @@ -196,9 +193,8 @@ void disconnect_from_ipc_server(s,msgp,echo) /* send_string -- send string to socket. */ -void send_string(s,msg) - int s; - CONST char *msg; +void +send_string (int s, const char *msg) { #if 0 if (send(s,msg,strlen(msg),0) < 0) { @@ -227,7 +223,8 @@ void send_string(s,msg) /* read_line -- read a \n terminated line from a socket */ -int read_line(int s, char *dest) +int +read_line (int s, char *dest) { int length; int offset=0; @@ -252,7 +249,8 @@ int read_line(int s, char *dest) domain socket. Returns socket descriptor for server if successful. */ -static int connect_to_unix_server (void) +static int +connect_to_unix_server (void) { int s; /* connected socket descriptor */ struct sockaddr_un server; /* for unix connections */ @@ -286,8 +284,8 @@ static int connect_to_unix_server (void) internet_addr -- return the internet addr of the hostname or internet address passed. Return -1 on error. */ -int internet_addr(host) - char *host; +int +internet_addr (char *host) { struct hostent *hp; /* pointer to host info for remote host */ IN_ADDR numeric_addr; /* host address */ @@ -314,13 +312,16 @@ static Xauth *server_xauth = NULL; an internet domain socket. Returns socket descriptor for server if successful. */ -static int connect_to_internet_server (char *serverhost, u_short port) +static int +connect_to_internet_server (char *serverhost, unsigned short port) { int s; /* connected socket descriptor */ struct servent *sp; /* pointer to service information */ struct sockaddr_in peeraddr_in; /* for peer socket address */ char buf[512]; /* temporary buffer */ + int t; + /* clear out address structures */ memset((char *)&peeraddr_in,0,sizeof(struct sockaddr_in)); @@ -328,10 +329,12 @@ static int connect_to_internet_server (char *serverhost, u_short port) peeraddr_in.sin_family = AF_INET; /* look up the server host's internet address */ - if ((peeraddr_in.sin_addr.s_addr = internet_addr(serverhost)) == -1) { + if ((t = internet_addr(serverhost)) == -1) { fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP\n", progname,serverhost); exit(1); + } else { + peeraddr_in.sin_addr.s_addr = t; }; /* if */ if (port == 0) { @@ -395,9 +398,8 @@ static int connect_to_internet_server (char *serverhost, u_short port) disconnect_from_server -- inform the server that sending has finished, and wait for its reply. */ -void disconnect_from_server(s,echo) - int s; - int echo; +void +disconnect_from_server (int s, int echo) { #if 0 char buffer[REPLYSIZ+1]; @@ -409,13 +411,11 @@ void disconnect_from_server(s,echo) send_string(s,EOT_STR); /* make sure server gets string */ -#if !defined (linux) && !defined (_SCO_DS) +#if !defined (_SCO_DS) /* - * shutdown is completely hozed under linux. If s is a unix domain socket, - * you'll get EOPNOTSUPP back from it. If s is an internet socket, you get - * a broken pipe when you try to read a bit later. The latter - * problem is fixed for linux versions >= 1.1.46, but the problem - * with unix sockets persists. Sigh. + * There used to be a comment here complaining about ancient Linux + * versions. It is no longer relevant. I don't know why _SCO_DS is + * verboten here, as the original comment did not say. */ if (shutdown(s,1) == -1) { @@ -434,7 +434,7 @@ void disconnect_from_server(s,echo) #else while ((length = read(s,buffer,GSERV_BUFSZ)) > 0 || (length == -1 && errno == EINTR)) { - if (length) { + if (length > 0) { buffer[length] = '\0'; if (echo) { fputs(buffer,stdout);