2 * $Id: ipc_c_tcp.c -1 $
4 * Client-side IPC functions
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
26 #include <libcitadel.h>
28 #include "citadel_ipc.h"
29 #include "citadel_decls.h"
35 /* Note that some of these functions may not work with multiple instances. */
37 static void (*deathHook)(void) = NULL;
38 int (*error_printf)(char *s, ...) = (int (*)(char *, ...))printf;
40 void setIPCDeathHook(void (*hook)(void)) {
44 void setIPCErrorPrintf(int (*func)(char *s, ...)) {
48 void connection_died(CtdlIPC* ipc, int using_ssl) {
49 if (deathHook != NULL) {
53 stty_ctdl(SB_RESTORE);
54 fprintf(stderr, "\r\n\n\n");
55 fprintf(stderr, "Your connection to %s is broken.\n", ipc->ServInfo.humannode);
59 fprintf(stderr, "Last error: %s\n", ERR_reason_error_string(ERR_get_error()));
64 fprintf(stderr, "Last error: %s\n", strerror(errno));
66 fprintf(stderr, "Please re-connect and log in again.\n");
69 shutdown(ipc->sock, 2);