xref: /titanic_50/usr/src/cmd/ipf/lib/common/loglevel.c (revision 3db86aab554edbb4244c8d1a1c90f152eee768af)
1 /*
2  * Copyright (C) 1993-2001 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * $Id: loglevel.c,v 1.5 2001/06/09 17:09:24 darrenr Exp $
7  */
8 
9 #include "ipf.h"
10 
11 
12 int loglevel(cpp, facpri, linenum)
13 char **cpp;
14 u_int *facpri;
15 int linenum;
16 {
17 	int fac, pri;
18 	char *s;
19 
20 	fac = 0;
21 	pri = 0;
22 	if (!*++cpp) {
23 		fprintf(stderr, "%d: %s\n", linenum,
24 			"missing identifier after level");
25 		return -1;
26 	}
27 
28 	s = strchr(*cpp, '.');
29 	if (s) {
30 		*s++ = '\0';
31 		fac = fac_findname(*cpp);
32 		if (fac == -1) {
33 			fprintf(stderr, "%d: %s %s\n", linenum,
34 				"Unknown facility", *cpp);
35 			return -1;
36 		}
37 		pri = pri_findname(s);
38 		if (pri == -1) {
39 			fprintf(stderr, "%d: %s %s\n", linenum,
40 				"Unknown priority", s);
41 			return -1;
42 		}
43 	} else {
44 		pri = pri_findname(*cpp);
45 		if (pri == -1) {
46 			fprintf(stderr, "%d: %s %s\n", linenum,
47 				"Unknown priority", *cpp);
48 			return -1;
49 		}
50 	}
51 	*facpri = fac|pri;
52 	return 0;
53 }
54