Skip to content

Commit aa4bc09

Browse files
committed
Move iniparser wrapper macros into its own atalk header
1 parent 47ecea9 commit aa4bc09

File tree

11 files changed

+54
-25
lines changed

11 files changed

+54
-25
lines changed

contrib/macipgw/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <atalk/ddp.h>
3535
#include <atalk/atp.h>
3636
#include <atalk/globals.h>
37+
#include <atalk/iniparser_util.h>
3738

3839
#include <errno.h>
3940
#ifdef HAVE_INIPARSER_INIPARSER_H

etc/afpd/afp_config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <atalk/ldapconfig.h>
3939
#endif
4040

41+
#include <atalk/iniparser_util.h>
4142
#include <atalk/logger.h>
4243
#include <atalk/netatalk_conf.h>
4344
#include <atalk/server_child.h>

etc/afpd/spotlight.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <atalk/compat.h>
3636
#include <atalk/dalloc.h>
3737
#include <atalk/errchk.h>
38+
#include <atalk/iniparser_util.h>
3839
#include <atalk/list.h>
3940
#include <atalk/logger.h>
4041
#include <atalk/netatalk_conf.h>

etc/cnid_dbd/cnid_metad.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#include <atalk/cnid_bdb_private.h>
8585
#include <atalk/compat.h>
8686
#include <atalk/errchk.h>
87+
#include <atalk/iniparser_util.h>
8788
#include <atalk/netatalk_conf.h>
8889
#include <atalk/volume.h>
8990

etc/netatalk/netatalk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <atalk/dsi.h>
3838
#include <atalk/errchk.h>
3939
#include <atalk/globals.h>
40+
#include <atalk/iniparser_util.h>
4041
#include <atalk/logger.h>
4142
#include <atalk/netatalk_conf.h>
4243
#include <atalk/server_child.h>

include/atalk/globals.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -76,31 +76,6 @@
7676

7777
#define IS_AFP_SESSION(obj) (((obj)->dsi && (obj)->dsi->serversock == -1) || ((obj)->Type))
7878

79-
/**********************************************************************************************
80-
* Ini config manipulation macros
81-
**********************************************************************************************/
82-
83-
#define INISEC_GLOBAL "global"
84-
#define INISEC_HOMES "homes"
85-
86-
#define INIPARSER_GETSTR(config, section, key, default) ({ \
87-
char _option[MAXOPTLEN]; \
88-
snprintf(_option, sizeof(_option), "%s:%s", section, key); \
89-
iniparser_getstring(config, _option, default); \
90-
})
91-
92-
#define INIPARSER_GETSTRDUP(config, section, key, default) ({ \
93-
char _option[MAXOPTLEN]; \
94-
snprintf(_option, sizeof(_option), "%s:%s", section, key); \
95-
const char *_tmp = iniparser_getstring(config, _option, default); \
96-
_tmp ? strdup(_tmp) : NULL; \
97-
})
98-
99-
#define CONFIG_ARG_FREE(a) do { \
100-
free(a); \
101-
a = NULL; \
102-
} while (0);
103-
10479
struct DSI;
10580

10681
#define AFPOBJ_TMPSIZ (MAXPATHLEN)

include/atalk/iniparser_util.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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

include/atalk/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ headers = [
1111
'ea.h',
1212
'globals.h',
1313
'hash.h',
14+
'iniparser_util.h',
1415
'list.h',
1516
'logger.h',
1617
'netatalk_conf.h',

libatalk/acl/ldap_config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <string.h>
3232

3333
#include <atalk/globals.h>
34+
#include <atalk/iniparser_util.h>
3435
#include <atalk/ldapconfig.h>
3536
#include <atalk/logger.h>
3637

libatalk/util/netatalk_conf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include <atalk/logger.h>
5757
#include <atalk/ea.h>
5858
#include <atalk/globals.h>
59+
#include <atalk/iniparser_util.h>
5960
#include <atalk/errchk.h>
6061
#include <atalk/unix.h>
6162
#include <atalk/cnid.h>

0 commit comments

Comments
 (0)