tumble_jpeg.c

changeset 151
83a99cc69861
parent 150
17531d20e477
     1.1 --- a/tumble_jpeg.c	Thu Mar 20 08:32:16 2003 +0000
     1.2 +++ b/tumble_jpeg.c	Thu Mar 20 14:55:28 2003 +0000
     1.3 @@ -1,7 +1,7 @@
     1.4  /*
     1.5   * tumble: build a PDF file from image files
     1.6   *
     1.7 - * $Id: tumble_jpeg.c,v 1.3 2003/03/20 00:32:16 eric Exp $
     1.8 + * $Id: tumble_jpeg.c,v 1.4 2003/03/20 06:55:27 eric Exp $
     1.9   * Copyright 2003 Eric Smith <eric@brouhaha.com>
    1.10   *
    1.11   * This program is free software; you can redistribute it and/or modify
    1.12 @@ -24,6 +24,7 @@
    1.13  #include <stdbool.h>
    1.14  #include <stdint.h>
    1.15  #include <stdio.h>
    1.16 +#include <strings.h>  /* strcasecmp() is a BSDism */
    1.17  #include <jpeglib.h>
    1.18  
    1.19  
    1.20 @@ -40,13 +41,19 @@
    1.21  static struct jpeg_error_mgr jerr;
    1.22  
    1.23  
    1.24 -bool close_jpeg_input_file (void)
    1.25 +static bool match_jpeg_suffix (char *suffix)
    1.26 +{
    1.27 +  return ((strcasecmp (suffix, ".jpg") == 0) ||
    1.28 +	  (strcasecmp (suffix, ".jpeg") == 0));
    1.29 +}
    1.30 +
    1.31 +static bool close_jpeg_input_file (void)
    1.32  {
    1.33    return (1);
    1.34  }
    1.35  
    1.36  
    1.37 -bool open_jpeg_input_file (FILE *f, char *name)
    1.38 +static bool open_jpeg_input_file (FILE *f, char *name)
    1.39  {
    1.40    uint8_t buf [2];
    1.41    size_t l;
    1.42 @@ -75,15 +82,15 @@
    1.43  }
    1.44  
    1.45  
    1.46 -bool last_jpeg_input_page (void)
    1.47 +static bool last_jpeg_input_page (void)
    1.48  {
    1.49    return (1);
    1.50  }
    1.51  
    1.52  
    1.53 -bool get_jpeg_image_info (int image,
    1.54 -			  input_attributes_t input_attributes,
    1.55 -			  image_info_t *image_info)
    1.56 +static bool get_jpeg_image_info (int image,
    1.57 +				 input_attributes_t input_attributes,
    1.58 +				 image_info_t *image_info)
    1.59  {
    1.60    double unit;
    1.61  
    1.62 @@ -155,10 +162,10 @@
    1.63  }
    1.64  
    1.65  
    1.66 -bool process_jpeg_image (int image,  /* range 1 .. n */
    1.67 -			 input_attributes_t input_attributes,
    1.68 -			 image_info_t *image_info,
    1.69 -			 pdf_page_handle page)
    1.70 +static bool process_jpeg_image (int image,  /* range 1 .. n */
    1.71 +				input_attributes_t input_attributes,
    1.72 +				image_info_t *image_info,
    1.73 +				pdf_page_handle page)
    1.74  {
    1.75    pdf_write_jpeg_image (page,
    1.76  			0, 0,  /* x, y */
    1.77 @@ -175,6 +182,7 @@
    1.78  
    1.79  input_handler_t jpeg_handler =
    1.80    {
    1.81 +    match_jpeg_suffix,
    1.82      open_jpeg_input_file,
    1.83      close_jpeg_input_file,
    1.84      last_jpeg_input_page,