diff --git a/src/Makefile.am b/src/Makefile.am index 6a916c5..45c9123 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,8 @@ -bin_PROGRAMS = test$(EXEEXT) log$(EXEEXT) watcher$(EXEEXT) +bin_PROGRAMS = \ + proTest$(EXEEXT) \ + logTest$(EXEEXT) \ + wtail$(EXEEXT) \ + watcher$(EXEEXT) lib_LTLIBRARIES = libwatchy.la pkgconfigdir = $(libdir)/pkgconfig @@ -9,13 +13,17 @@ libwatchy_cindlude_HEADERS = watchy.h libwatchy_la_LDFLAGS = -rpath '$(libdir)' libwatchy_la_SOURCES = \ libwatchy.c \ + runtime.c \ osdep-@PLATFORM@.c watcher_SOURCES = watcher.c watcher_LDADD = libwatchy.la -test_SOURCES = test.c -test_LDADD = libwatchy.la +wtail_SOURCES = wtail.c +wtail_LDADD = libwatchy.la -log_SOURCES = log.c -log_LDADD = libwatchy.la +proTest_SOURCES = test.c +proTest_LDADD = libwatchy.la + +logTest_SOURCES = log.c +logTest_LDADD = libwatchy.la diff --git a/src/runtime.c b/src/runtime.c new file mode 100644 index 0000000..293a88a --- /dev/null +++ b/src/runtime.c @@ -0,0 +1,29 @@ +#include "config.h" + +#include +#include +#include + +#include +#include +#include + +#include "watchy.h" + +static int pfd; +static bool init = false; + +int watchy_writePacket (const struct watchy_data * data, const int fd) +{ + return 0; +} + +int watchy_cAttachRuntime (const char * fifo, const char * bind, const int port) +{ + return; +} + +void watchy_detachRuntime (void) +{ + return; +} diff --git a/src/watchy.h b/src/watchy.h index 43eb588..7418572 100644 --- a/src/watchy.h +++ b/src/watchy.h @@ -25,6 +25,9 @@ // get all the data no need to keep reading etc.. #define WTCY_PACKET_SIZE 256 +// hardcoded /tmp +#define WTCY_DEFAULT_FIFO "/tmp/watchy.fifo" + #ifdef __cplusplus extern "C" { #endif diff --git a/src/wtail.c b/src/wtail.c new file mode 100644 index 0000000..7db84e8 --- /dev/null +++ b/src/wtail.c @@ -0,0 +1,49 @@ +#include +#include + +int main (int argc char **argv) +{ + FILE *ps_pipe; + FILE *grep_pipe; + + int bytes_read; + int nbytes = 100; + char *my_string; + + /* Open our two pipes */ + ps_pipe = popen ("ps -A", "r"); + grep_pipe = popen ("grep init", "w"); + + /* Check that pipes are non-null, therefore open */ + if ((!ps_pipe) || (!grep_pipe)) + { + fprintf (stderr, + "One or both pipes failed.\n"); + return EXIT_FAILURE; + } + + /* Read from ps_pipe until two newlines */ + my_string = (char *) malloc (nbytes + 1); + bytes_read = getdelim (&my_string, &nbytes, "\n\n", ps_pipe); + + /* Close ps_pipe, checking for errors */ + if (pclose (ps_pipe) != 0) + { + fprintf (stderr, + "Could not run 'ps', or other error.\n"); + } + + /* Send output of 'ps -A' to 'grep init', with two newlines */ + fprintf (grep_pipe, "%s\n\n", my_string); + + /* Close grep_pipe, cehcking for errors */ + if (pclose (grep_pipe) != 0) + { + fprintf (stderr, + "Could not run 'grep', or other error.\n"); + } + + /* Exit! */ + return 0; +} +