本文整理汇总了C++中parseargs函数的典型用法代码示例。如果您正苦于以下问题:C++ parseargs函数的具体用法?C++ parseargs怎么用?C++ parseargs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseargs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
//
// main:
int main(int argc, char *argv[])
{
printf("Commander is a command line parsing module writed by L. Maddalena\n");
t_commander *cmd = makecommander();
addparam(cmd, "source");
addparam(cmd, "destination");
addoption(cmd, "f", "foo", "the foo parameter", 0, "value");
addoption(cmd, "g", "gas", "the gas parameter", 0, NULL);
addoption(cmd, "b", "bar", "the bar parameter", 1, "1|2|3");
addoption(cmd, "z", "baz", "the baz parameter", 1, "name");
addoption(cmd, "h", "help", "output usage information", 0, NULL);
int p = parseargs(cmd, argc, argv);
if(argc == 1)
{
showusage(argv[0], cmd);
return 0;
}
if(p == 0 || strcmp(getoptionbysname("h", cmd)->value, "1") == 0)
{
showhelp(argv[0], cmd);
return 0;
}
showreport(cmd);
}
开发者ID:lmaddalena,项目名称:commander,代码行数:31,代码来源:test.c
示例2: main
int main(int argc, char** argv) {
webserver_initialise();
int rc = parseargs(argc, argv);
if (rc)return rc;
logconsole(PKGBANNER);
logconsole(PKGBUILD);
rc = opendb();
if (rc)return rc;
webserver_set_defaults();
webserver_add_search_int("/stanox", corpus_find_stanox);
webserver_add_search_int("/nlc", corpus_find_nlc);
webserver_add_search_int("/uic", corpus_find_uic);
webserver_add_search_str("/3alpha", corpus_find_3alpha);
webserver_add_search_str("/tiploc", corpus_find_tiploc);
logconsole("Starting webserver on port %d", webserver.port);
webserver_start();
while (1) {
sleep(60);
}
}
开发者ID:peter-mount,项目名称:corpus,代码行数:28,代码来源:corpusd.c
示例3: main
int main(int argc, char *argv[])
{
parseargs(argc, argv);
openfiles();
filter();
exit(EXIT_SUCCESS);
}
开发者ID:ivartj,项目名称:tpl,代码行数:7,代码来源:main.c
示例4: while
void IFCParser::parselist(wistream& is, Attribute& args)
{
args.clear();
wstring tok;
while ((tok = lookahead(is)).length() > 0) {
if (tok[0] == L',') {
gettok(is);
continue; // more
}
if (tok[0] == L')')
break;
if (tok[0] == L'(') {
Attribute* f = new Attribute(); // add a list
parseargs(is, *f);
args.add(f);
continue;
}
tok = gettok(is);
args.add(tok); // add a value
}
}
开发者ID:trieck,项目名称:research,代码行数:26,代码来源:ifcparser.cpp
示例5: checkargs
static int
checkargs (int argc, char **argv, bool_t *double_resolution, bool_t *panel,
int *fps, char **image_name, fiasco_d_options_t **options)
/*
* Check validness of command line parameters and of the parameter files.
*
* Return value.
* index in argv of the first argv-element that is not an option.
*
* Side effects:
* 'double_resolution', 'panel', 'fps', 'image_name' and 'options'
* are modified.
*/
{
int optind; /* last processed commandline param */
optind = parseargs (params, argc, argv,
"Decode FIASCO-FILEs and write frame(s) to disk.",
"With no FIASCO-FILE, or if FIASCO-FILE is -, "
"read standard input.\n"
"Environment:\n"
"FIASCO_DATA Search path for automata files. "
"Default: ./\n"
"FIASCO_IMAGES Save path for image files. "
"Default: ./", " [FIASCO-FILE]...",
FIASCO_SHARE, "system.fiascorc", ".fiascorc");
*image_name = (char *) parameter_value (params, "output");
*double_resolution = *((bool_t *) parameter_value (params, "double"));
*panel = *((bool_t *) parameter_value (params, "panel"));
*fps = *((int *) parameter_value (params, "framerate"));
/*
* Additional options ... (have to be set with the fiasco_set_... methods)
*/
*options = fiasco_d_options_new ();
{
int n = *((int *) parameter_value (params, "smoothing"));
if (!fiasco_d_options_set_smoothing (*options, max (-1, n)))
error (fiasco_get_error_message ());
}
{
int n = *((int *) parameter_value (params, "magnify"));
if (!fiasco_d_options_set_magnification (*options, n))
error (fiasco_get_error_message ());
}
{
bool_t n = *((bool_t *) parameter_value (params, "fast"));
if (!fiasco_d_options_set_4_2_0_format (*options, n > 0 ? YES : NO))
error (fiasco_get_error_message ());
}
return optind;
}
开发者ID:emanuele,项目名称:Fiasco,代码行数:60,代码来源:dwfa.c
示例6: main
int main(int argc, char **argv) {
if(signal(SIGINT, safe_exit) == SIG_ERR) SIGFAIL()
if(signal(SIGQUIT, safe_exit) == SIG_ERR) SIGFAIL()
if(signal(SIGTERM, safe_exit) == SIG_ERR) SIGFAIL()
appname = argv[0];
setconfigdefaults();
if(parseargs(argc, argv) != 0) {
return(1);
}
#ifdef DEBUG
(void)printf("name: %s\n", config.name);
(void)printf("host: %s\n", config.host);
(void)printf("port: %s\n", config.port);
(void)printf("limit: %d\n", (int)config.limit);
#endif
if(createandconnectsocket() != 0) {
cleanup();
return(1);
}
while(rcvmsg() == 0 && quit == 0) {
if(processmsg() != 0) {
break;
}
}
cleanup();
return(0);
}
开发者ID:schuay,项目名称:sysprog,代码行数:33,代码来源:main.c
示例7: main2
ram_reply_t main2(int argc, char *argv[])
{
ramtest_params_t testparams;
ram_reply_t e = RAM_REPLY_INSANE;
RAM_FAIL_TRAP(ram_initialize(NULL, NULL));
RAM_FAIL_TRAP(initdefaults(&testparams));
e = parseargs(&testparams, argc, argv);
switch (e)
{
default:
RAM_FAIL_TRAP(e);
case RAM_REPLY_OK:
break;
case RAM_REPLY_INPUTFAIL:
return e;
}
e = runtest(&testparams);
switch (e)
{
default:
RAM_FAIL_TRAP(e);
case RAM_REPLY_OK:
break;
case RAM_REPLY_INPUTFAIL:
return e;
}
return RAM_REPLY_OK;
}
开发者ID:fmrl,项目名称:ramalloc,代码行数:32,代码来源:defaulttest.c
示例8: cor_thresh
int cor_thresh(char *keyword, char *args)
{
static char *realargs[10];
int res;
int val;
int x = 0;
res = parseargs(args, realargs, 1, ',');
if (res != 1) {
error("Incorrect number of arguments to 'corthresh' (should be <value>)\n");
return -1;
}
res = sscanf(realargs[0], "%d", &val);
if ((res == 1) && (val < 1))
res = -1;
for(x = 0; corthreshes[x]; x++)
{
if (corthreshes[x] == val) break;
}
if (!corthreshes[x]) res = -1;
if (res != 1) {
error("Invalid value '%s', should be a number > 0.\n", realargs[0]);
return -1;
}
corthresh = x + 1;
return 0;
}
开发者ID:linuxhut,项目名称:linuxhut,代码行数:26,代码来源:dahdi_cfg.c
示例9: tx
int tx(char *keyword, char *args)
{
static char *realargs[10];
int res;
int txtone;
int isdcs = 0;
res = parseargs(args, realargs, 1, ',');
if (res != 1) {
error("Incorrect number of arguments to 'tx' (should be <txtone>)\n");
return -1;
}
if ((*realargs[0] == 'D') || (*realargs[0] == 'd'))
{
realargs[0]++;
isdcs = 0x8000;
}
res = sscanf(realargs[0], "%d", &txtone);
if ((res == 1) && (txtone < 1))
res = -1;
if (res != 1) {
error("Invalid tx (tone) '%s', should be a number > 0.\n", realargs[0]);
return -1;
}
txtones[0] = txtone | isdcs;
return 0;
}
开发者ID:linuxhut,项目名称:linuxhut,代码行数:27,代码来源:dahdi_cfg.c
示例10: ext_tone
int ext_tone(char *keyword, char *args)
{
static char *realargs[10];
int res;
int val;
res = parseargs(args, realargs, 1, ',');
if (res != 1) {
error("Incorrect number of arguments to 'exttone' (should be <value>)\n");
return -1;
}
if ((*realargs[0] == 'y') || (*realargs[0] == 'Y')) val = 1;
else if ((*realargs[0] == 'n') || (*realargs[0] == 'N')) val = 0;
else if ((*realargs[0] == 'i') || (*realargs[0] == 'I')) val = 2;
else
{
res = sscanf(realargs[0], "%d", &val);
if ((res == 1) && (val < 0))
res = -1;
if (val > 2) res = -1;
if (res != 1) {
error("Invalid value '%s', should be a number > 0.\n", realargs[0]);
return -1;
}
}
exttone = val;
return 0;
}
开发者ID:linuxhut,项目名称:linuxhut,代码行数:27,代码来源:dahdi_cfg.c
示例11: ExecCommandline
/*
*******************************************************************************
*
* FUNCTION: ExecCommandline
*
* DESCRIPTION: This function is used to process an input string, split the
* input string into command and parameter strings, find a command
* structure in the command list array and execute the command.
*
* INPUT PARAMETERS: cmdListP is a pointer to the command list array.
* cmdStringP is a pointer to the input string.
*
* RETURNS: none.
*******************************************************************************
*/
void ExecCommandline (CommandListEntry_T * cmdListP, char * inputStringP)
{
CommandListEntry_T * cmdListEntryP;
int argc;
char *argv[16];
char *resid;
while (*inputStringP) {
memset(argv, 0, sizeof(argv));
parseargs(inputStringP, &argc, argv, &resid);
if (argc > 0)
{
if ((cmdListEntryP=findCmd(cmdListP, argv[0])) == NULL)
{
SerialPutString("Command is not found\r\n");
}
else
{
cmdListEntryP->func(argc, (const char **)argv);
}
}
inputStringP = resid;
}
}
开发者ID:mambrus,项目名称:bitfire,代码行数:40,代码来源:platform.c
示例12: main
int main (int ac, char **av)
{
int ncount, ecount, foundtour = 0, rval = 0;
int *mytour;
int *elist = (int *) NULL;
int *elen = (int *) NULL;
double bestlen, *mylen;
rval = parseargs (ac, av);
if (rval) return 1;
if (wantlen) {
mytour = &foundtour;
mylen = &bestlen;
} else {
mytour = (int *) NULL;
mylen = (double *) NULL;
}
rval = CCutil_getedgelist_n (&ncount, filelist[0], &ecount, &elist,
&elen, 0);
if (rval) {
fprintf (stderr, "CCutil_getedgelist_n failed\n"); goto CLEANUP;
}
CC_IFFREE (elist, int);
CC_IFFREE (elen, int);
rval = CCutil_edge_file_union (ncount, nfiles, filelist, &ecount, &elist,
&elen, mytour, mylen);
if (rval) {
fprintf (stderr, "CCutil_edge_file_union failed\n"); goto CLEANUP;
}
printf ("Merged Edge List: %d edges\n", ecount); fflush (stdout);
if (outfname) {
rval = CCutil_writeedges_int (ncount, outfname, ecount, elist,
elen, 0);
if (rval) {
fprintf (stderr, "CCutil_writeedges_int failed\n"); goto CLEANUP;
}
}
if (wantlen) {
if (foundtour == 1) {
printf ("Best Tour: %.0f\n", bestlen); fflush (stdout);
} else {
printf ("No tours\n"); fflush (stdout);
}
}
CLEANUP:
CC_IFFREE (elist, int);
CC_IFFREE (elen, int);
return rval;
}
开发者ID:MotaDan,项目名称:Parallel-Concorde,代码行数:59,代码来源:edgunion.c
示例13: main
int main(int argc, char *argv[])
{
LALFrStream *stream;
REAL8TimeSeries *series;
LIGOTimeGPS start;
XLALSetErrorHandler(XLALAbortErrorHandler);
parseargs(argc, argv);
/* get the data */
stream = XLALFrStreamCacheOpen(cache);
XLALGPSSetREAL8(&start, t0 - pad);
series = XLALFrStreamInputREAL8TimeSeries(stream, channel, &start, dt + 2.0 * pad, 0);
XLALFrStreamClose(stream);
/* manipulate the data */
if (srate > 0)
XLALResampleREAL8TimeSeries(series, 1.0 / srate);
if (minfreq > 0)
XLALHighPassREAL8TimeSeries(series, minfreq, 0.9, 8);
if (maxfreq > 0)
XLALLowPassREAL8TimeSeries(series, maxfreq, 0.9, 8);
if (pad > 0)
series = XLALResizeREAL8TimeSeries(series, pad / series->deltaT, dt / series->deltaT);
if (df > 0) { /* we are computing a spectrum */
REAL8FrequencySeries *spectrum;
REAL8FFTPlan *plan;
REAL8Window *window;
size_t seglen = 1.0 / (df * series->deltaT);
/* make sure that the time series length is commensurate with seglen */
if (((2 * series->data->length) % seglen) != 0) {
size_t newlen = ((2 * series->data->length) / seglen) * seglen;
series = XLALResizeREAL8TimeSeries(series, 0, newlen);
}
spectrum = XLALCreateREAL8FrequencySeries(series->name, &series->epoch, 0.0, df, &lalDimensionlessUnit, seglen/2 + 1);
plan = XLALCreateForwardREAL8FFTPlan(seglen, 0);
window = XLALCreateHannREAL8Window(seglen);
XLALREAL8AverageSpectrumWelch(spectrum, series, seglen, seglen/2, window, plan);
if (minfreq > 0 || maxfreq > 0) {
size_t first = minfreq / spectrum->deltaF;
size_t last = maxfreq > 0 ? maxfreq / spectrum->deltaF : spectrum->data->length;
spectrum = XLALResizeREAL8FrequencySeries(spectrum, first, last - first);
}
output_fs(outfile, spectrum);
XLALDestroyREAL8Window(window);
XLALDestroyREAL8FFTPlan(plan);
XLALDestroyREAL8FrequencySeries(spectrum);
} else { /* we are outputting a time series */
output_ts(outfile, series);
}
XLALDestroyREAL8TimeSeries(series);
return 0;
}
开发者ID:Solaro,项目名称:lalsuite,代码行数:58,代码来源:vis.c
示例14: main
int main(int argc, char **argv)
{
startup_checks();
parseargs(argc, argv);
connect_to_server();
gethandle();
while (1)
do_something();
}
开发者ID:martylee,项目名称:CSC209,代码行数:9,代码来源:client.c
示例15: main
int main(int argc, char *argv[])
{
char tstr[32]; // string to hold GPS time -- 31 characters is enough
const double H0 = 0.72 * LAL_H0FAC_SI; // Hubble's constant in seconds
const size_t length = 65536; // number of points in a segment
const size_t stride = length / 2; // number of points in a stride
size_t i, n;
REAL8FrequencySeries *OmegaGW = NULL;
REAL8TimeSeries **seg = NULL;
LIGOTimeGPS epoch;
gsl_rng *rng;
XLALSetErrorHandler(XLALAbortErrorHandler);
parseargs(argc, argv);
XLALGPSSetREAL8(&epoch, tstart);
gsl_rng_env_setup();
rng = gsl_rng_alloc(gsl_rng_default);
OmegaGW = XLALSimSGWBOmegaGWFlatSpectrum(Omega0, flow, srate/length, length/2 + 1);
n = duration * srate;
seg = LALCalloc(numDetectors, sizeof(*seg));
printf("# time (s)");
for (i = 0; i < numDetectors; ++i) {
char name[LALNameLength];
snprintf(name, sizeof(name), "%s:STRAIN", detectors[i].frDetector.prefix);
seg[i] = XLALCreateREAL8TimeSeries(name, &epoch, 0.0, 1.0/srate, &lalStrainUnit, length);
printf("\t%s (strain)", name);
}
printf("\n");
XLALSimSGWB(seg, detectors, numDetectors, 0, OmegaGW, H0, rng); // first time to initilize
while (1) { // infinite loop
size_t j;
for (j = 0; j < stride; ++j, --n) { // output first stride points
LIGOTimeGPS t = seg[0]->epoch;
if (n == 0) // check if we're done
goto end;
printf("%s", XLALGPSToStr(tstr, XLALGPSAdd(&t, j * seg[0]->deltaT)));
for (i = 0; i < numDetectors; ++i)
printf("\t%e", seg[i]->data->data[j]);
printf("\n");
}
XLALSimSGWB(seg, detectors, numDetectors, stride, OmegaGW, H0, rng); // make more data
}
end:
for (i = 0; i < numDetectors; ++i)
XLALDestroyREAL8TimeSeries(seg[i]);
XLALFree(seg);
XLALDestroyREAL8FrequencySeries(OmegaGW);
LALCheckMemoryLeaks();
return 0;
}
开发者ID:ahnitz,项目名称:lalsuite,代码行数:57,代码来源:sgwb.c
示例16: main
int main(int argc, char** argv){
struct timeval tv;
if(argc > 4 || parseargs(argc, argv) == 0)
return -1;
/* This starts the xuartctl daemon TODO - Should we start it */
/* printf("Starting xuartctl...");*/
/* fflush(stdout);*/
/* system("xuartctl -d -p 0 -o 8n1 -s 9600");*/
/* printf("done\n");*/
printf("Starting gps with device %s\n", gps_device);
uart_init( 0, stderr, gps_device);
original_tries = tries;
for(;!is_gps_ready(); tries--)
{
if(tries <= 0)
{
fprintf(stderr, "Number of tries limit of %u was reached. Returning error -1\n", original_tries);
return -1;
}
sleep(1);
}
printf("GPS is ready. Reading value and setting it in kernel.\n");
switch(getGPStimeUTC(&tv)){
case 1:
fprintf(stderr, "Unable to read time from GPS (Error 1)\n");
return -1;
case 2:
fprintf(stderr, "An error occured while waiting for a time reply (Error 2)\n");
return -1;
}
printf("GPS returned with UNIX seconds: %ld\n", tv.tv_sec);
// set miavita time
set_seconds((uint64_t) tv.tv_sec); /* Set's the seconds in the miavia counter in the kernel cat ts7500_kernel/ipc/miavita_syscall.c:sys_miavitasetseconds */
printf("Seconds set in the miavita kernel variable: %lu\n", get_mean_value());
printf("Now I'm going to set the current date to the OS\n");
printf("Time at before setting:\n");
print_time();
// set system time
time_t seconds_time = (time_t) tv.tv_sec;
stime(&seconds_time);
sleep(2);
printf("Time at after setting:\n");
print_time();
printf("Program finished without errors.\n");
return 0;
}
开发者ID:cnm,项目名称:mia_vita,代码行数:57,代码来源:init_counter.c
示例17: main
int main (int ac, char **av)
{
CC_SPORT *p = (CC_SPORT *) NULL;
CC_SFILE *f = (CC_SFILE *) NULL;
int rval = 0;
if (parseargs (ac, av))
return 0;
CCutil_signal_init ();
if (debug) {
printf ("Serving files for %s\n", probname); fflush (stdout);
}
p = CCutil_snet_listen (probport);
if (p == (CC_SPORT *) NULL) {
fprintf (stderr, "CCutil_snet_listen failed\n");
rval = 1;
goto CLEANUP;
}
for (;;) {
if (debug) {
printf ("Waiting for connection\n"); fflush (stdout);
}
f = CCutil_snet_receive (p);
if (f == (CC_SFILE *) NULL) {
fprintf (stderr, "CCutil_snet_receive failed\n");
continue;
}
if (debug) {
printf ("Received connection\n"); fflush (stdout);
}
rval = serve_file (f, probname, run_silently);
if (rval) {
fprintf (stderr, "serve_file failed\n");
if (CCutil_sclose (f)) {
fprintf (stderr, "CCutil_sclose failed\n");
}
continue;
}
if (debug) {
printf ("Closing connection\n"); fflush (stdout);
}
rval = CCutil_sclose (f);
if (rval) {
fprintf (stderr, "CCutil_sclose failed\n");
}
f = (CC_SFILE *) NULL;
}
CLEANUP:
if (f != (CC_SFILE *) NULL) CCutil_sclose (f);
if (p != (CC_SPORT *) NULL) CCutil_snet_unlisten (p);
return rval;
}
开发者ID:MotaDan,项目名称:Parallel-Concorde,代码行数:56,代码来源:probserv.c
示例18: main
//Begin ClientCode
int main(int argc, char ** argv)
{
#ifdef CSEC_VERIFY
assume_string("clientID");
assume_string("serverID");
assume_string("port_ascii");
// Assumption that the corresponding argv fields indeed contains the correct ids:
readenvL(argv[1], strlen(argv[1]), "clientID");
readenvL(argv[2], strlen(argv[2]), "serverID");
readenvL(argv[3], strlen(argv[3]), "port_ascii");
#endif
RPCstate clState;
clState.end = CLIENT;
if (parseargs(argc,argv,&clState))
{
#ifdef VERBOSE
fprintf(stdout, "Usage: client clientAddress serverAddress [port] request\n");
#endif
exit(-1);
}
#ifdef VERBOSE
printf("Client: Now connecting to ");
print_text_buffer(clState.other,clState.other_len);
printf(", port %d.\n", clState.port);
fflush(stdout);
#endif
// Getting arguments
if (socket_connect(&(clState.conn_fd),(char*) clState.other, clState.other_len, clState.port))
return -1;
clState.k_ab = get_shared_key(clState.self, clState.self_len, clState.other, clState.other_len, &(clState.k_ab_len));
clState.k = mk_session_key(&(clState.k_len));
clState.response = NULL;
#ifdef CSEC_VERIFY
event3("client_begin", clState.self, clState.self_len, clState.other, clState.other_len, clState.request, clState.request_len);
#endif
/* Send request */
if (send_request(&clState) < 0) return -1;
/* Receive response */
if (recv_response(&clState) < 0) return -1;
#ifdef CSEC_VERIFY
event4("client_accept", clState.self, clState.self_len, clState.other, clState.other_len,
clState.request, clState.request_len, clState.response, clState.response_len);
#endif
return 0;
}
开发者ID:tari3x,项目名称:csec-modex,代码行数:57,代码来源:client.c
示例19: main
int main(int argc, char *argv[])
{
int ret;
if (argc < 2)
usage(EXIT_FAILURE);
color_init(false);
ret = parseargs(argc, argv);
fclose(stdout);
return ret;
}
开发者ID:shekkbuilder,项目名称:pax-utils-1,代码行数:10,代码来源:scanmacho.c
示例20: memcpy
/**
* Parse command line options and return dynamically allocated structure
* to global parameters
* @param argc - copy of argc from main
* @param argv - copy of argv from main
* @return allocated structure with global parameters
*/
glob_pars *parse_args(int argc, char **argv){
void *ptr;
ptr = memcpy(&G, &Gdefault, sizeof(G)); assert(ptr);
// format of help: "Usage: progname [args]\n"
change_helpstring("Usage: %s [args]\n\n\tWhere args are:\n");
// parse arguments
parseargs(&argc, &argv, cmdlnopts);
if(help || argc > 0) showhelp(-1, cmdlnopts);
return &G;
}
开发者ID:eddyem,项目名称:BTA_utils,代码行数:17,代码来源:cmdlnopts.c
注:本文中的parseargs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论