Lines Matching refs:form

49 static size_t readfromfile(struct Form *form, char *buffer, size_t size);
271 FormInfo *first_form, *current_form, *form = NULL;
426 form = AddFormInfo(fname, NULL, current_form);
427 if(!form) {
432 form->value_alloc = TRUE;
433 current_form = form;
434 form = NULL;
497 accepted as a fine form part */
515 form = AddFormInfo(NULL, type, current_form);
516 if(!form) {
521 form->contenttype_alloc = TRUE;
522 current_form = form;
523 form = NULL;
612 for(form = first_form;
613 form != NULL;
614 form = form->more) {
615 if(((!form->name || !form->value) && !post) ||
616 ( (form->contentslength) &&
617 (form->flags & HTTPPOST_FILENAME) ) ||
618 ( (form->flags & HTTPPOST_FILENAME) &&
619 (form->flags & HTTPPOST_PTRCONTENTS) ) ||
621 ( (!form->buffer) &&
622 (form->flags & HTTPPOST_BUFFER) &&
623 (form->flags & HTTPPOST_PTRBUFFER) ) ||
625 ( (form->flags & HTTPPOST_READFILE) &&
626 (form->flags & HTTPPOST_PTRCONTENTS) )
632 if(((form->flags & HTTPPOST_FILENAME) ||
633 (form->flags & HTTPPOST_BUFFER)) &&
634 !form->contenttype) {
635 char *f = form->flags & HTTPPOST_BUFFER?
636 form->showfilename : form->value;
639 form->contenttype = strdup(ContentTypeForFilename(f, prevtype));
640 if(!form->contenttype) {
644 form->contenttype_alloc = TRUE;
646 if(!(form->flags & HTTPPOST_PTRNAME) &&
647 (form == first_form) ) {
648 /* Note that there's small risk that form->name is NULL here if the
650 if(form->name) {
652 form->name = Curl_memdup(form->name, form->namelength?
653 form->namelength:
654 strlen(form->name)+1);
656 if(!form->name) {
660 form->name_alloc = TRUE;
662 if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE |
664 HTTPPOST_CALLBACK)) && form->value) {
666 size_t clen = (size_t) form->contentslength;
668 clen = strlen(form->value)+1;
670 form->value = Curl_memdup(form->value, clen);
672 if(!form->value) {
676 form->value_alloc = TRUE;
678 post = AddHttpPost(form->name, form->namelength,
679 form->value, form->contentslength,
680 form->buffer, form->bufferlength,
681 form->contenttype, form->flags,
682 form->contentheader, form->showfilename,
683 form->userp,
692 if(form->contenttype)
693 prevtype = form->contenttype;
701 for(ptr = form; ptr != NULL; ptr = ptr->more) {
924 struct FormData *next, *form;
926 form = *form_ptr;
927 if(!form)
931 next=form->next; /* the following form line */
932 if(form->type <= FORM_CONTENT)
933 free(form->line); /* free the line */
934 free(form); /* free the struct */
936 } while((form = next) != NULL); /* continue */
948 int curl_formget(struct curl_httppost *form, void *arg,
955 result = Curl_getformdata(NULL, &data, form, NULL, &size);
991 * curl_formfree() is an external function to free up a whole form post
994 void curl_formfree(struct curl_httppost *form)
998 if(!form)
999 /* no form to free, just get out of this */
1003 next=form->next; /* the following form line */
1006 curl_formfree(form->more);
1008 if(!(form->flags & HTTPPOST_PTRNAME))
1009 free(form->name); /* free the name */
1010 if(!(form->flags &
1013 free(form->contents); /* free the contents */
1014 free(form->contenttype); /* free the content type */
1015 free(form->showfilename); /* free the faked file name */
1016 free(form); /* free the struct */
1018 } while((form = next) != NULL); /* continue */
1084 struct FormData **form,
1118 result = AddFormDataf(form, size,
1145 struct FormData *form = NULL;
1155 *finalform = NULL; /* default form is empty */
1165 result = AddFormDataf(&form, NULL,
1168 "Content-Type: multipart/form-data",
1178 firstform = form;
1183 result = AddFormDataf(&form, &size, "\r\n");
1189 result = AddFormDataf(&form, &size, "--%s\r\n", boundary);
1197 result = AddFormDataf(&form, &size,
1198 "Content-Disposition: form-data; name=\"");
1202 result = AddFormData(&form, FORM_DATA, post->name, post->namelength,
1207 result = AddFormDataf(&form, &size, "\"");
1222 result = AddFormDataf(&form, &size,
1240 result = AddFormDataf(&form, &size,
1246 result = formdata_add_filename(file, &form, &size);
1256 result = formdata_add_filename(post, &form, &size);
1265 result = AddFormDataf(&form, &size,
1274 /* Process the additional headers specified for this form */
1275 result = AddFormDataf(&form, &size, "\r\n%s", curList->data);
1283 result = AddFormDataf(&form, &size, "\r\n\r\n");
1306 result = AddFormData(&form, FORM_FILE, file->contents, 0, &size);
1317 result = AddFormData(&form, FORM_CONTENT, buffer, nread, &size);
1332 result = AddFormData(&form, FORM_CONTENT, post->buffer,
1337 result = AddFormData(&form, FORM_CALLBACK, post->userp,
1342 result = AddFormData(&form, FORM_CONTENT, post->contents,
1354 result = AddFormDataf(&form, &size,
1365 result = AddFormDataf(&form, &size, "\r\n--%s--\r\n", boundary);
1385 * Curl_FormInit() inits the struct 'form' points to with the 'formdata'
1388 int Curl_FormInit(struct Form *form, struct FormData *formdata)
1393 form->data = formdata;
1394 form->sent = 0;
1395 form->fp = NULL;
1396 form->fread_func = ZERO_NULL;
1438 static size_t readfromfile(struct Form *form, char *buffer,
1442 bool callback = (form->data->type == FORM_CALLBACK)?TRUE:FALSE;
1445 if(form->fread_func == ZERO_NULL)
1448 nread = form->fread_func(buffer, 1, size, form->data->line);
1451 if(!form->fp) {
1453 form->fp = fopen_read(form->data->line, "rb"); /* b is for binary */
1454 if(!form->fp)
1457 nread = fread(buffer, 1, size, form->fp);
1461 if(form->fp) {
1462 fclose(form->fp);
1463 form->fp = NULL;
1465 form->data = form->data->next;
1480 struct Form *form;
1484 form=(struct Form *)mydata;
1488 if(!form->data)
1491 if((form->data->type == FORM_FILE) ||
1492 (form->data->type == FORM_CALLBACK)) {
1493 gotsize = readfromfile(form, buffer, wantedsize);
1501 if((form->data->length - form->sent) > wantedsize - gotsize) {
1503 memcpy(buffer + gotsize, form->data->line + form->sent,
1506 form->sent += wantedsize-gotsize;
1512 form->data->line + form->sent,
1513 (form->data->length - form->sent) );
1514 gotsize += form->data->length - form->sent;
1516 form->sent = 0;
1518 form->data = form->data->next; /* advance */
1520 } while(form->data && (form->data->type < FORM_CALLBACK));
1535 struct Form *form=(struct Form *)formp;
1537 if(!form->data)
1540 header = form->data->line;
1541 *len = form->data->length;
1543 form->data = form->data->next; /* advance */
1570 int curl_formget(struct curl_httppost *form, void *arg,
1573 (void) form;
1579 void curl_formfree(struct curl_httppost *form)
1581 (void)form;