• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * CGI test program for CUPS.
3  *
4  * Copyright © 2020-2024 by OpenPrinting.
5  * Copyright © 2007-2014 by Apple Inc.
6  * Copyright © 1997-2005 by Easy Software Products.
7  *
8  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
9  * information.
10  */
11 
12 /*
13  * Include necessary headers...
14  */
15 
16 #include "cgi.h"
17 
18 
19 /*
20  * 'main()' - Test the CGI code.
21  */
22 
23 int					/* O - Exit status */
main(void)24 main(void)
25 {
26  /*
27   * Test file upload/multi-part submissions...
28   */
29 
30   freopen("multipart.dat", "rb", stdin);
31 
32   putenv("CONTENT_TYPE=multipart/form-data; "
33          "boundary=---------------------------1977426492562745908748943111");
34   putenv("REQUEST_METHOD=POST");
35 
36   printf("cgiInitialize: ");
37   if (cgiInitialize())
38   {
39     const cgi_file_t	*file;		/* Upload file */
40 
41     if ((file = cgiGetFile()) != NULL)
42     {
43       puts("PASS");
44       printf("    tempfile=\"%s\"\n", file->tempfile);
45       printf("    name=\"%s\"\n", file->name);
46       printf("    filename=\"%s\"\n", file->filename);
47       printf("    mimetype=\"%s\"\n", file->mimetype);
48     }
49     else
50       puts("FAIL (no file!)");
51   }
52   else
53     puts("FAIL (init)");
54 
55  /*
56   * Return with no errors...
57   */
58 
59   return (0);
60 }
61