diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-07-15 12:14:22 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-07-15 12:14:22 +0200 |
| commit | 3da360332b38ba50e2a03f4b9287bc916523e492 (patch) | |
| tree | 7aff4d4a9cc3d1c2a9c5450cb2b3f22611f5dad2 | |
| parent | 5056c0636009ff72a976e366b1496d5a98d47f75 (diff) | |
Minor changes
| -rw-r--r-- | jean | 0 | ||||
| -rw-r--r-- | src/publisher.c | 31 | ||||
| -rw-r--r-- | src/utils.h | 3 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/publisher.c b/src/publisher.c index afbf45d..8764294 100644 --- a/src/publisher.c +++ b/src/publisher.c @@ -5,11 +5,42 @@ #include <zmq.h> #include <assert.h> #include <time.h> +#include <dirent.h> #include "utils.h" +// Global: +char *__logdir; +int __loginterval; + int main (int argc, char *argv []) { + if(argc != 3){ + printf("Usage: %s <abslogdir> <loginterval>",argv[0]); + exit(1); + } + + //----- Init global variables + __logdir=argv[1]; + __loginterval=atoi(argv[2]); + + DIR *dr = opendir(__logdir); + struct dirent *de; // Pointer for directory entry + for(int i=0;i<0;i++){ + int interval=INTERVAL(__loginterval); + int interval_next=INTERVAL_NEXT(__loginterval); + while ((de = readdir(dr)) != NULL){ + if(strcmp(de->d_name,".") && strcmp(de->d_name,"..")){ + char *client=de->d_name; + printf("aa%s\n",client); + } + } + } + closedir(dr); + + + + return 0; // Prepare our context and publisher void *context = zmq_ctx_new (); void *publisher = zmq_socket (context, ZMQ_PUB); diff --git a/src/utils.h b/src/utils.h index 01e0c33..af74328 100644 --- a/src/utils.h +++ b/src/utils.h @@ -18,6 +18,9 @@ #define INTERVAL(duration)\ ((TIMESTAMP()) - ((TIMESTAMP())%(duration))) +#define INTERVAL_NEXT(duration)\ + ((INTERVAL(duration))+(duration)) + #define INTERVAL_LAST(duration)\ (INTERVAL(INTERVAL((TIMESTAMP()),(duration))-1,(duration))) |
