projects
/
sxemacs
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'origin/master' into for-steve
[sxemacs]
/
lib-src
/
gnuslib.c
diff --git
a/lib-src/gnuslib.c
b/lib-src/gnuslib.c
index
6e6bcd5
..
e388fc0
100644
(file)
--- a/
lib-src/gnuslib.c
+++ b/
lib-src/gnuslib.c
@@
-8,15
+8,15
@@
Copyright (C) 1989 Free Software Foundation, Inc.
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.
*/
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.
*/
* Added EOT stuff.
*/
@@
-84,7
+84,7
@@
int make_connection(char *hostarg, int portarg, int *s)
#endif
if (hostarg != NULL) {
#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")) {
* so obey it. */
#ifdef UNIX_DOMAIN_SOCKETS
if (!strcmp(hostarg, "unix")) {
@@
-122,7
+122,7
@@
int make_connection(char *hostarg, int portarg, int *s)
#ifdef SYSV_IPC
/*
connect_to_ipc_server -- establish connection with server process via SYSV IPC
#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)
{
*/
static int connect_to_ipc_server(void)
{
@@
-130,7
+130,9
@@
static int connect_to_ipc_server(void)
key_t key; /* message key */
char buf[GSERV_BUFSZ + 1]; /* buffer for filename */
key_t key; /* message key */
char buf[GSERV_BUFSZ + 1]; /* buffer for filename */
- sprintf(buf, "%s/gsrv%d", tmpdir, (int)geteuid());
+ int sz;
+
+ SNPRINTF(sz, buf, sizeof(buf), "%s/gsrv%d", tmpdir, (int)geteuid());
creat(buf, 0600);
if ((key = ftok(buf, 1)) == -1) {
perror(progname);
creat(buf, 0600);
if ((key = ftok(buf, 1)) == -1) {
perror(progname);
@@
-151,7
+153,7
@@
static int connect_to_ipc_server(void)
/*
disconnect_from_ipc_server -- inform the server that sending has finished,
/*
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)
{
*/
void disconnect_from_ipc_server(int s, struct msgbuf *msgp, int echo)
{
@@
-238,13
+240,14
@@
int read_line(int s, char *dest)
#ifdef UNIX_DOMAIN_SOCKETS
/*
connect_to_unix_server -- establish connection with server process via a unix-
#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)
{
int s; /* connected socket descriptor */
struct sockaddr_un server; /* for unix connections */
if successful.
*/
static int connect_to_unix_server(void)
{
int s; /* connected socket descriptor */
struct sockaddr_un server; /* for unix connections */
+ int sz;
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
perror(progname);
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
perror(progname);
@@
-254,9
+257,11
@@
static int connect_to_unix_server(void)
server.sun_family = AF_UNIX;
#ifdef HIDE_UNIX_SOCKET
server.sun_family = AF_UNIX;
#ifdef HIDE_UNIX_SOCKET
- sprintf(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 */
#else /* HIDE_UNIX_SOCKET */
- sprintf(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 */
if (connect(s, (struct sockaddr *)&server, strlen(server.sun_path) + 2)
< 0) {
#endif /* HIDE_UNIX_SOCKET */
if (connect(s, (struct sockaddr *)&server, strlen(server.sun_path) + 2)
< 0) {
@@
-273,7
+278,7
@@
static int connect_to_unix_server(void)
#ifdef INTERNET_DOMAIN_SOCKETS
/*
internet_addr -- return the internet addr of the hostname or
#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)
{
*/
int internet_addr(char *host)
{
@@
-298,8
+303,8
@@
static Xauth *server_xauth = NULL;
#endif
/*
#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)
descriptor for server if successful.
*/
static int connect_to_internet_server(char *serverhost, unsigned short port)
@@
-365,9
+370,8
@@
static int connect_to_internet_server(char *serverhost, unsigned short port)
strlen(MCOOKIE_X_NAME), MCOOKIE_X_NAME);
if (server_xauth && server_xauth->data) {
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);
t = write(s, buf, len);
if(t != len) {
fprintf(stderr, "%s: unable to send auth", progname);
@@
-382,8
+386,7
@@
static int connect_to_internet_server(char *serverhost, unsigned short port)
}
#endif /* AUTH_MAGIC_COOKIE */
}
#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);
t = write(s, buf, len);
if(t != len) {
fprintf(stderr, "%s: unable to send auth", progname);
@@
-398,7
+401,7
@@
static int connect_to_internet_server(char *serverhost, unsigned short port)
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
/*
disconnect_from_server -- inform the server that sending has finished, and wait for
#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)
{
*/
void disconnect_from_server(int s, int echo)
{