Usermode/libposix - Implimenting functions for dropbear
[tpg/acess2.git] / Usermode / Libraries / libposix.so_src / syslog.c
1 /*
2  * Acess2 POSIX Emulation
3  * - By John Hodge (thePowersGang)
4  *
5  * syslog.h
6  * - Central Logging
7  */
8 #include <syslog.h>
9 #include <stdio.h>      // vsnprintf
10 #include <stdlib.h>     // free
11 #include <string.h>     // strdup
12 #include <stdarg.h>
13 #include <acess/sys.h>
14
15 // === GLOBALS ===
16 char    *gsSyslogPrefix = NULL;
17  int    gSyslogOptions;
18  int    gSyslogFacility;
19  int    gSyslogMask = -1;
20
21 // === CODE ===
22 /*
23  * Close global logging handle
24  */
25 void closelog(void)
26 {
27 }
28
29 void openlog(const char *name, int option, int facility)
30 {
31         if( gsSyslogPrefix )
32                 free(gsSyslogPrefix);
33         gsSyslogPrefix = strdup(name);
34         gSyslogOptions = option;
35         gSyslogFacility = facility;
36         
37         if( option & LOG_NOWAIT )
38         {
39                 // Open the logging handle!
40         }
41 }
42
43 extern int setlogmask(int mask)
44 {
45          int    ret = gSyslogMask;
46         gSyslogMask = mask;
47         return ret;
48 }
49
50 extern void syslog(int priority, const char *str, ...)
51 {
52         char    staticbuf[512];
53         va_list args;
54         va_start(args, str);
55         vsnprintf(staticbuf, sizeof(staticbuf), str, args);
56         va_end(args);
57         if( gSyslogOptions & (1 << priority) )
58         {
59                 // TODO: Proper syslog
60                 _SysDebug("syslog(%i: %s) - %s", priority, gsSyslogPrefix, staticbuf);
61         }
62 }
63

UCC git Repository :: git.ucc.asn.au