From 66c01d903344201469b7c74390ffb801cd4c56f9 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Fri, 11 Feb 2005 13:59:41 +0000 Subject: Add macro handling code from Olivier Thauvin --- URPM.pm | 30 ++++++++++++++++++++++++++++-- URPM.xs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/URPM.pm b/URPM.pm index 693f17b..bc58ba0 100644 --- a/URPM.pm +++ b/URPM.pm @@ -609,10 +609,36 @@ They roughly correspond to command-line options to rpm(1). =back +=head2 Macro handling functions + +=item loadmacrosfile($filename) + +Load the specified macro file. Sets $! if the file can't be read. + +=item expand($name) + +Expands the specified macro. + +=item add_macro($macro_definition) + +Define a macro. For example, + + URPM::add_macro("vendor Mandrakesoft"); + my $vendor = URPM::expand("%vendor"); + +=item del_macro($name) + +Delete a macro. + +=item resetmacros() + +Destroys macros. + =head1 COPYRIGHT -Copyright 2002, 2003, 2004 MandrakeSoft (François Pons -) +Copyright 2002-2005 Mandrakesoft + +Original author: François Pons This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/URPM.xs b/URPM.xs index d6f5b4e..86ad375 100644 --- a/URPM.xs +++ b/URPM.xs @@ -4095,4 +4095,34 @@ Urpm_stream2header(fp) Fclose(fd); } +void +expand(name) + char * name + PPCODE: + const char * value = rpmExpand(name, NULL); + XPUSHs(sv_2mortal(newSVpv(value, 0))); + +void +add_macro(macro) + char * macro + CODE: + rpmDefineMacro(NULL, macro, RMIL_DEFAULT); + +void +del_macro(name) + char * name + CODE: + delMacro(NULL, name); + +void +loadmacrosfile(filename) + char * filename + PPCODE: + rpmInitMacros(NULL, filename); + +void +resetmacros() + PPCODE: + rpmFreeMacros(NULL); + /* vim:set ts=8 sts=2 sw=2: */ -- cgit v1.2.1