Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 459 lines (364 sloc) 11.925 kb
995c36d @ppadron first commit
authored
1 /*
2 +----------------------------------------------------------------------+
81c6369 @ppadron tabs instead of spaces
authored
3 | PHP Version 5 |
995c36d @ppadron first commit
authored
4 +----------------------------------------------------------------------+
81c6369 @ppadron tabs instead of spaces
authored
5 | Copyright (c) 1997-2007 The PHP Group |
995c36d @ppadron first commit
authored
6 +----------------------------------------------------------------------+
1ced600 @ppadron tabs instead of spaces
authored
7 | This source file is subject to version 3.01 of the PHP license, |
995c36d @ppadron first commit
authored
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
0779ee0 @ppadron added a few comment blocks
authored
15 | Author: Pedro Padron <ppadron@php.net> |
995c36d @ppadron first commit
authored
16 +----------------------------------------------------------------------+
17 */
18
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22
23 #include "php.h"
24 #include "php_ini.h"
57de47b @ppadron including zend_extensions.h header file. fixes apache segfault on 64bit
authored
25 #include "zend_exceptions.h"
995c36d @ppadron first commit
authored
26 #include "ext/standard/info.h"
27 #include "augeas.h"
28 #include "php_augeas.h"
29
1ebc916 first version of object oriented API
Pedro Padron authored
30 /* {{{ zend_class_entry */
31 zend_class_entry *augeas_ce_Augeas;
dbe3fce @ppadron added AugeasException class
authored
32 zend_class_entry *augeas_ce_AugeasException;
1ebc916 first version of object oriented API
Pedro Padron authored
33 /* }}} */
34
35 /* {{{ ZEND_BEGIN_ARG_INFO */
61e07ae @ppadron Augeas::__construct() ZEND_ARG_INFO now describes parameters as optional
authored
36 ZEND_BEGIN_ARG_INFO_EX(arginfo_Augeas__construct, 0, 0, 0)
aa1b4e4 @ppadron tabs instead of spaces
authored
37 ZEND_ARG_INFO(0, root)
38 ZEND_ARG_INFO(0, loadpath)
39 ZEND_ARG_INFO(0, flags)
5af9d27 @ppadron added Reflection support by specifying arginfos
authored
40 ZEND_END_ARG_INFO();
41
1ebc916 first version of object oriented API
Pedro Padron authored
42 ZEND_BEGIN_ARG_INFO(arginfo_Augeas_get, 0)
aa1b4e4 @ppadron tabs instead of spaces
authored
43 ZEND_ARG_INFO(0, path)
5af9d27 @ppadron added Reflection support by specifying arginfos
authored
44 ZEND_END_ARG_INFO();
45
1ebc916 first version of object oriented API
Pedro Padron authored
46 ZEND_BEGIN_ARG_INFO(arginfo_Augeas_match, 0)
aa1b4e4 @ppadron tabs instead of spaces
authored
47 ZEND_ARG_INFO(0, path)
5af9d27 @ppadron added Reflection support by specifying arginfos
authored
48 ZEND_END_ARG_INFO();
49
1ebc916 first version of object oriented API
Pedro Padron authored
50 ZEND_BEGIN_ARG_INFO(arginfo_Augeas_set, 0)
aa1b4e4 @ppadron tabs instead of spaces
authored
51 ZEND_ARG_INFO(0, path)
52 ZEND_ARG_INFO(0, value)
5af9d27 @ppadron added Reflection support by specifying arginfos
authored
53 ZEND_END_ARG_INFO();
54
1ebc916 first version of object oriented API
Pedro Padron authored
55 ZEND_BEGIN_ARG_INFO(arginfo_Augeas_save, 0)
5af9d27 @ppadron added Reflection support by specifying arginfos
authored
56 ZEND_END_ARG_INFO();
57
1ebc916 first version of object oriented API
Pedro Padron authored
58 ZEND_BEGIN_ARG_INFO(arginfo_Augeas_rm, 0)
aa1b4e4 @ppadron tabs instead of spaces
authored
59 ZEND_ARG_INFO(0, path)
5af9d27 @ppadron added Reflection support by specifying arginfos
authored
60 ZEND_END_ARG_INFO();
61
a71069c @ppadron new method: Augeas::mv()
authored
62 ZEND_BEGIN_ARG_INFO(arginfo_Augeas_mv, 0)
63 ZEND_ARG_INFO(0, source)
64 ZEND_ARG_INFO(0, destination)
65 ZEND_END_ARG_INFO();
66
91e6568 @ppadron update ZEND_ARG_INFO for Augeas::insert()
authored
67 ZEND_BEGIN_ARG_INFO_EX(arginfo_Augeas_insert, 0, 0, 2)
aa1b4e4 @ppadron tabs instead of spaces
authored
68 ZEND_ARG_INFO(0, path)
69 ZEND_ARG_INFO(0, label)
70 ZEND_ARG_INFO(0, order)
5af9d27 @ppadron added Reflection support by specifying arginfos
authored
71 ZEND_END_ARG_INFO();
72 /* }}} */
73
1ebc916 first version of object oriented API
Pedro Padron authored
74 /* {{{ augeas_methods */
75 static zend_function_entry augeas_methods[] = {
aa1b4e4 @ppadron tabs instead of spaces
authored
76 PHP_ME(Augeas, __construct, arginfo_Augeas__construct, ZEND_ACC_PUBLIC)
1ebc916 first version of object oriented API
Pedro Padron authored
77 PHP_ME(Augeas, get, arginfo_Augeas_get, ZEND_ACC_PUBLIC)
78 PHP_ME(Augeas, set, arginfo_Augeas_set, ZEND_ACC_PUBLIC)
79 PHP_ME(Augeas, match, arginfo_Augeas_match, ZEND_ACC_PUBLIC)
80 PHP_ME(Augeas, rm, arginfo_Augeas_rm, ZEND_ACC_PUBLIC)
81 PHP_ME(Augeas, save, arginfo_Augeas_save, ZEND_ACC_PUBLIC)
a71069c @ppadron new method: Augeas::mv()
authored
82 PHP_ME(Augeas, mv, arginfo_Augeas_mv, ZEND_ACC_PUBLIC)
1ebc916 first version of object oriented API
Pedro Padron authored
83 PHP_ME(Augeas, insert, arginfo_Augeas_insert, ZEND_ACC_PUBLIC)
84 { NULL, NULL, NULL }
995c36d @ppadron first commit
authored
85 };
a71069c @ppadron new method: Augeas::mv()
authored
86 /* }}} */
995c36d @ppadron first commit
authored
87
88 /* {{{ augeas_module_entry
89 */
90 zend_module_entry augeas_module_entry = {
91 STANDARD_MODULE_HEADER,
92 "augeas",
1ebc916 first version of object oriented API
Pedro Padron authored
93 NULL,
995c36d @ppadron first commit
authored
94 PHP_MINIT(augeas),
95 PHP_MSHUTDOWN(augeas),
96 NULL,
97 NULL,
98 PHP_MINFO(augeas),
8311ccf @ppadron added module version information to phpinfo()
authored
99 PHP_AUGEAS_VERSION,
995c36d @ppadron first commit
authored
100 STANDARD_MODULE_PROPERTIES
101 };
102 /* }}} */
103
104 #ifdef COMPILE_DL_AUGEAS
105 ZEND_GET_MODULE(augeas)
106 #endif
107
a10426c @ppadron resource type is no longer used.
authored
108 /* {{{ AUGEAS_FROM_OBJECT */
109 #define AUGEAS_FROM_OBJECT(intern, object) \
110 { \
111 php_augeas_object *obj = (php_augeas_object*) zend_object_store_get_object(object TSRMLS_CC); \
112 intern = obj->augeas; \
113 if (!intern) { \
57de47b @ppadron including zend_extensions.h header file. fixes apache segfault on 64bit
authored
114 zend_throw_exception(augeas_ce_AugeasException, "Invalid or unitialized Augeas object", 0 TSRMLS_CC); \
a10426c @ppadron resource type is no longer used.
authored
115 RETURN_FALSE; \
116 } \
117 }
118 /* }}} */
119
120 /* {{{ augeas_object_dtor() */
121 static void augeas_object_dtor(void *object, zend_object_handle handle TSRMLS_DC)
52ebf2a @ppadron coding standards fixes
authored
122 {
a10426c @ppadron resource type is no longer used.
authored
123 php_augeas_object *intern;
0d00030 @ppadron new: augeas_close, destructor. fix: augeas_init default values
authored
124
a10426c @ppadron resource type is no longer used.
authored
125 intern = (php_augeas_object *) object;
126
127 zend_hash_destroy(intern->zo.properties);
128 FREE_HASHTABLE(intern->zo.properties);
0d00030 @ppadron new: augeas_close, destructor. fix: augeas_init default values
authored
129
a10426c @ppadron resource type is no longer used.
authored
130 if (intern->augeas) {
131 aug_close(intern->augeas);
132 }
133
134 efree(object);
0d00030 @ppadron new: augeas_close, destructor. fix: augeas_init default values
authored
135 }
0779ee0 @ppadron added a few comment blocks
authored
136 /* }}} */
0d00030 @ppadron new: augeas_close, destructor. fix: augeas_init default values
authored
137
a10426c @ppadron resource type is no longer used.
authored
138 /* {{{ augeas_object_new() */
139 static zend_object_value augeas_object_new(zend_class_entry *class_type TSRMLS_DC)
1ebc916 first version of object oriented API
Pedro Padron authored
140 {
a10426c @ppadron resource type is no longer used.
authored
141 zend_object_value retval;
142 php_augeas_object *intern;
143 zval *tmp;
1ebc916 first version of object oriented API
Pedro Padron authored
144
a10426c @ppadron resource type is no longer used.
authored
145 intern = emalloc(sizeof(php_augeas_object));
146 memset(intern, 0, sizeof(php_augeas_object));
147 intern->zo.ce = class_type;
148
149 ALLOC_HASHTABLE(intern->zo.properties);
150 zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
151 zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
1ebc916 first version of object oriented API
Pedro Padron authored
152
a10426c @ppadron resource type is no longer used.
authored
153 retval.handle = zend_objects_store_put(intern, augeas_object_dtor, NULL, NULL TSRMLS_CC);
154 retval.handlers = zend_get_std_object_handlers();
1ebc916 first version of object oriented API
Pedro Padron authored
155
a10426c @ppadron resource type is no longer used.
authored
156 return retval;
157
1ebc916 first version of object oriented API
Pedro Padron authored
158 }
159 /* }}} */
0d00030 @ppadron new: augeas_close, destructor. fix: augeas_init default values
authored
160
995c36d @ppadron first commit
authored
161 /* {{{ PHP_MINIT_FUNCTION
162 */
163 PHP_MINIT_FUNCTION(augeas)
164 {
5384536 @ppadron additional cleanup at MINIT
authored
165 zend_class_entry ce, ce_exception;
dbe3fce @ppadron added AugeasException class
authored
166
167 /* Register AugeasException class (inherits Exception) */
5384536 @ppadron additional cleanup at MINIT
authored
168 INIT_CLASS_ENTRY(ce_exception, "AugeasException", NULL);
169 augeas_ce_AugeasException = zend_register_internal_class_ex(&ce_exception, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_DC);
1ebc916 first version of object oriented API
Pedro Padron authored
170
aa1b4e4 @ppadron tabs instead of spaces
authored
171 /* Register Augeas class */
172 INIT_CLASS_ENTRY(ce, "Augeas", augeas_methods);
173 augeas_ce_Augeas = zend_register_internal_class(&ce TSRMLS_CC);
a10426c @ppadron resource type is no longer used.
authored
174 augeas_ce_Augeas->create_object = augeas_object_new;
1ebc916 first version of object oriented API
Pedro Padron authored
175
176 /* Register Augeas class constants */
5384536 @ppadron additional cleanup at MINIT
authored
177 zend_declare_class_constant_long(augeas_ce_Augeas, "AUGEAS_NONE", sizeof("AUGEAS_NONE")-1, AUG_NONE TSRMLS_CC);
178 zend_declare_class_constant_long(augeas_ce_Augeas, "AUGEAS_SAVE_BACKUP", sizeof("AUGEAS_SAVE_BACKUP")-1, AUG_SAVE_BACKUP TSRMLS_CC);
179 zend_declare_class_constant_long(augeas_ce_Augeas, "AUGEAS_SAVE_NEWFILE", sizeof("AUGEAS_SAVE_NEWFILE")-1, AUG_SAVE_NEWFILE TSRMLS_CC);
180 zend_declare_class_constant_long(augeas_ce_Augeas, "AUGEAS_TYPE_CHECK", sizeof("AUGEAS_TYPE_CHECK")-1, AUG_TYPE_CHECK TSRMLS_CC);
181 zend_declare_class_constant_long(augeas_ce_Augeas, "AUGEAS_NO_STDINC", sizeof("AUGEAS_NO_STDINC")-1, AUG_NO_STDINC TSRMLS_CC);
182
183 zend_declare_class_constant_long(augeas_ce_Augeas, "AUGEAS_INSERT_BEFORE", sizeof("AUGEAS_INSERT_BEFORE")-1, 1 TSRMLS_CC);
184 zend_declare_class_constant_long(augeas_ce_Augeas, "AUGEAS_INSERT_AFTER", sizeof("AUGEAS_INSERT_AFTER")-1, 0 TSRMLS_CC);
1ebc916 first version of object oriented API
Pedro Padron authored
185
995c36d @ppadron first commit
authored
186 return SUCCESS;
187 }
188 /* }}} */
189
190 /* {{{ PHP_MSHUTDOWN_FUNCTION
191 */
192 PHP_MSHUTDOWN_FUNCTION(augeas)
193 {
194 return SUCCESS;
195 }
196 /* }}} */
197
198 /* {{{ PHP_MINFO_FUNCTION
199 */
200 PHP_MINFO_FUNCTION(augeas)
201 {
202 php_info_print_table_start();
203 php_info_print_table_header(2, "augeas support", "enabled");
8311ccf @ppadron added module version information to phpinfo()
authored
204 php_info_print_table_row(2, "augeas version", PHP_AUGEAS_VERSION);
995c36d @ppadron first commit
authored
205 php_info_print_table_end();
206
207 }
208 /* }}} */
209
0bbd2b4 @ppadron fixed proto doc for Augeas::__construct
authored
210 /* {{{ proto void Augeas::__construct([string $root[, string $loadpath[, int $flags]]]) */
1ebc916 first version of object oriented API
Pedro Padron authored
211 PHP_METHOD(Augeas, __construct)
52ebf2a @ppadron coding standards fixes
authored
212 {
aa1b4e4 @ppadron tabs instead of spaces
authored
213 char *root = "/";
214 char *loadpath = "";
d29a242 @ppadron resource_id is now declared in the beginning of the function
authored
215 int root_len, loadpath_len, resource_id;
aa1b4e4 @ppadron tabs instead of spaces
authored
216 long flags = AUG_NONE;
a10426c @ppadron resource type is no longer used.
authored
217 php_augeas_object *obj;
aa1b4e4 @ppadron tabs instead of spaces
authored
218 zval *resource;
219 zval *this;
995c36d @ppadron first commit
authored
220
f69444b @ppadron several changes
authored
221
aa1b4e4 @ppadron tabs instead of spaces
authored
222 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!l", &root, &root_len, &loadpath, &loadpath_len, &flags) == FAILURE) {
223 RETURN_FALSE;
224 }
995c36d @ppadron first commit
authored
225
aa1b4e4 @ppadron tabs instead of spaces
authored
226 if (php_check_open_basedir(root TSRMLS_DC) != 0) {
227 RETURN_FALSE;
228 }
1c671a1 @ppadron added open_basedir check
authored
229
a10426c @ppadron resource type is no longer used.
authored
230 obj = (php_augeas_object *) zend_object_store_get_object(getThis() TSRMLS_DC);
231 obj->augeas = aug_init(root, loadpath, flags);
995c36d @ppadron first commit
authored
232
57de47b @ppadron including zend_extensions.h header file. fixes apache segfault on 64bit
authored
233 if (!obj->augeas) zend_throw_exception(augeas_ce_AugeasException, "could not initialize augeas resource", 0 TSRMLS_CC);
1ebc916 first version of object oriented API
Pedro Padron authored
234
235 }
236 /* }}} */
f69444b @ppadron several changes
authored
237
c3ed0c1 @ppadron fixed proto brackets
authored
238 /* {{{ proto string Augeas::get(string $path) */
1ebc916 first version of object oriented API
Pedro Padron authored
239 PHP_METHOD(Augeas, get)
52ebf2a @ppadron coding standards fixes
authored
240 {
aa1b4e4 @ppadron tabs instead of spaces
authored
241 char *path, *value;
242 char **matches;
243 int path_len, retval;
a10426c @ppadron resource type is no longer used.
authored
244 php_augeas_object *obj;
245 augeas *aug_intern;
1ebc916 first version of object oriented API
Pedro Padron authored
246
aa1b4e4 @ppadron tabs instead of spaces
authored
247 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len) == FAILURE) {
248 RETURN_FALSE;
249 }
995c36d @ppadron first commit
authored
250
aa1b4e4 @ppadron tabs instead of spaces
authored
251 if (path_len < 1) {
252 RETURN_FALSE;
253 }
995c36d @ppadron first commit
authored
254
a10426c @ppadron resource type is no longer used.
authored
255 AUGEAS_FROM_OBJECT(aug_intern, getThis());
995c36d @ppadron first commit
authored
256
244c075 @ppadron fixed some compiler warnings
authored
257 retval = aug_get(aug_intern, path, (const char **) &value);
aa1b4e4 @ppadron tabs instead of spaces
authored
258
259 switch (retval) {
260
261 /* No match */
262 case 0:
263 RETURN_NULL();
264 break;
265
266 /* Exactly one match */
267 case 1:
268 /* If the specified path is a tree, NULL is returned */
269 if (value == NULL) {
270 RETURN_NULL();
271 }
272 RETURN_STRING(value, 1);
273 break;
274
275 default:
57de47b @ppadron including zend_extensions.h header file. fixes apache segfault on 64bit
authored
276 zend_throw_exception(augeas_ce_AugeasException, "specified path is invalid", 0 TSRMLS_CC);
aa1b4e4 @ppadron tabs instead of spaces
authored
277 break;
278 }
279
995c36d @ppadron first commit
authored
280 }
0779ee0 @ppadron added a few comment blocks
authored
281 /* }}} */
995c36d @ppadron first commit
authored
282
78b07d1 @ppadron fixed proto definitions (removed augeas resource)
authored
283 /* {{{ proto boolean Augeas::set(string $path, string $value);
aa1b4e4 @ppadron tabs instead of spaces
authored
284 Sets the value of $path to $value */
1ebc916 first version of object oriented API
Pedro Padron authored
285 PHP_METHOD(Augeas, set)
286 {
aa1b4e4 @ppadron tabs instead of spaces
authored
287 int path_len, value_len, retval;
288 char *path, *value;
a10426c @ppadron resource type is no longer used.
authored
289 augeas *aug_intern;
1ebc916 first version of object oriented API
Pedro Padron authored
290
aa1b4e4 @ppadron tabs instead of spaces
authored
291 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &path, &path_len, &value, &value_len)) {
292 RETURN_FALSE;
293 }
1ebc916 first version of object oriented API
Pedro Padron authored
294
a10426c @ppadron resource type is no longer used.
authored
295 AUGEAS_FROM_OBJECT(aug_intern, getThis());
1ebc916 first version of object oriented API
Pedro Padron authored
296
a10426c @ppadron resource type is no longer used.
authored
297 retval = aug_set(aug_intern, path, value);
1ebc916 first version of object oriented API
Pedro Padron authored
298
aa1b4e4 @ppadron tabs instead of spaces
authored
299 if (retval == 0) {
300 RETURN_TRUE;
301 } else {
302 RETURN_FALSE;
303 }
995c36d @ppadron first commit
authored
304
1ebc916 first version of object oriented API
Pedro Padron authored
305 }
306 /* }}} */
307
01646b6 @ppadron fixed proto for Augeas::match()
authored
308 /* {{{ proto array Augeas::match(string $path);
aa1b4e4 @ppadron tabs instead of spaces
authored
309 Returns an array with all the matches */
1ebc916 first version of object oriented API
Pedro Padron authored
310 PHP_METHOD(Augeas, match)
52ebf2a @ppadron coding standards fixes
authored
311 {
aa1b4e4 @ppadron tabs instead of spaces
authored
312 int i;
313 char *path;
d68d428 @ppadron implemented: Augeas::match() should return assoc array with nodes => val...
authored
314 char *value, *tmpval;
aa1b4e4 @ppadron tabs instead of spaces
authored
315 char **matches;
a10426c @ppadron resource type is no longer used.
authored
316 augeas *aug_intern;
f69444b @ppadron several changes
authored
317
aa1b4e4 @ppadron tabs instead of spaces
authored
318 int path_len, retval;
995c36d @ppadron first commit
authored
319
aa1b4e4 @ppadron tabs instead of spaces
authored
320 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len) == FAILURE) {
321 RETURN_FALSE;
322 }
995c36d @ppadron first commit
authored
323
a10426c @ppadron resource type is no longer used.
authored
324 AUGEAS_FROM_OBJECT(aug_intern, getThis());
995c36d @ppadron first commit
authored
325
a10426c @ppadron resource type is no longer used.
authored
326 retval = aug_match(aug_intern, path, &matches);
995c36d @ppadron first commit
authored
327
aa1b4e4 @ppadron tabs instead of spaces
authored
328 array_init(return_value);
63b0989 @ppadron in Augeas::match() an exception must be thrown if path is invalid
authored
329
330 if (retval == -1) {
57de47b @ppadron including zend_extensions.h header file. fixes apache segfault on 64bit
authored
331 zend_throw_exception(augeas_ce_AugeasException, "the specified path is invalid", 0 TSRMLS_CC);
63b0989 @ppadron in Augeas::match() an exception must be thrown if path is invalid
authored
332 return;
333 }
3856bc4 @ppadron if no match is found in Augeas::match(), an empty array should be return...
authored
334
335 if (retval > 0) {
336 for (i=0; i<retval; i++) {
d68d428 @ppadron implemented: Augeas::match() should return assoc array with nodes => val...
authored
337
244c075 @ppadron fixed some compiler warnings
authored
338 aug_get(aug_intern, matches[i], (const char **) &tmpval);
d68d428 @ppadron implemented: Augeas::match() should return assoc array with nodes => val...
authored
339
340 if (tmpval) {
341 add_assoc_string(return_value, matches[i], tmpval, 1);
342 } else {
343 add_assoc_null(return_value, matches[i]);
344 }
3856bc4 @ppadron if no match is found in Augeas::match(), an empty array should be return...
authored
345 }
aa1b4e4 @ppadron tabs instead of spaces
authored
346 }
995c36d @ppadron first commit
authored
347
3856bc4 @ppadron if no match is found in Augeas::match(), an empty array should be return...
authored
348 /* if no matches were found, an empty array (return_value) is returned */
349
995c36d @ppadron first commit
authored
350 }
c3ed0c1 @ppadron fixed proto brackets
authored
351 /* }}} */
995c36d @ppadron first commit
authored
352
78b07d1 @ppadron fixed proto definitions (removed augeas resource)
authored
353 /* {{{ proto boolean Augeas::rm(string $path);
aa1b4e4 @ppadron tabs instead of spaces
authored
354 Removes a node and all it's children */
1ebc916 first version of object oriented API
Pedro Padron authored
355 PHP_METHOD(Augeas, rm)
52ebf2a @ppadron coding standards fixes
authored
356 {
aa1b4e4 @ppadron tabs instead of spaces
authored
357 int path_len, value_len, retval;
358 char *path, *value;
a10426c @ppadron resource type is no longer used.
authored
359 augeas *aug_intern;
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
360
aa1b4e4 @ppadron tabs instead of spaces
authored
361 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len, &value, &value_len)) {
362 RETURN_FALSE;
363 }
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
364
a10426c @ppadron resource type is no longer used.
authored
365 AUGEAS_FROM_OBJECT(aug_intern, getThis());
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
366
aa1b4e4 @ppadron tabs instead of spaces
authored
367 /* aug_rm returns the number of removed entries */
a10426c @ppadron resource type is no longer used.
authored
368 retval = aug_rm(aug_intern, path);
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
369
aa1b4e4 @ppadron tabs instead of spaces
authored
370 RETURN_LONG(retval);
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
371 }
a71069c @ppadron new method: Augeas::mv()
authored
372 /* }}} * /
373
374 /* {{{ proto boolean Augeas::mv(string $source, string $destination);
375 Moves $source node to $destination. If $destination exists, it will be overwritten. */
376 PHP_METHOD(Augeas, mv)
377 {
378 char *src, *dst;
379 int src_len, dst_len, retval;
380 augeas *aug_intern;
381
382 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &src, &src_len, &dst, &dst_len)) {
383 RETURN_FALSE;
384 }
385
386 AUGEAS_FROM_OBJECT(aug_intern, getThis());
387
388 retval = aug_mv(aug_intern, src, dst);
389
390 if (retval == 0) {
391 RETURN_TRUE;
392 } else {
393 RETURN_FALSE;
394 }
395
396 }
0779ee0 @ppadron added a few comment blocks
authored
397 /* }}} */
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
398
a71069c @ppadron new method: Augeas::mv()
authored
399 /* {{{ proto boolean Augeas::insert(string $path, string $label[, int $order]);
aa1b4e4 @ppadron tabs instead of spaces
authored
400 Inserts a new sibling of path expression $path with label $label before or after $path, depending on $order. $path must match exactly one node in the tree. */
1ebc916 first version of object oriented API
Pedro Padron authored
401 PHP_METHOD(Augeas, insert)
aa1b4e4 @ppadron tabs instead of spaces
authored
402 {
403 char *path, *label;
6f9b2f8 @ppadron $order is now optional and defaults to AUGEAS_INSERT_BEFORE in Augeas::i...
authored
404 int retval, path_len, label_len;
405 int order = 0;
a10426c @ppadron resource type is no longer used.
authored
406 augeas *aug_intern;
aa1b4e4 @ppadron tabs instead of spaces
authored
407
6f9b2f8 @ppadron $order is now optional and defaults to AUGEAS_INSERT_BEFORE in Augeas::i...
authored
408 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &path, &path_len,
aa1b4e4 @ppadron tabs instead of spaces
authored
409 &label, &label_len, &order)) {
410 RETURN_FALSE;
411 }
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
412
a10426c @ppadron resource type is no longer used.
authored
413 AUGEAS_FROM_OBJECT(aug_intern, getThis());
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
414
a10426c @ppadron resource type is no longer used.
authored
415 retval = aug_insert(aug_intern, path, label, order);
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
416
aa1b4e4 @ppadron tabs instead of spaces
authored
417 if (retval == 0) {
418 RETURN_TRUE;
419 } else {
420 RETURN_FALSE;
421 }
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
422 }
1ebc916 first version of object oriented API
Pedro Padron authored
423 /* }}} */
4c19368 @ppadron new functions: augeas_rm, augeas_insert. and also new constants.
authored
424
a71069c @ppadron new method: Augeas::mv()
authored
425
78b07d1 @ppadron fixed proto definitions (removed augeas resource)
authored
426 /* {{{ proto boolean Augeas::save();
aa1b4e4 @ppadron tabs instead of spaces
authored
427 Saves the parts of the tree that have been changed into their respective files. */
1ebc916 first version of object oriented API
Pedro Padron authored
428 PHP_METHOD(Augeas, save)
52ebf2a @ppadron coding standards fixes
authored
429 {
aa1b4e4 @ppadron tabs instead of spaces
authored
430 zval *zaug;
431 int retval;
a10426c @ppadron resource type is no longer used.
authored
432 augeas *aug_intern;
a1750ba @ppadron new functions: augeas_set, augeas_save
authored
433
6dde6e0 Augeas::save() should not parse parameters
Pedro Padron authored
434 if (ZEND_NUM_ARGS()) {
435 WRONG_PARAM_COUNT;
436 }
a1750ba @ppadron new functions: augeas_set, augeas_save
authored
437
a10426c @ppadron resource type is no longer used.
authored
438 AUGEAS_FROM_OBJECT(aug_intern, getThis());
a1750ba @ppadron new functions: augeas_set, augeas_save
authored
439
a10426c @ppadron resource type is no longer used.
authored
440 retval = aug_save(aug_intern);
a1750ba @ppadron new functions: augeas_set, augeas_save
authored
441
aa1b4e4 @ppadron tabs instead of spaces
authored
442 if (retval == 0) {
443 RETURN_TRUE;
444 } else {
445 RETURN_FALSE;
446 }
a1750ba @ppadron new functions: augeas_set, augeas_save
authored
447
448 }
0779ee0 @ppadron added a few comment blocks
authored
449 /* }}} */
a1750ba @ppadron new functions: augeas_set, augeas_save
authored
450
995c36d @ppadron first commit
authored
451 /*
452 * Local variables:
453 * tab-width: 4
454 * c-basic-offset: 4
455 * End:
456 * vim600: noet sw=4 ts=4 fdm=marker
457 * vim<600: noet sw=4 ts=4
458 */
Something went wrong with that request. Please try again.