formating

This commit is contained in:
Albert S. 2015-10-12 22:40:36 +02:00
parent 8b668be219
commit 68c11d296b

View File

@ -112,7 +112,9 @@ char *xrealpath(const char *path, char *resolved_path)
char *ndirname(const char *path) char *ndirname(const char *path)
{ {
if(path == NULL) if(path == NULL)
{
return xstrdup("."); return xstrdup(".");
}
char *c = strdupa(path); char *c = strdupa(path);
return xstrdup(dirname(c)); return xstrdup(dirname(c));
} }
@ -120,16 +122,24 @@ char *ndirname(const char *path)
char *find_ifd_path(int ifd) char *find_ifd_path(int ifd)
{ {
for(struct watchlistentry *lkp = watchlist_head; lkp != NULL; lkp = lkp->next) for(struct watchlistentry *lkp = watchlist_head; lkp != NULL; lkp = lkp->next)
{
if(lkp->ifd == ifd) if(lkp->ifd == ifd)
{
return lkp->path; return lkp->path;
}
}
return NULL; return NULL;
} }
bool is_ignored(const char *filename) bool is_ignored(const char *filename)
{ {
for(struct ignorelist *l = ignorelist_head; l != NULL; l = l->next) for(struct ignorelist *l = ignorelist_head; l != NULL; l = l->next)
{
if(fnmatch(l->ignore, filename, 0) == 0) if(fnmatch(l->ignore, filename, 0) == 0)
{
return true; return true;
}
}
return false; return false;
} }
@ -164,7 +174,9 @@ void add_to_ignore_list(const char *str)
void logwrite(const char *format, ...) void logwrite(const char *format, ...)
{ {
if(silent) if(silent)
{
return; return;
}
va_list args; va_list args;
va_start(args, format); va_start(args, format);
vfprintf(stdout, format, args); vfprintf(stdout, format, args);
@ -240,8 +252,10 @@ bool run_prog(const char *eventfile, uint32_t eventmask)
if(path_logfile) if(path_logfile)
{ {
if(! redirect_stdout(path_logfile)) if(! redirect_stdout(path_logfile))
{
return false; return false;
} }
}
if(! noenv) if(! noenv)
@ -352,8 +366,9 @@ char *get_eventfile_abspath(struct inotify_event *event)
{ {
char *wdpath = find_ifd_path(event->wd); char *wdpath = find_ifd_path(event->wd);
if(wdpath == NULL) if(wdpath == NULL)
{
return NULL; return NULL;
}
size_t nameLen = strlen(event->name); size_t nameLen = strlen(event->name);
char *abspath = xmalloc((strlen(wdpath) + nameLen + 2) * sizeof(char)); char *abspath = xmalloc((strlen(wdpath) + nameLen + 2) * sizeof(char));
strcpy(abspath, wdpath); strcpy(abspath, wdpath);
@ -531,8 +546,9 @@ void parse_options(int argc, char **argv)
void process_options() void process_options()
{ {
if(fromstdin) if(fromstdin)
{
queue_watches_from_stdin(); queue_watches_from_stdin();
}
if(daemonize) if(daemonize)
{ {
if(daemon(0,0) == -1) if(daemon(0,0) == -1)
@ -543,10 +559,14 @@ void process_options()
} }
if(watchlist_head == NULL) if(watchlist_head == NULL)
{
watchqueue_addpath(get_cwd()); watchqueue_addpath(get_cwd());
}
if(mask == 0) if(mask == 0)
{
mask |= IN_CLOSE_WRITE; mask |= IN_CLOSE_WRITE;
}
if(! file_exists(prog)) if(! file_exists(prog))
{ {
@ -555,8 +575,9 @@ void process_options()
} }
if(path_logfile) if(path_logfile)
{
path_logfile = xrealpath(path_logfile, NULL); path_logfile = xrealpath(path_logfile, NULL);
}
if(forkbombcheck) if(forkbombcheck)
{ {
@ -594,7 +615,9 @@ void start_monitoring(int ifd)
void child_handler(int signum, siginfo_t *info, void *context) void child_handler(int signum, siginfo_t *info, void *context)
{ {
if(signum != SIGCHLD) if(signum != SIGCHLD)
{
return; return;
}
int status; int status;
pid_t p = waitpid(-1, &status, WNOHANG); pid_t p = waitpid(-1, &status, WNOHANG);