Esempio n. 1
0
File: path.c Progetto: skout23/snowy
void check_insert_path(char *command, struct session *ses)
{
	struct listnode *node;

	if ((node = search_node_list(ses->list[LIST_PATHDIR], command)))
	{
		insert_node_list(ses->list[LIST_PATH], node->left, node->right, "0");
	}
}
Esempio n. 2
0
int process_rep(struct sk_buff *skb) {
  struct add_rep_pkt *pkt;
  struct add_node *node;

  printk(KERN_INFO "add: add_process_rep called\n");
  pkt = (struct add_rep_pkt *) skb_network_header(skb);

  node = (struct add_node *) kmalloc(sizeof(struct add_node), GFP_KERNEL);
  node->id = pkt->req_id;
  node->controller_id = pkt->req_controller;
  insert_node_list(node);

  kfree_skb(skb);
  return 0;
}
Esempio n. 3
0
void CHashMap::use_node(THashNode *node, void * key, int chunk_len, 
                              BC_MEM_HANDLER chunk_head)
{
    //set member
    memcpy(node->key_, key, get_key_size());
    node->chunk_len_ = chunk_len;
    node->chunk_head_ = chunk_head;
    node->add_info_1_ = 0;
	node->add_info_2_ = 0;

    int bucket_list_len = get_bucket_list_len(m_get_bucket_id(node->key_));
    if (bucket_list_len == 0)
    {
        //the bucket change from unused
        hash_map_->used_bucket_num_ ++;
    }
    
    insert_node_list(node);
    return;
}
Esempio n. 4
0
int cursor_tab_add(int input_now, int stop_after_first) {
  struct listroot *root = gtd->ses->list[LIST_TAB];
  char tab[BUFFER_SIZE];

  for (root->update = 0; root->update < root->used; root->update++) {
    substitute(gtd->ses, root->list[root->update]->left, tab, SUB_VAR | SUB_FUN);

    if (!strncmp(tab, &gtd->input_buf[input_now], strlen(&gtd->input_buf[input_now]))) {
      if (search_node_list(gtd->ses->list[LIST_TABCYCLE], tab)) {
        continue;
      }
      insert_node_list(gtd->ses->list[LIST_TABCYCLE], tab, "", "");

      if (stop_after_first) {
        return TRUE;
      }
    }
  }
  return FALSE;
}
Esempio n. 5
0
int cursor_auto_tab_add(int input_now, int stop_after_first) {
  char tab[BUFFER_SIZE], buf[BUFFER_SIZE];
  int scroll_cnt, line_cnt, tab_len;
  char *arg;

  line_cnt = 0;

  scroll_cnt = gtd->ses->scroll_row;

  do {
    if (scroll_cnt == gtd->ses->scroll_max - 1) {
      scroll_cnt = 0;
    } else {
      scroll_cnt++;
    }

    if (gtd->ses->buffer[scroll_cnt] == NULL) {
      break;
    }

    if (str_hash_grep(gtd->ses->buffer[scroll_cnt], FALSE)) {
      continue;
    }

    if (line_cnt++ >= gtd->ses->auto_tab) {
      break;
    }

    strip_vt102_codes(gtd->ses->buffer[scroll_cnt], buf);

    arg = buf;

    while (*arg) {
      arg = get_arg_stop_spaces(gtd->ses, arg, tab, 0);

      if (!strncmp(tab, &gtd->input_buf[input_now], strlen(&gtd->input_buf[input_now]))) {
        tab_len = strlen(tab) - 1;

        if (tab_len > 0) {
          if (tab[tab_len] == '.' || tab[tab_len] == ',') {
            tab[tab_len] = 0;
          }
        }

        if (search_node_list(gtd->ses->list[LIST_TABCYCLE], tab)) {
          continue;
        }
        insert_node_list(gtd->ses->list[LIST_TABCYCLE], tab, "", "");

        if (stop_after_first) {
          return TRUE;
        }
      }

      if (*arg == COMMAND_SEPARATOR) {
        arg++;
      }

    }
  }
  while (scroll_cnt != gtd->ses->scroll_row);

  return FALSE;
}
Esempio n. 6
0
void init_tintin(int greeting)
{
	int ref, index;

	gts = (struct session *) calloc(1, sizeof(struct session));

	for (index = 0 ; index < LIST_MAX ; index++)
	{
		gts->list[index] = init_list(gts, index, 32);
	}

	gts->name           = strdup("gts");
	gts->group          = strdup("");
	gts->host           = strdup("");
	gts->port           = strdup("");
	gts->cmd_color      = strdup("");
	gts->telopts        = TELOPT_FLAG_ECHO;
	gts->flags          = SES_FLAG_MCCP;
	gts->socket         = 1;
	gts->read_max       = 16384;

	gtd                 = (struct tintin_data *) calloc(1, sizeof(struct tintin_data));

	gtd->ses            = gts;

	gtd->str_size       = sizeof(struct str_data);
	gtd->str_hash_size  = sizeof(struct str_hash_data);

	gtd->mccp_len       = 4096;
	gtd->mccp_buf       = (unsigned char *) calloc(1, gtd->mccp_len);

	gtd->mud_output_max = 16384;
	gtd->mud_output_buf = (char *) calloc(1, gtd->mud_output_max);

	gtd->input_off      = 1;

	gtd->term           = strdup(getenv("TERM") ? getenv("TERM") : "UNKNOWN");

	for (index = 0 ; index < 100 ; index++)
	{
		gtd->vars[index] = strdup("");
		gtd->cmds[index] = strdup("");
	}

	for (ref = 0 ; ref < 26 ; ref++)
	{
		for (index = 0 ; *command_table[index].name != 0 ; index++)
		{
			if (*command_table[index].name == 'a' + ref)
			{
				gtd->command_ref[ref] = index;
				break;
			}
		}
	}

	init_screen_size(gts);

	printf("\033="); // set application keypad mode

	gts->input_level++;

	do_configure(gts, "{AUTO TAB}         {5000}");
	do_configure(gts, "{BUFFER SIZE}     {20000}");
	do_configure(gts, "{COLOR PATCH}       {OFF}");
	do_configure(gts, "{COMMAND COLOR}   {<078>}");
	do_configure(gts, "{COMMAND ECHO}       {ON}");
	do_configure(gts, "{CONNECT RETRY}      {15}");
	do_configure(gts, "{CHARSET}         {ASCII}");
	do_configure(gts, "{HISTORY SIZE}     {1000}");
	do_configure(gts, "{LOG}               {RAW}");
	do_configure(gts, "{PACKET PATCH}     {0.00}");
	do_configure(gts, "{REPEAT CHAR}         {!}");
	do_configure(gts, "{REPEAT ENTER}      {OFF}");
	do_configure(gts, "{SCROLL LOCK}        {ON}");
	do_configure(gts, "{SPEEDWALK}         {OFF}");
	do_configure(gts, "{TINTIN CHAR}         {#}");
	do_configure(gts, "{VERBATIM}          {OFF}");
	do_configure(gts, "{VERBATIM CHAR}      {\\}");
	do_configure(gts, "{VERBOSE}           {OFF}");
	do_configure(gts, "{WORDWRAP}           {ON}");
	do_configure(gts, "{256 COLORS}       {AUTO}");

	gts->input_level--;

	insert_node_list(gts->list[LIST_PATHDIR],  "n",  "s",  "1");
	insert_node_list(gts->list[LIST_PATHDIR],  "e",  "w",  "2");
	insert_node_list(gts->list[LIST_PATHDIR],  "s",  "n",  "4");
	insert_node_list(gts->list[LIST_PATHDIR],  "w",  "e",  "8");
	insert_node_list(gts->list[LIST_PATHDIR],  "u",  "d", "16");
	insert_node_list(gts->list[LIST_PATHDIR],  "d",  "u", "32");

	insert_node_list(gts->list[LIST_PATHDIR], "ne", "sw",  "3");
	insert_node_list(gts->list[LIST_PATHDIR], "nw", "se",  "9");
	insert_node_list(gts->list[LIST_PATHDIR], "se", "nw",  "6");
	insert_node_list(gts->list[LIST_PATHDIR], "sw", "ne", "12");

	init_terminal();

	if (greeting)
	{
		do_advertise(gts, "");

		do_help(gts, "GREETING");
	}
}