Improve source tree
This commit is contained in:
parent
61d4e2fc64
commit
efc292af2c
17 changed files with 77 additions and 35 deletions
43
moxerver/common.h
Normal file
43
moxerver/common.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* Common header file reused within the project. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/* ========================================================================== */
|
||||
|
||||
#define APPNAME "moxerver"
|
||||
#define BUFFER_LEN 128 /* length of a data buffer */
|
||||
|
||||
/* ========================================================================== */
|
||||
|
||||
int debug_messages; /* if > 0 debug messages will be printed */
|
||||
|
||||
/**
|
||||
* Wrapper for printing a log message to stderr.
|
||||
* Uses a "printf" syntax with format and arguments. The newline character '\n'
|
||||
* is appended to the message.
|
||||
*/
|
||||
#define LOG(...) \
|
||||
do { \
|
||||
fprintf(stderr, "[%s][%s] ", APPNAME, __func__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while(0)
|
||||
|
||||
/* ========================================================================== */
|
||||
|
||||
#define TIMESTAMP_FORMAT "%Y-%m-%dT%H:%M:%S" /* follow ISO 8601 format */
|
||||
#define TIMESTAMP_LEN 20+1 /* size of the timestamp format above */
|
||||
|
||||
/**
|
||||
* Converts time in "seconds from Epoch" to a conveniently formatted string.
|
||||
*/
|
||||
void time2string(time_t time, char* timestamp);
|
Loading…
Add table
Add a link
Reference in a new issue