当前位置: 首页>>代码示例>>C++>>正文


C++ VAL_STRING函数代码示例

本文整理汇总了C++中VAL_STRING函数的典型用法代码示例。如果您正苦于以下问题:C++ VAL_STRING函数的具体用法?C++ VAL_STRING怎么用?C++ VAL_STRING使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VAL_STRING函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: notification_cb

/* callback intercepting all notifications. The registeration is done in y_interfaces_alarms_init */
status_t notification_cb(agt_not_msg_t *notif)
{
    val_value_t *payload_val;
    char description_str[1024];
    status_t res;
    int ret;

    if((0==strcmp(obj_get_name(notif->notobj),"link-up")) || (0==strcmp(obj_get_name(notif->notobj),"link-down"))) {
        int down;
    	down = (0==strcmp(obj_get_name(notif->notobj),"link-down"));
        for (payload_val = (val_value_t *)dlq_firstEntry(&notif->payloadQ);
             payload_val != NULL;
             payload_val = (val_value_t *)dlq_nextEntry(payload_val)) {
            if(0==strcmp("if-name",obj_get_name(payload_val->obj))) {
                char* resource_str;
                sprintf(description_str,"Link down - %s",VAL_STRING(payload_val));
                //alarm_event_w_type(description_str, "minor", "communications", down?1:0);
                resource_str=malloc(strlen("/interfaces/interface[name=\'%s\']")+strlen(VAL_STRING(payload_val))+1);
                sprintf(resource_str,"/interfaces/interface[name=\'%s\']",VAL_STRING(payload_val));
                ret=alarmctrl_event(resource_str, "link-alarm"/*alarm_type_id_str*/, ""/*alarm_type_qualifier_str*/, "major", "Probably someone disconnected something?!", down?1:0);
                //assert(ret==0);
                free(resource_str);
                break;
            }
        }
    }
    return NO_ERR;
}
开发者ID:vlvassilev,项目名称:yuma123,代码行数:29,代码来源:interfaces-alarms.c

示例2: db_sqlite_bind_values

static int db_sqlite_bind_values(sqlite3_stmt* stmt, const db_val_t* v, const int n)
{
	int i, ret;

	if (n>0 && v) {
		for (i=0; i<n; i++) {
			if (VAL_NULL(v+i)) {
				ret=sqlite3_bind_null(stmt, i+1);
				goto check_ret;
			}


			switch(VAL_TYPE(v+i)) {
				/* every param has '+1' index because in sqlite the leftmost
				 * parameter has index '1' */
				case DB_INT:
					ret=sqlite3_bind_int(stmt, i+1, VAL_INT(v+i));
					break;
				case DB_BIGINT:
					ret=sqlite3_bind_int64(stmt, i+1, VAL_BIGINT(v+i));
					break;
				case DB_DOUBLE:
					ret=sqlite3_bind_double(stmt, i+1, VAL_DOUBLE(v+i));
					break;
				case DB_STRING:
					ret=sqlite3_bind_text(stmt, i+1, VAL_STRING(v+i),
											strlen(VAL_STRING(v+i)), SQLITE_STATIC);
					break;
				case DB_STR:
					ret=sqlite3_bind_text(stmt, i+1, VAL_STR(v+i).s,
											VAL_STR(v+i).len, SQLITE_STATIC);
					break;
				case DB_DATETIME:
					ret=sqlite3_bind_int64(stmt, i+1, (long int)VAL_TIME(v+i));
					break;
				case DB_BLOB:
					ret=sqlite3_bind_blob(stmt, i+1, (void*)VAL_BLOB(v+i).s,
											VAL_BLOB(v+i).len, SQLITE_STATIC);
					break;
				case DB_BITMAP:
					ret=sqlite3_bind_int(stmt, i+1, (int)VAL_BITMAP(v+i));
					break;
				default:
					LM_BUG("invalid db type\n");
					return 1;
			}

check_ret:
			if (ret != SQLITE_OK) {
				return ret;
			}
		}
	}

	return SQLITE_OK;
}
开发者ID:AndreiPlesa,项目名称:opensips,代码行数:56,代码来源:dbase.c

示例3: bdb_ufield_db2bdb

int bdb_ufield_db2bdb(bdb_uval_p v, db_val_t* _v)
{
	char	*s;

	VAL_NULL(&(v->v)) = VAL_NULL(_v);
	VAL_TYPE(&(v->v)) = VAL_TYPE(_v);

	if (!VAL_NULL(&(v->v))) {
		switch (VAL_TYPE(_v)) {
		case DB_INT:
			VAL_INT(&(v->v)) = VAL_INT(_v);
			break;
		case DB_FLOAT:
			VAL_FLOAT(&(v->v)) = VAL_FLOAT(_v);
			break;
		case DB_DATETIME:
			VAL_TIME(&(v->v)) = VAL_TIME(_v);
			break;
		case DB_BLOB:
			s = pkg_malloc(VAL_BLOB(_v).len);
			memcpy(s, VAL_BLOB(_v).s, VAL_BLOB(_v).len);
			VAL_BLOB(&(v->v)).s = s;
			VAL_BLOB(&(v->v)).len = VAL_BLOB(_v).len;
			break;
		case DB_DOUBLE:
			VAL_DOUBLE(&(v->v)) = VAL_DOUBLE(_v);
			break;
		case DB_STRING:
			VAL_STR(&(v->v)).len = strlen(VAL_STRING(_v)) + 1;
			s = pkg_malloc(VAL_STR(&(v->v)).len);
			strcpy(s, VAL_STRING(_v));
			VAL_STRING(&(v->v)) = s;
			break;
		case DB_STR:
			s = pkg_malloc(VAL_STR(_v).len);
			memcpy(s, VAL_STR(_v).s, VAL_STR(_v).len);
			VAL_STR(&(v->v)).s = s;
			VAL_STR(&(v->v)).len = VAL_STR(_v).len;
			break;
		case DB_BITMAP:
			VAL_BITMAP(&(v->v)) = VAL_BITMAP(_v);
			break;
		default:
			LOG(L_ERR, "BDB:bdb_ufield_db2bdb: unknown column type: %0X\n", VAL_TYPE(_v));
			return -1;
			break;
		}
	}

	return 0;
};
开发者ID:BackupTheBerlios,项目名称:ser,代码行数:51,代码来源:bdb_uval.c

示例4: bdb_set_key

int bdb_set_key(bdb_row_p _r, bdb_val_p _v)
{
	/* NULL is not allowed for primary key */
	if (VAL_NULL(&(_v->v))) {
		LOG(L_ERR, "BDB:bdb_set_key: NULL is not allowed for primary key\n");
		return -1;
	}

	switch (VAL_TYPE(&(_v->v))) {
	case DB_INT:
		_r->key.data = &VAL_INT(&(_v->v));
		_r->key.size = sizeof(VAL_INT(&(_v->v)));
		break;
	case DB_FLOAT:
		_r->key.data = &VAL_FLOAT(&(_v->v));
		_r->key.size = sizeof(VAL_FLOAT(&(_v->v)));
		break;
	case DB_DATETIME:
		_r->key.data = &VAL_TIME(&(_v->v));
		_r->key.size = sizeof(VAL_TIME(&(_v->v)));
		break;
	case DB_BLOB:
		_r->key.data = VAL_BLOB(&(_v->v)).s;
		_r->key.size = VAL_BLOB(&(_v->v)).len;
		break;
	case DB_DOUBLE:
		_r->key.data = &VAL_DOUBLE(&(_v->v));
		_r->key.size = sizeof(VAL_DOUBLE(&(_v->v)));
		break;
	case DB_STRING:
		_r->key.data = (void *)VAL_STRING(&(_v->v));
		_r->key.size = strlen(VAL_STRING(&(_v->v))) + 1;
		break;
	case DB_STR:
		_r->key.data = VAL_STR(&(_v->v)).s;
		_r->key.size = VAL_STR(&(_v->v)).len;
		break;
	case DB_BITMAP:
		_r->key.data = &VAL_BITMAP(&(_v->v));
		_r->key.size = sizeof(VAL_BITMAP(&(_v->v)));
		break;
	default:
		LOG(L_ERR, "BDB:bdb_set_skey: unknown column type: %0X\n", VAL_TYPE(&(_v->v)));
		return -1;
		break;
	}

	return 0;
};
开发者ID:BackupTheBerlios,项目名称:ser,代码行数:49,代码来源:bdb_val.c

示例5: bdb_set_skey

void bdb_set_skey(bdb_srow_p _r, bdb_sval_p _v)
{
	/* NULL is not allowed for primary key */
	if (VAL_NULL(&(_v->v)))
		return;

	switch (VAL_TYPE(&(_v->v))) {
	case DB_INT:
		_r->key.data = &VAL_INT(&(_v->v));
		_r->key.size = sizeof(VAL_INT(&(_v->v)));
		break;
	case DB_FLOAT:
		_r->key.data = &VAL_FLOAT(&(_v->v));
		_r->key.size = sizeof(VAL_FLOAT(&(_v->v)));
		break;
	case DB_DATETIME:
		_r->key.data = &VAL_TIME(&(_v->v));
		_r->key.size = sizeof(VAL_TIME(&(_v->v)));
		break;
	case DB_BLOB:
		_r->key.data = VAL_BLOB(&(_v->v)).s;
		_r->key.size = VAL_BLOB(&(_v->v)).len;
		break;
	case DB_DOUBLE:
		_r->key.data = &VAL_DOUBLE(&(_v->v));
		_r->key.size = sizeof(VAL_DOUBLE(&(_v->v)));
		break;
	case DB_STRING:
		_r->key.data = (void *)VAL_STRING(&(_v->v));
		_r->key.size = strlen(VAL_STRING(&(_v->v))) + 1;
		break;
	case DB_STR:
		_r->key.data = VAL_STR(&(_v->v)).s;
		_r->key.size = VAL_STR(&(_v->v)).len;
		break;
	case DB_BITMAP:
		_r->key.data = &VAL_BITMAP(&(_v->v));
		_r->key.size = sizeof(VAL_BITMAP(&(_v->v)));
		break;
	default:
		LOG(L_ERR, "BDB:bdb_set_skey: unknown column type: %0X\n", VAL_TYPE(&(_v->v)));
		break;
	}

#ifdef BDB_EXTRA_DEBUG
	LOG(L_NOTICE, "BDB:bdb_set_skey: use key '%.*s' (%d bytes)\n", _r->key.size, (char *)_r->key.data, _r->key.size);
#endif
};
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:48,代码来源:bdb_sval.c

示例6: y_starter_starter_kill_vnf_invoke

/********************************************************************
* FUNCTION y_starter_starter_kill_vnf_invoke
* 
* RPC invocation phase
* All constraints have passed at this point.
* Call device instrumentation code in this function.
* 
* INPUTS:
*     see agt/agt_rpc.h for details
* 
* RETURNS:
*     error status
********************************************************************/
static status_t y_starter_starter_kill_vnf_invoke (
    ses_cb_t *scb,
    rpc_msg_t *msg,
    xml_node_t *methnode)
{
    status_t res = NO_ERR;

    val_value_t *vnfID_val;
    const xmlChar *vnfID;

    vnfID_val = val_find_child(
        msg->rpc_input,
        y_starter_M_starter,
        y_starter_N_vnfID);
    if (vnfID_val != NULL && vnfID_val->res == NO_ERR) {
        vnfID = VAL_STRING(vnfID_val);
    }

    /* remove the next line if scb is used */
    (void)scb;

    /* remove the next line if methnode is used */
    (void)methnode;

    /* invoke your device instrumentation code here */
    
    return res;

} /* y_starter_starter_kill_vnf_invoke */
开发者ID:fredericoschardong,项目名称:escape,代码行数:42,代码来源:starter.c

示例7: y_starter_starter_kill_vnf_validate

/********************************************************************
* FUNCTION y_starter_starter_kill_vnf_validate
* 
* RPC validation phase
* All YANG constraints have passed at this point.
* Add description-stmt checks in this function.
* 
* INPUTS:
*     see agt/agt_rpc.h for details
* 
* RETURNS:
*     error status
********************************************************************/
static status_t y_starter_starter_kill_vnf_validate (
    ses_cb_t *scb,
    rpc_msg_t *msg,
    xml_node_t *methnode)
{
    status_t res = NO_ERR;
    val_value_t *errorval = NULL;

    val_value_t *vnfID_val;
    const xmlChar *vnfID;

    vnfID_val = val_find_child(
        msg->rpc_input,
        y_starter_M_starter,
        y_starter_N_vnfID);
    if (vnfID_val != NULL && vnfID_val->res == NO_ERR) {
        vnfID = VAL_STRING(vnfID_val);
    }

    if (res != NO_ERR) {
        agt_record_error(
            scb,
            &msg->mhdr,
            NCX_LAYER_OPERATION,
            res,
            methnode,
            (errorval) ? NCX_NT_VAL : NCX_NT_NONE,
            errorval,
            (errorval) ? NCX_NT_VAL : NCX_NT_NONE,
            errorval);
    }
    return res;

} /* y_starter_starter_kill_vnf_validate */
开发者ID:fredericoschardong,项目名称:escape,代码行数:47,代码来源:starter.c

示例8: y_starter_starter_start_vnf_validate

/********************************************************************
* FUNCTION y_starter_starter_start_vnf_validate
* 
* RPC validation phase
* All YANG constraints have passed at this point.
* Add description-stmt checks in this function.
* 
* INPUTS:
*     see agt/agt_rpc.h for details
* 
* RETURNS:
*     error status
********************************************************************/
static status_t y_starter_starter_start_vnf_validate (
    ses_cb_t *scb,
    rpc_msg_t *msg,
    xml_node_t *methnode)
{
    status_t res = NO_ERR;
    val_value_t *errorval = NULL;

    val_value_t *port_val;
    const xmlChar *port;
    val_value_t *clickDescription_val;
    const xmlChar *clickDescription;

    port_val = val_find_child(
        msg->rpc_input,
        y_starter_M_starter,
        y_starter_N_port);
    if (port_val != NULL && port_val->res == NO_ERR) {
        port = VAL_STRING(port_val);
    }

    clickDescription_val = val_find_child(
        msg->rpc_input,
        y_starter_M_starter,
        y_starter_N_clickDescription);
    if (clickDescription_val != NULL && clickDescription_val->res == NO_ERR) {
        clickDescription = VAL_STRING(clickDescription_val);
    }

    if (res != NO_ERR) {
        agt_record_error(
            scb,
            &msg->mhdr,
            NCX_LAYER_OPERATION,
            res,
            methnode,
            (errorval) ? NCX_NT_VAL : NCX_NT_NONE,
            errorval,
            (errorval) ? NCX_NT_VAL : NCX_NT_NONE,
            errorval);
    }
    return res;

} /* y_starter_starter_start_vnf_validate */
开发者ID:fredericoschardong,项目名称:escape,代码行数:57,代码来源:starter.c

示例9: switch

inline SV *valdata(db_val_t* val) {
	SV *data = &PL_sv_undef;
	const char* stringval;

	switch(VAL_TYPE(val)) {
		case DB1_INT:
			data = newSViv(VAL_INT(val));
			break;

		case DB1_BIGINT:
			LM_ERR("BIGINT not supported");
			data = &PL_sv_undef;
			break;

		case DB1_DOUBLE:
			data = newSVnv(VAL_DOUBLE(val));
			break;

		case DB1_STRING:
			stringval = VAL_STRING(val);
			if (strlen(stringval) > 0)
				data = newSVpv(stringval, strlen(stringval));
			else
				data = &PL_sv_undef;
			break;

		case DB1_STR:
			if (VAL_STR(val).len > 0)
				data = newSVpv(VAL_STR(val).s, VAL_STR(val).len);
			else
				data = &PL_sv_undef;
			break;

		case DB1_DATETIME:
			data = newSViv((unsigned int)VAL_TIME(val));
			break;

		case DB1_BLOB:
			if (VAL_BLOB(val).len > 0)
				data = newSVpv(VAL_BLOB(val).s,
						VAL_BLOB(val).len);
			else
				data = &PL_sv_undef;
			break;

		case DB1_BITMAP:
			data = newSViv(VAL_BITMAP(val));
			break;
	}

	return data;
}
开发者ID:AndreyRybkin,项目名称:kamailio,代码行数:52,代码来源:perlvdb_conv.c

示例10: Shuffle_String

//
//  Shuffle_String: C
//
// Randomize a string. Return a new string series.
// Handles both BYTE and UNICODE strings.
//
void Shuffle_String(REBVAL *value, bool secure)
{
    REBSTR *s = VAL_STRING(value);
    REBCNT idx = VAL_INDEX(value);

    REBCNT n;
    for (n = VAL_LEN_AT(value); n > 1;) {
        REBCNT k = idx + cast(REBCNT, Random_Int(secure)) % n;
        n--;
        REBUNI swap = GET_CHAR_AT(s, k);
        SET_CHAR_AT(s, k, GET_CHAR_AT(s, n + idx));
        SET_CHAR_AT(s, n + idx, swap);
    }
}
开发者ID:hostilefork,项目名称:rebol,代码行数:20,代码来源:s-ops.c

示例11: allow_trusted

/*
 * Checks based on given source IP address and protocol, and From URI
 * of request if request can be trusted without authentication.
 */
int allow_trusted(struct sip_msg* msg, char *src_ip, int proto) 
{
	int result;
	db1_res_t* res = NULL;
	
	db_key_t keys[1];
	db_val_t vals[1];
	db_key_t cols[4];

	if (db_mode == DISABLE_CACHE) {
		db_key_t order = &priority_col;
	
	        if (db_handle == 0) {
		    LM_ERR("no connection to database\n");
		    return -1;
	        }

		keys[0] = &source_col;
		cols[0] = &proto_col;
		cols[1] = &from_col;
		cols[2] = &ruri_col;
		cols[3] = &tag_col;

		if (perm_dbf.use_table(db_handle, &trusted_table) < 0) {
			LM_ERR("failed to use trusted table\n");
			return -1;
		}
		
		VAL_TYPE(vals) = DB1_STRING;
		VAL_NULL(vals) = 0;
		VAL_STRING(vals) = src_ip;

		if (perm_dbf.query(db_handle, keys, 0, vals, cols, 1, 4, order,
				   &res) < 0){
			LM_ERR("failed to query database\n");
			return -1;
		}

		if (RES_ROW_N(res) == 0) {
			perm_dbf.free_result(db_handle, res);
			return -1;
		}
		
		result = match_res(msg, proto, res);
		perm_dbf.free_result(db_handle, res);
		return result;
	} else {
		return match_hash_table(*hash_table, msg, src_ip, proto);
	}
}
开发者ID:AndreiPlesa,项目名称:kamailio,代码行数:54,代码来源:trusted.c

示例12: db_unixodbc_str2val

/*
 * Used when converting the query to a result
 */
int db_unixodbc_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l,
		const unsigned int _cpy)
{
	/* db_unixodbc uses the NULL string for NULL SQL values */
	if (_v && _s && !strcmp(_s, "NULL")) {
		LM_DBG("converting NULL value");
		static str dummy_string = {"", 0};
		memset(_v, 0, sizeof(db_val_t));
			/* Initialize the string pointers to a dummy empty
			 * string so that we do not crash when the NULL flag
			 * is set but the module does not check it properly
			 */
		VAL_STRING(_v) = dummy_string.s;
		VAL_STR(_v) = dummy_string;
		VAL_BLOB(_v) = dummy_string;
		VAL_TYPE(_v) = _t;
		VAL_NULL(_v) = 1;
		return 0;
	} else {
		return db_str2val(_t, _v, _s, _l, _cpy);
	}
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:25,代码来源:val.c

示例13: load_info


//.........这里部分代码省略.........
		}
		no_rows = estimate_available_rows(4 + 4 + 4 + 64 + 4 + 45 + 4 + 8 + 4 + 4, db_cols);
		if (no_rows == 0) no_rows = 5;
		if (dr_dbf->fetch_result(db_hdl, &res, no_rows) < 0) {
			LM_ERR("Error fetching rows\n");
			goto error;
		}
	} else {
		if (dr_dbf->query(db_hdl, clusterer_cluster_id_key, 0,
			clusterer_cluster_id_value, columns, no_of_results, db_cols, 0, &res) < 0) {
			LM_ERR("DB query failed - retrieve valid connections\n");
			goto error;
		}
	}

	LM_DBG("%d rows found in %.*s\n",
		RES_ROW_N(res), db_table->len, db_table->s);

	n = 0;
	do {
		for (i = 0; i < RES_ROW_N(res); i++) {
			row = RES_ROWS(res) + i;
			/* CLUSTER ID column */
			check_val(cluster_id_col, ROW_VALUES(row), DB_INT, 1, 0);
			int_vals[INT_VALS_CLUSTER_ID_COL] = VAL_INT(ROW_VALUES(row));
			/* MACHINE ID column */
			check_val(machine_id_col, ROW_VALUES(row) + 1, DB_INT, 1, 0);
			int_vals[INT_VALS_MACHINE_ID_COL] = VAL_INT(ROW_VALUES(row) + 1);
			/* STATE column */
			check_val(state_col, ROW_VALUES(row) + 2, DB_INT, 1, 0);
			int_vals[INT_VALS_STATE_COL] = VAL_INT(ROW_VALUES(row) + 2);
			/* DESCRIPTION column */
			check_val(description_col, ROW_VALUES(row) + 3, DB_STRING, 0, 0);
			str_vals[STR_VALS_DESCRIPTION_COL] = (char*) VAL_STRING(ROW_VALUES(row) + 3);
			/* URL column */
			check_val(url_col, ROW_VALUES(row) + 4, DB_STRING, 1, 1);
			str_vals[STR_VALS_URL_COL] = (char*) VAL_STRING(ROW_VALUES(row) + 4);
			/* CLUSTERER_ID column */
			check_val(id_col, ROW_VALUES(row) + 5, DB_INT, 1, 0);
			int_vals[INT_VALS_CLUSTERER_ID_COL] = VAL_INT(ROW_VALUES(row) + 5);
			/* LAST_ATTEMPT column */
			check_val(last_attempt_col, ROW_VALUES(row) + 6, DB_BIGINT, 1, 0);
			last_attempt = VAL_BIGINT(ROW_VALUES(row) + 6);
			/* FAILED_ATTEMPTS column */
			check_val(failed_attempts_col, ROW_VALUES(row) + 7, DB_INT, 1, 0);
			int_vals[INT_VALS_FAILED_ATTEMPTS_COL] = VAL_INT(ROW_VALUES(row) + 7);
			/* NO_TRIES column */
			check_val(no_tries_col, ROW_VALUES(row) + 8, DB_INT, 1, 0);
			int_vals[INT_VALS_NO_TRIES_COL] = VAL_INT(ROW_VALUES(row) + 8);
			/* DURATION column */
			check_val(duration_col, ROW_VALUES(row) + 9, DB_INT, 1, 0);
			int_vals[INT_VALS_DURATION_COL] = VAL_INT(ROW_VALUES(row) + 9);


			/* store data */
			if (add_info(&data, int_vals, last_attempt, str_vals) < 0) {
				LM_DBG("error while adding info to shm\n");
				goto error;
			}

			LM_DBG("machine id %d\n", int_vals[0]);
			LM_DBG("cluster id %d\n", int_vals[1]);
			LM_DBG("state %d\n", int_vals[2]);
			LM_DBG("clusterer_id %d\n", int_vals[3]);
			LM_DBG("description %s\n", str_vals[0]);
			LM_DBG("url %s\n", str_vals[1]);
开发者ID:Danfx,项目名称:opensips,代码行数:67,代码来源:clusterer.c

示例14: db_mysql_str2val

/*
 * Convert str to db value, does not copy strings
 */
int db_mysql_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l)
{
	static str dummy_string = {"", 0};
	
	if (!_v) {
		LM_ERR("invalid parameter value\n");
		return -1;
	}

	if (!_s) {
		memset(_v, 0, sizeof(db_val_t));
			/* Initialize the string pointers to a dummy empty
			 * string so that we do not crash when the NULL flag
			 * is set but the module does not check it properly
			 */
		VAL_STRING(_v) = dummy_string.s;
		VAL_STR(_v) = dummy_string;
		VAL_BLOB(_v) = dummy_string;
		VAL_TYPE(_v) = _t;
		VAL_NULL(_v) = 1;
		return 0;
	}
	VAL_NULL(_v) = 0;

	switch(_t) {
	case DB_INT:
		LM_DBG("converting INT [%s]\n", _s);
		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
			LM_ERR("error while converting integer value from string\n");
			return -2;
		} else {
			VAL_TYPE(_v) = DB_INT;
			return 0;
		}
		break;

	case DB_BIGINT:
		LM_DBG("converting INT BIG[%s]\n", _s);
		if (db_str2bigint(_s, &VAL_BIGINT(_v)) < 0) {
			LM_ERR("error while converting big integer value from string\n");
			return -2;
		} else {
			VAL_TYPE(_v) = DB_BIGINT;
			return 0;
		}
		break;

	case DB_BITMAP:
		LM_DBG("converting BITMAP [%s]\n", _s);
		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
			LM_ERR("error while converting bitmap value from string\n");
			return -3;
		} else {
			VAL_TYPE(_v) = DB_BITMAP;
			return 0;
		}
		break;
	
	case DB_DOUBLE:
		LM_DBG("converting DOUBLE [%s]\n", _s);
		if (db_str2double(_s, &VAL_DOUBLE(_v)) < 0) {
			LM_ERR("error while converting double value from string\n");
			return -4;
		} else {
			VAL_TYPE(_v) = DB_DOUBLE;
			return 0;
		}
		break;

	case DB_STRING:
		LM_DBG("converting STRING [%s]\n", _s);
		VAL_STRING(_v) = _s;
		VAL_TYPE(_v) = DB_STRING;
		return 0;

	case DB_STR:
		LM_DBG("converting STR [%.*s]\n", _l, _s);
		VAL_STR(_v).s = (char*)_s;
		VAL_STR(_v).len = _l;
		VAL_TYPE(_v) = DB_STR;
		return 0;

	case DB_DATETIME:
		LM_DBG("converting DATETIME [%s]\n", _s);
		if (db_str2time(_s, &VAL_TIME(_v)) < 0) {
			LM_ERR("error while converting datetime value from string\n");
			return -5;
		} else {
			VAL_TYPE(_v) = DB_DATETIME;
			return 0;
		}
		break;

	case DB_BLOB:
		LM_DBG("converting BLOB [%.*s]\n", _l, _s);
		VAL_BLOB(_v).s = (char*)_s;
		VAL_BLOB(_v).len = _l;
//.........这里部分代码省略.........
开发者ID:KISSMonX,项目名称:opensips,代码行数:101,代码来源:val.c

示例15: y_starter_starter_start_vnf_invoke

/********************************************************************
* FUNCTION y_starter_starter_start_vnf_invoke
* 
* RPC invocation phase
* All constraints have passed at this point.
* Call device instrumentation code in this function.
* 
* INPUTS:
*     see agt/agt_rpc.h for details
* 
* RETURNS:
*     error status
********************************************************************/
static status_t y_starter_starter_start_vnf_invoke (
    ses_cb_t *scb,
    rpc_msg_t *msg,
    xml_node_t *methnode)
{
    status_t res = NO_ERR;

    val_value_t *port_val;
    const xmlChar *port;
    val_value_t *clickDescription_val;
    const xmlChar *clickDescription;

    port_val = val_find_child(
        msg->rpc_input,
        y_starter_M_starter,
        y_starter_N_port);
    if (port_val != NULL && port_val->res == NO_ERR) {
        port = VAL_STRING(port_val);
    }

    clickDescription_val = val_find_child(
        msg->rpc_input,
        y_starter_M_starter,
        y_starter_N_clickDescription);
    if (clickDescription_val != NULL && clickDescription_val->res == NO_ERR) {
        clickDescription = VAL_STRING(clickDescription_val);
    }

    /* remove the next line if scb is used */
    (void)scb;

    /* remove the next line if methnode is used */
    (void)methnode;

    /* invoke your device instrumentation code here */
          /*********************** THIS PART IS ADDED MANUALLY BY LEVI *************************/
	log_info("\nStart VNF RPC is invoked with the following settings: \n");
	log_info("\n%s",clickDescription);
	

	int processID;
	int status;

		
	log_info("\nFORKING\n");
	
	
	/* in order to avoid block main thread 
	   otherwise, yangcli also waits for 
	   termination of child process */
	signal(SIGCHLD, SIG_IGN);
		
	
	if((processID = fork() == 0 ))
	{
		/*	the child process	*/
		
		log_info("\nPID of child: %d ",getpid());
		/*lastProcess.name = "sleep";
		lastProcess.pid = getpid();*/
		
		//dumping data into the processes_array
		process p;
		p.uniqueID = uniqueID;
		p.name = "click";
		p.pid = getpid();
		process_array[uniqueID]=p;
		uniqueID++;
		
		
		log_info("\nPID of netconfd: %d ", getppid());
		
		
		// setting up the default params for starting click
		char control_socket[3] = "-R";
		char port_param[8] = "-p";
		strcat(port_param,(char*)port);
		char p3[3] = "-e";
/*		char p4[100] = "FromDevice(eth1)->Discard;";*/
		char click_path[100]="/home/unify/click_binaries/bin/click";
		
		int errorCode = execlp(click_path, click_path, control_socket, port_param, p3, clickDescription, NULL);
		
		
		/* if everything went fine, we do not reach this point */
		log_info("\nThe result of the execution is %d", errorCode);
		_exit(127);		
//.........这里部分代码省略.........
开发者ID:fredericoschardong,项目名称:escape,代码行数:101,代码来源:starter.c


注:本文中的VAL_STRING函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。