2 * Copyright (c) 2012, Intel Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Intel Corporation nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef __SRS_DAEMON_CONFIG_H__
31 #define __SRS_DAEMON_CONFIG_H__
33 /** SRS configuration variable type. */
34 typedef struct srs_cfg_s srs_cfg_t;
36 #include "src/daemon/context.h"
39 # define LIBDIR "/usr/lib"
43 # define SYSCONFDIR "/etc"
46 #ifndef SRS_DEFAULT_CONFIG_FILE
47 # define SRS_DEFAULT_CONFIG_FILE SYSCONFDIR"/src/srs.conf"
50 #ifndef SRS_DEFAULT_PLUGIN_DIR
51 # define SRS_DEFAULT_PLUGIN_DIR LIBDIR"/srs"
56 * a configuration variable/setting
60 char *key; /* configuration key */
61 char *value; /* configuration value */
62 int used; /* TRUE if ever looked up */
66 /** Parse the daemon command line. */
67 void config_parse_cmdline(srs_context_t *srs, int argc, char **argv,
70 /** Get the value of a string configuration variable. */
71 const char *srs_config_get_string(srs_cfg_t *settings, const char *key,
74 /** Get the value of a boolean configuration variable. */
75 int srs_config_get_bool(srs_cfg_t *settings, const char *key, int defval);
77 /** Get the value of a 32-bit signed integer configuration variable. */
78 int32_t srs_config_get_int32(srs_cfg_t *settings, const char *key,
81 /** Get the value of a 32-bit unsigned integer configuration variable. */
82 uint32_t srs_config_get_uint32(srs_cfg_t *settings, const char *key,
85 /** Collect configuration variable matching the given prefix. */
86 int srs_config_collect(srs_cfg_t *settings, const char *prefix,
87 srs_cfg_t **matching);
89 /** Free an array of configuration variables. */
90 void srs_config_free(srs_cfg_t *settings);
92 /** Set a configuration variable to the given value. */
93 void srs_set_config(srs_context_t *srs, const char *key, const char *value);
94 #endif /* __SRS_DAEMON_CONFIG_H__ */