tarx
Horst von Brand
vonbrand en inf.utfsm.cl
Mar Ago 23 13:41:57 CLT 2005
Aca va un parche que lo endecenta para el uso de hoy. Ojala funcione...
--- tarx.c.old 2005-08-23 13:22:12.000000000 -0400
+++ tarx.c 2005-08-23 13:37:24.000000000 -0400
@@ -2,25 +2,32 @@
* tarx - manipulate damaged tar tapes heuristically
*/
+#include <unistd.h>
+#include <stdlib.h>
#include <stdio.h>
+#include <errno.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#define NAMSIZ 100 /* why isn't there a tar.h??? */
#define FLAG (NAMSIZ+8+8+8+12+12+8) /* offset of is-a-link flag */
struct matches {
int offset;
char value;
} matches[] = { /* pattern-match table for header blocks */
- NAMSIZ+6, ' ',
- NAMSIZ+7, '\0',
- NAMSIZ+8+6, ' ',
- NAMSIZ+8+7, '\0',
- NAMSIZ+16+6, ' ',
- NAMSIZ+16+7, '\0',
- NAMSIZ+24+11, ' ',
- NAMSIZ+36+11, ' ',
- NAMSIZ+48+6, '\0',
- 0, 0,
+ {NAMSIZ+6, ' '},
+ {NAMSIZ+7, '\0'},
+ {NAMSIZ+8+6, ' '},
+ {NAMSIZ+8+7, '\0'},
+ {NAMSIZ+16+6, ' '},
+ {NAMSIZ+16+7, '\0'},
+ {NAMSIZ+24+11, ' '},
+ {NAMSIZ+36+11, ' '},
+ {NAMSIZ+48+6, '\0'},
+ {0, 0},
};
#ifndef MAXBLOCK
@@ -46,14 +53,13 @@
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
-#ifndef lint
-static char RCSid[] = "$Header$";
-#endif
-
int debug = 0;
char *progname;
-extern void exit();
+extern void doblock(char *block, int argc, char **argv);
+extern int istar(char *block);
+extern int match(char *s, int argc, char **argv);
+
#ifdef UTZOOERR
extern char *mkprogname();
#else
@@ -63,6 +69,7 @@
/*
- main - parse arguments and handle options
*/
+int
main(argc, argv)
int argc;
char *argv[];
@@ -71,7 +78,6 @@
int errflg = 0;
register char *block;
extern char *readblock();
- extern char *malloc();
extern int optind;
extern char *optarg;
@@ -102,14 +108,14 @@
if (errflg) {
fprintf(stderr, "usage: %s ", progname);
fprintf(stderr, "[-t] [-b blockf] [-e errs] [-E eofs] [name] ...\n");
- exit(2);
+ exit(EXIT_FAILURE);
}
buf = malloc(maxblock*BLOCK);
if (buf == NULL) {
fprintf(stderr, "%s: cannot allocate buffer of %d blocks\n",
progname, maxblock);
- exit(1);
+ exit(EXIT_FAILURE);
}
for(;;) {
@@ -129,9 +135,6 @@
int desc;
{
register int count;
- extern int errno;
- extern int sys_nerr;
- extern char *sys_errlist[];
if (nleft > 0) {
whichnow++;
@@ -149,16 +152,14 @@
printf("---! bad block size (%d) - treated as bad\n", count);
nbad++;
} else {
- if (errno >= 0 && errno < sys_nerr)
- printf("---! error (%s)\n", sys_errlist[errno]);
- else
- printf("---! error %d\n", errno);
+ if (errno >= 0)
+ perror("---! error");
nbad++;
}
if (nbad >= badlimit)
- exit(1);
+ exit(EXIT_FAILURE);
if (neof >= eoflimit)
- exit(0);
+ exit(EXIT_SUCCESS);
return(NULL);
}
@@ -173,6 +174,7 @@
/*
- doblock - process a block
*/
+void
doblock(block, argc, argv)
char *block;
int argc;
Más información sobre la lista de distribución Linux