X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Fclient.c;h=5b080fb1a53c7786feea027e6e146d557a2868d8;hb=c5d236324fe6500844a86263e754339a2b3190f0;hp=fc2776b7e599fef28654c90f8cee5096e0f68b82;hpb=5ec60e4217863b0e2d6a86ba3f60f60c68608227;p=doldaconnect.git diff --git a/daemon/client.c b/daemon/client.c index fc2776b..5b080fb 100644 --- a/daemon/client.c +++ b/daemon/client.c @@ -60,9 +60,20 @@ static void writehashcache(int now); static struct configvar myvars[] = { + /** The default nick name to use. The nickname can also be + * specified for individual hubs, overriding this setting. */ {CONF_VAR_STRING, "defnick", {.str = L"DoldaConnect user"}}, + /** When scanning shares, this bitmask is consulted for every + * regular file. Unless the file's mode has the bits specified by + * this mask set, it will not be shared. */ {CONF_VAR_INT, "scanfilemask", {.num = 0004}}, + /** When scanning shares, this bitmask is consulted for every + * directory encountered. Unless the directory's mode has the bits + * specified by this mask set, it will be ignored and any files + * under it will not be shared. */ {CONF_VAR_INT, "scandirmask", {.num = 0005}}, + /** The filename to use for the hash cache (see the FILES section + * for more information). */ {CONF_VAR_STRING, "hashcache", {.str = L"dc-hashcache"}}, {CONF_VAR_END} }; @@ -244,52 +255,6 @@ static void freehashcache(struct hashcache *hc) free(hc); } -static char *findhashcachefile(int filldef) -{ - static char ret[128]; - char *hcname; - - if(getenv("HOME") != NULL) - { - snprintf(ret, sizeof(ret), "%s/.dc-hashcache", getenv("HOME")); - if(!access(ret, R_OK)) - return(ret); - } - if((hcname = icswcstombs(confgetstr("cli", "hashcache"), NULL, NULL)) == NULL) - { - flog(LOG_WARNING, "could not convert hash cache name into local charset: %s", strerror(errno)); - return(NULL); - } - if(strchr(hcname, '/') != NULL) - { - if(!access(hcname, R_OK)) - { - strcpy(ret, hcname); - return(ret); - } - } else { - snprintf(ret, sizeof(ret), "/etc/%s", hcname); - if(!access(ret, R_OK)) - return(ret); - snprintf(ret, sizeof(ret), "/usr/etc/%s", hcname); - if(!access(ret, R_OK)) - return(ret); - snprintf(ret, sizeof(ret), "/usr/local/etc/%s", hcname); - if(!access(ret, R_OK)) - return(ret); - } - if(filldef) - { - if(getenv("HOME") != NULL) - snprintf(ret, sizeof(ret), "%s/.dc-hashcache", getenv("HOME")); - else - snprintf(ret, sizeof(ret), "/etc/%s", hcname); - return(ret); - } else { - return(NULL); - } -} - static struct hashcache *findhashcache(dev_t dev, ino_t inode) { struct hashcache *hc; @@ -312,7 +277,7 @@ static void readhashcache(void) struct hashcache *hc; size_t len; - if((hcname = findhashcachefile(0)) == NULL) + if((hcname = findfile(icswcstombs(confgetstr("cli", "hashcache"), NULL, NULL), NULL, 0)) == NULL) return; if((stream = fopen(hcname, "r")) == NULL) { @@ -388,7 +353,7 @@ static void writehashcache(int now) } if(hashwritetimer != NULL) canceltimer(hashwritetimer); - hcname = findhashcachefile(1); + hcname = findfile(icswcstombs(confgetstr("cli", "hashcache"), NULL, NULL), NULL, 1); if((stream = fopen(hcname, "w")) == NULL) { flog(LOG_WARNING, "could not write hash cache %s: %s", hcname, strerror(errno)); @@ -408,7 +373,7 @@ static void writehashcache(int now) fclose(stream); } -static int hashread(struct socket *sk, void *uudata) +static void hashread(struct socket *sk, void *uudata) { static char *hashbuf; static size_t hashbufsize = 0, hashbufdata = 0; @@ -422,7 +387,7 @@ static int hashread(struct socket *sk, void *uudata) struct hashcache *hc; if((buf = sockgetinbuf(sk, &bufsize)) == NULL) - return(0); + return; bufcat(hashbuf, buf, bufsize); free(buf); while((lp = memchr(hashbuf, '\n', hashbufdata)) != NULL) @@ -464,7 +429,6 @@ static int hashread(struct socket *sk, void *uudata) } memmove(hashbuf, lp, hashbufdata -= (lp - hashbuf)); } - return(0); } static void hashexit(pid_t pid, int status, struct socket *outsock) @@ -543,7 +507,7 @@ static int hashfile(char *path) close(fd); close(pfd[1]); outsock = wrapsock(pfd[0]); - CBREG(outsock, socket_read, hashread, NULL, NULL); + outsock->readcb = hashread; childcallback(hashjob, (void (*)(pid_t, int, void *))hashexit, outsock); return(0); }