static belle_sip_error_code belle_http_request_marshal(const belle_http_request_t* request, char* buff, size_t buff_size, size_t *offset) { belle_sip_error_code error=belle_sip_snprintf(buff,buff_size,offset,"%s ",belle_http_request_get_method(request)); if (error!=BELLE_SIP_OK) return error; error=belle_generic_uri_marshal(belle_http_request_get_uri(request),buff,buff_size,offset); if (error!=BELLE_SIP_OK) return error; error=belle_sip_snprintf(buff,buff_size,offset," %s","HTTP/1.1\r\n"); if (error!=BELLE_SIP_OK) return error; error=belle_sip_headers_marshal(BELLE_SIP_MESSAGE(request),buff,buff_size,offset); if (error!=BELLE_SIP_OK) return error; return error; }
char * _belle_sip_object_describe_type(belle_sip_object_vptr_t *vptr){ const int maxbufsize=2048; char *ret=belle_sip_malloc(maxbufsize); belle_sip_object_vptr_t *it; size_t pos=0; belle_sip_list_t *l=NULL,*elem; belle_sip_snprintf(ret,maxbufsize,&pos,"Ownership:\n"); belle_sip_snprintf(ret,maxbufsize,&pos,"\t%s is created initially %s\n",vptr->type_name, vptr->initially_unowned ? "unowned" : "owned"); belle_sip_snprintf(ret,maxbufsize,&pos,"\nInheritance diagram:\n"); for(it=vptr;it!=NULL;it=it->get_parent()){ l=belle_sip_list_prepend(l,it); } for(elem=l;elem!=NULL;elem=elem->next){ it=(belle_sip_object_vptr_t*)elem->data; belle_sip_snprintf(ret,maxbufsize,&pos,"\t%s\n",it->type_name); if (elem->next) belle_sip_snprintf(ret,maxbufsize,&pos,"\t |\n"); } belle_sip_list_free(l); belle_sip_snprintf(ret,maxbufsize,&pos,"\nImplemented interfaces:\n"); for(it=vptr;it!=NULL;it=it->get_parent()){ belle_sip_interface_desc_t **desc=it->interfaces; if (desc!=NULL){ for(;*desc!=NULL;desc++){ belle_sip_snprintf(ret,maxbufsize,&pos,"\t* %s\n",(*desc)->ifname); } } } return ret; }
static belle_sip_error_code _linphone_event_marshall(belle_sip_object_t *obj, char* buff, size_t buff_size, size_t *offset) { LinphoneEvent *ev = (LinphoneEvent*)obj; belle_sip_error_code err = BELLE_SIP_OK; err = belle_sip_snprintf(buff, buff_size, offset, "%s of %s", ev->dir == LinphoneSubscriptionIncoming ? "Incoming Subscribe" : (ev->dir == LinphoneSubscriptionOutgoing ? "Outgoing subscribe" : "Publish"), ev->name); return err; }
static int linphone_ldap_contact_provider_marshal(LinphoneLDAPContactProvider* obj, char* buff, size_t buff_size, size_t *offset) { belle_sip_error_code error = BELLE_SIP_OK; char **attr; error = belle_sip_snprintf(buff, buff_size, offset, "ld:%p,\n", obj->ld); if(error!= BELLE_SIP_OK) return error; error = belle_sip_snprintf(buff, buff_size, offset, "req_count:%d,\n", obj->req_count); if(error!= BELLE_SIP_OK) return error; error = belle_sip_snprintf(buff, buff_size, offset, "CONFIG:\n" "tls: %d \n" "auth: %s \n" "user: %s \n" "pass: %s \n" "server: %s \n" "base: %s \n" "filter: %s \n" "timeout: %d \n" "deref: %d \n" "max_res: %d \n" "sip_attr:%s \n" "name_attr:%s \n" "attrs:\n", obj->use_tls, obj->auth_method, obj->username, obj->password, obj->server, obj->base_object, obj->filter, obj->timeout, obj->deref_aliases, obj->max_results, obj->sip_attr, obj->name_attr); if(error!= BELLE_SIP_OK) return error; attr = obj->attributes; while( *attr ){ error = belle_sip_snprintf(buff, buff_size, offset, "- %s\n", *attr); if(error!= BELLE_SIP_OK) return error; else attr++; } return error; }
static belle_sip_error_code _linphone_friend_marshall(belle_sip_object_t *obj, char* buff, size_t buff_size, size_t *offset) { LinphoneFriend *lf = (LinphoneFriend*)obj; belle_sip_error_code err = BELLE_SIP_OK; if (lf->uri){ char *tmp = linphone_address_as_string(lf->uri); err = belle_sip_snprintf(buff, buff_size, offset, "%s", tmp); ms_free(tmp); } return err; }
belle_sip_error_code belle_http_response_marshal(belle_http_response_t *resp, char* buff, size_t buff_size, size_t *offset) { belle_sip_error_code error=belle_sip_snprintf( buff ,buff_size ,offset ,"HTTP/1.1 %i %s\r\n" ,belle_http_response_get_status_code(resp) ,belle_http_response_get_reason_phrase(resp)?belle_http_response_get_reason_phrase(resp):""); if (error!=BELLE_SIP_OK) return error; error=belle_sip_headers_marshal(BELLE_SIP_MESSAGE(resp),buff,buff_size,offset); if (error!=BELLE_SIP_OK) return error; return error; }
static belle_sip_error_code _belle_object_marshal(belle_sip_object_t* obj, char* buff, size_t buff_size, size_t *offset) { return belle_sip_snprintf(buff,buff_size,offset,"{%s::%s %p}",obj->vptr->type_name,obj->name ? obj->name : "(no name)",obj); }
belle_sip_error_code belle_sip_uri_marshal(const belle_sip_uri_t* uri, char* buff, size_t buff_size, size_t *offset) { const belle_sip_list_t* list; belle_sip_error_code error=BELLE_SIP_OK; error=belle_sip_snprintf(buff,buff_size,offset,"%s:",uri->secure?"sips":"sip"); if (error!=BELLE_SIP_OK) return error; if (uri->user && uri->user[0]!='\0') { char* escaped_username=belle_sip_uri_to_escaped_username(uri->user); error=belle_sip_snprintf(buff,buff_size,offset,"%s",escaped_username); belle_sip_free(escaped_username); if (error!=BELLE_SIP_OK) return error; if (uri->user_password) { char* escaped_password=belle_sip_uri_to_escaped_userpasswd(uri->user_password); error=belle_sip_snprintf(buff,buff_size,offset,":%s",escaped_password); belle_sip_free(escaped_password); if (error!=BELLE_SIP_OK) return error; } error=belle_sip_snprintf(buff,buff_size,offset,"@"); if (error!=BELLE_SIP_OK) return error; } if (uri->host) { if (strchr(uri->host,':')) { /*ipv6*/ error=belle_sip_snprintf(buff,buff_size,offset,"[%s]",uri->host); } else { error=belle_sip_snprintf(buff,buff_size,offset,"%s",uri->host); } if (error!=BELLE_SIP_OK) return error; } else { belle_sip_warning("no host found in this uri"); } if (uri->port!=0) { error=belle_sip_snprintf(buff,buff_size,offset,":%i",uri->port); if (error!=BELLE_SIP_OK) return error; } { belle_sip_parameters_t *encparams = belle_sip_parameters_new(); belle_sip_list_for_each2(uri->params.param_list, (void (*)(void *, void *))encode_params, &encparams->param_list); error=belle_sip_parameters_marshal(encparams,buff,buff_size,offset); belle_sip_parameters_destroy(encparams); if (error!=BELLE_SIP_OK) return error; } { belle_sip_list_t * encheaders = NULL; belle_sip_list_for_each2(uri->header_list->param_list, (void (*)(void *, void *))encode_headers, &encheaders); for(list=encheaders;list!=NULL;list=list->next){ belle_sip_param_pair_t* container = list->data; if (list == encheaders) { //first case error=belle_sip_snprintf(buff,buff_size,offset,"?%s=%s",container->name,container->value?container->value:""); } else { //subsequent headers error=belle_sip_snprintf(buff,buff_size,offset,"&%s=%s",container->name,container->value?container->value:""); } if (error!=BELLE_SIP_OK) break; } belle_sip_list_free_with_data(encheaders,(void (*)(void*))belle_sip_param_pair_destroy); } return error; }