From 401ff80ed66f0726ac32518800983d133538a93a Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 12 Dec 2023 14:33:54 +0100 Subject: [PATCH] more lib stuff inside clients --- client/Makefile | 2 +- client/log.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ lib/Makefile | 6 ++++- sysdep/unix/Makefile | 2 ++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 client/log.c diff --git a/client/Makefile b/client/Makefile index 4f972815..434bb86b 100644 --- a/client/Makefile +++ b/client/Makefile @@ -1,4 +1,4 @@ -src := commands.c util.c client.c +src := commands.c util.c client.c log.c obj := $(src-o-files) $(all-client) diff --git a/client/log.c b/client/log.c new file mode 100644 index 00000000..acb8719a --- /dev/null +++ b/client/log.c @@ -0,0 +1,57 @@ +/* + * BIRD Client Logging Stubs + * + * (c) 2023 Maria Matejka + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include "nest/bird.h" + +#include +#include +#include + +int shutting_down; + +void write_msg(va_list args, const char *msg, const char *type) +{ + char buf[4096]; + bvsnprintf(buf, sizeof buf, msg, args); + fputs(type, stderr); + fputs(": ", stderr); + fputs(buf, stderr); + fputc('\n', stderr); +} + +void cf_error(const char *msg, ...) +{ + va_list args; + va_start(args, msg); + write_msg(args, msg, "error"); + va_end(args); + exit(1); +} + +void log_msg(const char *msg, ...) +{ + va_list args; + va_start(args, msg); + write_msg(args, msg, "info"); + va_end(args); + exit(1); +} + +void debug(const char *msg, ...) +{ + va_list args; + va_start(args, msg); + write_msg(args, msg, "debug"); + va_end(args); + exit(1); +} + +/* Ignore all events for now */ +struct event; +void ev_schedule(struct event *e UNUSED) +{ } diff --git a/lib/Makefile b/lib/Makefile index 812f721c..b7883ef9 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,4 +1,8 @@ -src := bitmap.c bitops.c blake2s.c blake2b.c checksum.c event.c flowspec.c idm.c ip.c lists.c mac.c md5.c mempool.c net.c patmatch.c printf.c resource.c sha1.c sha256.c sha512.c slab.c slists.c strtoul.c tbf.c timer.c xmalloc.c +src := bitmap.c bitops.c blake2s.c blake2b.c checksum.c flowspec.c idm.c ip.c lists.c mac.c md5.c mempool.c net.c patmatch.c printf.c resource.c sha1.c sha256.c sha512.c slab.c slists.c strtoul.c xmalloc.c +obj := $(src-o-files) +$(all-client) + +src += event.c timer.c tbf.c obj := $(src-o-files) $(all-daemon) diff --git a/sysdep/unix/Makefile b/sysdep/unix/Makefile index d0d36b5f..92344676 100644 --- a/sysdep/unix/Makefile +++ b/sysdep/unix/Makefile @@ -4,5 +4,7 @@ $(all-daemon) $(cf-local) $(conf-y-targets): $(s)krt.Y +$(client): $(addprefix $(o),alloc.o) + src := $(filter-out main.c, $(src)) tests_objs := $(tests_objs) $(src-o-files)