本文整理汇总了C++中pj_strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_strdup函数的具体用法?C++ pj_strdup怎么用?C++ pj_strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_strdup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PJ_DEF
/*
* Initialize server authorization session data structure to serve the
* specified realm and to use lookup_func function to look for the credential
* info.
*/
PJ_DEF(pj_status_t) pjsip_auth_srv_init( pj_pool_t *pool,
pjsip_auth_srv *auth_srv,
const pj_str_t *realm,
pjsip_auth_lookup_cred *lookup,
unsigned options )
{
PJ_ASSERT_RETURN(pool && auth_srv && realm && lookup, PJ_EINVAL);
pj_bzero(auth_srv, sizeof(*auth_srv));
pj_strdup( pool, &auth_srv->realm, realm);
auth_srv->lookup = lookup;
auth_srv->is_proxy = (options & PJSIP_AUTH_SRV_IS_PROXY);
return PJ_SUCCESS;
}
示例2: PJ_DEF
/* Duplicate credential */
PJ_DEF(void) pj_stun_auth_cred_dup( pj_pool_t *pool,
pj_stun_auth_cred *dst,
const pj_stun_auth_cred *src)
{
dst->type = src->type;
switch (src->type) {
case PJ_STUN_AUTH_CRED_STATIC:
pj_strdup(pool, &dst->data.static_cred.realm,
&src->data.static_cred.realm);
pj_strdup(pool, &dst->data.static_cred.username,
&src->data.static_cred.username);
dst->data.static_cred.data_type = src->data.static_cred.data_type;
pj_strdup(pool, &dst->data.static_cred.data,
&src->data.static_cred.data);
pj_strdup(pool, &dst->data.static_cred.nonce,
&src->data.static_cred.nonce);
break;
case PJ_STUN_AUTH_CRED_DYNAMIC:
pj_memcpy(&dst->data.dyn_cred, &src->data.dyn_cred,
sizeof(src->data.dyn_cred));
break;
}
}
示例3: PJ_DEF
/*
* Create NOTIFY
*/
PJ_DEF(pj_status_t) pjsip_mwi_notify( pjsip_evsub *sub,
pjsip_evsub_state state,
const pj_str_t *state_str,
const pj_str_t *reason,
const pjsip_media_type *mime_type,
const pj_str_t *body,
pjsip_tx_data **p_tdata)
{
pjsip_mwi *mwi;
pjsip_tx_data *tdata;
pj_status_t status;
/* Check arguments. */
PJ_ASSERT_RETURN(sub && mime_type && body && p_tdata, PJ_EINVAL);
/* Get the mwi object. */
mwi = (pjsip_mwi*) pjsip_evsub_get_mod_data(sub, mod_mwi.id);
PJ_ASSERT_RETURN(mwi != NULL, PJ_EINVALIDOP);
/* Lock object. */
pjsip_dlg_inc_lock(mwi->dlg);
/* Create the NOTIFY request. */
status = pjsip_evsub_notify( sub, state, state_str, reason, &tdata);
if (status != PJ_SUCCESS)
goto on_return;
/* Update the cached message body */
if (mime_type || body)
pj_pool_reset(mwi->body_pool);
if (mime_type)
pjsip_media_type_cp(mwi->body_pool, &mwi->mime_type, mime_type);
if (body)
pj_strdup(mwi->body_pool, &mwi->body, body);
/* Create message body */
status = mwi_create_msg_body( mwi, tdata );
if (status != PJ_SUCCESS)
goto on_return;
/* Done. */
*p_tdata = tdata;
on_return:
pjsip_dlg_dec_lock(mwi->dlg);
return status;
}
示例4: LOG_DEBUG
/// Calculate targets for incoming requests by querying HSS.
int ICSCFProxy::UASTsx::calculate_targets()
{
// Invoke the router to select an S-CSCF.
std::string scscf;
int status_code = _router->get_scscf(scscf);
if (status_code == PJSIP_SC_OK)
{
// Found a suitable S-CSCF.
if (_case == SessionCase::REGISTER)
{
// REGISTER request, so add a target with this S-CSCF as the Request-URI.
LOG_DEBUG("Route REGISTER to S-CSCF %s", scscf.c_str());
Target* target = new Target;
target->uri = PJUtils::uri_from_string(scscf, _req->pool);
add_target(target);
// Don't add a P-User-Database header - as per 5.3.1.2/TS24.229 Note 3
// this can only be added if we have local configuration that the S-CSCF
// can process P-User-Database.
}
else
{
// Non-register request, so add a Route header for the destination S-CSCF.
LOG_DEBUG("Route Non-REGISTER to S-CSCF %s", scscf.c_str());
Target* target = new Target;
pjsip_sip_uri* route_uri =
(pjsip_sip_uri*)PJUtils::uri_from_string(scscf, _req->pool);
route_uri->lr_param = 1;
if (_case == SessionCase::ORIGINATING)
{
// Add the "orig" parameter.
pjsip_param* p = PJ_POOL_ALLOC_T(_req->pool, pjsip_param);
pj_strdup(_req->pool, &p->name, &STR_ORIG);
p->value.slen = 0;
pj_list_insert_after(&route_uri->other_param, p);
}
target->paths.push_back((pjsip_uri*)route_uri);
add_target(target);
// Remove the P-Profile-Key header if present.
PJUtils::remove_hdr(_req->msg, &STR_P_PROFILE_KEY);
}
}
return status_code;
}
示例5: LLVMFuzzerInitialize
int LLVMFuzzerInitialize(int* /*argc*/, char*** argv)
{
const char* argv0 = (*argv)[0];
char* path = pj_strdup(argv0);
char* lastslash = strrchr(path, '/');
if( lastslash )
{
*lastslash = '\0';
setenv("PROJ_LIB", path, 1);
}
else
{
setenv("PROJ_LIB", ".", 1);
}
free(path);
return 0;
}
示例6: PJ_DEF
/**
* Create a "blank" SDP session description. The SDP will contain basic SDP
* fields such as origin, time, and name, but without any media lines.
*/
PJ_DEF(pj_status_t) pjmedia_endpt_create_base_sdp( pjmedia_endpt *endpt,
pj_pool_t *pool,
const pj_str_t *sess_name,
const pj_sockaddr *origin,
pjmedia_sdp_session **p_sdp)
{
char tmp_addr[PJ_INET6_ADDRSTRLEN];
pj_time_val tv;
pjmedia_sdp_session *sdp;
/* Sanity check arguments */
PJ_ASSERT_RETURN(endpt && pool && p_sdp, PJ_EINVAL);
sdp = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_session);
pj_gettimeofday(&tv);
sdp->origin.user = pj_str("-");
sdp->origin.version = sdp->origin.id = tv.sec + 2208988800UL;
sdp->origin.net_type = STR_IN;
if (origin->addr.sa_family == pj_AF_INET()) {
sdp->origin.addr_type = STR_IP4;
} else if (origin->addr.sa_family == pj_AF_INET6()) {
sdp->origin.addr_type = STR_IP6;
} else {
pj_assert(!"Invalid address family");
return PJ_EAFNOTSUP;
}
pj_strdup2(pool, &sdp->origin.addr,
pj_sockaddr_print(origin, tmp_addr, sizeof(tmp_addr), 0));
if (sess_name)
pj_strdup(pool, &sdp->name, sess_name);
else
sdp->name = STR_SDP_NAME;
/* SDP time and attributes. */
sdp->time.start = sdp->time.stop = 0;
sdp->attr_count = 0;
/* Done */
*p_sdp = sdp;
return PJ_SUCCESS;
}
示例7: PJ_DEF
PJ_DEF(pj_status_t) pjsip_regc_set_via_sent_by( pjsip_regc *regc,
pjsip_host_port *via_addr,
pjsip_transport *via_tp)
{
PJ_ASSERT_RETURN(regc, PJ_EINVAL);
if (!via_addr)
pj_bzero(®c->via_addr, sizeof(regc->via_addr));
else {
if (pj_strcmp(®c->via_addr.host, &via_addr->host))
pj_strdup(regc->pool, ®c->via_addr.host, &via_addr->host);
regc->via_addr.port = via_addr->port;
}
regc->via_tp = via_tp;
return PJ_SUCCESS;
}
示例8: PJ_DEF
PJ_DEF(void) pjsip_sip_uri_assign(pj_pool_t *pool, pjsip_sip_uri *url,
const pjsip_sip_uri *rhs)
{
pj_strdup( pool, &url->user, &rhs->user);
pj_strdup( pool, &url->passwd, &rhs->passwd);
pj_strdup( pool, &url->host, &rhs->host);
url->port = rhs->port;
pj_strdup( pool, &url->user_param, &rhs->user_param);
pj_strdup( pool, &url->method_param, &rhs->method_param);
pj_strdup( pool, &url->transport_param, &rhs->transport_param);
url->ttl_param = rhs->ttl_param;
pj_strdup( pool, &url->maddr_param, &rhs->maddr_param);
pjsip_param_clone(pool, &url->other_param, &rhs->other_param);
pjsip_param_clone(pool, &url->header_param, &rhs->header_param);
url->lr_param = rhs->lr_param;
}
示例9: get_tuple_note
/* Get <note> element from PIDF <tuple> element */
static pj_status_t get_tuple_note(const pjpidf_pres *pres,
pj_pool_t *pool,
pjrpid_element *elem)
{
const pj_xml_node *nd_tuple, *nd_note;
nd_tuple = find_node(pres, "tuple");
if (!nd_tuple)
return PJSIP_SIMPLE_EBADRPID;
nd_note = find_node(pres, "note");
if (nd_note) {
pj_strdup(pool, &elem->note, &nd_note->content);
return PJ_SUCCESS;
}
return PJSIP_SIMPLE_EBADRPID;
}
示例10: PJ_DEF
PJ_DEF(pj_status_t) pjxpidf_set_uri(pj_pool_t *pool, pjxpidf_pres *pres,
const pj_str_t *uri)
{
pj_xml_node *presentity;
pj_xml_node *atom;
pj_xml_node *addr;
pj_xml_attr *attr;
pj_str_t dup_uri;
presentity = pj_xml_find_node(pres, &STR_PRESENTITY);
if (!presentity) {
pj_assert(0);
return -1;
}
atom = pj_xml_find_node(pres, &STR_ATOM);
if (!atom) {
pj_assert(0);
return -1;
}
addr = pj_xml_find_node(atom, &STR_ADDRESS);
if (!addr) {
pj_assert(0);
return -1;
}
/* Set uri in presentity */
attr = pj_xml_find_attr(presentity, &STR_URI, NULL);
if (!attr) {
pj_assert(0);
return -1;
}
pj_strdup(pool, &dup_uri, uri);
attr->value = dup_uri;
/* Set uri in address. */
attr = pj_xml_find_attr(addr, &STR_URI, NULL);
if (!attr) {
pj_assert(0);
return -1;
}
attr->value = dup_uri;
return 0;
}
示例11: PJ_DEF
/*
* Add authentication challenge headers to the outgoing response in tdata.
* Application may specify its customized nonce and opaque for the challenge,
* or can leave the value to NULL to make the function fills them in with
* random characters.
*/
PJ_DEF(pj_status_t) pjsip_auth_srv_challenge( pjsip_auth_srv *auth_srv,
const pj_str_t *qop,
const pj_str_t *nonce,
const pj_str_t *opaque,
pj_bool_t stale,
pjsip_tx_data *tdata)
{
pjsip_www_authenticate_hdr *hdr;
char nonce_buf[16];
pj_str_t random;
PJ_ASSERT_RETURN( auth_srv && tdata, PJ_EINVAL );
random.ptr = nonce_buf;
random.slen = sizeof(nonce_buf);
/* Create the header. */
if (auth_srv->is_proxy)
hdr = pjsip_proxy_authenticate_hdr_create(tdata->pool);
else
hdr = pjsip_www_authenticate_hdr_create(tdata->pool);
/* Initialize header.
* Note: only support digest authentication now.
*/
hdr->scheme = pjsip_DIGEST_STR;
hdr->challenge.digest.algorithm = pjsip_MD5_STR;
if (nonce) {
pj_strdup(tdata->pool, &hdr->challenge.digest.nonce, nonce);
} else {
pj_create_random_string(nonce_buf, sizeof(nonce_buf));
pj_strdup(tdata->pool, &hdr->challenge.digest.nonce, &random);
}
if (opaque) {
pj_strdup(tdata->pool, &hdr->challenge.digest.opaque, opaque);
} else {
pj_create_random_string(nonce_buf, sizeof(nonce_buf));
pj_strdup(tdata->pool, &hdr->challenge.digest.opaque, &random);
}
if (qop) {
pj_strdup(tdata->pool, &hdr->challenge.digest.qop, qop);
} else {
hdr->challenge.digest.qop.slen = 0;
}
pj_strdup(tdata->pool, &hdr->challenge.digest.realm, &auth_srv->realm);
hdr->challenge.digest.stale = stale;
pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)hdr);
return PJ_SUCCESS;
}
示例12: add_cmd_name
/* Add command to the command hash */
static void add_cmd_name(pj_cli_t *cli, pj_cli_cmd_spec *group,
pj_cli_cmd_spec *cmd, pj_str_t *cmd_name)
{
pj_str_t cmd_val;
pj_str_t add_cmd;
char cmd_ptr[64];
cmd_val.ptr = &cmd_ptr[0];
cmd_val.slen = 0;
if (group) {
pj_strcat(&cmd_val, &group->name);
}
pj_strcat(&cmd_val, cmd_name);
pj_strdup(cli->pool, &add_cmd, &cmd_val);
pj_hash_set(cli->pool, cli->cmd_name_hash,
cmd_val.ptr, cmd_val.slen, 0, cmd);
}
示例13: init_registrar
pj_status_t init_registrar(RegStore* registrar_store,
RegStore* remote_reg_store,
HSSConnection* hss_connection,
AnalyticsLogger* analytics_logger,
ACRFactory* rfacr_factory,
int cfg_max_expires)
{
pj_status_t status;
store = registrar_store;
remote_store = remote_reg_store;
hss = hss_connection;
analytics = analytics_logger;
max_expires = cfg_max_expires;
acr_factory = rfacr_factory;
// Construct a Service-Route header pointing at the S-CSCF ready to be added
// to REGISTER 200 OK response.
pjsip_sip_uri* service_route_uri = (pjsip_sip_uri*)
pjsip_parse_uri(stack_data.pool,
stack_data.scscf_uri.ptr,
stack_data.scscf_uri.slen,
0);
service_route_uri->lr_param = 1;
// Add the orig parameter. The UE must provide this back on future messages
// to ensure we perform originating processing.
pjsip_param *orig_param = PJ_POOL_ALLOC_T(stack_data.pool, pjsip_param);
pj_strdup(stack_data.pool, &orig_param->name, &STR_ORIG);
pj_strdup2(stack_data.pool, &orig_param->value, "");
pj_list_insert_after(&service_route_uri->other_param, orig_param);
service_route = pjsip_route_hdr_create(stack_data.pool);
service_route->name = STR_SERVICE_ROUTE;
service_route->sname = pj_str("");
service_route->name_addr.uri = (pjsip_uri*)service_route_uri;
status = pjsip_endpt_register_module(stack_data.endpt, &mod_registrar);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
return status;
}
示例14: tsx_layer_test
/* Test transaction layer. */
static int tsx_layer_test(void)
{
pj_str_t target, from, tsx_key;
pjsip_tx_data *tdata;
pjsip_transaction *tsx, *found;
pj_status_t status;
PJ_LOG(3,(THIS_FILE, " transaction layer test"));
target = pj_str(TARGET_URI);
from = pj_str(FROM_URI);
status = pjsip_endpt_create_request(endpt, &pjsip_invite_method, &target,
&from, &target, NULL, NULL, -1, NULL,
&tdata);
if (status != PJ_SUCCESS) {
app_perror(" error: unable to create request", status);
return -110;
}
status = pjsip_tsx_create_uac(NULL, tdata, &tsx);
if (status != PJ_SUCCESS) {
app_perror(" error: unable to create transaction", status);
return -120;
}
pj_strdup(tdata->pool, &tsx_key, &tsx->transaction_key);
found = pjsip_tsx_layer_find_tsx(&tsx_key, PJ_FALSE);
if (found != tsx) {
return -130;
}
pjsip_tsx_terminate(tsx, PJSIP_SC_REQUEST_TERMINATED);
flush_events(500);
if (pjsip_tx_data_dec_ref(tdata) != PJSIP_EBUFDESTROYED) {
return -140;
}
return 0;
}
示例15: PJ_DECL
PJ_DECL(void) pjdialog_info_local_set_identity_display(pj_pool_t *pool,
pjdialog_info_local *local,
const pj_str_t *identity_display)
{
pj_xml_node *node = pj_xml_find_node((pj_xml_node*)local, &IDENTITY);
pj_xml_attr *attr;
if (!node) {
node = PJ_POOL_ALLOC_T(pool, pj_xml_node);
xml_init_node(pool, node, &IDENTITY, NULL);
pj_xml_add_node(local, node);
}
attr = pj_xml_find_attr(node, &DISPLAY, NULL);
if (!attr) {
attr = xml_create_attr(pool, &DISPLAY, identity_display);
pj_xml_add_attr(node, attr);
} else {
pj_strdup(pool, &attr->value, identity_display);
}
}