#include "rle_config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <string.h>
Go to the source code of this file.
|
static char | temp [] = "intoXXXXXX" |
|
static char | buf [4096 +1] |
|
short | forceflg |
|
#define _XOPEN_SOURCE /* For mkstemp */ |
void main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 52 of file into.c.
63 if (argc >= 2 && !strcmp(argv[1],
"-f"))
70 fprintf(stderr,
"Usage: into [ -f ] file\n");
73 if (!
forceflg && access(argv[1], 2) < 0 && errno != ENOENT)
75 fprintf(stderr,
"into: ");
80 if ( (cp =
rindex( argv[1],
'/' )) != NULL )
84 strcpy(
buf, argv[1] );
93 if ( (outf = fopen(
buf,
"w" )) == NULL )
99 while ( (size = fread(iobuf, 1,
sizeof iobuf, stdin)) != 0)
100 fwrite(iobuf, 1, size, outf);
102 if ( !
forceflg && ftell(outf) == 0L )
104 fprintf( stderr,
"into: empty output, \"%s\" not modified\n", argv[1]);
111 fprintf(stderr,
"into: %s, \"%s\" not modified\n",
112 strerror(errno), argv[1]);
118 if ( rename(
buf, argv[1] ) < 0 )
120 fprintf(stderr,
"into: rename(%s, %s): ",
buf, argv[1]);
char temp[] = "intoXXXXXX" |
|
static |