"Fossies" - the Fresh Open Source Software Archive

Member "libspf2-1.2.10/src/libspf2/spf_log_stdio.c" (28 Jan 2012, 1680 Bytes) of package /linux/privat/libspf2-1.2.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "spf_log_stdio.c" see the Fossies "Dox" file reference documentation.

    1 /* 
    2  * This program is free software; you can redistribute it and/or modify
    3  * it under the terms of either:
    4  * 
    5  *   a) The GNU Lesser General Public License as published by the Free
    6  *      Software Foundation; either version 2.1, or (at your option) any
    7  *      later version,
    8  * 
    9  *   OR
   10  * 
   11  *   b) The two-clause BSD license.
   12  *
   13  * These licenses can be found with the distribution in the file LICENSES
   14  */
   15 
   16 
   17 #include "spf_sys_config.h"
   18 
   19 
   20 #ifdef STDC_HEADERS
   21 # include <stdio.h>        /* stdin / stdout */
   22 # include <stdlib.h>       /* malloc / free */
   23 #endif
   24 
   25 #include "spf.h"
   26 
   27 /**
   28  * @file
   29  * Audited, 2008-09-13, Shevek.
   30  * Make sure no file:line combo is >127 bytes long.
   31  */
   32 
   33 void
   34 SPF_error_stdio(const char *file, int line, const char *errmsg)
   35 {
   36     char    buf[128];
   37     if (file) {
   38         snprintf(buf, sizeof(buf), "%s:%d", file, line);
   39         fprintf(stderr, "%-20s Error: %s\n", buf, errmsg);
   40     }
   41     else {
   42         fprintf(stderr, "Error: %s\n", errmsg);
   43     }
   44     abort();
   45 }
   46 
   47 void
   48 SPF_warning_stdio(const char *file, int line, const char *errmsg)
   49 {
   50     char    buf[128];
   51     if (file) {
   52         snprintf(buf, sizeof(buf), "%s:%d", file, line);
   53         fprintf(stderr, "%-20s Warning: %s\n", buf, errmsg);
   54     }
   55     else {
   56         fprintf(stderr, "Warning: %s\n", errmsg);
   57     }
   58 }
   59 
   60 void
   61 SPF_info_stdio(const char *file __attribute__((unused)), int line __attribute__((unused)), const char *errmsg)
   62 {
   63     printf("%s\n", errmsg);
   64 }
   65 
   66 void
   67 SPF_debug_stdio(const char *file, int line, const char *errmsg)
   68 {
   69     char    buf[128];
   70     if (file) {
   71         snprintf(buf, sizeof(buf), "%s:%d", file, line);
   72         fprintf(stderr, "%-20s Debug: %s\n", buf, errmsg);
   73     }
   74     else {
   75         fprintf(stderr, "Debug: %s\n", errmsg);
   76     }
   77 }