Instanciation of strings returned by mkpath...
[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 <sys/types.h>
32 #include <tzplatform_variables.h>
33
34 /*
35  Enforces the removal of the previously evaluated tizen platform variables.
36
37  Call this function in case of changing of user inside the application.
38 */
39 extern
40 void tzplatform_reset();
41
42 /*
43  Return the count of variables.
44 */
45 extern
46 int tzplatform_getcount();
47
48 /*
49  Return the name of the variable 'id' as a string.
50  Return NULL if 'id' is invalid.
51 */
52 extern
53 const char* tzplatform_getname(enum tzplatform_variable id);
54
55 /*
56  Return the id of the variable of 'name'.
57  Return _TZPLATFORM_VARIABLES_INVALID_ if 'name' doesn't match a 
58  valid variable name.
59 */
60 extern
61 enum tzplatform_variable tzplatform_getid(const char *name);
62
63 /*
64  Return the read-only string value of the tizen plaform variable 'id'.
65  The tizen global values are globals to the application.
66  Can return NULL in case of internal error or when 'id' isn't defined.
67 */
68 extern
69 const char* tzplatform_getenv(enum tzplatform_variable id);
70
71 /*
72  Return the integer value of the tizen plaform variable 'id'.
73 */
74 extern
75 int tzplatform_getenv_int(enum tzplatform_variable id);
76
77 /*
78  Return the string resulting of the concatenation of string value of the 
79  tizen plaform variable 'id' and the given string 'str'.
80
81  The returned value is an allocated unique string that MUST not be freed.
82
83  Can return NULL in case of internal error.
84
85  Example:
86     if TZ_SYS_HOME == "/opt/home" then calling
87
88        tzplatform_mkstr(TZ_SYS_HOME,"-yes") 
89
90     will return "/opt/home-yes"
91 */
92 extern
93 const char* tzplatform_mkstr(enum tzplatform_variable id, const char *str);
94
95 /*
96  Return the string resulting of the path-concatenation of string value of the 
97  tizen plaform variable 'id' and the given string 'path'.
98
99  path-concatenation is the concatenation taking care of / characters.
100
101  The returned value is an allocated unique string that MUST not be freed.
102
103  Can return NULL in case of internal error.
104
105  Example:
106     if TZ_SYS_HOME == "/opt/home" then calling
107
108        tzplatform_mkpath(TZ_SYS_HOME,"yes") 
109
110     will return "/opt/home/yes"
111 */
112 extern
113 const char* tzplatform_mkpath(enum tzplatform_variable id, const char *path);
114
115 /*
116  Return the string resulting of the path-concatenation of string value of the 
117  tizen plaform variable 'id' and the given strings 'path' and 'path2'.
118
119  path-concatenation is the concatenation taking care of / characters.
120
121  The returned value is an allocated unique string that MUST not be freed.
122
123  Can return NULL in case of internal error.
124
125  Example:
126     if TZ_SYS_HOME == "/opt/home" then calling
127
128        tzplatform_mkpath3(TZ_SYS_HOME,"yes","no")
129
130     will return "/opt/home/yes/no"
131 */
132 extern
133 const char* tzplatform_mkpath3(enum tzplatform_variable id, const char *path, 
134                                                             const char *path2);
135
136 /*
137  Return the string resulting of the path-concatenation of string value of the 
138  tizen plaform variable 'id' and the given strings 'path', 'path2' and 'path3'.
139
140  path-concatenation is the concatenation taking care of / characters.
141
142  The returned value is an allocated unique string that MUST not be freed.
143
144  Can return NULL in case of internal error.
145
146  Example:
147     if TZ_SYS_HOME == "/opt/home" then calling
148
149        tzplatform_mkpath4(TZ_SYS_HOME,"yes","no","/maybe")
150
151     will return "/opt/home/yes/no/maybe"
152 */
153 extern
154 const char* tzplatform_mkpath4(enum tzplatform_variable id, const char *path, 
155                                         const char *path2, const char *path3);
156
157 /*
158  Return the uid for a given user name, stored in variable <id>
159  Retun -1 in case of error.
160
161  Example:
162         if TZ_USER_NAME=="app" then calling:
163            
164            tzplatform_getuid(TZ_USER_NAME)
165         
166         will return the uid of the user 'app'
167 */
168 extern
169 uid_t tzplatform_getuid(enum tzplatform_variable id);
170
171 /*
172  Return the gid for a given group name, stored in variable <id>
173  Retun -1 in case of error.
174
175  Example:
176         if TZ_USER_GROUP=="app" then calling:
177            
178            tzplatform_getuid(TZ_USER_GROUP)
179         
180         will return the gid of the group 'app'
181 */
182 extern
183 gid_t tzplatform_getgid(enum tzplatform_variable id);
184
185 #ifdef __cplusplus
186 }
187 #endif
188
189 #endif // _LIBTIZEN-PLATFORM-WRAPPER