@cfg_get.<group_name>.<var_name> is documented
[sip-router] / dprint.c
1 /*
2  * $Id$
3  *
4  * debug print 
5  *
6  *
7  * Copyright (C) 2001-2003 FhG Fokus
8  *
9  * This file is part of ser, a free SIP server.
10  *
11  * ser is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version
15  *
16  * For a license to use the ser software under conditions
17  * other than those described here, or to purchase support for this
18  * software, please contact iptel.org by e-mail at the following addresses:
19  *    info@iptel.org
20  *
21  * ser is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License 
27  * along with this program; if not, write to the Free Software 
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29  */
30
31  
32 #include "dprint.h"
33 #include "globals.h"
34 #include "pt.h"
35  
36 #include <stdarg.h>
37 #include <stdio.h>
38 #include <strings.h>
39
40 volatile int dprint_crit=0; /* signal protection: !=0 when dprint/LOG/DBG are
41                                                                 printing */
42
43 static char* str_fac[]={"LOG_AUTH","LOG_CRON","LOG_DAEMON",
44                                         "LOG_KERN","LOG_LOCAL0","LOG_LOCAL1",
45                                         "LOG_LOCAL2","LOG_LOCAL3","LOG_LOCAL4","LOG_LOCAL5",
46                                         "LOG_LOCAL6","LOG_LOCAL7","LOG_LPR","LOG_MAIL",
47                                         "LOG_NEWS","LOG_USER","LOG_UUCP",
48 #ifndef __OS_solaris
49                                         "LOG_AUTHPRIV","LOG_FTP","LOG_SYSLOG",
50 #endif
51                                         0};
52 static int int_fac[]={LOG_AUTH ,  LOG_CRON , LOG_DAEMON ,
53                                         LOG_KERN , LOG_LOCAL0 , LOG_LOCAL1 ,
54                                         LOG_LOCAL2 , LOG_LOCAL3 , LOG_LOCAL4 , LOG_LOCAL5 ,
55                                         LOG_LOCAL6 , LOG_LOCAL7 , LOG_LPR , LOG_MAIL ,
56                                         LOG_NEWS , LOG_USER , LOG_UUCP
57 #ifndef __OS_solaris
58                                         ,LOG_AUTHPRIV,LOG_FTP,LOG_SYSLOG
59 #endif
60                                         };
61
62
63 void dprint(char * format, ...)
64 {
65         va_list ap;
66
67         fprintf(stderr, "%2d(%d) ", process_no, my_pid());
68         va_start(ap, format);
69         vfprintf(stderr,format,ap);
70         fflush(stderr);
71         va_end(ap);
72 }
73
74
75 int str2facility(char *s)
76 {
77         int i;
78
79         for( i=0; str_fac[i] ; i++) {
80                 if (!strcasecmp(s,str_fac[i]))
81                         return int_fac[i];
82         }
83         return -1;
84 }