coding style for util.c

This commit is contained in:
Markus Teich 2016-06-12 01:08:06 +02:00
parent ec1ce068ed
commit e0f63621dd

76
util.c
View File

@ -1,4 +1,23 @@
/* 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 TODO
*/
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -6,42 +25,63 @@
#include "util.h" #include "util.h"
static void xvprintf(const char *, va_list); static void xvprintf (const char *, va_list);
/**
* eprintf
*
* @param fmt TODO
* @param
*/
void void
eprintf(const char *fmt, ...) eprintf (const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start (ap, fmt);
xvprintf(fmt, ap); xvprintf (fmt, ap);
va_end(ap); va_end (ap);
abort(); abort ();
} }
/**
* weprintf
*
* @param fmt TODO
* @param
*/
void void
weprintf(const char *fmt, ...) weprintf (const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start (ap, fmt);
xvprintf(fmt, ap); xvprintf (fmt, ap);
va_end(ap); va_end (ap);
} }
/**
* xvprintf
*
* @param fmt TODO
* @param ap TODO
*/
void void
xvprintf(const char *fmt, va_list ap) xvprintf (const char *fmt, va_list ap)
{ {
/**TODO: provide other logging target than stderr */ /**TODO: provide other logging target than stderr */
fputs("libbrandt: ", stderr); fputs ("libbrandt: ", stderr);
vfprintf(stderr, fmt, ap); vfprintf (stderr, fmt, ap);
if (fmt[0] && fmt[strlen(fmt)-1] == ':') { if (fmt[0] && fmt[strlen (fmt) - 1] == ':')
fputc(' ', stderr); {
perror(NULL); fputc (' ', stderr);
} else { perror (NULL);
fputc('\n', stderr); }
else
{
fputc ('\n', stderr);
} }
} }