• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PrintUsage函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了PrintUsage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    pid_t pid = getpid();		// get process id
    int i, cycle, rc;
    long clktck = sysconf(_SC_CLK_TCK);	// [note] obtain the number of clock ticks per second.(man 2 times)
    struct tms t;	// [note] man 2 times
    clock_t starttick, stoptick;	// [note] clock_t - CPU usage counts
    sigset_t mask;
    FILE * output = DEFAULT_OP;
 
    colour = colours[pid % N_COLOUR];	// [hwx] randomly select colour for this process
   
    if (argc > 2 || (argc == 2 && !isdigit((int)argv[1][0])))
        PrintUsage(argv[0]);  
   
    fprintf(output,"%s%7d; START" BLACK NORMAL "\n", colour, (int) pid);
    fflush(output);  
        
    signal (SIGINT, SignalHandler);   // hook up signal handler
    signal (SIGQUIT, SignalHandler);
    signal (SIGHUP, SignalHandler);   
    signal (SIGTERM, SignalHandler);
    signal (SIGABRT, SignalHandler);
//  signal (SIGCONT, SignalHandler);	// do this intrinsically after return from SIGTSTP
										// due to Darwin/BSD inconsistent SIGCONT behaviour
    signal (SIGTSTP, SignalHandler);
                                           
    rc = setpriority(PRIO_PROCESS, 0, 20);	// [note] be nice, lower priority by 20
    										// linux is [-20, 19]
    cycle = argc < 2 ? DEFAULT_TIME : atoi(argv[1]);	// get tick count
    if (cycle <= 0) cycle = 1;
 
    for (i = 0; i < cycle;) {	// tick
 
        if (signal_SIGCONT) {
            signal_SIGCONT = FALSE;
            fprintf(output,"%s%7d; SIGCONT" BLACK NORMAL "\n", colour, (int) pid);
            fflush(output);
        }
           
        starttick = times (&t);		// use timer to ascertain whether 'tick' should be reported
        rc = sleep(1);
        stoptick = times (&t);
        
        if (rc == 0 || (stoptick-starttick) > clktck/2)	// [hwx] more than 0.5 second?
            fprintf(output,"%s%7d; tick %d" BLACK NORMAL "\n", colour, (int) pid, ++i);
               
        if (signal_SIGINT) {
            fprintf(output,"%s%7d; SIGINT" BLACK NORMAL "\n", colour, (int) pid);
            exit(0);
        }
        if (signal_SIGQUIT) {
            fprintf(output,"%s%7d; SIGQUIT" BLACK NORMAL "\n", colour, (int) pid);
            exit(0);
        }
        if (signal_SIGHUP) {
            fprintf(output,"%s%7d; SIGHUP" BLACK NORMAL "\n", colour, (int) pid);
            exit(0);
        }
        /* [note] more about how to handle SIGTSTP, see *TLPI* and *APUE* */
        if (signal_SIGTSTP) {
            signal_SIGTSTP = FALSE;
            fprintf(output,"%s%7d; SIGTSTP" BLACK NORMAL "\n", colour, (int) pid);
            fflush(output);
            sigemptyset (&mask);			// unblock SIGSTP if necessary (BSD/OS X)
            sigaddset (&mask, SIGTSTP);
            sigprocmask (SIG_UNBLOCK, &mask, NULL);
            signal(SIGTSTP, SIG_DFL);		// reset trap to default
            raise (SIGTSTP);				// now suspend ourselves
            								// kill(getpid(), sig);
            signal(SIGTSTP, SignalHandler);	// reset trap on return from suspension
            signal_SIGCONT = TRUE;			// set flag here rather than trap signal
        }
        if (signal_SIGABRT) {
            fprintf(output,"%s%7d; SIGABRT" BLACK NORMAL "\n", colour, (int) pid);
            fflush(output);
            signal (SIGABRT, SIG_DFL);
            raise (SIGABRT);
        }
        if (signal_SIGTERM) {
            fprintf(output,"%s%7d; SIGTERM" BLACK NORMAL "\n", colour, (int) pid);
            exit(0);
        }               
        fflush(output);
    }
    exit(0);
}
开发者ID:FrancisHe,项目名称:scheduler,代码行数:87,代码来源:sigtrap.c


示例2: main

int main(int argc, char* argv[])
{
    int opt;

    while ((opt = getopt(argc, argv, "t:c:")) != -1)
    {
        switch (opt)
        {
            case 't':
                TEST = atoi(optarg);
                break;
            case 'c':
                CONNECTIVITY = atoi(optarg);
                break;
            default:
                PrintUsage();
                return -1;
        }
    }
    if ((TEST <= TEST_INVALID || TEST >= MAX_TESTS) ||
        (CONNECTIVITY < CT_ADAPTER_DEFAULT || CONNECTIVITY >= MAX_CT))
    {
        PrintUsage();
        return -1;
    }

    /* Initialize OCStack*/
    if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, "OCStack init error");
        return 0;
    }

    if(CONNECTIVITY == CT_ADAPTER_DEFAULT || CONNECTIVITY == CT_IP)
    {
        OC_CONNTYPE = CT_ADAPTER_IP;
    }
    else
    {
        OC_LOG(INFO, TAG, "Default Connectivity type selected...");
        OC_CONNTYPE = CT_ADAPTER_IP;
    }

    InitDiscovery();

    // Break from loop with Ctrl+C
    OC_LOG(INFO, TAG, "Entering occlient main loop...");
    signal(SIGINT, handleSigInt);
    while (!gQuitFlag)
    {

        if (OCProcess() != OC_STACK_OK)
        {
            OC_LOG(ERROR, TAG, "OCStack process error");
            return 0;
        }

        sleep(2);
    } OC_LOG(INFO, TAG, "Exiting occlient main loop...");

    if (OCStop() != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, "OCStack stop error");
    }

    return 0;
}
开发者ID:darcyg,项目名称:iotivity-1,代码行数:67,代码来源:occlientcoll.cpp


示例3: main

int main(int argc, char * argv[])
{
    kern_return_t       err;
    bool                verbose;
    int                 ch;
    int                 argIndex;

    // Set gProgramName to the last path component of argv[0]

    gProgramName = strrchr(argv[0], '/');
    if (gProgramName == NULL) {
        gProgramName = argv[0];
    } else {
        gProgramName += 1;
    }

    // Parse our options.

    verbose = false;
    do {
        ch = getopt(argc, argv, "w");
        if (ch != -1) {
            switch (ch) {
            case 'w':
                verbose = true;
                break;
            case '?':
            default:
                PrintUsage();
                exit(EXIT_FAILURE);
                break;
            }
        }
    } while (ch != -1);

    // Handle the remaining arguments.  If none, we work against ourselves.
    // Otherwise each string is treated as a process name, and we look that
    // up using FindProcessByName.

    if (argv[optind] == NULL) {
        err = PrintProcessPortSpace(getpid(), verbose);
    } else {
        for (argIndex = optind; argIndex < argc; argIndex++) {
            pid_t   pid;

            if (argIndex > optind) {
                fprintf(stdout, "\n");
            }
            if (argv[argIndex][0] == 0) {
                err = EINVAL;
            } else {
                err = FindProcessByName(argv[argIndex], &pid);
            }
            if (err == 0) {
                fprintf(stdout, "Mach ports for '%s' (%lld):\n", argv[argIndex], (long long) pid);
                fprintf(stdout, "\n");

                err = PrintProcessPortSpace(pid, verbose);
            }

            if (err != 0) {
                break;
            }
        }
    }

    if (err != 0) {
        fprintf(stderr, "%s: Failed with error %d.\n", gProgramName, err);
    }
    return (err == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
开发者ID:proger,项目名称:darwinkit,代码行数:71,代码来源:machportdump.c


示例4: ParseCommandLineArguments

/**
 * @brief Parses the application's command-line arguments
 *
 * @param[in] argc          The number of input arguments
 * @param[in] argv          The input arguments
 * @param[in] rank          The MPI rank of the calling process
 * @param[in] size          The total number of MPI processes available
 * @param[out] domSize      The parsed domain size (2D)
 * @param[out] topSize	    The parsed topology size (2D)
 * @param[out] useFastSwap  The parsed flag for fast block swap
 * @return		    The parsing status (STATUS_OK indicates a successful parse)
 */
int ParseCommandLineArguments(int argc, char ** argv, int rank, int size, int2 * domSize, int2 * topSize, int * useFastSwap)
{
	int canPrint = (rank == MPI_MASTER_RANK);
	int argIdx;

	// If help is requested, all other arguments will be ignored
	if ((FindAndClearArgument("-h", argc, argv) != -1) || (FindAndClearArgument("--help", argc, argv) != -1))
	{
		if (canPrint)
		{
			PrintUsage(argv[0]);
		}

		// This simply prevents the application from continuing 
		return STATUS_ERR;
	}

	// Check if fast swapping was requested
	* useFastSwap = (FindAndClearArgument("-fs", argc, argv) != -1);

	// Topology information must always be present
	argIdx = FindAndClearArgument("-t", argc, argv);
	if (argIdx == -1)
	{
		OneErrPrintf(canPrint, "Error: Could not find the topology information.\n");
		return STATUS_ERR;
	}
	else
	{
		topSize->x = ExtractNumber(argIdx + 1, argc, argv);
		topSize->y = ExtractNumber(argIdx + 2, argc, argv);

		// At least the first topology dimension must be specified
		if (topSize->x <= 0)
		{
			OneErrPrintf(canPrint, "Error: The topology size is invalid (first value: %d)\n", topSize->x);
			return STATUS_ERR;
		}

		// If the second topology dimension is missing, it will default to 1
		if (topSize->y <= 0)
		{
			topSize->y = 1;
		}
	}

	// The domain size information is optional
	argIdx = FindAndClearArgument("-d", argc, argv);
	if (argIdx == -1)
	{
		domSize->x = domSize->y = DEFAULT_DOMAIN_SIZE;
	}
	else
	{
		domSize->x = ExtractNumber(argIdx + 1, argc, argv);
		domSize->y = ExtractNumber(argIdx + 2, argc, argv);

		// At least the first domain dimension must be specified
		if (domSize->x < MIN_DOM_SIZE)
		{
			OneErrPrintf(canPrint, "Error: The local domain size must be at least %d (currently: %d)\n", MIN_DOM_SIZE, domSize->x);
			return STATUS_ERR;
		}
		
		// If the second domain dimension is missing, it will default to the first dimension's value
		if (domSize->y <= 0)
		{
			domSize->y = domSize->x;
		}
	}

	// At the end, there should be no other arguments that haven't been parsed
	for (int i = 1; i < argc; ++i)
	{
		if (strlen(argv[i]) > 0)
		{
			OneErrPrintf(canPrint, "Error: Unknown argument (\"%s\")\n", argv[i]);
			return STATUS_ERR;
		}
	}

	// If we reach this point, all arguments were parsed successfully
	if (canPrint)
	{
		printf("Topology size: %d x %d\n", topSize->x, topSize->y);
		printf("Local domain size (current node): %d x %d\n", domSize->x, domSize->y);
		printf("Global domain size (all nodes): %d x %d\n", topSize->x * domSize->x, topSize->y * domSize->y);
	}
//.........这里部分代码省略.........
开发者ID:Haider-BA,项目名称:Matlab2CPP,代码行数:101,代码来源:Input.c


示例5: ProcessCmdLine

static void ProcessCmdLine(struct JoystickData *params, LPSTR lpCmdLine)
{
    int i, j, buffer_index;
    /* Options are { 'poll', 'max-range', 'min-range', 'joystick chosen', 'verbose', help' } */
    char options[] = { 'p', 'a', 'i', 'j', 'v', 'h' };
    char buffer[32];
    char command;

    for (i = 0; lpCmdLine[i] != '\0'; i++) {
        if (lpCmdLine[i] == '/' || lpCmdLine[i] == '-') {
            /* Find valid command */
            BOOL valid = FALSE;
            command = lpCmdLine[++i];
            for (j = 0; j < NUMELEMS(options) && !valid; j++)
                if (options[j] == command)
                    valid = TRUE;

            if (!valid)
                goto invalid;

            /* Skip extra spaces */
            while (lpCmdLine[++i] == ' ');

            /* If the next word is a parameter, copy it.
             * Parameters dont start with - or /, that's for commands.
             * The isdigit call is to test for negative numbers (-1 for example)
             * and to not confuse them with commands */
            buffer_index = 0;
            if ((lpCmdLine[i] != '-' || isdigit(lpCmdLine[i + 1]))
                    && lpCmdLine[i] != '/') {
                /* Copy the word and don't let it overflow */
                while (lpCmdLine[i] != ' ' && lpCmdLine[i] != '\0'
                        && buffer_index < sizeof(buffer)) {
                    buffer[buffer_index] = lpCmdLine[i];
                    buffer_index++;
                    i++;
                }
            }
            buffer[buffer_index] = '\0';

            /* Process command and extract parameter */
            switch (command) {
            case 'p':
                if (strlen(buffer) == 0)
                    goto invalid;
                params->poll_time = atoi(buffer);
                break;

            case 'a':
                if (strlen(buffer) == 0)
                    goto invalid;
                params->axes_max = atoi(buffer);
                break;

            case 'i':
                if (strlen(buffer) == 0)
                    goto invalid;
                params->axes_min = atoi(buffer);
                break;

            case 'j':
                if (strlen(buffer) == 0)
                    goto invalid;
                params->chosen_joystick = atoi(buffer);
                break;

            case 'v':
                gVerbose = TRUE;

            case 'h':
                PrintUsage();
                exit(0);
                break;
            }
        }
    }

    return;

invalid:
    printf("Invalid parameters or command line option '%c'\n", command);
    printf("Try using -h for help with commands and syntax\n");
    exit(1);
}
开发者ID:palmer-dabbelt,项目名称:wine-joysticks,代码行数:84,代码来源:main.c


示例6: main

int main(
    int argc,
    char *argv[])
{
    char    **myargv;
    char     *aLine;
    char     *firstdir = "";

#ifdef MUST_DISABLE_SIGFPE
    signal(SIGFPE, SIG_IGN);
#endif
#ifdef MUST_DISABLE_FPMASK
    fpsetmask(0);
#endif

    /* initialize locale settings
       according to localeconv(3) */
    setlocale(LC_ALL, "");

#if defined(HAVE_LIBINTL_H) && defined(BUILD_LIBINTL)
    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
    textdomain(GETTEXT_PACKAGE);
#endif
    if (argc == 1) {
        PrintUsage("");
        return 0;
    }

    if (((argc == 2) || (argc == 3)) && !strcmp("-", argv[1])) {
#if HAVE_GETRUSAGE
        struct rusage myusage;
        struct timeval starttime;
        struct timeval currenttime;

        gettimeofday(&starttime, NULL);
#endif
        RemoteMode = 1;
        if ((argc == 3) && strcmp("", argv[2])) {

            if (
#ifdef HAVE_GETUID
                getuid()
#else
                1
#endif
                == 0) {

#ifdef HAVE_CHROOT
                if (chroot(argv[2]) != 0) {
                    fprintf(stderr, "ERROR: chroot %s: %s\n", argv[2],rrd_strerror(errno));
                    exit(errno);
                }
                ChangeRoot = 1;
                firstdir = "/";
#else
                fprintf(stderr,
                        "ERROR: change root is not supported by your OS "
                        "or at least by this copy of rrdtool\n");
                exit(1);
#endif
            } else {
                firstdir = argv[2];
            }
        }
        if (strcmp(firstdir, "")) {
            if (chdir(firstdir) != 0) {
                fprintf(stderr, "ERROR: chdir %s %s\n", firstdir,rrd_strerror(errno));
                exit(errno);
            }
        }

        while (fgetslong(&aLine, stdin)) {
            char *aLineOrig = aLine;
            if ((argc = CountArgs(aLine)) == 0) {
                free(aLine);
                printf("ERROR: not enough arguments\n");
                continue;
            }
            if ((myargv = (char **) malloc((argc + 1) *
                                           sizeof(char *))) == NULL) {
                perror("malloc");
                exit(1);
            }
            if ((argc = CreateArgs(argv[0], aLine, myargv)) < 0) {
                printf("ERROR: creating arguments\n");
            } else {
                if ( HandleInputLine(argc, myargv, stdout) == 0 ) {
#if HAVE_GETRUSAGE
                    getrusage(RUSAGE_SELF, &myusage);
                    gettimeofday(&currenttime, NULL);
                    printf("OK u:%1.2f s:%1.2f r:%1.2f\n",
                           (double) myusage.ru_utime.tv_sec +
                           (double) myusage.ru_utime.tv_usec / 1000000.0,
                           (double) myusage.ru_stime.tv_sec +
                           (double) myusage.ru_stime.tv_usec / 1000000.0,
                           (double) (currenttime.tv_sec - starttime.tv_sec)
                           + (double) (currenttime.tv_usec -
                                       starttime.tv_usec)
                           / 1000000.0);
#else
//.........这里部分代码省略.........
开发者ID:rightscale,项目名称:rrdtool,代码行数:101,代码来源:rrd_tool.c


示例7: Tk_ParseArgv


//.........这里部分代码省略.........
	    *((int *) infoPtr->dst) = dstIndex;
	    goto argsDone;
	case TK_ARGV_FLOAT:
	    if (argc == 0) {
		goto missingArg;
	    }
	    *((double *) infoPtr->dst) = strtod(argv[srcIndex], &endPtr);
	    if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
			"expected %s argument for \"%s\" but got \"%s\"",
			"floating-point", infoPtr->key, argv[srcIndex]));
		Tcl_SetErrorCode(interp, "TK", "ARG", "FLOAT", curArg, NULL);
		return TCL_ERROR;
	    }
	    srcIndex++;
	    argc--;
	    break;
	case TK_ARGV_FUNC: {
	    typedef int (ArgvFunc)(char *, const char *, const char *);
	    ArgvFunc *handlerProc = (ArgvFunc *) infoPtr->src;

	    if (handlerProc(infoPtr->dst, infoPtr->key, argv[srcIndex])) {
		srcIndex++;
		argc--;
	    }
	    break;
	}
	case TK_ARGV_GENFUNC: {
	    typedef int (ArgvGenFunc)(char *, Tcl_Interp *, const char *, int,
		    const char **);
	    ArgvGenFunc *handlerProc = (ArgvGenFunc *) infoPtr->src;

	    argc = handlerProc(infoPtr->dst, interp, infoPtr->key, argc,
		    argv+srcIndex);
	    if (argc < 0) {
		return TCL_ERROR;
	    }
	    break;
	}
	case TK_ARGV_HELP:
	    PrintUsage(interp, argTable, flags);
	    Tcl_SetErrorCode(interp, "TK", "ARG", "HELP", NULL);
	    return TCL_ERROR;
	case TK_ARGV_CONST_OPTION:
	    Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src,
		    TK_INTERACTIVE_PRIO);
	    break;
	case TK_ARGV_OPTION_VALUE:
	    if (argc < 1) {
		goto missingArg;
	    }
	    Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex],
		    TK_INTERACTIVE_PRIO);
	    srcIndex++;
	    argc--;
	    break;
	case TK_ARGV_OPTION_NAME_VALUE:
	    if (argc < 2) {
		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
			"\"%s\" option requires two following arguments",
			curArg));
		Tcl_SetErrorCode(interp, "TK", "ARG", "NAME_VALUE", curArg,
			NULL);
		return TCL_ERROR;
	    }
	    Tk_AddOption(tkwin, argv[srcIndex], argv[srcIndex+1],
		    TK_INTERACTIVE_PRIO);
	    srcIndex += 2;
	    argc -= 2;
	    break;
	default:
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
		    "bad argument type %d in Tk_ArgvInfo", infoPtr->type));
	    Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL);
	    return TCL_ERROR;
	}
    }

    /*
     * If we broke out of the loop because of an OPT_REST argument, copy the
     * remaining arguments down.
     */

  argsDone:
    while (argc) {
	argv[dstIndex] = argv[srcIndex];
	srcIndex++;
	dstIndex++;
	argc--;
    }
    argv[dstIndex] = NULL;
    *argcPtr = dstIndex;
    return TCL_OK;

  missingArg:
    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
	    "\"%s\" option requires an additional argument", curArg));
    Tcl_SetErrorCode(interp, "TK", "ARG", "MISSING", curArg, NULL);
    return TCL_ERROR;
}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:101,代码来源:tkArgv.c


示例8: main

int main ( int argc, char** argv ) {

  MRI* mri = NULL;
  int zX = 256;
  int zY = 256;
  int zZ = 256;
  int err = NO_ERROR;
  int nX = 0;
  int nY = 0;
  int nZ = 0;
  float sizeX = 1.0;
  float sizeY = 1.0;
  float sizeZ = 1.0;
  int setMethod = SET_METHOD_XYZ;
  int setValue = 0;
  char fnVol[256] = "new_volume.mgz";
  int i;
  char* arg = NULL;

  for ( i = 1; i < argc; i++ ) {

    arg = argv[i];

    if ( argv[i] && *argv[i] != '-' ) {
      printf( "ERROR: Unrecognized argument %s\n", argv[i] );
      PrintUsage( NULL );
      exit( 1 );
    }

    while ( arg[0] == '-' )
      arg = arg+1;

    if ( strlen(arg) <= 0 )
      continue;

    if ( strcmp(arg,"h") == 0 ||
         strcmp(arg,"help") == 0 ) {
      PrintUsage( NULL );
      exit( 0 );
    }

    if ( strcmp(arg,"f") == 0 ||
         strcmp(arg,"filename") == 0 ) {
      if ( i+1 >= argc ) {
        PrintUsage( "No argument to filename option." );
        exit( 1 );
      }
      strcpy( fnVol, argv[i+1] );
      i++;
    }

    if ( strcmp(arg,"x") == 0 ||
         strcmp(arg,"width") == 0 ) {
      if ( i+1 >= argc ) {
        PrintUsage( "No argument to width option." );
        exit( 1 );
      }
      zX = atoi(argv[i+1]);
      i++;
    }
    if ( strcmp(arg,"y") == 0 ||
         strcmp(arg,"height") == 0 ) {
      if ( i+1 >= argc ) {
        PrintUsage( "No argument to height option." );
        exit( 1 );
      }
      zY = atoi(argv[i+1]);
      i++;
    }
    if ( strcmp(arg,"z") == 0 ||
         strcmp(arg,"depth") == 0 ) {
      if ( i+1 >= argc ) {
        PrintUsage( "No argument to depth option." );
        exit( 1 );
      }
      zZ = atoi(argv[i+1]);
      i ++;
    }

    if ( strcmp(arg,"sizex") == 0 ) {
      if ( i+1 >= argc ) {
        PrintUsage( "No argument to sizex option." );
        exit( 1 );
      }
      sizeX = atof(argv[i+1]);
      i++;
    }
    if ( strcmp(arg,"sizey") == 0 ) {
      if ( i+1 >= argc ) {
        PrintUsage( "No argument to sizey option." );
        exit( 1 );
      }
      sizeY = atof(argv[i+1]);
      i++;
    }
    if ( strcmp(arg,"sizez") == 0 ) {
      if ( i+1 >= argc ) {
        PrintUsage( "No argument to sizez optoin." );
        exit( 1 );
      }
//.........这里部分代码省略.........
开发者ID:ewong718,项目名称:freesurfer,代码行数:101,代码来源:main.c


示例9: main

int main(int argc, char *argv[]) 
{
	FILE *fp;
	char *fastaFileName=NULL;
	int minUnitLength=-1, maxUnitLength=-1;
	int minLength=-1;
	char unit[MAX_UNIT_LENGTH+1]="\0";
	RGBinary rg;
	int c;

	while((c = getopt(argc, argv, "f:m:r:M:h")) >= 0) {
		switch(c) {
			case 'f': fastaFileName=strdup(optarg); break;
			case 'h': return PrintUsage();
			case 'm': minUnitLength=atoi(optarg); break; 
			case 'M': maxUnitLength=atoi(optarg); break; 
			case 'r': minLength=atoi(optarg); break;
			default: fprintf(stderr, "Unrecognized option: -%c\n", c); return 1;
		}
	}
	
	if(1 == argc || argc != optind) {
		return PrintUsage();
	}

	if(NULL == fastaFileName) {
		PrintError(Name, "fastaFileName", "Command line option", Exit, InputArguments);
	}
	if(minUnitLength <= 0) {
		PrintError(Name, "minUnitLength", "Command line option", Exit, InputArguments);
	}
	if(maxUnitLength <= 0) {
		PrintError(Name, "maxUnitLength", "Command line option", Exit, InputArguments);
	}
	if(minLength <= 0) {
		PrintError(Name, "minLength", "Command line option", Exit, InputArguments);
	}

	assert(minUnitLength <= maxUnitLength);
	assert(maxUnitLength <= MAX_UNIT_LENGTH);

	if(!(fp = fdopen(fileno(stdout), "w"))) {
		PrintError(Name, "stdout", "Could not open stdout for writing", Exit, OpenFileError);
	}

	/* Read in the rg binary file */
	RGBinaryReadBinary(&rg, NTSpace, fastaFileName);

	fprintf(stderr, "Currently on:\n%2d %9d", -1, -1);
	/* For each contig */
	int curContig, curContigIndex;
	for(curContig=1, curContigIndex=0;
			curContig <= rg.numContigs && curContigIndex < rg.numContigs;
			curContig++, curContigIndex++) {
		/* For each starting position */
		int curPos;
		int prevBestUnitLength=-1;
		int prevBestStart=-1;
		int prevBestLength=-1;
		int prevBestEnd=-1;
		for(curPos=1;
				curPos <= rg.contigs[curContigIndex].sequenceLength;
				curPos++) {
			if(curPos%BREPEAT_ROTATE_NUM==0) {
				fprintf(stderr, "\r%2d %9d",
						curContig,
						curPos);
			}

			if(ToLower(RGBinaryGetBase(&rg, curContig, curPos)) != 'n') {

				/* For each unit length */
				int bestEnd=-1;
				char bestUnit[MAX_UNIT_LENGTH+1]="\0";
				int bestUnitLength=-1;
				int curUnitLength;
				for(curUnitLength=minUnitLength;curUnitLength<=maxUnitLength;curUnitLength++) { /* For each unit length */
					/* Check bounds */
					if(curPos + curUnitLength - 1 <= rg.contigs[curContigIndex].sequenceLength) {
						/* Get the current unit */
						int i;
						for(i=0;i<curUnitLength;i++) {
							unit[i] = ToLower(RGBinaryGetBase(&rg,
										curContig,
										curPos+i));
						}
						unit[curUnitLength]='\0';
						int end = curPos+curUnitLength-1;

						/* extend the unit */
						int cont=1;
						int curStart;
						for(curStart=curPos + curUnitLength;cont==1 && curStart <= rg.contigs[curContigIndex].sequenceLength-curUnitLength+1;curStart+=curUnitLength) {
							/* Check that the bases match cur */
							int j;
							for(j=0;j<curUnitLength;j++) {
								if(unit[j] != ToLower(RGBinaryGetBase(&rg, curContig, curStart+j))) {
									cont = 0;
								}
							}
//.........这里部分代码省略.........
开发者ID:alecw,项目名称:TS,代码行数:101,代码来源:brepeat.c


示例10: main

int
main (int argc, char *argv[])
{
    DisplayModeRec  *Mode;
    int  HDisplay = 0, VDisplay = 0;
    float  VRefresh = 0.0;
    Bool  Reduced = FALSE, Verbose = FALSE, IsCVT;
    Bool  Interlaced = FALSE;
    int  n;

    if ((argc < 3) || (argc > 7)) {
        PrintUsage(argv[0]);
        return 1;
    }

    /* This doesn't filter out bad flags properly. Bad flags get passed down
     * to atoi/atof, which then return 0, so that these variables can get
     * filled next time round. So this is just a cosmetic problem.
     */
    for (n = 1; n < argc; n++) {
        if (!strcmp(argv[n], "-r") || !strcmp(argv[n], "--reduced"))
            Reduced = TRUE;
        else if (!strcmp(argv[n], "-i") || !strcmp(argv[n], "--interlaced"))
            Interlaced = TRUE;
        else if (!strcmp(argv[n], "-v") || !strcmp(argv[n], "--verbose"))
            Verbose = TRUE;
        else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) {
            PrintUsage(argv[0]);
            return 0;
        } else if (!HDisplay) {
            HDisplay = atoi(argv[n]);
	    if (!HDisplay) {
		PrintUsage(argv[0]);
		return 1;
	    }
	}
        else if (!VDisplay) {
            VDisplay = atoi(argv[n]);
	    if (!VDisplay) {
		PrintUsage(argv[0]);
		return 1;
	    }
	}
        else if (!VRefresh) {
            VRefresh = atof(argv[n]);
	    if (!VRefresh) {
		PrintUsage(argv[0]);
		return 1;
	    }
	}
        else {
            PrintUsage(argv[0]);
            return 1;
        }
    }

    if (!HDisplay || !VDisplay) {
        PrintUsage(argv[0]);
        return 0;
    }

    /* Default to 60.0Hz */
    if (!VRefresh)
        VRefresh = 60.0;

    /* Horizontal timing is always a multiple of 8: round up. */
    if (HDisplay & 0x07) {
        HDisplay &= ~0x07;
        HDisplay += 8;
    }

    if (Reduced) {
	if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) {
	    fprintf(stderr,
		    "\nERROR: Multiple of 60Hz refresh rate required for "
		    " reduced blanking.\n");
	    PrintUsage(argv[0]);
	    return 0;
	}
    }

    IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose);

    Mode = xf86CVTMode(HDisplay, VDisplay, VRefresh, Reduced, Interlaced);

    PrintComment(Mode, IsCVT, Reduced);
    PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced);
    
    return 0;
}
开发者ID:4eremuxa,项目名称:xserver,代码行数:90,代码来源:cvt.c


示例11: HandleCLIOptions

int HandleCLIOptions(int argc,char *argv[], OPTIONS *options)
{
	int i,firstnonoption=0;

	for (i=1; i< argc;i++) {
		if (argv[i][0] == '/' || argv[i][0] == '-') {
			switch (argv[i][1]) {
				/* An argument -? means help is requested */
				case '?':
					PrintUsage(argv[0]);
					break;
				case 'h':
				case 'H':
					if (!stricmp(argv[i]+1,"help")) {
						PrintUsage(argv[0]);
					}
					if (!stricmp(argv[i]+1,"height")) {	//also might mean height
						if (i+1<argc)	{
							options->height = strtol(argv[i+1], NULL, 0);
							i++;
						}
					}
					break;
				case 'n':
				case 'N':
					if (!stricmp(argv[i]+1,"north") || *(argv[i]+2)==0)	{	//if it's north or n (terminated with 0)
						if (i+1<argc)	{
							options->north = strtod(argv[i+1], NULL);
							i++;
						}
					}
					break;
				case 's':
				case 'S':
					if (!stricmp(argv[i]+1,"south") || *(argv[i]+2)==0)	{	//if it's north or n (terminated with 0)
						if (i+1<argc)	{
							options->south = strtod(argv[i+1], NULL);
							i++;
						}
					}
					break;
				case 'w':
				case 'W':
					if (!stricmp(argv[i]+1,"west") || *(argv[i]+2)==0)	{	//if it's north or n (terminated with 0)
						if (i+1<argc)	{
							options->west = strtod(argv[i+1], NULL);
							i++;
						}
					}
					if (!stricmp(argv[i]+1,"width")) {	//also might mean height
						if (i+1<argc)	{
							options->width = strtol(argv[i+1], NULL, 0);
							i++;
						}

					}

					break;
				case 'e':
				case 'E':
					if (!stricmp(argv[i]+1,"east") || *(argv[i]+2)==0)	{	//if it's north or n (terminated with 0)
						if (i+1<argc)	{
							options->east = strtod(argv[i+1], NULL);
							i++;
						}
					}
					break;
				case 'x':
				case 'X':
					if (i+1<argc)	{
						options->width = strtol(argv[i+1], NULL, 0);
						i++;
					}
					break;
				case 'y':
				case 'Y':
					if (i+1<argc)	{
						options->height = strtol(argv[i+1], NULL, 0);
						i++;
					}
					break;

/* //I've stopped using zoom as an argument
				case 'z':
				case 'Z':
					if (i+1<argc)	{
						options->zoom = strtod(argv[i+1], NULL);
						i++;	//move to the next variable, we've got a zoom
					}
					break;
					*/
				case 'g':	//the grid
				case 'G':
					if (i+1<argc)	{
						options->gridsize = strtod(argv[i+1], NULL);
						i++;
					}
					break;
				case 'c':	//how to cycle through the colours
				case 'C':
//.........这里部分代码省略.........
开发者ID:tburtenshaw,项目名称:worldtracker,代码行数:101,代码来源:wtc.c


示例12: ProcOptList

static void ProcOptList( int pass )
{
    char            buff[80];
    char            err_buff[CMD_LEN];
    char            *curr;
    unsigned long   mem;

    SetupChar(); /* initialize scanner */
    for( ;; ) {
        SkipSpaces();
        if( !OptDelim( CurrChar ) )
            break;
        NextChar();
        curr = buff;
#ifndef __GUI__
        if( CurrChar == '?' ) {
            PrintUsage( MSG_USAGE_BASE );
            StartupErr( "" );
        }
#endif
        while( isalnum( CurrChar ) ) {
            *curr++ = CurrChar;
            NextChar();
        }
        if( curr == buff ) {
            if( OptDelim( CurrChar ) ) {
                NextChar();
                SkipSpaces();
                break;
            }
            OptError( LIT_ENG( STARTUP_No_Recog_Optn ) );
        }
        switch( Lookup( OptNameTab, buff, curr - buff ) ) {
        case OPT_CONTINUE_UNEXPECTED_BREAK:
            _SwitchOn( SW_CONTINUE_UNEXPECTED_BREAK );
            break;
        case OPT_DEFERSYM:
            _SwitchOn( SW_DEFER_SYM_LOAD );
            break;
        case OPT_DOWNLOAD:
            DownLoadTask = true;
            break;
        case OPT_NOEXPORTS:
            _SwitchOn( SW_NO_EXPORT_SYMS );
            break;
        case OPT_LOCALINFO:
            if( pass == 2 ) {
                char *symfile = GetFileName( pass );
                FindLocalDebugInfo( symfile );
                _Free( symfile );
            }
            break;
        case OPT_INVOKE:
            if( pass == 2 )
                _Free( InvokeFile );
            InvokeFile = GetFileName( pass );
            break;
        case OPT_NOINVOKE:
            if( pass == 2 )
                _Free( InvokeFile );
            InvokeFile = NULL;
            break;
        case OPT_NOSOURCECHECK:
            _SwitchOff( SW_CHECK_SOURCE_EXISTS );
            break;
        case OPT_NOSYMBOLS:
            _SwitchOff( SW_LOAD_SYMS );
            break;
        case OPT_NOMOUSE:
            _SwitchOff( SW_USE_MOUSE );
            break;
        case OPT_DYNAMIC:
            mem = GetMemory();
            if( pass == 1 ) {
                if( mem < MIN_MEM_SIZE )
                    mem = MIN_MEM_SIZE;
                MemSize = mem;
            }
            break;
        case OPT_DIP:
            {
                int i;

                for( i = 0; DipFiles[i] != NULL; ++i )
                    ;
                DipFiles[i] = GetFileName( pass );
            }
            break;
        case OPT_TRAP:
            if( pass == 2 )
                _Free( TrapParms );
            TrapParms = GetFileName( pass );
            SkipSpaces();
            if( CurrChar == TRAP_PARM_SEPARATOR ) {
                NextChar();
                GetTrapParm( pass );
            } else if( CurrChar == '{' ) {
                GetTrapParm( pass );
            }
            break;
//.........这里部分代码省略.........
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:101,代码来源:dbgcmdln.c


示例13: GetFlags

void GetFlags(int nargs, char **args, int **nreps, int *flsizeKB, int *mflop,
              int **ROUTs, int *ldagap, int **Ns, int **Ms, int **UPLOs,
              int **SDs)
{
   int *NBs=NULL, *ns=NULL, *ms=NULL, *ups=NULL, *sds=NULL, *ip;
   int i, k, n;

   *ROUTs = NULL;
   *ldagap = 0;
   *flsizeKB = L2SIZE/1024;
   *nreps = NULL;
   *mflop = 0;
   for (i=1; i < nargs; i++)
   {
      if (args[i][0] != '-')
         PrintUsage(args[0], i, args[i]);
      switch(args[i][1])
      {
      case 'n':         /* -n  or -nb */
         ns = GetIntList(nargs, args, i, 1);
         i += ns[0] + 1;
         break;
      case 'm':         /* -m # <M1> ... <M#> */
         ms = GetIntList(nargs, args, i, 1);
         i += ms[0] + 1;
         break;
      case 'N':         /* -N or -NB */
      case 'M':                         /* -M <Mstart> <Mend> <Minc>\n"); */
         if (i+3 >= nargs)
            PrintUsage(args[0], i, NULL);
         ip = IntRange2IntList(atoi(args[i+1]),atoi(args[i+2]),atoi(args[i+3]));
         if (args[i][0] == 'M')
            ms = ip;
         else                           /* -N <Nstart> <Nend> <Ninc>\n"); */
            ns = ip;
         i += 3;
         break;
      case 'R':        /* -R # <rout1> ... <routN#>  */
         *ROUTs = RoutNames2IntList(nargs, args, i);
         i += (*ROUTs)[0] + 1;
         break;
      case '#':                         /* set nreps */
         if (args[i][2] == 't')         /* -#t N1 reps1 ... Nt repst */
         {
            *nreps = GetIntList(nargs, args, i, 2);
            i += ((*nreps)[0] << 1) + 1;
         }
         else                           /* -# <reps> */
         {
            if (++i >= nargs)
               PrintUsage(args[0], i, NULL);
            *nreps = GetIntList2(0, atoi(args[i]));
         }
         break;
      case 'f':                         /* -f <flushKB> */
         if (++i >= nargs)
            PrintUsage(args[0], i, NULL);
         *flsizeKB = atoi(args[i]);
         break;
      case 'F':                         /* -F <mflop> */
         if (++i >= nargs)
            PrintUsage(args[0], i, NULL);
         *mflop = atoi(args[i]);
         break;
      case 'U':                         /* -U <nup> <u1> ... <uN>;[u,l,q,g] */
         if (++i >= nargs)
            PrintUsage(args[0], i, NULL);
         n = atoi(args[i]);
         ATL_assert(n > 0);
         ups = malloc(sizeof(int)*(n+1));
         ups[0] = n;
         for (k=0; k < n; k++)
         {
            if (++i >= nargs)
               PrintUsage(args[0], i, NULL);
            switch(args[i][0])
            {
            case 'U':
            case 'u':
               ups[k+1] = LAUpper;
               break;
            case 'l':
            case 'L':
            default:
               ups[k+1] = LALower;
               break;
            }
         }
         break;
      case 'S':                         /* -S <#> <side1> ... <sideN> */
         if (++i >= nargs)
            PrintUsage(args[0], i, NULL);
         n = atoi(args[i]);
         ATL_assert(n > 0);
         sds = malloc(sizeof(int)*(n+1));
         sds[0] = n;
         for (k=0; k < n; k++)
         {
            if (++i >= nargs)
               PrintUsage(args[0], i, NULL);
//.........这里部分代码省略.........
开发者ID:kevinoid,项目名称:atlas-debian,代码行数:101,代码来源:latime.c


示例14: ParseCommandLine


//.........这里部分代码省略.........
	case ARG_AUTH_METHODS:
		Settings.AuthMethods=CopyStr(Settings.AuthMethods,argv[++count]);
	break;

	case ARG_AUTH_FILE:
		Settings.AuthFile=CopyStr(Settings.AuthFile,argv[++count]);
	break;

	case ARG_LOGFILE:
	case ARG_LOGFILE2:
		Settings.LogPath=CopyStr(Settings.LogPath,argv[++count]);
	break;

	case ARG_ALLOWUSERS:
		Settings.AllowUsers=CopyStr(Settings.AllowUsers,argv[++count]);
	break;

	case ARG_DENYUSERS:
		Settings.DenyUsers=CopyStr(Settings.DenyUsers,argv[++count]);
	break;

	case ARG_NOPASV:
		Settings.Flags |= FLAG_NOPASV;
	break;

	case ARG_DCLOW:
   	Settings.DataConnectionLowPort=atoi(argv[++count]);
	break;

	case ARG_DCHIGH:
   	Settings.DataConnectionHighPort=atoi(argv[++count]);
	break;

	case ARG_IDLE:
   	Settings.DefaultIdle=atoi(argv[++count]);
	break;

	case ARG_MAXIDLE:
  	Settings.MaxIdle=atoi(argv[++count]);
	break;

	case ARG_MLOCKS:
  	Settings.Flags |= FLAG_MLOCK;
	break;

	case ARG_ALOCKS:
  	Settings.Flags |= FLAG_ALOCK;
	break;

	case ARG_MALOCKS:
  	Settings.Flags |= FLAG_MLOCK | FLAG_ALOCK;
	break;

	case ARG_BINDADDRESS:
	case ARG_INTERFACE:
		Settings.BindAddress=CopyStr(Settings.BindAddress,argv[++count]);
	break;

	case ARG_IPV4:
		Settings.BindAddress=CopyStr(Settings.BindAddress,"0.0.0.0");
	break;

	case ARG_UPDATE_PASSWORD:
  	Settings.UpdatePasswordType=CopyStr(Settings.UpdatePasswordType, argv[++count]);
	break;


	case ARG_CONFIRM_TRANSFER:
		Settings.ConfirmTransfer=MatchTokenFromList(argv[++count],HashNames,0);
	break;

/*
	case ARG_PERMITTEDCOMMANDS:
		Settings.PermittedCommands=CopyStr(Settings.PermittedCommands,argv[++count]);
	break;
*/

	case ARG_HELP1:
	case ARG_HELP2:
	case ARG_HELP3:
		PrintUsage();
	break;

	case ARG_VERSION:
	case ARG_VERSION2:
	printf("metaftpd %s\n",Version);
	exit(0);
	break;
   }
}

if (
	(! (Settings.Flags & MODE_FTP_SERVER)) && 
	(! (Settings.Flags & MODE_FTP_PROXY))
   )
{
 Settings.Flags |= MODE_FTP_SERVER;
}

}
开发者ID:ColumPaget,项目名称:MetaFTPD,代码行数:101,代码来源:Settings.c


示例15: GetFlags

void GetFlags(int nargs, char **args, int *MFLOP, int *CacheSize, TYPE *thresh,
              int *ldagap, int *nuplo, enum ATLAS_UPLO **Uplo,
              int *N0, int *NN, int *incN)
{
   int i, j, n;
   char ch;

   *MFLOP = 0;
   #ifdef L2SIZE
      *CacheSize = L2SIZE;
   #else
      *CacheSize = 4*1024*1024;
   #endif
   *thresh = 100.0;
   *N0 = *NN = *incN = -1;
   *ldagap = 0;
   *nuplo = -1;
   for (i=1; i < nargs; i++)
   {
      if (args[i][0] != '-') PrintUsage(args[0]);
      switch(args[i][1])
      {
      case 'T':
         *thresh = atof(args[++i]);
         break;
      case 'C':
         *CacheSize = 1024*atoi(args[++i]);
         break;
      case 'l':
         *ldagap = atoi(args[++i]);
         break;
      case 'n':
         *N0 = *NN = *incN = atoi(args[++i]);
         break;
      case 'N':
         *N0 = atoi(args[++i]);
         *NN = atoi(args[++i]);
         *incN = atoi(args[++i]);
         break;
      case 'F':
         *MFLOP = atoi(args[++i]);
         break;
      case 'U':
         *nuplo = atoi(args[++i]);
         if (*nuplo <= 0) PrintUsage(args[0]);
         *Uplo = malloc(*nuplo * sizeof(enum ATLAS_UPLO));
         ATL_assert(*Uplo);
         for (j=0; j != *nuplo; j++)
         {
            if (args[i] == NULL) PrintUsage(args[0]);
            ch = *args[++i];
            if (ch == 'u' || ch == 'U') (*Uplo)[j] = AtlasUpper;
            else if (ch == 'l' || ch == 'L') (*Uplo)[j] = AtlasLower;
            else PrintUsage(args[0]);
         }
         break;
      default:
         PrintUsage(args[0]);
      }
   }
   if (*N0 == -1)
   {
      *N0 = 100;
      *NN = 1000;
      *incN = 100;
   }
   if (*nuplo == -1)
   {
      *nuplo = 1;
      *Uplo = malloc(sizeof(enum ATLAS_UPLO));
      ATL_assert(*Uplo);
      **Uplo = AtlasLower;
   }
}
开发者ID:GorgonCryoEM,项目名称:Gorgon-CVS,代码行数:74,代码来源:llttst.c


示例16: main

int main(int argc, char **argv)
{
    Uint8* RawMooseData;
    SDL_RWops* handle;
    SDL_Surface* screen;
    SDL_Surface* MooseFrame[MOOSEFRAMES_COUNT];
    SDL_Overlay* overlay;
    SDL_Rect overlayrect;
    SDL_Event event;
    Uint32 lastftick;
    int paused=0;
    int resized=0;
    int i;
    int fps=12;
    int fpsdelay;
    int overlay_format=SDL_YUY2_OVERLAY;
    int scale=5;

    while ( argc > 1 )
    {
        if (strcmp(argv[1], "-fps")== 0)
        {
            if (argv[2])
            {
                fps = atoi(argv[2]);
                if (fps==0)
                {
                    fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
                    return -1;
                }
                if ((fps<0) || (fps>1000))
                {
                    fprintf(stderr, "The -fps option must be in range from 1 to 1000, default is 12.\n");
                    return -1;
                }
                argv += 2;
                argc -= 2;
            }
            else
            {
                fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
                return -1;
            }
        } else
        if (strcmp(argv[1], "-format")  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Printf函数代码示例发布时间:2022-05-30
下一篇:
C++ PrintTree函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap