int tsdp_header_serialize(const tsdp_header_t *self, tsk_buffer_t *output) { static char name; int ret = -1; if(!self || !output) { return -1; } /* Name */ name = tsdp_header_get_nameex(self); tsk_buffer_append_2(output, "%c=", name); /* Value */ if((ret = self->tostring(self, output))) { // Abort? } /* CRLF*/ if(output->size>2) { if(*(TSK_BUFFER_TO_U8(output)+TSK_BUFFER_SIZE(output)-2) != '\r' && *(TSK_BUFFER_TO_U8(output)+TSK_BUFFER_SIZE(output)-1) != '\n') { ret = tsk_buffer_append(output, "\r\n", 2); } } else { ret = tsk_buffer_append(output, "\r\n", 2); } return ret; }
/**@ingroup tsk_params_group * Serializes a @ref tsk_param_t object. * @param param The parameter to serialize. * @param output The output buffer. * @retval Zero if succeed and -1 otherwise. */ int tsk_params_param_tostring(const tsk_param_t *param, tsk_buffer_t* output) { if(param){ return tsk_buffer_append_2(output, param->value?"%s=%s":"%s", param->name, param->value); } return -1; }
/**@ingroup tsk_params_group * Serializes a @ref tsk_params_L_t object. * @param self The list of parameters to serialize. * @param separator The character to use as separator between params. * @param output The output buffer. * @retval Zero if succeed and non-zero error code otherwise. */ int tsk_params_tostring(const tsk_params_L_t *self, const char separator, tsk_buffer_t* output) { int ret = -1; if(self){ tsk_list_item_t *item; ret = 0; // for empty lists tsk_list_foreach(item, self){ tsk_param_t* param = item->data; //tsk_params_param_tostring(param, output); if(TSK_LIST_IS_FIRST(self, item)){ if((ret = tsk_buffer_append_2(output, param->value?"%s=%s":"%s", param->name, param->value))){ goto bail; } } else{ if((ret = tsk_buffer_append_2(output, param->value?"%c%s=%s":"%c%s", separator, param->name, param->value))){ goto bail; } } } }
int tsip_header_Authorization_serialize(const tsip_header_t* header, tsk_buffer_t* output) { if(header){ const tsip_header_Authorization_t *Authorization = (const tsip_header_Authorization_t *)header; if(Authorization && Authorization->scheme){ return tsk_buffer_append_2(output, "%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", Authorization->scheme, Authorization->username ? "username=\"" : "", Authorization->username ? Authorization->username : "", Authorization->username ? "\"" : "", Authorization->realm ? ",realm=\"" : "", Authorization->realm ? Authorization->realm : "", Authorization->realm ? "\"" : "", Authorization->nonce ? ",nonce=\"" : "", Authorization->nonce ? Authorization->nonce : "", Authorization->nonce ? "\"" : "", Authorization->uri ? ",uri=\"" : "", Authorization->uri ? Authorization->uri : "", Authorization->uri ? "\"" : "", Authorization->response ? ",response=\"" : "", Authorization->response ? Authorization->response : "", Authorization->response ? "\"" : "", Authorization->algorithm ? ",algorithm=" : "", Authorization->algorithm ? Authorization->algorithm : "", Authorization->cnonce ? ",cnonce=\"" : "", Authorization->cnonce ? Authorization->cnonce : "", Authorization->cnonce ? "\"" : "", Authorization->opaque ? ",opaque=\"" : "", Authorization->opaque ? Authorization->opaque : "", Authorization->opaque ? "\"" : "", Authorization->qop ? ",qop=" : "", Authorization->qop ? Authorization->qop : "", Authorization->nc ? ",nc=" : "", Authorization->nc ? Authorization->nc : "" ); } } return -1; }
int tmsrp_header_serialize(const tmsrp_header_t *self, tsk_buffer_t *output) { int ret = -1; if(!self || !output){ return -1; } /* Name */ tsk_buffer_append_2(output, "%s: ", tmsrp_header_get_nameex(self)); /* Value */ if((ret = self->tostring(self, output))){ // Abort? } /* CRLF*/ ret = tsk_buffer_append(output, "\r\n", 2); return ret; }
int tsip_header_Proxy_Authenticate_serialize(const tsip_header_t* header, tsk_buffer_t* output) { if(header){ const tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = (const tsip_header_Proxy_Authenticate_t*)header; if(Proxy_Authenticate && Proxy_Authenticate->scheme){ return tsk_buffer_append_2(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s", Proxy_Authenticate->scheme, Proxy_Authenticate->realm ? Proxy_Authenticate->realm : "", Proxy_Authenticate->domain ? ",domain=\"" : "", Proxy_Authenticate->domain ? Proxy_Authenticate->domain : "", Proxy_Authenticate->domain ? "\"" : "", Proxy_Authenticate->qop ? ",qop=\"" : "", Proxy_Authenticate->qop ? Proxy_Authenticate->qop : "", Proxy_Authenticate->qop ? "\"" : "", Proxy_Authenticate->nonce ? ",nonce=\"" : "", Proxy_Authenticate->nonce ? Proxy_Authenticate->nonce : "", Proxy_Authenticate->nonce ? "\"" : "", Proxy_Authenticate->opaque ? ",opaque=\"" : "", Proxy_Authenticate->opaque ? Proxy_Authenticate->opaque : "", Proxy_Authenticate->opaque ? "\"" : "", Proxy_Authenticate->stale ? "TRUE" : "FALSE", Proxy_Authenticate->algorithm ? ",algorithm=" : "", Proxy_Authenticate->algorithm ? Proxy_Authenticate->algorithm : "" ); } } return -1; }