2 * Client-side IPC functions
13 #include <sys/types.h>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 #include <arpa/inet.h>
23 #include <libcitadel.h>
24 #include "citadel_ipc.h"
32 #include <sys/types.h>
34 #if TIME_WITH_SYS_TIME
35 # include <sys/time.h>
39 # include <sys/time.h>
51 #ifdef HAVE_SYS_SELECT_H
52 #include <sys/select.h>
55 /* Note that some of these functions may not work with multiple instances. */
57 static void (*deathHook)(void) = NULL;
58 int (*error_printf)(char *s, ...) = (int (*)(char *, ...))printf;
60 void setIPCDeathHook(void (*hook)(void)) {
64 void setIPCErrorPrintf(int (*func)(char *s, ...)) {
68 void connection_died(CtdlIPC* ipc, int using_ssl) {
69 if (deathHook != NULL) {
73 stty_ctdl(SB_RESTORE);
74 fprintf(stderr, "\r\n\n\n");
75 fprintf(stderr, "Your connection to %s is broken.\n", ipc->ServInfo.humannode);
79 fprintf(stderr, "Last error: %s\n", ERR_reason_error_string(ERR_get_error()));
84 fprintf(stderr, "Last error: %s\n", strerror(errno));
86 fprintf(stderr, "Please re-connect and log in again.\n");
89 shutdown(ipc->sock, 2);