本文整理汇总了C++中pj_strdup_with_null函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_strdup_with_null函数的具体用法?C++ pj_strdup_with_null怎么用?C++ pj_strdup_with_null使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_strdup_with_null函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: has_auth_qop
/*
* Finds out if qop offer contains "auth" token.
*/
static pj_bool_t has_auth_qop( pj_pool_t *pool, const pj_str_t *qop_offer)
{
pj_str_t qop;
char *p;
pj_strdup_with_null( pool, &qop, qop_offer);
p = qop.ptr;
while (*p) {
*p = (char)tolower(*p);
++p;
}
p = qop.ptr;
while (*p) {
if (*p=='a' && *(p+1)=='u' && *(p+2)=='t' && *(p+3)=='h') {
int e = *(p+4);
if (e=='"' || e==',' || e==0)
return PJ_TRUE;
else
p += 4;
} else {
++p;
}
}
return PJ_FALSE;
}
示例2: PJ_DEF
PJ_DEF(void) pjsip_cred_info_dup(pj_pool_t *pool,
pjsip_cred_info *dst,
const pjsip_cred_info *src)
{
pj_memcpy(dst, src, sizeof(pjsip_cred_info));
pj_strdup_with_null(pool, &dst->realm, &src->realm);
pj_strdup_with_null(pool, &dst->scheme, &src->scheme);
pj_strdup_with_null(pool, &dst->username, &src->username);
pj_strdup_with_null(pool, &dst->data, &src->data);
if ((dst->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) {
dup_bin(pool, &dst->ext.aka.k, &src->ext.aka.k);
dup_bin(pool, &dst->ext.aka.op, &src->ext.aka.op);
dup_bin(pool, &dst->ext.aka.amf, &src->ext.aka.amf);
}
}
示例3: pjsip_messaging_create_session
pjsip_messaging_create_session( pjsip_endpoint *endpt, const pj_str_t *param_from,
const pj_str_t *param_to )
{
pj_pool_t *pool;
pjsip_messaging_session *ses;
pj_str_t tmp, to;
pool = pjsip_endpt_create_pool(endpt, "imsess", 1024, 1024);
if (!pool)
return NULL;
ses = pj_pool_calloc(pool, 1, sizeof(pjsip_messaging_session));
ses->pool = pool;
ses->endpt = endpt;
ses->call_id = pjsip_cid_hdr_create(pool);
pj_create_unique_string(pool, &ses->call_id->id);
ses->cseq = pjsip_cseq_hdr_create(pool);
ses->cseq->cseq = pj_rand();
ses->cseq->method = message_method;
ses->from = pjsip_from_hdr_create(pool);
pj_strdup_with_null(pool, &tmp, param_from);
ses->from->uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
if (ses->from->uri == NULL) {
pjsip_endpt_destroy_pool(endpt, pool);
return NULL;
}
pj_create_unique_string(pool, &ses->from->tag);
ses->to = pjsip_to_hdr_create(pool);
pj_strdup_with_null(pool, &to, param_from);
ses->to->uri = pjsip_parse_uri(pool, to.ptr, to.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
if (ses->to->uri == NULL) {
pjsip_endpt_destroy_pool(endpt, pool);
return NULL;
}
PJ_LOG(4,(THIS_FILE, "IM session created: recipient=%s", to.ptr));
return ses;
}
示例4: PJ_DECL
PJ_DECL(pj_status_t) set_turn_credentials(const pj_str_t username, const pj_str_t password, const pj_str_t realm, pj_stun_auth_cred *turn_auth_cred) {
PJ_ASSERT_RETURN(turn_auth_cred, PJ_EINVAL);
/* Create memory pool for application. */
if(css_var.pool == NULL){
css_var.pool = pjsua_pool_create("css", 1000, 1000);
PJ_ASSERT_RETURN(css_var.pool, PJ_ENOMEM);
}
if (username.slen) {
turn_auth_cred->type = PJ_STUN_AUTH_CRED_STATIC;
pj_strdup_with_null(css_var.pool,
&turn_auth_cred->data.static_cred.username,
&username);
} else {
turn_auth_cred->data.static_cred.username.slen = 0;
}
if(password.slen) {
turn_auth_cred->data.static_cred.data_type = PJ_STUN_PASSWD_PLAIN;
pj_strdup_with_null(css_var.pool,
&turn_auth_cred->data.static_cred.data,
&password);
}else{
turn_auth_cred->data.static_cred.data.slen = 0;
}
if(realm.slen) {
pj_strdup_with_null(css_var.pool,
&turn_auth_cred->data.static_cred.realm,
&realm);
} else {
turn_auth_cred->data.static_cred.realm = pj_str("*");
}
return PJ_SUCCESS;
}
示例5: PJ_DEF
/*
* Duplicate SSL socket parameter.
*/
PJ_DEF(void) pj_ssl_sock_param_copy( pj_pool_t *pool,
pj_ssl_sock_param *dst,
const pj_ssl_sock_param *src)
{
/* Init secure socket param */
pj_memcpy(dst, src, sizeof(*dst));
if (src->ciphers_num > 0) {
unsigned i;
dst->ciphers = (pj_ssl_cipher*)
pj_pool_calloc(pool, src->ciphers_num,
sizeof(pj_ssl_cipher));
for (i = 0; i < src->ciphers_num; ++i)
dst->ciphers[i] = src->ciphers[i];
}
if (src->curves_num > 0) {
unsigned i;
dst->curves = (pj_ssl_curve *)pj_pool_calloc(pool, src->curves_num,
sizeof(pj_ssl_curve));
for (i = 0; i < src->curves_num; ++i)
dst->curves[i] = src->curves[i];
}
if (src->server_name.slen) {
/* Server name must be null-terminated */
pj_strdup_with_null(pool, &dst->server_name, &src->server_name);
}
if (src->sigalgs.slen) {
/* Sigalgs name must be null-terminated */
pj_strdup_with_null(pool, &dst->sigalgs, &src->sigalgs);
}
if (src->entropy_path.slen) {
/* Path name must be null-terminated */
pj_strdup_with_null(pool, &dst->entropy_path, &src->entropy_path);
}
}
示例6: PJ_DEF
PJ_DEF(pjmedia_sdp_attr*) pjmedia_sdp_attr_clone(pj_pool_t *pool,
const pjmedia_sdp_attr *rhs)
{
pjmedia_sdp_attr *attr;
PJ_ASSERT_RETURN(pool && rhs, NULL);
attr = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_attr);
pj_strdup(pool, &attr->name, &rhs->name);
pj_strdup_with_null(pool, &attr->value, &rhs->value);
return attr;
}
示例7: PJ_DEF
PJ_DEF(pjmedia_sdp_attr*) pjmedia_sdp_attr_clone(pj_pool_t *pool,
const pjmedia_sdp_attr *rhs)
{
pjmedia_sdp_attr *attr;
PJ_ASSERT_RETURN(pool && rhs, NULL);
attr = pj_pool_alloc(pool, sizeof(pjmedia_sdp_attr));
pj_strdup(pool, &attr->name, &rhs->name);
pj_strdup_with_null(pool, &attr->value, &rhs->value);
return attr;
}
示例8: pj_strdup_with_null
/// Get the URI (either name-addr or addr-spec) from the string header
/// (e.g., P-Served-User), ignoring any parameters. If it's a bare
/// addr-spec, assume (like Contact) that parameters belong to the
/// header, not to the URI.
///
/// @return URI, or NULL if cannot be parsed.
pjsip_uri* PJUtils::uri_from_string_header(pjsip_generic_string_hdr* hdr,
pj_pool_t *pool)
{
// We must duplicate the string into memory from the specified pool first as
// pjsip_parse_uri does not clone the actual strings within the URI.
pj_str_t hvalue;
pj_strdup_with_null(pool, &hvalue, &hdr->hvalue);
char* end = strchr(hvalue.ptr, '>');
if (end != NULL)
{
*(end + 1) = '\0';
hvalue.slen = (end + 1 - hvalue.ptr);
}
return pjsip_parse_uri(pool, hvalue.ptr, hvalue.slen, 0);
}
示例9: pj_strdup_with_null
static pjsip_fromto_hdr *get_diversion_header(pjsip_rx_data *rdata)
{
static const pj_str_t from_name = { "From", 4 };
pjsip_generic_string_hdr *hdr;
pj_str_t value;
int size;
if (!(hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &diversion_name, NULL))) {
return NULL;
}
pj_strdup_with_null(rdata->tp_info.pool, &value, &hdr->hvalue);
/* parse as a fromto header */
return pjsip_parse_hdr(rdata->tp_info.pool, &from_name, value.ptr,
pj_strlen(&value), &size);
}
示例10: PJ_LOG
Jt_Station::Jt_Station(jt_station_config_t *cfg)
{
PJ_LOG(3, ("station.cpp", "Jt_Station: build a station. id: %d, name: %s", cfg->id, cfg->name.ptr));
_pool = pj_pool_create(&g_cp.factory, cfg->name.ptr, INIT_POOL_STATION_SIZE, INC_POOL_STATION_SIZE, NULL);
pj_strdup_with_null(_pool, &_name, &cfg->name);
_id = cfg->id;
_fin = cfg->fin;
_rtinfo = pj_hash_create(_pool, MAX_SIGNAL_KIND_COUNTS);
jt_neighbour_config_t *nb = (jt_neighbour_config_t*)pj_pool_calloc(_pool, cfg->link_cnts, sizeof(jt_neighbour_config_t));
for(pj_uint32_t i=0; i<cfg->link_cnts; i++)
{
nb[i].event = cfg->link_cfg[i]->event;
nb[i].stt_id = cfg->link_cfg[i]->stt_id;
pj_hash_set(_pool, _rtinfo, &(nb[i].event), sizeof(pj_uint32_t), 0, &(nb[i]));
}
_car_tbl = pj_hash_create(_pool, MAX_CAR_COUNTS_PER_STATION);
_ops_tbl = pj_hash_create(_pool, MAX_SIGNAL_KIND_COUNTS);
}
示例11: PJ_DEF
/*
* Find buddy.
*/
PJ_DEF(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri_str)
{
pj_str_t input;
pj_pool_t *pool;
pjsip_uri *uri;
pjsua_buddy_id buddy_id;
pool = pjsua_pool_create("buddyfind", 512, 512);
pj_strdup_with_null(pool, &input, uri_str);
uri = pjsip_parse_uri(pool, input.ptr, input.slen, 0);
if (!uri)
buddy_id = PJSUA_INVALID_ID;
else
buddy_id = pjsua_find_buddy(uri);
pj_pool_release(pool);
return buddy_id;
}
示例12: pjsip_msg_find_hdr_by_name
/*!
* \internal
* \brief Get a P-Asserted-Identity or Remote-Party-ID header from an incoming message
*
* This function will parse the header as if it were a From header. This allows for us
* to easily manipulate the URI, as well as add, modify, or remove parameters from the
* header
*
* \param rdata The incoming message
* \param header_name The name of the ID header to find
* \retval NULL No ID header present or unable to parse ID header
* \retval non-NULL The parsed ID header
*/
static pjsip_fromto_hdr *get_id_header(pjsip_rx_data *rdata, const pj_str_t *header_name)
{
static const pj_str_t from = { "From", 4 };
pj_str_t header_content;
pjsip_fromto_hdr *parsed_hdr;
pjsip_generic_string_hdr *ident = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
header_name, NULL);
int parsed_len;
if (!ident) {
return NULL;
}
pj_strdup_with_null(rdata->tp_info.pool, &header_content, &ident->hvalue);
parsed_hdr = pjsip_parse_hdr(rdata->tp_info.pool, &from, header_content.ptr,
pj_strlen(&header_content), &parsed_len);
if (!parsed_hdr) {
return NULL;
}
return parsed_hdr;
}
示例13: udp_set_pub_name
/* Set the published address of the transport */
static void udp_set_pub_name(struct udp_transport *tp,
const pjsip_host_port *a_name)
{
enum { INFO_LEN = 80 };
char local_addr[PJ_INET6_ADDRSTRLEN+10];
pj_assert(a_name->host.slen != 0);
pj_strdup_with_null(tp->base.pool, &tp->base.local_name.host,
&a_name->host);
tp->base.local_name.port = a_name->port;
/* Update transport info. */
if (tp->base.info == NULL) {
tp->base.info = (char*) pj_pool_alloc(tp->base.pool, INFO_LEN);
}
pj_sockaddr_print(&tp->base.local_addr, local_addr, sizeof(local_addr), 3);
pj_ansi_snprintf(
tp->base.info, INFO_LEN, "udp %s [published as %s:%d]",
local_addr,
tp->base.local_name.host.ptr,
tp->base.local_name.port);
}
示例14: PJ_DEF
/*
* Send instant messaging outside dialog, using the specified account for
* route set and authentication.
*/
PJ_DEF(pj_status_t) pjsua_im_send( pjsua_acc_id acc_id,
const pj_str_t *to,
const pj_str_t *mime_type,
const pj_str_t *content,
const pjsua_msg_data *msg_data,
void *user_data)
{
pjsip_tx_data *tdata;
const pj_str_t mime_text_plain = pj_str("text/plain");
pjsip_media_type media_type;
pjsua_im_data *im_data;
pjsua_acc *acc;
pj_status_t status;
/* To and message body must be specified. */
PJ_ASSERT_RETURN(to && content, PJ_EINVAL);
acc = &pjsua_var.acc[acc_id];
/* Create request. */
status = pjsip_endpt_create_request(pjsua_var.endpt,
&pjsip_message_method,
(msg_data && msg_data->target_uri.slen?
&msg_data->target_uri: to),
&acc->cfg.id,
to, NULL, NULL, -1, NULL, &tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create request", status);
return status;
}
/* If account is locked to specific transport, then set transport to
* the request.
*/
if (acc->cfg.transport_id != PJSUA_INVALID_ID) {
pjsip_tpselector tp_sel;
pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel);
pjsip_tx_data_set_transport(tdata, &tp_sel);
}
/* Add accept header. */
pjsip_msg_add_hdr( tdata->msg,
(pjsip_hdr*)pjsua_im_create_accept(tdata->pool));
/* Create suitable Contact header unless a Contact header has been
* set in the account.
*/
/* Ticket #1632: According to RFC 3428:
* MESSAGE requests do not initiate dialogs.
* User Agents MUST NOT insert Contact header fields into MESSAGE requests
*/
/*
if (acc->contact.slen) {
contact = acc->contact;
} else {
status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to generate Contact header", status);
pjsip_tx_data_dec_ref(tdata);
return status;
}
}
pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
pjsip_generic_string_hdr_create(tdata->pool,
&STR_CONTACT, &contact));
*/
/* Create IM data to keep message details and give it back to
* application on the callback
*/
im_data = PJ_POOL_ZALLOC_T(tdata->pool, pjsua_im_data);
im_data->acc_id = acc_id;
im_data->call_id = PJSUA_INVALID_ID;
pj_strdup_with_null(tdata->pool, &im_data->to, to);
pj_strdup_with_null(tdata->pool, &im_data->body, content);
im_data->user_data = user_data;
/* Set default media type if none is specified */
if (mime_type == NULL) {
mime_type = &mime_text_plain;
}
/* Parse MIME type */
pjsua_parse_media_type(tdata->pool, mime_type, &media_type);
/* Add message body */
tdata->msg->body = pjsip_msg_body_create( tdata->pool, &media_type.type,
&media_type.subtype,
&im_data->body);
if (tdata->msg->body == NULL) {
pjsua_perror(THIS_FILE, "Unable to create msg body", PJ_ENOMEM);
pjsip_tx_data_dec_ref(tdata);
return PJ_ENOMEM;
//.........这里部分代码省略.........
示例15: PJ_DECL
//Wrap start & stop
PJ_DECL(pj_status_t) csipsimple_init(pjsua_config *ua_cfg,
pjsua_logging_config *log_cfg, pjsua_media_config *media_cfg,
csipsimple_config *css_cfg, jobject context) {
pj_status_t result;
unsigned i;
/* Create memory pool for application. */
if(css_var.pool == NULL){
css_var.pool = pjsua_pool_create("css", 1000, 1000);
PJ_ASSERT_RETURN(css_var.pool, PJ_ENOMEM);
}
// Finalize configuration
log_cfg->cb = &pj_android_log_msg;
// Static cfg
extern pj_bool_t pjsip_use_compact_form;
extern pj_bool_t pjsip_include_allow_hdr_in_dlg;
extern pj_bool_t pjmedia_add_rtpmap_for_static_pt;
extern pj_bool_t pjmedia_add_bandwidth_tias_in_sdp;
extern pj_bool_t pjsua_no_update;
extern pj_bool_t pjmedia_webrtc_use_ns;
pjsua_no_update = css_cfg->use_no_update ? PJ_TRUE : PJ_FALSE;
pjsip_use_compact_form =
css_cfg->use_compact_form_headers ? PJ_TRUE : PJ_FALSE;
/* do not transmit Allow header */
pjsip_include_allow_hdr_in_dlg =
css_cfg->use_compact_form_headers ? PJ_FALSE : PJ_TRUE;
/* Do not include rtpmap for static payload types (<96) */
pjmedia_add_rtpmap_for_static_pt =
css_cfg->use_compact_form_sdp ? PJ_FALSE : PJ_TRUE;
/* Do not enable bandwidth information inclusion in sdp */
pjmedia_add_bandwidth_tias_in_sdp =
css_cfg->add_bandwidth_tias_in_sdp ? PJ_TRUE : PJ_FALSE;
/* Use noise suppressor ? */
pjmedia_webrtc_use_ns =
css_cfg->use_noise_suppressor ? PJ_TRUE : PJ_FALSE;
css_tcp_keep_alive_interval = css_cfg->tcp_keep_alive_interval;
css_tls_keep_alive_interval = css_cfg->tls_keep_alive_interval;
// Transaction timeouts
pjsip_sip_cfg_var.tsx.t1 = css_cfg->tsx_t1_timeout;
pjsip_sip_cfg_var.tsx.t2 = css_cfg->tsx_t2_timeout;
pjsip_sip_cfg_var.tsx.t4 = css_cfg->tsx_t4_timeout;
pjsip_sip_cfg_var.tsx.td = css_cfg->tsx_td_timeout;
pjsip_sip_cfg_var.endpt.disable_tcp_switch = css_cfg->disable_tcp_switch;
pjsip_sip_cfg_var.endpt.disable_rport = css_cfg->disable_rport;
// Audio codec cfg
css_var.extra_aud_codecs_cnt = css_cfg->extra_aud_codecs_cnt;
for (i = 0; i < css_cfg->extra_aud_codecs_cnt; i++) {
dynamic_factory *css_codec = &css_var.extra_aud_codecs[i];
dynamic_factory *cfg_codec = &css_cfg->extra_aud_codecs[i];
pj_strdup_with_null(css_var.pool, &css_codec->shared_lib_path,
&cfg_codec->shared_lib_path);
pj_strdup_with_null(css_var.pool, &css_codec->init_factory_name,
&cfg_codec->init_factory_name);
}
// Video codec cfg -- For now only destroy is useful but for future
// hopefully vid codec mgr will behaves as audio does
// Also in this case destroy will become obsolete
css_var.extra_vid_codecs_cnt = css_cfg->extra_vid_codecs_cnt;
for (i = 0; i < css_cfg->extra_vid_codecs_cnt; i++) {
dynamic_factory *css_codec = &css_var.extra_vid_codecs[i];
dynamic_factory *cfg_codec = &css_cfg->extra_vid_codecs[i];
pj_strdup_with_null(css_var.pool, &css_codec->shared_lib_path,
&cfg_codec->shared_lib_path);
pj_strdup_with_null(css_var.pool, &css_codec->init_factory_name,
&cfg_codec->init_factory_name);
css_codec = &css_var.extra_vid_codecs_destroy[i];
cfg_codec = &css_cfg->extra_vid_codecs_destroy[i];
pj_strdup_with_null(css_var.pool, &css_codec->shared_lib_path,
&cfg_codec->shared_lib_path);
pj_strdup_with_null(css_var.pool, &css_codec->init_factory_name,
&cfg_codec->init_factory_name);
}
// ZRTP cfg
css_var.default_use_zrtp = css_cfg->use_zrtp;
ua_cfg->cb.on_create_media_transport = &on_transport_created_wrapper;
#if defined(PJMEDIA_HAS_ZRTP) && PJMEDIA_HAS_ZRTP!=0
pj_ansi_snprintf(css_var.zid_file, sizeof(css_var.zid_file),
"%.*s/simple.zid", css_cfg->storage_folder.slen,
css_cfg->storage_folder.ptr);
#endif
JNIEnv *jni_env = 0;
ATTACH_JVM(jni_env);
css_var.context = (*jni_env)->NewGlobalRef(jni_env, context);
//.........这里部分代码省略.........