当前位置: 首页>>代码示例>>C++>>正文


C++ printusage函数代码示例

本文整理汇总了C++中printusage函数的典型用法代码示例。如果您正苦于以下问题:C++ printusage函数的具体用法?C++ printusage怎么用?C++ printusage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了printusage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的printusage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。