65 int num = 1,
oflag = 0, digits = 3, tflag = 0;
68 static char nullpref[] =
"";
69 char *prefix = nullpref;
78 "% n%-number!ddigits%d o%-prefix!s t%- infile%s\n(\
79 \tSplit a multi-image file into separate files.\n\
80 \t-n\tSpecify number assigned to first image, optionally specify\n\
81 \t\tnumber of digits used for numbering (default 3).\n\
82 \t-o\tSpecify output filename prefix. If not specified, input\n\
83 \t\tfile name (without .rle) will be used. Output file names are\n\
84 \t\tof the form prefix.number.rle.\n\
85 \t-t\tUse TITLE (or title) comment as file name. They should be distinct.)",
86 &num, &num, &digits, &
oflag, &prefix, &tflag,
94 if (
oflag || infname )
96 format =
"%s.%0*d.rle";
101 for ( cp = infname; *cp; cp++ )
104 for ( slashp = cp - 1; *slashp !=
'/' && slashp >
infname; )
106 if ( *slashp ==
'/' )
109 while ( *--cp !=
'.' && cp > infname )
111 if ( strcmp( cp,
".rle" ) != 0 )
112 cp = infname + strlen( infname );
114 prefix = (
char *)calloc( cp - slashp + 1, 1 );
117 strncpy( prefix, infname, cp - slashp );
128 sprintf( filebuf,
"%s%s", prefix, title );
130 sprintf( filebuf, format, prefix, digits, num++ );
132 fprintf( stderr,
"%s: Creating %s\n",
cmd_name( argv ), filebuf );
141 rle_cp( &in_hdr, &out_hdr );
int scanargs(int argc, char **argv, const char *format,...)
char * rle_getcom(const char *name, rle_hdr *the_hdr)
void rle_cp(rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_addhist(char *argv[], rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
int rle_get_setup(rle_hdr *the_hdr)
void rle_close_f(FILE *fd)
int rle_get_error(int code, const char *pgmname, const char *fname)
rle_hdr * rle_hdr_cp(rle_hdr *from_hdr, rle_hdr *to_hdr)
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
void rle_put_setup(rle_hdr *the_hdr)
char * cmd_name(char **argv)
#define RLE_CHECK_ALLOC(pgm, ptr, name)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)