Anonymous avatar Anonymous committed e3d5d96

cleanup, rearrange funcitons

Comments (0)

Files changed (1)

 	struct watch *next;
 };
 
+static int  add_dir(const char *fpath, const struct stat *sb, int typeflag);
+static void sigchld(int unused);
+static void sigusr(int unused);
+static void usage(void);
+static void win(struct watch *w);
+
 static struct watch *watches = NULL;
 static int evq;
 static char *nick = "";
 
-void win(struct watch *w)
-{
-	int fd = 0;
-	char out[PATH_MAX], in[PATH_MAX], path[PATH_MAX], channel[32];
-	char *cmd[] = CMD; // from config.h
-	struct stat st;
-
-	if (w->pid)
-		return;
-
-	sprintf(out, "%s/out", w->path);
-	sprintf(in,  "%s/in",  w->path);
-
-	// open() to see if ii has the fifo open for reading
-	if (stat(out, &st) < 0 || stat(in, &st) < 0 || (fd = open(in, O_WRONLY | O_NONBLOCK)) < 0)
-		return;
-
-	close(fd);
-	strcpy(path, w->path); // stupid basename messing with my strings
-	snprintf(channel, sizeof(channel), "%s> ", basename(path));
-
-	if ((w->pid = fork()) == 0) {
-		execvp(cmd[0], cmd);
-		err(1, "failed on execvp %s", cmd[0]);
-	}
-}
 
 int add_dir(const char *fpath, const struct stat *sb, int typeflag)
 {
 	return 0;
 }
 
-void sigusr(int unused) {
-	struct watch *w;
-
-	for (w = watches; w; w = w->next)
-		win(w);
-}
-
 void sigchld(int unused)
 {
 	pid_t pid;
 				w->pid = 0;
 }
 
+void sigusr(int unused)
+{
+	struct watch *w;
+
+	for (w = watches; w; w = w->next)
+		win(w);
+}
+
 void usage(void)
 {
 	fprintf(stderr, "Usage: pcw [-n nick] [-v] dir\n");
 	exit(1);
 }
 
+void win(struct watch *w)
+{
+	int fd = 0;
+	char out[PATH_MAX], in[PATH_MAX], path[PATH_MAX], channel[32];
+	char *cmd[] = CMD; // from config.h
+	struct stat st;
+
+	if (w->pid)
+		return;
+
+	sprintf(out, "%s/out", w->path);
+	sprintf(in,  "%s/in",  w->path);
+
+	// open() to see if ii has the fifo open for reading
+	if (stat(out, &st) < 0 || stat(in, &st) < 0 || (fd = open(in, O_WRONLY | O_NONBLOCK)) < 0)
+		return;
+
+	close(fd);
+	strcpy(path, w->path); // stupid basename messing with my strings
+	snprintf(channel, sizeof(channel), "%s> ", basename(path));
+
+	if ((w->pid = fork()) == 0) {
+		execvp(cmd[0], cmd);
+		err(1, "failed on execvp %s", cmd[0]);
+	}
+}
+
 int main(int argc, char **argv)
 {
 	char buf[4096];
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.