"Fossies" - the Fresh Open Source Software Archive

Member "libspf2-1.2.10/src/libspf2/spf_log.c" (28 Jan 2012, 3691 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.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 <stdlib.h>       /* malloc / free */
   22 # include <stdarg.h>
   23 # include <stdio.h>
   24 #endif
   25 
   26 #include "spf.h"
   27 #include "spf_internal.h"
   28 
   29 
   30 /*
   31  * standard expanded error formating routines
   32  */
   33 
   34 void
   35 SPF_errorx( const char *file, int line, const char *format, ... )
   36 {
   37     char    errmsg[SPF_SYSLOG_SIZE];
   38     va_list ap;
   39     
   40     if (SPF_error_handler == NULL)
   41         abort();
   42     
   43     va_start(ap, format);
   44     vsnprintf(errmsg, sizeof(errmsg), format, ap);
   45     va_end(ap);
   46 
   47     SPF_error_handler(file, line, errmsg);
   48     abort();
   49 }
   50 
   51 
   52 void
   53 SPF_warningx( const char *file, int line, const char *format, ... )
   54 {
   55     char    errmsg[SPF_SYSLOG_SIZE];
   56     va_list ap;
   57 
   58     if (SPF_warning_handler == NULL)
   59         return;
   60 
   61     va_start(ap, format);
   62     vsnprintf(errmsg, sizeof(errmsg), format, ap);
   63     va_end(ap);
   64 
   65     SPF_warning_handler(file, line, errmsg);
   66 }
   67 
   68 
   69 void
   70 SPF_infox( const char *file, int line, const char *format, ... )
   71 {
   72     char    errmsg[SPF_SYSLOG_SIZE];
   73     va_list ap;
   74 
   75     if (SPF_info_handler == NULL)
   76         return;
   77 
   78     va_start(ap, format);
   79     vsnprintf(errmsg, sizeof(errmsg), format, ap);
   80     va_end(ap);
   81 
   82     SPF_info_handler(file, line, errmsg);
   83 }
   84 
   85 
   86 void
   87 SPF_debugx( const char *file, int line, const char *format, ... )
   88 {
   89     char    errmsg[SPF_SYSLOG_SIZE];
   90     va_list ap;
   91 
   92     if (SPF_debug_handler == NULL)
   93         return;
   94 
   95     va_start(ap, format);
   96     vsnprintf(errmsg, sizeof(errmsg), format, ap);
   97     va_end(ap);
   98 
   99     SPF_debug_handler(file, line, errmsg);
  100 }
  101 
  102 
  103 
  104 /*
  105  * error reporting routines that accept a va_list
  106  */
  107 
  108 void
  109 SPF_errorv(const char *file, int line, const char *format, va_list ap)
  110 {
  111     char    errmsg[SPF_SYSLOG_SIZE];
  112     
  113     if (SPF_error_handler == NULL)
  114         abort();
  115     
  116     vsnprintf(errmsg, sizeof(errmsg), format, ap);
  117     SPF_error_handler( file, line, errmsg );
  118 
  119     abort();
  120 }
  121 
  122 
  123 void
  124 SPF_warningv(const char *file, int line, const char *format, va_list ap)
  125 {
  126     char    errmsg[SPF_SYSLOG_SIZE];
  127     
  128     if (SPF_warning_handler == NULL)
  129         return;
  130     
  131     vsnprintf(errmsg, sizeof(errmsg), format, ap);
  132     SPF_warning_handler(file, line, errmsg);
  133 }
  134 
  135 
  136 void
  137 SPF_infov(const char *file, int line, const char *format, va_list ap)
  138 {
  139     char    errmsg[SPF_SYSLOG_SIZE];
  140     
  141     if (SPF_info_handler == NULL)
  142         return;
  143     
  144     vsnprintf(errmsg, sizeof(errmsg), format, ap);
  145     SPF_info_handler(file, line, errmsg);
  146 }
  147 
  148 
  149 void
  150 SPF_debugv(const char *file, int line, const char *format, va_list ap)
  151 {
  152     char    errmsg[SPF_SYSLOG_SIZE];
  153     
  154     if (SPF_debug_handler == NULL)
  155         return;
  156     
  157     vsnprintf(errmsg, sizeof(errmsg), format, ap);
  158     SPF_debug_handler(file, line, errmsg);
  159 }
  160 
  161 
  162 /*
  163  * reporting routines for braindead compilers
  164  */
  165 
  166 void
  167 SPF_errorx2(const char *format, ...)
  168 {
  169     va_list ap;
  170     va_start(ap, format);
  171     SPF_errorv(NULL, 0, format, ap);
  172     va_end(ap);
  173 }
  174 
  175 void
  176 SPF_warningx2(const char *format, ...)
  177 {
  178     va_list ap;
  179     va_start(ap, format);
  180     SPF_warningv(NULL, 0, format, ap);
  181     va_end(ap);
  182 }
  183 
  184 void
  185 SPF_infox2(const char *format, ...)
  186 {
  187     va_list ap;
  188     va_start(ap, format);
  189     SPF_infov(NULL, 0, format, ap);
  190     va_end(ap);
  191 }
  192 
  193 void
  194 SPF_debugx2(const char *format, ...)
  195 {
  196     va_list ap;
  197     va_start(ap, format);
  198     SPF_debugv(NULL, 0, format, ap);
  199     va_end(ap);
  200 }