Convert-Binary-C
view release on metacpan or search on metacpan
ctlib/ctparse.c view on Meta::CPAN
*
* DESCRIPTION:
*
* ARGUMENTS:
*
* RETURNS:
*
*******************************************************************************/
static char *get_path_name(const char *dir, const char *file)
{
int dirlen = 0, filelen, append_delim = 0;
char *buf, *b;
if (dir != NULL)
{
dirlen = strlen(dir);
if (!IS_ANY_DIRECTORY_DELIMITER(dir[dirlen-1]))
append_delim = 1;
}
filelen = strlen(file);
AllocF(char *, buf, dirlen + append_delim + filelen + 1);
if (dir != NULL)
strcpy(buf, dir);
if (append_delim)
buf[dirlen++] = SYSTEM_DIRECTORY_DELIMITER;
strcpy(buf+dirlen, file);
for (b = buf; *b; b++)
if (IS_NON_SYSTEM_DIR_DELIM(*b))
*b = SYSTEM_DIRECTORY_DELIMITER;
return buf;
}
/*******************************************************************************
*
* ROUTINE: macro_callback
*
* WRITTEN BY: Marcus Holland-Moritz ON: Feb 2006
* CHANGED BY: ON:
*
********************************************************************************
*
* DESCRIPTION:
*
* ARGUMENTS:
*
* RETURNS:
*
*******************************************************************************/
struct macro_cb_arg
{
HashTable predef;
void (*func)(const CMacroInfo *);
CMacroInfo info;
};
static void macro_callback(const struct macro_info *pmi)
{
struct macro_cb_arg *a = pmi->arg;
if (a->predef == NULL || !HT_exists(a->predef, pmi->name, 0, 0))
{
CMacroInfo *p = &a->info;
p->name = pmi->name;
p->definition = pmi->definition;
p->definition_len = pmi->definition_len;
a->func(p);
}
}
/*******************************************************************************
*
* ROUTINE: add_predef_callback
*
* WRITTEN BY: Marcus Holland-Moritz ON: Feb 2006
* CHANGED BY: ON:
*
********************************************************************************
*
* DESCRIPTION:
*
* ARGUMENTS:
*
* RETURNS:
*
*******************************************************************************/
static void add_predef_callback(const struct macro_info *pmi)
{
HT_store(pmi->arg, pmi->name, 0, 0, NULL);
}
/*******************************************************************************
*
* ROUTINE: destroy_cpp
*
* WRITTEN BY: Marcus Holland-Moritz ON: Feb 2006
* CHANGED BY: ON:
*
********************************************************************************
*
* DESCRIPTION:
*
* ARGUMENTS:
*
* RETURNS:
*
*******************************************************************************/
static void destroy_cpp(struct CPP *pp)
{
assert(pp != 0);
wipeout(pp);
del_cpp(pp);
/* XXX: This cannot be used with concurrent preprocessor objects.
* Leak checking has to be done when all objects are gone.
*/
#ifdef MEM_DEBUG
ctlib/ctparse.c view on Meta::CPAN
*
********************************************************************************
*
* DESCRIPTION:
*
* ARGUMENTS:
*
* RETURNS:
*
*******************************************************************************/
char *macro_get_def(CParseInfo *pCPI, const char *name, size_t *plen)
{
assert(pCPI != NULL);
if (pCPI->pp)
return get_macro_definition(pCPI->pp, name, plen);
return NULL;
}
/*******************************************************************************
*
* ROUTINE: macro_free_def
*
* WRITTEN BY: Marcus Holland-Moritz ON: Feb 2006
* CHANGED BY: ON:
*
********************************************************************************
*
* DESCRIPTION:
*
* ARGUMENTS:
*
* RETURNS:
*
*******************************************************************************/
void macro_free_def(char *p)
{
free_macro_definition(p);
}
/*******************************************************************************
*
* ROUTINE: macro_iterate_defs
*
* WRITTEN BY: Marcus Holland-Moritz ON: Feb 2006
* CHANGED BY: ON:
*
********************************************************************************
*
* DESCRIPTION:
*
* ARGUMENTS:
*
* RETURNS:
*
*******************************************************************************/
void macro_iterate_defs(CParseInfo *pCPI, void (*func)(const CMacroInfo *),
void *arg, CMIFlags flags)
{
if (pCPI && pCPI->pp)
{
struct macro_cb_arg a;
unsigned long ppflags = 0;
if (flags & CMIF_WITH_DEFINITION)
ppflags |= MI_WITH_DEFINITION;
if (flags & CMIF_NO_PREDEFINED)
a.predef = pCPI->htPredefined;
else
a.predef = NULL;
a.func = func;
a.info.arg = arg;
iterate_macros(pCPI->pp, macro_callback, &a, ppflags);
}
}
/*******************************************************************************
*
* ROUTINE: parse_buffer
*
* WRITTEN BY: Marcus Holland-Moritz ON: Jan 2002
* CHANGED BY: ON:
*
********************************************************************************
*
* DESCRIPTION:
*
* ARGUMENTS:
*
* RETURNS:
*
*******************************************************************************/
int parse_buffer(const char *filename, const Buffer *pBuf,
const CParseConfig *pCPC, CParseInfo *pCPI)
{
int rval, pp_needs_init;
char *file, *str;
FILE *infile;
struct lexer_state lexer;
ParserState *pState;
struct CPP *pp;
CT_DEBUG(CTLIB, ("ctparse::parse_buffer( %s, %p, %p, %p )",
filename ? filename : BUFFER_NAME, pBuf, pCPI, pCPC));
/*----------------------------------*/
/* Initialize parse info structures */
/*----------------------------------*/
if (!pCPI->available)
{
assert(pCPI->enums == NULL);
assert(pCPI->structs == NULL);
( run in 0.578 second using v1.01-cache-2.11-cpan-39bf76dae61 )