/* * call-seq: * setm(BASE, SUB, VALUE) -> boolean * * Set multiple nodes in one operation. Find or create a node matching * SUB by interpreting SUB as a path expression relative to each node * matching BASE. SUB may be NULL, in which case all the nodes matching * BASE will be modified. */ VALUE augeas_setm(VALUE s, VALUE base, VALUE sub, VALUE value) { augeas *aug = aug_handle(s); const char *cbase = StringValueCStr(base) ; const char *csub = StringValueCStrOrNull(sub) ; const char *cvalue = StringValueCStrOrNull(value) ; int callValue = aug_setm(aug, cbase, csub, cvalue) ; return INT2FIX(callValue); }
VALUE augeas_init(VALUE m, VALUE r, VALUE l, VALUE f) { unsigned int flags = NUM2UINT(f); const char *root = StringValueCStrOrNull(r); const char *loadpath = StringValueCStrOrNull(l); augeas *aug = NULL; aug = aug_init(root, loadpath, flags); if (aug == NULL) { rb_raise(rb_eSystemCallError, "Failed to initialize Augeas"); } return Data_Wrap_Struct(c_augeas, NULL, augeas_free, aug); }
/* * call-seq: * defnode(NAME, EXPR, VALUE) -> boolean * * Define a variable NAME whose value is the result of evaluating EXPR, * which must be non-NULL and evaluate to a nodeset. If a variable NAME * already exists, its name will be replaced with the result of evaluating * EXPR. * * If EXPR evaluates to an empty nodeset, a node is created, equivalent to * calling AUG_SET(AUG, EXPR, VALUE) and NAME will be the nodeset containing * that single node. * * Returns +false+ if +aug_defnode+ fails, and the number of nodes in the * nodeset on success. */ VALUE augeas_defnode(VALUE s, VALUE name, VALUE expr, VALUE value) { augeas *aug = aug_handle(s); const char *cname = StringValueCStr(name); const char *cexpr = StringValueCStrOrNull(expr); const char *cvalue = StringValueCStrOrNull(value); /* FIXME: Figure out a way to return created, maybe accept a block that gets run when created == 1 ? */ int r = aug_defnode(aug, cname, cexpr, cvalue, NULL); return (r < 0) ? Qfalse : INT2NUM(r); }
static int set(VALUE s, VALUE path, VALUE value) { augeas *aug = aug_handle(s); const char *cpath = StringValueCStr(path) ; const char *cvalue = StringValueCStrOrNull(value) ; return aug_set(aug, cpath, cvalue) ; }
/* * call-seq: * defvar(NAME, EXPR) -> boolean * * Define a variable NAME whose value is the result of evaluating EXPR. If * a variable NAME already exists, its name will be replaced with the * result of evaluating EXPR. * * If EXPR is NULL, the variable NAME will be removed if it is defined. * */ VALUE augeas_defvar(VALUE s, VALUE name, VALUE expr) { augeas *aug = aug_handle(s); const char *cname = StringValueCStr(name); const char *cexpr = StringValueCStrOrNull(expr); int r = aug_defvar(aug, cname, cexpr); return (r < 0) ? Qfalse : Qtrue; }
/* * call-seq: * set(PATH, VALUE) -> boolean * * Set the value associated with PATH to VALUE. VALUE is copied into the * internal data structure. Intermediate entries are created if they don't * exist. */ VALUE augeas_set(VALUE s, VALUE path, VALUE value) { augeas *aug = aug_handle(s); const char *cpath = StringValueCStr(path) ; const char *cvalue = StringValueCStrOrNull(value) ; int callValue = aug_set(aug, cpath, cvalue) ; VALUE returnValue ; if (callValue == 0) returnValue = Qtrue ; else returnValue = Qfalse ; return returnValue ; }
VALUE augeas_defnode(VALUE s, VALUE name, VALUE expr, VALUE value) { augeas *aug = aug_handle(s); const char *cname = StringValueCStr(name); const char *cexpr = StringValueCStrOrNull(expr); const char *cvalue = StringValueCStrOrNull(value); /* FIXME: Figure out a way to return created, maybe accept a block that gets run when created == 1 ? */ int r = aug_defnode(aug, cname, cexpr, cvalue, NULL); return (r < 0) ? Qfalse : INT2NUM(r); } static VALUE init(VALUE class, VALUE m, VALUE r, VALUE l, VALUE f) { unsigned int flags = NUM2UINT(f); const char *root = StringValueCStrOrNull(r); const char *loadpath = StringValueCStrOrNull(l); augeas *aug = NULL; aug = aug_init(root, loadpath, flags); if (aug == NULL) { rb_raise(rb_eSystemCallError, "Failed to initialize Augeas"); } return Data_Wrap_Struct(class, NULL, augeas_free, aug); } VALUE augeas_init(VALUE m, VALUE r, VALUE l, VALUE f) { return init(c_augeas, m, r, l, f); } VALUE facade_init(VALUE m, VALUE r, VALUE l, VALUE f) {