Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Functions
rleaddeof.c File Reference
#include <stdio.h>
#include "rle.h"
#include "rle_raw.h"
Include dependency graph for rleaddeof.c:

Go to the source code of this file.

Functions

void main (int argc, char **argv)
 

Function Documentation

void main ( int  argc,
char **  argv 
)

Definition at line 32 of file rleaddeof.c.

35 {
36  char * infname = NULL, *outfname = NULL;
37  int oflag = 0;
38  FILE *outfile = stdout;
40  int rle_cnt, rle_err;
41 
42  in_hdr = *rle_hdr_init( NULL );
43  out_hdr = *rle_hdr_init( NULL );
44 
45  if ( scanargs( argc, argv, "% o%-outfile!s infile%s",
46  &oflag, &outfname, &infname ) == 0 )
47  exit( 1 );
48 
49  /* Open input file */
50  in_hdr.rle_file = rle_open_f( cmd_name( argv ), infname, "r" );
51  rle_names( &in_hdr, cmd_name( argv ), infname, 0 );
52  rle_names( &out_hdr, out_hdr.cmd, outfname, 0 );
53  for ( rle_cnt = 0;
54  (rle_err = rle_get_setup( &in_hdr )) == RLE_SUCCESS;
55  rle_cnt++ )
56  {
57  /* Open output after first successful read. */
58  if ( rle_cnt == 0 )
59  outfile = rle_open_f( "rleaddeof", outfname, "w" );
60 
61  /* Copy input to output file */
62  (void)rle_hdr_cp( &in_hdr, &out_hdr );
63  out_hdr.rle_file = outfile;
64  rle_put_setup( &out_hdr );
65 
66  rle_cp( &in_hdr, &out_hdr );
67  }
68 
69  /* Check for an error. EOF or EMPTY is ok if at least one image
70  * has been read. Otherwise, print an error message.
71  */
72  if ( rle_cnt == 0 || (rle_err != RLE_EOF && rle_err != RLE_EMPTY) )
73  rle_get_error( rle_err, cmd_name( argv ), infname );
74 
75 
76  exit( 0 );
77 }
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
static rle_hdr in_hdr
Definition: rletogif.c:37
FILE * outfile
Definition: giftorle.c:61
#define RLE_EMPTY
Definition: rle.h:73
void rle_cp(rle_hdr *in_hdr, rle_hdr *out_hdr)
Definition: rle_cp.c:69
#define RLE_SUCCESS
Definition: rle.h:70
string infname
Definition: getbob.c:68
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
const char * cmd
Definition: rle.h:133
int rle_get_setup(rle_hdr *the_hdr)
Definition: rle_getrow.c:74
Definition: rle.h:96
int rle_get_error(int code, const char *pgmname, const char *fname)
#define RLE_EOF
Definition: rle.h:74
rle_hdr * rle_hdr_cp(rle_hdr *from_hdr, rle_hdr *to_hdr)
Definition: rle_hdr.c:119
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
void rle_put_setup(rle_hdr *the_hdr)
Definition: rle_putrow.c:453
char * cmd_name(char **argv)
Definition: cmd_name.c:31
int oflag
Definition: painttorle.c:45
FILE * rle_file
Definition: rle.h:114
rle_hdr out_hdr
Definition: dvirle2.c:89
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267