nfmod/common.hpp
#pragma once
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <time.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#define LOG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#define LOG_ERRNO(fmt, ...) LOG(fmt " - %d: %s", ##__VA_ARGS__, errno, strerror(errno))
#ifdef NDEBUG
#define DBG(fmt, ...) do{}while(0)
#define DBG_ERRNO(fmt, ...) do{}while(0)
#else
#define DEBUG
#define DBG(fmt, ...) LOG("debug: " fmt, ##__VA_ARGS__)
#define DBG_ERRNO(fmt, ...) LOG_ERRNO("debug: " fmt, ##__VA_ARGS__)
#endif
#define talloc(t) (t*)malloc(sizeof(t))
#define MAX(a, b) (((a)>(b))?(a):(b))
#define MIN(a, b) (((a)<(b))?(a):(b))
#define CONCAT_(a, b) a ## b
#define CONCAT(a, b) CONCAT_(a, b)
extern time_t NOW;
void update_now();