當前位置: 首頁>>代碼示例>>C++>>正文


C++ GETARG函數代碼示例

本文整理匯總了C++中GETARG函數的典型用法代碼示例。如果您正苦於以下問題:C++ GETARG函數的具體用法?C++ GETARG怎麽用?C++ GETARG使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GETARG函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: child

static int child( euca_opts *args, java_home_t *data, uid_t uid, gid_t gid ) {
	int ret = 0;
    jboolean r=0;
	__write_pid( GETARG(args,pidfile) );
	setpgrp( );
	__die(java_init( args, data ) != 1, "Failed to initialize Eucalyptus.");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.init))==0,"Failed to init Eucalyptus.");
	__abort(4, set_keys_ownership( GETARG( args, home ), uid, gid ) != 0,"Setting ownership of keyfile failed." );
	__abort(4, linuxset_user_group( GETARG( args, user ), uid, gid ) != 0,"Setting the user failed." );
	__abort(4, (set_caps(0)!=0), "set_caps (0) failed");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.load))==0,"Failed to load Eucalyptus.");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.start))==0,"Failed to start Eucalyptus.");
	handle._hup = signal_set( SIGHUP, handler );
	handle._term = signal_set( SIGTERM, handler );
	handle._int = signal_set( SIGINT, handler );
	child_pid = getpid( );
	__debug( "Waiting for a signal to be delivered" );
	while( !stopping ) sleep( 60 );
	__debug( "Shutdown or reload requested: exiting" );
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.stop))==0,"Failed to stop Eucalyptus.");
	if( doreload == 1 ) ret = EUCA_RET_RELOAD;
	else ret = 0;
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.destroy))==0,"Failed to destroy Eucalyptus.");
	__die((JVM_destroy( ret ) != 1), "Failed trying to destroy JVM... bailing out seems like the right thing to do" );
	return ret;
}
開發者ID:1ukash,項目名稱:eucalyptus-fork-2.0,代碼行數:26,代碼來源:eucalyptus-bootstrap.c

示例2: __error

char *java_library(euca_opts *args, java_home_t *data) {
    char *libjvm_path=NULL;
    int x;
    if (data->jnum==0) {
        __error("Cannot find any VM in Java Home %s",data->path);
		exit(1);
    }
    if (args->jvm_name_given==0) {
    	libjvm_path=data->jvms[0]->libjvm_path;
    } else {
        for (x=0; x<data->jnum; x++) {
            if (data->jvms[x]->name==NULL) continue;
            if (strcmp(GETARG(args,jvm_name),data->jvms[x]->name)==0) {
            	libjvm_path=data->jvms[x]->libjvm_path;
                break;
            }
        }
    }
    if (libjvm_path==NULL) {
        __error("Failed to locate usable JVM %s %s",GETARG(args,jvm_name),libjvm_path);
        exit(1);
    }
    __debug("Using libjvm.so in %s",libjvm_path);
    return libjvm_path;
}
開發者ID:1ukash,項目名稱:eucalyptus-fork-2.0,代碼行數:25,代碼來源:eucalyptus-bootstrap.c

示例3: java_library_path

char* java_library_path(euca_opts *args) {
#define JAVA_PATH_LEN 65536
    char lib_dir[256],etc_dir[256],script_dir[256],*jar_list=(char*)malloc(JAVA_PATH_LEN*sizeof(char));
    __die(( strlen(GETARG(args,home))+strlen(EUCA_LIB_DIR)>=254),"Directory path too long: %s/%s", GETARG(args,home), EUCA_LIB_DIR);
    snprintf(lib_dir,255,"%s%s",GETARG(args,home),EUCA_LIB_DIR);
    snprintf(etc_dir,255,"%s%s",GETARG(args,home),EUCA_ETC_DIR);
    snprintf(script_dir,255,"%s%s",GETARG(args,home),EUCA_SCRIPT_DIR);
    if(!CHECK_ISDIR(lib_dir) ) __die(1,"Can't find library directory %s", lib_dir );
    int wb = 0;
    wb += snprintf(jar_list+wb,JAVA_PATH_LEN-wb,"-Djava.class.path=%s:",etc_dir);
    wb += snprintf(jar_list+wb,JAVA_PATH_LEN-wb,"%s",script_dir);
    DIR* lib_dir_p = opendir(lib_dir);
    struct direct *dir_ent;
    while ((dir_ent = readdir(lib_dir_p))!=0)  {
            if (strcmp(dir_ent->d_name,".") != 0 && strcmp(dir_ent->d_name,"..") != 0 && strcmp(dir_ent->d_name,"openjdk-crypto.jar") != 0 && strstr(dir_ent->d_name,"disabled") == NULL && strstr(dir_ent->d_name,"eucalyptus-") != NULL )  {
                            char jar[256];
                            snprintf(jar,255,"%s/%s",lib_dir,dir_ent->d_name);
                            if( (CHECK_ISREG(jar) || CHECK_ISLNK(jar)) ) wb += snprintf(jar_list+wb,JAVA_PATH_LEN-wb,":%s",jar);
            }
    }
    closedir(lib_dir_p);
    lib_dir_p = opendir(lib_dir);
    while ((dir_ent = readdir(lib_dir_p))!=0)  {
            if (strcmp(dir_ent->d_name,".") != 0 && strcmp(dir_ent->d_name,"..") != 0 && strcmp(dir_ent->d_name,"openjdk-crypto.jar") != 0 && strstr(dir_ent->d_name,"disabled") == NULL && strstr(dir_ent->d_name,"eucalyptus-") == NULL)  {
                            char jar[256];
                            snprintf(jar,255,"%s/%s",lib_dir,dir_ent->d_name);
                            if( (CHECK_ISREG(jar) || CHECK_ISLNK(jar)) ) wb += snprintf(jar_list+wb,JAVA_PATH_LEN-wb,":%s",jar);
            }
    }
    closedir(lib_dir_p);
    return jar_list;
}
開發者ID:1ukash,項目名稱:eucalyptus-fork-2.0,代碼行數:32,代碼來源:eucalyptus-bootstrap.c

示例4: LOAD_CONST

/* Replace LOAD_CONST c1. LOAD_CONST c2 ... LOAD_CONST cn BUILD_TUPLE n
   with    LOAD_CONST (c1, c2, ... cn).
   The consts table must still be in list form so that the
   new constant (c1, c2, ... cn) can be appended.
   Called with codestr pointing to the first LOAD_CONST.
   Bails out with no change if one or more of the LOAD_CONSTs is missing.
   Also works for BUILD_LIST and BUILT_SET when followed by an "in" or "not in"
   test; for BUILD_SET it assembles a frozenset rather than a tuple.
*/
static int
tuple_of_constants(unsigned char *codestr, Py_ssize_t n, PyObject *consts)
{
    PyObject *newconst, *constant;
    Py_ssize_t i, arg, len_consts;

    /* Pre-conditions */
    assert(PyList_CheckExact(consts));
    assert(codestr[n*3] == BUILD_TUPLE || codestr[n*3] == BUILD_LIST || codestr[n*3] == BUILD_SET);
    assert(GETARG(codestr, (n*3)) == n);
    for (i=0 ; i<n ; i++)
        assert(codestr[i*3] == LOAD_CONST);

    /* Buildup new tuple of constants */
    newconst = PyTuple_New(n);
    if (newconst == NULL)
        return 0;
    len_consts = PyList_GET_SIZE(consts);
    for (i=0 ; i<n ; i++) {
        arg = GETARG(codestr, (i*3));
        assert(arg < len_consts);
        constant = PyList_GET_ITEM(consts, arg);
        Py_INCREF(constant);
        PyTuple_SET_ITEM(newconst, i, constant);
    }

    /* If it's a BUILD_SET, use the PyTuple we just built to create a
      PyFrozenSet, and use that as the constant instead: */
    if (codestr[n*3] == BUILD_SET) {
        PyObject *tuple = newconst;
        newconst = PyFrozenSet_New(tuple);
        Py_DECREF(tuple);
        if (newconst == NULL)
            return 0;
    }

    /* Append folded constant onto consts */
    if (PyList_Append(consts, newconst)) {
        Py_DECREF(newconst);
        return 0;
    }
    Py_DECREF(newconst);

    /* Write NOPs over old LOAD_CONSTS and
       add a new LOAD_CONST newconst on top of the BUILD_TUPLE n */
    memset(codestr, NOP, n*3);
    codestr[n*3] = LOAD_CONST;
    SETARG(codestr, (n*3), len_consts);
    return 1;
}
開發者ID:Jimlan,項目名稱:kbengine,代碼行數:59,代碼來源:peephole.c

示例5: regm_CheckSection1

static uint32_t regm_CheckSection1 (poffHandle_t hPoff, uint32_t dwOffset)
{
  OPTYPE op;

  /* Seek to the beginning of the section. */

  regm_ProgSeek(hPoff, dwOffset);

  /* Read the opcode at that position. */

  (void)insn_GetOpCode(hPoff, &op);

  /* Is it a oJMP instruction? This happens when there are nested
   * functions.  The entry point into the parent function is a jump
   * around the nested functions.
   */

  if (GETOP(&op) == oJMP)
    {
      /* Yes, then the block really begins at the target of the jump */

      return GETARG(&op);
    }
  else
    {
      /* No, then the block really begins right here */

      return dwOffset;
    }
}
開發者ID:grissiom,項目名稱:muttx-mirror,代碼行數:30,代碼來源:regm_pass1.c

示例6: pass1

static void pass1(poffHandle_t poffHandle, poffProgHandle_t poffProgHandle)
{
    OPTYPE op;
    uint32_t pc;
    int opsize;
    int fileno = 0;

    /* Build label / line number reference table
     *
     * CASE 1: LABEL
     *   Add label number + PC to table
     *   discard
     * CASE 2: LINE
     *   genereate a line number reference
     *   discard
     * ELSE:
     *   pass through with no additional action
     */

    pc = 0;
    do
    {
        opsize = insn_GetOpCode(poffHandle, &op);
        if (GETOP(&op) == oLABEL)
        {
            poffAddToDefinedLabelTable(GETARG(&op), pc);
        }
        else if (GETOP(&op) == oINCLUDE)
        {
            fileno = GETARG(&op);
        }
        else if (GETOP(&op) == oLINE)
        {
            poffAddLineNumber(poffHandle, GETARG(&op), fileno, pc);
        }
        else
        {
            insn_AddTmpOpCode(poffProgHandle, &op);
            pc += opsize;
        }
    }
    while (GETOP(&op) != oEND);

    /* Replace the original program data with the new program data */

    poffReplaceProgData(poffHandle, poffProgHandle);
}
開發者ID:hechan,項目名稱:NuttX,代碼行數:47,代碼來源:pfopt.c

示例7: getgeom

static int
getgeom(struct vndgeom *vng, char *cp)
{
	char *secsize, *nsectors, *ntracks, *ncylinders;

#define	GETARG(arg) \
	do { \
		if (cp == NULL || *cp == '\0') \
			return (1); \
		arg = strsep(&cp, "/"); \
		if (arg == NULL) \
			return (1); \
	} while (0)

	GETARG(secsize);
	GETARG(nsectors);
	GETARG(ntracks);
	GETARG(ncylinders);

#undef GETARG

	/* Too many? */
	if (cp != NULL)
		return (1);

#define	CVTARG(str, num) \
	do { \
		num = strtol(str, &cp, 10); \
		if (*cp != '\0') \
			return (1); \
	} while (0)

	CVTARG(secsize, vng->vng_secsize);
	CVTARG(nsectors, vng->vng_nsectors);
	CVTARG(ntracks, vng->vng_ntracks);
	CVTARG(ncylinders, vng->vng_ncylinders);

#undef CVTARG

	return (0);
}
開發者ID:marklee77,項目名稱:frankenlibc,代碼行數:41,代碼來源:vnconfig.c

示例8: fold_unaryops_on_constants

static int
fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
{
    PyObject *newconst=NULL, *v;
    Py_ssize_t len_consts;
    int opcode;

    /* Pre-conditions */
    assert(PyList_CheckExact(consts));
    assert(codestr[0] == LOAD_CONST);

    /* Create new constant */
    v = PyList_GET_ITEM(consts, GETARG(codestr, 0));
    opcode = codestr[3];
    switch (opcode) {
        case UNARY_NEGATIVE:
            /* Preserve the sign of -0.0 */
            if (PyObject_IsTrue(v) == 1)
                newconst = PyNumber_Negative(v);
            break;
        case UNARY_INVERT:
            newconst = PyNumber_Invert(v);
            break;
        case UNARY_POSITIVE:
            newconst = PyNumber_Positive(v);
            break;
        default:
            /* Called with an unknown opcode */
            PyErr_Format(PyExc_SystemError,
                 "unexpected unary operation %d on a constant",
                     opcode);
            return 0;
    }
    if (newconst == NULL) {
        if(!PyErr_ExceptionMatches(PyExc_KeyboardInterrupt))
            PyErr_Clear();
        return 0;
    }

    /* Append folded constant into consts table */
    len_consts = PyList_GET_SIZE(consts);
    if (PyList_Append(consts, newconst)) {
        Py_DECREF(newconst);
        return 0;
    }
    Py_DECREF(newconst);

    /* Write NOP LOAD_CONST newconst */
    codestr[0] = NOP;
    codestr[1] = LOAD_CONST;
    SETARG(codestr, 1, len_consts);
    return 1;
}
開發者ID:Jimlan,項目名稱:kbengine,代碼行數:53,代碼來源:peephole.c

示例9: el_get

int
el_get (EditLine *el, int code, ...)
{
    switch ( code )
    {
    case ( EL_CLIENTDATA ):
        {
            void **dout = (void**) GETARG( 0 );
            *dout = clientData;
        }
        break;
    default:
        assert( !"Not implemented!" );
    }
    return 0;
}
開發者ID:Narupol,項目名稱:lldb,代碼行數:16,代碼來源:ELWrapper.cpp

示例10: stop_child

static int stop_child(euca_opts *args) {
	int pid = __get_pid(GETARG(args, pidfile)), rc = 0, i;
	if (pid <= 0)
		return -1;
	fprintf(stderr, "Waiting for process to terminate: pid=%d .", pid);
	for (i = 0; i < 60 && (rc = kill(pid, SIGTERM)) != -1; i++) {
		usleep(1000 * 1000), fprintf(stderr, "."), fflush(stderr);
	}
	if (i == 0) {
		i = errno;
		__die(rc == -1 && i == ESRCH, "No process with the specified pid=%d",
				pid);
		__die(rc == -1 && i == EPERM, "Do not have permission to kill pid=%d",
				pid);
	} else if (i == 60) {
		__debug("Forcefully terminating hung process.");
		kill(pid, SIGKILL);
	} else {
		fprintf(stderr, "\nTerminated process with pid=%d\n", pid);
	}
	return 0;
}
開發者ID:sosilent,項目名稱:euca,代碼行數:22,代碼來源:eucalyptus-bootstrap.c

示例11: main

int main( int argc, char *argv[ ] ) {
	euca_opts euca_args;
	euca_opts *args = &euca_args;
	java_home_t *data = NULL;
	int status = 0;
	pid_t pid = 0;
	uid_t uid = 0;
	gid_t gid = 0;
	if( arguments( argc, argv, args ) != 0 ) exit( 1 );
	debug = args->verbose_flag || args->debug_flag;
	if( args->stop_flag == 1 ) return stop_child( args );
	if( checkuser( GETARG( args, user ), &uid, &gid ) == 0 ) return 1;
	char* java_home_user = GETARG(args,java_home);
	char* java_home_env = getenv( "JAVA_HOME" );
	if( java_home_user != NULL ) {
		__debug("Trying user supplied java home: %s", java_home_user);
		data = get_java_home(java_home_user);
	}
	if( data == NULL && java_home_env != NULL ) {
		__debug("Trying environment JAVA_HOME: %s", java_home_env);
		data = get_java_home(java_home_env);
	}
	__debug("TODO: loop through common locations for JVMs here.");
	if( data == NULL ) {
		__error( "Cannot locate Java Home" );
		return 1;
	}
	int x;
	if( debug == 1 ) {
		__debug( "+-- DUMPING JAVA HOME STRUCTURE ------------------------" );
		__debug( "| Java Home:       \"%s\"", PRINT_NULL( data->path ) );
		__debug( "| Found JVMs:      %d", data->jnum );
		for( x = 0; x < data->jnum; x++ ) {
			jvm_info_t *jvm = data->jvms[ x ];
			__debug( "| JVM Name:        \"%s\"", PRINT_NULL( jvm->name ) );
			__debug( "|                  \"%s\"", PRINT_NULL( jvm->libjvm_path ) );
		}
		__debug( "+-------------------------------------------------------" );
	}
	if( strcmp( argv[ 0 ], "eucalyptus-cloud" ) != 0 ) {
		char *oldpath = getenv( "LD_LIBRARY_PATH" ),*libf = java_library( args, data );
		char *old = argv[ 0 ],buf[ 32768 ],*tmp = NULL,*p1 = NULL,*p2 = NULL;
		p1 = strdup( libf );
		tmp = strrchr( p1, '/' );
		if( tmp != NULL ) tmp[ 0 ] = '\0';
		p2 = strdup( p1 );
		tmp = strrchr( p2, '/' );
		if( tmp != NULL ) tmp[ 0 ] = '\0';
		if( oldpath == NULL ) snprintf( buf, 32768, "%s:%s:%s/bin/linux-x64", p1, p2, GETARG(args,profiler_home) );
		else snprintf( buf, 32768, "%s:%s:%s:%s/bin/linux-x64", oldpath, p1, p2, GETARG(args,profiler_home) );
		tmp = strdup( buf );

		setenv( "LD_LIBRARY_PATH", tmp, 1 );
		__debug( "Invoking w/ LD_LIBRARY_PATH=%s", getenv( "LD_LIBRARY_PATH" ) );
		argv[ 0 ] = "eucalyptus-cloud";
		execve( old, argv, environ );
		__error( "Cannot execute process" );
		return 1;
	}
	__debug( "Running w/ LD_LIBRARY_PATH=%s", getenv( "LD_LIBRARY_PATH" ) );
	if(args->fork_flag) {
		pid = fork( );
		__die(( pid == -1 ),"Cannot detach from parent process" );
		if( pid != 0 ) return wait_child( args, pid );
		setsid( );
	}
	set_output(GETARG(args,out), GETARG(args,err));
	while( ( pid = fork( ) ) != -1 ) {
		if( pid == 0 ) exit( child( args, data, uid, gid ) );
		child_pid = pid;
		signal( SIGHUP, controller );
		signal( SIGTERM, controller );
		signal( SIGINT, controller );
		while( waitpid( pid, &status, 0 ) != pid );
		if( WIFEXITED( status ) ) {
			status = WEXITSTATUS( status );
			__debug( "Eucalyptus exited with status: %d", status );
			if( status != 122 ) unlink( GETARG( args, pidfile ) );
			if( status == 123 ) {
				__debug( "Reloading service" );
				continue;
			}
			if( status == 0 ) {
				__debug( "Service shut down" );
				return 0;
			}
			__error( "Service exit with a return value of %d", status );
			return 1;
		} else {
			__error( "Service did not exit cleanly exit value %d", status );
			return 1;
		}
	}
	__error( "Cannot decouple controller/child processes" );
	return 1;
}
開發者ID:1ukash,項目名稱:eucalyptus-fork-2.0,代碼行數:96,代碼來源:eucalyptus-bootstrap.c

示例12: binaryOptimize

int binaryOptimize(void)
{
  register int i;
  int nchanges = 0;

  TRACE(stderr, "[binaryOptimize]");

  /* At least two pcodes are needed to perform the following binary */
  /* operator optimizations */

  i = 0;
  while (i < nops-2)
    {
      if (GETOP(pptr[i]) == oPUSH)
        {
          if (GETOP(pptr[i+1]) == oPUSH)
            {
              switch (GETOP(pptr[i+2]))
                {
                case oADD :
                  PUTARG(pptr[i], GETARG(pptr[i]) + GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oSUB :
                  PUTARG(pptr[i], GETARG(pptr[i]) - GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oMUL :
                  PUTARG(pptr[i], GETARG(pptr[i]) * GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oDIV :
                  PUTARG(pptr[i], GETARG(pptr[i]) / (int32_t)GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oMOD :
                  PUTARG(pptr[i], GETARG(pptr[i]) % GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oSLL :
                  PUTARG(pptr[i], GETARG(pptr[i]) << GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oSRL :
                  PUTARG(pptr[i], GETARG(pptr[i]) >> GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oSRA :
                  PUTARG(pptr[i], (int32_t)GETARG(pptr[i]) >> GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oOR  :
                  PUTARG(pptr[i], GETARG(pptr[i]) | GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oAND :
                  PUTARG(pptr[i], GETARG(pptr[i]) & GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oEQU :
                  if (GETARG(pptr[i]) == GETARG(pptr[i+1]))
                    PUTARG(pptr[i], -1);
                  else
                    PUTARG(pptr[i], 0);
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oNEQ :
                  if (GETARG(pptr[i]) != GETARG(pptr[i+1]))
                    PUTARG(pptr[i], -1);
                  else
                    PUTARG(pptr[i], 0);
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oLT  :
                  if ((int32_t)GETARG(pptr[i]) < (int32_t)GETARG(pptr[i+1]))
                    PUTARG(pptr[i], -1);
//.........這裏部分代碼省略.........
開發者ID:CompagnieDesLampadaires,項目名稱:terrarium_2015,代碼行數:101,代碼來源:pcopt.c

示例13: stop_child

static int stop_child( euca_opts *args ) {
	int pid = __get_pid( GETARG(args,pidfile) );
	if( pid <= 0 ) return -1;
	kill( pid, SIGTERM );
	return wait_child(args,pid);
}
開發者ID:1ukash,項目名稱:eucalyptus-fork-2.0,代碼行數:6,代碼來源:eucalyptus-bootstrap.c

示例14: rb_str_format


//.........這裏部分代碼省略.........

	  case '.':
	    if (flags & FPREC0) {
		rb_raise(rb_eArgError, "precision given twice");
	    }
	    flags |= FPREC|FPREC0;

	    prec = 0;
	    p++;
	    if (*p == '*') {
		GETASTER(prec);
		if (prec < 0) {	/* ignore negative precision */
		    flags &= ~FPREC;
		}
		p++;
		goto retry;
	    }

	    GETNUM(prec, precision);
	    goto retry;

	  case '\n':
	  case '\0':
	    p--;
	  case '%':
	    if (flags != FNONE) {
		rb_raise(rb_eArgError, "invalid format character - %%");
	    }
	    PUSH("%", 1);
	    break;

	  case 'c':
	    {
		VALUE val = GETARG();
		VALUE tmp;
		unsigned int c;
		int n;

		tmp = rb_check_string_type(val);
		if (!NIL_P(tmp)) {
		    if (rb_enc_strlen(RSTRING_PTR(tmp),RSTRING_END(tmp),enc) != 1) {
			rb_raise(rb_eArgError, "%%c requires a character");
		    }
		    c = rb_enc_codepoint_len(RSTRING_PTR(tmp), RSTRING_END(tmp), &n, enc);
		    RB_GC_GUARD(tmp);
		}
		else {
		    c = NUM2INT(val);
		    n = rb_enc_codelen(c, enc);
		}
		if (n <= 0) {
		    rb_raise(rb_eArgError, "invalid character");
		}
		if (!(flags & FWIDTH)) {
		    CHECK(n);
		    rb_enc_mbcput(c, &buf[blen], enc);
		    blen += n;
		}
		else if ((flags & FMINUS)) {
		    CHECK(n);
		    rb_enc_mbcput(c, &buf[blen], enc);
		    blen += n;
		    FILL(' ', width-1);
		}
		else {
		    FILL(' ', width-1);
開發者ID:DashYang,項目名稱:sim,代碼行數:67,代碼來源:sprintf.c

示例15: PETScParseFortranArgs_Private

PetscErrorCode PETScParseFortranArgs_Private(int *argc,char ***argv)
{
#if defined(PETSC_USE_NARGS)
  short          i,flg;
#else
  int            i;
#endif
  PetscErrorCode ierr;
  int            warg = 256;
  PetscMPIInt    rank;
  char           *p;

  ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr);
  if (!rank) {
#if defined(PETSC_HAVE_IARG_COUNT_PROGNAME)
    *argc = iargc_();
#else
    /* most compilers do not count the program name for argv[0] */
    *argc = 1 + iargc_();
#endif
  }
  ierr = MPI_Bcast(argc,1,MPI_INT,0,PETSC_COMM_WORLD);CHKERRQ(ierr);

  /* PetscTrMalloc() not yet set, so don't use PetscMalloc() */
  ierr = PetscMallocAlign((*argc+1)*(warg*sizeof(char)+sizeof(char*)),0,0,0,(void**)argv);CHKERRQ(ierr);
  (*argv)[0] = (char*)(*argv + *argc + 1);

  if (!rank) {
    ierr = PetscMemzero((*argv)[0],(*argc)*warg*sizeof(char));CHKERRQ(ierr);
    for (i=0; i<*argc; i++) {
      (*argv)[i+1] = (*argv)[i] + warg;
#if defined (PETSC_HAVE_FORTRAN_GET_COMMAND_ARGUMENT) /* same as 'else' case */
      getarg_(&i,(*argv)[i],warg);
#elif defined(PETSC_HAVE_PXFGETARG_NEW)
      {char *tmp = (*argv)[i];
      int ilen;
      getarg_(&i,tmp,&ilen,&ierr,warg);CHKERRQ(ierr);
      tmp[ilen] = 0;}
#elif defined(PETSC_USE_NARGS)
      GETARG(&i,(*argv)[i],warg,&flg);
#else
      /*
      Because the stupid #defines above define all kinds of things to getarg_ we cannot do this test
      #elif defined(PETSC_HAVE_GETARG)
      getarg_(&i,(*argv)[i],warg);
      #else
         SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot get Fortran command line arguments");
      */
      getarg_(&i,(*argv)[i],warg);
#endif
      /* zero out garbage at end of each argument */
      p = (*argv)[i] + warg-1;
      while (p > (*argv)[i]) {
        if (*p == ' ') *p = 0;
        p--;
      }
    }
  }
  ierr = MPI_Bcast((*argv)[0],*argc*warg,MPI_CHAR,0,PETSC_COMM_WORLD);CHKERRQ(ierr);
  if (rank) {
    for (i=0; i<*argc; i++) (*argv)[i+1] = (*argv)[i] + warg;
  }
  return 0;
}
開發者ID:tom-klotz,項目名稱:petsc,代碼行數:64,代碼來源:zstart.c


注:本文中的GETARG函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。