Split server out.

This commit is contained in:
Ian Gulliver
2016-02-22 21:53:25 -08:00
parent c6e1eb9d42
commit bc9219b4a8
5 changed files with 23 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ LIBS ?= -ljansson
OBJ_NETWORK = incoming.o outgoing.o receive.o send.o
OBJ_PROTOCOL = airspy_adsb.o beast.o json.o raw.o stats.o
OBJ_UTIL = buf.o hex.o opts.o packet.o peer.o rand.o uuid.o wakeup.o
OBJ_UTIL = buf.o hex.o opts.o packet.o peer.o rand.o server.o uuid.o wakeup.o
all: adsbus

View File

@@ -15,6 +15,7 @@
#include "rand.h"
#include "receive.h"
#include "send.h"
#include "server.h"
#include "stats.h"
#include "wakeup.h"
@@ -99,6 +100,7 @@ int main(int argc, char *argv[]) {
hex_init();
rand_init();
server_init();
wakeup_init();
peer_init();

View File

@@ -10,12 +10,12 @@
#include <sys/epoll.h>
#include <unistd.h>
#include "server.h"
#include "uuid.h"
#include "wakeup.h"
#include "peer.h"
static char server_id[UUID_LEN];
static int peer_epoll_fd;
static int peer_cancel_fd;
static bool peer_canceled = false;
@@ -32,8 +32,6 @@ static void peer_cancel_handler(struct peer *peer) {
}
void peer_init() {
uuid_gen(server_id);
peer_epoll_fd = epoll_create1(0);
assert(peer_epoll_fd >= 0);

13
adsbus/server.c Normal file
View File

@@ -0,0 +1,13 @@
#include <stdio.h>
#include "uuid.h"
#include "server.h"
char server_id[UUID_LEN];
char server_version[] = "https://github.com/flamingcowtv/adsb-tools#1";
void server_init() {
uuid_gen(server_id);
fprintf(stderr, "X %s: Server start\n", server_id);
}

6
adsbus/server.h Normal file
View File

@@ -0,0 +1,6 @@
#pragma once
extern char server_id[];
extern char server_version[];
void server_init();