+#include "citadel_dirs.h"
+#include <libcitadel.h>
+
+int serv_sock = (-1);
+
+int uds_connectsock(char *sockpath)
+{
+ int s;
+ struct sockaddr_un addr;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ strncpy(addr.sun_path, sockpath, sizeof addr.sun_path);
+
+ s = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (s < 0) {
+ fprintf(stderr, "sendcommand: Can't create socket: %s\n", strerror(errno));
+ exit(3);
+ }
+
+ if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ fprintf(stderr, "sendcommand: can't connect: %s\n", strerror(errno));
+ close(s);
+ exit(3);
+ }