ReactOS 0.4.15-dev-8419-g7f0e8a3
syslog.h File Reference
#include <stdarg.h>
Include dependency graph for syslog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LOG_EMERG   0 /* system is unusable */
 
#define LOG_ALERT   1 /* action must be taken immediately */
 
#define LOG_CRIT   2 /* critical conditions */
 
#define LOG_ERR   3 /* error conditions */
 
#define LOG_WARNING   4 /* warning conditions */
 
#define LOG_NOTICE   5 /* normal but significant condition */
 
#define LOG_INFO   6 /* informational */
 
#define LOG_DEBUG   7 /* debug-level messages */
 
#define LOG_PRIMASK   0x07 /* mask to extract priority part (internal) */
 
#define LOG_PRI(p)   ((p) & LOG_PRIMASK)
 
#define LOG_MAKEPRI(fac, pri)   (((fac) << 3) | (pri))
 
#define LOG_KERN   (0<<3) /* kernel messages */
 
#define LOG_USER   (1<<3) /* random user-level messages */
 
#define LOG_MAIL   (2<<3) /* mail system */
 
#define LOG_DAEMON   (3<<3) /* system daemons */
 
#define LOG_AUTH   (4<<3) /* security/authorization messages */
 
#define LOG_SYSLOG   (5<<3) /* messages generated internally by syslogd */
 
#define LOG_LPR   (6<<3) /* line printer subsystem */
 
#define LOG_NEWS   (7<<3) /* network news subsystem */
 
#define LOG_UUCP   (8<<3) /* UUCP subsystem */
 
#define LOG_CRON   (9<<3) /* clock daemon */
 
#define LOG_AUTHPRIV   (10<<3) /* security/authorization messages (private) */
 
#define LOG_FTP   (11<<3) /* ftp daemon */
 
#define LOG_LOCAL0   (16<<3) /* reserved for local use */
 
#define LOG_LOCAL1   (17<<3) /* reserved for local use */
 
#define LOG_LOCAL2   (18<<3) /* reserved for local use */
 
#define LOG_LOCAL3   (19<<3) /* reserved for local use */
 
#define LOG_LOCAL4   (20<<3) /* reserved for local use */
 
#define LOG_LOCAL5   (21<<3) /* reserved for local use */
 
#define LOG_LOCAL6   (22<<3) /* reserved for local use */
 
#define LOG_LOCAL7   (23<<3) /* reserved for local use */
 
#define LOG_NFACILITIES   24 /* current number of facilities */
 
#define LOG_FACMASK   0x03f8 /* mask to extract facility part */
 
#define LOG_FAC(p)   (((p) & LOG_FACMASK) >> 3)
 
#define LOG_MASK(pri)   (1 << (pri)) /* mask for one priority */
 
#define LOG_UPTO(pri)   ((1 << ((pri)+1)) - 1) /* all priorities through pri */
 
#define LOG_PID   0x01 /* log the pid with each message */
 
#define LOG_CONS   0x02 /* log on the console if errors in sending */
 
#define LOG_ODELAY   0x04 /* delay open until first syslog() (default) */
 
#define LOG_NDELAY   0x08 /* don't delay open */
 
#define LOG_NOWAIT   0x10 /* don't wait for console forks: DEPRECATED */
 
#define LOG_PERROR   0x20 /* log to stderr as well */
 
#define SYSLOG_PORT   514
 

Functions

void closelog (void)
 
void openlog (char *__ident, int __option, int __facility)
 
int setlogmask (int __mask)
 
void syslog (int __pri, char *__fmt,...)
 
void vsyslog (int __pri, char *__fmt, va_list __ap)
 
const charset_syslog_conf_dir (const char *dir)
 

Macro Definition Documentation

◆ LOG_ALERT

#define LOG_ALERT   1 /* action must be taken immediately */

Definition at line 46 of file syslog.h.

◆ LOG_AUTH

#define LOG_AUTH   (4<<3) /* security/authorization messages */

Definition at line 91 of file syslog.h.

◆ LOG_AUTHPRIV

#define LOG_AUTHPRIV   (10<<3) /* security/authorization messages (private) */

Definition at line 97 of file syslog.h.

◆ LOG_CONS

#define LOG_CONS   0x02 /* log on the console if errors in sending */

Definition at line 157 of file syslog.h.

◆ LOG_CRIT

#define LOG_CRIT   2 /* critical conditions */

Definition at line 47 of file syslog.h.

◆ LOG_CRON

#define LOG_CRON   (9<<3) /* clock daemon */

Definition at line 96 of file syslog.h.

◆ LOG_DAEMON

#define LOG_DAEMON   (3<<3) /* system daemons */

Definition at line 90 of file syslog.h.

◆ LOG_DEBUG

#define LOG_DEBUG   7 /* debug-level messages */

Definition at line 52 of file syslog.h.

◆ LOG_EMERG

#define LOG_EMERG   0 /* system is unusable */

Definition at line 45 of file syslog.h.

◆ LOG_ERR

#define LOG_ERR   3 /* error conditions */

Definition at line 48 of file syslog.h.

◆ LOG_FAC

#define LOG_FAC (   p)    (((p) & LOG_FACMASK) >> 3)

Definition at line 113 of file syslog.h.

◆ LOG_FACMASK

#define LOG_FACMASK   0x03f8 /* mask to extract facility part */

Definition at line 111 of file syslog.h.

◆ LOG_FTP

#define LOG_FTP   (11<<3) /* ftp daemon */

Definition at line 98 of file syslog.h.

◆ LOG_INFO

#define LOG_INFO   6 /* informational */

Definition at line 51 of file syslog.h.

◆ LOG_KERN

#define LOG_KERN   (0<<3) /* kernel messages */

Definition at line 87 of file syslog.h.

◆ LOG_LOCAL0

#define LOG_LOCAL0   (16<<3) /* reserved for local use */

Definition at line 101 of file syslog.h.

◆ LOG_LOCAL1

#define LOG_LOCAL1   (17<<3) /* reserved for local use */

Definition at line 102 of file syslog.h.

◆ LOG_LOCAL2

#define LOG_LOCAL2   (18<<3) /* reserved for local use */

Definition at line 103 of file syslog.h.

◆ LOG_LOCAL3

#define LOG_LOCAL3   (19<<3) /* reserved for local use */

Definition at line 104 of file syslog.h.

◆ LOG_LOCAL4

#define LOG_LOCAL4   (20<<3) /* reserved for local use */

Definition at line 105 of file syslog.h.

◆ LOG_LOCAL5

#define LOG_LOCAL5   (21<<3) /* reserved for local use */

Definition at line 106 of file syslog.h.

◆ LOG_LOCAL6

#define LOG_LOCAL6   (22<<3) /* reserved for local use */

Definition at line 107 of file syslog.h.

◆ LOG_LOCAL7

#define LOG_LOCAL7   (23<<3) /* reserved for local use */

Definition at line 108 of file syslog.h.

◆ LOG_LPR

#define LOG_LPR   (6<<3) /* line printer subsystem */

Definition at line 93 of file syslog.h.

◆ LOG_MAIL

#define LOG_MAIL   (2<<3) /* mail system */

Definition at line 89 of file syslog.h.

◆ LOG_MAKEPRI

#define LOG_MAKEPRI (   fac,
  pri 
)    (((fac) << 3) | (pri))

Definition at line 57 of file syslog.h.

◆ LOG_MASK

#define LOG_MASK (   pri)    (1 << (pri)) /* mask for one priority */

Definition at line 147 of file syslog.h.

◆ LOG_NDELAY

#define LOG_NDELAY   0x08 /* don't delay open */

Definition at line 159 of file syslog.h.

◆ LOG_NEWS

#define LOG_NEWS   (7<<3) /* network news subsystem */

Definition at line 94 of file syslog.h.

◆ LOG_NFACILITIES

#define LOG_NFACILITIES   24 /* current number of facilities */

Definition at line 110 of file syslog.h.

◆ LOG_NOTICE

#define LOG_NOTICE   5 /* normal but significant condition */

Definition at line 50 of file syslog.h.

◆ LOG_NOWAIT

#define LOG_NOWAIT   0x10 /* don't wait for console forks: DEPRECATED */

Definition at line 160 of file syslog.h.

◆ LOG_ODELAY

#define LOG_ODELAY   0x04 /* delay open until first syslog() (default) */

Definition at line 158 of file syslog.h.

◆ LOG_PERROR

#define LOG_PERROR   0x20 /* log to stderr as well */

Definition at line 161 of file syslog.h.

◆ LOG_PID

#define LOG_PID   0x01 /* log the pid with each message */

Definition at line 156 of file syslog.h.

◆ LOG_PRI

#define LOG_PRI (   p)    ((p) & LOG_PRIMASK)

Definition at line 56 of file syslog.h.

◆ LOG_PRIMASK

#define LOG_PRIMASK   0x07 /* mask to extract priority part (internal) */

Definition at line 54 of file syslog.h.

◆ LOG_SYSLOG

#define LOG_SYSLOG   (5<<3) /* messages generated internally by syslogd */

Definition at line 92 of file syslog.h.

◆ LOG_UPTO

#define LOG_UPTO (   pri)    ((1 << ((pri)+1)) - 1) /* all priorities through pri */

Definition at line 148 of file syslog.h.

◆ LOG_USER

#define LOG_USER   (1<<3) /* random user-level messages */

Definition at line 88 of file syslog.h.

◆ LOG_UUCP

#define LOG_UUCP   (8<<3) /* UUCP subsystem */

Definition at line 95 of file syslog.h.

◆ LOG_WARNING

#define LOG_WARNING   4 /* warning conditions */

Definition at line 49 of file syslog.h.

◆ SYSLOG_PORT

#define SYSLOG_PORT   514

Definition at line 163 of file syslog.h.

Function Documentation

◆ closelog()

void closelog ( void  )

Definition at line 153 of file syslog.c.

154{
155 if( !initialized )
156 return;
157 closesocket( sock );
158 WSACleanup();
160}
#define FALSE
Definition: types.h:117
#define closesocket
Definition: ncftp.h:477
Definition: tcpcore.h:1455
static BOOL initialized
Definition: syslog.c:39
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60

Referenced by openlog().

◆ openlog()

void openlog ( char __ident,
int  __option,
int  __facility 
)

Definition at line 167 of file syslog.c.

168{
169 BOOL failed = TRUE, wsa_initialized = FALSE;
170 WSADATA wsd;
171 SOCKADDR_IN sa_local;
172 DWORD n;
173 int size;
174
175 if( initialized )
176 return;
177
178 syslog_facility = facility? facility : LOG_USER;
179
180 /* FIXME: should we reset logmask? */
181
182 if( option & LOG_PID )
183 snprintf( str_pid, sizeof(str_pid), "[%lu]", GetCurrentProcessId() );
184 else
185 str_pid[0] = 0;
186
187 /* FIXME: handle other options */
188
189 n = sizeof(local_hostname);
191 goto done;
192
194 if( WSAStartup( MAKEWORD( 2, 2 ), &wsd ) )
195 goto done;
196 wsa_initialized = TRUE;
197
199
200 for( n = 0;; n++ )
201 {
202 sock = socket( AF_INET, SOCK_DGRAM, 0 );
203 if( INVALID_SOCKET == sock )
204 goto done;
205
206 memset( &sa_local, 0, sizeof(SOCKADDR_IN) );
207 sa_local.sin_family = AF_INET;
208 if( bind( sock, (SOCKADDR*) &sa_local, sizeof(SOCKADDR_IN) ) == 0 )
209 break;
210 closesocket( sock );
212 if( n == 100 )
213 goto done;
214 Sleep(0);
215 }
216
217 /* get size of datagramm */
218 size = sizeof(datagramm_size);
220 goto done;
221 if( datagramm_size - strlen(local_hostname) - (ident? strlen(ident) : 0) < 64 )
222 goto done;
223 if( datagramm_size > sizeof(datagramm) )
224 datagramm_size = sizeof(datagramm);
225
226 if( atexit( closelog ) )
227 goto done;
228
230 syslog_facility = facility;
231 failed = FALSE;
232
233done:
234 if( failed )
235 {
237 if( wsa_initialized ) WSACleanup();
238 }
239 initialized = !failed;
240}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static WSADATA wsd
Definition: adapter.c:10
#define TRUE
Definition: types.h:120
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#define AF_INET
Definition: tcpip.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLdouble n
Definition: glext.h:7729
int __cdecl atexit(void(__cdecl *)(void))
Definition: atonexit.c:97
#define memset(x, y, z)
Definition: compat.h:39
INT WSAAPI getsockopt(IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT INT FAR *optlen)
Definition: sockctrl.c:271
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
Definition: getopt.h:109
short sin_family
Definition: winsock.h:510
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
void closelog()
Definition: syslog.c:153
static int syslog_facility
Definition: syslog.c:42
static char str_pid[40]
Definition: syslog.c:43
static char local_hostname[MAX_COMPUTERNAME_LENGTH+1]
Definition: syslog.c:46
static void init_logger_addr()
Definition: syslog.c:70
static char datagramm[SYSLOG_DGRAM_SIZE]
Definition: syslog.c:47
static char * syslog_ident
Definition: syslog.c:41
static int datagramm_size
Definition: syslog.c:48
#define LOG_PID
Definition: syslog.h:156
#define LOG_USER
Definition: syslog.h:88
#define MAKEWORD(a, b)
Definition: typedefs.h:248
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
#define GetComputerName
Definition: winbase.h:3800
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3994
#define INVALID_SOCKET
Definition: winsock.h:332
#define SOCK_DGRAM
Definition: winsock.h:336
#define SOL_SOCKET
Definition: winsock.h:398
#define snprintf
Definition: wintirpc.h:48
#define SO_MAX_MSG_SIZE
Definition: ws2def.h:119

Referenced by vsyslog().

◆ set_syslog_conf_dir()

const char * set_syslog_conf_dir ( const char dir)

Definition at line 55 of file syslog.c.

56{
57 const char *ret = syslog_conf_dir;
59 return ret;
60}
unsigned int dir
Definition: maze.c:112
static const char * syslog_conf_dir
Definition: syslog.c:22
int ret

◆ setlogmask()

int setlogmask ( int  __mask)

Definition at line 247 of file syslog.c.

248{
249 int ret = log_mask;
250
251 if( mask )
252 log_mask = mask;
253 return ret;
254}
GLenum GLint GLuint mask
Definition: glext.h:6028
static int log_mask
Definition: syslog.c:40

◆ syslog()

void syslog ( int  __pri,
char __fmt,
  ... 
)

Definition at line 261 of file syslog.c.

262{
263 va_list ap;
264
265 va_start( ap, fmt );
266 vsyslog( pri, fmt, ap );
267 va_end( ap );
268}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
Definition: dsound.c:943
void vsyslog(int pri, char *fmt, va_list ap)
Definition: syslog.c:275
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

◆ vsyslog()

void vsyslog ( int  __pri,
char __fmt,
va_list  __ap 
)

Definition at line 275 of file syslog.c.

276{
277 static char *month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
278 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
279 SYSTEMTIME stm;
280 int len;
281 char *p;
282
283 if( !(LOG_MASK( LOG_PRI( pri )) & log_mask) )
284 return;
285
286 openlog( NULL, 0, pri & LOG_FACMASK );
287 if( !initialized )
288 return;
289
290 if( !(pri & LOG_FACMASK) )
291 pri |= syslog_facility;
292
293 GetLocalTime( &stm );
294 len = sprintf( datagramm, "<%d>%s %2d %02d:%02d:%02d %s %s%s: ",
295 pri,
296 month[ stm.wMonth - 1 ], stm.wDay, stm.wHour, stm.wMinute, stm.wSecond,
299 p = strchr( datagramm, '\n' );
300 if( p )
301 *p = 0;
302 p = strchr( datagramm, '\r' );
303 if( p )
304 *p = 0;
305
307}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define NULL
Definition: types.h:112
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
static const WCHAR month[12][4]
Definition: session.c:2150
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
Definition: send.c:82
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
#define sprintf(buf, format,...)
Definition: sprintf.c:55
WORD wMonth
Definition: winbase.h:906
WORD wHour
Definition: winbase.h:909
WORD wSecond
Definition: winbase.h:911
WORD wMinute
Definition: winbase.h:910
WORD wDay
Definition: winbase.h:908
void openlog(char *ident, int option, int facility)
Definition: syslog.c:167
static SOCKADDR_IN sa_logger
Definition: syslog.c:44
#define LOG_FACMASK
Definition: syslog.h:111
#define LOG_MASK(pri)
Definition: syslog.h:147
#define LOG_PRI(p)
Definition: syslog.h:56
#define vsnprintf
Definition: tif_win32.c:406

Referenced by syslog().