version 1.0
[platform/core/system/tizen-platform-wrapper.git] / src / tzplatform_config.h
1 /*
2  * Copyright (C) 2013 Intel Corporation.
3  * 
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Authors:
19  *   José Bollo <jose.bollo@open.eurogiciel.org>
20  *   Stéphane Desneux <stephane.desneux@open.eurogiciel.org>
21  *   Jean-Benoit Martin <jean-benoit.martin@open.eurogiciel.org>
22  *
23  */
24 #ifndef LIBTIZEN_PLATFORM_WRAPPER
25 #define LIBTIZEN_PLATFORM_WRAPPER
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #include <tzplatform_variables.h>
32
33 /*
34  Enforces the removal of the previously evaluated tizen platform variables.
35
36  Call this function in case of changing of user inside the application.
37 */
38 extern
39 void tzplatform_reset();
40
41 /*
42  Return the count of variables.
43 */
44 extern
45 int tzplatform_getcount();
46
47 /*
48  Return the name of the variable 'id' as a string.
49  Return NULL if 'id' is invalid.
50 */
51 extern
52 const char* tzplatform_getname(enum tzplatform_variable id);
53
54 /*
55  Return the id of the variable of 'name'.
56  Return _TZPLATFORM_VARIABLES_INVALID_ if 'name' doesn't match a 
57  valid variable name.
58 */
59 extern
60 enum tzplatform_variable tzplatform_getid(const char *name);
61
62 /*
63  Return the read-only string value of the tizen plaform variable 'id'.
64  The tizen global values are globals to the application.
65  Can return NULL in case of internal error or when 'id' isn't defined.
66 */
67 extern
68 const char* tzplatform_getenv(enum tzplatform_variable id);
69
70 /*
71  Return the integer value of the tizen plaform variable 'id'.
72 */
73 extern
74 int tzplatform_getenv_int(enum tzplatform_variable id);
75
76 /*
77  Return the string resulting of the concatenation of string value of the 
78  tizen plaform variable 'id' and the given string 'str'.
79
80  The returned value is a scratch buffer (unique for the thread) that is
81  available until the next call to 'tzplatform_mkstr', 'tzplatform_mkpath', or,
82  'tzplatform_mkpath3'.
83
84  Can return NULL in case of internal error.
85
86  Example:
87     if TZ_SYS_HOME == "/opt/home" then calling
88
89        tzplatform_mkstr(TZ_SYS_HOME,"-yes") 
90
91     will return "/opt/home-yes"
92 */
93 extern
94 const char* tzplatform_mkstr(enum tzplatform_variable id, const char * str);
95
96 /*
97  Return the string resulting of the path-concatenation of string value of the 
98  tizen plaform variable 'id' and the given string 'path'.
99
100  path-concatenation is the concatenation taking care of / characters.
101
102  The returned value is a scratch buffer (unique for the thread) that is
103  available until the next call to 'tzplatform_mkstr', 'tzplatform_mkpath', or,
104  'tzplatform_mkpath3'.
105
106  Can return NULL in case of internal error.
107
108  Example:
109     if TZ_SYS_HOME == "/opt/home" then calling
110
111        tzplatform_mkpath(TZ_SYS_HOME,"yes") 
112
113     will return "/opt/home/yes"
114 */
115 extern
116 const char* tzplatform_mkpath(enum tzplatform_variable id, const char * path);
117
118 /*
119  Return the string resulting of the path-concatenation of string value of the 
120  tizen plaform variable 'id' and the given strings 'path' and 'path2'.
121
122  path-concatenation is the concatenation taking care of / characters.
123
124  The returned value is a scratch buffer (unique for the thread) that is
125  available until the next call to 'tzplatform_mkstr', 'tzplatform_mkpath', or,
126  'tzplatform_mkpath3'.
127
128  Can return NULL in case of internal error.
129
130  Example:
131     if TZ_SYS_HOME == "/opt/home" then calling
132
133        tzplatform_mkpath3(TZ_SYS_HOME,"yes","no")
134
135     will return "/opt/home/yes/no"
136 */
137 extern
138 const char* tzplatform_mkpath3(enum tzplatform_variable id, const char * path, 
139                                                             const char* path2);
140
141 /*
142  Return the uid for a given user name, stored in variable <id>
143  Retun -1 in case of error.
144
145  Example:
146         if TZ_USER_NAME=="app" then calling:
147            
148            tzplatform_getuid(TZ_USER_NAME)
149         
150         will return the uid of the user 'app'
151 */
152 extern
153 uid_t tzplatform_getuid(enum tzplatform_variable id);
154
155 /*
156  Return the gid for a given group name, stored in variable <id>
157  Retun -1 in case of error.
158
159  Example:
160         if TZ_USER_GROUP=="app" then calling:
161            
162            tzplatform_getuid(TZ_USER_GROUP)
163         
164         will return the gid of the group 'app'
165 */
166 extern
167 gid_t tzplatform_getgid(enum tzplatform_variable id);
168
169 #ifdef __cplusplus
170 }
171 #endif
172
173 #endif // _LIBTIZEN-PLATFORM-WRAPPER