static int sensor_config_get_sensor(xmlNodePtr node, struct sensor_t *sensor_item, const xmlChar *type) {
    xmlChar *str = NULL;
    xmlChar *attr = NULL;
    float value = 0;
    xmlNodePtr p = node;

    if (p != NULL) {
        sensor_item->handle = sensor_config_get_handle((const char *)type);
        sensor_item->type = sensor_config_get_type((const char *)type);
    }
    while (p != NULL) {
        str = xmlNodeGetContent(p);
        if (str == NULL || (!xmlStrcmp(str, (const xmlChar *)"0")) || (!xmlStrcmp(str, (const xmlChar *)""))) {
            if (str != NULL)
                xmlFree(str);
            p = p->next;
            continue;
        }

        if ((!xmlStrcmp(p->name, (const xmlChar *)"name"))) {
            sensor_item->name = generate_string(str);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"vendor"))) {
            sensor_item->vendor = generate_string(str);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"version"))) {
            sensor_item->version = atoi((char *)str);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"maxRange"))) {
            value = atof((char *)str);
            attr = xmlGetProp(p, (const xmlChar*)"unit");
            sensor_item->maxRange = value * sensor_config_get_unit((char *)attr);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"resolution"))) {
            value = atof((char *)str);
            attr = xmlGetProp(p, (const xmlChar*)"unit");
            sensor_item->resolution = value * sensor_config_get_unit((char *)attr);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"power"))) {
            sensor_item->power = atof((char *)str);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"minDelay"))) {
            sensor_item->minDelay = atoi((char *)str);
        }
        xmlFree(str);
        p = p->next;
    }
    return 0;
}
Esempio n. 2
0
string cl_brute_generator::create_random()
{
   cb = random() % allb.size();
   for (size_t i = 0 ; i < cs.size() ; i++)
     cs[i] = random() % alphabet.size();
   string s;
   generate_string(s);
   return s;
}
Esempio n. 3
0
std::vector<std::string> test_data_generator::generate_strings(size_t num_lines)
{
	std::vector<std::string> r;

	for (size_t i = 0; i < num_lines; ++i)
	{
		const auto sz = size_distr_(gen_);
		r.push_back(generate_string(sz));
	}

	return r;
}
Esempio n. 4
0
void handle_client(int client_sock)
{
  char buf[BUFFERSIZE];
  int r_val;
  int num_threads = omp_get_max_threads();

  struct timeval tic, toc, diff;
  struct timezone tzp;

  // At first, receive string to generate
  if ((r_val = recv(client_sock, buf, BUFFERSIZE, 0)) <= 0) {
    char error_msg[] = "Error: Was not able to receive request correctly. Bye.\n";
    send(client_sock, error_msg, strlen(error_msg), 0);
    close(client_sock);
  }
  buf[r_val] = '\0';

  char orig_str[BUFFERSIZE];
  strcpy(orig_str, buf);

  struct prot_req_accepted_t accept;
  accept.strlen = htonl(strlen(orig_str));
  accept.cores = htonl(num_threads);
  send(client_sock, &accept, sizeof(struct prot_req_accepted_t), 0);

  printf("Generating word \"%s\"...", orig_str);

  srand (time(NULL));
  gettimeofday(&tic, &tzp);
  gettimeofday(&tic, &tzp);
  
  uint64_t attempts = generate_string(orig_str);
  
  if (tic.tv_usec > toc.tv_usec) {
    toc.tv_usec += 1000000;
    toc.tv_sec--;
  }

  gettimeofday(&toc, &tzp);
  diff.tv_usec = toc.tv_usec - tic.tv_usec;
  diff.tv_sec  = toc.tv_sec  - tic.tv_sec;
  double seconds = (diff.tv_usec/1000000.0+diff.tv_sec);

  printf("done with %lld attempts after %f seconds.\n", attempts, seconds);

  struct prot_req_accomp_t accomp;
  accomp.attempts = htonllnet(attempts);
  accomp.seconds = seconds;
  send(client_sock, &accomp, sizeof(struct prot_req_accomp_t), 0);

  close(client_sock);
}
Esempio n. 5
0
bool cl_brute_generator::get_next(string& s)
{
   s = "";
   if (cb == allb.size()) //finish
     return false;
   generate_string(s);
   if (!get_next_cs())
     {
	//put zeros to cs again
	fill(cs.begin(), cs.end(), 0);
	cb++; //and take new bracket set
     }
   return true;
}
Esempio n. 6
0
void test_data_generator::generate_file(const std::string& filename, std::uint64_t size)
{
	// Result file
	file_writer out(filename);

	while (out.written() < size)
	{
		auto sz = size_distr_(gen_);
		if (out.written() + sz > size)
			sz = static_cast<size_t>(size - out.written());
		
		auto line = generate_string(sz);
		out.write(line);
	}
}
Esempio n. 7
0
int find_sb_string(void **list, selbox_type_t type, int nentries, char *compare_string)
{
	int index, len = strlen(compare_string);

	for(index=0; index<nentries; index++)
	{
		char buffer[4096];

		(void)generate_string(buffer, list, type, sizeof(buffer) - 1, index);

		if (strncmp(buffer, compare_string, len) == 0)
			return index;
	}

	return -1;
}
Esempio n. 8
0
int find_sb_string(void **list, selbox_type_t type, int nentries, char *compare_string)
{
	int index;

	for(index=0; index<nentries; index++)
	{
		char buffer[4096];

		(void)generate_string(buffer, list, type, sizeof(buffer) - 1, index);

	  if (string_fuzzy_search(buffer, compare_string))
	    return index;
	}

	return -1;
}
Esempio n. 9
0
static svn_error_t *
many_strings_table_body(svn_boolean_t do_load_store,
                        apr_pool_t *pool)
{
    /* cause multiple sub-tables (6 to be exact) to be created */
    enum { COUNT = 100 };

    svn_stringbuf_t *strings[COUNT] = { 0 };
    apr_size_t indexes[COUNT] = { 0 };

    string_table_builder_t *builder;
    string_table_t *table;
    int i;

    builder = svn_fs_x__string_table_builder_create(pool);
    for (i = 0; i < COUNT; ++i)
    {
        strings[i] = generate_string(APR_UINT64_C(0x1234567876543210) * (i + 1),
                                     (i * i) % 23000,  pool);
        indexes[i] = svn_fs_x__string_table_builder_add(builder,
                     strings[i]->data,
                     strings[i]->len);
    }

    table = svn_fs_x__string_table_create(builder, pool);
    if (do_load_store)
        SVN_ERR(store_and_load_table(&table, pool));

    for (i = 0; i < COUNT; ++i)
    {
        apr_size_t len;
        const char *string
            = svn_fs_x__string_table_get(table, indexes[i], &len, pool);

        SVN_TEST_STRING_ASSERT(string, strings[i]->data);
        SVN_TEST_ASSERT(len == strlen(string));
        SVN_TEST_ASSERT(len == strings[i]->len);
    }

    return SVN_NO_ERROR;
}
Esempio n. 10
0
void CodeGen::generate_assignment(node *cur){
	if(cur){
		char c = cur -> data[0];

		var_addr v = find_var(c);

		if(!v.type.compare("int")){
			generate_int(cur -> younger_sibling);
		}
		else if(!v.type.compare("boolean")){
			std::string a = generate_bool(cur -> younger_sibling);

			load_acc_const(a);
		}
		else if(!v.type.compare("string")){
			generate_string(cur -> younger_sibling -> data);
		}

		store_acc(v.temp);
	}
}
int
main (int __attr_unused___ argc,
      char __attr_unused___ **argv)
{
  const ecma_char_t *ptrs[test_sub_iters];
  ecma_number_t numbers[test_sub_iters];
  ecma_char_t strings[test_sub_iters][max_characters_in_string + 1];
  ecma_length_t lengths[test_sub_iters];

  mem_init ();
  lit_init ();

  srand ((unsigned int) time (NULL));
  int k = rand ();
  printf ("seed=%d\n", k);
  srand ((unsigned int) k);

  for (uint32_t i = 0; i < test_iters; i++)
  {
    memset (numbers, 0, sizeof (ecma_number_t) * test_sub_iters);
    memset (lengths, 0, sizeof (ecma_length_t) * test_sub_iters);
    memset (ptrs, 0, sizeof (ecma_char_t *) * test_sub_iters);

    for (uint32_t j = 0; j < test_sub_iters; j++)
    {
      int type = rand () % 3;
      if (type == 0)
      {
        lengths[j] = (ecma_length_t) (rand () % max_characters_in_string + 1);
        generate_string (strings[j], lengths[j]);
        lit_create_literal_from_charset (strings[j], lengths[j]);
        strings[j][lengths[j]] = '\0';
        ptrs[j] = strings[j];
        JERRY_ASSERT (ptrs[j]);
      }
      else if (type == 1)
      {
        ecma_magic_string_id_t msi = (ecma_magic_string_id_t) (rand () % ECMA_MAGIC_STRING__COUNT);
        ptrs[j] = ecma_get_magic_string_zt (msi);
        JERRY_ASSERT (ptrs[j]);
        lengths[j] = (ecma_length_t) ecma_zt_string_length (ptrs[j]);
        lit_create_literal_from_charset (ptrs[j], lengths[j]);
      }
      else
      {
        ecma_number_t num = generate_number ();
        lengths[j] = ecma_number_to_zt_string (num, strings[j], max_characters_in_string);
        lit_create_literal_from_num (num);
      }
    }

    // Add empty string
    lit_create_literal_from_charset (NULL, 0);

    for (uint32_t j = 0; j < test_sub_iters; j++)
    {
      literal_t lit1;
      literal_t lit2;
      if (ptrs[j])
      {
        lit1 = lit_find_or_create_literal_from_charset (ptrs[j], lengths[j]);
        lit2 = lit_find_literal_by_charset (ptrs[j], lengths[j]);
        JERRY_ASSERT (lit_literal_equal_zt (lit1, ptrs[j]));
        JERRY_ASSERT (lit_literal_equal_type_zt (lit2, ptrs[j]));
      }
      else
      {
        lit1 = lit_find_or_create_literal_from_num (numbers[j]);
        lit2 = lit_find_literal_by_num (numbers[j]);
        JERRY_ASSERT (lit_literal_equal_num (lit1, numbers[j]));
        JERRY_ASSERT (lit_literal_equal_type_num (lit2, numbers[j]));
      }
      JERRY_ASSERT (lit1);
      JERRY_ASSERT (lit2);
      JERRY_ASSERT (lit1 == lit2);
      JERRY_ASSERT (lit_literal_equal (lit1, lit2));
    }

    // Check empty string exists
    JERRY_ASSERT (lit_find_literal_by_charset (NULL, 0));

    lit_storage.cleanup ();
    JERRY_ASSERT (lit_storage.get_first () == NULL);
  }

  lit_finalize ();
  mem_finalize (true);
  return 0;
}
Esempio n. 12
0
int selection_box(void **list, char *needs_mark, int nlines, selbox_type_t type, int what_help, char *heading)
{
	NEWWIN *mywin;
	int wlines = min(nlines, (max_y - 1) - 4);
	int total_win_size = wlines + 4;
	int win_width = max(32, max_x / 3);
	int wcols = win_width - 4;
	int pos = 0, ppos = -1, offs = 0, poffs = -1;
	int loop = 0, sel = -1;
	char first = 1;
	char *dummy = (char *)mymalloc(wcols + 1);
	int path_max = find_path_max();
	char *selstr = (char *)mymalloc(path_max + 1), selfound = 0;

	selstr[0] = 0x00;

	mywin = create_popup(total_win_size, win_width);

	for(;;)
	{
		int c;

		/* draw list */
		if (pos != ppos)
		{
			int entries_left = (nlines - pos);

			werase(mywin -> win);

			if (heading)
				win_header(mywin, heading);
			else if (type == SEL_WIN)
				win_header(mywin, "Select window");
			else if (type == SEL_SUBWIN)
				win_header(mywin, "Select subwindow");
			else if (type == SEL_FILES)
				win_header(mywin, "Select file");
			else if (type == SEL_CSCHEME)
				win_header(mywin, "Select color scheme");
			else if (type == SEL_HISTORY)
				win_header(mywin, "Select string from history");

			for(loop=0; loop<min(entries_left, wlines); loop++)
			{
				char invert = generate_string(dummy, list, type, wcols, loop + pos);
				if (loop == offs)
					ui_inverse_on(mywin);
				if (invert) color_on(mywin, find_colorpair(COLOR_YELLOW, -1, 0));
				if (needs_mark && needs_mark[loop + pos])
					mvwprintw(mywin -> win, loop + 2, 1, "*");
				mvwprintw(mywin -> win, loop + 2, 2, "%s", dummy);
				if (invert) color_off(mywin, find_colorpair(COLOR_YELLOW, -1, 0));
				if (loop == offs)
					ui_inverse_off(mywin);
			}

			draw_border(mywin);

			ppos = pos;
			poffs = offs;
		}
		else if (poffs != offs)
		{
			int yellow_cp = find_colorpair(COLOR_YELLOW, -1, 0);
			char invert = generate_string(dummy, list, type, wcols, poffs + pos);
			if (invert) color_on(mywin, yellow_cp);
			mvwprintw(mywin -> win, poffs + 2, 2, "%s", dummy);
			if (invert) color_off(mywin, yellow_cp);

			invert = generate_string(dummy, list, type, wcols, offs + pos);

			ui_inverse_on(mywin);
			if (invert) color_on(mywin, yellow_cp);
			if (needs_mark && needs_mark[offs + pos])
				mvwprintw(mywin -> win, loop + 2, 1, "*");
			mvwprintw(mywin -> win, offs + 2, 2, "%s", dummy);
			if (invert) color_off(mywin, yellow_cp);
			ui_inverse_off(mywin);

			poffs = offs;
		}

		if (first)
		{
			first = 0;
			color_on(mywin, find_colorpair(COLOR_GREEN, -1, 0));
			mvwprintw(mywin -> win, total_win_size - 2, 2, "Press ^G to abort");
			color_off(mywin, find_colorpair(COLOR_GREEN, -1, 0));
		}
		else
		{
			int loop, len = strlen(selstr);

			for(loop=0; loop<wcols; loop++)
				mvwprintw(mywin -> win, total_win_size - 2, 1 + loop, " ");

			if (!selfound) color_on(mywin, find_colorpair(COLOR_RED, -1, 0));
			mvwprintw(mywin -> win, total_win_size - 2, 1, "%s", &selstr[max(0, len - wcols)]);
			if (!selfound) color_off(mywin, find_colorpair(COLOR_RED, -1, 0));
		}

		mydoupdate();

		c = wait_for_keypress(what_help, 0, mywin, 1);

		if (c == KEY_UP)
		{
			if ((offs + pos) > 0)
			{
				if (offs)
					offs--;
				else
					pos--;
			}
			else
			{
				wrong_key();
			}
		}
		else if (c == KEY_DOWN)
		{
			if ((pos + offs) < (nlines-1))
			{
				if (offs < (wlines-1))
					offs++;
				else
					pos++;
			}
			else
			{
				wrong_key();
			}
		}
		else if (c == KEY_NPAGE)
		{
			if ((pos + offs) < (nlines - 1))
			{
				pos += min(wlines, (nlines - 1) - (pos + offs));
			}
			else
			{
				wrong_key();
			}
		}
		else if (c == KEY_PPAGE)
		{
			if ((pos + offs - wlines) >= 0)
			{
				if (pos > wlines)
				{
					pos -= wlines;
				}
				else
				{
					pos -= (wlines - offs);
					offs = 0;
				}
			}
			else if (offs > 0)
			{
				offs = 0;
			}
			else if (pos > 0)
			{
				pos = 0;
			}
			else
			{
				wrong_key();
			}
		}
		else if (c == KEY_ENTER || c == 13 || c == 10)
		{
			sel = pos + offs;
			break;
		}
		else if (c == abort_key || c == -1)
		{
			break;
		}
		else if ((c > 31 && c != 127) || (c == KEY_BACKSPACE))
		{
			int index, curlen;

			curlen = strlen(selstr);
			if (c == KEY_BACKSPACE)
			{
				if (curlen > 0)
					selstr[curlen - 1] = 0x00;
				else
					wrong_key();
			}
			else if (curlen < path_max)
			{
				selstr[curlen] = c;
				selstr[curlen + 1] = 0x00;
			}
			else
				wrong_key();


			curlen = strlen(selstr);
			if (curlen > 0)
			{
				index = find_sb_string(list, type, nlines, selstr);
				if (index != -1)
				{
					ppos = -1;
					sel = pos = index;
					selfound = 1;
				}
				else
				{
					selfound = 0;
				}
			}
		}
		else
		{
			wrong_key();
		}
	}

	delete_popup(mywin);

	myfree(dummy);
	myfree(selstr);

	return sel;
}
Esempio n. 13
0
int
main (int __attr_unused___ argc,
      char __attr_unused___ **argv)
{
  TEST_INIT ();

  const lit_utf8_byte_t *ptrs[test_sub_iters];
  ecma_number_t numbers[test_sub_iters];
  lit_utf8_byte_t strings[test_sub_iters][max_characters_in_string + 1];
  lit_utf8_size_t lengths[test_sub_iters];

  jmem_init ();
  lit_init ();

  for (uint32_t i = 0; i < test_iters; i++)
  {
    memset (numbers, 0, sizeof (ecma_number_t) * test_sub_iters);
    memset (lengths, 0, sizeof (lit_utf8_size_t) * test_sub_iters);
    memset (ptrs, 0, sizeof (lit_utf8_byte_t *) * test_sub_iters);

    for (uint32_t j = 0; j < test_sub_iters; j++)
    {
      int type = rand () % 3;
      if (type == 0)
      {
        lengths[j] = (lit_utf8_size_t) (rand () % max_characters_in_string + 1);
        generate_string (strings[j], lengths[j]);
        lit_create_literal_from_utf8_string (strings[j], lengths[j]);
        strings[j][lengths[j]] = '\0';
        ptrs[j] = strings[j];
        JERRY_ASSERT (ptrs[j]);
      }
      else if (type == 1)
      {
        lit_magic_string_id_t msi = (lit_magic_string_id_t) (rand () % LIT_MAGIC_STRING__COUNT);
        ptrs[j] = lit_get_magic_string_utf8 (msi);
        JERRY_ASSERT (ptrs[j]);
        lengths[j] = (lit_utf8_size_t) lit_zt_utf8_string_size (ptrs[j]);
        lit_create_literal_from_utf8_string (ptrs[j], lengths[j]);
      }
      else
      {
        ecma_number_t num = generate_number ();
        lengths[j] = ecma_number_to_utf8_string (num, strings[j], max_characters_in_string);
        lit_create_literal_from_num (num);
      }
    }

    // Add empty string
    lit_create_literal_from_utf8_string (NULL, 0);

    for (uint32_t j = 0; j < test_sub_iters; j++)
    {
      lit_literal_t lit1;
      lit_literal_t lit2;
      if (ptrs[j])
      {
        lit1 = lit_find_or_create_literal_from_utf8_string (ptrs[j], lengths[j]);
        lit2 = lit_find_literal_by_utf8_string (ptrs[j], lengths[j]);
        JERRY_ASSERT (compare_utf8_string_and_string_literal (ptrs[j], lengths[j], lit1));
        JERRY_ASSERT (compare_utf8_string_and_string_literal (ptrs[j], lengths[j], lit2));
      }
      else
      {
        lit1 = lit_find_or_create_literal_from_num (numbers[j]);
        lit2 = lit_find_literal_by_num (numbers[j]);
        JERRY_ASSERT (numbers[j] == lit_number_literal_get_number (lit1));
        JERRY_ASSERT (numbers[j] == lit_number_literal_get_number (lit2));
      }
      JERRY_ASSERT (lit1);
      JERRY_ASSERT (lit2);
      JERRY_ASSERT (lit1 == lit2);
    }

    // Check empty string exists
    JERRY_ASSERT (lit_find_literal_by_utf8_string (NULL, 0));
  }

  lit_finalize ();
  jmem_finalize (true);
  return 0;
} /* main */
Esempio n. 14
0
int
main (void)
{
  TEST_INIT ();

  const lit_utf8_byte_t *ptrs[test_sub_iters];
  ecma_number_t numbers[test_sub_iters];
  lit_utf8_byte_t strings[test_sub_iters][max_characters_in_string + 1];
  lit_utf8_size_t lengths[test_sub_iters];

  jmem_init ();

  for (uint32_t i = 0; i < test_iters; i++)
  {
    memset (numbers, 0, sizeof (ecma_number_t) * test_sub_iters);
    memset (lengths, 0, sizeof (lit_utf8_size_t) * test_sub_iters);
    memset (ptrs, 0, sizeof (lit_utf8_byte_t *) * test_sub_iters);

    for (uint32_t j = 0; j < test_sub_iters; j++)
    {
      int type = rand () % 3;
      if (type == 0)
      {
        lengths[j] = (lit_utf8_size_t) (rand () % max_characters_in_string + 1);
        generate_string (strings[j], lengths[j]);
        ecma_find_or_create_literal_string (strings[j], lengths[j]);
        strings[j][lengths[j]] = '\0';
        ptrs[j] = strings[j];
        TEST_ASSERT (ptrs[j]);
      }
      else if (type == 1)
      {
        lit_magic_string_id_t msi = (lit_magic_string_id_t) (rand () % LIT_NON_INTERNAL_MAGIC_STRING__COUNT);
        ptrs[j] = lit_get_magic_string_utf8 (msi);
        TEST_ASSERT (ptrs[j]);
        lengths[j] = (lit_utf8_size_t) lit_zt_utf8_string_size (ptrs[j]);
        ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
      }
      else
      {
        ecma_number_t num = generate_number ();
        lengths[j] = ecma_number_to_utf8_string (num, strings[j], max_characters_in_string);
        ecma_find_or_create_literal_number (num);
      }
    }

    /* Add empty string. */
    ecma_find_or_create_literal_string (NULL, 0);

    for (uint32_t j = 0; j < test_sub_iters; j++)
    {
      jmem_cpointer_t lit1;
      jmem_cpointer_t lit2;
      if (ptrs[j])
      {
        lit1 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
        lit2 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
        TEST_ASSERT (lit1 == lit2);
      }
      else
      {
        lit1 = ecma_find_or_create_literal_number (numbers[j]);
        lit2 = ecma_find_or_create_literal_number (numbers[j]);
        TEST_ASSERT (lit1 == lit2);
      }
      TEST_ASSERT (lit1);
      TEST_ASSERT (lit2);
      TEST_ASSERT (lit1 == lit2);
    }

    /* Check empty string exists. */
    TEST_ASSERT (ecma_find_or_create_literal_string (NULL, 0) != JMEM_CP_NULL);
  }

  ecma_finalize_lit_storage ();
  jmem_finalize ();
  return 0;
} /* main */
static int sensor_config_get_platform_data(xmlNodePtr node, sensor_platform_config_t * config, const xmlChar *type) {
    xmlChar *str = NULL;
    xmlChar *attr = NULL;
    union sensor_data_t *temp;
    xmlNodePtr p = node;

    if (p != NULL) {
        config->handle = sensor_config_get_handle((const char *)type);
    }

    while (p != NULL) {
        if (p->properties) {
            if ((!xmlStrcmp(p->name, (const xmlChar *)"mapper"))) {
                attr = xmlGetProp(p, (const xmlChar*)"axis_x");
                if (attr) {
                    config->mapper[0] = sensor_config_get_axis((char *)attr);
                    xmlFree(attr);
                }
                attr = xmlGetProp(p, (const xmlChar*)"axis_y");
                if (attr) {
                    config->mapper[1] = sensor_config_get_axis((char *)attr);
                    xmlFree(attr);
                }
                attr = xmlGetProp(p, (const xmlChar*)"axis_z");
                if (attr) {
                    config->mapper[2] = sensor_config_get_axis((char *)attr);
                    xmlFree(attr);
                }
            }
            else if ((!xmlStrcmp(p->name, (const xmlChar *)"scale"))) {
                attr = xmlGetProp(p, (const xmlChar*)"axis_x");
                if (attr) {
                    config->scale[0] = atof((char *)attr);
                    xmlFree(attr);
                }
                attr = xmlGetProp(p, (const xmlChar*)"axis_y");
                if (attr) {
                    config->scale[1] = atof((char *)attr);
                    xmlFree(attr);
                }
                attr = xmlGetProp(p, (const xmlChar*)"axis_z");
                if (attr) {
                    config->scale[2] = atof((char *)attr);
                    xmlFree(attr);
                }
            }
            else if ((!xmlStrcmp(p->name, (const xmlChar *)"range"))) {
                attr = xmlGetProp(p, (const xmlChar*)"min");
                if (attr) {
                    config->range[0] = atof((char *)attr);
                    xmlFree(attr);
                }
                attr = xmlGetProp(p, (const xmlChar*)"max");
                if (attr) {
                    config->range[1] = atof((char *)attr);
                    xmlFree(attr);
                }
            }
            else if ((!xmlStrcmp(p->name, (const xmlChar *)"priv_data"))) {
                attr = xmlGetProp(p, (const xmlChar*)"compass_filter_en");
                if (attr) {
                    temp = (sensor_data_t *)malloc(sizeof(union sensor_data_t));
                    if(!temp)
                        LOGE("malloc priv_data error!\n");
                    else
                        temp->compass_filter_en = atoi((char *)attr);
                    config->priv_data = temp;
                    xmlFree(attr);
                }
                else if ((attr = xmlGetProp(p, (const xmlChar*)"light_glass_factor"))) {
                    temp = (sensor_data_t *)malloc(sizeof(union sensor_data_t));
                    if(!temp)
                        LOGE("malloc priv_data error!\n");
                    else
                        temp->light_glass_factor = atof((char *)attr);
                    config->priv_data = temp;
                    xmlFree(attr);
                }
            }
            p = p->next;
            continue;
        }

        str = xmlNodeGetContent(p);
        if (str == NULL) {
            p = p->next;
            continue;
        }
	if ((!xmlStrcmp(str, (const xmlChar *)"0")) || (!xmlStrcmp(str, (const xmlChar *)""))) {
            xmlFree(str);
            p = p->next;
            continue;
        }

        if ((!xmlStrcmp(p->name, (const xmlChar *)"name"))) {
            config->name = generate_string(str);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"activate_path"))) {
            config->activate_path = generate_string(str);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"poll_path"))) {
            config->poll_path = generate_string(str);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"data_path"))) {
            config->data_path = generate_string(str);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"config_path"))) {
            config->config_path = generate_string(str);
        }
        else if ((!xmlStrcmp(p->name, (const xmlChar *)"min_delay"))) {
            config->min_delay = atoi((char *)str);
        }
        xmlFree(str);
        p = p->next;
    }
    return 0;
}
Esempio n. 16
0
static void send_notifies(db1_res_t *result, int did_col, int resource_uri_col, int auth_state_col, int reason_col,
                   int pres_state_col, int content_type_col)
{
	int i;
	char* prev_did= NULL, * curr_did= NULL;
	db_row_t *row;	
	db_val_t *row_vals;
	char* resource_uri;
	str pres_state = {0, 0};
	xmlDocPtr rlmi_doc= NULL;
	xmlNodePtr list_node= NULL, instance_node= NULL, resource_node;
	unsigned int hash_code= 0;
	int size= BUF_REALLOC_SIZE, buf_len= 0;	
	char* buf= NULL, *auth_state= NULL, *boundary_string= NULL;
	str cid = {0,0};
	str content_type= {0, 0};
	int auth_state_flag;
	int chunk_len=0;
	str bstr= {0, 0};
	subs_t* dialog= NULL;
	int len_est = 0;
	int resource_added = 0; /* Flag to indicate that we have added at least one resource */

	/* generate the boundary string */
	boundary_string= generate_string(BOUNDARY_STRING_LEN);
	bstr.len= strlen(boundary_string);
	bstr.s= (char*)pkg_malloc((bstr.len+ 1)* sizeof(char));
	if(bstr.s== NULL)
	{
		ERR_MEM(PKG_MEM_STR);
	}
	memcpy(bstr.s, boundary_string, bstr.len);
	bstr.s[bstr.len]= '\0';

	/* Allocate an initial buffer for the multipart body.
	 * This buffer will be reallocated if neccessary */
	buf= pkg_malloc(size* sizeof(char));
	if(buf== NULL)
	{
		ERR_MEM(PKG_MEM_STR);
	}

	LM_DBG("found %d records with updated state\n", result->n);
	for(i= 0; i< result->n; i++)
	{
		row = &result->rows[i];
		row_vals = ROW_VALUES(row);
		
		curr_did=     (char*)row_vals[did_col].val.string_val;
		resource_uri= (char*)row_vals[resource_uri_col].val.string_val;
		auth_state_flag=     row_vals[auth_state_col].val.int_val;
		pres_state.s=   (char*)row_vals[pres_state_col].val.string_val;
		pres_state.len = strlen(pres_state.s);
		trim(&pres_state);
		
		/* If we have moved onto a new resource list Subscribe dialog indentifier, 
		   send a NOTIFY for the previous ID and then drop the existing documents. */
		if(prev_did!= NULL && strcmp(prev_did, curr_did)) 
		{
			if (send_notify(&rlmi_doc, buf, buf_len, bstr, dialog, hash_code))
			{  
				LM_ERR("in send_notify\n");
				goto error;
			}
			len_est = 0;
			pkg_free(dialog);
			dialog= NULL;
		}

		/*if first or different*/
		if(prev_did==NULL || strcmp(prev_did, curr_did)!=0)
		{
			/* Work out a subscription from the did. */
			get_dialog_from_did(curr_did, &dialog, &hash_code);
			if(dialog== NULL)
			{
				prev_did = NULL;
				LM_INFO("Dialog is NULL\n");
				continue;
			}
		
			len_est = create_empty_rlmi_doc(&rlmi_doc, &list_node, &dialog->pres_uri, dialog->version, 0);
			len_est += 2*strlen(boundary_string)+4+102+2+50+strlen(resource_uri)+20;
			buf_len= 0;
			resource_added = 0;

			/* !!!! for now I will include the auth state without checking if 
			 * it has changed - > in future chech if it works */		
		}

		/* add a node in rlmi_doc and if any presence state registered add 
		 * it in the buffer */
		
		resource_node= xmlNewChild(list_node,NULL,BAD_CAST "resource", NULL);
		if(resource_node== NULL)
		{
			LM_ERR("when adding resource child\n");
			goto done;
		}
		xmlNewProp(resource_node, BAD_CAST "uri", BAD_CAST resource_uri);
		len_est += strlen (resource_uri) + 35; /* <resource uri="[uri]"></resource>/r/n */
		resource_added = 1;

		/* there might be more records with the same uri- more instances-
		 * search and add them all */
		
		while(1)
		{
			cid.s= NULL;
			cid.len= 0;
			
			auth_state= get_auth_string(auth_state_flag);
			if(auth_state== NULL)
			{
				LM_ERR("bad authorization status flag\n");
				goto error;
			}	
			len_est += strlen(auth_state) + 38; /* <instance id="12345678" state="[auth_state]" />r/n */

			if(auth_state_flag & ACTIVE_STATE)
			{
				cid.s= generate_cid(resource_uri, strlen(resource_uri));
				cid.len = strlen(cid.s);
				len_est += cid.len + 8; /* cid="[cid]" */
				content_type.s = (char*)row_vals[content_type_col].val.string_val;
				content_type.len = strlen(content_type.s);
				chunk_len = 4 + bstr.len
							+ 35
							+ 16 + cid.len
							+ 18 + content_type.len
							+ 4 + pres_state.len + 8;
				len_est += chunk_len;
			}
			else
			if(auth_state_flag & TERMINATED_STATE)
			{
				len_est += strlen(row_vals[resource_uri_col].val.string_val) + 10; /* reason="[resaon]" */
			}
            
			if (rls_max_notify_body_len > 0 && len_est > rls_max_notify_body_len)
			{
				/* We have a limit on body length set, and we were about to exceed it */
				if (resource_added == 1)
				{
					/* We added at least one resource. */
					LM_DBG("timer_send_notify hit the size limit. len_est = %d\n", len_est);
					if (send_notify(&rlmi_doc, buf, buf_len, bstr, dialog, hash_code))
					{
						LM_ERR("in send_notify\n");
						goto error;
					}
					i --;
				}
				else
				{
					LM_DBG("timer_send_notify hit the size limit. NO RESOURCE ADDED len_est = %d\n", len_est);
				}
				len_est = 0;

				pkg_free(dialog);
				dialog= NULL;
				curr_did=NULL;
				break;
			}

			/* OK, we are happy this will fit */
			instance_node= xmlNewChild(resource_node, NULL, BAD_CAST "instance", NULL);
			if(instance_node== NULL)
			{
				LM_ERR("while adding instance child\n");
				goto error;
			}	

			/* Instance ID should be unique for each instance node
 			   within a resource node.  The same instance ID can be
			   used in different resource nodes.  Instance ID needs
			   to remain the same for each resource instance in
			   future updates.  We can just use a common string
			   here because you will only get multiple instances
			   for a resource when the back-end SUBSCRIBE is forked
			   and pua does not support this.  If/when pua supports
			   forking of the SUBSCRIBEs it sends this will need to
			   be fixed properly. */
			xmlNewProp(instance_node, BAD_CAST "id", 
					BAD_CAST instance_id);
			if(auth_state_flag & ACTIVE_STATE)
			{
				xmlNewProp(instance_node, BAD_CAST "state", BAD_CAST auth_state);
			}
			else
			if(auth_state_flag & TERMINATED_STATE)
			{
				xmlNewProp(instance_node, BAD_CAST "reason",
						BAD_CAST row_vals[resource_uri_col].val.string_val);
			}
			xmlNewProp(instance_node, BAD_CAST "cid", BAD_CAST cid.s);

			/* add in the multipart buffer */
			if(cid.s)
			{
	
				while(buf_len + chunk_len >= size)
				{
					REALLOC_BUF
				}
				buf_len+= sprintf(buf+ buf_len, "--%.*s\r\n", bstr.len,
						bstr.s);
				buf_len+= sprintf(buf+ buf_len,
						"Content-Transfer-Encoding: binary\r\n");
				buf_len+= sprintf(buf+ buf_len, "Content-ID: <%.*s>\r\n",
						cid.len, cid.s);
				buf_len+= sprintf(buf+ buf_len, "Content-Type: %.*s\r\n\r\n",
						content_type.len, content_type.s);
				buf_len+= sprintf(buf+buf_len,"%.*s\r\n\r\n", pres_state.len,
						pres_state.s);
			}

			i++;
			if(i== result->n)
			{
				i--;
				break;
			}
	
			row = &result->rows[i];
			row_vals = ROW_VALUES(row);

			if(strncmp(resource_uri, row_vals[resource_uri_col].val.string_val,
					strlen(resource_uri))
				|| strncmp(curr_did, row_vals[did_col].val.string_val,
					strlen(curr_did)))
			{
				i--;
				break;
			}
			resource_uri= (char*)row_vals[resource_uri_col].val.string_val;
			auth_state_flag=     row_vals[auth_state_col].val.int_val;
			pres_state.s=   (char*)row_vals[pres_state_col].val.string_val;
			pres_state.len= strlen(pres_state.s);
			trim(&pres_state);
		}

		prev_did= curr_did;
	}

	if(rlmi_doc)
	{
		LM_DBG("timer_send_notify at end len_est = %d resource_added = %d\n", len_est, resource_added);
		if (resource_added == 1)
		{
			send_notify(&rlmi_doc, buf, buf_len, bstr, dialog, hash_code);
		}
		if(dialog)
		{
			pkg_free(dialog);
		}
		dialog= NULL;
	}

	
error:
done:
	if(bstr.s)
		pkg_free(bstr.s);

	if(buf)
		pkg_free(buf);
	if(dialog)
		pkg_free(dialog);
	return;
}
Esempio n. 17
0
void timer_send_notify(unsigned int ticks,void *param)
{
	db_key_t query_cols[2], update_cols[1], result_cols[7];
	db_val_t query_vals[2], update_vals[1];
	int did_col, resource_uri_col, auth_state_col, reason_col,
		body_col, ctype_col;
	int n_result_cols= 0, i;
	db_res_t *result= NULL;
	char* prev_did= NULL, * curr_did= NULL;
	db_row_t *row;	
	db_val_t *row_vals;
	char* resource_uri;
	str body;
	str callid, to_tag, from_tag;
	xmlDocPtr rlmi_doc= NULL;
	xmlNodePtr list_node= NULL, instance_node= NULL, resource_node;
	unsigned int hash_code= 0;
	int len;
	int size= BUF_REALLOC_SIZE, buf_len= 0;
	char* buf= NULL, *auth_state= NULL;
	int contor= 0, auth_state_flag;
	str bstr= {0, 0};
	str rlmi_cont= {0, 0}, multi_cont;
	subs_t* s, *dialog= NULL;
	char* rl_uri= NULL;
	char* str_aux = NULL;
	str ctype, cid;
	int add_len;

	query_cols[0]= &str_updated_col;
	query_vals[0].type = DB_INT;
	query_vals[0].nul = 0;
	query_vals[0].val.int_val= UPDATED_TYPE; 

	result_cols[did_col= n_result_cols++]= &str_rlsubs_did_col;
	result_cols[resource_uri_col= n_result_cols++]= &str_resource_uri_col;
	result_cols[auth_state_col= n_result_cols++]= &str_auth_state_col;
	result_cols[ctype_col= n_result_cols++]= &str_content_type_col;
	result_cols[reason_col= n_result_cols++]= &str_reason_col;
	result_cols[body_col= n_result_cols++]= &str_presence_state_col;

	/* query in alfabetical order after rlsusbs_did 
	 * (resource list Subscribe dialog indentifier)*/

	if (rls_dbf.use_table(rls_db, &rlpres_table) < 0) 
	{
		LM_ERR("in use_table\n");
		goto done;
	}

	if(rls_dbf.query(rls_db, query_cols, 0, query_vals, result_cols,
					1, n_result_cols, &str_rlsubs_did_col, &result)< 0)
	{
		LM_ERR("in sql query\n");
		goto done;
	}
	if(result== NULL || result->n<= 0)
		goto done;

	/* update the rlpres table */
	update_cols[0]= &str_updated_col;
	update_vals[0].type = DB_INT;
	update_vals[0].nul = 0;
	update_vals[0].val.int_val= NO_UPDATE_TYPE; 

	if (rls_dbf.use_table(rls_db, &rlpres_table) < 0) 
	{
		LM_ERR("in use_table\n");
		goto error;
	}
	if(rls_dbf.update(rls_db, query_cols, 0, query_vals, update_cols,
					update_vals, 1, 1)< 0)
	{
		LM_ERR("in sql update\n");
		goto error;
	}

	/* generate the boundary string */

	bstr.s= generate_string((int)time(NULL), BOUNDARY_STRING_LEN);
	if(bstr.s == NULL)
	{
		LM_ERR("failed to generate random string\n");
		goto error;
	}
	bstr.len= strlen(bstr.s);

	/* for the multipart body , use here also an initial allocated
	 * and reallocated on need buffer */
	buf= pkg_malloc(size);
	if(buf== NULL)
	{
		ERR_MEM(PKG_MEM_STR);
	}

	LM_DBG("found %d records with updated state\n", result->n);
	for(i= 0; i< result->n; i++)
	{
		row = &result->rows[i];
		row_vals = ROW_VALUES(row);
		
		curr_did=     (char*)row_vals[did_col].val.string_val;
		resource_uri= (char*)row_vals[resource_uri_col].val.string_val;
		auth_state_flag=     row_vals[auth_state_col].val.int_val;
		body.s=   (char*)row_vals[body_col].val.string_val;
		body.len= strlen(body.s);
		ctype.s = (char*)row_vals[ctype_col].val.string_val;
		ctype.len = strlen(ctype.s);

		/* if all the info for one dialog have been collected -> send notify */
		/* the 'dialog' variable must be filled with the dialog info */
		/* 'buf' must contain the body */
		if(prev_did!= NULL && strcmp(prev_did, curr_did)) 
		{
			xmlDocDumpMemory(rlmi_doc,(xmlChar**)(void*)&rlmi_cont.s,
				&rlmi_cont.len);
		
			multi_cont.s= buf;
			multi_cont.len= buf_len;
			 
			if(agg_body_sendn_update(&dialog->pres_uri, bstr, &rlmi_cont, 
						 (buf_len==0)?NULL:&multi_cont, dialog, hash_code)<0)
			 {
				 LM_ERR("in function agg_body_sendn_update\n");
				 goto error;
			 }
			xmlFree(rlmi_cont.s);

			xmlFreeDoc(rlmi_doc);
			rlmi_doc= NULL;
			pkg_free(rl_uri);
			rl_uri= NULL;
			pkg_free(dialog);
			dialog= NULL;
		}

		/* for the new dialog -> search the dialog info and 
		 * fill the dialog structure and start a new rlmi document */
		if(prev_did== NULL || strcmp(prev_did, curr_did)) 
		{
			/* search the subscription in rlsubs_table*/
			if( parse_rlsubs_did(curr_did, &callid, &from_tag, &to_tag)< 0)
			{
				LM_ERR("bad format for "
					"resource list Subscribe dialog indentifier(rlsubs did)\n");
				prev_did = NULL;
				continue;

			}
			hash_code= core_hash(&callid, &to_tag, hash_size);
		
			lock_get(&rls_table[hash_code].lock);
			s= pres_search_shtable(rls_table,callid,to_tag,from_tag,hash_code);
			if(s== NULL)
			{
				LM_DBG("record not found in hash_table [rlsubs_did]= %s\n",
						curr_did);
				LM_DBG("callid= %.*s\tfrom_tag= %.*s\tto_tag= %.*s\n",
						callid.len, callid.s,from_tag.len,from_tag.s,
						to_tag.len,to_tag.s);
				lock_release(&rls_table[hash_code].lock);
				prev_did = NULL;
				continue;
			}
			LM_DBG("Found rl-subs record in hash table\n");
					
			/* save dialog info and rl_uri*/
			dialog= pres_copy_subs(s, PKG_MEM_TYPE);
			if(dialog== NULL)
			{	
				LM_ERR("while copying subs_t structure\n");
				lock_release(&rls_table[hash_code].lock);
				goto done;
			}
			dialog->expires-= (int)time(NULL);
			lock_release(&rls_table[hash_code].lock);

			/* make new rlmi and multipart documents */
			rlmi_doc= xmlNewDoc(BAD_CAST "1.0");
			if(rlmi_doc== NULL)
			{
				LM_ERR("when creating new xml doc\n");
				goto done;
			}
			list_node= xmlNewNode(NULL, BAD_CAST "list");
			if(list_node== NULL)
			{
				LM_ERR("while creating new xml node\n");
				goto done;
			}
			rl_uri= (char*)pkg_malloc((dialog->pres_uri.len+ 1)* sizeof(char));
			if(rl_uri==  NULL)
			{
				ERR_MEM(PKG_MEM_STR);
			}
			memcpy(rl_uri, dialog->pres_uri.s, dialog->pres_uri.len);
			rl_uri[dialog->pres_uri.len]= '\0';

			xmlNewProp(list_node, BAD_CAST "uri", BAD_CAST rl_uri);
			xmlNewProp(list_node, BAD_CAST "xmlns", BAD_CAST "urn:ietf:params:xml:ns:rlmi");
			xmlNewProp(list_node, BAD_CAST "version", BAD_CAST int2str(dialog->version, &len));
			xmlNewProp(list_node, BAD_CAST "fullState", BAD_CAST "false");

			xmlDocSetRootElement(rlmi_doc, list_node);
			buf_len= 0;

			/* !!!! for now I will include the auth state without checking if 
			 * it has changed - > in future chech if it works */		
		}		

		/* add a node in rlmi_doc and if any presence state registered add 
		 * it in the buffer */
		
		resource_node= xmlNewChild(list_node,NULL,BAD_CAST "resource", NULL);
		if(resource_node== NULL)
		{
			LM_ERR("when adding resource child\n");
			goto done;
		}
		xmlNewProp(resource_node, BAD_CAST "uri", BAD_CAST resource_uri);
			
		/* there might be more records with the same uri- more instances-
		 * search and add them all */
		
		contor= 0;
		while(1)
		{
			contor++;
			cid.s= NULL;
			instance_node= xmlNewChild(resource_node, NULL, 
					BAD_CAST "instance", NULL);
			if(instance_node== NULL)
			{
				LM_ERR("while adding instance child\n");
				goto error;
			}
			str_aux = generate_string(contor, 8);
			if(str_aux == NULL)
			{
				LM_ERR("failed to create random string\n");
				goto error;
			}
			xmlNewProp(instance_node, BAD_CAST "id",
					BAD_CAST str_aux);
			pkg_free(str_aux);

			auth_state= get_auth_string(auth_state_flag);
			if(auth_state== NULL)
			{
				LM_ERR("bad authorization status flag\n");
				goto error;
			}
			xmlNewProp(instance_node, BAD_CAST "state", BAD_CAST auth_state);
		
			if(auth_state_flag & ACTIVE_STATE)
			{
				cid.s= generate_cid(resource_uri, strlen(resource_uri));
				cid.len = strlen(cid.s);
				xmlNewProp(instance_node, BAD_CAST "cid", BAD_CAST cid.s);
			}
			else
			if(auth_state_flag & TERMINATED_STATE)
			{
				xmlNewProp(instance_node, BAD_CAST "reason",
					BAD_CAST row_vals[resource_uri_col].val.string_val);
			}
		
			/* add in the multipart buffer */
			if(cid.s)
			{
				APPEND_MULTIPART_BODY();
				pkg_free(cid.s);
				cid.s = NULL;
			}

			i++;
			if(i== result->n)
			{
				i--;
				break;
			}

			row = &result->rows[i];
			row_vals = ROW_VALUES(row);
	
			if(strncmp(row_vals[resource_uri_col].val.string_val,resource_uri,
					strlen(resource_uri)) || strncmp(curr_did, 
					row_vals[did_col].val.string_val, strlen(curr_did)))
			{
				i--;
				break;
			}
			resource_uri= (char*)row_vals[resource_uri_col].val.string_val;
			auth_state_flag=     row_vals[auth_state_col].val.int_val;
			body.s=   (char*)row_vals[body_col].val.string_val;
			body.len = strlen(body.s);
		}

		prev_did= curr_did;
	}

	if(rlmi_doc)
	{
		xmlDocDumpMemory( rlmi_doc,(xmlChar**)(void*)&rlmi_cont.s,
		&rlmi_cont.len);
		
		multi_cont.s= buf;
		multi_cont.len= buf_len;
	
		 if(agg_body_sendn_update(&dialog->pres_uri, bstr, &rlmi_cont, 
			 (buf_len==0)?NULL:&multi_cont, dialog, hash_code)<0)
		 {
			 LM_ERR("in function agg_body_sendn_update\n");
			 goto error;
		}
		xmlFree(rlmi_cont.s);
		pkg_free(rl_uri);
		rl_uri= NULL;
		pkg_free(dialog);
		dialog= NULL;
	}

error:
done:
	if(result)
		rls_dbf.free_result(rls_db, result);
	if(rlmi_doc)
		xmlFreeDoc(rlmi_doc);
	if(rl_uri)
		pkg_free(rl_uri);
	if(bstr.s)
		pkg_free(bstr.s);
		
	if(buf)
		pkg_free(buf);
	if(dialog)
		pkg_free(dialog);
	return;
}
Esempio n. 18
0
void CodeGen::generate_print(node *cur){
	if(cur){
		if(!cur -> data.compare("add")){
			generate_int(cur);

			std::stringstream temp_addr;
			temp_addr << "I" << compilation_temp_vars++ << "xx";

			var_addr v = {
				temp_addr.str(),
				'#',
				"digit",
				scope_level,
				temp_num++
			};

			static_table.push_back(v);

			store_acc(v.temp);

			load_y_mem(v.temp);
			load_x_const("01");
		}
		else if(std::regex_match(cur -> data, std::regex("[0-9]"))) {
			char *val_star = new char[2];
	 		std::sprintf(val_star, "%02X", std::stoi(cur -> data));

			load_y_const(val_star);
			load_x_const("01");
		}
		else if(std::regex_match(cur -> data, std::regex("\"[a-z ]*\""))){
			generate_string(cur -> data);

			std::stringstream temp_addr;
			temp_addr << "I" << compilation_temp_vars++ << "xx";

			var_addr v = {
				temp_addr.str(),
				'\"',
				"string",
				scope_level,
				temp_num++
			};

			static_table.push_back(v);

			store_acc(v.temp);

			load_y_mem(v.temp);
			load_x_const("02");
		}
		else if(std::regex_match(cur -> data, std::regex("[a-z]"))){
			load_y_mem(find_var(cur -> data[0]).temp);
			
			if(!find_var(cur -> data[0]).type.compare("string")){
				load_x_const("02");
			}
			else{
				load_x_const("01");
			}
		}

		system_call();
	}
}