+#if ENABLE_FEATURE_IPC_SYSLOG
+ struct shbuf_ds *shbuf;
+#endif
+ time_t last_log_time;
+ /* localhost's name. We print only first 64 chars */
+ char *hostname;
+
+ /* We recv into recvbuf... */
+ char recvbuf[MAX_READ * (1 + ENABLE_FEATURE_SYSLOGD_DUP)];
+ /* ...then copy to parsebuf, escaping control chars */
+ /* (can grow x2 max) */
+ char parsebuf[MAX_READ*2];
+ /* ...then sprintf into printbuf, adding timestamp (15 chars),
+ * host (64), fac.prio (20) to the message */
+ /* (growth by: 15 + 64 + 20 + delims = ~110) */
+ char printbuf[MAX_READ*2 + 128];
+};
+
+static const struct init_globals init_data = {
+ .logFilePath = "/var/log/messages",
+ .logFD = -1,
+#ifdef SYSLOGD_MARK
+ .markInterval = 20 * 60,
+#endif
+ .logLevel = 8,
+#if ENABLE_FEATURE_ROTATE_LOGFILE
+ .logFileSize = 200 * 1024,
+ .logFileRotate = 1,
+#endif
+#if ENABLE_FEATURE_REMOTE_LOG
+ .remoteFD = -1,
+#endif
+#if ENABLE_FEATURE_IPC_SYSLOG
+ .shmid = -1,
+ .s_semid = -1,
+ .shm_size = ((CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE)*1024), // default shm size
+ .SMwup = { {1, -1, IPC_NOWAIT} },
+ .SMwdn = { {0, 0}, {1, 0}, {1, +1} },
+#endif
+};
+
+#define G (*ptr_to_globals)
+#define INIT_G() do { \
+ SET_PTR_TO_GLOBALS(memcpy(xzalloc(sizeof(G)), &init_data, sizeof(init_data))); \
+} while (0)
+
+
+/* Options */
+enum {
+ OPTBIT_mark = 0, // -m
+ OPTBIT_nofork, // -n
+ OPTBIT_outfile, // -O
+ OPTBIT_loglevel, // -l
+ OPTBIT_small, // -S
+ USE_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize ,) // -s
+ USE_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt ,) // -b
+ USE_FEATURE_REMOTE_LOG( OPTBIT_remote ,) // -R
+ USE_FEATURE_REMOTE_LOG( OPTBIT_locallog ,) // -L
+ USE_FEATURE_IPC_SYSLOG( OPTBIT_circularlog,) // -C
+ USE_FEATURE_SYSLOGD_DUP( OPTBIT_dup ,) // -D
+
+ OPT_mark = 1 << OPTBIT_mark ,
+ OPT_nofork = 1 << OPTBIT_nofork ,
+ OPT_outfile = 1 << OPTBIT_outfile ,
+ OPT_loglevel = 1 << OPTBIT_loglevel,
+ OPT_small = 1 << OPTBIT_small ,
+ OPT_filesize = USE_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize )) + 0,
+ OPT_rotatecnt = USE_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt )) + 0,
+ OPT_remotelog = USE_FEATURE_REMOTE_LOG( (1 << OPTBIT_remote )) + 0,
+ OPT_locallog = USE_FEATURE_REMOTE_LOG( (1 << OPTBIT_locallog )) + 0,
+ OPT_circularlog = USE_FEATURE_IPC_SYSLOG( (1 << OPTBIT_circularlog)) + 0,
+ OPT_dup = USE_FEATURE_SYSLOGD_DUP( (1 << OPTBIT_dup )) + 0,
+};
+#define OPTION_STR "m:nO:l:S" \
+ USE_FEATURE_ROTATE_LOGFILE("s:" ) \
+ USE_FEATURE_ROTATE_LOGFILE("b:" ) \
+ USE_FEATURE_REMOTE_LOG( "R:" ) \
+ USE_FEATURE_REMOTE_LOG( "L" ) \
+ USE_FEATURE_IPC_SYSLOG( "C::") \
+ USE_FEATURE_SYSLOGD_DUP( "D" )
+#define OPTION_DECL *opt_m, *opt_l \
+ USE_FEATURE_ROTATE_LOGFILE(,*opt_s) \
+ USE_FEATURE_ROTATE_LOGFILE(,*opt_b) \
+ USE_FEATURE_IPC_SYSLOG( ,*opt_C = NULL)
+#define OPTION_PARAM &opt_m, &G.logFilePath, &opt_l \
+ USE_FEATURE_ROTATE_LOGFILE(,&opt_s) \
+ USE_FEATURE_ROTATE_LOGFILE(,&opt_b) \
+ USE_FEATURE_REMOTE_LOG( ,&G.remoteAddrStr) \
+ USE_FEATURE_IPC_SYSLOG( ,&opt_C)