struct options global_options;
+static int default_add_all_directories();
+
int defaults() {
// logging needs to be setup first
logging_thread = pthread_self();
snprintf(buf,10,"%lu",sysconf(_SC_NPROCESSORS_ONLN));
if(opt_set_worker_threads(buf)<0) { return -1; }
}
-
+
+ if(default_add_all_directories()<0) { return -1; }
+
+ return 1;
+}
+
+static int default_add_all_directories() {
+ // add all directories in PREFIX
+ DIR *dir;
+ struct dirent *ent;
+ char *p;
+ if((dir = opendir(PREFIX))==NULL) {
+ log_err(DEFAULT_MESSAGE_COULD_NOT_OPEN);
+ return -1;
+ }
+
+ while((ent = readdir(dir))!=NULL) {
+ if(strcmp(ent->d_name,".")==0) { continue; }
+ if(strcmp(ent->d_name,"..")==0) { continue; }
+
+ p = malloc(sizeof(char)*(strlen(PREFIX)+strlen(ent->d_name)+1));
+ if(NULL==p) {
+ perror("malloc");
+ return -1;
+ }
+
+ sprintf(p,PREFIX "/%s",ent->d_name);
+ if(opt_add_watch(p)<0) {
+ free(p);
+ return -1;
+ }
+
+ free(p);
+ }
+
+ closedir(dir);
+
return 1;
}
// logging must be setup first
if(setup_logging()<0) { return -1; }
- if(setup_session()<0) { return -1; }
-
return 1;
}