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