示例#1
0
void waitCmd()
{
  char* cmd;
  gets(cmd);
  putchar('\n');
  runShell(cmd);
}
示例#2
0
static char*
doDir_assert(char* pzArg, char* pzScan)
{
    switch (*pzArg) {
    case '`':
    {
        char* pzS = pzArg+1;
        char* pzR;

        pzR = strrchr(pzS, '`');
        if (pzR == NULL)
            break; /* not a valid script */

        *pzR = NUL;
        pzS = runShell((char const*)pzS);
        check_assert_str(pzS, pzArg);
        free(pzS);
        break;
    }

    case '(':
    {
        SCM res = ag_scm_c_eval_string_from_file_line(
                      pzArg, pCurCtx->pzCtxFname, pCurCtx->lineNo );

        check_assert_str(resolveSCM(res), pzArg);
        break;
    }

    default:
        break;
    }

    return pzScan;
}
示例#3
0
int main(int argc, char ** argv, char ** envp) {
  char *fullpath = findPath(envp);
  //get the path variables
  char ** path = parse(fullpath, ':');
  //    pointerPrint(path);

  //Run shell
  runShell(path);

  return 0;
}
示例#4
0
void CommandLineFrontend::handleProjectsResolved()
{
    if (m_cancelStatus != CancelStatusNone)
        throw ErrorInfo(Tr::tr("Execution canceled."));
    switch (m_parser.command()) {
    case ResolveCommandType:
        qApp->quit();
        break;
    case CleanCommandType:
        makeClean();
        break;
    case ShellCommandType:
        qApp->exit(runShell());
        break;
    case StatusCommandType:
        qApp->exit(printStatus(m_projects.front().projectData()));
        break;
    case GenerateCommandType:
        checkGeneratorName();
        Q_FALLTHROUGH();
    case BuildCommandType:
        build();
        break;
    case InstallCommandType:
    case RunCommandType:
        if (m_parser.buildBeforeInstalling())
            build();
        else
            install();
        break;
    case UpdateTimestampsCommandType:
        updateTimestamps();
        qApp->quit();
        break;
    case DumpNodesTreeCommandType:
        dumpNodesTree();
        qApp->quit();
        break;
    case ListProductsCommandType:
        listProducts();
        qApp->quit();
        break;
    case HelpCommandType:
    case VersionCommandType:
        Q_ASSERT_X(false, Q_FUNC_INFO, "Impossible.");
    }
}
示例#5
0
int
main(
   int                        argc,
   char**                     argv
   )
{
   SCIP_RETCODE retcode;

   retcode = runShell(argc, argv, "scip.set");
   if( retcode != SCIP_OKAY )
   {
      SCIPprintError(retcode);
      return -1;
   }

   return 0;
}
示例#6
0
/** main method */
int main(
   int                   argc,          /**< number of arguments */
   char**                argv           /**< string array with arguments */
   )
{
  SCIP_RETCODE retcode;

  retcode = runShell(argc, argv, "scip.set");

  if( retcode != SCIP_OKAY )
  {
     SCIPprintError(retcode);
     return -1;
  }

  return 0;
}
示例#7
0
static void refreshDomains(void)
{
	int i,*activeDomains;
	char *domName;
	char shc[50];

	for (i=0; i<MAX_DOMAINS;i++)
	{
		vms[i].dom = NULL;
        vms[i].pid = -1;
        memset(vms[i].ip,0,20*sizeof(char));
	}

	numDomains = virConnectNumOfDomains(conn);
    activeDomains = malloc(sizeof(int) * numDomains);
    numDomains = virConnectListDomains(conn, activeDomains, numDomains);

	if (numDomains==0)
	{
		printf("No active VMs\n");
		return -1;
	}

	for (i = 0 ; i < numDomains ; i++)
	{
		memset(shc,0,50*sizeof(char));

	    vms[i].dom = virDomainLookupByID(conn, activeDomains[i]);
	    domName = virDomainGetName(vms[i].dom);
	    sprintf(shc,"./vm-ip.sh %s", domName);
        pid=0;
	    examineVM(domName);
        vms[i].pid=pid;
        runShell(shc, vms[i].ip, 20);
        printf("Process %d runs the virtual machine %s on IP %s\n ", vms[i].pid, domName, vms[i].ip);
	}
	printf("\n");
    //initVMIFile(numDomains, sysmap);
	free(activeDomains);
}
示例#8
0
void keyboard_handler()
{
	unsigned char scancode;
	//Read from port 60 when handler is called.
	//0x60 is the keyboard key port
	scancode = inportb(0x60);
	//if top bit is set, then key has just been released
	//useful for shifts and control/alt
	if ((scancode & 0x80) != 0 )
	{
		if (scancode == 0xAA || scancode == 0xB6)
		{
			isShift = 0;
			return;
		}
	}
	else
	{
		if (kbdus[scancode] == 91 || kbdus[scancode] == 90)
		{
			isShift = 1;
			return;
		}
		if (isShift != 0)
		{
			terminal_putchar(upperKbdus[scancode]);
		}
		else
			terminal_putchar(kbdus[scancode]);

		if (kbdus[scancode] == '\n')
		{
			runShell();
		}
		//key just pressed down
	}
}
示例#9
0
文件: defLex.c 项目: pexip/os-autogen
static tSuccess
lex_backquote(void)
{
    int line_no = pCurCtx->lineNo;
    char* pz = ao_string_cook(pCurCtx->pzScan, &line_no);

    if (pz == NULL)
        return FAILURE;

    pz_token = pCurCtx->pzScan;

    pCurCtx->pzScan = pz;

    lastToken = DP_EV_STRING;
    pz = runShell((char const*)pz_token);
    pCurCtx->lineNo = line_no;

    if (pz == NULL)
        return PROBLEM;
    TAGMEM(pz, "shell definition string");
    pz_token = pz;
    manageAllocatedData(pz);
    return SUCCESS;
}
示例#10
0
main(){
	runShell();
}
void makeDiffAndSplit(struct commit *c, char *u, boolean full)
/* Generate a full diff and then split it up into its parts.
 * This was motivated because no other way to show deleted files
 * since they are not in repo and git paths must actually exist
 * in working repo dir.  However leaving off the path produces
 * a diff with everything we want, we just have to split it up. */
{
safef(gitCmd,sizeof(gitCmd), 
    "git diff -b -w --no-prefix --unified=%d %s^! > %s"  
    , full ? 1000000 : contextSize
    , c->commitId, tempMakeDiffName);
//git shorthand: x^! is equiv to range x^ x, 
//  i.e. just the one commit and nothing more.

// hack until better fix - this is the case where there is no previous commit
if (sameString(c->commitId, "dc78303b079985b5a146d093bbb8a5d06489562d"))
    {
    safef(gitCmd,sizeof(gitCmd), 
	"git show -b -w --no-prefix --unified=%d %s > %s"  
    , full ? 1000000 : contextSize
	, c->commitId, tempMakeDiffName);
    }

runShell(gitCmd);


// now parse it and split it into separate files with the right path.
struct lineFile *lf = lineFileOpen(tempMakeDiffName, TRUE);
int lineSize;
char *line;
FILE *h = NULL;
while (lineFileNext(lf, &line, &lineSize))
    {
    if (startsWith("diff --git ", line))
	{
	if (h)
	    {
	    fclose(h);
	    h = NULL;
	    }
	char *fpath = line + strlen("diff --git ");
	fpath = strchr(fpath, ' ');
	++fpath;   // now we should be pointing to the world

	char path[1024];
	char *r = strrchr(fpath, '/');
	if (r)
	    {
	    *r = 0;
	    /* make internal levels of subdirs */
	    safef(path, sizeof(path), "mkdir -p %s/%s/%s/%s/%s/%s", outDir, outPrefix, "user", u, full ? "full" : "context", fpath);
	    runShell(path);
	    *r = '/';
	    }
	safef(path, sizeof(path), "%s/%s/%s/%s/%s/%s%s.diff"
	    , outDir, outPrefix, "user", u, full ? "full" : "context", fpath, c->commitId);

	h = mustOpen(path, "w");
	fprintf(h, "%s\n", c->commitId);
	fprintf(h, "%s\n", c->author);
	fprintf(h, "%s\n", c->date);
	fprintf(h, "%s\n", c->comment);
	}
    else if (startsWith("@@", line))
	{
	char *end = strchr(line+2, '@');
	*(end+2) = 0;  // chop the weird unwanted context string from here following e.g. 
        //@@ -99,7 +99,9 @@ weird unwanted context string here
        // converts to
        //@@ -99,7 +99,9 @@
	// saves 17 seconds over the more expensive sed command
	}
    if (h)
	fprintf(h, "%s\n", line);
    }
if (h)
    {
    fclose(h);
    h = NULL;
    }
lineFileClose(&lf);
}
struct commit* getCommits()
/* Get all commits from startTag to endTag */
{
int numCommits = 0;
safef(gitCmd,sizeof(gitCmd), ""
"git log %s..%s --name-status > commits.tmp"
, startTag, endTag);
runShell(gitCmd);
struct lineFile *lf = lineFileOpen("commits.tmp", TRUE);
int lineSize;
char *line;
struct commit *commits = NULL, *commit = NULL;
struct files *files = NULL, *f = NULL;
char *sep = "";
while (lineFileNext(lf, &line, &lineSize))
    {
    boolean isMerge = FALSE;
    char *w = nextWord(&line);
    AllocVar(commit);
    if (!sameString("commit", w))
	errAbort("expected keyword commit parsing commits.tmp\n");
    commit->commitId = cloneString(nextWord(&line));
    commit->commitNumber = ++numCommits;

    lineFileNext(lf, &line, &lineSize);
    w = nextWord(&line);
    if (sameString("Merge:", w))
	{
	isMerge = TRUE;
	lineFileNext(lf, &line, &lineSize);
	w = nextWord(&line);
	}
    if (!sameString("Author:", w))
	errAbort("expected keyword Author: parsing commits.tmp\n");

    /* by request, keep just the email account name */
    char *lc = strchr(line, '<');
    if (!lc)
	errAbort("expected '<' char in email address in Author: parsing commits.tmp\n");
    ++lc;
    char *rc = strchr(lc, '>');
    if (!rc)
	errAbort("expected '>' char in email address in Author: parsing commits.tmp\n");
    char *ac = strchr(lc, '@');
    if (ac)
	rc = ac;
    commit->author = cloneStringZ(lc, rc-lc);

    lineFileNext(lf, &line, &lineSize);
    w = nextWord(&line);
    if (!sameString("Date:", w))
	errAbort("expected keyword Date: parsing commits.tmp\n");
    commit->date = cloneString(line);

    lineFileNext(lf, &line, &lineSize);
    if (!sameString("", line))
	errAbort("expected blank line parsing commits.tmp\n");

    /* collect the comment-lines */
    struct dyString *dy = NULL;
    dy = dyStringNew(0);
    sep = "";
    files = NULL;
    while (lineFileNext(lf, &line, &lineSize))
	{
	if (sameString("", line))
	    break;
	w = skipLeadingSpaces(line);
	dyStringPrintf(dy, "%s%s", w, sep);
	sep = "\n";
	}
    commit->comment = cloneString(dy->string);
    freeDyString(&dy);

    if (!isMerge)
	{
	/* collect the files-list */
	while (lineFileNext(lf, &line, &lineSize))
	    {
	    if (sameString("", line))
		break;
	    AllocVar(f);
	    w = nextWord(&line);
	    f->type = w[0];
	    f->path = cloneString(line);
	    slAddHead(&files, f);
	    }
	slReverse(&files);
	}

    commit->files = files;

    
    if (!isMerge  /* for now, default to filtering out the records for automatic-merges */
        && !endsWith(commit->comment, "elease log update"))  /* filter out automatic release log commits */
	slAddHead(&commits, commit);

    verbose(2, 
 "commitId: %s\n"
 "author: %s\n"
 "date: %s\n"
 "comment: [%s]\n"
 "file(s): \n"
, commit->commitId
, commit->author
, commit->date
, commit->comment);

    for (f=commit->files; f; f = f->next)
	{
    	verbose(2, "%c %s\n", f->type, f->path);

	// anything other than M or A?
	if (f->type != 'M' && f->type != 'A' )
	    verbose(2, "special type: %c %s\n", f->type, f->path);
	}


    verbose(2, "------------\n");

    }
lineFileClose(&lf);
/* We want to keep them chronological order,
so do not need slReverse since the addHead reversed git log's rev chron order already */


unlink("commits.tmp");
return commits;
}
示例#13
0
/*=directive shell
 *
 *  text:
 *  Invokes @code{$SHELL} or @file{/bin/sh} on a script that should
 *  generate AutoGen definitions.  It does this using the same server
 *  process that handles the back-quoted @code{`} text.
 *  @strong{CAUTION}@:  let not your @code{$SHELL} be @code{csh}.
=*/
static char*
doDir_shell(char* pzArg, char* pzScan)
{
    static char const zShellText[] = "Computed Definitions";
    static char const zEndShell[]  = "\n#endshell";

    tScanCtx*  pCtx;
    char*      pzText = pzScan;

    /*
     *  The output time will always be the current time.
     *  The dynamic content is always current :)
     */
    outTime = time(NULL);

    /*
     *  IF there are no data after the '#shell' directive,
     *  THEN we won't write any data
     *  ELSE we have to find the end of the data.
     */
    if (strncmp(pzText, zEndShell+1, STRSIZE(zEndShell)-1) == 0)
        return pzScan;

    {
        static char const noend[] =
            "Missing #endshell after '#shell' in %s on line %d\n";
        char* pz = strstr(pzScan, zEndShell);
        if (pz == NULL)
            AG_ABEND(aprf(noend, pCurCtx->pzCtxFname, pCurCtx->lineNo));

        while (pzScan < pz) {
            if (*(pzScan++) == NL) pCurCtx->lineNo++;
        }

        *pzScan = NUL;
    }

    /*
     *  Advance the scan pointer to the next line after '#endshell'
     *  IF there is no such line,
     *  THEN the scan will resume on a zero-length string.
     */
    pzScan = strchr(pzScan + STRSIZE(zEndShell), NL);
    if (pzScan == NULL)
        pzScan = (void*)zNil;

    /*
     *  Save the scan pointer into the current context
     */
    pCurCtx->pzScan  = pzScan;

    /*
     *  Run the shell command.  The output text becomes the
     *  "file text" that is used for more definitions.
     */
    pzText = runShell(pzText);
    if (pzText == NULL)
        return pzScan;

    if (*pzText == NUL) {
        AGFREE(pzText);
        return pzScan;
    }

    /*
     *  Get the space for the output data and for context overhead.
     *  This is an extra allocation and copy, but easier than rewriting
     *  'loadData()' for this special context.
     */
    pCtx = (tScanCtx*)AGALOC(sizeof(tScanCtx) + strlen(pzText) + 4,
                             "shell output");

    /*
     *  Link the new scan data into the context stack
     */
    pCtx->pCtx       = pCurCtx;
    pCurCtx          = pCtx;

    /*
     *  Set up the rest of the context structure
     */
    AGDUPSTR(pCtx->pzCtxFname, zShellText, "shell text");
    pCtx->pzScan     =
        pCtx->pzData     = (char*)(pCtx+1);
    pCtx->lineNo     = 0;
    strcpy(pCtx->pzScan, pzText);
    AGFREE(pzText);

    return pCtx->pzScan;
}