MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / mc_compress_cb

Function mc_compress_cb

modules/compression/compression.c:1121–1608  ·  view source on GitHub ↗

* */

Source from the content-addressed store, hash-verified

1119 *
1120 */
1121int mc_compress_cb(char** buf_p, void* param, int type, int* olen)
1122{
1123 int rc;
1124 int len;
1125 int algo;
1126 int flags;
1127 int ret = -1;
1128 int compress_len=0;
1129 int uncompress_len=0;
1130 int hdr_compress_len=0;
1131
1132 str msg_start;
1133
1134 char *buf=*buf_p;
1135 char *end=buf+strlen(buf);
1136 unsigned long temp;
1137 struct mc_comp_args *args=(struct mc_comp_args*)param;
1138
1139 struct hdr_field *hf;
1140 struct hdr_field *mnd_hdrs=NULL;
1141 struct hdr_field *non_mnd_hdrs=NULL;
1142 struct hdr_field *mnd_hdrs_head=NULL;
1143 struct hdr_field *non_mnd_hdrs_head=NULL;
1144
1145 mc_whitelist_p hdr2compress_list;
1146
1147 hdr2compress_list = args->hdr2compress_list;
1148 algo = args->algo;
1149 flags = args->flags;
1150
1151 mc_parse_first_line(&msg_start, &buf);
1152
1153 uncompress_len = msg_start.len;
1154
1155 /* Parse the message until the body is found
1156 Build two lists one of mandatory headers and one
1157 of non mandatory headers */
1158
1159 while (1) {
1160 hf = pkg_malloc(sizeof(struct hdr_field));
1161 if (hf == NULL) {
1162 LM_ERR("no more pkg mem\n");
1163 goto free_mem_full;
1164 }
1165 memset(hf, 0, sizeof(struct hdr_field));
1166 hf->type=HDR_ERROR_T;
1167 buf=get_hdr_field(buf, end, hf);
1168
1169 if (hf->type == HDR_ERROR_T) {
1170 goto free_mem_full;
1171 }
1172
1173 if (hf->type == HDR_EOH_T) {
1174 compress_len += strlen(buf);
1175 compress_len = compress_len > CRLF_LEN ? compress_len : 0;
1176 pkg_free(hf);
1177 break;
1178 }

Callers 2

wrap_tm_funcFunction · 0.85
wrap_msg_funcFunction · 0.85

Calls 12

mc_parse_first_lineFunction · 0.85
mc_is_in_whitelistFunction · 0.85
wrap_reallocFunction · 0.85
wrap_copy_and_updateFunction · 0.85
check_zlib_rcFunction · 0.85
gzip_compressFunction · 0.85
base64encodeFunction · 0.85
mc_ndigitsFunction · 0.85
int2strFunction · 0.85
shm_freeFunction · 0.85
shm_mallocFunction · 0.85
free_hdr_listFunction · 0.85

Tested by

no test coverage detected