Lines Matching refs:Form
50 static size_t readfromfile(struct Form *form, char *buffer, size_t size);
256 * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form
272 FormInfo *first_form, *current_form, *form = NULL;
427 form = AddFormInfo(fname, NULL, current_form);
428 if(!form) {
433 form->value_alloc = TRUE;
434 current_form = form;
435 form = NULL;
498 accepted as a fine form part */
516 form = AddFormInfo(NULL, type, current_form);
517 if(!form) {
522 form->contenttype_alloc = TRUE;
523 current_form = form;
524 form = NULL;
613 for(form = first_form;
614 form != NULL;
615 form = form->more) {
616 if(((!form->name || !form->value) && !post) ||
617 ( (form->contentslength) &&
618 (form->flags & HTTPPOST_FILENAME) ) ||
619 ( (form->flags & HTTPPOST_FILENAME) &&
620 (form->flags & HTTPPOST_PTRCONTENTS) ) ||
622 ( (!form->buffer) &&
623 (form->flags & HTTPPOST_BUFFER) &&
624 (form->flags & HTTPPOST_PTRBUFFER) ) ||
626 ( (form->flags & HTTPPOST_READFILE) &&
627 (form->flags & HTTPPOST_PTRCONTENTS) )
633 if(((form->flags & HTTPPOST_FILENAME) ||
634 (form->flags & HTTPPOST_BUFFER)) &&
635 !form->contenttype) {
636 char *f = form->flags & HTTPPOST_BUFFER?
637 form->showfilename : form->value;
640 form->contenttype = strdup(ContentTypeForFilename(f, prevtype));
641 if(!form->contenttype) {
645 form->contenttype_alloc = TRUE;
647 if(!(form->flags & HTTPPOST_PTRNAME) &&
648 (form == first_form) ) {
649 /* Note that there's small risk that form->name is NULL here if the
651 if(form->name) {
653 form->name = Curl_memdup(form->name, form->namelength?
654 form->namelength:
655 strlen(form->name)+1);
657 if(!form->name) {
661 form->name_alloc = TRUE;
663 if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE |
665 HTTPPOST_CALLBACK)) && form->value) {
667 size_t clen = (size_t) form->contentslength;
669 clen = strlen(form->value)+1;
671 form->value = Curl_memdup(form->value, clen);
673 if(!form->value) {
677 form->value_alloc = TRUE;
679 post = AddHttpPost(form->name, form->namelength,
680 form->value, form->contentslength,
681 form->buffer, form->bufferlength,
682 form->contenttype, form->flags,
683 form->contentheader, form->showfilename,
684 form->userp,
693 if(form->contenttype)
694 prevtype = form->contenttype;
702 for(ptr = form; ptr != NULL; ptr = ptr->more) {
941 struct FormData *next, *form;
943 form = *form_ptr;
944 if(!form)
948 next=form->next; /* the following form line */
949 if(form->type <= FORM_CONTENT)
950 free(form->line); /* free the line */
951 free(form); /* free the struct */
953 } while((form = next) != NULL); /* continue */
965 int curl_formget(struct curl_httppost *form, void *arg,
972 result = Curl_getformdata(NULL, &data, form, NULL, &size);
980 struct Form temp;
1008 * curl_formfree() is an external function to free up a whole form post
1011 void curl_formfree(struct curl_httppost *form)
1015 if(!form)
1016 /* no form to free, just get out of this */
1020 next=form->next; /* the following form line */
1023 curl_formfree(form->more);
1025 if(!(form->flags & HTTPPOST_PTRNAME))
1026 free(form->name); /* free the name */
1027 if(!(form->flags &
1030 free(form->contents); /* free the contents */
1031 free(form->contenttype); /* free the content type */
1032 free(form->showfilename); /* free the faked file name */
1033 free(form); /* free the struct */
1035 } while((form = next) != NULL); /* continue */
1101 struct FormData **form,
1135 result = AddFormDataf(form, size,
1162 struct FormData *form = NULL;
1172 *finalform = NULL; /* default form is empty */
1182 result = AddFormDataf(&form, NULL,
1185 "Content-Type: multipart/form-data",
1195 firstform = form;
1200 result = AddFormDataf(&form, &size, "\r\n");
1206 result = AddFormDataf(&form, &size, "--%s\r\n", boundary);
1214 result = AddFormDataf(&form, &size,
1215 "Content-Disposition: form-data; name=\"");
1219 result = AddFormData(&form, FORM_DATA, post->name, post->namelength,
1224 result = AddFormDataf(&form, &size, "\"");
1239 result = AddFormDataf(&form, &size,
1257 result = AddFormDataf(&form, &size,
1263 result = formdata_add_filename(file, &form, &size);
1273 result = formdata_add_filename(post, &form, &size);
1282 result = AddFormDataf(&form, &size,
1291 /* Process the additional headers specified for this form */
1292 result = AddFormDataf(&form, &size, "\r\n%s", curList->data);
1300 result = AddFormDataf(&form, &size, "\r\n\r\n");
1323 result = AddFormData(&form, FORM_FILE, file->contents, 0, &size);
1334 result = AddFormData(&form, FORM_CONTENT, buffer, nread, &size);
1349 result = AddFormData(&form, FORM_CONTENT, post->buffer,
1354 result = AddFormData(&form, FORM_CALLBACK, post->userp,
1359 result = AddFormData(&form, FORM_CONTENT, post->contents,
1371 result = AddFormDataf(&form, &size,
1382 result = AddFormDataf(&form, &size, "\r\n--%s--\r\n", boundary);
1402 * Curl_FormInit() inits the struct 'form' points to with the 'formdata'
1405 int Curl_FormInit(struct Form *form, struct FormData *formdata)
1410 form->data = formdata;
1411 form->sent = 0;
1412 form->fp = NULL;
1413 form->fread_func = ZERO_NULL;
1456 static size_t readfromfile(struct Form *form, char *buffer,
1460 bool callback = (form->data->type == FORM_CALLBACK)?TRUE:FALSE;
1463 if(form->fread_func == ZERO_NULL)
1466 nread = form->fread_func(buffer, 1, size, form->data->line);
1469 if(!form->fp) {
1471 form->fp = fopen_read(form->data->line, "rb"); /* b is for binary */
1472 if(!form->fp)
1475 nread = fread(buffer, 1, size, form->fp);
1479 if(form->fp) {
1480 fclose(form->fp);
1481 form->fp = NULL;
1483 form->data = form->data->next;
1498 struct Form *form;
1502 form=(struct Form *)mydata;
1506 if(!form->data)
1509 if((form->data->type == FORM_FILE) ||
1510 (form->data->type == FORM_CALLBACK)) {
1511 gotsize = readfromfile(form, buffer, wantedsize);
1519 if((form->data->length - form->sent) > wantedsize - gotsize) {
1521 memcpy(buffer + gotsize, form->data->line + form->sent,
1524 form->sent += wantedsize-gotsize;
1530 form->data->line + form->sent,
1531 (form->data->length - form->sent) );
1532 gotsize += form->data->length - form->sent;
1534 form->sent = 0;
1536 form->data = form->data->next; /* advance */
1538 } while(form->data && (form->data->type < FORM_CALLBACK));
1553 struct Form *form=(struct Form *)formp;
1555 if(!form->data)
1558 header = form->data->line;
1559 *len = form->data->length;
1561 form->data = form->data->next; /* advance */
1592 int curl_formget(struct curl_httppost *form, void *arg,
1595 (void) form;
1601 void curl_formfree(struct curl_httppost *form)
1603 (void)form;