Rename MacroBuf to rpmMacroBuf for exporting
This is just in preparation for exposing the handle in some APIs. No functional changes.
This commit is contained in:
parent
b3449a0774
commit
0758d03f7f
100
rpmio/macro.c
100
rpmio/macro.c
|
@ -41,8 +41,8 @@ enum macroFlags_e {
|
||||||
ME_FUNC = (1 << 4),
|
ME_FUNC = (1 << 4),
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct MacroBuf_s *MacroBuf;
|
typedef struct rpmMacroBuf_s *rpmMacroBuf;
|
||||||
typedef void (*macroFunc)(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed);
|
typedef void (*macroFunc)(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed);
|
||||||
|
|
||||||
/*! The structure used to store a macro. */
|
/*! The structure used to store a macro. */
|
||||||
struct rpmMacroEntry_s {
|
struct rpmMacroEntry_s {
|
||||||
|
@ -100,7 +100,7 @@ static void initLocks(void)
|
||||||
/**
|
/**
|
||||||
* Macro expansion state.
|
* Macro expansion state.
|
||||||
*/
|
*/
|
||||||
struct MacroBuf_s {
|
struct rpmMacroBuf_s {
|
||||||
char * buf; /*!< Expansion buffer. */
|
char * buf; /*!< Expansion buffer. */
|
||||||
size_t tpos; /*!< Current position in expansion buffer */
|
size_t tpos; /*!< Current position in expansion buffer */
|
||||||
size_t nb; /*!< No. bytes remaining in expansion buffer. */
|
size_t nb; /*!< No. bytes remaining in expansion buffer. */
|
||||||
|
@ -134,7 +134,7 @@ static int print_macro_trace = _PRINT_MACRO_TRACE;
|
||||||
static int print_expand_trace = _PRINT_EXPAND_TRACE;
|
static int print_expand_trace = _PRINT_EXPAND_TRACE;
|
||||||
|
|
||||||
/* forward ref */
|
/* forward ref */
|
||||||
static int expandMacro(MacroBuf mb, const char *src, size_t slen);
|
static int expandMacro(rpmMacroBuf mb, const char *src, size_t slen);
|
||||||
static void pushMacro(rpmMacroContext mc,
|
static void pushMacro(rpmMacroContext mc,
|
||||||
const char * n, const char * o, const char * b, int level, int flags);
|
const char * n, const char * o, const char * b, int level, int flags);
|
||||||
static void popMacro(rpmMacroContext mc, const char * n);
|
static void popMacro(rpmMacroContext mc, const char * n);
|
||||||
|
@ -318,7 +318,7 @@ matchchar(const char * p, char pl, char pr)
|
||||||
return (const char *)NULL;
|
return (const char *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mbErr(MacroBuf mb, int error, const char *fmt, ...)
|
static void mbErr(rpmMacroBuf mb, int error, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char *emsg = NULL;
|
char *emsg = NULL;
|
||||||
int n;
|
int n;
|
||||||
|
@ -350,7 +350,7 @@ static void mbErr(MacroBuf mb, int error, const char *fmt, ...)
|
||||||
* @param se end of string
|
* @param se end of string
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
printMacro(MacroBuf mb, const char * s, const char * se)
|
printMacro(rpmMacroBuf mb, const char * s, const char * se)
|
||||||
{
|
{
|
||||||
const char *senl;
|
const char *senl;
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ printMacro(MacroBuf mb, const char * s, const char * se)
|
||||||
* @param te end of string
|
* @param te end of string
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
printExpansion(MacroBuf mb, rpmMacroEntry me, const char * t, const char * te)
|
printExpansion(rpmMacroBuf mb, rpmMacroEntry me, const char * t, const char * te)
|
||||||
{
|
{
|
||||||
const char *mname = me ? me->name : "";
|
const char *mname = me ? me->name : "";
|
||||||
if (!(te > t)) {
|
if (!(te > t)) {
|
||||||
|
@ -439,9 +439,9 @@ printExpansion(MacroBuf mb, rpmMacroEntry me, const char * t, const char * te)
|
||||||
* @return result of expansion
|
* @return result of expansion
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
expandThis(MacroBuf mb, const char * src, size_t slen, char **target)
|
expandThis(rpmMacroBuf mb, const char * src, size_t slen, char **target)
|
||||||
{
|
{
|
||||||
struct MacroBuf_s umb;
|
struct rpmMacroBuf_s umb;
|
||||||
|
|
||||||
/* Copy other state from "parent", but we want a buffer of our own */
|
/* Copy other state from "parent", but we want a buffer of our own */
|
||||||
umb = *mb;
|
umb = *mb;
|
||||||
|
@ -456,9 +456,9 @@ expandThis(MacroBuf mb, const char * src, size_t slen, char **target)
|
||||||
return umb.error;
|
return umb.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MacroBuf mbCreate(rpmMacroContext mc, int flags)
|
static rpmMacroBuf mbCreate(rpmMacroContext mc, int flags)
|
||||||
{
|
{
|
||||||
MacroBuf mb = xcalloc(1, sizeof(*mb));
|
rpmMacroBuf mb = xcalloc(1, sizeof(*mb));
|
||||||
mb->buf = NULL;
|
mb->buf = NULL;
|
||||||
mb->depth = mc->depth;
|
mb->depth = mc->depth;
|
||||||
mb->level = mc->level;
|
mb->level = mc->level;
|
||||||
|
@ -469,7 +469,7 @@ static MacroBuf mbCreate(rpmMacroContext mc, int flags)
|
||||||
return mb;
|
return mb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mbAllocBuf(MacroBuf mb, size_t slen)
|
static void mbAllocBuf(rpmMacroBuf mb, size_t slen)
|
||||||
{
|
{
|
||||||
size_t blen = MACROBUFSIZ + slen;
|
size_t blen = MACROBUFSIZ + slen;
|
||||||
mb->buf = xmalloc(blen + 1);
|
mb->buf = xmalloc(blen + 1);
|
||||||
|
@ -478,7 +478,7 @@ static void mbAllocBuf(MacroBuf mb, size_t slen)
|
||||||
mb->nb = blen;
|
mb->nb = blen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mbInit(MacroBuf mb, MacroExpansionData *med, size_t slen)
|
static int mbInit(rpmMacroBuf mb, MacroExpansionData *med, size_t slen)
|
||||||
{
|
{
|
||||||
if (mb->buf == NULL)
|
if (mb->buf == NULL)
|
||||||
mbAllocBuf(mb, slen);
|
mbAllocBuf(mb, slen);
|
||||||
|
@ -494,7 +494,7 @@ static int mbInit(MacroBuf mb, MacroExpansionData *med, size_t slen)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mbFini(MacroBuf mb, rpmMacroEntry me, MacroExpansionData *med)
|
static void mbFini(rpmMacroBuf mb, rpmMacroEntry me, MacroExpansionData *med)
|
||||||
{
|
{
|
||||||
mb->buf[mb->tpos] = '\0';
|
mb->buf[mb->tpos] = '\0';
|
||||||
mb->depth--;
|
mb->depth--;
|
||||||
|
@ -506,7 +506,7 @@ static void mbFini(MacroBuf mb, rpmMacroEntry me, MacroExpansionData *med)
|
||||||
mb->expand_trace = med->expand_trace;
|
mb->expand_trace = med->expand_trace;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mbAppend(MacroBuf mb, char c)
|
static void mbAppend(rpmMacroBuf mb, char c)
|
||||||
{
|
{
|
||||||
if (mb->nb < 1) {
|
if (mb->nb < 1) {
|
||||||
mb->buf = xrealloc(mb->buf, mb->tpos + MACROBUFSIZ + 1);
|
mb->buf = xrealloc(mb->buf, mb->tpos + MACROBUFSIZ + 1);
|
||||||
|
@ -517,7 +517,7 @@ static void mbAppend(MacroBuf mb, char c)
|
||||||
mb->nb--;
|
mb->nb--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mbAppendStr(MacroBuf mb, const char *str)
|
static void mbAppendStr(rpmMacroBuf mb, const char *str)
|
||||||
{
|
{
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
if (len > mb->nb) {
|
if (len > mb->nb) {
|
||||||
|
@ -529,7 +529,7 @@ static void mbAppendStr(MacroBuf mb, const char *str)
|
||||||
mb->nb -= len;
|
mb->nb -= len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doDnl(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doDnl(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
const char *se = argv[1];
|
const char *se = argv[1];
|
||||||
const char *start = se, *end;
|
const char *start = se, *end;
|
||||||
|
@ -548,7 +548,7 @@ static void doDnl(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
* @param clen no. bytes in shell command
|
* @param clen no. bytes in shell command
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
doShellEscape(MacroBuf mb, const char * cmd, size_t clen)
|
doShellEscape(rpmMacroBuf mb, const char * cmd, size_t clen)
|
||||||
{
|
{
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
FILE *shf;
|
FILE *shf;
|
||||||
|
@ -585,7 +585,7 @@ exit:
|
||||||
* @param expr expression
|
* @param expr expression
|
||||||
* @param len no. bytes in expression
|
* @param len no. bytes in expression
|
||||||
*/
|
*/
|
||||||
static void doExpressionExpansion(MacroBuf mb, const char * expr, size_t len)
|
static void doExpressionExpansion(rpmMacroBuf mb, const char * expr, size_t len)
|
||||||
{
|
{
|
||||||
char *buf = rstrndup(expr, len);
|
char *buf = rstrndup(expr, len);
|
||||||
char *result;
|
char *result;
|
||||||
|
@ -627,7 +627,7 @@ static unsigned int getncpus(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
validName(MacroBuf mb, const char *name, size_t namelen, const char *action)
|
validName(rpmMacroBuf mb, const char *name, size_t namelen, const char *action)
|
||||||
{
|
{
|
||||||
rpmMacroEntry *mep;
|
rpmMacroEntry *mep;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@ -660,7 +660,7 @@ exit:
|
||||||
* @return number of consumed characters
|
* @return number of consumed characters
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
doDefine(MacroBuf mb, const char * se, int level, int expandbody, size_t *parsed)
|
doDefine(rpmMacroBuf mb, const char * se, int level, int expandbody, size_t *parsed)
|
||||||
{
|
{
|
||||||
const char *start = se;
|
const char *start = se;
|
||||||
const char *s = se;
|
const char *s = se;
|
||||||
|
@ -794,7 +794,7 @@ exit:
|
||||||
* @return number of consumed characters
|
* @return number of consumed characters
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
doUndefine(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
doUndefine(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
const char *n = argv[1];
|
const char *n = argv[1];
|
||||||
if (!validName(mb, n, strlen(n), "%undefine")) {
|
if (!validName(mb, n, strlen(n), "%undefine")) {
|
||||||
|
@ -804,7 +804,7 @@ doUndefine(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doArgvDefine(MacroBuf mb, ARGV_t argv, int level, int expand, size_t *parsed)
|
static void doArgvDefine(rpmMacroBuf mb, ARGV_t argv, int level, int expand, size_t *parsed)
|
||||||
{
|
{
|
||||||
char *args = NULL;
|
char *args = NULL;
|
||||||
const char *se = argv[1];
|
const char *se = argv[1];
|
||||||
|
@ -817,17 +817,17 @@ static void doArgvDefine(MacroBuf mb, ARGV_t argv, int level, int expand, size_t
|
||||||
free(args);
|
free(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doDef(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doDef(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
doArgvDefine(mb, argv, mb->level, 0, parsed);
|
doArgvDefine(mb, argv, mb->level, 0, parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doGlobal(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doGlobal(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
doArgvDefine(mb, argv, RMIL_GLOBAL, 1, parsed);
|
doArgvDefine(mb, argv, RMIL_GLOBAL, 1, parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doDump(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doDump(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
rpmDumpMacroTable(mb->mc, NULL);
|
rpmDumpMacroTable(mb->mc, NULL);
|
||||||
}
|
}
|
||||||
|
@ -835,7 +835,7 @@ static void doDump(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
|
|
||||||
static int mbopt(int c, const char *oarg, int oint, void *data)
|
static int mbopt(int c, const char *oarg, int oint, void *data)
|
||||||
{
|
{
|
||||||
MacroBuf mb = data;
|
rpmMacroBuf mb = data;
|
||||||
char *name = NULL, *body = NULL;
|
char *name = NULL, *body = NULL;
|
||||||
|
|
||||||
/* Define option macros. */
|
/* Define option macros. */
|
||||||
|
@ -865,7 +865,7 @@ static int mbopt(int c, const char *oarg, int oint, void *data)
|
||||||
* @param argv parsed arguments for the macro
|
* @param argv parsed arguments for the macro
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setupArgs(MacroBuf mb, const rpmMacroEntry me, ARGV_t argv)
|
setupArgs(rpmMacroBuf mb, const rpmMacroEntry me, ARGV_t argv)
|
||||||
{
|
{
|
||||||
char *args = NULL;
|
char *args = NULL;
|
||||||
int argc;
|
int argc;
|
||||||
|
@ -931,7 +931,7 @@ exit:
|
||||||
* @param mb macro expansion state
|
* @param mb macro expansion state
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
freeArgs(MacroBuf mb)
|
freeArgs(rpmMacroBuf mb)
|
||||||
{
|
{
|
||||||
rpmMacroContext mc = mb->mc;
|
rpmMacroContext mc = mb->mc;
|
||||||
|
|
||||||
|
@ -1030,7 +1030,7 @@ char *unsplitQuoted(ARGV_const_t av, const char *sep)
|
||||||
* @return address to continue parsing
|
* @return address to continue parsing
|
||||||
*/
|
*/
|
||||||
static const char *
|
static const char *
|
||||||
grabArgs(MacroBuf mb, const rpmMacroEntry me, ARGV_t *argvp,
|
grabArgs(rpmMacroBuf mb, const rpmMacroEntry me, ARGV_t *argvp,
|
||||||
const char * se, const char * lastc, int splitargs)
|
const char * se, const char * lastc, int splitargs)
|
||||||
{
|
{
|
||||||
if ((me->flags & ME_PARSE) != 0) {
|
if ((me->flags & ME_PARSE) != 0) {
|
||||||
|
@ -1050,7 +1050,7 @@ grabArgs(MacroBuf mb, const rpmMacroEntry me, ARGV_t *argvp,
|
||||||
lastc : lastc + 1;
|
lastc : lastc + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doBody(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doBody(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
if (*argv[1]) {
|
if (*argv[1]) {
|
||||||
rpmMacroEntry *mep = findEntry(mb->mc, argv[1], 0, NULL);
|
rpmMacroEntry *mep = findEntry(mb->mc, argv[1], 0, NULL);
|
||||||
|
@ -1062,7 +1062,7 @@ static void doBody(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doOutput(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doOutput(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
int loglevel = RPMLOG_NOTICE; /* assume echo */
|
int loglevel = RPMLOG_NOTICE; /* assume echo */
|
||||||
if (rstreq("error", me->name)) {
|
if (rstreq("error", me->name)) {
|
||||||
|
@ -1074,7 +1074,7 @@ static void doOutput(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed
|
||||||
rpmlog(loglevel, "%s\n", argv[1]);
|
rpmlog(loglevel, "%s\n", argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doLua(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doLua(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
rpmlua lua = NULL; /* Global state. */
|
rpmlua lua = NULL; /* Global state. */
|
||||||
const char *scriptbuf = argv[1];
|
const char *scriptbuf = argv[1];
|
||||||
|
@ -1113,7 +1113,7 @@ static void doLua(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
* Note extra parentheses to force only one result returned, multi-value
|
* Note extra parentheses to force only one result returned, multi-value
|
||||||
* returns such as from string.gsub() make no sense in this context.
|
* returns such as from string.gsub() make no sense in this context.
|
||||||
*/
|
*/
|
||||||
static void doString(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doString(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
rpmlua lua = NULL; /* Global state. */
|
rpmlua lua = NULL; /* Global state. */
|
||||||
char *printbuf = NULL;
|
char *printbuf = NULL;
|
||||||
|
@ -1132,7 +1132,7 @@ static void doString(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doSP(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doSP(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
|
|
||||||
|
@ -1141,7 +1141,7 @@ static void doSP(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doUncompress(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doUncompress(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
if (*argv[1]) {
|
if (*argv[1]) {
|
||||||
expandMacro(mb, "%__rpmuncompress ", 0);
|
expandMacro(mb, "%__rpmuncompress ", 0);
|
||||||
|
@ -1149,13 +1149,13 @@ static void doUncompress(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *par
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doExpand(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doExpand(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
if (*argv[1])
|
if (*argv[1])
|
||||||
expandMacro(mb, argv[1], 0);
|
expandMacro(mb, argv[1], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doVerbose(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doVerbose(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
if (parsed || !argv || !argv[1]) {
|
if (parsed || !argv || !argv[1]) {
|
||||||
mbAppend(mb, rpmIsVerbose() ? '1' : '0');
|
mbAppend(mb, rpmIsVerbose() ? '1' : '0');
|
||||||
|
@ -1164,7 +1164,7 @@ static void doVerbose(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doShescape(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doShescape(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
mbAppend(mb, '\'');
|
mbAppend(mb, '\'');
|
||||||
for (const char *s = argv[1]; *s != '\0'; s++) {
|
for (const char *s = argv[1]; *s != '\0'; s++) {
|
||||||
|
@ -1218,7 +1218,7 @@ static unsigned long getmem_proc(int thread)
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doGetncpus(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doGetncpus(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
const char *sizemacro = NULL;
|
const char *sizemacro = NULL;
|
||||||
const char *arg = argv[1] ? argv[1] : "total";
|
const char *arg = argv[1] ? argv[1] : "total";
|
||||||
|
@ -1260,7 +1260,7 @@ static void doGetncpus(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parse
|
||||||
mbAppendStr(mb, buf);
|
mbAppendStr(mb, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doFoo(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doFoo(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
char *b = NULL;
|
char *b = NULL;
|
||||||
|
@ -1323,14 +1323,14 @@ static void doFoo(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doLoad(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doLoad(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
if (loadMacroFile(mb->mc, argv[1])) {
|
if (loadMacroFile(mb->mc, argv[1])) {
|
||||||
mbErr(mb, 1, _("failed to load macro file %s\n"), argv[1]);
|
mbErr(mb, 1, _("failed to load macro file %s\n"), argv[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doTrace(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doTrace(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
mb->expand_trace = mb->macro_trace = mb->depth;
|
mb->expand_trace = mb->macro_trace = mb->depth;
|
||||||
if (mb->depth == 1) {
|
if (mb->depth == 1) {
|
||||||
|
@ -1339,7 +1339,7 @@ static void doTrace(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doRpmver(MacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
static void doRpmver(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
|
||||||
{
|
{
|
||||||
mbAppendStr(mb, VERSION);
|
mbAppendStr(mb, VERSION);
|
||||||
}
|
}
|
||||||
|
@ -1441,7 +1441,7 @@ const char *findMacroEnd(const char *str)
|
||||||
* @param parsed how many characters ME_PARSE parsed (or NULL)
|
* @param parsed how many characters ME_PARSE parsed (or NULL)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
doMacro(MacroBuf mb, rpmMacroEntry me, ARGV_t args, size_t *parsed)
|
doMacro(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t args, size_t *parsed)
|
||||||
{
|
{
|
||||||
rpmMacroEntry prevme = mb->me;
|
rpmMacroEntry prevme = mb->me;
|
||||||
ARGV_t prevarg = mb->args;
|
ARGV_t prevarg = mb->args;
|
||||||
|
@ -1482,7 +1482,7 @@ exit:
|
||||||
* @return 0 on success, 1 on failure
|
* @return 0 on success, 1 on failure
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
expandMacro(MacroBuf mb, const char *src, size_t slen)
|
expandMacro(rpmMacroBuf mb, const char *src, size_t slen)
|
||||||
{
|
{
|
||||||
rpmMacroEntry *mep;
|
rpmMacroEntry *mep;
|
||||||
rpmMacroEntry me = NULL;
|
rpmMacroEntry me = NULL;
|
||||||
|
@ -1679,7 +1679,7 @@ exit:
|
||||||
* @return 0 on success, 1 on failure
|
* @return 0 on success, 1 on failure
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
expandThisMacro(MacroBuf mb, rpmMacroEntry me, ARGV_const_t args, int flags)
|
expandThisMacro(rpmMacroBuf mb, rpmMacroEntry me, ARGV_const_t args, int flags)
|
||||||
{
|
{
|
||||||
MacroExpansionData med;
|
MacroExpansionData med;
|
||||||
ARGV_t optargs = NULL;
|
ARGV_t optargs = NULL;
|
||||||
|
@ -1725,7 +1725,7 @@ exit:
|
||||||
static int doExpandMacros(rpmMacroContext mc, const char *src, int flags,
|
static int doExpandMacros(rpmMacroContext mc, const char *src, int flags,
|
||||||
char **target)
|
char **target)
|
||||||
{
|
{
|
||||||
MacroBuf mb = mbCreate(mc, flags);
|
rpmMacroBuf mb = mbCreate(mc, flags);
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
rc = expandMacro(mb, src, 0);
|
rc = expandMacro(mb, src, 0);
|
||||||
|
@ -1826,7 +1826,7 @@ static void popMacro(rpmMacroContext mc, const char * n)
|
||||||
|
|
||||||
static int defineMacro(rpmMacroContext mc, const char * macro, int level)
|
static int defineMacro(rpmMacroContext mc, const char * macro, int level)
|
||||||
{
|
{
|
||||||
MacroBuf mb = xcalloc(1, sizeof(*mb));
|
rpmMacroBuf mb = xcalloc(1, sizeof(*mb));
|
||||||
int rc;
|
int rc;
|
||||||
size_t parsed = 0;
|
size_t parsed = 0;
|
||||||
|
|
||||||
|
@ -1920,7 +1920,7 @@ int rpmExpandThisMacro(rpmMacroContext mc, const char *n, ARGV_const_t args, ch
|
||||||
mc = rpmmctxAcquire(mc);
|
mc = rpmmctxAcquire(mc);
|
||||||
mep = findEntry(mc, n, 0, NULL);
|
mep = findEntry(mc, n, 0, NULL);
|
||||||
if (mep) {
|
if (mep) {
|
||||||
MacroBuf mb = mbCreate(mc, flags);
|
rpmMacroBuf mb = mbCreate(mc, flags);
|
||||||
rc = expandThisMacro(mb, *mep, args, flags);
|
rc = expandThisMacro(mb, *mep, args, flags);
|
||||||
mb->buf[mb->tpos] = '\0'; /* XXX just in case */
|
mb->buf[mb->tpos] = '\0'; /* XXX just in case */
|
||||||
target = xrealloc(mb->buf, mb->tpos + 1);
|
target = xrealloc(mb->buf, mb->tpos + 1);
|
||||||
|
|
Loading…
Reference in New Issue