semantics.c

changeset 55
43a9b9f27403
parent 49
be20d7e8466f
child 104
82cb954059c4
     1.1 --- a/semantics.c	Wed Feb 19 10:17:12 2003 +0000
     1.2 +++ b/semantics.c	Wed Feb 19 10:20:05 2003 +0000
     1.3 @@ -4,7 +4,7 @@
     1.4   *      will be compressed using ITU-T T.6 (G4) fax encoding.
     1.5   *
     1.6   * Semantic routines for spec file parser
     1.7 - * $Id: semantics.c,v 1.16 2003/01/21 10:30:49 eric Exp $
     1.8 + * $Id: semantics.c,v 1.17 2003/02/19 02:20:05 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 @@ -449,7 +449,7 @@
    1.13  }
    1.14  
    1.15  
    1.16 -static char *get_input_file (input_context_t *context)
    1.17 +static char *get_input_filename (input_context_t *context)
    1.18  {
    1.19    for (; context; context = context->parent)
    1.20      if (context->input_file)
    1.21 @@ -498,7 +498,7 @@
    1.22    return (0);  /* default */
    1.23  }
    1.24  
    1.25 -static char *get_output_file (output_context_t *context)
    1.26 +static char *get_output_filename (output_context_t *context)
    1.27  {
    1.28    for (; context; context = context->parent)
    1.29      if (context->output_file)
    1.30 @@ -547,7 +547,7 @@
    1.31  					     parity,
    1.32  					     & page_size);
    1.33  	printf ("file '%s' image %d",
    1.34 -	        get_input_file (image->input_context),
    1.35 +	        get_input_filename (image->input_context),
    1.36  		i);
    1.37  	if (has_rotation)
    1.38  	  printf (" rotation %d", rotation);
    1.39 @@ -575,7 +575,7 @@
    1.40        for (i = page->range.first; i <= page->range.last; i++)
    1.41  	{
    1.42  	  page_label_t *label = get_output_page_label (page->output_context);
    1.43 -	  printf ("file \"%s\" ", get_output_file (page->output_context));
    1.44 +	  printf ("file \"%s\" ", get_output_filename (page->output_context));
    1.45  	  if (label)
    1.46  	    {
    1.47  	      printf ("label ");
    1.48 @@ -658,27 +658,41 @@
    1.49      {
    1.50        if ((! image) || (i >= range_count (image->range)))
    1.51  	{
    1.52 +	  char *input_fn;
    1.53  	  if (image)
    1.54  	    image = image->next;
    1.55  	  else
    1.56  	    image = first_input_image;
    1.57  	  if (! image)
    1.58 -	    return (0);
    1.59 +	    return (1);  /* done */
    1.60  	  i = 0;
    1.61 -	  if (! open_tiff_input_file (get_input_file (image->input_context)))
    1.62 -	    return (0);
    1.63 +	  input_fn = get_input_filename (image->input_context);
    1.64 +	  if (verbose)
    1.65 +	    fprintf (stderr, "opening TIFF file '%s'\n", input_fn);
    1.66 +	  if (! open_tiff_input_file (input_fn))
    1.67 +	    {
    1.68 +	      fprintf (stderr, "error opening TIFF file '%s'\n", input_fn);
    1.69 +	      return (0);
    1.70 +	    }
    1.71  	}
    1.72  
    1.73        if ((! page) || (p >= range_count (page->range)))
    1.74  	{
    1.75 +	  char *output_fn;
    1.76  	  if (page)
    1.77  	    page = page->next;
    1.78  	  else
    1.79  	    page = first_output_page;
    1.80  	  p = 0;
    1.81 -	  if (! open_pdf_output_file (get_output_file (page->output_context),
    1.82 +	  output_fn = get_output_filename (page->output_context);
    1.83 +	  if (verbose)
    1.84 +	    fprintf (stderr, "opening PDF file '%s'\n", output_fn);
    1.85 +	  if (! open_pdf_output_file (output_fn,
    1.86  				      get_output_file_attributes (page->output_context)))
    1.87 -	    return (0);
    1.88 +	    {
    1.89 +	      fprintf (stderr, "error opening PDF file '%s'\n", output_fn);
    1.90 +	      return (0);
    1.91 +	    }
    1.92  	  page_label = get_output_page_label (page->output_context);
    1.93  	  process_page_numbers (page_index,
    1.94  				range_count (page->range),
    1.95 @@ -699,14 +713,17 @@
    1.96  							    parity,
    1.97  							    & input_attributes.page_size);
    1.98  
    1.99 +      if (verbose)
   1.100 +	fprintf (stderr, "processing image %d\n", image->range.first + i);
   1.101        if (! process_page (image->range.first + i,
   1.102  			  input_attributes,
   1.103  			  page->bookmark_list))
   1.104 -	return (0);
   1.105 +	{
   1.106 +	  fprintf (stderr, "error processing image %d\n", image->range.first + i);
   1.107 +	  return (0);
   1.108 +	}
   1.109        i++;
   1.110        p++;
   1.111        page_index++;
   1.112      }
   1.113 -
   1.114 -  return (1);
   1.115  }