packaging: bumped version, updated changelog.
[profile/ivi/speech-recognition.git] / src / daemon / config.h
1 /*
2  * Copyright (c) 2012, Intel Corporation
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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.
16  *
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.
28  */
29
30 #ifndef __SRS_DAEMON_CONFIG_H__
31 #define __SRS_DAEMON_CONFIG_H__
32
33 /** SRS configuration variable type. */
34 typedef struct srs_cfg_s srs_cfg_t;
35
36 #include "src/daemon/context.h"
37
38 #ifndef LIBDIR
39 #    define LIBDIR "/usr/lib"
40 #endif
41
42 #ifndef SYSCONFDIR
43 #    define SYSCONFDIR "/etc"
44 #endif
45
46 #ifndef SRS_DEFAULT_CONFIG_FILE
47 #    define SRS_DEFAULT_CONFIG_FILE SYSCONFDIR"/src/srs.conf"
48 #endif
49
50 #ifndef SRS_DEFAULT_PLUGIN_DIR
51 #    define SRS_DEFAULT_PLUGIN_DIR  LIBDIR"/srs"
52 #endif
53
54
55 /*
56  * a configuration variable/setting
57  */
58
59 struct srs_cfg_s {
60     char *key;                           /* configuration key */
61     char *value;                         /* configuration value */
62     int   used;                          /* TRUE if ever looked up */
63 };
64
65
66 /** Parse the daemon command line. */
67 void config_parse_cmdline(srs_context_t *srs, int argc, char **argv,
68                           char **env);
69
70 /** Get the value of a string configuration variable. */
71 const char *srs_config_get_string(srs_cfg_t *settings, const char *key,
72                                   const char *defval);
73
74 /** Get the value of a boolean configuration variable. */
75 int srs_config_get_bool(srs_cfg_t *settings, const char *key, int defval);
76
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,
79                              int32_t defval);
80
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,
83                                uint32_t defval);
84
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);
88
89 /** Free an array of configuration variables. */
90 void srs_config_free(srs_cfg_t *settings);
91
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__ */