rpm  5.4.10
Macros | Typedefs | Functions | Variables
rpmmc-rb.c File Reference
#include "system.h"
#include "rpm-rb.h"
#include "rpmmc-rb.h"
#include <rpmmacro.h>
#include <rpmio/argv.h>
#include "../debug.h"
Include dependency graph for rpmmc-rb.c:

Go to the source code of this file.

Macros

#define _MACRO_INTERNAL
 

Typedefs

typedef MacroContext rpmmc
 

Functions

static rpmmc _rpmmc_get_mc (VALUE self)
 Returns the wrapped C structure ::MacroContext_s. More...
 
static VALUE rpmmc_add (VALUE self, VALUE macro)
 Adds a new macro definition to the Macro Context. More...
 
static VALUE rpmmc_del (VALUE self, VALUE macro)
 Deletes a macro definition. More...
 
static VALUE rpmmc_list (VALUE self)
 List all macro definitions in the corresponding Macro Context. More...
 
static VALUE rpmmc_expand (VALUE self, VALUE macro)
 Expands a macro. More...
 
static VALUE rpmmc_load_macro_file (VALUE self, VALUE fn_v, VALUE nesting_v)
 Loads a macro file. More...
 
static VALUE rpmmc_init_macros (VALUE self, VALUE macrofiles_v)
 Initializes a macro context from a list of files. More...
 
static void initMethods (VALUE klass)
 
static VALUE rpmmc_debug_get (VALUE s)
 Get debugging log level. More...
 
static VALUE rpmmc_debug_set (VALUE s, VALUE v)
 Set debugging log level. More...
 
static VALUE rpmmc_get_global_mc (void)
 Return the global macro context. More...
 
static VALUE rpmmc_get_cli_mc (void)
 Return the CLI macro context. More...
 
static void initProperties (VALUE klass)
 
static void _rpmmc_free (rpmmc mc)
 
VALUE rpmmc_wrap (rpmmc mc)
 Wraps an already existing MacroContext struct in a Ruby class. More...
 
static VALUE rpmmc_alloc (VALUE klass)
 
void Init_rpmmc (void)
 

Variables

VALUE rpmmcClass
 RPM::Mc macro context Ruby class. More...
 
static int _debug = 0
 

Macro Definition Documentation

§ _MACRO_INTERNAL

#define _MACRO_INTERNAL

Definition at line 9 of file rpmmc-rb.c.

Typedef Documentation

§ rpmmc

Definition at line 16 of file rpmmc-rb.c.

Function Documentation

§ _rpmmc_free()

static void _rpmmc_free ( rpmmc  mc)
static

Definition at line 314 of file rpmmc-rb.c.

References _free(), rpmCLIMacroContext, rpmFreeMacros(), and rpmGlobalMacroContext.

Referenced by rpmmc_wrap().

§ _rpmmc_get_mc()

static rpmmc _rpmmc_get_mc ( VALUE  self)
static

Returns the wrapped C structure ::MacroContext_s.

Definition at line 28 of file rpmmc-rb.c.

Referenced by rpmmc_add(), rpmmc_del(), rpmmc_expand(), rpmmc_init_macros(), rpmmc_list(), and rpmmc_load_macro_file().

§ Init_rpmmc()

void Init_rpmmc ( void  )

Definition at line 348 of file rpmmc-rb.c.

References _debug, initMethods(), initProperties(), rpmmc_alloc(), rpmmcClass, and rpmModule.

Referenced by Init_rpm().

§ initMethods()

static void initMethods ( VALUE  klass)
static

§ initProperties()

static void initProperties ( VALUE  klass)
static

Definition at line 301 of file rpmmc-rb.c.

References rpmmc_debug_get(), rpmmc_debug_set(), rpmmc_get_cli_mc(), and rpmmc_get_global_mc().

Referenced by Init_rpmmc().

§ rpmmc_add()

static VALUE rpmmc_add ( VALUE  self,
VALUE  macro 
)
static

Adds a new macro definition to the Macro Context.

call-seq: RPM::Mc::add(macro) -> RPM::Mc

Parameters
macroThe macro definition in string form just like it would be done in a macro definition file, but minus the define stanza.
Returns
The used macro context instance
See also
rpmDefineMacro()

Definition at line 48 of file rpmmc-rb.c.

References _debug, _rpmmc_get_mc(), rpm_rb_raise(), and rpmDefineMacro().

Referenced by initMethods().

§ rpmmc_alloc()

static VALUE rpmmc_alloc ( VALUE  klass)
static

Definition at line 334 of file rpmmc-rb.c.

References _debug, rpmmc_wrap(), and xcalloc().

Referenced by Init_rpmmc().

§ rpmmc_debug_get()

static VALUE rpmmc_debug_get ( VALUE  s)
static

Get debugging log level.

call-seq: RPM::Mc::debug -> Fixnum

Returns
The debugging level

Definition at line 244 of file rpmmc-rb.c.

References _debug.

Referenced by initProperties().

§ rpmmc_debug_set()

static VALUE rpmmc_debug_set ( VALUE  s,
VALUE  v 
)
static

Set debugging log level.

call-seq: RPM::Mc.debug = LEVEL -> Fixnum

Returns
The new debug level

Definition at line 261 of file rpmmc-rb.c.

References _debug.

Referenced by initProperties().

§ rpmmc_del()

static VALUE rpmmc_del ( VALUE  self,
VALUE  macro 
)
static

Deletes a macro definition.

call-seq: RPM::Mc::del(macro) -> RPM::Mc

Parameters
macroThe macro name
Returns
The Mc object instance
See also
rpmUndefineMacro()

Definition at line 77 of file rpmmc-rb.c.

References _debug, _rpmmc_get_mc(), rpm_rb_raise(), and rpmUndefineMacro().

Referenced by initMethods().

§ rpmmc_expand()

static VALUE rpmmc_expand ( VALUE  self,
VALUE  macro 
)
static

Expands a macro.

call-seq: RPM::Mc::expand(macro) -> String

Parameters
macroThe macro name (with leading % sign)
Returns
The result of the expansion

Definition at line 161 of file rpmmc-rb.c.

References _debug, _rpmmc_get_mc(), and rpmMCExpand().

Referenced by initMethods().

§ rpmmc_get_cli_mc()

static VALUE rpmmc_get_cli_mc ( void  )
static

Return the CLI macro context.

call-seq: RPM::Mc.cli_context -> RPM::Mc

Returns
An RPM::Mc object representing the CLI mc.

Definition at line 294 of file rpmmc-rb.c.

References rpmCLIMacroContext, and rpmmc_wrap().

Referenced by initProperties().

§ rpmmc_get_global_mc()

static VALUE rpmmc_get_global_mc ( void  )
static

Return the global macro context.

call-seq: RPM::Mc.global_context -> RPM::Mc

Returns
An RPM::Mc object representing the global mc.

Definition at line 279 of file rpmmc-rb.c.

References rpmGlobalMacroContext, and rpmmc_wrap().

Referenced by initProperties().

§ rpmmc_init_macros()

static VALUE rpmmc_init_macros ( VALUE  self,
VALUE  macrofiles_v 
)
static

Initializes a macro context from a list of files.

call-seq: RPM::Mc::init_macros(files) -> RPM::Mc

Parameters
filesA list of files to add, separated by colons
Returns
The RPM::Mc instance
See also
rpmInitMacros()

Definition at line 210 of file rpmmc-rb.c.

References _rpmmc_get_mc(), and rpmInitMacros().

Referenced by initMethods().

§ rpmmc_list()

static VALUE rpmmc_list ( VALUE  self)
static

List all macro definitions in the corresponding Macro Context.

call-seq: RPM::Mc::list() -> Array

Returns
A list of all macro definitions in form of an array of arrays, where each nested arry contains the macro's name, arguments (or an empty string) and the macro body.

Definition at line 105 of file rpmmc-rb.c.

References _debug, _rpmmc_get_mc(), argvFree(), name, and rpmGetMacroEntries().

Referenced by initMethods().

§ rpmmc_load_macro_file()

static VALUE rpmmc_load_macro_file ( VALUE  self,
VALUE  fn_v,
VALUE  nesting_v 
)
static

Loads a macro file.

call-seq: RPM::Mc::load_macro_file(fn, nesting) -> RPM::Mc

Parameters
fnThe path of the macro file
nestingMaximum recursion depth; 0 disables recursion
Returns
The RPM::Mc instance
See also
rpmLoadMacroFile()

Definition at line 185 of file rpmmc-rb.c.

References _rpmmc_get_mc(), rpm_rb_raise(), and rpmLoadMacroFile().

Referenced by initMethods().

§ rpmmc_wrap()

VALUE rpmmc_wrap ( MacroContext  mc)

Wraps an already existing MacroContext struct in a Ruby class.

Parameters
mcThe allocated MacroContext
Returns
The RPM::Mc Ruby class

Definition at line 325 of file rpmmc-rb.c.

References _debug, _rpmmc_free(), and rpmmcClass.

Referenced by rpmmc_alloc(), rpmmc_get_cli_mc(), rpmmc_get_global_mc(), and spec_get_macros().

Variable Documentation

§ _debug

int _debug = 0
static

§ rpmmcClass

VALUE rpmmcClass

RPM::Mc macro context Ruby class.

Definition at line 18 of file rpmmc-rb.c.

Referenced by Init_rpmmc(), and rpmmc_wrap().