[sr-dev] git:master:f8a6d4e3: core: add facility2str() function

Stefan Mititelu stefan.mititelu at 1and1.ro
Wed Jan 6 15:13:40 CET 2016


Module: kamailio
Branch: master
Commit: f8a6d4e370bfe95d4968a1c29d275a91cdda12ce
URL: https://github.com/kamailio/kamailio/commit/f8a6d4e370bfe95d4968a1c29d275a91cdda12ce

Author: Stefan Mititelu <stefan.mititelu at 1and1.ro>
Committer: Stefan Mititelu <stefan.mititelu at 1and1.ro>
Date: 2016-01-05T13:24:08+02:00

core: add facility2str() function

Add support to get the facility number given the facility string.

---

Modified: dprint.c
Modified: dprint.h

---

Diff:  https://github.com/kamailio/kamailio/commit/f8a6d4e370bfe95d4968a1c29d275a91cdda12ce.diff
Patch: https://github.com/kamailio/kamailio/commit/f8a6d4e370bfe95d4968a1c29d275a91cdda12ce.patch

---

diff --git a/dprint.c b/dprint.c
index 0a5c0c3..269dd83 100644
--- a/dprint.c
+++ b/dprint.c
@@ -90,13 +90,27 @@ int str2facility(char *s)
 {
 	int i;
 
-	for( i=0; str_fac[i] ; i++) {
+	for (i=0; str_fac[i]; i++) {
 		if (!strcasecmp(s,str_fac[i]))
 			return int_fac[i];
 	}
 	return -1;
 }
 
+char* facility2str(int fl, int *len)
+{
+	int i;
+
+	for (i=0; str_fac[i]; i++) {
+		if (fl == int_fac[i]) {
+			*len = strlen(str_fac[i]);
+			return str_fac[i];
+		}
+	}
+
+	return NULL;
+}
+
 /* fixup function for log_facility cfg parameter */
 int log_facility_fixup(void *handle, str *gname, str *name, void **val)
 {
diff --git a/dprint.h b/dprint.h
index 35d5a0d..5f03445 100644
--- a/dprint.h
+++ b/dprint.h
@@ -160,6 +160,8 @@ extern volatile int dprint_crit;
 #endif
 
 int str2facility(char *s);
+char* facility2str(int fl, int *len);
+
 int log_facility_fixup(void *handle, str *gname, str *name, void **val);
 
 void dprint_color(int level);




More information about the sr-dev mailing list