37 #include <sys/types.h>
38 #include <sys/param.h>
42 # define MAXPATHLEN BUFSIZ
45 static char temp[] =
"rleaddcomXXXXXX";
46 static char buf[MAXPATHLEN+1];
77 rle_hdr in_hdr, out_hdr;
78 char * fname = NULL, * out_fname = NULL;
80 FILE *outfile = stdout;
81 char ** comments = NULL;
83 int oflag = 0, iflag = 0, delflag = 0, ncomment = 0;
91 if (
scanargs( argc
, argv
, "% d%- i%- o%-outfile!s infile!s comments!*s",
92 &delflag
, &iflag
, &oflag
, &out_fname
, &fname
,
93 &ncomment
, &comments
) == 0 )
106 if ( strcmp( i_fname,
"-" ) == 0 )
109 "%s: Can't add comments \"in place\" to standard %s.\n",
110 my_name, oflag ?
"output" :
"input" );
113 #ifndef NO_OPEN_PIPES
114 if ( *i_fname ==
'|' )
117 "%s: Can't add comments \"in place\" to piped %s.\n",
118 my_name, oflag ?
"output" :
"input" );
122 strcpy(
buf, i_fname );
132 #ifndef NO_OPEN_PIPES
134 cp = i_fname + strlen( i_fname ) - 2;
135 if ( cp > i_fname && *cp ==
'.' && *(cp + 1) ==
'Z' )
159 for ( j = 0; j < ncomment; j++ )
187 fprintf( stderr,
"%s: %s not replaced\n",
191 #ifndef NO_OPEN_PIPES
198 if ( rename(
buf, i_fname ) < 0 )
200 fprintf( stderr,
"%s: rename failed: ", my_name );
211 rename( file1, file2 )
216 if ( stat(file2, &st) >= 0 && unlink(file2) < 0 )
218 if ( link(file1, file2) < 0 )
220 return unlink( file1 );
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
rle_hdr * rle_hdr_cp(rle_hdr *from_hdr, rle_hdr *to_hdr)
void rle_cp(rle_hdr *in_hdr, rle_hdr *the_hdr)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_get_setup(rle_hdr *the_hdr)
int rle_get_error(int code, const char *pgmname, const char *fname)
int scanargs(int argc, char **argv, const char *format,...)
const char * rle_delcom(char *name, the_hdr) const
void rle_put_setup(rle_hdr *the_hdr)
const char * rle_putcom(char *value, rle_hdr *the_hdr) const
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)