42 lines
918 B
C
42 lines
918 B
C
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.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;
|
|
|
|
struct jb_server *srv = jb_server_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 (jb_server_turn(srv) < 0) {
|
|
fprintf(stderr, "server_turn failed\n");
|
|
jb_server_free(srv);
|
|
return EXIT_FAILURE;
|
|
}
|
|
}
|
|
|
|
jb_server_free(srv);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|