MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cgi_initialize_multipart

Function cgi_initialize_multipart

cgi-bin/var.c:836–1047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

834 */
835
836static int /* O - 1 if form data was read */
837cgi_initialize_multipart(
838 const char *boundary) /* I - Boundary string */
839{
840 char line[10240], /* MIME header line */
841 name[1024], /* Form variable name */
842 filename[1024], /* Form filename */
843 mimetype[1024], /* MIME media type */
844 bstring[256], /* Boundary string to look for */
845 *ptr, /* Pointer into name/filename */
846 *end; /* End of buffer */
847 int ch, /* Character from file */
848 fd; /* Temporary file descriptor */
849 size_t blen; /* Length of boundary string */
850
851
852 /*
853 * Read multipart form data until we run out...
854 */
855
856 name[0] = '\0';
857 filename[0] = '\0';
858 mimetype[0] = '\0';
859
860 snprintf(bstring, sizeof(bstring), "\r\n--%s", boundary);
861 blen = strlen(bstring);
862
863 while (fgets(line, sizeof(line), stdin))
864 {
865 if (!strcmp(line, "\r\n"))
866 {
867 /*
868 * End of headers, grab value...
869 */
870
871 if (filename[0])
872 {
873 /*
874 * Read an embedded file...
875 */
876
877 if (form_file)
878 {
879 /*
880 * Remove previous file...
881 */
882
883 cgi_unlink_file();
884 }
885
886 /*
887 * Allocate memory for the new file...
888 */
889
890 if ((form_file = calloc(1, sizeof(cgi_file_t))) == NULL)
891 return (0);
892
893 form_file->name = strdup(name);

Callers 1

cgiInitializeFunction · 0.85

Calls 7

cgi_unlink_fileFunction · 0.85
cupsTempFdFunction · 0.85
cgiSetArrayFunction · 0.85
cgiGetVariableFunction · 0.85
cgiGetSizeFunction · 0.85
cgiSetVariableFunction · 0.85
_cups_strncasecmpFunction · 0.85

Tested by

no test coverage detected