Home | History | Annotate | Download | only in lib

Lines Matching refs:Form

50 static size_t readfromfile(struct Form *form, char *buffer, size_t size);
248 * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form
264 FormInfo *first_form, *current_form, *form = NULL;
416 form = AddFormInfo(fname, NULL, current_form);
417 if(!form) {
422 form->value_alloc = TRUE;
423 current_form = form;
424 form = NULL;
487 accepted as a fine form part */
505 form = AddFormInfo(NULL, type, current_form);
506 if(!form) {
511 form->contenttype_alloc = TRUE;
512 form;
513 form = NULL;
602 for(form = first_form;
603 form != NULL;
604 form = form->more) {
605 if(((!form->name || !form->value) && !post) ||
606 ( (form->contentslength) &&
607 (form->flags & HTTPPOST_FILENAME) ) ||
608 ( (form->flags & HTTPPOST_FILENAME) &&
609 (form->flags & HTTPPOST_PTRCONTENTS) ) ||
611 ( (!form->buffer) &&
612 (form->flags & HTTPPOST_BUFFER) &&
613 (form->flags & HTTPPOST_PTRBUFFER) ) ||
615 ( (form->flags & HTTPPOST_READFILE) &&
616 (form->flags & HTTPPOST_PTRCONTENTS) )
622 if(((form->flags & HTTPPOST_FILENAME) ||
623 (form->flags & HTTPPOST_BUFFER)) &&
624 !form->contenttype ) {
625 char *f = form->flags & HTTPPOST_BUFFER?
626 form->showfilename : form->value;
629 form->contenttype = strdup(ContentTypeForFilename(f, prevtype));
630 if(!form->contenttype) {
634 form->contenttype_alloc = TRUE;
636 if(!(form->flags & HTTPPOST_PTRNAME) &&
637 (form == first_form) ) {
638 /* Note that there's small risk that form->name is NULL here if the
640 if(form->name) {
642 form->name = Curl_memdup(form->name, form->namelength?
643 form->namelength:
644 strlen(form->name)+1);
646 if(!form->name) {
650 form->name_alloc = TRUE;
652 if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE |
654 HTTPPOST_CALLBACK)) && form->value) {
656 form->value = Curl_memdup(form->value, form->contentslength?
657 form->contentslength:
658 strlen(form->value)+1);
659 if(!form->value) {
663 form->value_alloc = TRUE;
665 post = AddHttpPost(form->name, form->namelength,
666 form->value, form->contentslength,
667 form->buffer, form->bufferlength,
668 form->contenttype, form->flags,
669 form->contentheader, form->showfilename,
670 form->userp,
679 if(form->contenttype)
680 prevtype = form->contenttype;
688 for(ptr = form; ptr != NULL; ptr = ptr->more) {
890 struct FormData *next, *form;
892 form = *form_ptr;
893 if(!form)
897 next=form->next; /* the following form line */
898 if(form->type <= FORM_CONTENT)
899 free(form->line); /* free the line */
900 free(form); /* free the struct */
902 } while((form = next) != NULL); /* continue */
914 int curl_formget(struct curl_httppost *form, void *arg,
921 result = Curl_getformdata(NULL, &data, form, NULL, &size);
929 struct Form temp;
957 * curl_formfree() is an external function to free up a whole form post
960 void curl_formfree(struct curl_httppost *form)
964 if(!form)
965 /* no form to free, just get out of this */
969 next=form->next; /* the following form line */
972 curl_formfree(form->more);
974 if(!(form->flags & HTTPPOST_PTRNAME))
975 free(form->name); /* free the name */
976 if(!(form->flags &
979 free(form->contents); /* free the contents */
980 free(form->contenttype); /* free the content type */
981 free(form->showfilename); /* free the faked file name */
982 free(form); /* free the struct */
984 } while((form = next) != NULL); /* continue */
1050 struct FormData **form,
1084 result = AddFormDataf(form, size,
1111 struct FormData *form = NULL;
1121 *finalform = NULL; /* default form is empty */
1131 result = AddFormDataf(&form, NULL,
1134 "Content-Type: multipart/form-data",
1144 firstform = form;
1149 result = AddFormDataf(&form, &size, "\r\n");
1155 result = AddFormDataf(&form, &size, "--%s\r\n", boundary);
1163 result = AddFormDataf(&form, &size,
1164 "Content-Disposition: form-data; name=\"");
1168 result = AddFormData(&form, FORM_DATA, post->name, post->namelength,
1173 result = AddFormDataf(&form, &size, "\"");
1188 result = AddFormDataf(&form, &size,
1206 result = AddFormDataf(&form, &size,
1212 result = formdata_add_filename(file, &form, &size);
1222 result = formdata_add_filename(post, &form, &size);
1231 result = AddFormDataf(&form, &size,
1240 /* Process the additional headers specified for this form */
1241 result = AddFormDataf( &form, &size, "\r\n%s", curList->data );
1249 result = AddFormDataf(&form, &size, "\r\n\r\n");
1272 result = AddFormData(&form, FORM_FILE, file->contents, 0, &size);
1283 result = AddFormData(&form, FORM_CONTENT, buffer, nread, &size);
1298 result = AddFormData(&form, FORM_CONTENT, post->buffer,
1303 result = AddFormData(&form, FORM_CALLBACK, post->userp,
1307 result = AddFormData(&form, FORM_CONTENT, post->contents,
1319 result = AddFormDataf(&form, &size,
1330 result = AddFormDataf(&form, &size, "\r\n--%s--\r\n", boundary);
1350 * Curl_FormInit() inits the struct 'form' points to with the 'formdata'
1353 int Curl_FormInit(struct Form *form, struct FormData *formdata )
1358 form->data = formdata;
1359 form->sent = 0;
1360 form->fp = NULL;
1361 form->fread_func = ZERO_NULL;
1403 static size_t readfromfile(struct Form *form, char *buffer,
1407 bool callback = (form->data->type == FORM_CALLBACK)?TRUE:FALSE;
1410 if(form->fread_func == ZERO_NULL)
1413 nread = form->fread_func(buffer, 1, size, form->data->line);
1416 if(!form->fp) {
1418 form->fp = fopen_read(form->data->line, "rb"); /* b is for binary */
1419 if(!form->fp)
1422 nread = fread(buffer, 1, size, form->fp);
1426 if(form->fp) {
1427 fclose(form->fp);
1428 form->fp = NULL;
1430 form->data = form->data->next;
1445 struct Form *form;
1449 form=(struct Form *)mydata;
1453 if(!form->data)
1456 if((form->data->type == FORM_FILE) ||
1457 (form->data->type == FORM_CALLBACK)) {
1458 gotsize = readfromfile(form, buffer, wantedsize);
1466 if((form->data->length - form->sent ) > wantedsize - gotsize) {
1468 memcpy(buffer + gotsize , form->data->line + form->sent,
1471 form->sent += wantedsize-gotsize;
1477 form->data->line + form->sent,
1478 (form->data->length - form->sent) );
1479 gotsize += form->data->length - form->sent;
1481 form->sent = 0;
1483 form->data = form->data->next; /* advance */
1485 } while(form->data && (form->data->type < FORM_CALLBACK));
1500 struct Form *form=(struct Form *)formp;
1502 if(!form->data)
1505 header = form->data->line;
1506 *len = form->data->length;
1508 form->data = form->data->next; /* advance */
1535 int curl_formget(struct curl_httppost *form, void *arg,
1538 (void) form;
1544 void curl_formfree(struct curl_httppost *form)
1546 (void)form;