/* Client process that communicates with GNU Emacs acting as server.
- Copyright (C) 1986-1987, 1994, 1999-2012 Free Software Foundation, Inc.
+
+Copyright (C) 1986-1987, 1994, 1999-2012 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#ifdef WINDOWSNT
-/* config.h defines these, which disables sockets altogether! */
+/* ms-w32.h defines these, which disables sockets altogether! */
# undef _WINSOCKAPI_
# undef _WINSOCK_H
/* Additional space when allocating buffers for filenames, etc. */
#define EXTRA_SPACE 100
-/* Use this to suppress gcc's `...may be used before initialized' warnings. */
-#ifdef lint
-# define IF_LINT(Code) Code
-#else
-# define IF_LINT(Code) /* empty */
-#endif
-
#ifdef min
#undef min
#endif
/* From sysdep.c */
#if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME)
-/* From lisp.h */
-#ifndef DIRECTORY_SEP
-#define DIRECTORY_SEP '/'
-#endif
-#ifndef IS_DIRECTORY_SEP
-#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
-#endif
-#ifndef IS_DEVICE_SEP
-#ifndef DEVICE_SEP
-#define IS_DEVICE_SEP(_c_) 0
-#else
-#define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP)
-#endif
-#endif
-
char *get_current_dir_name (void);
/* Return the current working directory. Returns NULL on errors.
return window_app;
}
-/*
- execvp wrapper for Windows. Quotes arguments with embedded spaces.
+/* execvp wrapper for Windows. Quotes arguments with embedded spaces.
This is necessary due to the broken implementation of exec* routines in
the Microsoft libraries: they concatenate the arguments together without
quoting special characters, and pass the result to CreateProcess, with
predictably bad results. By contrast, POSIX execvp passes the arguments
- directly into the argv array of the child process.
-*/
+ directly into the argv array of the child process. */
+
int
w32_execvp (const char *path, char **argv)
{
int i;
+ extern int execvp (const char*, char **);
/* Required to allow a .BAT script as alternate editor. */
argv[0] = (char *) alternate_editor;
exit (EXIT_SUCCESS);
}
-/*
- Try to run a different command, or --if no alternate editor is
- defined-- exit with an errorcode.
- Uses argv, but gets it from the global variable main_argv.
-*/
+/* Try to run a different command, or --if no alternate editor is
+ defined-- exit with an errorcode.
+ Uses argv, but gets it from the global variable main_argv. */
+
static _Noreturn void
fail (void)
{
#define AUTH_KEY_LENGTH 64
#define SEND_BUFFER_SIZE 4096
-extern char *strerror (int);
-
/* Buffer to accumulate data to send in TCP connections. */
char send_buffer[SEND_BUFFER_SIZE + 1];
int sblen = 0; /* Fill pointer for the send buffer. */
/* Socket used to communicate with the Emacs server process. */
HSOCKET emacs_socket = 0;
-/* On Windows, the socket library was historically separate from the standard
- C library, so errors are handled differently. */
+/* On Windows, the socket library was historically separate from the
+ standard C library, so errors are handled differently. */
+
static void
sock_err_message (const char *function_name)
{
/* The inverse of quote_argument. Removes quoting in string STR by
- modifying the string in place. Returns STR. */
+ modifying the string in place. Returns STR. */
static char *
unquote_argument (char *str)
#endif /* WINDOWSNT */
\f
-/*
- * Read the information needed to set up a TCP comm channel with
- * the Emacs server: host, port, and authentication string.
- */
+/* Read the information needed to set up a TCP comm channel with
+ the Emacs server: host, port, and authentication string. */
+
static int
get_server_config (const char *config_file, struct sockaddr_in *server,
char *authentication)
message (FALSE, "%s: connected to remote socket at %s\n",
progname, inet_ntoa (server.sin_addr));
- /*
- * Open up an AF_INET socket
- */
+ /* Open up an AF_INET socket. */
if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
sock_err_message ("socket");
return INVALID_SOCKET;
}
- /*
- * Set up the socket
- */
+ /* Set up the socket. */
if (connect (s, (struct sockaddr *) &server, sizeof server) < 0)
{
sock_err_message ("connect");
setsockopt (s, SOL_SOCKET, SO_LINGER, (char *) &l_arg, sizeof l_arg);
- /*
- * Send the authentication
- */
+ /* Send the authentication. */
auth_string[AUTH_KEY_LENGTH] = '\0';
send_to_emacs (s, "-auth ");
going to sleep. Normally the suspend is initiated by Emacs via
server-handle-suspend-tty, but if the server gets out of sync with
reality, we may get a SIGTSTP on C-z. Handling this signal and
- notifying Emacs about it should get things under control again. */
+ notifying Emacs about it should get things under control again. */
static void
handle_sigtstp (int signalnum)
HSOCKET s;
struct sockaddr_un server;
- /*
- * Open up an AF_UNIX socket in this person's home directory
- */
-
+ /* Open up an AF_UNIX socket in this person's home directory. */
if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
{
message (TRUE, "%s: socket: %s\n", progname, strerror (errno));
return FALSE;
}
-/*
- * Search for a window of class "Emacs" and owned by a process with
- * process id = emacs_pid. If found, allow it to grab the focus.
- */
+/* Search for a window of class "Emacs" and owned by a process with
+ process id = emacs_pid. If found, allow it to grab the focus. */
+
void
w32_give_focus (void)
{
}
#endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
-
-\f
-#ifndef HAVE_STRERROR
-char *
-strerror (errnum)
- int errnum;
-{
- extern char *sys_errlist[];
- extern int sys_nerr;
-
- if (errnum >= 0 && errnum < sys_nerr)
- return sys_errlist[errnum];
- return (char *) "Unknown error";
-}
-
-#endif /* ! HAVE_STRERROR */
-
-
-/* emacsclient.c ends here */