#include #include #include #include #include #include #include "match.h" #include "server.h" const char *arg_shift(int *argc, char ***argv) { if (*argc < 1) return NULL; const char *result = *argv[0]; *argc -= 1; *argv += 1; return result; } int main(int argc, char *argv[]) { arg_shift(&argc, &argv); const char *socket_path = arg_shift(&argc, &argv); socket_path = socket_path == NULL ? "/tmp/jitterbug-unix0" : socket_path; /* we handle send() errors directly in the code */ signal(SIGPIPE, SIG_IGN); Bus *srv = bus_create(socket_path); if (srv == NULL) { fprintf(stderr, "server_create failed\n"); return EXIT_FAILURE; } printf("Listening on %s\n", socket_path); while (1) { if (bus_turn(srv) < 0) { fprintf(stderr, "server_turn failed (errno=%d, strerror=%s)\n", errno, strerror(errno)); bus_free(srv); return EXIT_FAILURE; } } bus_free(srv); return EXIT_SUCCESS; }