2016-09-09 21:52:56 +02:00
|
|
|
#include "../lib/pubsubd.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
void
|
|
|
|
ohshit(int rvalue, const char* str) {
|
|
|
|
fprintf(stderr, "%s\n", str);
|
|
|
|
exit(rvalue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void usage (char **argv) {
|
|
|
|
fprintf (stderr, "usage: %s path\n", argv[0]);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
if (argc != 2) {
|
|
|
|
usage (argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *spath = argv[1];
|
|
|
|
|
|
|
|
printf ("Listening on %s.\n", spath);
|
|
|
|
|
|
|
|
struct channels chans;
|
|
|
|
memset (&chans, 0, sizeof (struct channels));
|
|
|
|
|
2016-09-10 23:15:10 +02:00
|
|
|
for (int nb = 2, i = 0 ; nb > 0; i++, nb--) {
|
2016-09-09 21:52:56 +02:00
|
|
|
struct app_list_elm ale;
|
|
|
|
memset (&ale, 0, sizeof (struct app_list_elm));
|
|
|
|
|
|
|
|
struct channel chan;
|
|
|
|
memset (&chan, 0, sizeof (struct channel));
|
|
|
|
struct channel *c = &chan;
|
|
|
|
|
|
|
|
pubsubd_get_new_process (spath, &ale, &chans, &c);
|
|
|
|
|
2016-09-11 01:47:25 +02:00
|
|
|
printf ("print the channels\n");
|
2016-09-09 21:52:56 +02:00
|
|
|
printf ("--\n");
|
|
|
|
pubsubd_channels_print (&chans);
|
|
|
|
printf ("--\n");
|
|
|
|
printf ("still %d remaining processes\n", nb);
|
2016-09-10 17:16:39 +02:00
|
|
|
|
|
|
|
pubsubd_app_list_elm_free (&ale);
|
2016-09-09 21:52:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pubsubd_channels_del_all (&chans);
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|