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


C++ run_program函数代码示例

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


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

示例1: md_update

/* Upgrade support */
int
md_update(void)
{
	const char *mntdir = "/mnt2";
	char bootpath[MAXPATHLEN];
	struct stat sb;
	bool hasboot = false;

	/*
	 * Check if there is a boot UFS parttion and it has the old bootloader.
	 * We'll update bootloader only if the old one was installed.
	 */
	if (!run_program(RUN_SILENT | RUN_ERROR_OK,
	    "mount -r /dev/%s%c %s", pm->diskdev, 'a' + PART_BOOT, mntdir)) {
		mnt2_mounted = 1;
		snprintf(bootpath, sizeof(bootpath), "%s/%s", mntdir, "boot");
		if (stat(bootpath, &sb) == 0 && S_ISREG(sb.st_mode))
			hasboot = true;
		run_program(RUN_SILENT | RUN_ERROR_OK, "umount %s", mntdir);
		mnt2_mounted = 0;
		if (hasboot)
			(void)copy_bootloader();
	}
	return 1;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:26,代码来源:md.c

示例2: run_program

/*************************************************************************
 * Open a read-only pipe using a given command line.
 *************************************************************************/
FILE* open_command_pipe
  (char*     program,          // The program to run in the pipe.
   char*     directory,        // Directory to look in.
   char*     test_arguments,   // Arguments used when searching for program.
   char*     expected_reply,   // Expected reply from search.
   char*     real_arguments,   // Arguments used when running the program.
   BOOLEAN_T stdout_on_error,  // If command fails, return STDOUT?
   char*     error_message)    // Error or warning if command fails.
{
  FILE* return_value;

  // Try to run the command with no directory specified.
  if (try_to_run(program, "", test_arguments, expected_reply)) {
    return_value = run_program(program, "", real_arguments, "w");
  }

  // Try to run the program in the specified directory.
  else if (try_to_run(program, directory, test_arguments, expected_reply)) {
    return_value = run_program(program, directory, real_arguments, "w");

  } else {

    // If we failed, print the error message.
    fprintf(stderr, "%s", error_message);
    if (stdout_on_error) {
      return_value = stdout;
    } else {
      exit(1);
    }
  }

  return(return_value);
}
开发者ID:CPFL,项目名称:gmeme,代码行数:36,代码来源:utils.c

示例3: main

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

    if( argc == 1 ) {
        interactive();
        return 0;
    }

    if( argc == 2 ) {
        if( strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0 ) {
            std::cout << "Usage: " << argv[0] << " [-l | -p | -s | -r] <filename>\n"
                         "\n"
                         "This program will analyse the program specified in the last argument.\n"
                         "  -l, --lexer     Do lexical analysis on the program.\n"
                         "  -p, --parser    Do syntactic analysis on the program.\n"
                         "  -s, --semantic  Do semantical analysis on the program.\n"
                         "  -r, --run       Run the program. This is the default.\n"
                         "  -h, --help      Display this help and quit.\n"
                         "If no argument is provided, run in interactive mode.\n";
            return 0;
        }
        run_program( argv[1] );
        return 0;
    }

    if( argc != 3 ) {
        std::cout << "Usage: " << argv[0] << " [-l | -p | -s | -r] <filename>\n";
        return 1;
    }

    const char * filename = argv[2];
    if( strcmp(argv[1], "-l" ) == 0 || strcmp(argv[1], "--lexer") == 0 ) {
        lexical_analysis( filename );
        return 0;
    }
    if( strcmp(argv[1], "-p" ) == 0 || strcmp(argv[1], "--parser") == 0 ) {
        syntactic_analysis( filename );
        return 0;
    }
    if( strcmp(argv[1], "-s" ) == 0 || strcmp(argv[1], "--semantic") == 0 ) {
        semantic_analysis( filename );
        return 0;
    }
    if( strcmp(argv[1], "-r" ) == 0 || strcmp(argv[1], "--run") == 0 ) {
        run_program( filename );
        return 0;
    }

    std::cerr << "Unknown option " << argv[1] << '\n';
    return 1;
}
开发者ID:royertiago,项目名称:INE5426,代码行数:51,代码来源:main.cpp

示例4: strrchr

// Launch a project (science) graphics application
//
int CScreensaver::launch_screensaver(RESULT* rp, GFXAPP_ID& graphics_application) {
    int retval = 0;
    
    if (strlen(rp->graphics_exec_path)) {
        // V6 Graphics
#ifdef __APPLE__
        // For sandbox security, use gfx_switcher to launch gfx app 
        // as user boinc_project and group boinc_project.
        //
        // For unknown reasons, the graphics application exits with 
        // "RegisterProcess failed (error = -50)" unless we pass its 
        // full path twice in the argument list to execv.
        char* argv[5];
        argv[0] = "gfx_Switcher";
        argv[1] = "-launch_gfx";
        argv[2] = strrchr(rp->slot_path, '/');
        if (*argv[2]) argv[2]++;    // Point to the slot number in ascii
        
        argv[3] = "--fullscreen";
        argv[4] = 0;

       retval = run_program(
            rp->slot_path,
            m_gfx_Switcher_Path,
            4,
            argv,
            0,
            graphics_application
        );

    if (graphics_application) {
        launchedGfxApp(rp->graphics_exec_path, graphics_application, rp->slot);
    }
#else
        char* argv[3];
        argv[0] = rp->graphics_exec_path;
        argv[1] = "--fullscreen";
        argv[2] = 0;
        retval = run_program(
            rp->slot_path,
            rp->graphics_exec_path,
            2,
            argv,
            0,
            graphics_application
        );
#endif
    }
    return retval;
}
开发者ID:drshawnkwang,项目名称:boinc,代码行数:52,代码来源:screensaver.cpp

示例5: fsl_dcm_sysfs_info

ssize_t fsl_dcm_sysfs_info(struct device *dev, struct device_attribute *attr,
	char *buf)
{
	struct fsl_dcm_data *dcm = dev_get_drvdata(dev);
	struct om_info info;
	ssize_t len;

	if (!is_sram_available(dcm)) {
		dev_err(dev, "dcm is busy\n");
		return 0;
	}

	if (!run_program(dcm, 0, 3, OM_INFO, DATA_ADDR, OM_END)) {
		dev_err(dev, "could not run 'info' program\n");
		return 0;
	}

	if (!copy_from_sram(dcm, DATA_ADDR, &info, sizeof(info))) {
		dev_err(dev, "could not copy 'info' data\n");
		return 0;
	}

	len = sprintf(buf, "DCM Version: %u\n", info.version);
	len += sprintf(buf + len, "Prescale: %u\n", info.prescale);
	len += sprintf(buf + len, "Timer: %u\n", info.timer);
	len += sprintf(buf + len, "Number of CRECORDs: %u\n", info.count);
	len += sprintf(buf + len, "CRECORD Address: %u\n", info.address);

	return len;
}
开发者ID:sonoble,项目名称:linux-3.8.13,代码行数:30,代码来源:fsl_dcm.c

示例6: stop_data_collection

/*
 * Tells the DCM to stop data collection.  Collected data is copied from
 * SRAM into a local buffer.
 */
int stop_data_collection(struct fsl_dcm_data *dcm)
{
	if (!dcm->running) {
		dev_dbg(dcm->dev, "dcm is already stopped\n");
		return 1;
	}

	if (!is_sram_available(dcm)) {
		dev_err(dcm->dev, "dcm is busy\n");
		return 0;
	}

	if (!run_program(dcm, 0, 4, OM_STOP, OM_GET, DATA_ADDR, OM_END)) {
		dev_err(dcm->dev, "could not stop monitoring\n");
		return 0;
	}

	if (!copy_from_sram(dcm, DATA_ADDR, dcm->rec,
			    dcm->board->num * sizeof(struct crecord))) {
		dev_err(dcm->dev, "could not copy sensor data\n");
		return 0;
	}

	dcm->running = 0;
	return 1;
}
开发者ID:sonoble,项目名称:linux-3.8.13,代码行数:30,代码来源:fsl_dcm.c

示例7: merge_entry

static int merge_entry(int pos, const char *path)
{
	int found;

	if (pos >= active_nr)
		die("git merge-index: %s not in the cache", path);
	arguments[0] = pgm;
	arguments[1] = "";
	arguments[2] = "";
	arguments[3] = "";
	arguments[4] = path;
	arguments[5] = "";
	arguments[6] = "";
	arguments[7] = "";
	arguments[8] = NULL;
	found = 0;
	do {
		static char hexbuf[4][60];
		static char ownbuf[4][60];
		struct cache_entry *ce = active_cache[pos];
		int stage = ce_stage(ce);

		if (strcmp(ce->name, path))
			break;
		found++;
		strcpy(hexbuf[stage], sha1_to_hex(ce->sha1));
		sprintf(ownbuf[stage], "%o", ce->ce_mode);
		arguments[stage] = hexbuf[stage];
		arguments[stage + 4] = ownbuf[stage];
	} while (++pos < active_nr);
	if (!found)
		die("git merge-index: %s not in the cache", path);
	run_program();
	return found;
}
开发者ID:DJHartley,项目名称:git,代码行数:35,代码来源:merge-index.c

示例8: md_cleanup_install

void
md_cleanup_install(void)
{
#ifndef DEBUG
	int new_speed;

	enable_rc_conf();

	/*
	 * Set the console speed in /etc/ttys depending on the board.
	 * The default speed is 115200, which is patched when needed.
	 */
	if (strcmp(prodname, "kurobox") == 0)
		new_speed = 57600;			/* KuroBox */

	else if (strcmp(prodname, "dlink") == 0 ||	/* D-Link DSM-G600 */
	    strcmp(prodname, "nhnas") == 0)		/* NH23x, All6250 */
		new_speed = 9600;

	else
		new_speed = 0;

	if (new_speed != 0) {
		run_program(RUN_CHROOT, "sed -an -e 's/115200/%d/;H;$!d;g;w"
		    "/etc/ttys' /etc/ttys", new_speed);
	}
#endif
}
开发者ID:VargMon,项目名称:netbsd-cvs-mirror,代码行数:28,代码来源:md.c

示例9: run1

/* Run the program PROG with the single argument ARG */
void run1(struct netcf *ncf, const char *prog, const char *arg) {
    const char *const argv[] = {
        prog, arg, NULL
    };

    run_program(ncf, argv, NULL);
}
开发者ID:seanbruno,项目名称:fbsd-netcf,代码行数:8,代码来源:dutil_posix.c

示例10: run_program_block

/* run_program_block - Run a program according to an argument vector, blocking until
 * return 
 * Arguments:
 *      char **argv - argumentvector as usual, first element is the path to the
 *      program to be executed
 * Returns:
 *      int - exit status of program run. Negative returns are errors, positive
 *          are return values of program
 */
int run_program_block(char **argv)
{
    int retval, status, pid;

    s_time start, end;
    time_t run_time;

    retval = gettimeofday(&start, NULL);
    pid = run_program(argv, 0);


    /* Check retval after forking as not to skew results */
    if (retval == -1)
        fprintf(stderr, "Could not get time of day\n");

    /* Wait until child has exited */
    do 
        waitpid(pid, &status, 0);
    while (!WIFEXITED(status) && !WIFSIGNALED(status));
    retval = gettimeofday(&end, NULL);
    if (retval == -1)
        fprintf(stderr, "Could not get time of day\n");

    /* Calculate elapsed time in milliseconds */
    run_time = end.tv_sec*1e6+end.tv_usec - start.tv_sec*1e6 + start.tv_usec;
    run_time /= 1e3;

    printf("#[STAT]# Pid %d stopped executing after %li ms\n", pid, run_time);
    
    return 255 == WEXITSTATUS(status) ? INVALIDARGS : WEXITSTATUS(status);
}
开发者ID:linuxxon,项目名称:ID2206,代码行数:40,代码来源:minish.c

示例11: main

int main(int argc, char **argv)
{
  // Check if at least a program and some final states were given
  if (argc < 3)
    {
      usage(argv[0]);
      exit(0);
    }
  char *tape = NULL;
  unsigned int tape_length = 4096;
  unsigned int position = 0;
  int state = 0;
  struct state_list final_states;
  struct rule_list rules;
  // Set to user-defined length if enough parameters given
  if (argc > 3)
      tape_length = set_tape_length(argv[3]);
  // Set to user-defined initial state if enough parameters given
  if (argc > 4)
      state = set_state(argv[4]);
  // Set to user-defined tape data if enough parameters given or initialize the tape empty
  if (argc > 5)
    init_data_tape(&tape,tape_length,argv[5]);
  else
    init_empty_tape(&tape,tape_length);
  load_program(argv[1],&rules);
  set_final_states(&final_states,argv[2]);
  run_program(tape,position,tape_length,state,&final_states,&rules);
  if (argc > 6)
    save_tape(tape,tape_length,argv[6]);
  return 0;
}
开发者ID:daherb,项目名称:turing,代码行数:32,代码来源:turing.c

示例12: shell

int shell (int argc, char *argv[]) {
  char *s = malloc(INPUT_STRING_SIZE+1);			/* user input string */
  tok_t *t;			/* tokens parsed from input */
  int lineNum = 0;
  int fundex = -1;
  pid_t pid = getpid();		/* get current processes PID */
  pid_t ppid = getppid();	/* get parents PID */
  // pid_t cpid, tcpid, cpgid;

  init_shell();

  printf("%s running as PID %d under %d\n",argv[0],pid,ppid);

  lineNum=0;
  char *cwd = getcwd(NULL, 0);
  fprintf(stdout, "%d [%s]:", lineNum, cwd);
  free(cwd);
  while ((s = freadln(stdin))){
    // printf("%s\n", s);
    char *s_copy;
    asprintf(&s_copy, "%s", s);

    t = getToks(s); /* break the line into tokens */
    fundex = lookup(t[0]); /* Is first token a shell literal */
    if(fundex >= 0) cmd_table[fundex].fun(&t[1]);
    else {
      run_program(t, s_copy);
    }
    ++lineNum;
    cwd = getcwd(NULL, 0);
    fprintf(stdout, "%d [%s]:", lineNum, cwd);
    free(cwd);
  }
  return 0;
}
开发者ID:Dovizu,项目名称:OS-Personal-Projects,代码行数:35,代码来源:shell.c

示例13: open_shell

static void
open_shell(void)
{
	const char *shell;
	struct passwd *pw;

#ifdef __linux__
	const char *sys = rc_sys();

	/* VSERVER and OPENVZ systems cannot really drop to shells */
	if (sys &&
	    (strcmp(sys, "VSERVER") == 0 || strcmp(sys, "OPENVZ") == 0))
	{
		execl("/sbin/halt", "/sbin/halt", "-f", (char *) NULL);
		eerrorx("%s: unable to exec `/sbin/halt': %s",
		    applet, strerror(errno));
	}
#endif

	shell = rc_conf_value("rc_shell");
	/* No shell set, so obey env, then passwd, then default to /bin/sh */
	if (shell == NULL) {
		shell = getenv("SHELL");
		if (shell == NULL) {
			pw = getpwuid(getuid());
			if (pw)
				shell = pw->pw_shell;
			if (shell == NULL)
				shell = "/bin/sh";
		}
	}
	run_program(shell);
}
开发者ID:andrewgregory,项目名称:openrc,代码行数:33,代码来源:rc.c

示例14: qmain

int qmain(int argc, char* argv[]){

  //  char in[80];
  // int answer;
  char *p_buf;
  // char *t;

  if(argc!=2) {
    printf("usage: run <filename>\n");
    exit(1);
  }

  /* allocate memory for the program */
  if(!(p_buf=(char *) malloc(PROG_SIZE))) {
    printf("allocation failure");
    exit(1);
  }
  
  /* load the program to execute */
  if(!load_program(p_buf,argv[1])) exit(1);

  // serror can return here and die
  if(setjmp(e_buf)) exit(1); /* initialize the long jump buffer */

  init_namespace();
  run_program(p_buf);// THIS RUNS THE PROGRAM

  /*  run_program("print \"THIS IS END\"\n");// THIS RUNS THE PROGRAM
  run_program("print 1+2+3+4+5");// THIS RUNS THE PROGRAM
  run_program("print 1.01+2.02+3.03+4.04+5.05");// THIS RUNS THE PROGRAM
  run_program("print \"THIS IS END\"\n");// THIS RUNS THE PROGRAM
  */
  return 0;
}//MAIN-------------------------------
开发者ID:jaromrax,项目名称:calibNR,代码行数:34,代码来源:pb_basic.c

示例15: _swrast_exec_fragment_program

/**
 * Execute the current fragment program for all the fragments
 * in the given span.
 */
void
_swrast_exec_fragment_program( GLcontext *ctx, SWspan *span )
{
   const struct gl_fragment_program *program = ctx->FragmentProgram._Current;

   /* incoming colors should be floats */
   if (program->Base.InputsRead & FRAG_BIT_COL0) {
      ASSERT(span->array->ChanType == GL_FLOAT);
   }

   ctx->_CurrentProgram = GL_FRAGMENT_PROGRAM_ARB; /* or NV, doesn't matter */

   run_program(ctx, span, 0, span->end);

   if (program->Base.OutputsWritten & (1 << FRAG_RESULT_COLR)) {
      span->interpMask &= ~SPAN_RGBA;
      span->arrayMask |= SPAN_RGBA;
   }

   if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) {
      span->interpMask &= ~SPAN_Z;
      span->arrayMask |= SPAN_Z;
   }

   ctx->_CurrentProgram = 0;
}
开发者ID:Starlink,项目名称:mesa,代码行数:30,代码来源:s_fragprog.c


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