00001 /* $Id: encode_content_disposition.c 5192 2008-11-13 10:18:48Z eliasbaixas $ 00002 * 00003 * Copyright (C) 2006-2007 VozTelecom Sistemas S.L 00004 * 00005 * This file is part of Kamailio, a free SIP server. 00006 * 00007 * Kamailio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version 00011 * 00012 * Kamailio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 /* 00023 * ===================================================================================== 00024 * 00025 * Filename: encode_content_disposition.c 00026 * 00027 * Description: [en|de]encodes content disposition 00028 * 00029 * Version: 1.0 00030 * Created: 21/11/05 20:36:19 CET 00031 * Revision: none 00032 * Compiler: gcc 00033 * 00034 * Author: Elias Baixas (EB), elias@conillera.net 00035 * Company: VozTele.com 00036 * 00037 * ===================================================================================== 00038 */ 00039 00040 #define _GNU_SOURCE 00041 #include <stdio.h> 00042 #include "../../parser/parse_disposition.h" 00043 #include "encode_parameters.h" 00044 00045 /* 00046 struct disposition_param { str name; str body; int is_quoted; struct disposition_param *next; }; 00047 struct disposition { str type; struct disposition_param *params; }; 00048 */ 00049 00050 int encode_content_disposition(char *hdrstart,int hdrlen,struct disposition *body,unsigned char *where) 00051 { 00052 unsigned char i=3; 00053 00054 /*where[0] reserved flags for future use*/ 00055 where[1]=(unsigned char)(body->type.s-hdrstart); 00056 where[2]=(unsigned char)body->type.len; 00057 i+=encode_parameters(&where[3],(void *)body->params,hdrstart,body,'d'); 00058 return i; 00059 } 00060 00061 int print_encoded_content_disposition(FILE* fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix) 00062 { 00063 int i=3;/* flags + urilength */ 00064 unsigned char flags=0; 00065 00066 flags=payload[0]; 00067 fprintf(fd,"%s",prefix); 00068 for(i=0;i<paylen;i++) 00069 fprintf(fd,"%s%d%s",i==0?"ENCODED CONTENT-DISPOSITION=[":":",payload[i],i==paylen-1?"]\n":""); 00070 fprintf(fd,"%sCONTENT DISPOSITION:[%.*s]\n",prefix,payload[2],&hdr[payload[1]]); 00071 print_encoded_parameters(fd,&payload[3],hdr,paylen-3,prefix); 00072 return 0; 00073 } 00074 00075
1.5.6