Browse code

core: add facility2str() function

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

Stefan Mititelu authored on 05/01/2016 11:24:08
Showing 2 changed files
... ...
@@ -90,13 +90,27 @@ int str2facility(char *s)
90 90
 {
91 91
 	int i;
92 92
 
93
-	for( i=0; str_fac[i] ; i++) {
93
+	for (i=0; str_fac[i]; i++) {
94 94
 		if (!strcasecmp(s,str_fac[i]))
95 95
 			return int_fac[i];
96 96
 	}
97 97
 	return -1;
98 98
 }
99 99
 
100
+char* facility2str(int fl, int *len)
101
+{
102
+	int i;
103
+
104
+	for (i=0; str_fac[i]; i++) {
105
+		if (fl == int_fac[i]) {
106
+			*len = strlen(str_fac[i]);
107
+			return str_fac[i];
108
+		}
109
+	}
110
+
111
+	return NULL;
112
+}
113
+
100 114
 /* fixup function for log_facility cfg parameter */
101 115
 int log_facility_fixup(void *handle, str *gname, str *name, void **val)
102 116
 {
... ...
@@ -160,6 +160,8 @@ extern volatile int dprint_crit;
160 160
 #endif
161 161
 
162 162
 int str2facility(char *s);
163
+char* facility2str(int fl, int *len);
164
+
163 165
 int log_facility_fixup(void *handle, str *gname, str *name, void **val);
164 166
 
165 167
 void dprint_color(int level);