本文整理汇总了C++中HAVE_OPT函数的典型用法代码示例。如果您正苦于以下问题:C++ HAVE_OPT函数的具体用法?C++ HAVE_OPT怎么用?C++ HAVE_OPT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HAVE_OPT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmd_parser
static void cmd_parser(int argc, char **argv)
{
const char *rest = NULL;
int optct = optionProcess(&gnutls_cli_debugOptions, argc, argv);
argc -= optct;
argv += optct;
if (rest == NULL && argc > 0)
rest = argv[0];
if (HAVE_OPT(PORT))
port = OPT_VALUE_PORT;
else {
if (HAVE_OPT(STARTTLS_PROTO))
port = starttls_proto_to_port(OPT_ARG(STARTTLS_PROTO));
else
port = 443;
}
if (rest == NULL)
hostname = "localhost";
else
hostname = rest;
if (HAVE_OPT(DEBUG))
debug = OPT_VALUE_DEBUG;
if (HAVE_OPT(VERBOSE))
verbose++;
}
示例2: verify_response
static void verify_response(gnutls_datum_t *nonce)
{
gnutls_datum_t dat;
size_t size;
gnutls_x509_crt_t signer;
int v;
if (HAVE_OPT(LOAD_RESPONSE))
dat.data =
(void *) read_binary_file(OPT_ARG(LOAD_RESPONSE),
&size);
else
dat.data = (void *) fread_file(infile, &size);
if (dat.data == NULL) {
fprintf(stderr, "error reading response\n");
exit(1);
}
dat.size = size;
signer = load_signer();
v = _verify_response(&dat, nonce, signer);
if (v && !HAVE_OPT(IGNORE_ERRORS))
exit(1);
}
示例3: processEmbeddedOptions
/*
* processEmbeddedOptions
*
* This routine processes the text contained within "/\*==--"
* and "=\*\/" as a single option. If that option is the SUBBLOCK
* option, it will need to be massaged for use.
*/
LOCAL void
processEmbeddedOptions(char* pzText)
{
tSCC zStStr[] = "/*=--";
tSCC zEndSt[] = "=*/";
for (;;) {
char* pzStart = strstr(pzText, zStStr);
char* pzEnd;
int sblct = 0;
if (pzStart == NULL)
return;
if (HAVE_OPT(SUBBLOCK))
sblct = STACKCT_OPT(SUBBLOCK);
pzEnd = strstr(pzStart, zEndSt);
if (pzEnd == NULL)
return;
pzStart = compressOptionText(pzStart + sizeof(zStStr)-1, pzEnd);
optionLoadLine(&getdefsOptions, pzStart);
if (HAVE_OPT(SUBBLOCK) && (sblct != STACKCT_OPT(SUBBLOCK))) {
tCC** ppz = STACKLST_OPT(SUBBLOCK);
ppz[ sblct ] = fixupSubblockString(ppz[sblct]);
}
pzText = pzEnd + sizeof(zEndSt);
}
}
示例4: ask_server
static void ask_server(const char* url)
{
gnutls_datum_t resp_data;
int ret, v;
gnutls_x509_crt_t cert, issuer;
cert = load_cert();
issuer = load_issuer();
ret = send_ocsp_request(url, cert, issuer, &resp_data, ENABLED_OPT(NONCE));
if (ret < 0)
{
fprintf(stderr, "Cannot send OCSP request\n");
exit(1);
}
_response_info (&resp_data);
if (HAVE_OPT(LOAD_SIGNER) || HAVE_OPT(LOAD_TRUST))
{
fprintf(outfile, "\n");
v = _verify_response(&resp_data);
}
else
{
fprintf(stderr, "\nResponse could not be verified (use --load-signer).\n");
v = 0;
}
if (HAVE_OPT(OUTFILE) && v == 0)
{
fwrite(resp_data.data, 1, resp_data.size, outfile);
}
}
示例5: ask_server
static void ask_server(const char *url)
{
gnutls_datum_t resp_data;
int ret, v = 0;
gnutls_x509_crt_t cert, issuer;
unsigned char noncebuf[23];
gnutls_datum_t nonce = { noncebuf, sizeof(noncebuf) };
gnutls_datum_t *n;
cert = load_cert();
issuer = load_issuer();
if (ENABLED_OPT(NONCE)) {
ret =
gnutls_rnd(GNUTLS_RND_NONCE, nonce.data, nonce.size);
if (ret < 0) {
fprintf(stderr, "gnutls_rnd: %s\n",
gnutls_strerror(ret));
exit(1);
}
n = &nonce;
} else {
n = NULL;
}
ret =
send_ocsp_request(url, cert, issuer, &resp_data, n);
if (ret < 0) {
fprintf(stderr, "Cannot send OCSP request\n");
exit(1);
}
_response_info(&resp_data);
if (HAVE_OPT(LOAD_TRUST)) {
v = _verify_response(&resp_data, n, NULL);
} else if (HAVE_OPT(LOAD_SIGNER)) {
v = _verify_response(&resp_data, n, load_signer());
} else {
fprintf(stderr,
"\nAssuming response's signer = issuer (use --load-signer to override).\n");
v = _verify_response(&resp_data, n, issuer);
}
if (HAVE_OPT(OUTFILE) && (v == 0 || HAVE_OPT(IGNORE_ERRORS))) {
fwrite(resp_data.data, 1, resp_data.size, outfile);
}
if (v && !HAVE_OPT(IGNORE_ERRORS))
exit(1);
}
示例6: load_cert
static gnutls_x509_crt_t
load_cert (void)
{
gnutls_x509_crt_t crt;
int ret;
gnutls_datum_t dat;
size_t size;
if (!HAVE_OPT(LOAD_CERT))
error (EXIT_FAILURE, 0, "missing --load-cert");
ret = gnutls_x509_crt_init (&crt);
if (ret < 0)
error (EXIT_FAILURE, 0, "crt_init: %s", gnutls_strerror (ret));
dat.data = (void*)read_binary_file (OPT_ARG(LOAD_CERT), &size);
dat.size = size;
if (!dat.data)
error (EXIT_FAILURE, errno, "reading --load-cert: %s", OPT_ARG(LOAD_CERT));
ret = gnutls_x509_crt_import (crt, &dat, encoding);
free (dat.data);
if (ret < 0)
error (EXIT_FAILURE, 0, "importing --load-cert: %s: %s",
OPT_ARG(LOAD_CERT), gnutls_strerror (ret));
return crt;
}
示例7: run
int run(void)
{
#ifdef USE_ST
st_usleep(1); //force context switch so timers will work
#endif
g_hash_table_foreach(hash, create_q_threads, NULL);
#ifdef USE_ST
if (debug > 3) { LOG(LOG_DEBUG, "waiting for all threads to finish"); }
while (thread_count) {
st_usleep(10000); /* 10 ms */
}
#endif
if (HAVE_OPT(HANGUPSCRIPT) && online) {
int status;
status = system(OPT_ARG(HANGUPSCRIPT));
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) != 0) {
LOG(LOG_WARNING, "%s: error %d", OPT_ARG(HANGUPSCRIPT), WEXITSTATUS(status));
}
} else {
LOG(LOG_ERR, "%s exited abnormally", OPT_ARG(HANGUPSCRIPT));
}
}
online = FALSE;
uw_setproctitle("sleeping");
return 0;
}
示例8: opt_to_flags
static
unsigned opt_to_flags(void)
{
unsigned flags = 0;
if (HAVE_OPT(MARK_PRIVATE)) {
if (ENABLED_OPT(MARK_PRIVATE)) {
flags |= GNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE;
} else {
flags |= GNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_PRIVATE;
}
}
if (ENABLED_OPT(MARK_TRUSTED))
flags |=
GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED;
if (ENABLED_OPT(MARK_CA))
flags |=
GNUTLS_PKCS11_OBJ_FLAG_MARK_CA;
if (ENABLED_OPT(MARK_WRAP))
flags |= GNUTLS_PKCS11_OBJ_FLAG_MARK_KEY_WRAP;
if (ENABLED_OPT(LOGIN))
flags |= GNUTLS_PKCS11_OBJ_FLAG_LOGIN;
if (ENABLED_OPT(SO_LOGIN))
flags |= GNUTLS_PKCS11_OBJ_FLAG_LOGIN_SO;
return flags;
}
示例9: request_info
static void
request_info (void)
{
gnutls_ocsp_req_t req;
int ret;
gnutls_datum_t dat;
size_t size;
ret = gnutls_ocsp_req_init (&req);
if (ret < 0)
error (EXIT_FAILURE, 0, "ocsp_req_init: %s", gnutls_strerror (ret));
if (HAVE_OPT(LOAD_REQUEST))
dat.data = (void*)read_binary_file (OPT_ARG(LOAD_REQUEST), &size);
else
dat.data = (void*)fread_file (infile, &size);
if (dat.data == NULL)
error (EXIT_FAILURE, errno, "reading request");
dat.size = size;
ret = gnutls_ocsp_req_import (req, &dat);
free (dat.data);
if (ret < 0)
error (EXIT_FAILURE, 0, "importing request: %s", gnutls_strerror (ret));
ret = gnutls_ocsp_req_print (req, GNUTLS_OCSP_PRINT_FULL, &dat);
if (ret != 0)
error (EXIT_FAILURE, 0, "ocsp_req_print: %s", gnutls_strerror (ret));
printf ("%.*s", dat.size, dat.data);
gnutls_free (dat.data);
gnutls_ocsp_req_deinit (req);
}
示例10: dlt_user_parse_opts
/*
* This is where you should define all your AutoGen AutoOpts option parsing.
* Any user specified option should have it's bit turned on in the 'provides'
* bit mask.
* Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN
*/
int
dlt_user_parse_opts(tcpeditdlt_t *ctx)
{
tcpeditdlt_plugin_t *plugin;
user_config_t *config;
assert(ctx);
plugin = tcpedit_dlt_getplugin(ctx, dlt_value);
config = plugin->config;
/*
* --user-dlt will override the output DLT type, otherwise we'll use
* the DLT of the decoder
*/
if (HAVE_OPT(USER_DLT)) {
config->dlt = OPT_VALUE_USER_DLT;
} else {
config->dlt = ctx->decoder->dlt;
}
/* --user-dlink */
if (HAVE_OPT(USER_DLINK)) {
int ct = STACKCT_OPT(USER_DLINK);
char **list = STACKLST_OPT(USER_DLINK);
int first = 1;
do {
char *p = *list++;
if (first) {
config->length = read_hexstring(p, config->l2server, USER_L2MAXLEN);
memcpy(config->l2client, config->l2server, config->length);
} else {
if (config->length != read_hexstring(p, config->l2client, USER_L2MAXLEN)) {
tcpedit_seterr(ctx->tcpedit, "%s",
"both --dlink's must contain the same number of bytes");
return TCPEDIT_ERROR;
}
}
first = 0;
} while (--ct > 0);
}
return TCPEDIT_OK; /* success */
}
示例11: dlt_hdlc_parse_opts
/*
* This is where you should define all your AutoGen AutoOpts option parsing.
* Any user specified option should have it's bit turned on in the 'provides'
* bit mask.
* Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN
*/
int
dlt_hdlc_parse_opts(tcpeditdlt_t *ctx)
{
tcpeditdlt_plugin_t *plugin;
hdlc_config_t *config;
assert(ctx);
plugin = tcpedit_dlt_getplugin(ctx, dlt_value);
config = plugin->config;
if (HAVE_OPT(HDLC_CONTROL)) {
config->control = (uint16_t)OPT_VALUE_HDLC_CONTROL;
}
if (HAVE_OPT(HDLC_ADDRESS)) {
config->address = (uint16_t)OPT_VALUE_HDLC_ADDRESS;
}
return TCPEDIT_OK; /* success */
}
示例12: init
int init(void)
{
if (!HAVE_OPT(OUTPUT)) {
LOG(LOG_ERR, "missing output option");
return 0;
}
daemonize = TRUE;
every = EVERY_MINUTE;
xmlSetGenericErrorFunc(NULL, UpwatchXmlGenericErrorFunc);
return(1);
}
示例13: printHeader
static xmlNodePtr
printHeader( xmlDocPtr pDoc )
{
tSCC zDef[] = "AutoGen Definitions %s%s;\n";
char const* pzSfx = ".tpl";
xmlNodePtr pRootNode = xmlDocGetRootElement( pDoc );
xmlChar* pTpl = NULL;
xmlChar* pzTpl;
if (pRootNode == NULL) {
fprintf( stderr, "Root node not found\n" );
exit( EXIT_FAILURE );
}
if (HAVE_OPT( OVERRIDE_TPL )) {
if (strchr( OPT_ARG( OVERRIDE_TPL ), '.' ) != NULL)
pzSfx = "";
pzTpl = (xmlChar*)(void*)OPT_ARG( OVERRIDE_TPL );
}
else {
pTpl = xmlGetProp( pRootNode, (xmlChar*)(void*)"template" );
if (pTpl == NULL) {
fprintf( stderr, "No template was specified.\n" );
exit( EXIT_FAILURE );
}
pzTpl = pTpl;
if (strchr( (char*)pzTpl, '.' ) != NULL)
pzSfx = "";
}
fprintf( outFp, zDef, pzTpl, pzSfx );
if (pTpl != NULL)
free( pTpl );
if (pDoc->name != NULL)
fprintf( outFp, "XML-name = '%s';\n", TRIM( pDoc->name, NULL ));
if (pDoc->version != NULL)
fprintf( outFp, "XML-version = '%s';\n", TRIM( pDoc->version, NULL ));
if (pDoc->encoding != NULL)
fprintf( outFp, "XML-encoding = '%s';\n", TRIM( pDoc->encoding, NULL ));
if (pDoc->URL != NULL)
fprintf( outFp, "XML-URL = '%s';\n", TRIM( pDoc->URL, NULL ));
if (pDoc->standalone)
fputs( "XML-standalone = true;\n", outFp );
return pRootNode;
}
示例14: check_exit_conditions
/*
* check_exit_conditions()
*
* If sntp has a reply, ask the event loop to stop after this round of
* callbacks, unless --wait was used.
*/
void
check_exit_conditions(void)
{
if ((0 == n_pending_ntp && 0 == n_pending_dns) ||
(time_derived && !HAVE_OPT(WAIT))) {
event_base_loopexit(base, NULL);
shutting_down = TRUE;
} else {
TRACE(2, ("%d NTP and %d name queries pending\n",
n_pending_ntp, n_pending_dns));
}
}
示例15: exec_autogen
static void
exec_autogen(char ** pzBase)
{
char const ** paparg;
char const ** pparg;
int argCt = 5;
/*
* IF we don't have template search directories,
* THEN allocate the default arg counter of pointers and
* set the program name into it.
* ELSE insert each one into the arg list.
*/
if (! HAVE_OPT(AGARG)) {
paparg = pparg = (char const **)malloc(argCt * sizeof(char*));
*pparg++ = pzAutogen;
} else {
int ct = STACKCT_OPT(AGARG);
char const ** ppz = STACKLST_OPT(AGARG);
argCt += ct;
paparg = pparg = (char const **)malloc(argCt * sizeof(char*));
*pparg++ = pzAutogen;
do {
*pparg++ = *ppz++;
} while (--ct > 0);
}
*pparg++ = *pzBase;
*pparg++ = "--";
*pparg++ = "-";
*pparg++ = NULL;
#ifdef DEBUG
fputc('\n', stderr);
pparg = paparg;
for (;;) {
fputs(*pparg++, stderr);
if (*pparg == NULL)
break;
fputc(' ', stderr);
}
fputc('\n', stderr);
fputc('\n', stderr);
#endif
execvp(pzAutogen, (char**)(void*)paparg);
fserr_die("exec of %s %s %s %s\n", paparg[0], paparg[1], paparg[2],
paparg[3]);
}