Skip to content

Commit 2ad3b35

Browse files
committed
core: add API for default configuration directory
1 parent e7b6395 commit 2ad3b35

File tree

4 files changed

+68
-5
lines changed

4 files changed

+68
-5
lines changed

include/ipfixcol2/api.h.in

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* \file api.h
33
* \author Petr Velan <[email protected]>
44
* \author Lukas Hutak <[email protected]>
5-
* \brief Definitions for API functions
6-
* \date 2016
5+
* \brief Definitions for API functions (header file)
6+
* \date 2016-2018
77
*/
88

9-
/* Copyright (C) 2016 CESNET, z.s.p.o.
9+
/* Copyright (C) 2016-2018 CESNET, z.s.p.o.
1010
*
1111
* Redistribution and use in source and binary forms, with or without
1212
* modification, are permitted provided that the following conditions
@@ -57,7 +57,7 @@ extern "C" {
5757

5858
/**
5959
* \def IPX_API
60-
* \brief Make an interface public outsite
60+
* \brief Make an interface public outside
6161
*
6262
* If the compiler supports attribute to mark objects as hidden, mark all
6363
* objects as hidden and export only objects explicitly marked to be part of
@@ -130,6 +130,13 @@ extern "C" {
130130
/** Status code for reaching maximum capacity */
131131
#define IPX_ERR_LIMIT (-13)
132132

133+
/**
134+
* \brief Get the default directory with configuration
135+
* \return Statically allocated string
136+
*/
137+
IPX_API const char *
138+
ipx_api_cfg_dir();
139+
133140
/**@}*/
134141

135142
#ifdef __cplusplus

src/build_config.h.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@
6666
#define IPX_BUILD_VERSION_FULL_STR \
6767
"@IPFIXCOL_VERSION_MAJOR@.@IPFIXCOL_VERSION_MINOR@.@IPFIXCOL_VERSION_PATCH@"
6868

69+
/** \brief Path to the directory with configuration */
70+
#define IPX_DEFAULT_CONFIG_DIR \
71+
"@CMAKE_INSTALL_FULL_SYSCONFDIR@/ipfixcol2/"
6972
/** \brief Path to default (if not specified) user configuration file */
7073
#define IPX_DEFAULT_STARTUP_CONFIG \
71-
"@CMAKE_INSTALL_FULL_SYSCONFDIR@/ipfixcol2/startup.xml"
74+
IPX_DEFAULT_CONFIG_DIR "startup.xml"
7275
/** \brief Path to the directory with plugins */
7376
#define IPX_DEFAULT_PLUGINS_DIR \
7477
"@CMAKE_INSTALL_FULL_LIBDIR@/ipfixcol2/"

src/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set(CORE_SOURCE
1010
configurator/plugin_finder.hpp
1111
configurator/model.cpp
1212
configurator/model.hpp
13+
api.c
1314
context.c
1415
context.h
1516
fpipe.c

src/core/api.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* \file src/core/api.c
3+
* \author Lukas Hutak <[email protected]>
4+
* \brief Definitions for API functions (source file)
5+
* \date 2018
6+
*/
7+
8+
/* Copyright (C) 2018 CESNET, z.s.p.o.
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
* 1. Redistributions of source code must retain the above copyright
14+
* notice, this list of conditions and the following disclaimer.
15+
* 2. Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in
17+
* the documentation and/or other materials provided with the
18+
* distribution.
19+
* 3. Neither the name of the Company nor the names of its contributors
20+
* may be used to endorse or promote products derived from this
21+
* software without specific prior written permission.
22+
*
23+
* ALTERNATIVELY, provided that this notice is retained in full, this
24+
* product may be distributed under the terms of the GNU General Public
25+
* License (GPL) version 2 or later, in which case the provisions
26+
* of the GPL apply INSTEAD OF those given above.
27+
*
28+
* This software is provided ``as is'', and any express or implied
29+
* warranties, including, but not limited to, the implied warranties of
30+
* merchantability and fitness for a particular purpose are disclaimed.
31+
* In no event shall the company or contributors be liable for any
32+
* direct, indirect, incidental, special, exemplary, or consequential
33+
* damages (including, but not limited to, procurement of substitute
34+
* goods or services; loss of use, data, or profits; or business
35+
* interruption) however caused and on any theory of liability, whether
36+
* in contract, strict liability, or tort (including negligence or
37+
* otherwise) arising in any way out of the use of this software, even
38+
* if advised of the possibility of such damage.
39+
*
40+
*/
41+
42+
#include <ipfixcol2/api.h>
43+
#include <build_config.h>
44+
45+
/** Statically allocated string with default configuration directory */
46+
static const char *ipx_dir_str = IPX_DEFAULT_CONFIG_DIR;
47+
48+
const char *
49+
ipx_api_cfg_dir()
50+
{
51+
return ipx_dir_str;
52+
}

0 commit comments

Comments
 (0)