aboutsummaryrefslogtreecommitdiff
path: root/sysutils/fileschanged/files
diff options
context:
space:
mode:
authorPav Lucistnik <pav@FreeBSD.org>2004-05-23 16:29:27 +0000
committerPav Lucistnik <pav@FreeBSD.org>2004-05-23 16:29:27 +0000
commit85dafff40303a63c70b0325c67b4bb8120cc2e4d (patch)
treeb610cc2996aa86ec539a7968db45baad99e9abf9 /sysutils/fileschanged/files
parent3d01474b04dd5215ddb501409dd2e3dd57eddc22 (diff)
downloadports-85dafff40303a63c70b0325c67b4bb8120cc2e4d.tar.gz
ports-85dafff40303a63c70b0325c67b4bb8120cc2e4d.zip
Add fileschanged, a client to the FAM (File Alteration Monitor) server.
Here's how the fileschanged FAM client works: you give it some filenames on the command line and then it monitors those files for changes. When it discovers that a file has changed (or has been altered), it displays the filename on the standard-output. PR: ports/66894 Submitted by: Konstantin Reznichenko <kot@premierbank.dp.ua>
Notes
Notes: svn path=/head/; revision=109792
Diffstat (limited to 'sysutils/fileschanged/files')
-rw-r--r--sysutils/fileschanged/files/patch-configure11
-rw-r--r--sysutils/fileschanged/files/patch-filelist.c33
-rw-r--r--sysutils/fileschanged/files/patch-handlers.c32
-rw-r--r--sysutils/fileschanged/files/patch-monitor.c12
-rw-r--r--sysutils/fileschanged/files/patch-opts.c28
-rw-r--r--sysutils/fileschanged/files/patch-opts.h10
6 files changed, 126 insertions, 0 deletions
diff --git a/sysutils/fileschanged/files/patch-configure b/sysutils/fileschanged/files/patch-configure
new file mode 100644
index 000000000000..b6c51787ae0c
--- /dev/null
+++ b/sysutils/fileschanged/files/patch-configure
@@ -0,0 +1,11 @@
+--- configure.orig Mon Feb 23 02:18:08 2004
++++ configure Tue May 18 15:08:38 2004
+@@ -341,7 +341,7 @@
+ bindir='${exec_prefix}/bin'
+ sbindir='${exec_prefix}/sbin'
+ libexecdir='${exec_prefix}/libexec'
+-datadir='${prefix}/share'
++datadir='${prefix}/share/doc'
+ sysconfdir='${prefix}/etc'
+ sharedstatedir='${prefix}/com'
+ localstatedir='${prefix}/var'
diff --git a/sysutils/fileschanged/files/patch-filelist.c b/sysutils/fileschanged/files/patch-filelist.c
new file mode 100644
index 000000000000..22f662c13bb6
--- /dev/null
+++ b/sysutils/fileschanged/files/patch-filelist.c
@@ -0,0 +1,33 @@
+--- src/filelist.c.orig Mon Feb 23 02:17:30 2004
++++ src/filelist.c Wed May 19 18:30:04 2004
+@@ -12,6 +12,30 @@
+ #include "opts.h"
+ #include "listdirs.h"
+ extern struct arguments_t arguments;
++#if defined(__FreeBSD__)
++ssize_t getline(char **lineptr, size_t *n, FILE *stream)
++{
++ char *line;
++ size_t len;
++
++ line = fgetln(stream, &len);
++ if (!line)
++ return -1;
++ if (len >= *n) {
++ char *tmp;
++
++ /* XXX some realloc() implementations don't set errno */
++ tmp = realloc(*lineptr, len + 1);
++ if (!tmp)
++ return -1;
++ *lineptr = tmp;
++ *n = len + 1;
++ }
++ memcpy(*lineptr, line, len);
++ (*lineptr)[len] = 0;
++ return len;
++}
++#endif
+ int for_every_filename(int (*for_every_file)(int (*)(void *, char *), void *list), int (*add_it_to_the)(void *list, char *filename), void *list)
+ {
+ for_every_file(add_it_to_the, list);
diff --git a/sysutils/fileschanged/files/patch-handlers.c b/sysutils/fileschanged/files/patch-handlers.c
new file mode 100644
index 000000000000..6a85acfd3fca
--- /dev/null
+++ b/sysutils/fileschanged/files/patch-handlers.c
@@ -0,0 +1,32 @@
+--- src/handlers.c.orig Mon Feb 23 01:42:46 2004
++++ src/handlers.c Sun May 23 17:50:35 2004
+@@ -7,6 +7,10 @@
+ #include "node.h"
+ #include "opts.h"
+ #include "wl.h"
++#if defined(__FreeBSD__)
++#include "libgen.h"
++#endif
++
+ extern struct arguments_t arguments;
+ struct handler_t handlers[FC_HANDLER_MAX]=
+ {
+@@ -180,12 +184,18 @@
+ }
+ void show_event(enum handler_enum_t id, char *filename)
+ {
++ if (arguments.fileschanged.exec_command == NULL) {
+ if (arguments.fileschanged.showaction)
+ {
+ fprintf(stdout, "%s ", handlers[id].name);
+ }
+ fprintf(stdout, "%s\n",filename);
+ fflush(stdout);
++ } else {
++ if (!fork()) {
++ execlp(arguments.fileschanged.exec_command, arguments.fileschanged.exec_command, handlers[id].name, filename, NULL);
++ }
++ }
+ return;
+ }
+ int handle_created_file(FAMConnection *c, void *list, enum handler_enum_t id, char *filename)
diff --git a/sysutils/fileschanged/files/patch-monitor.c b/sysutils/fileschanged/files/patch-monitor.c
new file mode 100644
index 000000000000..fc33c2a7995c
--- /dev/null
+++ b/sysutils/fileschanged/files/patch-monitor.c
@@ -0,0 +1,12 @@
+--- src/monitor.c.orig Mon Feb 23 02:17:30 2004
++++ src/monitor.c Wed May 19 18:30:54 2004
+@@ -2,7 +2,9 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdlib.h>
++#if !defined(__FreeBSD__)
+ #include <sys/select.h>
++#endif
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <time.h>
diff --git a/sysutils/fileschanged/files/patch-opts.c b/sysutils/fileschanged/files/patch-opts.c
new file mode 100644
index 000000000000..f2ee24633b09
--- /dev/null
+++ b/sysutils/fileschanged/files/patch-opts.c
@@ -0,0 +1,28 @@
+--- src/opts.c.orig Mon Feb 23 01:17:30 2004
++++ src/opts.c Sun May 23 17:52:10 2004
+@@ -19,6 +19,7 @@
+ const char filelist_option_explanation[]="Monitor the list of filenames inside FILE";
+ const char filechangetimeout_option_explanation[]="Delay showing changed files for N seconds (Def=2)";
+ const char showaction_option_explanation[]="Also display action when displaying altered files";
++const char execcmd_option_explanation[]="Execute COMMAND when file altered (COMMAND action filename)";
+
+ struct arguments_t arguments;
+ static struct argp_option options[] =
+@@ -34,6 +35,7 @@
+ {"filelist", 'l',"FILENAME",0, filelist_option_explanation, 3},
+ {"timeout", 't',"N",0, filechangetimeout_option_explanation, 4},
+ {"prepend-action", 'p',0,0, showaction_option_explanation, 5},
++ {"execcmd", 'x',"COMMAND",0, execcmd_option_explanation, 6},
+ { 0 }
+ };
+
+@@ -93,6 +95,9 @@
+ arguments->fileschanged.filechangetimeout=atoi(arg);
+ if (arguments->fileschanged.filechangetimeout<=1)
+ arguments->fileschanged.filechangetimeout=-1;
++ break;
++ case 'x':
++ arguments->fileschanged.exec_command=strdup(arg);
+ break;
+ case ARGP_KEY_INIT:
+ free_arguments();
diff --git a/sysutils/fileschanged/files/patch-opts.h b/sysutils/fileschanged/files/patch-opts.h
new file mode 100644
index 000000000000..7daaf7d5fe20
--- /dev/null
+++ b/sysutils/fileschanged/files/patch-opts.h
@@ -0,0 +1,10 @@
+--- src/opts.h.orig Mon Feb 23 01:17:30 2004
++++ src/opts.h Sun May 23 17:53:00 2004
+@@ -17,6 +17,7 @@
+ int filestomonitor;
+ int filechangetimeout;
+ int showaction;
++ char *exec_command;
+ };
+ struct arguments_t {
+ char **args;