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