-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetFacilityName.c
48 lines (41 loc) · 1.15 KB
/
getFacilityName.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Copyright 2011, University Corporation for Atmospheric Research.
* See COPYRIGHT file for copying and redistribution conditions.
*/
#define _XOPEN_SOURCE 500
#include <stddef.h>
#include <syslog.h>
#include "config.h"
#include "getFacilityName.h" /* eat own dog food */
typedef struct _code {
char* c_name;
int c_val;
} CODE;
static CODE facilitynames[] = {
{ "local0", LOG_LOCAL0 },
{ "local1", LOG_LOCAL1 },
{ "local2", LOG_LOCAL2 },
{ "local3", LOG_LOCAL3 },
{ "local4", LOG_LOCAL4 },
{ "local5", LOG_LOCAL5 },
{ "local6", LOG_LOCAL6 },
{ "local7", LOG_LOCAL7 },
{ NULL, -1 }
};
/**
* Returns the name corresponding to a logging facility.
*
* @return The name corresponding to the given logging facility.
*/
const char* getFacilityName(
const unsigned facility) /**< [in] Integer representation of the logging
* facility */
{
int i;
const char* name = NULL;
for (i = 0; NULL != facilitynames[i].c_name; i++) {
if (facility == facilitynames[i].c_val)
return facilitynames[i].c_name;
}
return "unknown";
}