aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c110
1 files changed, 0 insertions, 110 deletions
diff --git a/util.c b/util.c
deleted file mode 100644
index 76ceab8..0000000
--- a/util.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* This file is part of libbrandt.
- * Copyright (C) 2016 GNUnet e.V.
- *
- * libbrandt is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * libbrandt is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * libbrandt. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * @file util.c
- * @brief Implementation of common utility functions.
- * @author Markus Teich
- */
-
-#include "brandt_config.h"
-
-#include <errno.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "util.h"
-
-
-static FILE *logstream = NULL;
-
-
-/**
- * setlog sets another output for logging.
- *
- * @param[in] stream The new logging target.
- */
-void
-setlog (FILE *stream)
-{
- logstream = stream;
-}
-
-
-/**
- * xvprintf prints a formatstring with prefix "libbrandt: ". If the format
- * string ends with a ':', the strerror() from errno.h output will be appended.
- * The output is always terminated with a newline.
- *
- * @param[in] fmt The format string
- * @param[in] ap The inputs to the format string
- */
-static void
-xvprintf (const char *fmt, va_list ap)
-{
- fputs ("libbrandt: ", logstream ? logstream : stderr);
-
- vfprintf (logstream ? logstream : stderr, fmt, ap);
-
- if (fmt[0] && fmt[strlen (fmt) - 1] == ':')
- {
- fputc (' ', logstream ? logstream : stderr);
- fputs (strerror (errno), logstream ? logstream : stderr);
- }
- else
- {
- fputc ('\n', logstream ? logstream : stderr);
- }
-}
-
-
-/**
- * eprintf prints an error message and then calls abort() to terminate the
- * process.
- *
- * @param[in] fmt The format string
- * @param[in] ... The inputs to the format string
- */
-void
-eprintf (const char *fmt, ...)
-{
- va_list ap;
-
- va_start (ap, fmt);
- xvprintf (fmt, ap);
- va_end (ap);
-
- abort ();
-}
-
-
-/**
- * weprintf prints a warning message
- *
- * @param[in] fmt The format string
- * @param[in] ... The inputs to the format string
- */
-void
-weprintf (const char *fmt, ...)
-{
- va_list ap;
-
- va_start (ap, fmt);
- xvprintf (fmt, ap);
- va_end (ap);
-}