Ejemplo n.º 1
0
Archivo: goc2c.c Proyecto: 0day-ci/gcc
/* Process the entire file.  */
static void
process_file(void)
{
	char *package, *name;
	struct params *params, *rets;

	package = read_package();
	read_preprocessor_lines();
	while (read_func_header(&name, &params, &rets)) {
		char *p;
		char *pkg;
		char *nm;

		p = strchr(name, '.');
		if (p == NULL) {
			pkg = package;
			nm = name;
		} else {
			pkg = name;
			nm = p + 1;
			*p = '\0';
		}
		write_func_header(pkg, nm, params, rets);
		copy_body();
		write_func_trailer(pkg, nm, rets);
		free(name);
		free_params(params);
		free_params(rets);
	}
	free(package);
}
void unit_message_serialize_request(UNUSED(void **state))
{
  msgpack_sbuffer sbuf;
  msgpack_packer pk;
  struct message_request request;
  array params;

  params.size = 1;
  params.obj = CALLOC(1, struct message_object);
  params.obj[0].type = OBJECT_TYPE_UINT;
  params.obj[0].data.uinteger = 1234;

  msgpack_sbuffer_init(&sbuf);

  /* positiv test */
  msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
  request.msgid = 1234;
  request.method = (string) {.str = "test method",
      .length = sizeof("test method") - 1};
  request.params = params;
  assert_int_equal(0, message_serialize_request(&request, &pk));
  msgpack_sbuffer_clear(&sbuf);

  /* no valid string */
  msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
  request.msgid = 1234;
  request.method = (string) STRING_INIT;
  request.params = params;
  assert_int_not_equal(0, message_serialize_request(&request, &pk));
  msgpack_sbuffer_clear(&sbuf);

  free_params(request.params);

  params.size = 1;
  params.obj = CALLOC(1, struct message_object);
  params.obj[0].type = 1000;
  params.obj[0].data.uinteger = 1234;

  /* no valid params */
  msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
  request.msgid = 1234;
  request.method = (string) {.str = "test method",
      .length = sizeof("test method") - 1};
  request.params = params;
  assert_int_not_equal(0, message_serialize_request(&request, &pk));
  msgpack_sbuffer_clear(&sbuf);

  free_params(request.params);

  /* null check */
  assert_int_not_equal(0, message_serialize_request(NULL, NULL));

  msgpack_sbuffer_destroy(&sbuf);
}
Ejemplo n.º 3
0
int xavp_params_explode(str *params, str *xname)
{
	param_t* params_list = NULL;
	param_hooks_t phooks;
	param_t *pit=NULL;
	str s;
	sr_xavp_t *xavp=NULL;
	sr_xval_t xval;

	if(params==NULL || xname==NULL || params->s==NULL || xname->s==NULL
			|| params->len<=0 || xname->len<=0)
	{
		LM_ERR("invalid parameters\n");
		return -1;
	}

	s.s = params->s;
	s.len = params->len;
	if(s.s[s.len-1]==';')
		s.len--;
	if (parse_params(&s, CLASS_ANY, &phooks, &params_list)<0) {
		LM_DBG("invalid formatted values [%.*s]\n", params->len, params->s);
		return -1;
	}

	if(params_list==NULL) {
		return -1;
	}


	for (pit = params_list; pit; pit=pit->next)
	{
		memset(&xval, 0, sizeof(sr_xval_t));
		xval.type = SR_XTYPE_STR;
		xval.v.s = pit->body;
		if(xavp_add_value(&pit->name, &xval, &xavp)==NULL) {
			free_params(params_list);
			xavp_destroy_list(&xavp);
			return -1;
		}
	}
	free_params(params_list);

	/* add main xavp in root list */
	memset(&xval, 0, sizeof(sr_xval_t));
	xval.type = SR_XTYPE_XAVP;
	xval.v.xavp = xavp;
	if(xavp_add_value(xname, &xval, NULL)==NULL) {
		xavp_destroy_list(&xavp);
		return -1;
	}

	return 0;
}
Ejemplo n.º 4
0
int mq_param(modparam_t type, void *val)
{
	str mqs;
	param_t* params_list = NULL;
	param_hooks_t phooks;
	param_t *pit=NULL;
	str qname = {0, 0};
	int msize = 0;

	if(val==NULL)
		return -1;

	if(!shm_initialized())
	{
		LM_ERR("shm not initialized - cannot define mqueue now\n");
		return 0;
	}

	mqs.s = (char*)val;
	mqs.len = strlen(mqs.s);
	if(mqs.s[mqs.len-1]==';')
		mqs.len--;
	if (parse_params(&mqs, CLASS_ANY, &phooks, &params_list)<0)
		return -1;
	for (pit = params_list; pit; pit=pit->next)
	{
		if (pit->name.len==4
				&& strncasecmp(pit->name.s, "name", 4)==0) {
			qname = pit->body;
		} else if(pit->name.len==4
				&& strncasecmp(pit->name.s, "size", 4)==0) {
			str2sint(&pit->body, &msize);
		}  else {
			LM_ERR("unknown param: %.*s\n", pit->name.len, pit->name.s);
			free_params(params_list);
			return -1;
		}
	}
	if(qname.len<=0)
	{
		LM_ERR("mqueue name not defined: %.*s\n", mqs.len, mqs.s);
		free_params(params_list);
		return -1;
	}
	if(mq_head_add(&qname, msize)<0)
	{
		LM_ERR("cannot add mqueue: %.*s\n", mqs.len, mqs.s);
		free_params(params_list);
		return -1;
	}
	free_params(params_list);
	return 0;
}
Ejemplo n.º 5
0
/*
 * Find if Request URI has a given parameter with matching value
 */
int uri_param_2(struct sip_msg* _msg, char* _param, char* _value)
{
	str *param, *value, t;

	param_hooks_t hooks;
	param_t* params;

	param = (str*)_param;
	value = (str*)_value;

	if (parse_sip_msg_uri(_msg) < 0) {
	        LM_ERR("ruri parsing failed\n");
	        return -1;
	}

	t = _msg->parsed_uri.params;

	if (parse_params(&t, CLASS_ANY, &hooks, &params) < 0) {
	        LM_ERR("ruri parameter parsing failed\n");
	        return -1;
	}

	while (params) {
		if ((params->name.len == param->len) &&
		    (strncmp(params->name.s, param->s, param->len) == 0)) {
			if (value) {
				if ((value->len == params->body.len) &&
				    strncmp(value->s, params->body.s, value->len) == 0) {
					goto ok;
				} else {
					goto nok;
				}
			} else {
				if (params->body.len > 0) {
					goto nok;
				} else {
					goto ok;
				}
			}
		} else {
			params = params->next;
		}
	}

nok:
	free_params(params);
	return -1;

ok:
	free_params(params);
	return 1;
}
Ejemplo n.º 6
0
static int check_ftag(struct sip_msg* msg, str* uri)
{
	param_hooks_t hooks;
	param_t* params;
	char* semi;
	struct to_body* from;
	str t;

	t = *uri;
	params = 0;
	semi = q_memchr(t.s, ';', t.len);
	if (!semi) {
		DBG("No ftag parameter found\n");
		return -1;
	}

	t.len -= semi - uri->s + 1;
	t.s = semi + 1;
	trim_leading(&t);

	if (parse_params(&t, CLASS_URI, &hooks, &params) < 0) {
		ERR("Error while parsing parameters\n");
		return -1;
	}

	if (!hooks.uri.ftag) {
		DBG("No ftag parameter found\n");
		goto err;
	}

	from = get_from(msg);

	if (!from || !from->tag_value.len || !from->tag_value.s) {
		DBG("No from tag parameter found\n");
		goto err;
	}

	if (from->tag_value.len == hooks.uri.ftag->body.len &&
	    !strncmp(from->tag_value.s, hooks.uri.ftag->body.s, hooks.uri.ftag->body.len)) {
		DBG("Route ftag and From tag are same\n");
		free_params(params);
		return 0;
	} else {
		DBG("Route ftag and From tag are NOT same\n");
		free_params(params);
		return 1;
	}

 err:
	if (params) free_params(params);
	return -1;
}
Ejemplo n.º 7
0
static void free_message_object(message_object obj)
{
  switch (obj.type) {
  case OBJECT_TYPE_NIL:
    break;
  case OBJECT_TYPE_INT:
    break;
  case OBJECT_TYPE_UINT:
    break;
  case OBJECT_TYPE_BIN:
    /* FALLTHROUGH */
  case OBJECT_TYPE_STR:
    free_string(obj.data.string);
    break;
  case OBJECT_TYPE_BOOL:
    break;
  case OBJECT_TYPE_FLOAT:
    break;
  case OBJECT_TYPE_ARRAY:
    free_params(obj.data.params);
    break;
  default:
    return;
  }
}
Ejemplo n.º 8
0
void
g_flickr_tags_getHotList (GFlickr *f,
                          gint count,
                          GFlickrListCb callback,
                          gpointer user_data)
{
  g_return_if_fail (G_IS_FLICKR (f));

  gchar *params[2];

  params[0] = g_strdup_printf ("count=%d", count);
  params[1] = g_strdup_printf ("method=%s", FLICKR_TAGS_GETHOTLIST_METHOD);

  gchar *request = create_url (f, params, 2);

  free_params (params, 2);

  GFlickrData *gfd = g_slice_new (GFlickrData);
  gfd->flickr = g_object_ref (f);
  gfd->parse_xml = process_taglist_result;
  gfd->list_cb = callback;
  gfd->user_data = user_data;

  read_url_async (f, request, gfd);
  g_free (request);
}
Ejemplo n.º 9
0
Archivo: mysh.c Proyecto: Sweta23/ucsc
// --------------------------------------------------------------------------
int main(int argc, char** argv)
{
    struct params* params = 0;


    signal(SIGUSR1, signal_handler);

    params = alloc_params();
    extract_params_from_cmdline_options(params, argc, argv);

    if (is_help_desired(params)) {
        show_help(argv[0]);
        goto done;
    }

    if (use_sysv_ipc(params)) {
        mysh_implemented_with_sysv_ipc();
    } else {
        mysh_implemented_with_pipe();
    }

done:
    free_params(params);

    return 0;
}
Ejemplo n.º 10
0
CAMLprim value PQexecPrepared_stub(
  value v_conn, value v_stm_name, value v_params, value v_binary_params)
{
  CAMLparam1(v_conn);
  PGconn *conn = get_conn(v_conn);
  np_callback *np_cb = get_conn_cb(v_conn);
  PGresult *res;
  size_t len = caml_string_length(v_stm_name) + 1;
  char *stm_name = caml_stat_alloc(len);
  size_t nparams = Wosize_val(v_params);
  const char * const *params = copy_params(v_params, nparams);
  int *formats, *lengths;
  copy_binary_params(v_params, v_binary_params, nparams, &formats, &lengths);
  memcpy(stm_name, String_val(v_stm_name), len);
  caml_enter_blocking_section();
    res = PQexecPrepared(conn, stm_name, nparams, params, lengths, formats, 0);
    free(stm_name);
    free_binary_params(formats, lengths);
    free_params(params, nparams);
  caml_leave_blocking_section();
  CAMLreturn(alloc_result(res, np_cb));
#else
CAMLprim value PQexecPrepared_stub(
  value __unused v_conn, value __unused v_stm_name, value __unused v_params,
  value __unused v_binary_params)
{
  caml_failwith("Postgresql.exec_prepared: not supported");
  return Val_unit;
#endif
}
Ejemplo n.º 11
0
static void decode_params(game_params *params, char const *string)
{
    char const *p = string;
    game_params *defs = default_params();

    *params = *defs; free_params(defs);

    while (*p) {
        switch (*p++) {
        case 'w':
            params->w = atoi(p);
            while (*p && isdigit((unsigned char)*p)) p++;
            break;

        case 'h':
            params->h = atoi(p);
            while (*p && isdigit((unsigned char)*p)) p++;
            break;

        case 'm':
            params->minballs = atoi(p);
            while (*p && isdigit((unsigned char)*p)) p++;
            break;

        case 'M':
            params->maxballs = atoi(p);
            while (*p && isdigit((unsigned char)*p)) p++;
            break;

        default:
            ;
        }
    }
}
Ejemplo n.º 12
0
int statsc_track_param(modparam_t type, void* val)
{
	param_t* params_list = NULL;
	param_hooks_t phooks;
	param_t *pit=NULL;
	str s;

	if(val==NULL)
		return -1;
	if(statsc_init()<0)
		return -1;
	s.s = (char*)val;
	s.len = strlen(s.s);
	if(s.s[s.len-1]==';')
		s.len--;
	if (parse_params(&s, CLASS_ANY, &phooks, &params_list)<0)
		return -1;
	for (pit = params_list; pit; pit=pit->next) {
		if(statsc_nmap_add(&pit->name, &pit->body)<0) {
			LM_ERR("cannot enable tracking statistics\n");
			return -1;
		}
	}
	free_params(params_list);
	return 0;
}
Ejemplo n.º 13
0
CAMLprim value PQexecParams_stub(
  value v_conn, value v_query, value v_params, value v_binary_params)
{
  CAMLparam1(v_conn);
  PGconn *conn = get_conn(v_conn);
  np_callback *np_cb = get_conn_cb(v_conn);
  PGresult *res;
  size_t len = caml_string_length(v_query) + 1;
  char *query = caml_stat_alloc(len);
  size_t nparams = Wosize_val(v_params);
  const char * const *params = copy_params(v_params, nparams);
  int *formats, *lengths;
  copy_binary_params(v_params, v_binary_params, nparams, &formats, &lengths);
  memcpy(query, String_val(v_query), len);
  caml_enter_blocking_section();
    res =
      (nparams == 0)
        ? PQexec(conn, query)
        : PQexecParams(conn, query, nparams, NULL, params, lengths, formats, 0);
    free_binary_params(formats, lengths);
    free_params(params, nparams);
    free(query);
  caml_leave_blocking_section();
  CAMLreturn(alloc_result(res, np_cb));
}
Ejemplo n.º 14
0
// --------------------------------------------------------------------------
int main(int argc, char** argv)
{
    struct params* params = 0;
    int sockfd = -1;

    params = alloc_params();
    extract_params_from_cmdline_options(params, argc, argv);

    if (is_help_desired(params)) {
        show_help(argv[0]);
        goto out;
    }

    sockfd = inet_connect(hostname(params), portnumber(params), SOCK_STREAM);
    if (sockfd < 0) {
        fprintf(stderr, "failed to connect to remote host.\n");
        goto out;
    }

    do_interactive_loop(sockfd);

out:
    if (sockfd > 0) {
        close(sockfd);
    }

    free_params(params);

    return 0;
}
Ejemplo n.º 15
0
void
g_flickr_auth_checkToken (GFlickr *f,
                          const gchar *token,
                          GFlickrHashTableCb callback,
                          gpointer user_data)
{
  gchar *request;
  gchar *params[1];

  g_return_if_fail (G_IS_FLICKR (f));
  g_return_if_fail (token);
  g_return_if_fail (callback);

  params[0] = g_strdup_printf ("method=%s", FLICKR_OAUTH_CHECKTOKEN_METHOD);

  request = create_url (f, params, 1);

  free_params (params, 1);

  GFlickrData *gfd = g_slice_new (GFlickrData);
  gfd->flickr = g_object_ref (f);
  gfd->parse_xml = process_token_result;
  gfd->hashtable_cb = callback;
  gfd->user_data = user_data;

  read_url_async (f, request, gfd);
  g_free (request);
}
Ejemplo n.º 16
0
void
g_flickr_photosets_getPhotos (GFlickr *f,
                              const gchar *photoset_id,
                              gint page,
                              GFlickrListCb callback,
                              gpointer user_data)
{
  g_return_if_fail (G_IS_FLICKR (f));
  g_return_if_fail (photoset_id);

  gchar *params[6];

  params[0] = g_strdup_printf ("photoset_id=%s", photoset_id);
  params[1] = g_strdup ("extras=date_taken,owner_name,url_o,url_t,media");
  params[2] = g_strdup ("media=photos");
  params[3] = g_strdup_printf ("page=%d", page);
  params[4] = g_strdup_printf ("per_page=%d", f->priv->per_page);
  params[5] = g_strdup_printf ("method=%s", FLICKR_PHOTOSETS_GETPHOTOS_METHOD);

  gchar *request = create_url (f, params, 6);

  free_params (params, 6);

  GFlickrData *gfd = g_slice_new (GFlickrData);
  gfd->flickr = g_object_ref (f);
  gfd->parse_xml = process_photosetsphotos_result;
  gfd->list_cb = callback;
  gfd->user_data = user_data;

  read_url_async (f, request, gfd);
  g_free (request);
}
Ejemplo n.º 17
0
void
g_flickr_photosets_getList (GFlickr *f,
                           const gchar *user_id,
                           GFlickrListCb callback,
                           gpointer user_data)
{
  /* Either we insert user_id or not */
  gint params_no = (user_id == NULL) ? 1 : 2;

  gchar *params[2];

  params[0] = g_strdup_printf ("method=%s", FLICKR_PHOTOSETS_GETLIST_METHOD);

  if (user_id != NULL)
    params[1] = g_strdup_printf ("user_id=%s", user_id);

  gchar *request = create_url (f, params, params_no);

  free_params (params, params_no);

  GFlickrData *gfd = g_slice_new (GFlickrData);
  gfd->flickr = g_object_ref (f);
  gfd->parse_xml = process_photosetslist_result;
  gfd->list_cb = callback;
  gfd->user_data = user_data;

  read_url_async (f, request, gfd);
  g_free (request);
}
Ejemplo n.º 18
0
double VilmaOracle::PwVilmaRegularized<Loss>::risk(const double *weights,
                                                   double *subgrad) {
  const int pw_dim = data_->GetDataDim() * kPW;
  std::fill(subgrad, subgrad + GetOracleParamsDim(), 0);

  const int nexamples = data_->GetDataNumExamples();

  DenseVecD w(pw_dim, const_cast<double *>(weights));
  // free_params is theta for Ord and beta for Mord
  DenseVecD free_params(this->GetFreeParamsDim(),
                        const_cast<double *>(weights) + pw_dim);

  ProjectData(w, data_, wx_buffer_.get(), kPW);

  double *wx = wx_buffer_.get();
  double obj = 0;

  for (int example_idx = 0; example_idx < nexamples; ++example_idx) {
    double val = this->UpdateSingleExampleGradient(free_params, wx, example_idx,
                                                   subgrad, subgrad + pw_dim);
    obj += val;
    wx += kPW;
  }
  // normalize
  for (int i = 0; i < this->GetOracleParamsDim(); ++i) subgrad[i] /= nexamples;
  obj /= nexamples;

  return obj;
}
Ejemplo n.º 19
0
void
g_flickr_photos_getInfo (GFlickr *f,
                         const gchar *photo_id,
                         GFlickrHashTableCb callback,
                         gpointer user_data)
{
  g_return_if_fail (G_IS_FLICKR (f));

  gchar *params[2];

  params[0] = g_strdup_printf ("photo_id=%s", photo_id);
  params[1] = g_strdup_printf ("method=%s", FLICKR_PHOTOS_GETINFO_METHOD);

  gchar *request = create_url (f, params, 2);

  free_params (params, 2);

  GFlickrData *gfd = g_slice_new (GFlickrData);
  gfd->flickr = g_object_ref (f);
  gfd->parse_xml = process_photo_result;
  gfd->hashtable_cb = callback;
  gfd->user_data = user_data;

  read_url_async (f, request, gfd);
  g_free (request);
}
Ejemplo n.º 20
0
int mt_node_set_payload(mt_node_t *node, int type)
{
	param_t *list;
	param_t *it;
	param_hooks_t hooks;
	str s;
	mt_dw_t *dwl;
	mt_dw_t *dw;

	if(type!=MT_TREE_DW)
		return 0;
	s = node->tvalues->tvalue.s;
	if(s.s[s.len-1]==';')
		s.len--;
	if(parse_params(&s, CLASS_ANY, &hooks, &list)<0)
	{
		LM_ERR("cannot parse tvalue payload [%.*s]\n", s.len, s.s);
		return -1;
	}
	dwl = NULL;
	for(it=list; it; it=it->next)
	{
		dw = (mt_dw_t*)shm_malloc(sizeof(mt_dw_t));
		if(dw==NULL)
		{
			LM_ERR("no more shm\n");
			goto error;
		}
		memset(dw, 0, sizeof(mt_dw_t));
		str2int(&it->name, &dw->dstid);
		str2int(&it->body, &dw->weight);
		dw->next = dwl;
		dwl = dw;
	}
	node->data = (void*)dwl;
	free_params(list);
	return 0;
error:
	while(dwl)
	{
		dw=dwl;
		dwl=dwl->next;
		shm_free(dwl);
	}
	free_params(list);
	return -1;
}
Ejemplo n.º 21
0
/*! \brief
 * Free all memory
 */
void free_event(event_t** _e)
{
	if (*_e) {
		if ((*_e)->params.list) free_params((*_e)->params.list);
		pkg_free(*_e);
		*_e = NULL;
	}
}
Ejemplo n.º 22
0
/**
 * Find if Request URI has a given parameter and returns the value.
 */
int get_uri_param(struct sip_msg* _msg, char* _param, char* _value)
{
	str *param, t;
	pv_spec_t* dst;
	pv_value_t val;

	param_hooks_t hooks;
	param_t* params;

	param = (str*)_param;
	dst = (pv_spec_t *) _value;
  
	if (parse_sip_msg_uri(_msg) < 0) {
		LM_ERR("ruri parsing failed\n");
		return -1;
	}

	t = _msg->parsed_uri.params;

	if (parse_params(&t, CLASS_ANY, &hooks, &params) < 0) {
		LM_ERR("ruri parameter parsing failed\n");
		return -1;
	}

	while (params) {
		if ((params->name.len == param->len)
				&& (strncmp(params->name.s, param->s, param->len) == 0)) {
			memset(&val, 0, sizeof(pv_value_t));
			val.rs.s = params->body.s;
			val.rs.len = params->body.len;
			val.flags = PV_VAL_STR;
			dst->setf(_msg, &dst->pvp, (int)EQ_T, &val);
			goto found;
		} else {
			params = params->next;
		}
	}
  
	free_params(params);
	return -1;

found:
	free_params(params);
	return 1;
}
Ejemplo n.º 23
0
/*
 * Free all memory
 */
void free_event(event_t** _e)
{
	if (*_e)
	{	
		if((*_e)->params)
			free_params((*_e)->params);
		pkg_free(*_e);
	}	
	*_e = 0;
}
Ejemplo n.º 24
0
/* Process the entire file.  */
static void
process_file(void)
{
	char *package, *name;
	struct params *params, *rets;
	int paramwid;

	package = read_package();
	read_preprocessor_lines();
	while (read_func_header(&name, &params, &paramwid, &rets)) {
		write_func_header(package, name, params, paramwid, rets);
		copy_body();
		write_func_trailer(package, name, rets);
		free(name);
		free_params(params);
		free_params(rets);
	}
	free(package);
}
Ejemplo n.º 25
0
void keyvalue_destroy(keyvalue_t *res)
{
	if(res==NULL)
		return;
	if(res->type==KEYVALUE_TYPE_PARAMS)
	{
		if(res->u.params!=NULL)
			free_params(res->u.params);
	}
	memset(res, 0, sizeof(keyvalue_t));
}
Ejemplo n.º 26
0
/**
 * @brief destroy dmq node
 */
void destroy_dmq_node(dmq_node_t* node, int shm)
{
    if(shm) {
        if (node->params!=NULL)
            shm_free_params(node->params);
        shm_free_node(node);
    } else {
        if (node->params!=NULL)
            free_params(node->params);
        pkg_free_node(node);
    }
}
Ejemplo n.º 27
0
static void test_param_flt(CuTest * tc)
{
    struct param *par = 0;
    test_cleanup();
    CuAssertDblEquals(tc, 13, get_param_flt(par, "foo", 13), 0.01);
    set_param(&par, "foo", "23.0");
    set_param(&par, "bar", "42.0");
    CuAssertDblEquals(tc, 23.0, get_param_flt(par, "foo", 0.0), 0.01);
    CuAssertDblEquals(tc, 42.0, get_param_flt(par, "bar", 0.0), 0.01);
    free_params(&par);
    test_cleanup();
}
Ejemplo n.º 28
0
static void test_param_int(CuTest * tc)
{
    struct param *par = 0;
    test_cleanup();
    CuAssertIntEquals(tc, 13, get_param_int(par, "foo", 13));
    set_param(&par, "foo", "23");
    set_param(&par, "bar", "42");
    CuAssertIntEquals(tc, 23, get_param_int(par, "foo", 0));
    CuAssertIntEquals(tc, 42, get_param_int(par, "bar", 0));
    free_params(&par);
    test_cleanup();
}
Ejemplo n.º 29
0
int tps_get_param_value(str *in, str *name, str *value)
{
	param_t* params = NULL;
	param_t* p = NULL;
	param_hooks_t phooks;
	if (parse_params(in, CLASS_ANY, &phooks, &params)<0)
		return -1;
	for (p = params; p; p=p->next)
	{
		if (p->name.len==name->len
				&& strncasecmp(p->name.s, name->s, name->len)==0)
		{
			*value = p->body;
			free_params(params);
			return 0;
		}
	}
	
	if(params) free_params(params);
	return 1;

}
Ejemplo n.º 30
0
/*
 * Free list of contacts
 * _c is head of the list
 */
void free_contacts(contact_t** _c)
{
	contact_t* ptr;

	while(*_c) {
		ptr = *_c;
		*_c = (*_c)->next;
		if (ptr->params) {
			free_params(ptr->params);
		}
		pkg_free(ptr);
	}
}