| 1 |
/**************************************************************************/ |
| 2 |
/* */ |
| 3 |
/* This file is part of Frama-C. */ |
| 4 |
/* */ |
| 5 |
/* Copyright (C) 2007-2022 */ |
| 6 |
/* CEA (Commissariat à l'énergie atomique et aux énergies */ |
| 7 |
/* alternatives) */ |
| 8 |
/* */ |
| 9 |
/* you can redistribute it and/or modify it under the terms of the GNU */ |
| 10 |
/* Lesser General Public License as published by the Free Software */ |
| 11 |
/* Foundation, version 2.1. */ |
| 12 |
/* */ |
| 13 |
/* It is distributed in the hope that it will be useful, */ |
| 14 |
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 15 |
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
| 16 |
/* GNU Lesser General Public License for more details. */ |
| 17 |
/* */ |
| 18 |
/* See the GNU Lesser General Public License version 2.1 */ |
| 19 |
/* for more details (enclosed in the file licenses/LGPLv2.1). */ |
| 20 |
/* */ |
| 21 |
/**************************************************************************/ |
| 22 |
|
| 23 |
#ifndef __FC_SYSLOG_H |
| 24 |
#define __FC_SYSLOG_H |
| 25 |
#include "features.h" |
| 26 |
__PUSH_FC_STDLIB |
| 27 |
#include "__fc_define_null.h" |
| 28 |
#include "stdarg.h" |
| 29 |
|
| 30 |
__BEGIN_DECLS |
| 31 |
|
| 32 |
typedef struct __fc_code { |
| 33 |
const char *c_name; |
| 34 |
int c_val; |
| 35 |
} CODE; |
| 36 |
|
| 37 |
#define LOG_PID 0x01 /* log the pid with each message */ |
| 38 |
#define LOG_CONS 0x02 /* log on the console if errors in sending */ |
| 39 |
#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ |
| 40 |
#define LOG_NDELAY 0x08 /* don't delay open */ |
| 41 |
#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ |
| 42 |
#define LOG_PERROR 0x20 /* log to stderr as well */ |
| 43 |
|
| 44 |
#define LOG_KERN (0<<3) /* kernel messages */ |
| 45 |
#define LOG_USER (1<<3) /* random user-level messages */ |
| 46 |
#define LOG_MAIL (2<<3) /* mail system */ |
| 47 |
#define LOG_DAEMON (3<<3) /* system daemons */ |
| 48 |
#define LOG_AUTH (4<<3) /* security/authorization messages */ |
| 49 |
#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ |
| 50 |
#define LOG_LPR (6<<3) /* line printer subsystem */ |
| 51 |
#define LOG_NEWS (7<<3) /* network news subsystem */ |
| 52 |
#define LOG_UUCP (8<<3) /* UUCP subsystem */ |
| 53 |
#define LOG_CRON (9<<3) /* clock daemon */ |
| 54 |
#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ |
| 55 |
#define LOG_FTP (11<<3) /* ftp daemon */ |
| 56 |
|
| 57 |
/* other codes through 15 reserved for system use */ |
| 58 |
#define LOG_LOCAL0 (16<<3) /* reserved for local use */ |
| 59 |
#define LOG_LOCAL1 (17<<3) /* reserved for local use */ |
| 60 |
#define LOG_LOCAL2 (18<<3) /* reserved for local use */ |
| 61 |
#define LOG_LOCAL3 (19<<3) /* reserved for local use */ |
| 62 |
#define LOG_LOCAL4 (20<<3) /* reserved for local use */ |
| 63 |
#define LOG_LOCAL5 (21<<3) /* reserved for local use */ |
| 64 |
#define LOG_LOCAL6 (22<<3) /* reserved for local use */ |
| 65 |
#define LOG_LOCAL7 (23<<3) /* reserved for local use */ |
| 66 |
|
| 67 |
#define LOG_NFACILITIES 24 /* current number of facilities */ |
| 68 |
#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ |
| 69 |
/* facility of pri */ |
| 70 |
#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) |
| 71 |
#define LOG_PRIMASK 0x07 |
| 72 |
#define LOG_PRI(p) ((p) & LOG_PRIMASK) |
| 73 |
#define LOG_MAKEPRI(fac, pri) ((fac) | (pri)) |
| 74 |
#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ |
| 75 |
/* mark "facility" */ |
| 76 |
#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) |
| 77 |
|
| 78 |
CODE facilitynames[] = |
| 79 |
{ |
| 80 |
{ "auth", LOG_AUTH }, |
| 81 |
{ "authpriv", LOG_AUTHPRIV }, |
| 82 |
{ "cron", LOG_CRON }, |
| 83 |
{ "daemon", LOG_DAEMON }, |
| 84 |
{ "ftp", LOG_FTP }, |
| 85 |
{ "kern", LOG_KERN }, |
| 86 |
{ "lpr", LOG_LPR }, |
| 87 |
{ "mail", LOG_MAIL }, |
| 88 |
{ "mark", INTERNAL_MARK }, /* INTERNAL */ |
| 89 |
{ "news", LOG_NEWS }, |
| 90 |
{ "security", LOG_AUTH }, /* DEPRECATED */ |
| 91 |
{ "syslog", LOG_SYSLOG }, |
| 92 |
{ "user", LOG_USER }, |
| 93 |
{ "uucp", LOG_UUCP }, |
| 94 |
{ "local0", LOG_LOCAL0 }, |
| 95 |
{ "local1", LOG_LOCAL1 }, |
| 96 |
{ "local2", LOG_LOCAL2 }, |
| 97 |
{ "local3", LOG_LOCAL3 }, |
| 98 |
{ "local4", LOG_LOCAL4 }, |
| 99 |
{ "local5", LOG_LOCAL5 }, |
| 100 |
{ "local6", LOG_LOCAL6 }, |
| 101 |
{ "local7", LOG_LOCAL7 }, |
| 102 |
{ NULL, -1 } |
| 103 |
}; |
| 104 |
|
| 105 |
#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ |
| 106 |
#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ |
| 107 |
|
| 108 |
#define LOG_EMERG 0 |
| 109 |
#define LOG_ALERT 1 |
| 110 |
#define LOG_CRIT 2 |
| 111 |
#define LOG_ERR 3 |
| 112 |
#define LOG_WARNING 4 |
| 113 |
#define LOG_NOTICE 5 |
| 114 |
#define LOG_INFO 6 |
| 115 |
#define LOG_DEBUG 7 |
| 116 |
|
| 117 |
|
| 118 |
CODE prioritynames[] = |
| 119 |
{ |
| 120 |
{ "alert", LOG_ALERT }, |
| 121 |
{ "crit", LOG_CRIT }, |
| 122 |
{ "debug", LOG_DEBUG }, |
| 123 |
{ "emerg", LOG_EMERG }, |
| 124 |
{ "err", LOG_ERR }, |
| 125 |
{ "error", LOG_ERR }, /* DEPRECATED */ |
| 126 |
{ "info", LOG_INFO }, |
| 127 |
{ "none", INTERNAL_NOPRI }, /* INTERNAL */ |
| 128 |
{ "notice", LOG_NOTICE }, |
| 129 |
{ "panic", LOG_EMERG }, /* DEPRECATED */ |
| 130 |
{ "warn", LOG_WARNING }, /* DEPRECATED */ |
| 131 |
{ "warning", LOG_WARNING }, |
| 132 |
{ NULL, -1 } |
| 133 |
}; |
| 134 |
|
| 135 |
/*@ assigns \nothing ; */ |
| 136 |
extern void closelog(void); |
| 137 |
/*@ assigns \nothing ; */ |
| 138 |
extern void openlog(const char *, int, int); |
| 139 |
/*@ assigns \nothing ; */ |
| 140 |
extern int setlogmask(int); |
| 141 |
/*@ assigns \nothing ; */ |
| 142 |
extern void syslog(int, const char *, ...); |
| 143 |
|
| 144 |
// Not POSIX, but present in glibc |
| 145 |
/*@ assigns \nothing ; */ |
| 146 |
extern void vsyslog(int, const char *, va_list); |
| 147 |
|
| 148 |
__END_DECLS |
| 149 |
|
| 150 |
__POP_FC_STDLIB |
| 151 |
#endif |