Exemplo n.º 1
0
static void
send_command(char *command,int com_type)
{
    char buf[1024];

    if (com_type != Spadsrc) {
        escape_string(command);
        sprintf(buf, "(|parseAndEvalToHypertex| '\"%s\")", command);
        send_lisp_command(buf);
    }
    else {
        FILE *f;
        char name[512], str[512]/*, *c*/;

        sprintf(name, "/tmp/hyper%s.input", getenv("SPADNUM"));
        f = fopen(name, "w");
        if (f == NULL) {
            fprintf(stderr, "Can't open temporary input file %s\n", name);
            return;
        }
        fprintf(f, "%s", command);
        fclose(f);
        sprintf(str, "(|parseAndEvalToHypertex| '\")read %s\")", name);
        send_lisp_command(str);
    }
}
Exemplo n.º 2
0
static void
killAxiomPage(HyperDocPage * page)
{
    char command[512];

    sprintf(command, "(|htpDestroyPage| '%s)", page->name);
    send_lisp_command(command);
}
Exemplo n.º 3
0
void
verify_record(void)
{
  int i;
  for (i=0;i<input_file_count;i++){
    send_lisp_command("(|clearCmdCompletely|)");
    send_lisp_command("(setq |$testingSystem| T)");
    send_lisp_command("(setq |$printLoadMsgs| NIL)");
    send_lisp_command("(setq |$BreakMode| '|resume|)");
    sprintf(buf_for_record_commands,"(|verifyRecordFile| '\"%s\")",input_file_list[i]);
    fprintf(stderr,"%s\n",buf_for_record_commands);
    send_lisp_command(buf_for_record_commands);
  }
  if (kill_spad) {
    i = connect_spad();
    if (i != NotConnected && i != SpadBusy)
      send_int(spad_socket, KillLispSystem);
  }
}
Exemplo n.º 4
0
/*
 * THEMOS says: There is a problem here in that we issue the (|close|) and
 * then go on. If this is the last command, we will soon send a SIGTERM and
 * the whole thing will collapse maybe BEFORE the writing out has finished.
 * Fix: Call a Lisp function that checks (with \axiomOp{key} ps and grep) the
 * health of the viewport. We do this after the (|close|).
 */
void
get_graph_output(char *command,char *pagename,int com_type)
{
    int n, i;
    char buf[1024];

    send_command(command, com_type);
    n = get_int(spad_socket);
    /* FIXME: this looks crazy */
    for (i = 0; i < n; i++) {
        get_string_buf(spad_socket, buf, 1024);
    }
    sprintf(buf, "(|processInteractive| '(|write| |%s| \"%s%d\" \"image\") NIL)", "%",
            pagename, example_number);
    send_lisp_command(buf);
    send_lisp_command("(|setViewportProcess|)");
    send_lisp_command("(|processInteractive| '(|close| (|%%| -3)) NIL)");
    send_lisp_command("(|waitForViewport|)");
    get_int(spad_socket);
}
Exemplo n.º 5
0
static void
make_input_file_from_page(HyperDocPage *page)
{
  TextNode *node;
  int starting_file = 1,/* i,*/ /*len,*/ ret_val;
  char *buf, buf2[1024], buf3[1024];
  char *b, *c, *com;
  FILE *file = NULL;
  FILE *pfile = NULL;
  static HyperDocPage *op = NULL;

  if (op == page)
    return;
  op = page;
  if (page == NULL)
    return;
  b = make_input_file_name(buf2, page->filename);
  c = make_paste_file_name(buf3, page->filename);
  if (inListAndNewer(b, page->filename)) {
    /* open and prepare the input file */
    file = fopen(b, "a");
    if (file == NULL) {
      fprintf(stderr, "couldn't open output file %s\n", b);
      exit(-1);
    }
    fprintf(file, "\n-- Input for page %s\n", page->name);
    fprintf(file, ")clear all\n\n");

    for (node = page->scrolling; node != NULL; node = node->next)
      if (node->type == Spadcommand || node->type == Spadgraph
          || node->type == Spadsrc) {
        if (starting_file) {
          example_number = 1;
          if (make_patch_files) {
            send_lisp_command("(|clearCmdAll|)");
            send_lisp_command("(|resetWorkspaceVariables|)");
            send_lisp_command("(setq $linelength 55)");
            send_lisp_command("(setq |$printLoadMsgs| NIL)");
            send_lisp_command("(setq |$UserLevel| '|development|)");
            pfile = fopen(c, "a");
            if (pfile == NULL) {
              fprintf(stderr, "couldn't open output file %s\n", c);
              exit(-1);
            }
          }
          starting_file = 0;
        }
        else
          example_number++;
        buf = print_to_string(node->next);
        com = alloc_string(buf);
        fprintf(file, "%s\n", buf);
        fflush(file);
        fprintf(stderr, "writing:\t%s\n", buf);
        include_bf = 1;
        buf = print_to_string(node->next);
        include_bf = 0;
        if (make_patch_files) {
          if (node->type == Spadcommand || node->type == Spadsrc)
            print_paste(pfile, com, buf, page->name, node->type);
          else
            print_graph_paste(pfile, com, buf, page->name, node->type);
        }
      }
    if (!starting_file && make_patch_files) {
      ret_val = fclose(pfile);
      if (ret_val == -1) {
        fprintf(stderr, "couldn't close file %s\n", b);
        exit(-1);
      }
    }
    ret_val = fclose(file);
    if (ret_val == -1) {
      fprintf(stderr, "couldn't close file %s\n", b);
      exit(-1);
    }
  }
}