{
if (socket_fd >= 0)
{
- close(socket_fd);
+ close (socket_fd); /* unix only */
socket_fd = -1;
}
if (socket_path)
{
- unlink(socket_path);
- free(socket_path);
+ unlink (socket_path);
+ free (socket_path);
socket_path = NULL;
}
- exit(EXIT_SUCCESS);
+ exit (EXIT_SUCCESS);
}
void log_error (int status, gpg_error_t errnum,
{
/* TODO: check for WRDE_BADCHAR, etc. */
fprintf (log_stream, "could not expand socket path\n");
- exit(EXIT_FAILURE);
+ exit (EXIT_FAILURE);
}
if (words.we_wordc != 1)
{
fprintf (log_stream, "expanded socket path into %d fields\n",
words.we_wordc);
- exit(EXIT_FAILURE);
+ exit (EXIT_FAILURE);
}
path = malloc (sizeof(char) * (strlen(words.we_wordv[0]) + 1));
if (! path)
{
- perror("can't allocate path");
- exit(EXIT_FAILURE);
+ perror ("can't allocate path");
+ exit (EXIT_FAILURE);
}
strcpy (path, words.we_wordv[0]);
{
struct sockaddr_un addr;
- socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ socket_fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (socket_fd == -1)
{
- perror("can't create stream socket");
- exit(EXIT_FAILURE);
+ perror ("can't create stream socket");
+ exit (EXIT_FAILURE);
}
addr.sun_family = AF_UNIX;
- socket_path = expand_path("~/.gnupg/S.gpgme-tool");
+ socket_path = expand_path ("~/.gnupg/S.gpgme-tool");
strcpy (addr.sun_path, socket_path);
if (bind (socket_fd, (struct sockaddr *) &addr, sizeof(struct sockaddr_un)))
{
- perror("can't bind to stream socket");
- exit(EXIT_FAILURE);
+ perror ("can't bind to stream socket");
+ exit (EXIT_FAILURE);
}
- signal(SIGINT, &cleanup_handler);
- signal(SIGTERM, &cleanup_handler);
+ signal (SIGINT, &cleanup_handler);
+ signal (SIGTERM, &cleanup_handler);
- listen(socket_fd, 5);
+ listen (socket_fd, 5);
for (;;)
{
- sock = accept(socket_fd, NULL, 0);
+ sock = accept (socket_fd, NULL, 0);
if (sock == -1)
{
perror("accept");
}
if ((pid = fork ()) == -1)
{
- perror("fork");
- close(sock);
+ perror ("fork");
+ close (sock);
sock = -1;
continue;
}
}
/* the child doesn't need cleanup handlers */
- signal(SIGINT, SIG_DFL);
- signal(SIGTERM, SIG_DFL);
+ signal (SIGINT, SIG_DFL);
+ signal (SIGTERM, SIG_DFL);
err = assuan_init_socket_server (
server.assuan_ctx, sock,