示例#1
0
void Interpret(char expr[])
{
  SetIntSignal(True);
  if(commandline(expr))
    ;
  else if(seterror()==0)
  {
    initstack();
    restoretemplates();
    CloseAllIOFiles();
    interrupted = False;
    if(parseinput(expr))
      checkexpression(top(), True);
    else
    {
      checkexpression(top(), False);
      settop(modify_expression(top()));
      starttiming();
      toplevel();
      stoptiming();
    }
  }
  SetIntSignal(False);
  initstack();
  restoretemplates();
  CloseAllIOFiles();
  interrupted = False;
  Write("\n");
}
示例#2
0
文件: amcon.c 项目: remco138/amanda
static void amaobj(char path[], char filename[])
{
  char command[stringsize], s[stringsize], *words[stringsize];
  int k, handle = -1, count;
  bool echo = False;
  
  InitOptions(False, path);
  CreateInterpreter();
  if(!Load(filename) || !InitRemote()) return;
  for(;;)
  {
    getstring(">> ", command);
    if(echo) WriteString(command);
    WriteString("\n");
    count = FindWords(command, words, stringsize);
    if(count == 2 && strcmp(words[0], "object") == 0)
    {
      DropRemote(handle);
      handle = CreateRemote(words[1]);
    }
    else if(count >= 2 && strcmp(words[0], "call") == 0)
    {
      if(handle < 0)
        WriteString("No object selected");
      else
      {
        starttiming();
        for(k=2; k < count; k++) PutRemote(handle, words[k]);
        CallRemote(handle, words[1]);
        WriteString("<\n");
        while(GetRemote(handle, s, stringsize))
        {
          WriteString(s);
          WriteString("\n");
        }
        WriteString(">\n");
        stoptiming();
      }
    }
    else if(count == 1 && strcmp(words[0], "echo") == 0)
      echo = !echo;
    else if(count == 1 && strcmp(words[0], "time") == 0)
      timing = !timing;
    else if(count == 1 && strcmp(words[0], "exit") == 0)
      break;
    else
      WriteString("???\n");
    WriteString("\n");
  }
}