@@ -203,7 +203,8 @@ main(int argc, // I - Number of command-line args
203203 * resolutions , // pwg-raster-document-resolution-supported
204204 * sheet_back , // pwg-raster-document-sheet-back
205205 * types , // pwg-raster-document-type-supported
206- * opt ; // Option character
206+ * opt , // Option character
207+ * ext ; // Filename extension
207208 size_t num_files = 0 ; // Number of files
208209 xform_document_t files [1000 ]; // Files to convert
209210 size_t num_options = 0 ; // Number of options
@@ -304,6 +305,20 @@ main(int argc, // I - Number of command-line args
304305 usage (1 );
305306 }
306307
308+ if (!output_type && (ext = strrchr (argv [i ], '.' )) != NULL )
309+ {
310+ if (!strcasecmp (ext , ".pcl" ))
311+ output_type = "application/vnd.hp-PCL" ;
312+ else if (!strcasecmp (ext , ".pdf" ))
313+ output_type = "application/pdf" ;
314+ else if (!strcasecmp (ext , ".ps" ))
315+ output_type = "application/postscript" ;
316+ else if (!strcasecmp (ext , ".pwg" ))
317+ output_type = "image/pwg-raster" ;
318+ else if (!strcasecmp (ext , ".urf" ))
319+ output_type = "image/urf" ;
320+ }
321+
307322 if (!freopen (argv [i ], "w" , stdout ))
308323 {
309324 cupsLangPrintf (stderr , _ ("%s: Unable to open '%s': %s" ), Prefix , argv [i ], strerror (errno ));
@@ -412,23 +427,19 @@ main(int argc, // I - Number of command-line args
412427
413428 if (!files [num_files ].format )
414429 {
415- if ((opt = strrchr (argv [i ], '.' )) != NULL )
430+ if ((ext = strrchr (argv [i ], '.' )) != NULL )
416431 {
417- if (!strcmp ( opt , ".jpg" ) || !strcmp ( opt , ".jpeg" ))
432+ if (!strcasecmp ( ext , ".jpg" ) || !strcasecmp ( ext , ".jpeg" ))
418433 files [num_files ].format = "image/jpeg" ;
419- else if (!strcmp (opt , ".pcl" ))
420- files [num_files ].format = "application/vnd.hp-PCL" ;
421- else if (!strcmp (opt , ".pdf" ))
434+ else if (!strcasecmp (ext , ".pdf" ))
422435 files [num_files ].format = "application/pdf" ;
423- else if (!strcmp ( opt , ".png" ))
436+ else if (!strcasecmp ( ext , ".png" ))
424437 files [num_files ].format = "image/png" ;
425- else if (!strcmp (opt , ".pxl" ))
426- files [num_files ].format = "application/vnd.hp-PCLXL" ;
427- else if (!strcmp (opt , ".pwg" ))
438+ else if (!strcasecmp (ext , ".pwg" ))
428439 files [num_files ].format = "image/pwg-raster" ;
429- else if (!strcmp ( opt , ".c" ) || !strcmp ( opt , ".c++" ) || !strcmp ( opt , ".cpp" ) || !strcmp ( opt , ".cxx" ) || !strcmp ( opt , ".h" ) || !strcmp ( opt , ".hpp" ) || !strcmp ( opt , ".m" ) || !strcmp ( opt , ".md" ) || !strcmp ( opt , ".py" ) || !strcmp ( opt , ".rst" ) || !strcmp ( opt , ".swift" ) || !strcmp ( opt , ".txt" ))
440+ else if (!strcasecmp ( ext , ".c" ) || !strcasecmp ( ext , ".c++" ) || !strcasecmp ( ext , ".cpp" ) || !strcasecmp ( ext , ".cxx" ) || !strcasecmp ( ext , ".h" ) || !strcasecmp ( ext , ".hpp" ) || !strcasecmp ( ext , ".m" ) || !strcasecmp ( ext , ".md" ) || !strcasecmp ( ext , ".pl" ) || ! strcasecmp ( ext , ". py" ) || !strcasecmp ( ext , ".rst" ) || !strcasecmp ( ext , ".swift" ) || !strcasecmp ( ext , ".txt" ))
430441 files [num_files ].format = "text/plain" ;
431- else if (!strcmp ( opt , ".urf" ))
442+ else if (!strcasecmp ( ext , ".urf" ))
432443 files [num_files ].format = "image/urf" ;
433444 }
434445 }
0 commit comments