本文整理汇总了C++中OPT_ARG函数的典型用法代码示例。如果您正苦于以下问题:C++ OPT_ARG函数的具体用法?C++ OPT_ARG怎么用?C++ OPT_ARG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OPT_ARG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: update_server_color
//*******************************************************************
// UPDATE SERVER COLOR
//*******************************************************************
static void update_server_color(trx *t, struct probe_result *prv)
{
dbi_result result;
int maxcolor, newcolor;
if (t->def->server < 2) return;
if (t->probe->fuse && (t->res->color < prv->color)) {
// if this probe acts like a fuse, use the previous color if it's higher
newcolor = prv->color;
} else {
newcolor = t->res->color;
}
maxcolor = newcolor; // init
result = db_query(t->probe->db, 0,
"select max(color) as color from pr_status where server = '%u'", t->def->server);
if (result && dbi_result_next_row(result)) {
maxcolor = dbi_result_get_uint(result, "color");
}
dbi_result_free(result);
//if (t->res->color <= maxcolor) return;
result = db_query(t->probe->db, 0,
// update server set color = '200' where id = '345'
"update %s set %s = '%u' where %s = '%u'",
OPT_ARG(SERVER_TABLE_NAME), OPT_ARG(SERVER_TABLE_COLOR_FIELD),
maxcolor, OPT_ARG(SERVER_TABLE_ID_FIELD), t->def->server);
dbi_result_free(result);
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:33,代码来源:process.c
示例2: 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;
}
开发者ID:frankmorgner,项目名称:gnutls,代码行数:29,代码来源:ocsptool.c
示例3: run
int run(void)
{
database *db;
if (!cache) {
cache = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, free_probe);
}
LOG(LOG_INFO, "reading info from database (group %u)", (unsigned)OPT_VALUE_GROUPID);
uw_setproctitle("reading info from database (group %u)", (unsigned)OPT_VALUE_GROUPID);
db = open_database(OPT_ARG(DBTYPE), OPT_ARG(DBHOST), OPT_VALUE_DBPORT, OPT_ARG(DBNAME),
OPT_ARG(DBUSER), OPT_ARG(DBPASSWD));
if (db) {
refresh_database(db);
close_database(db);
}
if (g_hash_table_size(cache) > 0) {
LOG(LOG_INFO, "running %d probes from group %u", g_hash_table_size(cache), (unsigned)OPT_VALUE_GROUPID);
uw_setproctitle("running %d probes from group %u", g_hash_table_size(cache), (unsigned)OPT_VALUE_GROUPID);
run_actual_probes(); /* this runs the actual probes */
LOG(LOG_INFO, "writing results");
uw_setproctitle("writing results");
write_results();
}
return(g_hash_table_size(cache));
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:29,代码来源:run.c
示例4: 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;
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:28,代码来源:run.c
示例5: find_expired_probes
int find_expired_probes(struct dbspec *dbspec)
{
xmlDocPtr doc;
xmlNodePtr probe;
dbi_result result;
dbi_conn conn;
int count = 0;
char buf[10];
sprintf(buf, "%d", dbspec->port);
conn = open_database(OPT_ARG(DBTYPE), dbspec->host, buf, dbspec->db,
dbspec->user, dbspec->password);
if (!conn) return 0;
doc = UpwatchXmlDoc("result", NULL);
// find all expired probes, but skip those for which processing
// has been stopped for some reason
result = db_query(conn, 0, "select probe.name, pr_status.probe, "
" pr_status.server, pr_status.color, "
" pr_status.expires "
"from pr_status, probe "
"where probe.id = pr_status.class and color <> 400 "
" and expires < UNIX_TIMESTAMP()-30 "
" and expires < probe.lastseen"
" and probe.expiry = 'yes'");
if (!result) goto errexit;
while (dbi_result_next_row(result)) {
char buffer[256];
time_t now = time(NULL);
probe = xmlNewChild(xmlDocGetRootElement(doc), NULL, dbi_result_get_string(result, "name"), NULL);
xmlSetProp(probe, "realm", dbspec->realm);
xmlSetProp(probe, "id", dbi_result_get_string(result, "probe"));
xmlSetProp(probe, "server", dbi_result_get_string(result, "server"));
sprintf(buffer, "%u", (int) now); xmlSetProp(probe, "date", buffer);
xmlSetProp(probe, "expires", dbi_result_get_string(result, "expires"));
xmlNewChild(probe, NULL, "color", "400"); // PURPLE
xmlNewChild(probe, NULL, "prevcolor", dbi_result_get_string(result, "color"));
LOG(LOG_INFO, "%s: purpled %s %d", dbspec->realm, dbi_result_get_string(result, "name"),
dbi_result_get_uint(result, "probe"));
count++;
}
if (count) {
xmlSetDocCompressMode(doc, OPT_VALUE_COMPRESS);
spool_result(OPT_ARG(SPOOLDIR), OPT_ARG(OUTPUT), doc, NULL);
LOG(LOG_INFO, "%s: purpled %u probes", dbspec->realm, count);
}
errexit:
if (result) dbi_result_free(result);
if (conn) close_database(conn);
if (doc) xmlFreeDoc(doc);
return count;
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:59,代码来源:run.c
示例6: main
int main(int argc, char **argv)
{
int ret;
if ((ret = gnutls_global_init()) < 0) {
fprintf(stderr, "global_init: %s\n", gnutls_strerror(ret));
exit(1);
}
optionProcess(&ocsptoolOptions, argc, argv);
gnutls_global_set_log_function(tls_log_func);
gnutls_global_set_log_level(OPT_VALUE_DEBUG);
if (HAVE_OPT(OUTFILE)) {
outfile = fopen(OPT_ARG(OUTFILE), "wb");
if (outfile == NULL) {
fprintf(stderr, "%s\n", OPT_ARG(OUTFILE));
exit(1);
}
} else
outfile = stdout;
if (HAVE_OPT(INFILE)) {
infile = fopen(OPT_ARG(INFILE), "rb");
if (infile == NULL) {
fprintf(stderr, "%s\n", OPT_ARG(INFILE));
exit(1);
}
} else
infile = stdin;
if (ENABLED_OPT(INDER))
encoding = GNUTLS_X509_FMT_DER;
else
encoding = GNUTLS_X509_FMT_PEM;
if (HAVE_OPT(REQUEST_INFO))
request_info();
else if (HAVE_OPT(RESPONSE_INFO))
response_info();
else if (HAVE_OPT(GENERATE_REQUEST))
generate_request(NULL);
else if (HAVE_OPT(VERIFY_RESPONSE))
verify_response(NULL);
else if (HAVE_OPT(ASK))
ask_server(OPT_ARG(ASK));
else {
USAGE(1);
}
return 0;
}
开发者ID:ffmpeg-build-win,项目名称:gnutls,代码行数:53,代码来源:ocsptool.c
示例7: 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;
}
开发者ID:pexip,项目名称:os-autogen,代码行数:53,代码来源:xml2ag.c
示例8: bin_syserror
static int
bin_syserror(char *nam, char **args, Options ops, UNUSED(int func))
{
int num = 0;
char *errvar = NULL, *msg, *pfx = "", *str;
/* variable in which to write error message */
if (OPT_ISSET(ops, 'e')) {
errvar = OPT_ARG(ops, 'e');
if (!isident(errvar)) {
zwarnnam(nam, "not an identifier: %s", errvar);
return 1;
}
}
/* prefix for error message */
if (OPT_ISSET(ops, 'p'))
pfx = OPT_ARG(ops, 'p');
if (!*args)
num = errno;
else {
char *ptr = *args;
while (*ptr && idigit(*ptr))
ptr++;
if (!*ptr && ptr > *args)
num = atoi(*args);
else {
const char **eptr;
for (eptr = sys_errnames; *eptr; eptr++) {
if (!strcmp(*eptr, *args)) {
num = (eptr - sys_errnames) + 1;
break;
}
}
if (!*eptr)
return 2;
}
}
msg = strerror(num);
if (errvar) {
str = (char *)zalloc(strlen(msg) + strlen(pfx) + 1);
sprintf(str, "%s%s", pfx, msg);
setsparam(errvar, str);
} else {
fprintf(stderr, "%s%s\n", pfx, msg);
}
return 0;
}
开发者ID:Jaharmi,项目名称:zsh,代码行数:50,代码来源:system.c
示例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);
}
开发者ID:frankmorgner,项目名称:gnutls,代码行数:34,代码来源:ocsptool.c
示例10: 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);
}
开发者ID:ffmpeg-build-win,项目名称:gnutls,代码行数:25,代码来源:ocsptool.c
示例11: bin_sysopen
static int
bin_sysopen(char *nam, char **args, Options ops, UNUSED(int func))
{
int read = OPT_ISSET(ops, 'r');
int write = OPT_ISSET(ops, 'w');
int append = OPT_ISSET(ops, 'a') ? O_APPEND : 0;
int flags = O_NOCTTY | append | ((append || write) ?
(read ? O_RDWR : O_WRONLY) : O_RDONLY);
char *opt, *ptr, *nextopt, *fdvar;
int o, fd, explicit = -1;
mode_t perms = 0666;
#if defined(FD_CLOEXEC) && !defined(O_CLOEXEC)
int fdflags;
#endif
if (!OPT_ISSET(ops, 'u')) {
zwarnnam(nam, "file descriptor not specified");
return 1;
}
/* file descriptor, either 0-9 or a variable name */
fdvar = OPT_ARG(ops, 'u');
if (idigit(*fdvar) && !fdvar[1]) {
explicit = atoi(fdvar);
} else if (!isident(fdvar)) {
开发者ID:phy1729,项目名称:zsh,代码行数:25,代码来源:system.c
示例12: 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++;
}
开发者ID:komh,项目名称:gnutls-os2,代码行数:31,代码来源:cli-debug.c
示例13: bb_cpu_find_realm
// determine - given the servername - the db realm it belongs to.
int bb_cpu_find_realm(trx *t)
{
int i, server;
query_server_by_name = NULL;
for (i=0; i < dblist_cnt; i++) {
t->probe->db = open_realm(dblist[i].realm, OPT_ARG(DBTYPE), OPT_ARG(DBHOST), OPT_VALUE_DBPORT, OPT_ARG(DBNAME), OPT_ARG(DBUSER), OPT_ARG(DBPASSWD));
server = realm_server_by_name(dblist[i].realm, t->res->hostname);
if (server > 1) {
t->res->server = server;
t->res->realm = strdup(dblist[i].realm);
query_server_by_name = dblist[i].srvrbyname;
break;
}
}
return 1;
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:18,代码来源:bb_cpu.c
示例14: bin_syswrite
static int
bin_syswrite(char *nam, char **args, Options ops, UNUSED(int func))
{
int outfd = 1, len, count, totcount;
char *countvar = NULL;
/* -o: output file descriptor if not stdout */
if (OPT_ISSET(ops, 'o')) {
outfd = getposint(OPT_ARG(ops, 'o'), nam);
if (outfd < 0)
return 1;
}
/* -c: variable in which to store count of bytes written */
if (OPT_ISSET(ops, 'c')) {
countvar = OPT_ARG(ops, 'c');
if (!isident(countvar)) {
zwarnnam(nam, "not an identifier: %s", countvar);
return 1;
}
}
totcount = 0;
unmetafy(*args, &len);
while (len) {
while ((count = write(outfd, *args, len)) < 0) {
if (errno != EINTR || errflag || retflag || breaks || contflag)
{
if (countvar)
setiparam(countvar, totcount);
return 2;
}
}
*args += count;
totcount += count;
len -= count;
}
if (countvar)
setiparam(countvar, totcount);
return 0;
}
开发者ID:Jaharmi,项目名称:zsh,代码行数:42,代码来源:system.c
示例15: add_sysstat_info
void add_sysstat_info(xmlNodePtr node)
{
char info[32768];
if (st.load) {
if (st.load->min1 >= atof(OPT_ARG(LOADAVG_YELLOW))) {
char cmd[1024];
char buffer[24];
FILE *in;
if (st.load->min1 >= atof(OPT_ARG(LOADAVG_YELLOW))) sprintf(buffer, "%d", STAT_YELLOW);
if (st.load->min1 >= atof(OPT_ARG(LOADAVG_RED))) sprintf(buffer, "%d", STAT_RED);
xmlSetProp(node, "color", buffer);
sprintf(cmd, "%s > /tmp/.uw_sysstat.tmp", OPT_ARG(TOP_COMMAND));
LOG(LOG_INFO, cmd);
uw_setproctitle("running %s", OPT_ARG(TOP_COMMAND));
system(cmd);
in = fopen("/tmp/.uw_sysstat.tmp", "r");
if (in) {
signed char *s = info;
size_t len;
for (len=0; len < sizeof(info)-1; len++) {
int c;
if ((c = fgetc(in)) != EOF) {
if (c < 0) c = ' ';
*s++ = c;
}
}
*s = 0;
fclose(in);
} else {
strcpy(info, strerror(errno));
}
unlink("/tmp/.uw_sysstat.tmp");
xmlNewTextChild(node, NULL, "info", info);
}
}
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:40,代码来源:run.c
示例16: handle_lookup
/*
** handle_lookup
*/
void
handle_lookup(
const char *name,
int flags
)
{
struct addrinfo hints; /* Local copy is OK */
struct dns_ctx *ctx;
char * name_copy;
size_t name_sz;
size_t octets;
TRACE(1, ("handle_lookup(%s,%#x)\n", name, flags));
ZERO(hints);
hints.ai_family = ai_fam_pref;
hints.ai_flags = AI_CANONNAME | Z_AI_NUMERICSERV;
/*
** Unless we specify a socktype, we'll get at least two
** entries for each address: one for TCP and one for
** UDP. That's not what we want.
*/
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
name_sz = 1 + strlen(name);
octets = sizeof(*ctx) + name_sz; // Space for a ctx and the name
ctx = emalloc_zero(octets); // ctx at ctx[0]
name_copy = (char *)(ctx + 1); // Put the name at ctx[1]
memcpy(name_copy, name, name_sz); // copy the name to ctx[1]
ctx->name = name_copy; // point to it...
ctx->flags = flags;
ctx->timeout = response_tv;
ctx->key = NULL;
/* The following should arguably be passed in... */
if (ENABLED_OPT(AUTHENTICATION)) {
ctx->key_id = OPT_VALUE_AUTHENTICATION;
get_key(ctx->key_id, &ctx->key);
if (NULL == ctx->key) {
fprintf(stderr, "%s: Authentication with keyID %d requested, but no matching keyID found in <%s>!\n",
progname, ctx->key_id, OPT_ARG(KEYFILE));
exit(1);
}
} else {
ctx->key_id = -1;
}
++n_pending_dns;
getaddrinfo_sometime(name, "123", &hints, 0,
&sntp_name_resolved, ctx);
}
开发者ID:kjopek,项目名称:freebsd,代码行数:55,代码来源:main.c
示例17: tcpedit_dlt_post_args
/**
* \brief Call this to parse AutoOpts arguments for the DLT encoder plugin
*
* Was previously part of tcpedit_dlt_init(), but moved into it's own function
* to allow a full programtic API. Basically, if you're not using this function
* you'll need to roll your own!
* Returns 0 on success, -1 on error
*/
int
tcpedit_dlt_post_args(tcpedit_t *tcpedit)
{
tcpeditdlt_t *ctx;
const char *dst_dlt_name = NULL;
int rcode;
assert(tcpedit);
ctx = tcpedit->dlt_ctx;
assert(ctx);
/* Select the encoder plugin */
dst_dlt_name = OPT_ARG(DLT) ? OPT_ARG(DLT) : ctx->decoder->name;
if ((ctx->encoder = tcpedit_dlt_getplugin_byname(ctx, dst_dlt_name)) == NULL) {
tcpedit_seterr(tcpedit, "No output DLT plugin available for: %s", dst_dlt_name);
return TCPEDIT_ERROR;
}
/* Figure out if we're skipping braodcast & multicast */
if (HAVE_OPT(SKIPL2BROADCAST))
ctx->skip_broadcast = 1;
/* init encoder plugin if it's not the decoder plugin */
if (ctx->encoder->dlt != ctx->decoder->dlt) {
if ((rcode = ctx->encoder->plugin_init(ctx)) != TCPEDIT_OK) {
/* plugin should generate the error */
return TCPEDIT_ERROR;
}
}
/* parse the DLT specific options */
if ((rcode = tcpedit_dlt_parse_opts(ctx)) != TCPEDIT_OK) {
/* parser should generate the error */
return TCPEDIT_ERROR;
}
/* we're OK */
return tcpedit_dlt_post_init(ctx);
}
开发者ID:cpackham,项目名称:tcpreplay,代码行数:47,代码来源:dlt_plugins.c
示例18: add_systemp
void add_systemp(xmlNodePtr node)
{
char buffer[24];
int systemp = 0;
if (HAVE_OPT(SYSTEMP_COMMAND)) {
char cmd[1024];
FILE *in;
sprintf(cmd, "%s > /tmp/.uw_sysstat.tmp", OPT_ARG(SYSTEMP_COMMAND));
uw_setproctitle("running %s", OPT_ARG(SYSTEMP_COMMAND));
system(cmd);
in = fopen("/tmp/.uw_sysstat.tmp", "r");
if (in) {
fscanf(in, "%d", &systemp);
fclose(in);
}
unlink("tmp/.uw_sysstat.tmp");
}
sprintf(buffer, "%d", systemp);
xmlNewChild(node, NULL, "systemp", buffer);
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:22,代码来源:run.c
示例19: bin_strftime
static int
bin_strftime(char *nam, char **argv, Options ops, UNUSED(int func))
{
int bufsize, x;
char *endptr = NULL, *scalar = NULL, *buffer;
time_t secs;
struct tm *t;
if (OPT_ISSET(ops,'s')) {
scalar = OPT_ARG(ops, 's');
if (!isident(scalar)) {
zwarnnam(nam, "not an identifier: %s", scalar);
return 1;
}
}
if (OPT_ISSET(ops, 'r'))
return reverse_strftime(nam, argv, scalar, OPT_ISSET(ops, 'q'));
errno = 0;
secs = (time_t)strtoul(argv[1], &endptr, 10);
if (errno != 0) {
zwarnnam(nam, "%s: %e", argv[1], errno);
return 1;
} else if (*endptr != '\0') {
zwarnnam(nam, "%s: invalid decimal number", argv[1]);
return 1;
}
t = localtime(&secs);
if (!t) {
zwarnnam(nam, "%s: unable to convert to time", argv[1]);
return 1;
}
bufsize = strlen(argv[0]) * 8;
buffer = zalloc(bufsize);
for (x=0; x < 4; x++) {
if (ztrftime(buffer, bufsize, argv[0], t) >= 0)
break;
buffer = zrealloc(buffer, bufsize *= 2);
}
if (scalar) {
setsparam(scalar, metafy(buffer, -1, META_DUP));
} else {
printf("%s\n", buffer);
}
zfree(buffer, bufsize);
return 0;
}
开发者ID:Lujaw,项目名称:zsh,代码行数:51,代码来源:datetime.c
示例20: post_args
/**
* post AutoGen argument processing
*/
void
post_args(_U_ int argc, _U_ char *argv[])
{
char ebuf[PCAP_ERRBUF_SIZE];
#ifdef DEBUG
if (HAVE_OPT(DBUG))
debug = OPT_VALUE_DBUG;
#else
if (HAVE_OPT(DBUG))
warn("not configured with --enable-debug. Debugging disabled.");
#endif
#ifdef ENABLE_VERBOSE
if (HAVE_OPT(VERBOSE))
options.verbose = 1;
if (HAVE_OPT(DECODE))
tcpdump.args = safe_strdup(OPT_ARG(DECODE));
#endif
#ifdef ENABLE_FRAGROUTE
if (HAVE_OPT(FRAGROUTE))
options.fragroute_args = safe_strdup(OPT_ARG(FRAGROUTE));
options.fragroute_dir = FRAGROUTE_DIR_BOTH;
if (HAVE_OPT(FRAGDIR)) {
if (strcmp(OPT_ARG(FRAGDIR), "c2s") == 0) {
options.fragroute_dir = FRAGROUTE_DIR_C2S;
} else if (strcmp(OPT_ARG(FRAGDIR), "s2c") == 0) {
options.fragroute_dir = FRAGROUTE_DIR_S2C;
} else if (strcmp(OPT_ARG(FRAGDIR), "both") == 0) {
options.fragroute_dir = FRAGROUTE_DIR_BOTH;
} else {
errx(-1, "Unknown --fragdir value: %s", OPT_ARG(FRAGDIR));
}
}
#endif
/* open up the input file */
options.infile = safe_strdup(OPT_ARG(INFILE));
if ((options.pin = pcap_open_offline(options.infile, ebuf)) == NULL)
errx(-1, "Unable to open input pcap file: %s", ebuf);
#ifdef HAVE_PCAP_SNAPSHOT
if (pcap_snapshot(options.pin) < 65535)
warnx("%s was captured using a snaplen of %d bytes. This may mean you have truncated packets.",
options.infile, pcap_snapshot(options.pin));
#endif
}
开发者ID:AmesianX,项目名称:tcpreplay-netmap,代码行数:56,代码来源:tcprewrite.c
注:本文中的OPT_ARG函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论