Files
progettoso/lib/utils/serverUtil.h

31 lines
1.2 KiB
C
Raw Normal View History

2022-03-15 00:30:04 +01:00
#pragma once
#ifndef _SERVER_UTIL
#define _SERVER_UTIL
#include <stdio.h>
2022-03-22 19:35:06 +01:00
#include <string.h>
2022-03-15 00:30:04 +01:00
#include <inttypes.h>
2022-05-07 23:00:47 +02:00
#include "ini.h"
2022-04-04 22:31:14 +02:00
#define CONFGETINT(var, config, t, q, p, base) \
var = (int) strtol(ini_get(config, t, q), p, base); \
if(var<=0) { \
fprintf(stderr, "ERROR reading config for variable %s\n", t); \
ini_free(config); \
return 1; \
2022-03-15 00:30:04 +01:00
}
2022-04-04 22:31:14 +02:00
#define CONFGETSTR(var, config, t, q, buff) \
buff = ini_get(config, t, q); \
if(buff==NULL) { \
fprintf(stderr, "ERROR reading config for variable %s\n", t); \
ini_free(config); \
return 1; \
} \
2022-04-23 17:43:38 +02:00
var = calloc(strlen(buff)+1, sizeof(char)); \
2022-04-04 22:31:14 +02:00
strncpy(var, buff, strlen(buff)+1);
2022-03-22 19:35:06 +01:00
2022-03-15 00:30:04 +01:00
#endif /* _SERVER_STATUS */