* \file rpmio/rpmmacro.h
*/
+#include <stdio.h>
+#include <stddef.h>
+
+#include <rpm/rpmutil.h>
+#include <rpm/rpmfileutil.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-/*! The structure used to store a macro. */
-typedef struct rpmMacroEntry_s {
- struct rpmMacroEntry_s *prev;/*!< Macro entry stack. */
- const char *name; /*!< Macro name. */
- const char *opts; /*!< Macro parameters (a la getopt) */
- const char *body; /*!< Macro body. */
- int used; /*!< No. of expansions. */
- int level; /*!< Scoping level. */
-} * rpmMacroEntry;
-
-/*! The structure used to store the set of macros in a context. */
-typedef struct rpmMacroContext_s {
- rpmMacroEntry *macroTable; /*!< Macro entry table for context. */
- int macrosAllocated;/*!< No. of allocated macros. */
- int firstFree; /*!< No. of macros. */
-} * rpmMacroContext;
+typedef struct rpmMacroEntry_s * rpmMacroEntry;
+
+typedef struct rpmMacroContext_s * rpmMacroContext;
extern rpmMacroContext rpmGlobalMacroContext;
#define RMIL_OLDSPEC -1
#define RMIL_GLOBAL 0
-/**
+/** \ingroup rpmmacro
* Print macros to file stream.
* @param mc macro context (NULL uses global context).
* @param fp file stream (NULL uses stderr).
void rpmDumpMacroTable (rpmMacroContext mc,
FILE * fp);
-/**
- * Return URL path(s) from a (URL prefixed) pattern glob.
- * @param patterns glob pattern
- * @retval *argcPtr no. of paths
- * @retval *argvPtr array of paths (malloc'd contiguous blob)
- * @return 0 on success
- */
-int rpmGlob(const char * patterns, int * argcPtr,
- const char *** argvPtr);
-
-/**
+/** \ingroup rpmmacro
* Expand macro into buffer.
* @deprecated Use rpmExpand().
* @todo Eliminate from API.
char * sbuf,
size_t slen);
-/**
+/** \ingroup rpmmacro
* Add macro to context.
* @deprecated Use rpmDefineMacro().
* @param mc macro context (NULL uses global context).
const char * o,
const char * b, int level);
-/**
+/** \ingroup rpmmacro
* Delete macro from context.
* @param mc macro context (NULL uses global context).
* @param n macro name
*/
void delMacro (rpmMacroContext mc, const char * n);
-/**
+/** \ingroup rpmmacro
* Define macro in context.
* @param mc macro context (NULL uses global context).
* @param macro macro name, options, body
* @param level macro recursion level (0 is entry API)
- * @return @todo Document.
+ * @return 0 on success (always)
*/
int rpmDefineMacro (rpmMacroContext mc, const char * macro,
int level);
-/**
+/** \ingroup rpmmacro
* Load macros from specific context into global context.
* @param mc macro context (NULL does nothing).
* @param level macro recursion level (0 is entry API)
*/
void rpmLoadMacros (rpmMacroContext mc, int level);
-/**
+/** \ingroup rpmmacro
* Load macro context from a macro file.
* @param mc (unused)
* @param fn macro file name
*/
int rpmLoadMacroFile(rpmMacroContext mc, const char * fn);
-/**
+/** \ingroup rpmmacro
* Initialize macro context from set of macrofile(s).
* @param mc macro context
* @param macrofiles colon separated list of macro files (NULL does nothing)
*/
void rpmInitMacros (rpmMacroContext mc, const char * macrofiles);
-/**
+/** \ingroup rpmmacro
* Destroy macro context.
* @param mc macro context (NULL uses global context).
*/
void rpmFreeMacros (rpmMacroContext mc);
-typedef enum rpmCompressedMagic_e {
- COMPRESSED_NOT = 0, /*!< not compressed */
- COMPRESSED_OTHER = 1, /*!< gzip can handle */
- COMPRESSED_BZIP2 = 2, /*!< bzip2 can handle */
- COMPRESSED_ZIP = 3, /*!< unzip can handle */
- COMPRESSED_LZMA = 4 /*!< lzma can handle */
-} rpmCompressedMagic;
-
-/**
- * Return type of compression used in file.
- * @param file name of file
- * @retval compressed address of compression type
- * @return 0 on success, 1 on I/O error
- */
-int isCompressed (const char * file,
- rpmCompressedMagic * compressed);
-
-/**
+/** \ingroup rpmmacro
* Return (malloc'ed) concatenated macro expansion(s).
* @param arg macro(s) to expand (NULL terminates list)
* @return macro expansion (malloc'ed)
*/
-char * rpmExpand (const char * arg, ...);
-
-/**
- * Canonicalize file path.
- * @param path path to canonicalize (in-place)
- * @return canonicalized path (malloc'ed)
- */
-char * rpmCleanPath (char * path);
-
-/**
- * Return (malloc'ed) expanded, canonicalized, file path.
- * @param path macro(s) to expand (NULL terminates list)
- * @return canonicalized path (malloc'ed)
- */
-/* LCL: shrug */
-const char * rpmGetPath (const char * path, ...);
-
-/**
- * Merge 3 args into path, any or all of which may be a url.
- * The leading part of the first URL encountered is used
- * for the result, other URL prefixes are discarded, permitting
- * a primitive form of URL inheiritance.
- * @param urlroot root URL (often path to chroot, or NULL)
- * @param urlmdir directory URL (often a directory, or NULL)
- * @param urlfile file URL (often a file, or NULL)
- * @return expanded, merged, canonicalized path (malloc'ed)
- */
-/* LCL: shrug */
-const char * rpmGenPath (const char * urlroot,
- const char * urlmdir,
- const char * urlfile);
+char * rpmExpand (const char * arg, ...) RPM_GNUC_NULL_TERMINATED;
-/**
+/** \ingroup rpmmacro
* 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.
*/
int rpmExpandNumeric (const char * arg);
+/** \ingroup rpmmacro
+ * Return rpm configuration base directory.
+ * If RPM_CONFIGDIR environment variable is set, it's value will be used.
+ * Otherwise the configuration directory is the one set at build time,
+ * typically /usr/lib/rpm. The value of rpmConfigDir() is determined
+ * on first call to this function and is guaranteed to remain the same
+ * on subsequent calls.
+ * @return rpm configuration directory name
+ */
+const char *rpmConfigDir(void);
+
#ifdef __cplusplus
}
#endif