Thu, 20 Mar 2003 14:55:28 +0000
added match_suffix() to input handlers.
tumble.c | file | annotate | diff | revisions | |
tumble_input.c | file | annotate | diff | revisions | |
tumble_input.h | file | annotate | diff | revisions | |
tumble_jpeg.c | file | annotate | diff | revisions | |
tumble_tiff.c | file | annotate | diff | revisions |
1.1 --- a/tumble.c Thu Mar 20 08:32:16 2003 +0000 1.2 +++ b/tumble.c Thu Mar 20 14:55:28 2003 +0000 1.3 @@ -2,7 +2,7 @@ 1.4 * tumble: build a PDF file from image files 1.5 * 1.6 * Main program 1.7 - * $Id: tumble.c,v 1.39 2003/03/20 00:26:18 eric Exp $ 1.8 + * $Id: tumble.c,v 1.40 2003/03/20 06:55:27 eric Exp $ 1.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 1.10 * 1.11 * This program is free software; you can redistribute it and/or modify 1.12 @@ -224,10 +224,7 @@ 1.13 int len = strlen (in_fn); 1.14 1.15 p = strrchr (in_fn, '.'); 1.16 - if (p && ((strcasecmp (p, ".tif") == 0) || 1.17 - (strcasecmp (p, ".tiff") == 0) || 1.18 - (strcasecmp (p, ".jpg") == 0) || 1.19 - (strcasecmp (p, ".jpeg") == 0))) 1.20 + if (p && match_input_suffix (p)) 1.21 return (p - in_fn); 1.22 return (len); 1.23 }
2.1 --- a/tumble_input.c Thu Mar 20 08:32:16 2003 +0000 2.2 +++ b/tumble_input.c Thu Mar 20 14:55:28 2003 +0000 2.3 @@ -2,7 +2,7 @@ 2.4 * tumble: build a PDF file from image files 2.5 * 2.6 * Input handler dispatch 2.7 - * $Id: tumble_input.c,v 1.2 2003/03/19 23:02:28 eric Exp $ 2.8 + * $Id: tumble_input.c,v 1.3 2003/03/20 06:55:27 eric Exp $ 2.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 2.10 * 2.11 * This program is free software; you can redistribute it and/or modify 2.12 @@ -57,6 +57,15 @@ 2.13 } 2.14 2.15 2.16 +bool match_input_suffix (char *suffix) 2.17 +{ 2.18 + int i; 2.19 + for (i = 0; i < input_handler_count; i++) 2.20 + if (input_handlers [i]->match_suffix (suffix)) 2.21 + return (1); 2.22 + return (0); 2.23 +} 2.24 + 2.25 bool open_input_file (char *name) 2.26 { 2.27 int i;
3.1 --- a/tumble_input.h Thu Mar 20 08:32:16 2003 +0000 3.2 +++ b/tumble_input.h Thu Mar 20 14:55:28 2003 +0000 3.3 @@ -1,7 +1,7 @@ 3.4 /* 3.5 * tumble: build a PDF file from image files 3.6 * 3.7 - * $Id: tumble_input.h,v 1.1 2003/03/19 22:54:08 eric Exp $ 3.8 + * $Id: tumble_input.h,v 1.2 2003/03/20 06:55:27 eric Exp $ 3.9 * Copyright 2003 Eric Smith <eric@brouhaha.com> 3.10 * 3.11 * This program is free software; you can redistribute it and/or modify 3.12 @@ -32,6 +32,7 @@ 3.13 3.14 typedef struct 3.15 { 3.16 + bool (*match_suffix) (char *suffix); 3.17 bool (*open_input_file) (FILE *f, char *name); 3.18 bool (*close_input_file) (void); 3.19 bool (*last_input_page) (void); 3.20 @@ -48,6 +49,7 @@ 3.21 void install_input_handler (input_handler_t *handler); 3.22 3.23 3.24 +bool match_input_suffix (char *suffix); 3.25 bool open_input_file (char *name); 3.26 bool close_input_file (void); 3.27 bool last_input_page (void);
4.1 --- a/tumble_jpeg.c Thu Mar 20 08:32:16 2003 +0000 4.2 +++ b/tumble_jpeg.c Thu Mar 20 14:55:28 2003 +0000 4.3 @@ -1,7 +1,7 @@ 4.4 /* 4.5 * tumble: build a PDF file from image files 4.6 * 4.7 - * $Id: tumble_jpeg.c,v 1.3 2003/03/20 00:32:16 eric Exp $ 4.8 + * $Id: tumble_jpeg.c,v 1.4 2003/03/20 06:55:27 eric Exp $ 4.9 * Copyright 2003 Eric Smith <eric@brouhaha.com> 4.10 * 4.11 * This program is free software; you can redistribute it and/or modify 4.12 @@ -24,6 +24,7 @@ 4.13 #include <stdbool.h> 4.14 #include <stdint.h> 4.15 #include <stdio.h> 4.16 +#include <strings.h> /* strcasecmp() is a BSDism */ 4.17 #include <jpeglib.h> 4.18 4.19 4.20 @@ -40,13 +41,19 @@ 4.21 static struct jpeg_error_mgr jerr; 4.22 4.23 4.24 -bool close_jpeg_input_file (void) 4.25 +static bool match_jpeg_suffix (char *suffix) 4.26 +{ 4.27 + return ((strcasecmp (suffix, ".jpg") == 0) || 4.28 + (strcasecmp (suffix, ".jpeg") == 0)); 4.29 +} 4.30 + 4.31 +static bool close_jpeg_input_file (void) 4.32 { 4.33 return (1); 4.34 } 4.35 4.36 4.37 -bool open_jpeg_input_file (FILE *f, char *name) 4.38 +static bool open_jpeg_input_file (FILE *f, char *name) 4.39 { 4.40 uint8_t buf [2]; 4.41 size_t l; 4.42 @@ -75,15 +82,15 @@ 4.43 } 4.44 4.45 4.46 -bool last_jpeg_input_page (void) 4.47 +static bool last_jpeg_input_page (void) 4.48 { 4.49 return (1); 4.50 } 4.51 4.52 4.53 -bool get_jpeg_image_info (int image, 4.54 - input_attributes_t input_attributes, 4.55 - image_info_t *image_info) 4.56 +static bool get_jpeg_image_info (int image, 4.57 + input_attributes_t input_attributes, 4.58 + image_info_t *image_info) 4.59 { 4.60 double unit; 4.61 4.62 @@ -155,10 +162,10 @@ 4.63 } 4.64 4.65 4.66 -bool process_jpeg_image (int image, /* range 1 .. n */ 4.67 - input_attributes_t input_attributes, 4.68 - image_info_t *image_info, 4.69 - pdf_page_handle page) 4.70 +static bool process_jpeg_image (int image, /* range 1 .. n */ 4.71 + input_attributes_t input_attributes, 4.72 + image_info_t *image_info, 4.73 + pdf_page_handle page) 4.74 { 4.75 pdf_write_jpeg_image (page, 4.76 0, 0, /* x, y */ 4.77 @@ -175,6 +182,7 @@ 4.78 4.79 input_handler_t jpeg_handler = 4.80 { 4.81 + match_jpeg_suffix, 4.82 open_jpeg_input_file, 4.83 close_jpeg_input_file, 4.84 last_jpeg_input_page,
5.1 --- a/tumble_tiff.c Thu Mar 20 08:32:16 2003 +0000 5.2 +++ b/tumble_tiff.c Thu Mar 20 14:55:28 2003 +0000 5.3 @@ -1,7 +1,7 @@ 5.4 /* 5.5 * tumble: build a PDF file from image files 5.6 * 5.7 - * $Id: tumble_tiff.c,v 1.3 2003/03/20 00:20:52 eric Exp $ 5.8 + * $Id: tumble_tiff.c,v 1.4 2003/03/20 06:55:28 eric Exp $ 5.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 5.10 * 5.11 * This program is free software; you can redistribute it and/or modify 5.12 @@ -25,7 +25,7 @@ 5.13 #include <stdint.h> 5.14 #include <stdio.h> 5.15 #include <stdlib.h> 5.16 -#include <string.h> 5.17 +#include <strings.h> /* strcasecmp() is a BSDism */ 5.18 5.19 #include <tiffio.h> 5.20 #define TIFF_REVERSE_BITS 5.21 @@ -44,14 +44,21 @@ 5.22 #define SWAP(type,a,b) do { type temp; temp = a; a = b; b = temp; } while (0) 5.23 5.24 5.25 -bool close_tiff_input_file (void) 5.26 +static bool match_tiff_suffix (char *suffix) 5.27 +{ 5.28 + return ((strcasecmp (suffix, ".tif") == 0) || 5.29 + (strcasecmp (suffix, ".tiff") == 0)); 5.30 +} 5.31 + 5.32 + 5.33 +static bool close_tiff_input_file (void) 5.34 { 5.35 TIFFClose (tiff_in); 5.36 return (1); 5.37 } 5.38 5.39 5.40 -bool open_tiff_input_file (FILE *f, char *name) 5.41 +static bool open_tiff_input_file (FILE *f, char *name) 5.42 { 5.43 uint8_t buf [2]; 5.44 size_t l; 5.45 @@ -75,15 +82,15 @@ 5.46 } 5.47 5.48 5.49 -bool last_tiff_input_page (void) 5.50 +static bool last_tiff_input_page (void) 5.51 { 5.52 return (TIFFLastDirectory (tiff_in)); 5.53 } 5.54 5.55 5.56 -bool get_tiff_image_info (int image, 5.57 - input_attributes_t input_attributes, 5.58 - image_info_t *image_info) 5.59 +static bool get_tiff_image_info (int image, 5.60 + input_attributes_t input_attributes, 5.61 + image_info_t *image_info) 5.62 { 5.63 uint32_t image_height, image_width; 5.64 uint16_t samples_per_pixel; 5.65 @@ -250,10 +257,10 @@ 5.66 } 5.67 5.68 5.69 -bool process_tiff_image (int image, /* range 1 .. n */ 5.70 - input_attributes_t input_attributes, 5.71 - image_info_t *image_info, 5.72 - pdf_page_handle page) 5.73 +static bool process_tiff_image (int image, /* range 1 .. n */ 5.74 + input_attributes_t input_attributes, 5.75 + image_info_t *image_info, 5.76 + pdf_page_handle page) 5.77 { 5.78 bool result = 0; 5.79 Rect rect; 5.80 @@ -333,6 +340,7 @@ 5.81 5.82 input_handler_t tiff_handler = 5.83 { 5.84 + match_tiff_suffix, 5.85 open_tiff_input_file, 5.86 close_tiff_input_file, 5.87 last_tiff_input_page,