261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
free(prev);
}
}
return(NULL);
}
static int filed_logging_thread_init(FILE *logfp) {
struct filed_logging_thread_args *args;
pthread_t thread_id;
args = malloc(sizeof(*args));
args->fp = logfp;
filed_log_msg_list = NULL;
pthread_mutex_init(&filed_log_msg_list_mutex, NULL);
pthread_create(&thread_id, NULL, filed_logging_thread, args);
return(0);
}
static void filed_log_msg(const char *fmt, ...) {
struct filed_log_entry *entry;
va_list args;
entry = malloc(sizeof(*entry));
va_start(args, fmt);
|
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
-
|
pthread_mutex_unlock(&filed_log_msg_list_mutex);
pthread_cond_signal(&filed_log_msg_list_ready);
return;
}
static const char *filed_log_ip(struct sockaddr *addr, char *buffer, size_t bufferlen) {
struct sockaddr_in *addr_v4;
struct sockaddr_in6 *addr_v6;
const char *retval = NULL;
addr_v6 = (struct sockaddr_in6 *) addr;
|
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
if (retval == NULL) {
retval = "<unknown>";
}
return(retval);
}
static int filed_logging_thread_init(FILE *logfp) {
struct filed_logging_thread_args *args;
pthread_t thread_id;
args = malloc(sizeof(*args));
args->fp = logfp;
filed_log_msg_list = NULL;
pthread_mutex_init(&filed_log_msg_list_mutex, NULL);
pthread_create(&thread_id, NULL, filed_logging_thread, args);
filed_log_msg("START");
return(0);
}
#endif
/* Format time per RFC2616 */
static char *filed_format_time(char *buffer, size_t buffer_len, const time_t timeinfo) {
struct tm timeinfo_tm, *timeinfo_tm_p;
timeinfo_tm_p = gmtime_r(&timeinfo, &timeinfo_tm);
|