X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=50079eb4d1219fb0bd07c32fa4970ade8695195a;hp=8ea12a737955fa962db954654fdd4c31c377b866;hb=2834059b2ac047bc099ed7617c4f6174d441d7e1;hpb=94050e0344685b6916e21581e618ad3e85795008 diff --git a/src/generator.ml b/src/generator.ml index 8ea12a7..50079eb 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -32,17 +32,25 @@ and ret = * indication, ie. 0 or -1. *) | Err + (* "Int" as a return value means an int which is -1 for error + * or any value >= 0 on success. + *) + | RInt of string (* "RBool" is a bool return value which can be true/false or * -1 for error. *) | RBool of string (* "RConstString" is a string that refers to a constant value. - * Try to avoid using this. + * Try to avoid using this. In particular you cannot use this + * for values returned from the daemon, because there is no + * thread-safe way to return them in the C API. *) | RConstString of string (* "RString" and "RStringList" are caller-frees. *) | RString of string | RStringList of string + (* Some limited tuples are possible: *) + | RIntBool of string * string (* LVM PVs, VGs and LVs. *) | RPVList of string | RVGList of string @@ -52,10 +60,12 @@ and args = | P0 | P1 of argt | P2 of argt * argt + | P3 of argt * argt * argt and argt = | String of string (* const char *name, cannot be NULL *) | OptString of string (* const char *name, may be NULL *) | Bool of string (* boolean *) + | Int of string (* int (smallish ints, signed, <= 31 bits) *) type flags = | ProtocolLimitWarning (* display warning about protocol size limits *) @@ -310,6 +320,165 @@ of the L command. The \"full\" version includes all fields."); "\ List all the logical volumes detected. This is the equivalent of the L command. The \"full\" version includes all fields."); + + ("read_lines", (RStringList "lines", P1 (String "path")), 15, [], + "read file as lines", + "\ +Return the contents of the file named C. + +The file contents are returned as a list of lines. Trailing +C and C character sequences are I returned. + +Note that this function cannot correctly handle binary files +(specifically, files containing C<\\0> character which is treated +as end of line). For those you need to use the C +function which has a more complex interface."); + + ("aug_init", (Err, P2 (String "root", Int "flags")), 16, [], + "create a new Augeas handle", + "\ +Create a new Augeas handle for editing configuration files. +If there was any previous Augeas handle associated with this +guestfs session, then it is closed. + +You must call this before using any other C +commands. + +C is the filesystem root. C must not be NULL, +use C instead. + +The flags are the same as the flags defined in +Eaugeas.hE, the logical I of the following +integers: + +=over 4 + +=item C = 1 + +Keep the original file with a C<.augsave> extension. + +=item C = 2 + +Save changes into a file with extension C<.augnew>, and +do not overwrite original. Overrides C. + +=item C = 4 + +Typecheck lenses (can be expensive). + +=item C = 8 + +Do not use standard load path for modules. + +=item C = 16 + +Make save a no-op, just record what would have been changed. + +=item C = 32 + +Do not load the tree in C. + +=back + +To close the handle, you can call C. + +To find out more about Augeas, see L."); + + ("aug_close", (Err, P0), 26, [], + "close the current Augeas handle", + "\ +Close the current Augeas handle and free up any resources +used by it. After calling this, you have to call +C again before you can use any other +Augeas functions."); + + ("aug_defvar", (RInt "nrnodes", P2 (String "name", OptString "expr")), 17, [], + "define an Augeas variable", + "\ +Defines an Augeas variable C whose value is the result +of evaluating C. If C is NULL, then C is +undefined. + +On success this returns the number of nodes in C, or +C<0> if C evaluates to something which is not a nodeset."); + + ("aug_defnode", (RIntBool ("nrnodes", "created"), P3 (String "name", String "expr", String "val")), 18, [], + "define an Augeas node", + "\ +Defines a variable C whose value is the result of +evaluating C. + +If C evaluates to an empty nodeset, a node is created, +equivalent to calling C C, C. +C will be the nodeset containing that single node. + +On success this returns a pair containing the +number of nodes in the nodeset, and a boolean flag +if a node was created."); + + ("aug_get", (RString "val", P1 (String "path")), 19, [], + "look up the value of an Augeas path", + "\ +Look up the value associated with C. If C +matches exactly one node, the C is returned."); + + ("aug_set", (Err, P2 (String "path", String "val")), 20, [], + "set Augeas path to value", + "\ +Set the value associated with C to C."); + + ("aug_insert", (Err, P3 (String "path", String "label", Bool "before")), 21, [], + "insert a sibling Augeas node", + "\ +Create a new sibling C