1 #ifndef __FORMDATA_H 2 #define __FORMDATA_H 3 4 /*************************************************************************** 5 * _ _ ____ _ 6 * Project ___| | | | _ \| | 7 * / __| | | | |_) | | 8 * | (__| |_| | _ <| |___ 9 * \___|\___/|_| \_\_____| 10 * 11 * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. 12 * 13 * This software is licensed as described in the file COPYING, which 14 * you should have received as part of this distribution. The terms 15 * are also available at http://curl.haxx.se/docs/copyright.html. 16 * 17 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 18 * copies of the Software, and permit persons to whom the Software is 19 * furnished to do so, under the terms of the COPYING file. 20 * 21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 22 * KIND, either express or implied. 23 * 24 * $Id: formdata.h,v 1.27 2008-03-31 10:02:25 bagder Exp $ 25 ***************************************************************************/ 26 27 enum formtype { 28 FORM_DATA, /* form metadata (convert to network encoding if necessary) */ 29 FORM_CONTENT, /* form content (never convert) */ 30 FORM_CALLBACK, /* 'line' points to the custom pointer we pass to the callback 31 */ 32 FORM_FILE /* 'line' points to a file name we should read from 33 to create the form data (never convert) */ 34 }; 35 36 /* plain and simple linked list with lines to send */ 37 struct FormData { 38 struct FormData *next; 39 enum formtype type; 40 char *line; 41 size_t length; 42 }; 43 44 struct Form { 45 struct FormData *data; /* current form line to send */ 46 size_t sent; /* number of bytes of the current line that has 47 already been sent in a previous invoke */ 48 FILE *fp; /* file to read from */ 49 curl_read_callback fread_func; /* fread callback pointer */ 50 }; 51 52 /* used by FormAdd for temporary storage */ 53 typedef struct FormInfo { 54 char *name; 55 bool name_alloc; 56 size_t namelength; 57 char *value; 58 bool value_alloc; 59 size_t contentslength; 60 char *contenttype; 61 bool contenttype_alloc; 62 long flags; 63 char *buffer; /* pointer to existing buffer used for file upload */ 64 size_t bufferlength; 65 char *showfilename; /* The file name to show. If not set, the actual 66 file name will be used */ 67 bool showfilename_alloc; 68 char *userp; /* pointer for the read callback */ 69 struct curl_slist* contentheader; 70 struct FormInfo *more; 71 } FormInfo; 72 73 int Curl_FormInit(struct Form *form, struct FormData *formdata ); 74 75 CURLcode 76 Curl_getFormData(struct FormData **, 77 struct curl_httppost *post, 78 const char *custom_contenttype, 79 curl_off_t *size); 80 81 /* fread() emulation */ 82 size_t Curl_FormReader(char *buffer, 83 size_t size, 84 size_t nitems, 85 FILE *mydata); 86 87 /* 88 * Curl_formpostheader() returns the first line of the formpost, the 89 * request-header part (which is not part of the request-body like the rest of 90 * the post). 91 */ 92 char *Curl_formpostheader(void *formp, size_t *len); 93 94 char *Curl_FormBoundary(void); 95 96 void Curl_formclean(struct FormData **); 97 98 CURLcode Curl_formconvert(struct SessionHandle *, struct FormData *); 99 100 #endif 101 102