![]() |
This is Unofficial EPICS BASE Doxygen Site
|
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dbDefs.h"
#include "errlog.h"
#include "dbmf.h"
#include "macLib.h"
Go to the source code of this file.
Classes | |
struct | mac_entry |
Macros | |
#define | MAC_MAGIC 0xbadcafe /* ...sells sub-standard coffee? */ |
#define | FLAG_SUPPRESS_WARNINGS 0x1 |
#define | FLAG_USE_ENVIRONMENT 0x80 |
Typedefs | |
typedef struct mac_entry | MAC_ENTRY |
Functions | |
long epicsStdCall | macCreateHandle (MAC_HANDLE **pHandle, const char *pairs[]) |
Creates a new macro substitution context. More... | |
void epicsStdCall | macSuppressWarning (MAC_HANDLE *handle, int suppress) |
Disable or enable warning messages. More... | |
long epicsStdCall | macExpandString (MAC_HANDLE *handle, const char *src, char *dest, long capacity) |
Expand a string which may contain macro references. More... | |
long epicsStdCall | macPutValue (MAC_HANDLE *handle, const char *name, const char *value) |
Sets the value of a specific macro. More... | |
long epicsStdCall | macGetValue (MAC_HANDLE *handle, const char *name, char *value, long capacity) |
Returns the value of a macro. More... | |
long epicsStdCall | macDeleteHandle (MAC_HANDLE *handle) |
Marks a handle invalid, and frees all storage associated with it. More... | |
long epicsStdCall | macPushScope (MAC_HANDLE *handle) |
Marks the start of a new scoping level. More... | |
long epicsStdCall | macPopScope (MAC_HANDLE *handle) |
Retrieve the last pushed scope (like stack operations) More... | |
long epicsStdCall | macReportMacros (MAC_HANDLE *handle) |
Reports details of current definitions. More... | |
#define MAC_MAGIC 0xbadcafe /* ...sells sub-standard coffee? */ |
long epicsStdCall macCreateHandle | ( | MAC_HANDLE ** | handle, |
const char * | pairs[] | ||
) |
Creates a new macro substitution context.
pHandle | pointer to variable to receive pointer to new macro substitution context |
pairs | pointer to NULL-terminated array of {name,value} pair strings. A NULL value implies undefined; a NULL pairs argument implies no macros. |
Definition at line 100 of file macCore.c.
long epicsStdCall macDeleteHandle | ( | MAC_HANDLE * | handle | ) |
Marks a handle invalid, and frees all storage associated with it.
handle | opaque handle |
Definition at line 360 of file macCore.c.
long epicsStdCall macExpandString | ( | MAC_HANDLE * | handle, |
const char * | src, | ||
char * | dest, | ||
long | capacity | ||
) |
Expand a string which may contain macro references.
This routine parses the src
string looking for macro references and passes any it finds to macGetValue() for translation.
dest
. If the return value is negative, at least one undefined macro was left unexpanded. handle | opaque handle |
src | source string |
dest | destination string |
capacity | capacity of destination buffer (dest) |
Definition at line 174 of file macCore.c.
long epicsStdCall macGetValue | ( | MAC_HANDLE * | handle, |
const char * | name, | ||
char * | value, | ||
long | capacity | ||
) |
Returns the value of a macro.
value
will be zero-terminated if the length of the value is less than capacity
. The return value is the number of characters copied to value
(see below for behavior if the macro is undefined). If capacity
is zero, no characters will be copied to value
(which may be NULL) and the call can be used to check whether the macro is defined.
If the macro is undefined, the macro reference will be returned in the value string (if permitted by maxlen) and the function value will be minus the number of characters copied. Note that treatment of capacity
is intended to be consistent with the strncpy() routine.
If the value contains macro references, these references will be expanded recursively. This expansion will detect a direct or indirect self reference.
Macro references begin with a "$" immediately followed by either a "(" or a "{" character. The macro name comes next, and may optionally be succeeded by an "=" and a default value, which will be returned if the named macro is undefined at the moment of expansion. A reference is terminated by the matching ")" or "}" character.
handle | opaque handle |
name | macro name or reference |
value | string to receive macro value or name argument if macro is undefined |
capacity | capacity of destination buffer (value) |
Definition at line 301 of file macCore.c.
long epicsStdCall macPopScope | ( | MAC_HANDLE * | handle | ) |
Retrieve the last pushed scope (like stack operations)
See macPushScope()
handle | opaque handle |
Definition at line 427 of file macCore.c.
long epicsStdCall macPushScope | ( | MAC_HANDLE * | handle | ) |
Marks the start of a new scoping level.
Marks all macro definitions added after this call as belonging to another scope. These macros will be lost on a macPopScope() call and those at the current scope will be re-instated.
handle | opaque handle |
Definition at line 392 of file macCore.c.
long epicsStdCall macPutValue | ( | MAC_HANDLE * | handle, |
const char * | name, | ||
const char * | value | ||
) |
Sets the value of a specific macro.
value
is NULL, all instances of name
are undefined at all scoping levels (the named macro doesn't have to exist in this case). Macros referenced in value
need not be defined at this point. handle | opaque handle |
name | macro name |
value | macro value |
Definition at line 233 of file macCore.c.
long epicsStdCall macReportMacros | ( | MAC_HANDLE * | handle | ) |
Reports details of current definitions.
handle | opaque handle |
Definition at line 471 of file macCore.c.
void epicsStdCall macSuppressWarning | ( | MAC_HANDLE * | handle, |
int | falseTrue | ||
) |
Disable or enable warning messages.
The macExpandString() routine prints warnings when it cant expand a macro. This routine can be used to silence those warnings. A non zero value will suppress the warning messages from subsequent library routines given the same handle
.
handle | opaque handle |
suppress | 0 means issue, 1 means suppress |
Definition at line 154 of file macCore.c.