netatalk  4.5.0
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#ifdef HAVE_INIPARSER_CONST_DICTIONARY
21#define INIPARSER_DICTIONARY const dictionary
22#else
23#define INIPARSER_DICTIONARY dictionary
24#endif
25
26/**********************************************************************************************
27 * Ini config manipulation macros
28 **********************************************************************************************/
29
30#define INISEC_GLOBAL "global"
31#define INISEC_HOMES "homes"
32
33#define INIPARSER_GETSTR(config, section, key, default) ({ \
34 char _option[MAXOPTLEN]; \
35 snprintf(_option, sizeof(_option), "%s:%s", section, key); \
36 iniparser_getstring(config, _option, default); \
37})
38
39#define INIPARSER_GETSTRDUP(config, section, key, default) ({ \
40 char _option[MAXOPTLEN]; \
41 snprintf(_option, sizeof(_option), "%s:%s", section, key); \
42 const char *_tmp = iniparser_getstring(config, _option, default); \
43 _tmp ? strdup(_tmp) : NULL; \
44})
45
46#define CONFIG_ARG_FREE(a) do { \
47 free(a); \
48 a = NULL; \
49 } while (0);
50
51#endif