本文整理汇总了C++中AGFREE函数的典型用法代码示例。如果您正苦于以下问题:C++ AGFREE函数的具体用法?C++ AGFREE怎么用?C++ AGFREE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AGFREE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_scm
static void
init_scm(void)
{
last_scm_cmd = SCHEME_INIT_TEXT;
{
SCM ini_res = ag_scm_c_eval_string_from_file_line(
SCHEME_INIT_TEXT, AG_TEXT_STRTABLE_FILE, SCHEME_INIT_TEXT_LINENO);
AGDUPSTR(libguile_ver, scm2display(ini_res), "ini res");
}
{
unsigned int maj, min, mic;
switch (sscanf(libguile_ver, "%u.%u.%u", &maj, &min, &mic)) {
case 2:
case 3: break;
default:
AG_ABEND(aprf(GUILE_VERSION_BAD, libguile_ver));
/* NOT_REACHED */
}
maj = min + (100 * maj);
if ((GUILE_VERSION / 1000) != maj)
AG_ABEND(aprf(GUILE_VERSION_WRONG, libguile_ver,
MK_STR(GUILE_VERSION)));
}
{
# if GUILE_VERSION >= 200000
# define SCHEME_INIT_DEBUG SCHEME_INIT_DEBUG_2_0
# else
# define SCHEME_INIT_DEBUG SCHEME_INIT_DEBUG_1_6
# endif
char * p = aprf(INIT_SCM_ERRS_FMT, SCHEME_INIT_DEBUG);
# undef SCHEME_INIT_DEBUG
last_scm_cmd = p;
ag_scm_c_eval_string_from_file_line(p, __FILE__, __LINE__);
AGFREE(p);
}
}
示例2: optionTimeVal
/*=export_func optionTimeVal
* private:
*
* what: process an option with a time duration.
* arg: + tOptions * + opts + program options descriptor +
* arg: + tOptDesc * + od + the descriptor for this arg +
*
* doc:
* Decipher a time duration value.
=*/
void
optionTimeVal(tOptions * opts, tOptDesc * od)
{
time_t val;
if (INQUERY_CALL(opts, od))
return;
val = parse_duration(od->optArg.argString);
if (val == BAD_TIME) {
fprintf(stderr, zNotDuration, opts->pzProgName, od->optArg.argString);
if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
(*(opts->pUsageProc))(opts, EXIT_FAILURE);
}
if (od->fOptState & OPTST_ALLOC_ARG) {
AGFREE(od->optArg.argString);
od->fOptState &= ~OPTST_ALLOC_ARG;
}
od->optArg.argInt = (long)val;
}
示例3: optionTimeVal
/*=export_func optionTimeVal
* private:
*
* what: process an option with a time duration.
* arg: + tOptions* + pOpts + program options descriptor +
* arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
*
* doc:
* Decipher a time duration value.
=*/
void
optionTimeVal(tOptions * pOpts, tOptDesc * pOD)
{
time_t val;
if ((pOD->fOptState & OPTST_RESET) != 0)
return;
val = parse_duration(pOD->optArg.argString);
if (val == BAD_TIME) {
fprintf(stderr, zNotDuration, pOpts->pzProgName, pOD->optArg.argString);
if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
(*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
}
if (pOD->fOptState & OPTST_ALLOC_ARG) {
AGFREE(pOD->optArg.argString);
pOD->fOptState &= ~OPTST_ALLOC_ARG;
}
pOD->optArg.argInt = (unsigned long)val;
}
示例4: aoflags_directive
/**
* handle AutoOpts mode flags
*/
static char *
aoflags_directive(tOptions * pOpts, char * pzText)
{
char * pz = pzText;
while (IS_WHITESPACE_CHAR(*++pz)) ;
pzText = strchr(pz, '>');
if (pzText != NULL) {
size_t len = pzText - pz;
char * ftxt = AGALOC(len + 1, "aoflags");
memcpy(ftxt, pz, len);
ftxt[len] = NUL;
set_usage_flags(pOpts, ftxt);
AGFREE(ftxt);
pzText++;
}
return pzText;
}
示例5: aoflags_directive
/**
* handle AutoOpts mode flags.
*
* @param[in,out] opts program option descriptor
* @param[in] txt scanning pointer
* @returns the next character to look at
*/
static char *
aoflags_directive(tOptions * opts, char * txt)
{
char * pz;
pz = SPN_WHITESPACE_CHARS(txt+1);
txt = strchr(pz, '>');
if (txt != NULL) {
size_t len = (unsigned)(txt - pz);
char * ftxt = AGALOC(len + 1, "aoflags");
memcpy(ftxt, pz, len);
ftxt[len] = NUL;
set_usage_flags(opts, ftxt);
AGFREE(ftxt);
txt++;
}
return txt;
}
示例6: printSetMemberArg
static void
printSetMemberArg(FILE * fp, tOptDesc * pOD)
{
uintptr_t val = pOD->optArg.argEnum;
/*
* This is a magic incantation that will convert the
* bit flag values back into a string suitable for printing.
*/
(*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
printEntry( fp, pOD, (const void*)(pOD->optArg.argString));
if (pOD->optArg.argString != NULL) {
/*
* set membership strings get allocated
*/
AGFREE( pOD->optArg.argString );
pOD->fOptState &= ~OPTST_ALLOC_ARG;
}
pOD->optArg.argEnum = val;
}
示例7: cleanup
/**
* This gets called when all is well at the end.
*/
LOCAL void
cleanup(tTemplate* pTF)
{
if (HAVE_OPT(USED_DEFINES))
print_used_defines();
if (pfDepends != NULL)
wrap_up_depends();
optionFree(&autogenOptions);
for (;;) {
tTemplate* pT = pNamedTplList;
if (pT == NULL)
break;
pNamedTplList = (tTemplate*)(void*)(pT->pNext);
unloadTemplate(pT);
}
AGFREE(forInfo.fi_data);
unloadTemplate(pTF);
unloadDefs();
}
示例8: print_one_paragraph
static void
print_one_paragraph(char const * text, bool plain, FILE * fp)
{
if (plain) {
#ifdef ENABLE_NLS
#ifdef HAVE_LIBINTL_H
#ifdef DEBUG_ENABLED
#undef gettext
#endif
char * buf = dgettext("libopts", text);
if (buf == text)
text = gettext(text);
#endif /* HAVE_LIBINTL_H */
#endif /* ENABLE_NLS */
fputs(text, fp);
}
else {
char const * t = optionQuoteString(text, LINE_SPLICE);
fprintf(fp, PUTS_FMT, t);
AGFREE((void *)t);
}
}
示例9: delete_data_entry
static int delete_data_entry (SCROLLER_T * scrlr, void *delete_me)
{
NEXTED_PTR_T *data_ptr = delete_me;
register NEXTED_PTR_T *tmp;
if (data_ptr == scrlr->first_data_ptr)
{
scrlr->first_data_ptr = data_ptr->next;
if (data_ptr == scrlr->last_data_ptr)
scrlr->last_data_ptr = NULL;
}
else
{ /* not first */
for (tmp = scrlr->first_data_ptr; tmp; tmp = tmp->next)
{
if (tmp->next == data_ptr)
{
if (data_ptr == scrlr->last_data_ptr)
scrlr->last_data_ptr = tmp;
tmp->next = data_ptr->next;
break;
}
} /* for */
} /* not first */
if (data_ptr == scrlr->current_data_ptr)
scrlr->current_data_ptr = data_ptr->next;
if (scrlr->data_destructor)
scrlr->data_destructor (scrlr, data_ptr);
AGFREE (data_ptr);
scrlr->data_created--;
scrlr->data_stored--;
return 0;
}
示例10: eval_true
/*
* eval_true - should a string be interpreted as TRUE?
*
* It is always true unless:
*
* 1. it is the empty string
* 2. it starts with a digit and the number evaluates to zero
* 3. it starts with either "#f" or "#F"
* 4. For its length or its first five characters (whichever is less)
* it matches the string "false"
*/
static ag_bool
eval_true(void)
{
ag_bool needFree;
ag_bool res = AG_TRUE;
char const * pz = evalExpression(&needFree);
if (IS_DEC_DIGIT_CHAR(*pz))
res = (atoi(pz) == 0) ? AG_FALSE : AG_TRUE;
else switch (*pz) {
case NUL:
res = AG_FALSE;
break;
case '#':
if ((pz[1] == 'f') || (pz[1] == 'F'))
res = AG_FALSE;
break;
case 'f':
case 'F':
{
int len = strlen(pz);
if (len > 5)
len = 5;
if (strneqvcmp(EVAL_TRUE_FALSE_STR, pz, len) == 0)
res = AG_FALSE;
break;
}
}
if (needFree)
AGFREE(pz);
return res;
}
示例11: doDir_assert
/**
* This directive @i{is} processed, but only if the expression begins with
* either a back quote (@code{`}) or an open parenthesis (@code{(}).
* Text within the back quotes are handed off to the shell for processing
* and parenthesized text is handed off to Guile. Multiple line expressions
* must be joined with backslashes.
*
* If the @code{shell-script} or @code{scheme-expr} do not yield @code{true}
* valued results, autogen will be aborted. If @code{<anything else>} or
* nothing at all is provided, then this directive is ignored.
*
* The result is @code{false} (and fails) if the result is empty, the
* number zero, or a string that starts with the letters 'n' or 'f' ("no"
* or "false").
*/
char *
doDir_assert(directive_enum_t id, char const * dir, char * scan_next)
{
(void)id;
dir = SPN_WHITESPACE_CHARS(dir);
switch (*dir) {
case '`':
{
char * pzS = (char *)dir+1;
char * pzR = SPN_WHITESPACE_BACK(pzS, NULL);
if (*(--pzR) != '`')
break; /* not a valid script */
*pzR = NUL;
pzS = shell_cmd((char const *)pzS);
check_assert_str(pzS, dir);
AGFREE(pzS);
break;
}
case '(':
{
SCM res = ag_scm_c_eval_string_from_file_line(
dir, cctx->scx_fname, cctx->scx_line);
check_assert_str(scm2display(res), dir);
break;
}
default:
break;
}
return scan_next;
}
示例12: program_directive
/**
* handle program segmentation of config file.
*
* @param[in,out] opts program option descriptor
* @param[in] txt scanning pointer
* @returns the next character to look at
*/
static char *
program_directive(tOptions * opts, char * txt)
{
static char const ttlfmt[] = "<?";
size_t ttl_len = sizeof(ttlfmt) + strlen(zCfgProg);
char * ttl = AGALOC(ttl_len, "prog title");
size_t name_len = strlen(opts->pzProgName);
memcpy(ttl, ttlfmt, sizeof(ttlfmt) - 1);
memcpy(ttl + sizeof(ttlfmt) - 1, zCfgProg, ttl_len - (sizeof(ttlfmt) - 1));
do {
txt = SPN_WHITESPACE_CHARS(txt+1);
if ( (strneqvcmp(txt, opts->pzProgName, (int)name_len) == 0)
&& (IS_END_XML_TOKEN_CHAR(txt[name_len])) ) {
txt += name_len;
break;
}
txt = strstr(txt, ttl);
} while (txt != NULL);
AGFREE(ttl);
if (txt != NULL)
for (;;) {
if (*txt == NUL) {
txt = NULL;
break;
}
if (*(txt++) == '>')
break;
}
return txt;
}
示例13: mFunc_Case
//.........这里部分代码省略.........
&Select_Compare,
&Select_Equivalent_Full,
&Select_Equivalent_End,
&Select_Equivalent_Start,
&Select_Equivalent,
&Select_Match_Full,
&Select_Match_End,
&Select_Match_Start,
&Select_Match,
&Select_Match_Always,
&Select_Match_Existence,
&Select_Match_NonExistence
};
static char const * const match_names[] = {
"COMPARE_FULL",
"COMPARE_END",
"COMPARE_START",
"CONTAINS",
"EQUIVALENT_FULL",
"EQUIVALENT_END",
"EQUIVALENT_START",
"EQUIV_CONTAINS",
"MATCH_FULL",
"MATCH_END",
"MATCH_START",
"MATCH_WITHIN",
"MATCH_ALWAYS",
"MATCH_EXISTENCE",
"MATCH_NONEXISTENCE"
};
tMacro* pEnd = pT->aMacros + pMac->endIndex;
ag_bool needFree;
char const * pzSampleText = evalExpression(&needFree);
/*
* Search through the selection clauses until we either
* reach the end of the list for this CASE macro, or we match.
*/
for (;;) {
tSuccess mRes;
pMac = pT->aMacros + pMac->sibIndex;
if (pMac >= pEnd) {
if (OPT_VALUE_TRACE >= TRACE_BLOCK_MACROS) {
fprintf(pfTrace, "CASE string `%s' did not match\n",
pzSampleText);
if (OPT_VALUE_TRACE == TRACE_EVERYTHING)
fprintf(pfTrace, zFileLine, pCurTemplate->pzTplFile,
pMac->lineNo);
}
break;
}
/*
* The current macro becomes the selected selection macro
*/
pCurMacro = pMac;
mRes = (*(match_procs[pMac->funcCode & 0x0F])
)(pzSampleText, pT->pzTemplText + pMac->ozText);
/*
* IF match, THEN generate and stop looking for a match.
*/
if (SUCCEEDED(mRes)) {
if (OPT_VALUE_TRACE >= TRACE_BLOCK_MACROS) {
fprintf(pfTrace, "CASE string `%s' %s matched `%s'\n",
pzSampleText,
match_names[pMac->funcCode & 0x0F],
pT->pzTemplText + pMac->ozText);
if (OPT_VALUE_TRACE == TRACE_EVERYTHING)
fprintf(pfTrace, zFileLine, pCurTemplate->pzTplFile,
pMac->lineNo);
}
generateBlock(pT, pMac + 1, pT->aMacros + pMac->sibIndex);
break;
}
else if (OPT_VALUE_TRACE == TRACE_EVERYTHING) {
fprintf(pfTrace, "CASE no match: `%s' %s vs. `%s'\n",
pzSampleText,
match_names[pMac->funcCode & 0x0F],
pT->pzTemplText + pMac->ozText);
}
}
if (needFree)
AGFREE((void*)pzSampleText);
return pEnd;
}
示例14: doDir_shell
/**
* Invokes @code{$SHELL} or @file{/bin/sh} on a script that should
* generate AutoGen definitions. It does this using the same server
* process that handles the back-quoted @code{`} text.
* The block of text handed to the shell is terminated with
* the #endshell directive.
*
* @strong{CAUTION}@: let not your @code{$SHELL} be @code{csh}.
*/
char *
doDir_shell(directive_enum_t id, char const * arg, char * scan_next)
{
static size_t const endshell_len = sizeof("\n#endshell") - 1;
scan_ctx_t * pCtx;
char * pzText = scan_next;
(void)arg;
(void)id;
/*
* The output time will always be the current time.
* The dynamic content is always current :)
*/
maxfile_time = outfile_time = time(NULL);
/*
* IF there are no data after the '#shell' directive,
* THEN we won't write any data
* ELSE we have to find the end of the data.
*/
if (strncmp(pzText, DIRECT_SHELL_END_SHELL+1, endshell_len-1) == 0)
return scan_next;
{
char * pz = strstr(scan_next, DIRECT_SHELL_END_SHELL);
if (pz == NULL)
AG_ABEND(aprf(DIRECT_SHELL_NOEND, cctx->scx_fname,
cctx->scx_line));
while (scan_next < pz) {
if (*(scan_next++) == NL) cctx->scx_line++;
}
*scan_next = NUL;
}
/*
* Advance the scan pointer to the next line after '#endshell'
* IF there is no such line,
* THEN the scan will resume on a zero-length string.
*/
scan_next = strchr(scan_next + endshell_len, NL);
if (scan_next == NULL)
scan_next = VOIDP(zNil);
/*
* Save the scan pointer into the current context
*/
cctx->scx_scan = scan_next;
/*
* Run the shell command. The output text becomes the
* "file text" that is used for more definitions.
*/
pzText = shell_cmd(pzText);
if (pzText == NULL)
return scan_next;
if (*pzText == NUL) {
AGFREE(pzText);
return scan_next;
}
/*
* Get the space for the output data and for context overhead.
* This is an extra allocation and copy, but easier than rewriting
* 'loadData()' for this special context.
*/
pCtx = (scan_ctx_t *)AGALOC(sizeof(scan_ctx_t) + strlen(pzText) + 4,
"shell output");
/*
* Link the new scan data into the context stack
*/
pCtx->scx_next = cctx;
cctx = pCtx;
/*
* Set up the rest of the context structure
*/
AGDUPSTR(pCtx->scx_fname, DIRECT_SHELL_COMP_DEFS, DIRECT_SHELL_COMP_DEFS);
pCtx->scx_scan =
pCtx->scx_data = (char *)(pCtx + 1);
pCtx->scx_line = 0;
strcpy(pCtx->scx_scan, pzText);
AGFREE(pzText);
return pCtx->scx_scan;
}
示例15: write_eventControl
static int
write_eventControl(int action, u_char * var_val, u_char var_val_type,
size_t var_val_len, u_char * statP,
oid * name, size_t name_len)
{
long long_temp;
char *char_temp;
int leaf_id, snmp_status;
static int prev_action = COMMIT;
RMON_ENTRY_T *hdr;
CRTL_ENTRY_T *cloned_body;
switch (action) {
case RESERVE1:
case FREE:
case UNDO:
case ACTION:
case COMMIT:
default:
return ROWAPI_do_another_action(name, eventEntryFirstIndexBegin,
action, &prev_action,
table_ptr, sizeof(CRTL_ENTRY_T));
case RESERVE2:
/*
* get values from PDU, check them and save them in the cloned entry
*/
long_temp = name[eventEntryFirstIndexBegin];
leaf_id = (int) name[eventEntryFirstIndexBegin - 1];
hdr = ROWAPI_find(table_ptr, long_temp); /* it MUST be OK */
cloned_body = (CRTL_ENTRY_T *) hdr->tmp;
switch (leaf_id) {
case Leaf_event_index:
return SNMP_ERR_NOTWRITABLE;
case Leaf_event_description:
char_temp = AGMALLOC(1 + MAX_event_description);
if (!char_temp)
return SNMP_ERR_TOOBIG;
snmp_status = AGUTIL_get_string_value(var_val, var_val_type,
var_val_len,
MAX_event_description,
1, NULL, char_temp);
if (SNMP_ERR_NOERROR != snmp_status) {
AGFREE(char_temp);
return snmp_status;
}
if (cloned_body->event_description)
AGFREE(cloned_body->event_description);
cloned_body->event_description = AGSTRDUP(char_temp);
/*
* ag_trace ("rx: event_description=<%s>", cloned_body->event_description);
*/
AGFREE(char_temp);
break;
case Leaf_event_type:
snmp_status = AGUTIL_get_int_value(var_val, var_val_type,
var_val_len,
EVENT_NONE,
EVENT_LOG_AND_TRAP,
&long_temp);
if (SNMP_ERR_NOERROR != snmp_status) {
return snmp_status;
}
cloned_body->event_type = long_temp;
break;
case Leaf_event_last_time_sent:
return SNMP_ERR_NOTWRITABLE;
case Leaf_event_community:
char_temp = AGMALLOC(1 + MAX_event_community);
if (!char_temp)
return SNMP_ERR_TOOBIG;
snmp_status = AGUTIL_get_string_value(var_val, var_val_type,
var_val_len,
MAX_event_community,
1, NULL, char_temp);
if (SNMP_ERR_NOERROR != snmp_status) {
AGFREE(char_temp);
return snmp_status;
}
if (cloned_body->event_community)
AGFREE(cloned_body->event_community);
cloned_body->event_community = AGSTRDUP(char_temp);
AGFREE(char_temp);
break;
case Leaf_eventOwner:
if (hdr->new_owner)
AGFREE(hdr->new_owner);
hdr->new_owner = AGMALLOC(MAX_OWNERSTRING);;
if (!hdr->new_owner)
return SNMP_ERR_TOOBIG;
snmp_status = AGUTIL_get_string_value(var_val, var_val_type,
var_val_len,
MAX_OWNERSTRING,
1, NULL, hdr->new_owner);
//.........这里部分代码省略.........