sendcommand: locate admin socket using calc_dirs_n_files
authorArt Cancro <ajc@uncensored.citadel.org>
Fri, 20 Jan 2012 18:20:34 +0000 (13:20 -0500)
committerArt Cancro <ajc@uncensored.citadel.org>
Fri, 20 Jan 2012 18:20:34 +0000 (13:20 -0500)
citadel/Makefile.in
citadel/utils/sendcommand.c

index a1abae852bd017e9b2a515ce6d6290abd9bc5eb2..6cfec73277245437cf4d35cd6c4f5d54d93bb66c 100644 (file)
@@ -204,8 +204,8 @@ stress$(EXEEXT): utils/stress.o utillib/ipc_c_tcp.o utillib/citadel_ipc.o \
                utillib/citadel_dirs.o $(LIBOBJS) \
                $(LDFLAGS) -o stress$(EXEEXT) $(LIBS)
 
-sendcommand$(EXEEXT): utils/sendcommand.o $(LIBOBJS)
-       $(CC) utils/sendcommand.o \
+sendcommand$(EXEEXT): utils/sendcommand.o utillib/citadel_dirs.o $(LIBOBJS)
+       $(CC) utils/sendcommand.o utillib/citadel_dirs.o \
                $(LIBOBJS) $(LDFLAGS) -o sendcommand$(EXEEXT) $(LIBS)
 
 base64$(EXEEXT): utils/base64.o
index e9e5fbcd639a56dbece398927634d6418f4f0514..fde3d5c3c5dff8e39aee0fe6ca9f086e5c32b8a5 100644 (file)
@@ -26,6 +26,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include "citadel.h"
+#include "include/citadel_dirs.h"
 
 
 
@@ -141,15 +142,18 @@ int main(int argc, char **argv)
 {
        int a;
        int watchdog = 60;
-       char *ctdl_home_directory = CTDLDIR;
        char buf[SIZ];
        int xfermode = 0;
+       int relh=0;
+       int home=0;
+       char relhome[PATH_MAX]="";
+       char ctdldir[PATH_MAX]=CTDLDIR;
 
        /* Parse command line */
        while ((a = getopt(argc, argv, "h:w:")) != EOF) {
                switch (a) {
                case 'h':
-                       ctdl_home_directory = strdup(optarg);
+                       strcpy(relhome, optarg);
                        break;
                case 'w':
                        watchdog = atoi(optarg);
@@ -159,15 +163,16 @@ int main(int argc, char **argv)
                }
        }
 
-       fprintf(stderr, "sendcommand: started (pid=%d) connecting to Citadel server in %s\n",
+       calc_dirs_n_files(relh, home, relhome, ctdldir, 0);
+
+       fprintf(stderr, "sendcommand: started (pid=%d) connecting to Citadel server at %s\n",
                (int) getpid(),
-               ctdl_home_directory
+               file_citadel_admin_socket
        );
        fflush(stderr);
 
        alarm(watchdog);
-       snprintf(buf, sizeof buf, "%s/citadel-admin.socket", ctdl_home_directory);
-       serv_sock = uds_connectsock(buf);
+       serv_sock = uds_connectsock(file_citadel_admin_socket);
 
        serv_gets(buf);
        fprintf(stderr, "%s\n", buf);