1998-07-25 23:10:58 +08:00
|
|
|
#ifndef _H_MACRO_
|
|
|
|
#define _H_MACRO_
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2000-08-28 02:34:02 +08:00
|
|
|
/** \ingroup rpmio
|
|
|
|
* \file rpmio/rpmmacro.h
|
|
|
|
*/
|
|
|
|
|
2008-01-28 17:45:38 +08:00
|
|
|
#include <stdio.h>
|
2008-01-28 19:43:32 +08:00
|
|
|
#include <stddef.h>
|
2008-01-28 17:45:38 +08:00
|
|
|
|
2008-02-25 17:03:38 +08:00
|
|
|
#include <rpm/rpmutil.h>
|
|
|
|
|
2007-10-08 16:05:06 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-11-02 16:40:45 +08:00
|
|
|
typedef struct rpmMacroEntry_s * rpmMacroEntry;
|
1997-03-31 22:13:21 +08:00
|
|
|
|
2007-11-02 16:40:45 +08:00
|
|
|
typedef struct rpmMacroContext_s * rpmMacroContext;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2007-09-20 20:52:03 +08:00
|
|
|
extern rpmMacroContext rpmGlobalMacroContext;
|
2001-10-15 11:22:10 +08:00
|
|
|
|
2007-09-20 20:52:03 +08:00
|
|
|
extern rpmMacroContext rpmCLIMacroContext;
|
2001-10-18 00:43:36 +08:00
|
|
|
|
|
|
|
/** \ingroup rpmrc
|
|
|
|
* List of macro files to read when configuring rpm.
|
|
|
|
* This is a colon separated list of files. URI's are permitted as well,
|
|
|
|
* identified by the token '://', so file paths must not begin with '//'.
|
|
|
|
*/
|
|
|
|
extern const char * macrofiles;
|
2001-10-15 11:22:10 +08:00
|
|
|
|
2000-09-30 03:50:29 +08:00
|
|
|
/**
|
|
|
|
* Markers for sources of macros added throughout rpm.
|
1998-08-02 23:14:38 +08:00
|
|
|
*/
|
1998-12-03 03:55:36 +08:00
|
|
|
#define RMIL_DEFAULT -15
|
|
|
|
#define RMIL_MACROFILES -13
|
|
|
|
#define RMIL_RPMRC -11
|
|
|
|
|
|
|
|
#define RMIL_CMDLINE -7
|
1998-09-06 04:02:08 +08:00
|
|
|
#define RMIL_TARBALL -5
|
1998-09-06 05:54:05 +08:00
|
|
|
#define RMIL_SPEC -3
|
1998-08-02 23:14:38 +08:00
|
|
|
#define RMIL_OLDSPEC -1
|
|
|
|
#define RMIL_GLOBAL 0
|
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2000-09-30 03:50:29 +08:00
|
|
|
* Print macros to file stream.
|
|
|
|
* @param mc macro context (NULL uses global context).
|
2001-05-04 05:00:18 +08:00
|
|
|
* @param fp file stream (NULL uses stderr).
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2007-09-20 20:52:03 +08:00
|
|
|
void rpmDumpMacroTable (rpmMacroContext mc,
|
2007-09-11 22:48:54 +08:00
|
|
|
FILE * fp);
|
1998-08-01 04:11:49 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2000-09-30 03:50:29 +08:00
|
|
|
* Expand macro into buffer.
|
2000-09-02 05:15:40 +08:00
|
|
|
* @deprecated Use rpmExpand().
|
|
|
|
* @todo Eliminate from API.
|
2000-09-30 03:50:29 +08:00
|
|
|
* @param spec cookie (unused)
|
|
|
|
* @param mc macro context (NULL uses global context).
|
|
|
|
* @retval sbuf input macro to expand, output expansion
|
2001-10-16 01:53:34 +08:00
|
|
|
* @param slen size of buffer
|
2000-09-30 03:50:29 +08:00
|
|
|
* @return 0 on success
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2007-09-20 20:52:03 +08:00
|
|
|
int expandMacros (void * spec, rpmMacroContext mc,
|
2007-09-11 22:48:54 +08:00
|
|
|
char * sbuf,
|
|
|
|
size_t slen);
|
2000-09-02 05:15:40 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2000-09-30 03:50:29 +08:00
|
|
|
* Add macro to context.
|
|
|
|
* @deprecated Use rpmDefineMacro().
|
|
|
|
* @param mc macro context (NULL uses global context).
|
|
|
|
* @param n macro name
|
|
|
|
* @param o macro paramaters
|
|
|
|
* @param b macro body
|
|
|
|
* @param level macro recursion level (0 is entry API)
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2007-09-20 20:52:03 +08:00
|
|
|
void addMacro (rpmMacroContext mc, const char * n,
|
2007-09-11 22:48:54 +08:00
|
|
|
const char * o,
|
|
|
|
const char * b, int level);
|
2000-09-02 05:15:40 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2000-09-30 03:50:29 +08:00
|
|
|
* Delete macro from context.
|
|
|
|
* @param mc macro context (NULL uses global context).
|
|
|
|
* @param n macro name
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2007-09-20 20:52:03 +08:00
|
|
|
void delMacro (rpmMacroContext mc, const char * n);
|
1998-12-02 07:28:26 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2000-09-30 03:50:29 +08:00
|
|
|
* Define macro in context.
|
|
|
|
* @param mc macro context (NULL uses global context).
|
2002-04-09 02:56:01 +08:00
|
|
|
* @param macro macro name, options, body
|
2000-09-30 03:50:29 +08:00
|
|
|
* @param level macro recursion level (0 is entry API)
|
2008-05-22 16:25:15 +08:00
|
|
|
* @return 0 on success (always)
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2007-09-20 20:52:03 +08:00
|
|
|
int rpmDefineMacro (rpmMacroContext mc, const char * macro,
|
2007-09-11 22:48:54 +08:00
|
|
|
int level);
|
2000-09-02 05:15:40 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2001-10-19 09:24:21 +08:00
|
|
|
* Load macros from specific context into global context.
|
2000-09-30 03:50:29 +08:00
|
|
|
* @param mc macro context (NULL does nothing).
|
|
|
|
* @param level macro recursion level (0 is entry API)
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2007-09-20 20:52:03 +08:00
|
|
|
void rpmLoadMacros (rpmMacroContext mc, int level);
|
2000-09-02 05:15:40 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2004-03-02 09:31:01 +08:00
|
|
|
* Load macro context from a macro file.
|
2001-10-19 09:24:21 +08:00
|
|
|
* @param mc (unused)
|
2004-03-23 15:18:55 +08:00
|
|
|
* @param fn macro file name
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2007-09-20 20:52:03 +08:00
|
|
|
int rpmLoadMacroFile(rpmMacroContext mc, const char * fn);
|
2004-03-02 09:31:01 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2004-03-02 09:31:01 +08:00
|
|
|
* Initialize macro context from set of macrofile(s).
|
|
|
|
* @param mc macro context
|
|
|
|
* @param macrofiles colon separated list of macro files (NULL does nothing)
|
|
|
|
*/
|
2007-09-20 20:52:03 +08:00
|
|
|
void rpmInitMacros (rpmMacroContext mc, const char * macrofiles);
|
2000-09-02 05:15:40 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2000-09-30 03:50:29 +08:00
|
|
|
* Destroy macro context.
|
|
|
|
* @param mc macro context (NULL uses global context).
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2007-09-20 20:52:03 +08:00
|
|
|
void rpmFreeMacros (rpmMacroContext mc);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2000-09-30 03:50:29 +08:00
|
|
|
* Return (malloc'ed) concatenated macro expansion(s).
|
|
|
|
* @param arg macro(s) to expand (NULL terminates list)
|
|
|
|
* @return macro expansion (malloc'ed)
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2008-02-25 17:03:38 +08:00
|
|
|
char * rpmExpand (const char * arg, ...) RPM_GNUC_NULL_TERMINATED;
|
2000-09-02 05:15:40 +08:00
|
|
|
|
2007-11-23 20:39:51 +08:00
|
|
|
/** \ingroup rpmmacro
|
2000-09-30 03:50:29 +08:00
|
|
|
* Return macro expansion as a numeric value.
|
|
|
|
* Boolean values ('Y' or 'y' returns 1, 'N' or 'n' returns 0)
|
|
|
|
* are permitted as well. An undefined macro returns 0.
|
|
|
|
* @param arg macro to expand
|
|
|
|
* @return numeric value
|
2000-09-02 05:15:40 +08:00
|
|
|
*/
|
2007-09-11 22:48:54 +08:00
|
|
|
int rpmExpandNumeric (const char * arg);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-25 23:10:58 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _H_ MACRO_ */
|