Jelajahi Sumber

- rls excluded from the compile by default list (depends on external libs)
- added DEBUG(), ERR(), WARN(), INFO(), BUG() which can be used instead of
LOG(L_*, ). The new macros will add "DEBUG:", "ERROR:" a.s.o in front of the
message and also the filename and line number from where they were called
( DEBUG("x") in foo.c:23 is equiv. with DBG("DEBUG: foo.c:23: x"))

Andrei Pelinescu-Onciul 20 tahun lalu
induk
melakukan
a86d53b012
6 mengubah file dengan 47 tambahan dan 13 penghapusan
  1. 1 1
      Makefile
  2. 1 1
      Makefile.defs
  3. 1 1
      cfg.lex
  4. 3 3
      cfg.y
  5. 40 7
      dprint.h
  6. 1 0
      test/gcc_versions.txt

+ 1 - 1
Makefile

@@ -52,7 +52,7 @@ exclude_modules?= 			cpl ext extcmd \
 							jabber mysql \
 							cpl-c \
 							auth_radius group_radius uri_radius avp_radius \
-							pa
+							pa rls
 # always exclude the CVS dir
 override exclude_modules+= CVS $(skip_modules)
 

+ 1 - 1
Makefile.defs

@@ -61,7 +61,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 10
 SUBLEVEL =   99
-EXTRAVERSION = -dev23-tcp
+EXTRAVERSION = -dev24
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 1 - 1
cfg.lex

@@ -371,7 +371,7 @@ EAT_ABLE	[\ \t\b\r]
 <INITIAL>{AF}	{ count(); yylval.strval=yytext; return AF; }
 <INITIAL>{MYSELF}	{ count(); yylval.strval=yytext; return MYSELF; }
 
-<INITIAL>{DEBUG}	{ count(); yylval.strval=yytext; return DEBUG; }
+<INITIAL>{DEBUG}	{ count(); yylval.strval=yytext; return DEBUG_V; }
 <INITIAL>{FORK}		{ count(); yylval.strval=yytext; return FORK; }
 <INITIAL>{LOGSTDERROR}	{ yylval.strval=yytext; return LOGSTDERROR; }
 <INITIAL>{LOGFACILITY}	{ yylval.strval=yytext; return LOGFACILITY; }

+ 3 - 3
cfg.y

@@ -193,7 +193,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
 %token TLS
 
 /* config vars. */
-%token DEBUG
+%token DEBUG_V
 %token FORK
 %token LOGSTDERROR
 %token LOGFACILITY
@@ -406,8 +406,8 @@ id_lst:		phostport		{  $$=$1 ; }
 		;
 
 
-assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
-		| DEBUG EQUAL error  { yyerror("number  expected"); }
+assign_stm:	DEBUG_V EQUAL NUMBER { debug=$3; }
+		| DEBUG_V EQUAL error  { yyerror("number  expected"); }
 		| FORK  EQUAL NUMBER { dont_fork= ! $3; }
 		| FORK  EQUAL error  { yyerror("boolean value expected"); }
 		| LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }

+ 40 - 7
dprint.h

@@ -57,6 +57,24 @@ void dprint (char* format, ...);
 
 int str2facility(char *s);
 
+/* C >= 99 has __func__, older gcc versions have __FUNCTION__ */
+#if __STDC_VERSION__ < 199901L
+# if __GNUC__ >= 2
+#  define _FUNC_NAME_ __FUNCTION__
+# else
+#  define _FUNC_NAME_ ""
+# endif
+#else
+# define _FUNC_NAME_ __func__
+#endif
+
+
+#define XCT2STR(i) #i
+#define CT2STR(l) XCT2STR(l)
+
+#define LOC_INFO	__FILE__ ":" CT2STR(__LINE__) ": "
+
+
 
 #ifdef NO_DEBUG
 	#ifdef __SUNPRO_C
@@ -142,25 +160,25 @@ int str2facility(char *s);
 					else { \
 						switch(lev){ \
 							case L_CRIT: \
-								syslog(LOG_CRIT|log_facility, "CRIT: " fmt, ##args); \
+								syslog(LOG_CRIT|log_facility, fmt, ##args); \
 								break; \
 							case L_ALERT: \
-								syslog(LOG_ALERT|log_facility, "ALERT: " fmt, ##args); \
+								syslog(LOG_ALERT|log_facility, fmt, ##args); \
 								break; \
 							case L_ERR: \
-								syslog(LOG_ERR|log_facility, "ERROR: " fmt, ##args); \
+								syslog(LOG_ERR|log_facility, fmt, ##args); \
 								break; \
 							case L_WARN: \
-								syslog(LOG_WARNING|log_facility, "WARNING: " fmt, ##args);\
+								syslog(LOG_WARNING|log_facility, fmt, ##args);\
 								break; \
 							case L_NOTICE: \
-								syslog(LOG_NOTICE|log_facility, "NOTICE: " fmt, ##args); \
+								syslog(LOG_NOTICE|log_facility, fmt, ##args); \
 								break; \
 							case L_INFO: \
-								syslog(LOG_INFO|log_facility, "INFO: " fmt, ##args); \
+								syslog(LOG_INFO|log_facility, fmt, ##args); \
 								break; \
 							case L_DBG: \
-								syslog(LOG_DEBUG|log_facility, "DEBUG: " fmt, ##args); \
+								syslog(LOG_DEBUG|log_facility, fmt, ##args); \
 								break; \
 						} \
 					} \
@@ -184,4 +202,19 @@ int str2facility(char *s);
 	#endif
 #endif
 
+#ifdef __SUNPRO_C
+		#define DEBUG(...) DBG("DEBUG"            LOC_INFO __VA_ARGS__)
+		#define ERR(...)  LOG(L_ERR, "ERROR: "    LOC_INFO __VA_ARGS__)
+		#define WARN(...) LOG(L_WARN, "WARNING: " LOC_INFO __VA_ARGS__)
+		#define INFO(...) LOG(L_INFO, "INFO: "    LOC_INFO __VA_ARGS__)
+		#define BUG(...) LOG(L_CRIT, "BUG: "      LOC_INFO __VA_ARGS__)
+#else
+		#define DEBUG(fmt, args...) DBG("DEBUG "        LOC_INFO fmt, ## args)
+		#define ERR(fmt, args...) LOG(L_ERR, "ERROR: "  LOC_INFO fmt, ## args)
+		#define WARN(fmt, args...) LOG(L_WARN, "WARN: " LOC_INFO fmt, ## args)
+		#define INFO(fmt, args...) LOG(L_INFO, "INFO: " LOC_INFO fmt, ## args)
+		#define BUG(fmt, args...) LOG(L_CRIT, "BUG: "   LOC_INFO fmt, ## args)
+#endif
+
+
 #endif /* ifndef dprint_h */

+ 1 - 0
test/gcc_versions.txt

@@ -15,4 +15,5 @@ gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
 gcc-3.4 (GCC) 3.4.4 20041218 (prerelease) (Debian 3.4.3-7)
 powerpc-apple-darwin8-gcc-4.0.0 (GCC) 4.0.0 20041026 (Apple Computer, Inc. build 4061)
 gcc-4.0 (GCC) 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)
+gcc-4.0.1 (GCC) 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)