netatalk  4.4.0dev
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
iniparser_util.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2025 Daniel Markstedt
3 * All Rights Reserved. See COPYING.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10
11#ifndef AFPD_INIPARSER_UTIL_H
12#define AFPD_INIPARSER_UTIL_H 1
13
14#ifdef HAVE_INIPARSER_INIPARSER_H
15#include <iniparser/iniparser.h>
16#else
17#include <iniparser.h>
18#endif
19
20/**********************************************************************************************
21 * Ini config manipulation macros
22 **********************************************************************************************/
23
24#define INISEC_GLOBAL "global"
25#define INISEC_HOMES "homes"
26
27#define INIPARSER_GETSTR(config, section, key, default) ({ \
28 char _option[MAXOPTLEN]; \
29 snprintf(_option, sizeof(_option), "%s:%s", section, key); \
30 iniparser_getstring(config, _option, default); \
31})
32
33#define INIPARSER_GETSTRDUP(config, section, key, default) ({ \
34 char _option[MAXOPTLEN]; \
35 snprintf(_option, sizeof(_option), "%s:%s", section, key); \
36 const char *_tmp = iniparser_getstring(config, _option, default); \
37 _tmp ? strdup(_tmp) : NULL; \
38})
39
40#define CONFIG_ARG_FREE(a) do { \
41 free(a); \
42 a = NULL; \
43 } while (0);
44
45#endif