예제 #1
0
파일: sockio-c.c 프로젝트: oldk1331/fricas
char *
sock_get_string_buf(int purpose, char * buf, int buf_len)
{
  if (accept_if_needed(purpose) != -1)
    return get_string_buf(purpose_table[purpose], buf, buf_len);
  return NULL;
}
static
String_buf read_mace4_input(FILE *fp)
{
  char line[1000], *s;  /* the first 999 chars of the line */
  String_buf sb = get_string_buf();
  BOOL ok = FALSE;

  s = fgets(line, 1000, fp);
  while (s && !substring("==== end of input", s)) {
    if (!ok && (initial_substring("clauses(", s) ||
		initial_substring("formulas(", s))) {
      if (sb_size(sb) != 0)
	sb_append(sb, "\n");  /* no newline before first list */
      ok = TRUE;
    }
    
    if (ok) {
      sb_append(sb, s);
      if (initial_substring("end_of_list.", s))
	ok = FALSE;
    }
      
    s = fgets(line, 1000, fp);
  }

  if (!s)
    fatal_error("read_mace4_input, \"==== end of input\" not found");

  return sb;
}  /* read_mace4_input */
예제 #3
0
/* PUBLIC */
char *term_to_string(Term t)
{
  char *s;
  String_buf sb = get_string_buf();
  sprint_term(sb, t);
  s = sb_to_malloc_string(sb);
  zap_string_buf(sb);
  return s;
}  /* term_to_string */
예제 #4
0
파일: htinp.c 프로젝트: bfauser/fricas
void
get_spad_output(FILE *pfile,char *command,int com_type)
{
    int n, i;
    char buf[1024];

    send_command(command, com_type);
    n = get_int(spad_socket);
    for (i = 0; i < n; i++) {
        get_string_buf(spad_socket, buf, 1024);
        fprintf(pfile, "%s\n", buf);
    }
    unescape_string(command);
}
예제 #5
0
파일: htinp.c 프로젝트: bfauser/fricas
/*
 * 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);
}
static
String_buf read_next_section(FILE *fp)
{
  char line[1000], *s;  /* the first 999 chars of the line */
  String_buf sb = get_string_buf();
  BOOL ok = FALSE;

  s = fgets(line, 1000, fp);
  while (s && !substring("==== end of ", s)) {
    if (ok)
      sb_append(sb, s);
    else if (initial_substring("====", s))
      ok = TRUE;
    s = fgets(line, 1000, fp);
  }

  if (!s)
    fatal_error("read_next_section, \"==== end of \" not found");

  return sb;
}  /* read_next_section */
/* PUBLIC */
void fwrite_clause_jmap(FILE *fp, Topform c, int format, I3list map)
			
{
  if (c == NULL)
    fprintf(fp, "fwrite_clause_jmap: NULL clause\n");
  else {
    String_buf sb = get_string_buf();
    if (format == CL_FORM_XML)
      sb_xml_write_clause_jmap(sb, c, map);
    else if (format == CL_FORM_IVY)
      sb_ivy_write_clause_jmap(sb, c, map);

    /* BV(2007-aug-20): tagged proof format */
    else if (format == CL_FORM_TAGGED)
      sb_tagged_write_clause_jmap(sb, c, format, map);

    else
      sb_write_clause_jmap(sb, c, format, map);
    fprint_sb(fp, sb);
    zap_string_buf(sb);
  }
  fflush(fp);
}  /* fwrite_clause_jmap */
예제 #8
0
파일: event.c 프로젝트: billpage/open-axiom
void
get_new_window()
{

    int val;
    char buf[128];
    int frame;
    Window wid;
    HDWindow *htw;
    HyperDocPage *hpage;


    /*
     * If I am going to try and start a new window, then I should make sure I
     * have a coonection to listen on
     *
     * BUT This code is entered when a socket selects
     *
     * if (spad_socket == NULL) { spad_socket =
     * connect_to_local_server(SpadServer, MenuServer, 10); if (spad_socket
     * == NULL) { fprintf(stderr, "Get_new_window: Couldn't Connect to
     * SpadServer\n"); return -1; } }
     *
     */


    frame = get_int(spad_socket);
    val = get_int(spad_socket);
    switch (val) {
      case StartPage:
        init_top_window(NULL);
        val = get_int(spad_socket);
        init_scanner();
        input_type = SourceInputKind::SpadSocket;
        input_string = "";
        gWindow->page = parse_page_from_socket();
        gWindow->fAxiomFrame = frame;
        XFlush(gXDisplay);
        break;
      case LinkToPage:
        get_string_buf(spad_socket, buf, 128);
        if (init_top_window(buf) == -1) {
            fprintf(stderr, "get_new_window: Did not find page %s\n", buf);
            /* return -1; */
        }
        gWindow->fAxiomFrame = frame;
        break;
      case PopUpPage:
        val = get_int(spad_socket);
        init_form_window(NULL, val);
        send_int(spad_socket, gWindow->fMainWindow);
        init_scanner();
        input_type = SourceInputKind::SpadSocket;
        input_string = "";
        gWindow->page = parse_page_from_socket();
        compute_form_page(gWindow->page);

        XMapWindow(gXDisplay, gWindow->fMainWindow);

        gWindow->fWindowHashTable = gWindow->page->fLinkHashTable;
        gWindow->fAxiomFrame = frame;
        XFlush(gXDisplay);
        break;
      case PopUpNamedPage:
        val = get_int(spad_socket);
        get_string_buf(spad_socket, buf, 128);

        if (init_form_window(buf, val) == -1) {
            send_int(spad_socket, -1);
            break;
        }
        load_page(gWindow->page);
        compute_form_page(gWindow->page);

        XMapWindow(gXDisplay, gWindow->fMainWindow);

        gWindow->fWindowHashTable = gWindow->page->fLinkHashTable;
        gWindow->fAxiomFrame = frame;
        XFlush(gXDisplay);
        send_int(spad_socket, gWindow->fMainWindow);
        /* fprintf(stderr, "Window Id was %d\n", gWindow->fMainWindow); */
        break;
      case ReplaceNamedPage:
        wid = (Window) get_int(spad_socket);
        get_string_buf(spad_socket, buf, 128);

        htw = (HDWindow *) hash_find(&gSessionHashTable,(char *)&wid);
        if (htw == NULL) break;
        hpage = (HyperDocPage *) hash_find(gWindow->fPageHashTable, buf);
        if (hpage == NULL) break;
        gWindow = htw;
        gWindow->page = hpage;
        display_page(gWindow->page);
        gWindow->fWindowHashTable = gWindow->page->fLinkHashTable;
        clear_exposures(gWindow->fMainWindow);
        clear_exposures(gWindow->fScrollWindow);
        XFlush(gXDisplay);
        break;
      case ReplacePage:
        wid = (Window) get_int(spad_socket);
        set_window(wid);
        init_scanner();
        input_type = SourceInputKind::SpadSocket;
        input_string = "";
        gWindow->page = parse_page_from_socket();
        display_page(gWindow->page);
        gWindow->fWindowHashTable = gWindow->page->fLinkHashTable;
        clear_exposures(gWindow->fMainWindow);
        clear_exposures(gWindow->fScrollWindow);
        XFlush(gXDisplay);
        break;
      case KillPage:
        /* Here the user wishes to kill the page */
        wid = (Window) get_int(spad_socket);
        htw = (HDWindow *) hash_find(&gSessionHashTable,(char *)&wid);
        if (htw !=NULL) {
            gWindow = htw;
            exitHyperDoc();
            break;
          }
        break;
    }
}
/* PUBLIC */
String_buf init_string_buf(char *s)
{
  String_buf p = get_string_buf();
  sb_append(p, s);
  return(p);
}  /* init_string_buf */