本文整理汇总了C++中printusage函数的典型用法代码示例。如果您正苦于以下问题:C++ printusage函数的具体用法?C++ printusage怎么用?C++ printusage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printusage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: processcommandline
static void processcommandline(int argc, char **argv) {
int r;
while ((r = getopt(argc, argv, "hvc:")) != -1) {
switch (r) {
case 'v':
printversion();
break;
case 'h':
printusage();
exit(0);
break;
case 'c':
configfilename = optarg;
break;
default:
if (isprint(optopt))
fprintf(stderr, "unknown option '-%c'.\n", optopt);
else
fprintf(stderr, "unknown option character '-%x'.\n", optopt);
exit(1);
}
}
if (optind < argc) {
printusage();
exit(1);
}
}
开发者ID:nonoo,项目名称:nalarminterface,代码行数:29,代码来源:main.c
示例2: main
int main(int argc, char *argv[]) {
FILE *fp;
unsigned int blknum, i;
unsigned char block[BLOCKSIZE];
char c;
blknum = 0;
if (argc != 5) {
printusage(argc, argv);
exit(0);
}
while ((c = getopt(argc, argv, "n:f:h")) != -1) {
switch(c) {
case 'n':
blknum = atoi(optarg);
break;
case 'f':
fp = fopen(optarg, "r");
if (fp == NULL) {
printf("Could not open file: '%s'\n", optarg);
exit(1);
}
break;
case 'h':
printusage(argc, argv);
exit(0);
break;
}
}
if (fp == NULL) {
printf("Must specify filename!\n");
exit(1);
}
if (fseek(fp, BLOCKSIZE * blknum, SEEK_SET) < 0) {
printf("Error seeking to block no. %d!\n", blknum);
fclose(fp);
exit(1);
}
if (fread(&block, BLOCKSIZE, 1, fp) != 1) {
printf("Error reading block no. %d!\n", blknum);
fclose(fp);
exit(1);
}
/* Block was actually read; print it. */
for (i = 0; i < BLOCKSIZE; i++) {
if ((i % 16) == 0) printf("\n");
printf("%02x ", block[i]);
}
printf("\n");
fclose(fp);
return 0;
}
开发者ID:RagnarDanneskjold,项目名称:Stierlitz,代码行数:59,代码来源:getblk.c
示例3: main
int main(int argc, char **argv)
{
bool brief = false;
afSetErrorHandler(errorHandler);
if (argc == 1)
{
printusage();
return 0;
}
static struct option long_options[] =
{
{"short", 0, 0, 's'},
{"reporterror", 0, 0, 'r'},
{"help", 0, 0, 'h'},
{"version", 0, 0, 'v'},
{0, 0, 0, 0}
};
int result;
int option_index = 1;
while ((result = getopt_long(argc, argv, "srhv", long_options,
&option_index)) != -1)
{
switch (result)
{
case 's':
brief = true;
break;
case 'r':
reportError = true;
break;
case 'h':
printusage();
exit(EXIT_SUCCESS);
case 'v':
printversion();
exit(EXIT_SUCCESS);
}
}
int i = optind;
while (i < argc)
{
bool processed = brief ? printshortinfo(argv[i]) :
printfileinfo(argv[i]);
i++;
if (!brief && processed && i < argc)
putchar('\n');
}
return 0;
}
开发者ID:matthiasr,项目名称:audiofile,代码行数:55,代码来源:sfinfo.c
示例4: getargs
int getargs(int argc, char **argv, argoptions * opt) {
int i, rc, unknowncnt;
if (opt == NULL)
return -1;
initoptions(opt);
if (argc < 2) {
// printusage(argv); Ok to not have params - default model
#ifndef DEFAULT_MODELFILE
return -1;
#else
return 0;
#endif//DEFAULT_MODELFILE
}
i = 1;
unknowncnt = 0;
while (i < argc) {
if (argv[i][0] == '-' || argv[i][0] == '+') {
rc = getparm(argc, argv, i, opt);
if (rc != -1) {
i += rc;
}
else {
printusage(argv);
return -1;
}
}
else {
unknowncnt++;
if (unknowncnt > 1) {
fprintf(stderr, "Too many model file names found!\n");
printusage(argv);
return -1;
}
else {
strcpy(opt->filename, argv[i]);
opt->foundfilename = 1;
i++;
}
}
}
if (opt->foundfilename == -1) {
fprintf(stderr, "Missing model file name!\n");
printusage(argv);
return -1;
}
return 0;
}
开发者ID:Gorfaal,项目名称:CIS410Parallel,代码行数:53,代码来源:getargs.cpp
示例5: getoptions
/********************************************
* getoptions()
*
* Parses argument list for options
*
* Any arguments in argv that are not
* recognized here are assumed to be files.
* This function returns the number of
* the first non-option argument. It is up
* to xdd_readfile() to make sure they
* are actual filenames.
********************************************/
int getoptions(int argc, char **argv) {
int ierr, opt, argnum;
extern char *optarg;
ierr = 0;
argnum = 1; /* track number of args parsed */
/* set default options */
strcpy(outfilebase,".");
window_size = 1;
/* loop through options */
while ((opt = getopt(argc, argv, "t:ko:h")) != -1) {
switch (opt) {
case 't': /* moving average */
window_size = atoi(optarg);
argnum += 2;
if (window_size <= 0) {
fprintf(stderr,"\nwindow size must be more than 0.\n\n");
ierr++;
}
break;
case 'k': /* use src, dst kernel trace files */
kernel_trace = 1;
argnum += 1;
break;
case 'o': /* output file name */
strncpy(outfilebase,optarg,OUTFILENAME_LEN);
outfilebase[OUTFILENAME_LEN-1] = '\0';
argnum += 2;
if (strlen(outfilebase) == 0)
ierr++;
break;
case 'h': /* help */
default:
printusage(argv[0]);
break;
}
}
/* do we have two filenames and no parsing errors? */
if ( (argc-argnum < 1) || (ierr != 0) ) {
printusage(argv[0]);
}
/* return the number of the first non-option argument */
return argnum;
}
开发者ID:DaElf,项目名称:xdd,代码行数:60,代码来源:read_tsdumps.c
示例6: mainprogram
int mainprogram (int argc, char *argv[]) {
char *outwavhdrfilename,*outwavdatfilename;
int len;
int result=0;
if (parseArgs(argc,argv)!=0) {
printusage();
return 0;
}
len = strlen(wavtool_args.outputfilename)+4+1;
outwavhdrfilename = (char *)malloc(len*sizeof(char));
memset(outwavhdrfilename,0,len*sizeof(char));
outwavdatfilename = (char *)malloc(len*sizeof(char));
memset(outwavdatfilename,0,len*sizeof(char));
_snprintf(outwavhdrfilename,len,"%s.whd",wavtool_args.outputfilename);
_snprintf(outwavdatfilename,len,"%s.dat",wavtool_args.outputfilename);
if (!isFileExist(outwavhdrfilename)) {
wfh_init(outwavhdrfilename);
}
if (!isFileExist(outwavdatfilename)) {
wfd_init(outwavdatfilename);
}
len = wfd_append(outwavdatfilename,wavtool_args.inputfilename,wavtool_args.offset,wavtool_args.length,wavtool_args.ovr,wavtool_args.p,wavtool_args.v);
result = wfh_putlength(outwavhdrfilename,len);
return 0;
}
开发者ID:MISATOSUSUMI,项目名称:UtauBridger,代码行数:31,代码来源:wavtool-pl.c
示例7: main
//-----------------------------------------------------------------------------
// Purpose:
// Input : argc -
// argv[] -
// Output : int
//-----------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
SpewOutputFunc( SpewFunc );
Msg( "Valve Software - vcprojtomake.exe (%s)\n", __DATE__ );
Msg( "Modified for VS2010 Support by Killer Monkey\n" );
Msg( "<[email protected]>\n" );
CommandLine()->CreateCmdLine( argc, argv );
if ( CommandLine()->ParmCount() < 2)
{
printusage();
return 0;
}
CVCProjConvert proj;
if ( !proj.LoadProject( CommandLine()->GetParm( 1 )) )
{
Msg( "Failed to parse project\n" );
return -1;
}
OutputKeyValuesVersion(proj);
CMakefileCreator makefile;
makefile.CreateMakefiles( proj );
return 0;
}
开发者ID:Cameron-D,项目名称:DeathmatchClassicSource,代码行数:34,代码来源:vprojtomake.cpp
示例8: main
/*
* main() : Entry point
*/
int main(int argc, char *argv[]) {
if (argc < 2 || strcmp(argv[1], "-?") == 0) {
/* Print usage */
return printusage();
}
if (strcmp(argv[1], "-s") == 0) {
/* Hash string */
return hashstring(argv[2]);
}
if (strcmp(argv[1], "-t") == 0) {
/* Time trial */
return timetrial();
}
if (strcmp(argv[1], "-x") == 0) {
/* Test suite */
return testsuite();
}
/* Hash file */
return hashfile(argv[1]);
}
开发者ID:ryanlederman,项目名称:validus,代码行数:28,代码来源:main.c
示例9: help
/*
* help - tell about commands, or details of a particular command
*/
static void
help(
struct parse *pcmd,
FILE *fp
)
{
struct xcmd *xcp;
char *cmd;
const char *list[100];
size_t word, words;
size_t row, rows;
size_t col, cols;
size_t length;
if (pcmd->nargs == 0) {
words = 0;
for (xcp = builtins; xcp->keyword != 0; xcp++) {
if (*(xcp->keyword) != '?')
list[words++] = xcp->keyword;
}
for (xcp = opcmds; xcp->keyword != 0; xcp++)
list[words++] = xcp->keyword;
qsort((void *)list, (size_t)words, sizeof(list[0]),
helpsort);
col = 0;
for (word = 0; word < words; word++) {
length = strlen(list[word]);
col = max(col, length);
}
cols = SCREENWIDTH / ++col;
rows = (words + cols - 1) / cols;
fprintf(fp, "ntpdc commands:\n");
for (row = 0; row < rows; row++) {
for (word = row; word < words; word += rows)
fprintf(fp, "%-*.*s", col, col-1, list[word]);
fprintf(fp, "\n");
}
} else {
cmd = pcmd->argval[0].string;
words = findcmd(cmd, builtins, opcmds, &xcp);
if (words == 0) {
fprintf(stderr,
"Command `%s' is unknown\n", cmd);
return;
} else if (words >= 2) {
fprintf(stderr,
"Command `%s' is ambiguous\n", cmd);
return;
}
fprintf(fp, "function: %s\n", xcp->comment);
printusage(xcp, fp);
}
}
开发者ID:pexip,项目名称:os-ntp,代码行数:60,代码来源:ntpdc.c
示例10: CheckOptions
static void CheckOptions(int argc, char **argv) {
int n,m;
int i;
for(n=1;n<argc;n++) {
/* an option ? */
if (argv[n][0]=='-') {
/* is it "--" ? */
if (argv[n][1]=='-') {
/* --blabla options are not used */
if (argv[n][2]) {
printf("long option not recognized : %s\n",argv[n]);
grr(argv[0]);
} else return;
}
m=n;
/* -blabla, check every letter */
for (i=1;argv[n][i];i++) {
if (argv[n][i]=='d')
if (visiobases_dir) {
free(visiobases_dir);
visiobases_dir=NULL;
}
if (argv[n][i]=='h') {
printusage(argv[0]);
exit(0);
}
if (argv[n][i]=='s') {
if (++m==argc) grr(argv[0]);
socketport=argv[m];
}
if (argv[n][i]=='k') {
if (++m==argc) grr(argv[0]);
keyname=argv[m];
}
if (argv[n][i]=='o') {
if (++m==argc) grr(argv[0]);
Parse(argv[m]);
}
if (argv[n][i]=='b')
backup=1;
if (argv[n][i]=='n')
backup=0;
if (argv[n][i]=='f')
burstmode=VB_AUTOMATIC;
if (argv[n][i]=='i')
burstmode=VB_MANUAL;
if (strchr(OPTIONS,argv[n][i])==NULL) {
printf("option not recognized : -%c\n",argv[n][i]);
grr(argv[0]);
}
}
n=m;
}
}
}
开发者ID:brltty,项目名称:brltty,代码行数:56,代码来源:vstp_main.c
示例11: main
int main(int argc, char **argv)
{
int i;
QStringList args;
QPEApplication a(argc, argv);
QWidget w;
a.setMainWidget(&w);
QWidget *d = a.desktop();
int width=d->width();
int height=d->height();
for(i=0; i < argc; i++)
{
args += argv[i];
}
for(i=0; i < argc; i++)
{
if(args[i] == "-m")
{
return myMessageBox(width, height, &w, argc, args);
}
if(args[i] == "-f")
{
return fileviewer(&a, argc, args);
}
if(args[i] == "-i")
{
return input(width, height, &w, argc, args);
}
if(args[i] == "-h" || args[i] =="--help")
{
printusage();
return -1;
}
}
printusage();
return -1;
}
开发者ID:opieproject,项目名称:opie,代码行数:43,代码来源:opie-sh.cpp
示例12: printhelp
//
// printhelp: prints the help for the program
//
static void printhelp(char *progname)
{
printusage(progname);
fprintf(stderr,"TODO: help not well written\n");
fprintf(stderr,"press ESC to end the program (user must have context of the video window!).\n");
fprintf(stderr,"\n");
fprintf(stderr,"quick and dirty argument descriptions:\n");
fprintf(stderr," -h show help and exit\n");
fprintf(stderr," -p PATH load and save attributes files from/to PATH (should be a directory)\n");
}
开发者ID:umass-sensors,项目名称:iShadow,代码行数:13,代码来源:ml_rawfeatures_knearest.cpp
示例13: main
int
main(int argc, char **argv)
{
double factor, temp;
int i, j, doit, of, count, val, *col_list;
if ( BU_STR_EQUAL(argv[1], "-h") || BU_STR_EQUAL(argv[1], "-?") )
printusage();
if (argc < 4)
printusage();
sscanf(*(argv+1), "%lf", &factor);
sscanf(*(argv+2), "%d", &of);
col_list = (int *) bu_calloc(argc-2, sizeof(int), "int array");
for (i=3;i<argc;i++) {
sscanf(*(argv+i), "%d", col_list+(i-3));
}
count = 0;
while (!feof(stdin)) {
val = scanf("%lf", &temp);
if (val<1)
;
else {
doit = 0;
for (j=0;j<argc-3;j++) {
if (col_list[j]==count)
doit = 1;
}
if (doit)
printf("%.10g\t", temp*factor);
else
printf("%.10g\t", temp);
}
if (count == (of-1))
printf("\n");
count = (count+1)%of;
}
bu_free(col_list, "int array");
return 0;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:42,代码来源:chan_mult.c
示例14: printhelp
//
// printhelp: prints the help for the program
//
static void printhelp(char *progname)
{
printusage(progname);
fprintf(stderr,"TODO: help not well written\n");
fprintf(stderr,"press ESC to end the program (user must have context of the video window!).\n");
fprintf(stderr,"\n");
fprintf(stderr,"quick and dirty argument descriptions:\n");
fprintf(stderr," -a ASAP mode. just pump out frames as quickly as possible\n");
fprintf(stderr," -h show help and exit\n");
fprintf(stderr," -i PATH replay video located at PATH\n");
}
开发者ID:umass-sensors,项目名称:iShadow,代码行数:14,代码来源:glassesreplaystream.c
示例15: settiestr
void settiestr(char*s){
int i,j,c;
i= strlen(s);
if((i> 2*MAXLEN)||i%2==1)printusage(),exit(BAD_OPTIONS);
tiestrlen= i/2;
j= 0;
for(i= 0;i<tiestrlen;i++){
tiestr[i]= hexnum(s[j++])<<4;
tiestr[i]+= hexnum(s[j++]);
}
}
开发者ID:DawiX,项目名称:DawiX-dotfiles,代码行数:11,代码来源:vlna.c
示例16: main
int main(int argc, char *argv[])
{
if (argc >= 3) {
if ( 0 == strcmp("red",argv[1]) ) {
setreg(ledctl_red,0);
setreg(leddata_red,strcmp("off",argv[2])?1:0);
}
else {
setreg(ledctl_green,0);
setreg(leddata_green,strcmp("off",argv[2])?1:0);
}
} else {
printusage();
return -1;
}
return 0;
}
开发者ID:synel,项目名称:synergy2416-registers,代码行数:17,代码来源:ledcontroller.c
示例17: mygo
int mygo(int argc, char **argv, opts* op){
int c;
opterr = 0;
while ((c = getopt (argc, argv, "abdhi:n:o:t:")) != -1){
switch (c){
case 'a':
break;
case 'b':
break;
case 'd':
op->pw = 1;
break;
case 'h':
printusage();
exit(0);
break;
case 'i': //Infile needed:
sprintf(op->ifn,"%s",optarg);
case 't':
op->threshold = atoi(optarg);
break;
case 'w':
op->pw = 1;
break;
case '?':
fprintf(stderr,"INPUT ERROR:\n");
if (optopt == 'c')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
else if (isprint (optopt))
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
else
fprintf (stderr,"Unknown option character `\\x%x'.\n", optopt);
return 1;
default:
abort ();
}
}
// printf ("aflag = %d, bflag = %d, cvalue = %s\n",
// aflag, bflag, cvalue);
}
开发者ID:franticspider,项目名称:midiuino,代码行数:42,代码来源:moz_samp.c
示例18: main
int main(int argc, char* argv[])
{
short rotornumbers = 0123;
int rpositions[3] = {0};
char* input_filename;
FILE* fd;
/* Checks the cli arguments */
if (parseoptions(argc, argv, &input_filename, &rotornumbers, rpositions)
== EXIT_FAILURE) {
printusage(argv[0]);
return EXIT_FAILURE;
}
if ((fd = fopen(input_filename, "r")) == NULL) {
perror("fopen:");
return EXIT_FAILURE;
}
cryptstream(fd, rotornumbers, rpositions);
return EXIT_SUCCESS;
}
开发者ID:octarin,项目名称:enigma,代码行数:22,代码来源:main.c
示例19: main
int main(int argc, char **argv){
int err = 0;
char c;
uint32_t start_ip = 0, end_ip = 0;
int delay = 100;
struct option opts[] = {
{"start", 1, NULL, 's'},
{"end", 1, NULL, 'e'},
{"delay", 1, NULL, 'd'},
};
/**
* Get the options for the program
*/
while(((c = getopt_long(argc, argv, "s:S:e:E:d:D", opts, NULL)) != (char)-1) ){
switch(c){
case 's':
start_ip = ntohl((uint32_t)inet_addr(optarg));
break;
case 'e':
end_ip = ntohl((uint32_t)inet_addr(optarg));
break;
case 'd':
delay = atoi(optarg);
break;
default:
fprintf(stderr, "Unkown option %c\n", c);
printusage(argc, argv);
exit(1);
}
}
// set the interface to the last value
if(optind > 0 && optind < argc ){
strncpy(interface, argv[optind],IFNAMSIZ);
}else{
printusage(argc, argv);
return 1;
}
/**
* Check to see if running as root
*/
if(geteuid()) { // non root user
fprintf(stderr, "You must run this program as root! This is needed to open" \
" raw sockets and capture raw packets.\n");
return 1;
}
/**
* Done checking the inputs! Start the program logic
*/
// set the ip utility
if(sysarp_set(iplink_path,interface,0) < 0){
fprintf(stderr, "Error pausing the system ARP replies.\n");
err = 1; goto cleanup;
}
//debugging: printf("doing send_arp on %s with %u, %u, and %u\n", interface, start_ip, end_ip, delay);
printf("starting... ");
if( send_arp(interface, start_ip, end_ip, delay) < 0 ){
fprintf(stderr, "Error sending ARPs on the interface.\n");
err = 1; goto cleanup;
}
printf("done!\n");
cleanup:
if(sysarp_set(iplink_path,interface,1) < 0){
fprintf(stderr, "Could not resume the system ARP replies\n");
}
return err;
}
开发者ID:freddierice,项目名称:ArpDiscovery,代码行数:75,代码来源:main.c
示例20: main
int main(int argc, char **argv) {
int c;
const char *extension = ".txt";
bool verbose = false;
uint64_t data[13];
initializeMemUsageCounter();
while ((c = getopt(argc, argv, "ve:h")) != -1) switch (c) {
case 'e':
extension = optarg;
break;
case 'v':
verbose = true;
break;
case 'h':
printusage(argv[0]);
return 0;
default:
abort();
}
if (optind >= argc) {
printusage(argv[0]);
return -1;
}
char *dirname = argv[optind];
size_t count;
size_t *howmany = NULL;
uint32_t **numbers =
read_all_integer_files(dirname, extension, &howmany, &count);
if (numbers == NULL) {
printf(
"I could not find or load any data file with extension %s in "
"directory %s.\n",
extension, dirname);
return -1;
}
uint32_t maxvalue = 0;
for (size_t i = 0; i < count; i++) {
if( howmany[i] > 0 ) {
if(maxvalue < numbers[i][howmany[i]-1]) {
maxvalue = numbers[i][howmany[i]-1];
}
}
}
uint64_t totalcard = 0;
for (size_t i = 0; i < count; i++) {
totalcard += howmany[i];
}
uint64_t successivecard = 0;
for (size_t i = 1; i < count; i++) {
successivecard += howmany[i-1] + howmany[i];
}
uint64_t cycles_start = 0, cycles_final = 0;
RDTSC_START(cycles_start);
std::vector<vector> bitmaps = create_all_bitmaps(howmany, numbers, count);
RDTSC_FINAL(cycles_final);
if (bitmaps.empty()) return -1;
if(verbose) printf("Loaded %d bitmaps from directory %s \n", (int)count, dirname);
uint64_t totalsize = getMemUsageInBytes();
data[0] = totalsize;
if(verbose) printf("Total size in bytes = %" PRIu64 " \n", totalsize);
uint64_t successive_and = 0;
uint64_t successive_or = 0;
uint64_t total_or = 0;
uint64_t total_count = 0;
uint64_t successive_andnot = 0;
uint64_t successive_xor = 0;
RDTSC_START(cycles_start);
for (int i = 0; i < (int)count - 1; ++i) {
vector v;
std::set_intersection(bitmaps[i].begin(), bitmaps[i].end(),bitmaps[i+1].begin(), bitmaps[i+1].end(),std::back_inserter(v));
successive_and += v.size();
}
RDTSC_FINAL(cycles_final);
data[1] = cycles_final - cycles_start;
if(verbose) printf("Successive intersections on %zu bitmaps took %" PRIu64 " cycles\n", count,
cycles_final - cycles_start);
RDTSC_START(cycles_start);
for (int i = 0; i < (int)count - 1; ++i) {
vector v;
std::set_union(bitmaps[i].begin(), bitmaps[i].end(),bitmaps[i+1].begin(), bitmaps[i+1].end(),std::back_inserter(v));
successive_or += v.size();
}
RDTSC_FINAL(cycles_final);
data[2] = cycles_final - cycles_start;
if(verbose) printf("Successive unions on %zu bitmaps took %" PRIu64 " cycles\n", count,
cycles_final - cycles_start);
RDTSC_START(cycles_start);
if(count>1) {
vector v;
std::set_union(bitmaps[0].begin(), bitmaps[0].end(),bitmaps[1].begin(), bitmaps[1].end(),std::back_inserter(v));
for (int i = 2; i < (int)count ; ++i) {
//.........这里部分代码省略.........
开发者ID:RoaringBitmap,项目名称:CBitmapCompetition,代码行数:101,代码来源:stl_vector_benchmarks.cpp
注:本文中的printusage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论