/* If we're using a unix domain socket we can do a bunch of stuff */
if (!strcmp(cithost, UDS)) {
if (!strcasecmp(citport, DEFAULT_PORT)) {
- snprintf(sockpath, sizeof sockpath, "%s%s",
-#ifndef HAVE_RUN_DIR
- CTDLDIR
+#ifdef HAVE_RUN_DIR
+ snprintf(sockpath, sizeof sockpath, RUNDIR "/citadel.socket");
#else
- RUN_DIR
+ snprintf(sockpath, sizeof sockpath, CTDLDIR "/citadel.socket");
#endif
- , "/citadel.socket");
}
else {
- snprintf(sockpath, sizeof sockpath, "%s%s",
- citport,
-#ifndef HAVE_RUN_DIR
- CTDLDIR
-#else
- RUN_DIR
-#endif
- "/citadel.socket");
+ snprintf(sockpath, sizeof sockpath, "%s/%s", citport, "citadel.socket");
}
ipc->sock = uds_connectsock(&(ipc->isLocal), sockpath);
if (ipc->sock == -1) {
/*
* Connect sendcommand to the Citadel server running on this computer.
*/
-void np_attach_to_server(void)
+void np_attach_to_server(char *host, char *port)
{
- char hostbuf[SIZ], portbuf[SIZ];
char buf[SIZ];
+ char hostbuf[256], portbuf[256];
char *args[] =
{"sendcommand", NULL};
int r;
- strcpy(hostbuf, UDS); /* Only run on a unix domain socket */
- strcpy(portbuf,
-#ifndef HAVE_RUN_DIR
- "." /* IPGM will refuse to run on the network */
-#else
- ""
-#endif
- );
fprintf(stderr, "Attaching to server...\n");
+ strcpy(hostbuf, host);
+ strcpy(portbuf, port);
ipc = CtdlIPC_new(1, args, hostbuf, portbuf);
if (!ipc) {
fprintf(stderr, "Can't connect: %s\n", strerror(errno));
char cmd[SIZ];
char buf[SIZ];
- strcpy(ctdl_home_directory, CTDLDIR);
+ strcpy(ctdl_home_directory, DEFAULT_PORT);
strcpy(cmd, "");
/*
(int) getpid(),
ctdl_home_directory);
fflush(stderr);
- np_attach_to_server();
+ np_attach_to_server(UDS, ctdl_home_directory);
fflush(stderr);
setIPCDeathHook(sendcommand_die);