Hello, attached are two patches adding bindings for augeas [1]. """Augeas is a configuration editing tool. It parses configuration files in their native formats and transforms them into a tree. Configuration changes are made by manipulating this tree and saving it back into native config files."""
A third file contains an example usage. I've previously opened a bug [2], but hope that those patche are easier to apply when distributed this way. Greetings fabian -- 1: http://www.augeas.net 2: https://bugzilla.gnome.org/show_bug.cgi?id=621697
From 4f769985ea4174a5eed16e6dc2343094ad744aed Mon Sep 17 00:00:00 2001 From: Fabian Deutsch <[email protected]> Date: Sat, 19 Jun 2010 22:04:38 +0200 Subject: [PATCH 1/2] Add bindings for augeas. Signed-off-by: Fabian Deutsch <[email protected]> --- vapi/augeas.vapi | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-) create mode 100644 vapi/augeas.vapi diff --git a/vapi/augeas.vapi b/vapi/augeas.vapi new file mode 100644 index 0000000..e73aeec --- /dev/null +++ b/vapi/augeas.vapi @@ -0,0 +1,95 @@ +/* augeas.vapi + * + * Copyright (C) 2010 Fabian Deutsch + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Fabian Deutsch <[email protected]> + */ + +[CCode (cheader_filename = "augeas.h")] +namespace Augeas { + + [Flags] + [CCode (cprefix = "AUG_")] + public enum InitFlags { + NONE, + SAVE_BACKUP, + SAVE_NEWFILE, + TYPE_CHECK, + NO_STDINC, + SAVE_NOOP, + NO_LOAD, + NO_MODL_AUTOLOAD + } + + [CCode (cprefix= "AUG_")] + public enum ErrorCode + { + NOERROR, + ENOMEM, + EINTERNAL, + EPATHX, + ENOMATCH, + EMMATCH, + ESYNTAX, + ENOLENS, + EMXFM + } + + [Compact] + [CCode (cname = "augeas", cprefix = "aug_", free_function = "aug_close")] + public class Augeas { + + [CCode (cname = "aug_init")] + public Augeas (string? root = null, string? loadpath = null, uint flags = 0); + + public int defvar (string name, string? expr); + public int defnode (string name, string expr, string value, out int created); + + public int get (string path, out unowned string? value); + public int set (string path, string value); + public int insert (string path, string label, int before); + + public int rm (string path); + public int mv (string src, string dst); + + [CCode (cname = "aug_match_wrapper")] + public int match (string path, out string[]? matches = null) + { + int len = _match (path, out matches); + if( matches != null ) matches.length = len; + return len; + } + [CCode (cname = "aug_match")] + int _match(string p, [CCode (array_length = false)] out string[]? matches); + + public int save (); + public int load (); +#if POSIX + public int print (Posix.FILE out, string path); +#else + public int print (GLib.FileStream out, string path); +#endif + public void close (); + + public ErrorCode error (); + public string error_message (); + public string error_minor_message (); + public string error_details (); + } +} + -- 1.7.1
From 5e8009cdfe8de93b5b2764ac6af5649944a3a1ed Mon Sep 17 00:00:00 2001 From: Fabian Deutsch <[email protected]> Date: Sat, 19 Jun 2010 22:05:45 +0200 Subject: [PATCH 2/2] Add augeas bindings to Makefile.am Signed-off-by: Fabian Deutsch <[email protected]> --- vapi/Makefile.am | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/vapi/Makefile.am b/vapi/Makefile.am index 591ef40..aabadd8 100644 --- a/vapi/Makefile.am +++ b/vapi/Makefile.am @@ -8,6 +8,7 @@ vala-1.0.vapi: ../gee/gee.vapi ../ccode/ccode.vapi ../vala/vala.vapi ../codegen/ dist_vapi_DATA = \ alsa.vapi \ atk.vapi \ + augeas.vapi \ avahi-gobject.deps \ avahi-gobject.vapi \ bzlib.vapi \ -- 1.7.1
/*
* valac --debug --verbose --save-temps --pkg augeas --vapidir . augeas-api-test-glib.vala
*/
using GLib.Test;
using LibAugeas;
string root;
string loadpath;
void test()
{
int r;
string value;
string[] values;
Augeas aug;
aug = new Augeas (root, loadpath, InitFlags.NO_STDINC | InitFlags.NO_LOAD);
r = aug.match ("/augeas/version/save/*", out values);
assert (r > 1);
assert (aug.error() == ErrorCode.NOERROR);
foreach (string value in values) debug ("vals: %s", value);
r = aug.get ("/augeas/version/save/*[1]", out value);
assert (r == 1);
assert (value != null);
assert (aug.error() == ErrorCode.NOERROR);
debug ("val: %s", value);
r = aug.get ("/augeas/version/save/*[ last() + 1 ]", out value);
assert (r == 0);
assert (value == null);
assert (aug.error() == ErrorCode.NOERROR);
debug ("val: %s", value);
r = aug.get ("/augeas/version/save/*", out value);
assert (r == -1);
assert (value == null);
assert (aug.error() == ErrorCode.EMMATCH);
}
int main(string[] args)
{
root = args[1] + "/tests/root";
loadpath = args[1] + "/tests/lenses";
init (ref args);
add_func ("/augeas/api-test", test);
return run ();
}
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
