rpm  5.4.15
Macros | Typedefs | Functions | Variables
rpmaug.h File Reference
#include <rpmiotypes.h>
#include <rpmio.h>
#include <popt.h>
Include dependency graph for rpmaug.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define rpmaugUnlink(_aug)   ((rpmaug)rpmioUnlinkPoolItem((rpmioItem)(_aug), __FUNCTION__, __FILE__, __LINE__))
 
#define rpmaugLink(_aug)   ((rpmaug)rpmioLinkPoolItem((rpmioItem)(_aug), __FUNCTION__, __FILE__, __LINE__))
 
#define rpmaugFree(_aug)   ((rpmaug)rpmioFreePoolItem((rpmioItem)(_aug), __FUNCTION__, __FILE__, __LINE__))
 

Typedefs

typedef struct rpmaug_s * rpmaug
 

Functions

rpmaug rpmaugUnlink (rpmaug aug)
 Unreference a augeas wrapper instance. More...
 
rpmaug rpmaugLink (rpmaug aug)
 Reference a augeas wrapper instance. More...
 
rpmaug rpmaugFree (rpmaug aug)
 Destroy a augeas wrapper. More...
 
rpmaug rpmaugNew (const char *root, const char *loadpath, unsigned int flags)
 Create and load a augeas wrapper. More...
 
int rpmaugDefvar (rpmaug aug, const char *name, const char *expr)
 Define an augeas variable. More...
 
int rpmaugDefnode (rpmaug aug, const char *name, const char *expr, const char *value, int *created)
 Define an augeas node. More...
 
int rpmaugGet (rpmaug aug, const char *path, const char **value)
 Get the value associated with a path. More...
 
int rpmaugSet (rpmaug aug, const char *path, const char *value)
 Set the value associated with a path. More...
 
int rpmaugInsert (rpmaug aug, const char *path, const char *label, int before)
 Insert new sibling node before/after a given node. More...
 
int rpmaugRm (rpmaug aug, const char *path)
 Remove node and associated sub-tree. More...
 
int rpmaugMv (rpmaug aug, const char *src, const char *dst)
 Move src node to dst node. More...
 
int rpmaugMatch (rpmaug aug, const char *path, char ***matches)
 Return path(s) in tree that match an expression. More...
 
int rpmaugSave (rpmaug aug)
 Save changed files to disk, appending .augnew or .augsave as requested. More...
 
int rpmaugLoad (rpmaug aug)
 Load files/lenses from disk. More...
 
int rpmaugPrint (rpmaug aug, FILE *out, const char *path)
 Print node paths that match an expression. More...
 
void rpmaugFprintf (rpmaug aug, const char *fmt,...)
 Append augeas output to an iob. More...
 
rpmRC rpmaugRun (rpmaug aug, const char *str, const char **resultp)
 Run augeas commands from a buffer. More...
 

Variables

int _rpmaug_debug
 
rpmaug _rpmaugI
 
const char * _rpmaugRoot
 
const char * _rpmaugLoadpath
 
unsigned int _rpmaugFlags
 
struct poptOption rpmaugPoptTable []
 Popt option table for options to configure Augeas augtool. More...
 

Macro Definition Documentation

#define rpmaugFree (   _aug)    ((rpmaug)rpmioFreePoolItem((rpmioItem)(_aug), __FUNCTION__, __FILE__, __LINE__))

Definition at line 94 of file rpmaug.h.

#define rpmaugLink (   _aug)    ((rpmaug)rpmioLinkPoolItem((rpmioItem)(_aug), __FUNCTION__, __FILE__, __LINE__))

Definition at line 82 of file rpmaug.h.

#define rpmaugUnlink (   _aug)    ((rpmaug)rpmioUnlinkPoolItem((rpmioItem)(_aug), __FUNCTION__, __FILE__, __LINE__))

Definition at line 71 of file rpmaug.h.

Typedef Documentation

typedef struct rpmaug_s* rpmaug

Definition at line 14 of file rpmaug.h.

Function Documentation

int rpmaugDefnode ( rpmaug  aug,
const char *  name,
const char *  expr,
const char *  value,
int *  created 
)

Define an augeas node.

Parameters
augaugeas wrapper (NULL uses global interpreter)
namevariable name
exprexpression to be evaluated (must eval to a nodeset)
valueinitial node value (if creating)
Return values
*created1 if node was created
Returns
-1 on error, or no. nodes in set

Definition at line 179 of file rpmaug.c.

Referenced by cmd_defnode().

int rpmaugDefvar ( rpmaug  aug,
const char *  name,
const char *  expr 
)

Define an augeas variable.

Parameters
augaugeas wrapper (NULL uses global interpreter)
namevariable name
exprexpression to be evaluated
Returns
-1 on error, or no. nodes in nodeset

Definition at line 165 of file rpmaug.c.

Referenced by cmd_defvar().

void rpmaugFprintf ( rpmaug  aug,
const char *  fmt,
  ... 
)

Append augeas output to an iob.

Parameters
augaugeas wrapper (NULL uses global interpreter)
fmtformat to use

Definition at line 322 of file rpmaug.c.

References _free(), b, rpmiobAppend(), vsnprintf(), xmalloc, and xrealloc.

Referenced by cmd_clear(), cmd_defnode(), cmd_defvar(), cmd_get(), cmd_help(), cmd_ins(), cmd_load(), cmd_ls(), cmd_match(), cmd_mv(), cmd_rm(), cmd_save(), cmd_set(), and rpmaugRun().

rpmaug rpmaugFree ( rpmaug  aug)

Destroy a augeas wrapper.

Parameters
augaugeas wrapper
Returns
NULL on last dereference

Referenced by expandMacro(), and rpmioClean().

int rpmaugGet ( rpmaug  aug,
const char *  path,
const char **  value 
)

Get the value associated with a path.

Parameters
augaugeas wrapper (NULL uses global interpreter)
pathpath to lookup
Return values
*valuereturned value (malloc'd)
Returns
-1 if multiple paths, 0 if none, 1 on success

Definition at line 194 of file rpmaug.c.

Referenced by cmd_get(), cmd_ls(), and cmd_match().

int rpmaugInsert ( rpmaug  aug,
const char *  path,
const char *  label,
int  before 
)

Insert new sibling node before/after a given node.

Parameters
augaugeas wrapper (NULL uses global interpreter)
pathpath to node in tree
labellabel to insert
beforeinsert label into tree before path? (else after)
Returns
-1 on failure, 0 on success

Definition at line 222 of file rpmaug.c.

Referenced by cmd_ins().

rpmaug rpmaugLink ( rpmaug  aug)

Reference a augeas wrapper instance.

Parameters
augaugeas wrapper
Returns
new augeas wrapper reference

Referenced by rpmaugNew().

int rpmaugLoad ( rpmaug  aug)

Load files/lenses from disk.

Parameters
augaugeas wrapper (NULL uses global interpreter)
Returns
-1 on error, 0 on success

Definition at line 292 of file rpmaug.c.

Referenced by cmd_load().

int rpmaugMatch ( rpmaug  aug,
const char *  path,
char ***  matches 
)

Return path(s) in tree that match an expression.

Parameters
augaugeas wrapper (NULL uses global interpreter)
pathpath expression to match
Return values
*matchespaths that match
Returns
no. of matches

Definition at line 264 of file rpmaug.c.

Referenced by child_count(), cmd_load(), cmd_ls(), cmd_match(), and cmd_save().

int rpmaugMv ( rpmaug  aug,
const char *  src,
const char *  dst 
)

Move src node to dst node.

Parameters
augaugeas wrapper (NULL uses global interpreter)
srcsrc path to node in tree
dstdst path to node in tree
Returns
-1 on failure, 0 on success

Definition at line 250 of file rpmaug.c.

Referenced by cmd_mv().

rpmaug rpmaugNew ( const char *  root,
const char *  loadpath,
unsigned int  flags 
)

Create and load a augeas wrapper.

Todo:
Change to common RPM embedded interpreter API.
Parameters
rootaugeas filesystem root
loadpathaugeas load path (colon separated)
flagsaugeas flags
Returns
new augeas wrapper

Definition at line 132 of file rpmaug.c.

References _rpmaugLoadpath, _rpmaugRoot, flags, rpmaugGetPool(), rpmaugLink(), rpmiobNew(), and xstrdup().

Referenced by expandMacro().

int rpmaugPrint ( rpmaug  aug,
FILE *  out,
const char *  path 
)

Print node paths that match an expression.

Parameters
augaugeas wrapper (NULL uses global interpreter)
outouput file (NULL uses stdout)
pathnode path expression
Returns
0 on success, <0 on error

Definition at line 306 of file rpmaug.c.

Referenced by cmd_print().

int rpmaugRm ( rpmaug  aug,
const char *  path 
)

Remove node and associated sub-tree.

Parameters
augaugeas wrapper (NULL uses global interpreter)
pathpath to node in tree to remove
Returns
-1 on failure, 0 on success

Definition at line 236 of file rpmaug.c.

Referenced by cmd_rm().

rpmRC rpmaugRun ( rpmaug  aug,
const char *  str,
const char **  resultp 
)

Run augeas commands from a buffer.

Parameters
augaugeas wrapper (NULL uses global interpreter)
straugeas commands to run
Return values
*resultpoutput running augeas commands
Returns
RPMRC_OK on success

Definition at line 763 of file rpmaug.c.

References _free(), rpmioP_s::ac, argvFree(), rpmioP_s::av, rpmaugFprintf(), rpmiobStr(), rpmioParse(), RPMRC_FAIL, RPMRC_NOTFOUND, RPMRC_OK, and rpmioP_s::str.

Referenced by expandMacro().

int rpmaugSave ( rpmaug  aug)

Save changed files to disk, appending .augnew or .augsave as requested.

Parameters
augaugeas wrapper (NULL uses global interpreter)
Returns
-1 on error, 0 on success

Definition at line 278 of file rpmaug.c.

Referenced by cmd_save().

int rpmaugSet ( rpmaug  aug,
const char *  path,
const char *  value 
)

Set the value associated with a path.

Parameters
augaugeas wrapper (NULL uses global interpreter)
pathpath to lookup
valuevalue
Returns
-1 if multiple paths, 0 if none, 1 on success

Definition at line 208 of file rpmaug.c.

Referenced by cmd_clear(), and cmd_set().

rpmaug rpmaugUnlink ( rpmaug  aug)

Unreference a augeas wrapper instance.

Parameters
augaugeas wrapper
Returns
NULL on last dereference

Variable Documentation

int _rpmaug_debug

Definition at line 33 of file rpmaug.c.

unsigned int _rpmaugFlags

Definition at line 80 of file rpmaug.c.

Referenced by expandMacro().

rpmaug _rpmaugI

Definition at line 36 of file rpmaug.c.

Referenced by rpmioClean().

const char* _rpmaugLoadpath

Definition at line 79 of file rpmaug.c.

Referenced by expandMacro(), and rpmaugNew().

const char* _rpmaugRoot

Definition at line 76 of file rpmaug.c.

Referenced by expandMacro(), and rpmaugNew().

struct poptOption rpmaugPoptTable[]

Popt option table for options to configure Augeas augtool.

Definition at line 109 of file rpmaug.c.