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


C++ runcmd函数代码示例

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


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

示例1: setacl

static void setacl(int index, int zoom, int x, int y)
{
	LOGI("%i: zoom=%i, x=%i, y=%i", index, zoom, x, y);

	char cmd[256];
	if(g_mode == MODE_NED)
	{
		snprintf(cmd, 256, "gsutil acl set -a public-read gs://goto/ned/%i/%i_%i.nedgz", zoom, x, y);
		runcmd(cmd);
	}
	else if(g_mode == MODE_OSM)
	{
		snprintf(cmd, 256, "gsutil acl set -a public-read gs://goto/osm/%i/%i_%i.pak", zoom, x, y);
		runcmd(cmd);
	}
	else if(g_mode == MODE_HEIGHTMAP)
	{
		snprintf(cmd, 256, "gsutil acl set -a public-read gs://goto/hillshade/%i/%i_%i.pak", zoom, x, y);
		runcmd(cmd);
	}
	else if(g_mode == MODE_BLUEMARBLE)
	{
		int month;
		for(month = 1; month <= 12; ++month)
		{
			snprintf(cmd, 256, "gsutil acl set -a public-read gs://goto/bluemarble/%i/%i/%i_%i.pak", month, zoom, x, y);
			runcmd(cmd);
		}
	}
}
开发者ID:jeffboody,项目名称:nedgz,代码行数:30,代码来源:setacl.c

示例2: __read

static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
	if (!fd || !fd->data) {
		return -1;
	}
	int wordSize = 4;
	ut32 *w = (ut32*)buf;
	int i;
	memset (buf, 0xff, count);
	int words = count / wordSize; // XXX must pad align to 4
	for (i = 0; i < words ; i++) {
		ut64 addr = io->off + (i * wordSize);
		char *cmd = r_str_newf ("x 0x%"PFMT64x, addr);
		char *res = runcmd (cmd);
		sscanf (res, "%x", &w[i]);
		free (res);
		free (cmd);
	}

	int left = count % wordSize;
	if (left > 0) {
		ut32 n = 0xff;
		ut8 *wn = (ut8*)&n;
		ut64 addr = io->off + (i * wordSize);
		char *cmd = r_str_newf ("x 0x%"PFMT64x, addr);
		char *res = runcmd (cmd);
		sscanf (res, "%x", &n);
		free (res);
		free (cmd);
		memcpy (buf + (words * wordSize), wn, left);
	}
	return count;
}
开发者ID:dtrecherel,项目名称:radare2,代码行数:32,代码来源:io_winedbg.c

示例3: runcmd

void runcmd(struct cmd *cmd)
{
  int p[2];
  struct execcmd *ecmd;
  struct pipecmd *pcmd;
  struct redircmd *rcmd;

  if(cmd == 0)
    exit(1);
  
  switch(cmd->type){
  default:
    printf("runcmd error!\n");

  case 1:
    ecmd = (struct execcmd*)cmd;
    if(ecmd->argv[0] == 0)
      exit(0);
    execvp(ecmd->argv[0], ecmd->argv);
    printf("exec %s failed\n", ecmd->argv[0]);
    break;

  case 2:
    rcmd = (struct redircmd*)cmd;
    close(rcmd->fd);
    if(open(rcmd->file, rcmd->mode) < 0){
      printf("open %s failed\n", rcmd->file);
      exit(0);
    }
    runcmd(rcmd->cmd);
    break;

  case 3:
    pcmd = (struct pipecmd*)cmd;
    if(pipe(p) < 0){
      printf("Errors in pipe!\n");
    }
    if(fork() == 0){
      close(1);
      dup(p[1]);
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->right);
    }
    if(fork() == 0){
      close(0);
      dup(p[0]);
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->left);
    }
    close(p[1]);
    close(p[0]);
    wait(NULL);
    wait(NULL);
    break;
  }
  exit(0);
}
开发者ID:moodfamily,项目名称:CMPT332_a1_Shell,代码行数:59,代码来源:myshell.c

示例4: init_judge_environment

void init_judge_environment(int RunID, int language, char *workdir)
{
    sprintf(workdir, "%s/run%d", oj_home, RunID);
    runcmd("rm %s/errmsg/%d.err", oj_home, RunID);
    runcmd("rm -r %s", workdir);
    runcmd("mkdir %s", workdir);   
    runcmd("cp %s/code/%d %s/%s", oj_home, RunID, workdir, codename[language]);
}
开发者ID:PiraHzq,项目名称:pjudge,代码行数:8,代码来源:judge.c

示例5: main

int
main(void)
{
  static char buf[100];
  static char bufCNM[100];
  int fd;
  
  // Assumes three file descriptors open.
  while((fd = open("console", O_RDWR)) >= 0){
    if(fd >= 3){
      close(fd);
      break;
    }
  }
  
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        printf(2, "cannot cd %s\n", buf+3);
      else{
        if((buf + 3)[0] == '.' && (buf + 3)[1] == '.' && (buf + 3)[2] == 0){
            cutChild(currentDir);
            if(currentDir[0] == 0) isRootDir = 1;
            continue;
        }
        if(isRootDir){
            catenate(currentDir, buf + 3);
            isRootDir = 0;
        }
        else{
            append(currentDir, '/');
            catenate(currentDir, buf + 3);
        }
      }
      continue;
    }

    if(fork1() == 0) {
      int i;
      int len = strlen(buf);
      for(i = len + 1; i > 0; i--) {
        bufCNM[i] = buf[i-1];        
      }   
      bufCNM[0] = '/';
      runcmd(parsecmd(buf));
      if(buf[0] != '/') {
        runcmd(parsecmd(bufCNM));
      }
      exit();
    }
    wait();
  }
  exit();
}
开发者ID:lishuwnc,项目名称:Xv6,代码行数:58,代码来源:sh.c

示例6: preparefiles

void preparefiles(char *dname, int len, char *workdir, char *datapath)
{
    char name[MAXLINE+1];
    strncpy(name, dname, len);
    name[len]='\0';
#ifdef DEBUG
    logerrmsg(judgelog, "name:#%s# %d copy %s/%s.in to %s/data.in", dname, len, datapath, name, workdir);
#endif
    runcmd("cp -a %s/%s.in %s/data.in", datapath, name, workdir);
    runcmd("cp -a %s/%s.out %s/data.out", datapath, name, workdir);
}
开发者ID:PiraHzq,项目名称:pjudge,代码行数:11,代码来源:judge.c

示例7: runcmd

// Execute cmd.  Never returns.
void
runcmd(struct cmd *cmd)
{
    int p[2], r;
    struct execcmd *ecmd;
    struct pipecmd *pcmd;
    struct redircmd *rcmd;
    
    if(cmd == 0)
        exit(0);
    
    switch(cmd->type){
        default:
            fprintf(stderr, "unknown runcmd\n");
            exit(-1);
            
        case ' ':
            ecmd = (struct execcmd*)cmd;
            if(ecmd->argv[0] == 0)
                exit(0);
            execvp(ecmd->argv[0], ecmd->argv);
            break;
        case '>':
        case '<':
            rcmd = (struct redircmd*)cmd;
            int is_out = cmd->type == '>';
            FILE* f = is_out ? freopen(rcmd->file, "w+", stdout) : freopen(rcmd->file, "r", stdin);
            runcmd(rcmd->cmd);
            fclose(f);
            close(fileno(f));
            break;
        case '|':
            pcmd = (struct pipecmd*)cmd;
            pipe(p);
            if (0 == fork()) {
                close(p[1]);
                close(0);
                dup(p[0]);
                runcmd(pcmd->right);
                exit(0);
            } else {
                close(p[0]);
                close(1);
                dup(p[1]);
                runcmd(pcmd->left);
                int r;
                wait(&r);
            }
            break;
    }
    exit(0);
}
开发者ID:molikto,项目名称:ExercisesAndCourses,代码行数:53,代码来源:sh.c

示例8: main

int
main(void)
{
  static char buf[100];
  int fd, r;

  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        fprintf(stderr, "cannot cd %s\n", buf+3);
      continue;
    }
    /* also clumsy: can't use exit* programs, but ok since not 
      traversing PATH anyway.*/
    if(!strncmp(buf, "exit", 4)) {
	exit(0);
    }
    if(fork1() == 0)
      runcmd(parsecmd(buf));
    wait(&r);
  }
  exit(0);
}
开发者ID:dcashman,项目名称:Coursework,代码行数:27,代码来源:sh.c

示例9: main

int main(int argc, char* argv[])
{
    static char buf[BUFSIZ];
    int fd;

    whitespace = " \t\r\n\v";
    symbols = "<|>&;()";

    if (argc == 2 && !strcmp(argv[1], "-i"))
        interactive = 1;

    // Assumes three file descriptors open.
    while ((fd = open("/dev/console", O_RDWR)) >= 0) {
        if (fd >= 3) {
            close(fd);
            break;
        }
    }

    // Read and run input commands.
    while (getcmd(buf) >= 0) {
        if (!memcmp(buf, "cd ", 3)) {
            // Clumsy but will have to do for now.
            // Chdir has no effect on the parent if run in the child.
            if (chdir(buf + 3) < 0)
                dprintf(2, "cannot cd %s\n", buf + 3);
            continue;
        } else if (!strcmp(buf, "exit"))
            return 0; // XXX should allow return code (exit [n])
        if (fork1() == 0)
            runcmd(parsecmd(buf));
        wait();
    }
    return 0;
}
开发者ID:JianxinMa,项目名称:v9.js,代码行数:35,代码来源:sh.c

示例10: umain

void
umain(int argc, char **argv)
{
	int r, interactive, echocmds;

	interactive = '?';
	echocmds = 0;
	ARGBEGIN{
	case 'd':
		debug++;
		break;
	case 'i':
		interactive = 1;
		break;
	case 'x':
		echocmds = 1;
		break;
	default:
		usage();
	}ARGEND

	if (argc > 1)
		usage();
	if (argc == 1) {
		close(0);
		if ((r = open(argv[0], O_RDONLY)) < 0)
			panic("open %s: %e", argv[0], r);
		assert(r == 0);
	}
	if (interactive == '?')
		interactive = iscons(0);
	
	while (1) {
		char *buf;

		buf = readline(interactive ? "$ " : NULL);
		if (buf == NULL) {
			if (debug)
				cprintf("EXITING\n");
			exit();	// end of file
		}
		if (debug)
			cprintf("LINE: %s\n", buf);
		if (buf[0] == '#')
			continue;
		if (echocmds)
			printf("# %s\n", buf);
		if (debug)
			cprintf("BEFORE FORK\n");
		if ((r = fork()) < 0)
			panic("fork: %e", r);
		if (debug)
			cprintf("FORK: %d\n", r);
		if (r == 0) {
			runcmd(buf);
			exit();
		} else
			wait(r);
	}
}
开发者ID:AkshayRShukla,项目名称:mit-jos,代码行数:60,代码来源:sh.c

示例11: main

int
main(void)
{
  static char buf[100];
  int fd, r;

  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        fprintf(stderr, "cannot cd %s\n", buf+3);
      continue;
    }
    if(strncmp(buf, "exit", 4) == 0) {
      fprintf(stdout, "Exit, good bye.\n");
      exit(0);
    }
    if(fork1() == 0)
      runcmd(parsecmd(buf));
    wait(&r);
  }
  exit(0);
}
开发者ID:yycsysu,项目名称:Operating-systems-6.828,代码行数:26,代码来源:sh.c

示例12: main

int
main(void)
{
  static char buf[100];
  int fd;

  // Assumes three file descriptors open.
  while((fd = open("console", O_RDWR)) >= 0) {
    if(fd >= 3){
      close(fd);

      break;
    }
  }

  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0) {
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        printf(2, "cannot cd %s\n", buf+3);
      continue;
    } else if(buf[0] == 'v' && buf[1] == 'e' && buf[2] == 'r' && buf[3] == 's' && buf[4] == 'i' && buf[5] == 'o' && buf[6] == 'n')
    	printf(1, "uNIX Version 0-1 \n Build Version 3");

    if(fork1() == 0)
      runcmd(parsecmd(buf));
    wait();
  }
  exit();
}
开发者ID:DylanEHolland,项目名称:Operating_Systems,代码行数:33,代码来源:sh.c

示例13: run

void
run(void)
{
	fd_set fs;
	int code;
	char **c;
	struct inotify_event ev;

	for (;;) {
		FD_ZERO(&fs);
		FD_SET(notfd, &fs);
		if (select(notfd+1, &fs, 0, 0, 0)==-1) {
			if (errno==EINTR || errno==EAGAIN)
				continue;
			perror("select");
			exit(1);
		}
		read(notfd, &ev, sizeof ev);
		if (ev.mask & IN_IGNORED
		&& inotify_add_watch(notfd, texfile, IN_MODIFY)==-1) {
			perror("inotify_add_watch");
			exit(1);
		}
		for (c=compile; *c; c++)
			if ((code=runcmd(*c))) {
				fprintf(stderr, "Command %s failed (%d)!\n",
					*c, code);
				break;
			}
//		if (code==0 && runcmd(reloadcmd)) {
//		err("Cannot sync xpdf, exiting");
//			exit(1);
//		}
	}
}
开发者ID:Telemin,项目名称:texwatch,代码行数:35,代码来源:texwatch.c

示例14: regState

static struct winedbg_x86_32 regState() {
	struct winedbg_x86_32 r = {0};
	char *res = runcmd ("info reg");
	if (res) {
		char *line = strstr (res, "EIP:");
		if (line) {
			ut32 eip, esp, ebp, eflags;
			(void)sscanf (line, "EIP:%08x ESP:%08x EBP:%08x EFLAGS:%08x",
				&eip, &esp, &ebp, &eflags);
			r.eip = eip;
			r.esp = esp;
			r.ebp = ebp;
			r.eflags = eflags;
			line = strstr (line, "EAX:");
			if (line) {
				ut32 eax, ebx, ecx, edx;
				(void)sscanf (line, "EAX:%08x EBX:%08x ECX:%08x EDX:%08x",
					&eax, &ebx, &ecx, &edx);
				r.eax = eax;
				r.ebx = ebx;
				r.ecx = ecx;
				r.edx = edx;
				line = strstr (line, "ESI:");
				if (line) {
					ut32 esi, edi;
					(void)sscanf (line, "ESI:%08x EDI:%08x", &esi, &edi);
					r.esi = esi;
					r.edi = edi;
				}
			}
		}
		free (res);
	}
	return r;
}
开发者ID:dtrecherel,项目名称:radare2,代码行数:35,代码来源:io_winedbg.c

示例15: R_EditFiles

/* As from R 2.7.0 we assume file, editor are in UTF-8 */
int R_EditFiles(int nfile, const char **file, const char **title,
		const char *editor)
{
    int   i;
    char  buf[1024];

    if (nfile > 0) {
	if (editor == NULL || strlen(editor) == 0)
	    editor = "internal";
	for (i = 0; i < nfile; i++) {
	    if (!strcmp(editor, "internal")) {
		Rgui_Edit(file[i], CE_UTF8, title[i], 0);
	    } else {
		/* Quote path if necessary */
		if (editor[0] != '"' && Rf_strchr(editor, ' '))
		    snprintf(buf, 1024, "\"%s\" \"%s\"", editor, file[i]);
		else
		    snprintf(buf, 1024, "%s \"%s\"", editor, file[i]);
		runcmd(buf, CE_UTF8, 0, 1, NULL, NULL, NULL);
	    }

	}
	return 0;
    }
    return 1;
}
开发者ID:csilles,项目名称:cxxr,代码行数:27,代码来源:system.c


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