/* Parse the input string statement * */
void
parse_inputstring(void)
{
  TextNode *input_node = curr_node;
  char *name;
  InputItem *item;
  int size;
  char *default_value;

  gStringValueOk = 0;

  /* first get the name */
  input_node->type = token.type;
  get_expected_token(openaxiom_Lbrace_token);
  name = get_input_string();
  input_node->data.text = alloc_string(name);
  /* now get the width */
  get_expected_token(openaxiom_Lbrace_token);
  get_expected_token(openaxiom_Word_token);
  get_expected_token(openaxiom_Rbrace_token);
  size = atoi(token.id);
  if (size < 0) {
    fprintf(stderr, "Illegal size in Input string\n");
    longjmp(jmpbuf, 1);
  }

  /* get the default value */
  get_expected_token(openaxiom_Lbrace_token);
  default_value = get_input_string();

  /** now I need to malloc space for the input stuff **/
  item = (InputItem *) halloc(sizeof(InputItem), "InputItem");

  /* Now store all the string info */
  item->name = (char *)
    halloc((strlen(input_node->data.text) + 1) * (sizeof(char)),"parse_inputstring");
  strcpy(item->name, input_node->data.text);
  item->size = size;
  item->entered = 0;
  item->next = NULL;
  initialize_default(item, default_value);

  /** Now that I have all the structures made, lets make the window, and
    add the item to the list                                 ****/

  input_node->link = make_input_window(item);
  if (!make_input_file)
    item->win = input_node->link->win;      /* TTT */
  insert_item(item);
  gStringValueOk = 1;
  curr_node = input_node;
  return ;
}
void
parse_pastebutton(void)
{
    PasteNode *paste;
    TextNode *pb;

    /*
     * this routine parse a \pastebutton expression. The syntax is
     * \pastebutton{name}
     */
    pb = curr_node;
    pb->type = openaxiom_Pastebutton_token;

    /* first thing I should do is get the name */
    get_token();
    if (token.type != openaxiom_Lbrace_token) {
        fprintf(stderr, "(HyperDoc) \\pastebutton needs a name\n");
        print_page_and_filename();
        print_next_ten_tokens();
        jump();
    }
    pb->data.text = alloc_string(get_input_string());

    /*
     * now I should see if the paste area has already been parsed, and if not
     * I should create a spot in the hash table for it
     */
    paste = (PasteNode *) hash_find(gWindow->fPasteHashTable, pb->data.text);
    if (paste == 0) {
        paste = alloc_paste_node(pb->data.text);
        hash_insert(gWindow->fPasteHashTable,(char *) paste, paste->name);
    }
    else if (paste->hasbutton) {
        fprintf(stderr, "(HyperDoc) Tried to redefine paste area %s\n", paste->name);
        print_page_and_filename();
        /* jump(); */
    }
    paste->hasbutton = 1;

    /* Now we need to parse the HyperDoc and for the displayed text */

    get_token();
    if (token.type != openaxiom_Lbrace_token) {
        fprintf(stderr, "(HyperDoc) \\pastebutton was expecting a { \n");
        print_page_and_filename();
        print_next_ten_tokens();
        jump();
    }
    pb->next = alloc_node();
    curr_node = pb->next;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endpastebutton_token;

    /* once that is done I need only make the window for this link */
    pb->link = make_paste_window(paste);
}
static void
authentication_callback (gconstpointer in, gsize in_size,
			 gpointer out, gsize out_size,
			 gpointer user_data)
{
 	MateVFSModuleCallbackAuthenticationIn *in_real;
 	MateVFSModuleCallbackAuthenticationOut *out_real;

 	g_return_if_fail (sizeof (MateVFSModuleCallbackAuthenticationIn) == in_size
 		&& sizeof (MateVFSModuleCallbackAuthenticationOut) == out_size);

	g_return_if_fail (in != NULL);
	g_return_if_fail (out != NULL);

 	in_real = (MateVFSModuleCallbackAuthenticationIn *)in;
 	out_real = (MateVFSModuleCallbackAuthenticationOut *)out;
	
	printf ("Authenticate for uri: %s realm: %s\n", in_real->uri, in_real->realm);

	out_real->username = get_input_string ("Username:\n");
	out_real->password = get_input_string ("Password:\n");
}
    static void
    declare_io(const ecto::tendrils& p, ecto::tendrils& inputs, ecto::tendrils& outputs)
    {
        unsigned int ninput = p.get<unsigned int>("n_inputs");
        //inputs
        for (unsigned int i = 0; i < ninput; i++)
        {
            inputs.declare<std::vector<PoseResult> >(get_input_string("pose_results", i),
                    "The results of object recognition");
        }

        //output
        outputs.declare(&Aggregator::output_pose_results_, "pose_results", "The results of object recognition");
    }
Exemple #5
0
void
parse_input_pix(void)
{
    TextNode *pixnode;
    char *filename;

    pixnode = curr_node;
    pixnode->type = token.type;
    pixnode->space = token.id[-1];
    pixnode->width = -1;
    get_expected_token(Lbrace);
    filename = get_input_string();
    pixnode->data.text = alloc_string(filename);
    curr_node = pixnode;
    if (pixnode->type == Inputimage) {
        char f[256];
        char *p;

        if ((gXDisplay && DisplayPlanes(gXDisplay, gXScreenNumber) == 1) || gSwitch_to_mono ==1) {
            pixnode->type = Inputbitmap;
            strcpy(f, pixnode->data.text);
            strcat(f, ".bm");
            p=pixnode->data.text;
            pixnode->data.text = alloc_string(f);
            free(p);
        }
        else {
            pixnode->type = Inputpixmap;
            strcpy(f, pixnode->data.text);
#ifdef OLD
            strcat(f, ".pm");
#endif
            strcat(f, ".xpm");
            p=pixnode->data.text;
            pixnode->data.text = alloc_string(f);
            free(p);
        }
    }
}
Exemple #6
0
void
parse_help(void)
{
    curr_node->type = Noop;
    get_token();
    if (token.type != Lbrace) {
        token_name(token.type);
        fprintf(stderr, "\\helppage was expecting a { and not a %s\n", ebuffer);
        print_page_and_filename();
        jump();
    }

/* before we clobber this pointer we better free the contents (cf. alloc_page) */
    free(gPageBeingParsed->helppage);
    gPageBeingParsed->helppage = alloc_string(get_input_string());

    if (token.type != Rbrace) {
        token_name(token.type);
        fprintf(stderr, "\\helppage was expecting a } and not a %s\n",
                ebuffer);
        print_page_and_filename();
        jump();
    }
}
Exemple #7
0
void
parse_value2(void)
{
    TextNode *value_node, *ocn = curr_node;
    char *s;

    curr_node->type = token.type;
    curr_node->space = token.id[-1];

    value_node = alloc_node();
    value_node->type = Word;
    curr_node->data.node = value_node;
    get_expected_token(Lbrace);
    s = get_input_string();
    if (!is_number(s)) {
        fprintf(stderr,
           "Parser Error: parse for value was expecting a numeric value\n");
        strcpy(value_node->data.text, "1");
    }
    else {
        value_node->data.text = alloc_string(s);
    }
    curr_node = ocn;
}
 void
 configure(const ecto::tendrils& p, const ecto::tendrils& in, const ecto::tendrils& out)
 {
     for (unsigned int i = 0; i < in.size(); i++)
         input_pose_results_.push_back(in[get_input_string("pose_results", i)]);
 }
void
parse_paste(void)
{
    TextNode *pn = curr_node;
    PasteNode *paste;
    int where;

    if (gParserRegion != Scrolling) {
        fprintf(stderr, "(HyperDoc) Paste areas are only allowed in the scrolling area:");
        print_page_and_filename();
        jump();
    }
    gInPaste++;

    /* now I need to get the name */
    get_token();
    if (token.type != openaxiom_Lbrace_token) {
        fprintf(stderr, "(HyperDoc) A paste area needs a name:\n");
        print_next_ten_tokens();
        print_page_and_filename();
        jump();
    }
    pn->data.text = alloc_string(get_input_string());
    pn->type = openaxiom_Paste_token;

    /*
     * now see if there is already an entry in the hash_table for this thing,
     * if not create it and put it there.
     */
    paste = (PasteNode *) hash_find(gWindow->fPasteHashTable, pn->data.text);
    if (paste == 0) {
        paste = alloc_paste_node(pn->data.text);
        hash_insert(gWindow->fPasteHashTable, (char *)paste, paste->name);
    }
    else if (paste->haspaste) {
        fprintf(stderr, "(HyperDoc) Tried to redefine paste area %s\n", paste->name);
        print_page_and_filename();
        /* jump(); */
    }
    paste->haspaste = 1;
    paste->paste_item = current_item();
    get_token();
    if (token.type == openaxiom_Lsquarebrace_token) {
        /* user wishes to specify a where to send the command */
        where = get_where();
        if (where == -1) {
            paste->where = -1;
            fprintf(stderr, "(HyperDoc) \\begin{paste} was expecting [lisp|unix|ht]\n");
            print_next_ten_tokens();
            print_page_and_filename();
            jump();
        }
        else
            paste->where = where;
        get_token();
    }
    else
        paste->where = openaxiom_FromFile_input;

    /* now try to get the command argument or page name */
    if (token.type != openaxiom_Lbrace_token) {
        paste->where = 0;
        fprintf(stderr, "(HyperDoc) \\begin{paste} was expecting an argument\n");
        print_next_ten_tokens();
        print_page_and_filename();
        jump();
    }
    paste->arg_node = alloc_node();
    curr_node = paste->arg_node;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endarg_token;

    gWindow->fDisplayedWindow = gWindow->fScrollWindow;

    /* Now try to find the displaying text */
    pn->next = alloc_node();
    curr_node = pn->next;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endpaste_token;
    paste->end_node = curr_node;

    paste->begin_node = pn;
    gInPaste--;
}
Exemple #10
0
void
parse_radioboxes(void)
{
  TextNode *return_node = curr_node;
  RadioBoxes *newrb;
  char *fname;

  /* I really don't need this node, it just sets up some parsing stuff */
  return_node->type = openaxiom_Noop_token;

  newrb = alloc_rbs();

  get_token();
  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "\\radioboxes was expecting a name not %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }

  newrb->name = alloc_string(get_input_string());

  /* quick search for the name in the current list */
  if (already_there(newrb->name)) {
    free(newrb->name);
    free(newrb);
    fprintf(stderr, "Tried to redefine radioboxes %s\n", newrb->name);
    print_page_and_filename();
    jump();
  }
  /* now I have to get the selected and unslected bitmaps */
  get_token();
  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "\\radioboxes was expecting a name not %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }
  fname = get_input_string();
  if (!make_input_file)
    newrb->selected = insert_image_struct(fname);

  get_token();
  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "\\radioboxes was expecting a name not %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }
  fname = get_input_string();
  if (!make_input_file) {
    newrb->unselected = insert_image_struct(fname);
    newrb->height = max(newrb->selected->height, newrb->unselected->height);
    newrb->width = max(newrb->selected->width, newrb->unselected->width);
    /* now add the thing to the current list of radio boxes */
  }
  newrb->next = gPageBeingParsed->radio_boxes;
  gPageBeingParsed->radio_boxes = newrb;

  curr_node = return_node;
  return;
}
Exemple #11
0
void
parse_radiobox(void)
{
  InputBox *box;
  char *name;
  char *group_name;
  short int picked = 0;
  TextNode *input_box = curr_node;

  gStringValueOk = 0;

  /* set the type and space fields  */
  input_box->type = openaxiom_Radiobox_token;
  input_box->space = token.id[-1];

  /* IS it selected? */
  get_token();
  if (token.type == openaxiom_Lsquarebrace_token) {
    get_expected_token(openaxiom_Word_token);
    if (!is_number(token.id)) {
      fprintf(stderr,
              "parse_simple_box: Expected a value not %s\n", token.id);
      print_page_and_filename();
      jump();
    }
    else if (!strcmp(token.id, "1"))
      picked = 1;
    else if (!strcmp(token.id, "0"))
      picked = 0;
    else {
      fprintf(stderr, "parse_simple_box: Unexpected Value %s\n", token.id);
      print_page_and_filename();
      jump();
    }
    get_expected_token(openaxiom_Rsquarebrace_token);
    get_token();
  }

  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "parse_inputbox was expecting a { not a %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }

  name = get_input_string();
  if (gPageBeingParsed->box_hash && hash_find(gPageBeingParsed->box_hash, name)) {
    fprintf(stderr, "Input box name %s is not unique \n", name);
    print_page_and_filename();
    jump();
  }

  box = alloc_inputbox();
  box->name = alloc_string(name);
  input_box->data.text = alloc_string(name);
  box->picked = picked;

  /* Now what I need to do is get the group name */
  get_token();
  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "parse_inputbox was expecting a { not a %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }
  group_name = get_input_string();

  /*
   * Now call a routine which searches the radio box list for the current
   * group name, and if found adds this box to it
   */
  add_box_to_rb_list(group_name, box);

  input_box->width = box->rbs->width;
  input_box->height = box->rbs->height;
  /* Make the window and stuff */
  input_box->link = make_box_window(box, openaxiom_Radiobox_token);
  if (!make_input_file)
    box->win = input_box->link->win;        /* TTT */


  /* Now add the box to the box_has table for this window */
  if (gPageBeingParsed->box_hash == NULL) {
    gPageBeingParsed->box_hash = (HashTable *) halloc(sizeof(HashTable),
                                                      "Box Hash");
    hash_init(
              gPageBeingParsed->box_hash, 
              BoxHashSize, 
              (EqualFunction) string_equal, 
              (HashcodeFunction) string_hash);
  }
  hash_insert(gPageBeingParsed->box_hash, (char *)box, box->name);

  /* reset the curr_node and then return */
  curr_node = input_box;
  gStringValueOk = 1;
  return;
}
Exemple #12
0
void
parse_simplebox(void)
{
  InputBox *box;
  char *name;
  short int picked = 0;
  char *filename;
  TextNode *input_box = curr_node;

  gStringValueOk = 0;

  /* set the type and space fields  */
  input_box->type = openaxiom_SimpleBox_token;
  input_box->space = token.id[-1];

  /* IS it selected? */
  get_token();
  if (token.type == openaxiom_Lsquarebrace_token) {
    get_expected_token(openaxiom_Word_token);
    if (!is_number(token.id)) {
      fprintf(stderr,
              "parse_simple_box: Expected a value not %s\n", token.id);
      print_page_and_filename();
      jump();
    }
    else if (!strcmp(token.id, "1"))
      picked = 1;
    else if (!strcmp(token.id, "0"))
      picked = 0;
    else {
      fprintf(stderr, "parse_simple_box: Unexpected Value %s\n", token.id);
      print_page_and_filename();
      jump();
    }
    get_expected_token(openaxiom_Rsquarebrace_token);
    get_token();
  }

  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "parse_inputbox was expecting a { not a %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }

  name = get_input_string();
  if (gPageBeingParsed->box_hash && hash_find(gPageBeingParsed->box_hash, name)) {
    fprintf(stderr, "Input box name %s is not unique \n", name);
    print_page_and_filename();
    jump();
  }

  box = alloc_inputbox();
  box->name = alloc_string(name);
  input_box->data.text = alloc_string(name);
  box->picked = picked;

  /* Get the filename for the selected and unselected bitmaps */
  get_expected_token(openaxiom_Lbrace_token);
  filename = get_input_string();
  if (!make_input_file)
    box->selected = insert_image_struct(filename);
  get_expected_token(openaxiom_Lbrace_token);
  filename = get_input_string();
  if (!make_input_file) {
    box->unselected = insert_image_struct(filename);
    /* set the width and height for the maximaum of the two */
    input_box->height = max(box->selected->height, box->unselected->height);
    input_box->width = max(box->selected->width, box->unselected->width);
    /* Make the window and stuff */
    input_box->link = make_box_window(box, openaxiom_SimpleBox_token);
    box->win = input_box->link->win;

    /* Now add the box to the box_has table for this window */
    if (gPageBeingParsed->box_hash == NULL) {
      gPageBeingParsed->box_hash = (HashTable *) halloc(sizeof(HashTable),
                                                        "Box Hash");
      hash_init(
                gPageBeingParsed->box_hash, 
                BoxHashSize, 
                (EqualFunction) string_equal, 
                (HashcodeFunction) string_hash);
    }
    hash_insert(gPageBeingParsed->box_hash, (char *)box, box->name);
  }

  /* reset the curr_node and then return */
  curr_node = input_box;
  gStringValueOk = 1;
  return;
}
Exemple #13
0
gboolean _upload_goagent(UP_DATA *data)
{
	GtkTextBuffer *buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(data->text));
	GtkTextIter end;
	GtkTextMark *mark;
	char buf[512];
	int ret;
	char *result;
	int len;
	fd_set reads;
	struct timeval timeout;

	timeout.tv_sec=0;
	timeout.tv_usec=300;

	FD_ZERO(&reads);
	FD_SET(data->pty,&reads);

	/*侦听读,直到有数据可读
	 * 或者超时
	 * 如果超时则返回TRUE
	 * 否则显示内容
	 */
	ret=select(data->pty+1,&reads,NULL,NULL,&timeout);

	if(ret==-1 || ret==0)
		return TRUE;

	len=read(data->pty,buf,sizeof(buf)-1);

	if(len<=0)
		return TRUE;

	buf[len]='\0';

	gtk_text_buffer_get_end_iter(buffer,&end);

	if(strstr(buf,"WARNING"))
		gtk_text_buffer_insert_with_tags_by_name(buffer,&end,buf,
				len,"green_fg",NULL);
	else if(strstr(buf,"ERROR"))
		gtk_text_buffer_insert_with_tags_by_name(buffer,&end,buf,
				len,"red_fg",NULL);
	else
		gtk_text_buffer_insert_with_tags_by_name(buffer,&end,buf,
				len,"black_fg",NULL);

	/*交互输入APPID Email与Password*/
	if(strstr(buf,"APPID:"))
	{
		result=get_input_string("APPID");
		write(data->pty,result,strlen(result));
		write(data->pty,"\n",1);
	}

	if(strstr(buf,"Email:"))
	{
		result=get_input_string("Email");
		write(data->pty,result,strlen(result));
		write(data->pty,"\n",1);
	}

	if(strstr(buf,"Password for"))
	{
		result=get_input_string("Password");
		write(data->pty,result,strlen(result));
		write(data->pty,"\n",1);
	}

	if(strstr(buf,"proxy.ini") || strstr(buf,"python_upload:"))
	{
		kill(data->pid,SIGKILL);
		while(waitpid(-1,NULL,WNOHANG)!=-1);
		data->off=0;
		return FALSE;
	}

	/*gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(data->text),&end,
			0,FALSE,FALSE,FALSE);*/

	/*移动滚动条到最后*/
	mark=gtk_text_buffer_create_mark(buffer,NULL,&end,TRUE);
	gtk_text_buffer_move_mark(buffer,mark,&end);
	gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(data->text),mark,
			0,TRUE,TRUE,TRUE);

	return TRUE;
}