Beispiel #1
0
/*
  This function is going to be used in inout.c and util.c
*/
char* 
acxnum (const char *str, const struct numfmt* pnf)
{
  char *ptr, *endrp, *ptr2;
  endrp = ptr = anum (str, pnf);

  if (ptr != str)
    {
      if (*ptr == pnf->iu)
	{
	  return ptr + 1;
	}
      else
	{
	  while (is_space (*ptr))
	    ptr++;
	  if (*ptr == POS_SIGN || *ptr == NEG_SIGN)
	    {
	      ptr2 = anum (ptr, pnf);
	      return (*ptr2 != pnf->iu ? endrp : ptr2 + 1);
	    }
	  else
	    return endrp;
	}
    }
  else
    return ptr;
}
Beispiel #2
0
	/* constructor */
static __init void g2_con_init(void)
{
	size_t i;
	/* memory for free_cons */
	for(i = 0; i < anum(free_cons); i++)
	{
		g2_connection_t *tmp = g2_con_alloc(1);
		if(tmp)
		{
			if((tmp = atomic_pxa(tmp, &free_cons[i]))) {
				logg_pos(LOGF_CRIT, "another thread working while init???\n");
				g2_con_free(tmp);
			}
		}
		else
		{
			logg_errno(LOGF_CRIT, "free_cons memory");
			if(FC_TRESHOLD < i)
				break;

			for(; i > 0; --i) {
				tmp = NULL;
				g2_con_free(atomic_pxa(tmp, &free_cons[i]));
			}
			exit(EXIT_FAILURE);
		}
	}
}
Beispiel #3
0
static void g2_con_deinit(void)
{
	size_t i;
	/* memory for free_cons */
	for(i = 0; i < anum(free_cons); i++)
	{
		g2_connection_t *tmp = NULL;
		g2_con_free(atomic_pxa(tmp, &free_cons[i]));
	}
}
Beispiel #4
0
bool config_parser_handle_bool(struct list_head *head, void *data)
{
	static const struct tr_vals
	{
		bool val;
		char txt[6];
	} tr_vals[] =
	{
		{true, "true"}, {false, "false"}, {true, "yes"}, {false, "no"},
		{true, "1"}, {false, "0"}, {true, "t"}, {false, "f"}, {true, "y"}, {false, "n"},
	};
	struct ptoken *t, *first;
	bool *target = data, found;
	unsigned i;

	first = list_entry(head->next, struct ptoken, list);
	t = config_token_after_equal(head);
	if(!t) {
		logg(LOGF_NOTICE, "Parsing config file %s@%zu: Option \"%s\" wants a value assigned, will ignore\n",
		     first->ctx->in_filename, first->ctx->line_num, first->d.t);
		return true;
	}
	for(i = 0, found = false; i < anum(tr_vals); i++)
	{
		if(0 == strcmp(tr_vals[i].txt, t->d.t)) {
			*target = tr_vals[i].val;
			found = true;
			break;
		}
	}
	if(!found) {
		logg(LOGF_NOTICE, "Parsing config file %s@%zu: I don't understand \"%s\"  for a boolean value, will ignore\n",
		     first->ctx->in_filename, first->ctx->line_num, t->d.t);
		return true;
	}
	if(!list_is_last(&t->list, head))
		logg(LOGF_INFO, "Parsing config file %s@%zu: ignored tokens after \"%s\", hopefully OK\n",
		     first->ctx->in_filename, first->ctx->line_num, t->d.t);
	return true;
}
 virtual JsonValue*      valueParseNumber(std::string* num)                  { std::unique_ptr<std::string> anum(num); return new JsonNumberItem(anum);}