dprint.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. * [email protected]
  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. #include "globals.h"
  31. #include "dprint.h"
  32. #include <stdarg.h>
  33. #include <stdio.h>
  34. #include <strings.h>
  35. #ifndef NO_SIG_DEBUG
  36. /* signal protection: !=0 when LOG/DBG/... are printing */
  37. volatile int dprint_crit = 0;
  38. #endif
  39. static char* str_fac[]={"LOG_AUTH","LOG_CRON","LOG_DAEMON",
  40. "LOG_KERN","LOG_LOCAL0","LOG_LOCAL1",
  41. "LOG_LOCAL2","LOG_LOCAL3","LOG_LOCAL4","LOG_LOCAL5",
  42. "LOG_LOCAL6","LOG_LOCAL7","LOG_LPR","LOG_MAIL",
  43. "LOG_NEWS","LOG_USER","LOG_UUCP",
  44. #ifndef __OS_solaris
  45. "LOG_AUTHPRIV","LOG_FTP","LOG_SYSLOG",
  46. #endif
  47. 0};
  48. static int int_fac[]={LOG_AUTH , LOG_CRON , LOG_DAEMON ,
  49. LOG_KERN , LOG_LOCAL0 , LOG_LOCAL1 ,
  50. LOG_LOCAL2 , LOG_LOCAL3 , LOG_LOCAL4 , LOG_LOCAL5 ,
  51. LOG_LOCAL6 , LOG_LOCAL7 , LOG_LPR , LOG_MAIL ,
  52. LOG_NEWS , LOG_USER , LOG_UUCP,
  53. #ifndef __OS_solaris
  54. LOG_AUTHPRIV,LOG_FTP,LOG_SYSLOG,
  55. #endif
  56. 0};
  57. struct log_level_info log_level_info[] = {
  58. {"ALERT", LOG_ALERT}, /* L_ALERT */
  59. {"BUG", LOG_CRIT}, /* L_CRIT */
  60. {"ERROR", LOG_ERR}, /* L_ERR */
  61. {"WARNING", LOG_WARNING}, /* L_WARN */
  62. {"NOTICE", LOG_NOTICE}, /* L_NOTICE */
  63. {"INFO", LOG_INFO}, /* L_INFO */
  64. {"DEBUG", LOG_DEBUG} /* L_DBG */
  65. };
  66. int str2facility(char *s)
  67. {
  68. int i;
  69. for( i=0; str_fac[i] ; i++) {
  70. if (!strcasecmp(s,str_fac[i]))
  71. return int_fac[i];
  72. }
  73. return -1;
  74. }
  75. /* fixup function for log_facility cfg parameter */
  76. int log_facility_fixup(void *handle, str *gname, str *name, void **val)
  77. {
  78. int i;
  79. if ((i = str2facility((char *)*val)) == -1) {
  80. LOG(L_ERR, "log_facility_fixup: invalid log facility: %s\n",
  81. (char *)*val);
  82. return -1;
  83. }
  84. *val = (void *)(long)i;
  85. return 0;
  86. }