alsa.audio: limit the supported frequencies to common set
[AROS.git] / workbench / network / stacks / AROSTCP / netlib / syslog.c
blobaf2bdfe0e37e9deb969d0b680e8b2e3ef00f1d88
1 /* $Id$
3 * syslog.c - syslog function stubs for the AmiTCP/IP
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
7 * All rights reserved.
8 * Copyright © 2005 Pavel Fedin
9 */
11 #include <sys/param.h>
12 #include <sys/syslog.h>
14 #include <proto/socket.h>
15 #include <bsdsocket/socketbasetags.h>
17 /****** net.lib/syslog *********************************************
19 * NAME
20 * openlog(), closelog(), setlogmask() -- syslog utility functions
22 * SYNOPSIS
23 * #include <syslog.h>
25 * openlog(ident, logopt, facility);
27 * void openlog(const char *, int, int);
29 * closelog();
31 * void closelog(void);
33 * oldmask = setlogmask(maskpri);
35 * int setlogmask(int);
37 * FUNCTION
38 * openlog() can be called to initialize the log file, if special
39 * processing is needed. ident is a string that precedes every
40 * message. logopt is a mask of bits, logically OR'ed together,
41 * indicating logging options. The values for logopt are:
43 * LOG_PID Log the process ID with each message;
44 * useful for identifying instantiations
45 * of daemons.
47 * LOG_CONS Force writing messages to the console
48 * if unable to send it to syslogd.
49 * This option is safe to use in daemon
50 * processes that have no controlling
51 * terminal because syslog() forks
52 * before opening the console.
54 * LOG_NDELAY Open the connection to syslogd
55 * immediately. Normally, the open is
56 * delayed until the first message is
57 * logged. This is useful for programs
58 * that need to manage the order in
59 * which file descriptors are allocated.
61 * LOG_NOWAIT Do not wait for children forked to
62 * log messages on the console. Obsolete
63 * in AmiTCP/IP, since AmiTCP/IP does
64 * not fork.
66 * facility encodes a default facility to be assigned to all
67 * messages written subsequently by syslog() with no explicit
68 * facility encoded. The facility codes are:
70 * LOG_KERN Messages generated by the kernel.
71 * These cannot be generated by any user
72 * processes.
74 * LOG_USER Messages generated by random user
75 * processes. This is the default
76 * facility identifier if none is
77 * specified.
79 * LOG_MAIL The mail system.
81 * LOG_DAEMON System daemons, such as inetd, ftpd,
82 * etc.
84 * LOG_AUTH The authorization system: login, su,
85 * getty, etc.
87 * LOG_LPR The line printer spooling system: lp,
88 * lpsched, etc.
90 * LOG_LOCAL0 Reserved for local use. Similarly for
91 * LOG_LOCAL1 through LOG_LOCAL7.
94 * closelog() closes the log file.
96 * setlogmask() sets the log priority mask to maskpri and returns
97 * the previous mask. Calls to syslog() with a priority not set
98 * in maskpri are rejected. The mask for an individual priority
99 * pri is calculated by the macro LOG_MASK(pri); the mask for all
100 * priorities up to and including toppri is given by the macro
101 * LOG_UPTO(toppri). By default, all priorities are logged.
103 * EXAMPLES
104 * who logs a message regarding some sort of unexpected and
105 * serious error:
107 * syslog(LOG_ALERT, "who: internal error 23");
109 * ftpd uses openlog() to arrange to log its process ID, to log
110 * to the console if necessary, and to log in the name of the
111 * daemon facility:
113 * openlog("ftpd", LOG_PID|LOG_CONS, LOG_DAEMON);
115 * Arrange to log messages only at levels LOG_ERR and lower:
117 * setlogmask(LOG_UPTO(LOG_ERR));
119 * Typical usage of syslog() to log a connection:
121 * syslog(LOG_INFO, "Connection from host %d", CallingHost);
123 * If the facility has not been set with openlog(), it defaults
124 * to LOG_USER.
126 * Explicitly set the facility for this message:
128 * syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
130 * NOTES
131 * openlog() does not copy and store the ident string internally;
132 * it stores only the character pointer. Therefore it is the
133 * responsibility of the programmer to make sure that the ident
134 * argument points to the correct string while syslog() is being
135 * called.
137 * BUGS
138 * Most of the logopt and facility codes are currently being
139 * ignored by AmiTCP/IP, but they should be used for future
140 * compatibility.
142 * The autoinit module of the net.lib tells the program name
143 * to the AmiTCP/IP at program startup, so use of the openlog()
144 * for that purpose only is not necessary.
146 * AUTHOR
147 * syslog() was developed by the University of California,
148 * Berkeley.
150 * SEE ALSO
151 * bsdsocket.library/syslog(), bsdsocket.library/SocketBaseTagList()
152 *****************************************************************************
155 void
156 openlog(const char *ident, int logstat, int logfac)
159 * Note: SocketBaseTags() does value checking for the arguments
161 SocketBaseTags(SBTM_SETVAL(SBTC_LOGTAGPTR), ident,
162 SBTM_SETVAL(SBTC_LOGSTAT), logstat,
163 SBTM_SETVAL(SBTC_LOGFACILITY), logfac,
164 TAG_END);
167 void
168 closelog(void)
170 SocketBaseTags(SBTM_SETVAL(SBTC_LOGTAGPTR), NULL,
171 TAG_END);
174 /* setlogmask -- set the log mask level */
176 setlogmask(int pmask)
178 ULONG taglist[5];
180 taglist[0] = SBTM_GETVAL(SBTC_LOGMASK);
181 taglist[2] = SBTM_SETVAL(SBTC_LOGMASK);
182 taglist[3] = pmask;
183 taglist[4] = TAG_END;
185 SocketBaseTagList((struct TagItem *)taglist);
186 return (int)taglist[1];