aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/ar.c24
-rw-r--r--archival/gunzip.c22
-rw-r--r--archival/gzip.c18
-rw-r--r--archival/tar.c106
4 files changed, 85 insertions, 85 deletions
diff --git a/archival/ar.c b/archival/ar.c
index a9a0a0a71..88cdd4f9f 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -106,7 +106,7 @@ static int checkTarMagic(int srcFd)
106 106
107 headerStart = lseek(srcFd, 0, SEEK_CUR); 107 headerStart = lseek(srcFd, 0, SEEK_CUR);
108 lseek(srcFd, (off_t) 257, SEEK_CUR); 108 lseek(srcFd, (off_t) 257, SEEK_CUR);
109 fullRead(srcFd, magic, 6); 109 full_read(srcFd, magic, 6);
110 lseek(srcFd, headerStart, SEEK_SET); 110 lseek(srcFd, headerStart, SEEK_SET);
111 if (strncmp(magic, "ustar", 5)!=0) 111 if (strncmp(magic, "ustar", 5)!=0)
112 return(FALSE); 112 return(FALSE);
@@ -123,7 +123,7 @@ static int readTarHeader(int srcFd, headerL_t *current)
123 off_t initialOffset; 123 off_t initialOffset;
124 124
125 initialOffset = lseek(srcFd, 0, SEEK_CUR); 125 initialOffset = lseek(srcFd, 0, SEEK_CUR);
126 if (fullRead(srcFd, (char *) &rawTarHeader, 512) != 512) { 126 if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
127 lseek(srcFd, initialOffset, SEEK_SET); 127 lseek(srcFd, initialOffset, SEEK_SET);
128 return(FALSE); 128 return(FALSE);
129 } 129 }
@@ -157,8 +157,8 @@ static int checkArMagic(int srcFd)
157 char arMagic[8]; 157 char arMagic[8];
158 158
159 headerStart = lseek(srcFd, 0, SEEK_CUR); 159 headerStart = lseek(srcFd, 0, SEEK_CUR);
160 if (fullRead(srcFd, arMagic, 8) != 8) { 160 if (full_read(srcFd, arMagic, 8) != 8) {
161 errorMsg("fatal error\n"); 161 error_msg("fatal error\n");
162 return (FALSE); 162 return (FALSE);
163 } 163 }
164 lseek(srcFd, headerStart, SEEK_SET); 164 lseek(srcFd, headerStart, SEEK_SET);
@@ -178,7 +178,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
178 off_t initialOffset; 178 off_t initialOffset;
179 179
180 initialOffset = lseek(srcFd, 0, SEEK_CUR); 180 initialOffset = lseek(srcFd, 0, SEEK_CUR);
181 if (fullRead(srcFd, (char *) &rawArHeader, 60) != 60) { 181 if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
182 lseek(srcFd, initialOffset, SEEK_SET); 182 lseek(srcFd, initialOffset, SEEK_SET);
183 return(FALSE); 183 return(FALSE);
184 } 184 }
@@ -215,7 +215,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
215 215
216 if (entry->size > MAX_NAME_LENGTH) 216 if (entry->size > MAX_NAME_LENGTH)
217 entry->size = MAX_NAME_LENGTH; 217 entry->size = MAX_NAME_LENGTH;
218 fullRead(srcFd, tempName, entry->size); 218 full_read(srcFd, tempName, entry->size);
219 tempName[entry->size-3]='\0'; 219 tempName[entry->size-3]='\0';
220 220
221 /* read the second header for this entry */ 221 /* read the second header for this entry */
@@ -226,7 +226,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
226 if ((entry->name[0]='/') && (entry->name[1]='0')) 226 if ((entry->name[0]='/') && (entry->name[1]='0'))
227 strcpy(entry->name, tempName); 227 strcpy(entry->name, tempName);
228 else { 228 else {
229 errorMsg("Invalid long filename\n"); 229 error_msg("Invalid long filename\n");
230 return(FALSE); 230 return(FALSE);
231 } 231 }
232 } 232 }
@@ -343,7 +343,7 @@ extern int ar_main(int argc, char **argv)
343 usage(ar_usage); 343 usage(ar_usage);
344 344
345 if ( (srcFd = open(argv[optind], O_RDONLY)) < 0) 345 if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
346 fatalError("Cannot read %s\n", argv[optind]); 346 error_msg_and_die("Cannot read %s\n", argv[optind]);
347 347
348 optind++; 348 optind++;
349 entry = (headerL_t *) xmalloc(sizeof(headerL_t)); 349 entry = (headerL_t *) xmalloc(sizeof(headerL_t));
@@ -368,8 +368,8 @@ extern int ar_main(int argc, char **argv)
368 368
369 while(extractList->next != NULL) { 369 while(extractList->next != NULL) {
370 if (funct & EXT_TO_FILE) { 370 if (funct & EXT_TO_FILE) {
371 if (isDirectory(extractList->name, TRUE, NULL)==FALSE) 371 if (is_directory(extractList->name, TRUE, NULL)==FALSE)
372 createPath(extractList->name, 0666); 372 create_path(extractList->name, 0666);
373 dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode); 373 dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
374 lseek(srcFd, extractList->offset, SEEK_SET); 374 lseek(srcFd, extractList->offset, SEEK_SET);
375 copy_file_chunk(srcFd, dstFd, (size_t) extractList->size); 375 copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
@@ -380,9 +380,9 @@ extern int ar_main(int argc, char **argv)
380 } 380 }
381 if ( (funct & DISPLAY) || (funct & VERBOSE)) { 381 if ( (funct & DISPLAY) || (funct & VERBOSE)) {
382 if (funct & VERBOSE) 382 if (funct & VERBOSE)
383 printf("%s %d/%d %8d %s ", modeString(extractList->mode), 383 printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
384 extractList->uid, extractList->gid, 384 extractList->uid, extractList->gid,
385 extractList->size, timeString(extractList->mtime)); 385 extractList->size, time_string(extractList->mtime));
386 printf("%s\n", extractList->name); 386 printf("%s\n", extractList->name);
387 } 387 }
388 extractList=extractList->next; 388 extractList=extractList->next;
diff --git a/archival/gunzip.c b/archival/gunzip.c
index eeff9774a..a5846c378 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -113,7 +113,7 @@ static char *license_msg[] = {
113 113
114/* Diagnostic functions */ 114/* Diagnostic functions */
115#ifdef DEBUG 115#ifdef DEBUG
116# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} 116# define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
117# define Trace(x) fprintf x 117# define Trace(x) fprintf x
118# define Tracev(x) {if (verbose) fprintf x ;} 118# define Tracev(x) {if (verbose) fprintf x ;}
119# define Tracevv(x) {if (verbose>1) fprintf x ;} 119# define Tracevv(x) {if (verbose>1) fprintf x ;}
@@ -297,7 +297,7 @@ int in; /* input file descriptor */
297 297
298 method = (int) get_byte(); 298 method = (int) get_byte();
299 if (method != DEFLATED) { 299 if (method != DEFLATED) {
300 errorMsg("unknown method %d -- get newer version of gzip\n", method); 300 error_msg("unknown method %d -- get newer version of gzip\n", method);
301 exit_code = ERROR; 301 exit_code = ERROR;
302 return -1; 302 return -1;
303 } 303 }
@@ -1114,13 +1114,13 @@ int in, out; /* input and output file descriptors */
1114 int res = inflate(); 1114 int res = inflate();
1115 1115
1116 if (res == 3) { 1116 if (res == 3) {
1117 errorMsg(memory_exhausted); 1117 error_msg(memory_exhausted);
1118 } else if (res != 0) { 1118 } else if (res != 0) {
1119 errorMsg("invalid compressed data--format violated\n"); 1119 error_msg("invalid compressed data--format violated\n");
1120 } 1120 }
1121 1121
1122 } else { 1122 } else {
1123 errorMsg("internal error, invalid method\n"); 1123 error_msg("internal error, invalid method\n");
1124 } 1124 }
1125 1125
1126 /* Get the crc and original length */ 1126 /* Get the crc and original length */
@@ -1149,10 +1149,10 @@ int in, out; /* input and output file descriptors */
1149 1149
1150 /* Validate decompression */ 1150 /* Validate decompression */
1151 if (orig_crc != updcrc(outbuf, 0)) { 1151 if (orig_crc != updcrc(outbuf, 0)) {
1152 errorMsg("invalid compressed data--crc error\n"); 1152 error_msg("invalid compressed data--crc error\n");
1153 } 1153 }
1154 if (orig_len != (ulg) bytes_out) { 1154 if (orig_len != (ulg) bytes_out) {
1155 errorMsg("invalid compressed data--length error\n"); 1155 error_msg("invalid compressed data--length error\n");
1156 } 1156 }
1157 1157
1158 /* Check if there are more entries in a pkzip file */ 1158 /* Check if there are more entries in a pkzip file */
@@ -1225,9 +1225,9 @@ int gunzip_main(int argc, char **argv)
1225 } 1225 }
1226 1226
1227 if (isatty(fileno(stdin)) && fromstdin==1 && force==0) 1227 if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
1228 fatalError( "data not read from terminal. Use -f to force it.\n"); 1228 error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
1229 if (isatty(fileno(stdout)) && tostdout==1 && force==0) 1229 if (isatty(fileno(stdout)) && tostdout==1 && force==0)
1230 fatalError( "data not written to terminal. Use -f to force it.\n"); 1230 error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
1231 1231
1232 1232
1233 foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; 1233 foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
@@ -1265,7 +1265,7 @@ int gunzip_main(int argc, char **argv)
1265 if (argc <= 0) 1265 if (argc <= 0)
1266 usage(gunzip_usage); 1266 usage(gunzip_usage);
1267 if (strlen(*argv) > MAX_PATH_LEN) { 1267 if (strlen(*argv) > MAX_PATH_LEN) {
1268 errorMsg(name_too_long); 1268 error_msg(name_too_long);
1269 exit(WARNING); 1269 exit(WARNING);
1270 } 1270 }
1271 strcpy(ifname, *argv); 1271 strcpy(ifname, *argv);
@@ -1304,7 +1304,7 @@ int gunzip_main(int argc, char **argv)
1304 1304
1305 /* And get to work */ 1305 /* And get to work */
1306 if (strlen(ifname) > MAX_PATH_LEN - 4) { 1306 if (strlen(ifname) > MAX_PATH_LEN - 4) {
1307 errorMsg(name_too_long); 1307 error_msg(name_too_long);
1308 exit(WARNING); 1308 exit(WARNING);
1309 } 1309 }
1310 strcpy(ofname, ifname); 1310 strcpy(ofname, ifname);
diff --git a/archival/gzip.c b/archival/gzip.c
index d8c22a924..49c429b3a 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -114,7 +114,7 @@ extern int method; /* compression method */
114# define DECLARE(type, array, size) type * array 114# define DECLARE(type, array, size) type * array
115# define ALLOC(type, array, size) { \ 115# define ALLOC(type, array, size) { \
116 array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ 116 array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
117 if (array == NULL) errorMsg(memory_exhausted); \ 117 if (array == NULL) error_msg(memory_exhausted); \
118 } 118 }
119# define FREE(array) {if (array != NULL) free(array), array=NULL;} 119# define FREE(array) {if (array != NULL) free(array), array=NULL;}
120#else 120#else
@@ -251,7 +251,7 @@ extern int save_orig_name; /* set if original name must be saved */
251 251
252/* Diagnostic functions */ 252/* Diagnostic functions */
253#ifdef DEBUG 253#ifdef DEBUG
254# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} 254# define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
255# define Trace(x) fprintf x 255# define Trace(x) fprintf x
256# define Tracev(x) {if (verbose) fprintf x ;} 256# define Tracev(x) {if (verbose) fprintf x ;}
257# define Tracevv(x) {if (verbose>1) fprintf x ;} 257# define Tracevv(x) {if (verbose>1) fprintf x ;}
@@ -1381,7 +1381,7 @@ int length;
1381 (char *) window + start, length) != EQUAL) { 1381 (char *) window + start, length) != EQUAL) {
1382 fprintf(stderr, 1382 fprintf(stderr,
1383 " start %d, match %d, length %d\n", start, match, length); 1383 " start %d, match %d, length %d\n", start, match, length);
1384 errorMsg("invalid match\n"); 1384 error_msg("invalid match\n");
1385 } 1385 }
1386 if (verbose > 1) { 1386 if (verbose > 1) {
1387 fprintf(stderr, "\\[%d,%d]", start - match, length); 1387 fprintf(stderr, "\\[%d,%d]", start - match, length);
@@ -1819,9 +1819,9 @@ int gzip_main(int argc, char **argv)
1819 } 1819 }
1820 1820
1821 if (isatty(fileno(stdin)) && fromstdin==1 && force==0) 1821 if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
1822 fatalError( "data not read from terminal. Use -f to force it.\n"); 1822 error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
1823 if (isatty(fileno(stdout)) && tostdout==1 && force==0) 1823 if (isatty(fileno(stdout)) && tostdout==1 && force==0)
1824 fatalError( "data not written to terminal. Use -f to force it.\n"); 1824 error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
1825 1825
1826 foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; 1826 foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
1827 if (foreground) { 1827 if (foreground) {
@@ -2900,7 +2900,7 @@ int eof; /* true if this is the last block for a file */
2900#endif 2900#endif
2901 /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ 2901 /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
2902 if (buf == (char *) 0) 2902 if (buf == (char *) 0)
2903 errorMsg("block vanished\n"); 2903 error_msg("block vanished\n");
2904 2904
2905 copy_block(buf, (unsigned) stored_len, 0); /* without header */ 2905 copy_block(buf, (unsigned) stored_len, 0); /* without header */
2906 compressed_len = stored_len << 3; 2906 compressed_len = stored_len << 3;
@@ -3083,7 +3083,7 @@ local void set_file_type()
3083 bin_freq += dyn_ltree[n++].Freq; 3083 bin_freq += dyn_ltree[n++].Freq;
3084 *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; 3084 *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
3085 if (*file_type == BINARY && translate_eol) { 3085 if (*file_type == BINARY && translate_eol) {
3086 errorMsg("-l used on binary file\n"); 3086 error_msg("-l used on binary file\n");
3087 } 3087 }
3088} 3088}
3089 3089
@@ -3239,13 +3239,13 @@ char *env; /* name of environment variable */
3239 nargv = (char **) calloc(*argcp + 1, sizeof(char *)); 3239 nargv = (char **) calloc(*argcp + 1, sizeof(char *));
3240 3240
3241 if (nargv == NULL) 3241 if (nargv == NULL)
3242 errorMsg(memory_exhausted); 3242 error_msg(memory_exhausted);
3243 oargv = *argvp; 3243 oargv = *argvp;
3244 *argvp = nargv; 3244 *argvp = nargv;
3245 3245
3246 /* Copy the program name first */ 3246 /* Copy the program name first */
3247 if (oargc-- < 0) 3247 if (oargc-- < 0)
3248 errorMsg("argc<=0\n"); 3248 error_msg("argc<=0\n");
3249 *(nargv++) = *(oargv++); 3249 *(nargv++) = *(oargv++);
3250 3250
3251 /* Then copy the environment args */ 3251 /* Then copy the environment args */
diff --git a/archival/tar.c b/archival/tar.c
index 906fd7eda..cc7ba3b80 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -193,10 +193,10 @@ extern int tar_main(int argc, char **argv)
193 break; 193 break;
194 case 'f': 194 case 'f':
195 if (*tarName != '-') 195 if (*tarName != '-')
196 fatalError( "Only one 'f' option allowed\n"); 196 error_msg_and_die( "Only one 'f' option allowed\n");
197 tarName = *(++argv); 197 tarName = *(++argv);
198 if (tarName == NULL) 198 if (tarName == NULL)
199 fatalError( "Option requires an argument: No file specified\n"); 199 error_msg_and_die( "Option requires an argument: No file specified\n");
200 stopIt=TRUE; 200 stopIt=TRUE;
201 break; 201 break;
202#if defined BB_FEATURE_TAR_EXCLUDE 202#if defined BB_FEATURE_TAR_EXCLUDE
@@ -205,7 +205,7 @@ extern int tar_main(int argc, char **argv)
205 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 205 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
206 excludeList[excludeListSize] = *(++argv); 206 excludeList[excludeListSize] = *(++argv);
207 if (excludeList[excludeListSize] == NULL) 207 if (excludeList[excludeListSize] == NULL)
208 fatalError( "Option requires an argument: No file specified\n"); 208 error_msg_and_die( "Option requires an argument: No file specified\n");
209 /* Remove leading "/"s */ 209 /* Remove leading "/"s */
210 if (*excludeList[excludeListSize] =='/') 210 if (*excludeList[excludeListSize] =='/')
211 excludeList[excludeListSize] = (excludeList[excludeListSize])+1; 211 excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
@@ -216,13 +216,13 @@ extern int tar_main(int argc, char **argv)
216 } 216 }
217 case 'X': 217 case 'X':
218 if (*excludeFileName != '-') 218 if (*excludeFileName != '-')
219 fatalError("Only one 'X' option allowed\n"); 219 error_msg_and_die("Only one 'X' option allowed\n");
220 excludeFileName = *(++argv); 220 excludeFileName = *(++argv);
221 if (excludeFileName == NULL) 221 if (excludeFileName == NULL)
222 fatalError("Option requires an argument: No file specified\n"); 222 error_msg_and_die("Option requires an argument: No file specified\n");
223 fileList = fopen (excludeFileName, "rt"); 223 fileList = fopen (excludeFileName, "rt");
224 if (! fileList) 224 if (! fileList)
225 fatalError("Exclude file: file not found\n"); 225 error_msg_and_die("Exclude file: file not found\n");
226 while (!feof(fileList)) { 226 while (!feof(fileList)) {
227 fscanf(fileList, "%s", file); 227 fscanf(fileList, "%s", file);
228 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 228 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
@@ -253,7 +253,7 @@ extern int tar_main(int argc, char **argv)
253 */ 253 */
254 if (createFlag == TRUE) { 254 if (createFlag == TRUE) {
255#ifndef BB_FEATURE_TAR_CREATE 255#ifndef BB_FEATURE_TAR_CREATE
256 fatalError( "This version of tar was not compiled with tar creation support.\n"); 256 error_msg_and_die( "This version of tar was not compiled with tar creation support.\n");
257#else 257#else
258 status = writeTarFile(tarName, verboseFlag, argv, excludeList); 258 status = writeTarFile(tarName, verboseFlag, argv, excludeList);
259#endif 259#endif
@@ -271,7 +271,7 @@ extern int tar_main(int argc, char **argv)
271 return EXIT_FAILURE; 271 return EXIT_FAILURE;
272 272
273 flagError: 273 flagError:
274 fatalError( "Exactly one of 'c', 'x' or 't' must be specified\n"); 274 error_msg_and_die( "Exactly one of 'c', 'x' or 't' must be specified\n");
275} 275}
276 276
277static void 277static void
@@ -301,10 +301,10 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
301 if (extractFlag==TRUE && tostdoutFlag==FALSE) { 301 if (extractFlag==TRUE && tostdoutFlag==FALSE) {
302 /* Create the path to the file, just in case it isn't there... 302 /* Create the path to the file, just in case it isn't there...
303 * This should not screw up path permissions or anything. */ 303 * This should not screw up path permissions or anything. */
304 createPath(header->name, 0777); 304 create_path(header->name, 0777);
305 if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY, 305 if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY,
306 header->mode & ~S_IFMT)) < 0) { 306 header->mode & ~S_IFMT)) < 0) {
307 errorMsg(io_error, header->name, strerror(errno)); 307 error_msg(io_error, header->name, strerror(errno));
308 return( FALSE); 308 return( FALSE);
309 } 309 }
310 } 310 }
@@ -322,9 +322,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
322 readSize = size; 322 readSize = size;
323 writeSize = size; 323 writeSize = size;
324 } 324 }
325 if ( (readSize = fullRead(header->tarFd, buffer, readSize)) <= 0 ) { 325 if ( (readSize = full_read(header->tarFd, buffer, readSize)) <= 0 ) {
326 /* Tarball seems to have a problem */ 326 /* Tarball seems to have a problem */
327 errorMsg("Unexpected EOF in archive\n"); 327 error_msg("Unexpected EOF in archive\n");
328 return( FALSE); 328 return( FALSE);
329 } 329 }
330 if ( readSize < writeSize ) 330 if ( readSize < writeSize )
@@ -333,9 +333,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
333 /* Write out the file, if we are supposed to be doing that */ 333 /* Write out the file, if we are supposed to be doing that */
334 if (extractFlag==TRUE) { 334 if (extractFlag==TRUE) {
335 335
336 if ((actualWriteSz=fullWrite(outFd, buffer, writeSize)) != writeSize ) { 336 if ((actualWriteSz=full_write(outFd, buffer, writeSize)) != writeSize ) {
337 /* Output file seems to have a problem */ 337 /* Output file seems to have a problem */
338 errorMsg(io_error, header->name, strerror(errno)); 338 error_msg(io_error, header->name, strerror(errno));
339 return( FALSE); 339 return( FALSE);
340 } 340 }
341 } else { 341 } else {
@@ -361,13 +361,13 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
361 if (extractFlag==FALSE || tostdoutFlag==TRUE) 361 if (extractFlag==FALSE || tostdoutFlag==TRUE)
362 return( TRUE); 362 return( TRUE);
363 363
364 if (createPath(header->name, header->mode) != TRUE) { 364 if (create_path(header->name, header->mode) != TRUE) {
365 errorMsg("%s: Cannot mkdir: %s\n", 365 error_msg("%s: Cannot mkdir: %s\n",
366 header->name, strerror(errno)); 366 header->name, strerror(errno));
367 return( FALSE); 367 return( FALSE);
368 } 368 }
369 /* make the final component, just in case it was 369 /* make the final component, just in case it was
370 * omitted by createPath() (which will skip the 370 * omitted by create_path() (which will skip the
371 * directory if it doesn't have a terminating '/') */ 371 * directory if it doesn't have a terminating '/') */
372 if (mkdir(header->name, header->mode) == 0) { 372 if (mkdir(header->name, header->mode) == 0) {
373 fixUpPermissions(header); 373 fixUpPermissions(header);
@@ -382,7 +382,7 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
382 return( TRUE); 382 return( TRUE);
383 383
384 if (link(header->linkname, header->name) < 0) { 384 if (link(header->linkname, header->name) < 0) {
385 errorMsg("%s: Cannot create hard link to '%s': %s\n", 385 error_msg("%s: Cannot create hard link to '%s': %s\n",
386 header->name, header->linkname, strerror(errno)); 386 header->name, header->linkname, strerror(errno));
387 return( FALSE); 387 return( FALSE);
388 } 388 }
@@ -400,7 +400,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
400 400
401#ifdef S_ISLNK 401#ifdef S_ISLNK
402 if (symlink(header->linkname, header->name) < 0) { 402 if (symlink(header->linkname, header->name) < 0) {
403 errorMsg("%s: Cannot create symlink to '%s': %s\n", 403 error_msg("%s: Cannot create symlink to '%s': %s\n",
404 header->name, header->linkname, strerror(errno)); 404 header->name, header->linkname, strerror(errno));
405 return( FALSE); 405 return( FALSE);
406 } 406 }
@@ -415,7 +415,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
415 /* Do not change permissions or date on symlink, 415 /* Do not change permissions or date on symlink,
416 * since it changes the pointed to file instead. duh. */ 416 * since it changes the pointed to file instead. duh. */
417#else 417#else
418 errorMsg("%s: Cannot create symlink to '%s': %s\n", 418 error_msg("%s: Cannot create symlink to '%s': %s\n",
419 header->name, header->linkname, 419 header->name, header->linkname,
420 "symlinks not supported"); 420 "symlinks not supported");
421#endif 421#endif
@@ -430,13 +430,13 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
430 430
431 if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) { 431 if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
432 if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) { 432 if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
433 errorMsg("%s: Cannot mknod: %s\n", 433 error_msg("%s: Cannot mknod: %s\n",
434 header->name, strerror(errno)); 434 header->name, strerror(errno));
435 return( FALSE); 435 return( FALSE);
436 } 436 }
437 } else if (S_ISFIFO(header->mode)) { 437 } else if (S_ISFIFO(header->mode)) {
438 if (mkfifo(header->name, header->mode) < 0) { 438 if (mkfifo(header->name, header->mode) < 0) {
439 errorMsg("%s: Cannot mkfifo: %s\n", 439 error_msg("%s: Cannot mkfifo: %s\n",
440 header->name, strerror(errno)); 440 header->name, strerror(errno));
441 return( FALSE); 441 return( FALSE);
442 } 442 }
@@ -455,9 +455,9 @@ static long getOctal(const char *cp, int size)
455 long val = 0; 455 long val = 0;
456 456
457 for(;(size > 0) && (*cp == ' '); cp++, size--); 457 for(;(size > 0) && (*cp == ' '); cp++, size--);
458 if ((size == 0) || !isOctal(*cp)) 458 if ((size == 0) || !is_octal(*cp))
459 return -1; 459 return -1;
460 for(; (size > 0) && isOctal(*cp); size--) { 460 for(; (size > 0) && is_octal(*cp); size--) {
461 val = val * 8 + *cp++ - '0'; 461 val = val * 8 + *cp++ - '0';
462 } 462 }
463 for (;(size > 0) && (*cp == ' '); cp++, size--); 463 for (;(size > 0) && (*cp == ' '); cp++, size--);
@@ -484,7 +484,7 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
484 ++*(header->name); 484 ++*(header->name);
485 485
486 if (alreadyWarned == FALSE) { 486 if (alreadyWarned == FALSE) {
487 errorMsg("Removing leading '/' from member names\n"); 487 error_msg("Removing leading '/' from member names\n");
488 alreadyWarned = TRUE; 488 alreadyWarned = TRUE;
489 } 489 }
490 } 490 }
@@ -538,7 +538,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
538 else 538 else
539 tarFd = open(tarName, O_RDONLY); 539 tarFd = open(tarName, O_RDONLY);
540 if (tarFd < 0) { 540 if (tarFd < 0) {
541 errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno)); 541 error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
542 return ( FALSE); 542 return ( FALSE);
543 } 543 }
544 544
@@ -547,7 +547,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
547 umask(0); 547 umask(0);
548 548
549 /* Read the tar file, and iterate over it one file at a time */ 549 /* Read the tar file, and iterate over it one file at a time */
550 while ( (status = fullRead(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) { 550 while ( (status = full_read(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
551 551
552 /* Try to read the header */ 552 /* Try to read the header */
553 if ( readTarHeader(&rawHeader, &header) == FALSE ) { 553 if ( readTarHeader(&rawHeader, &header) == FALSE ) {
@@ -555,7 +555,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
555 goto endgame; 555 goto endgame;
556 } else { 556 } else {
557 errorFlag=TRUE; 557 errorFlag=TRUE;
558 errorMsg("Bad tar header, skipping\n"); 558 error_msg("Bad tar header, skipping\n");
559 continue; 559 continue;
560 } 560 }
561 } 561 }
@@ -572,7 +572,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
572 } 572 }
573 if ( skipNextHeaderFlag == TRUE ) { 573 if ( skipNextHeaderFlag == TRUE ) {
574 skipNextHeaderFlag=FALSE; 574 skipNextHeaderFlag=FALSE;
575 errorMsg(name_longer_than_foo, NAME_SIZE); 575 error_msg(name_longer_than_foo, NAME_SIZE);
576 if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE) 576 if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
577 errorFlag = TRUE; 577 errorFlag = TRUE;
578 continue; 578 continue;
@@ -638,7 +638,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
638 char buf[35]; 638 char buf[35];
639 struct tm *tm = localtime (&(header.mtime)); 639 struct tm *tm = localtime (&(header.mtime));
640 640
641 len=printf("%s ", modeString(header.mode)); 641 len=printf("%s ", mode_string(header.mode));
642 memset(buf, 0, 8*sizeof(char)); 642 memset(buf, 0, 8*sizeof(char));
643 my_getpwuid(buf, header.uid); 643 my_getpwuid(buf, header.uid);
644 if (! *buf) 644 if (! *buf)
@@ -731,7 +731,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
731 break; 731 break;
732#endif 732#endif
733 default: 733 default:
734 errorMsg("Unknown file type '%c' in tar file\n", header.type); 734 error_msg("Unknown file type '%c' in tar file\n", header.type);
735 close( tarFd); 735 close( tarFd);
736 return( FALSE); 736 return( FALSE);
737 } 737 }
@@ -739,11 +739,11 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
739 close(tarFd); 739 close(tarFd);
740 if (status > 0) { 740 if (status > 0) {
741 /* Bummer - we read a partial header */ 741 /* Bummer - we read a partial header */
742 errorMsg( "Error reading '%s': %s\n", tarName, strerror(errno)); 742 error_msg( "Error reading '%s': %s\n", tarName, strerror(errno));
743 return ( FALSE); 743 return ( FALSE);
744 } 744 }
745 else if (errorFlag==TRUE) { 745 else if (errorFlag==TRUE) {
746 errorMsg( "Error exit delayed from previous errors\n"); 746 error_msg( "Error exit delayed from previous errors\n");
747 return( FALSE); 747 return( FALSE);
748 } else 748 } else
749 return( status); 749 return( status);
@@ -753,13 +753,13 @@ endgame:
753 close( tarFd); 753 close( tarFd);
754 if (extractList != NULL) { 754 if (extractList != NULL) {
755 for (; *extractList != NULL; extractList++) { 755 for (; *extractList != NULL; extractList++) {
756 errorMsg("%s: Not found in archive\n", *extractList); 756 error_msg("%s: Not found in archive\n", *extractList);
757 errorFlag = TRUE; 757 errorFlag = TRUE;
758 } 758 }
759 } 759 }
760 if ( *(header.name) == '\0' ) { 760 if ( *(header.name) == '\0' ) {
761 if (errorFlag==TRUE) 761 if (errorFlag==TRUE)
762 errorMsg( "Error exit delayed from previous errors\n"); 762 error_msg( "Error exit delayed from previous errors\n");
763 else 763 else
764 return( TRUE); 764 return( TRUE);
765 } 765 }
@@ -903,7 +903,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
903 if (*fileName=='/') { 903 if (*fileName=='/') {
904 static int alreadyWarned=FALSE; 904 static int alreadyWarned=FALSE;
905 if (alreadyWarned==FALSE) { 905 if (alreadyWarned==FALSE) {
906 errorMsg("Removing leading '/' from member names\n"); 906 error_msg("Removing leading '/' from member names\n");
907 alreadyWarned=TRUE; 907 alreadyWarned=TRUE;
908 } 908 }
909 strncpy(header.name, fileName+1, sizeof(header.name)); 909 strncpy(header.name, fileName+1, sizeof(header.name));
@@ -956,7 +956,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
956 header.typeflag = SYMTYPE; 956 header.typeflag = SYMTYPE;
957 link_size = readlink(fileName, buffer, sizeof(buffer) - 1); 957 link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
958 if ( link_size < 0) { 958 if ( link_size < 0) {
959 errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); 959 error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
960 return ( FALSE); 960 return ( FALSE);
961 } 961 }
962 buffer[link_size] = '\0'; 962 buffer[link_size] = '\0';
@@ -978,7 +978,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
978 header.typeflag = REGTYPE; 978 header.typeflag = REGTYPE;
979 putOctal(header.size, sizeof(header.size), statbuf->st_size); 979 putOctal(header.size, sizeof(header.size), statbuf->st_size);
980 } else { 980 } else {
981 errorMsg("%s: Unknown file type\n", fileName); 981 error_msg("%s: Unknown file type\n", fileName);
982 return ( FALSE); 982 return ( FALSE);
983 } 983 }
984 984
@@ -994,8 +994,8 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
994 putOctal(header.chksum, 7, chksum); 994 putOctal(header.chksum, 7, chksum);
995 995
996 /* Now write the header out to disk */ 996 /* Now write the header out to disk */
997 if ((size=fullWrite(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) { 997 if ((size=full_write(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
998 errorMsg(io_error, fileName, strerror(errno)); 998 error_msg(io_error, fileName, strerror(errno));
999 return ( FALSE); 999 return ( FALSE);
1000 } 1000 }
1001 /* Pad the header up to the tar block size */ 1001 /* Pad the header up to the tar block size */
@@ -1036,7 +1036,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
1036 1036
1037 /* It is against the rules to archive a socket */ 1037 /* It is against the rules to archive a socket */
1038 if (S_ISSOCK(statbuf->st_mode)) { 1038 if (S_ISSOCK(statbuf->st_mode)) {
1039 errorMsg("%s: socket ignored\n", fileName); 1039 error_msg("%s: socket ignored\n", fileName);
1040 return( TRUE); 1040 return( TRUE);
1041 } 1041 }
1042 1042
@@ -1045,12 +1045,12 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
1045 * the new tarball */ 1045 * the new tarball */
1046 if (tbInfo->statBuf.st_dev == statbuf->st_dev && 1046 if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
1047 tbInfo->statBuf.st_ino == statbuf->st_ino) { 1047 tbInfo->statBuf.st_ino == statbuf->st_ino) {
1048 errorMsg("%s: file is the archive; skipping\n", fileName); 1048 error_msg("%s: file is the archive; skipping\n", fileName);
1049 return( TRUE); 1049 return( TRUE);
1050 } 1050 }
1051 1051
1052 if (strlen(fileName) >= NAME_SIZE) { 1052 if (strlen(fileName) >= NAME_SIZE) {
1053 errorMsg(name_longer_than_foo, NAME_SIZE); 1053 error_msg(name_longer_than_foo, NAME_SIZE);
1054 return ( TRUE); 1054 return ( TRUE);
1055 } 1055 }
1056 1056
@@ -1067,21 +1067,21 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
1067 1067
1068 /* open the file we want to archive, and make sure all is well */ 1068 /* open the file we want to archive, and make sure all is well */
1069 if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { 1069 if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
1070 errorMsg("%s: Cannot open: %s\n", fileName, strerror(errno)); 1070 error_msg("%s: Cannot open: %s\n", fileName, strerror(errno));
1071 return( FALSE); 1071 return( FALSE);
1072 } 1072 }
1073 1073
1074 /* write the file to the archive */ 1074 /* write the file to the archive */
1075 while ( (size = fullRead(inputFileFd, buffer, sizeof(buffer))) > 0 ) { 1075 while ( (size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
1076 if (fullWrite(tbInfo->tarFd, buffer, size) != size ) { 1076 if (full_write(tbInfo->tarFd, buffer, size) != size ) {
1077 /* Output file seems to have a problem */ 1077 /* Output file seems to have a problem */
1078 errorMsg(io_error, fileName, strerror(errno)); 1078 error_msg(io_error, fileName, strerror(errno));
1079 return( FALSE); 1079 return( FALSE);
1080 } 1080 }
1081 readSize+=size; 1081 readSize+=size;
1082 } 1082 }
1083 if (size == -1) { 1083 if (size == -1) {
1084 errorMsg(io_error, fileName, strerror(errno)); 1084 error_msg(io_error, fileName, strerror(errno));
1085 return( FALSE); 1085 return( FALSE);
1086 } 1086 }
1087 /* Pad the file up to the tar block size */ 1087 /* Pad the file up to the tar block size */
@@ -1106,7 +1106,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
1106 1106
1107 /* Make sure there is at least one file to tar up. */ 1107 /* Make sure there is at least one file to tar up. */
1108 if (*argv == NULL) 1108 if (*argv == NULL)
1109 fatalError("Cowardly refusing to create an empty archive\n"); 1109 error_msg_and_die("Cowardly refusing to create an empty archive\n");
1110 1110
1111 /* Open the tar file for writing. */ 1111 /* Open the tar file for writing. */
1112 if (!strcmp(tarName, "-")) 1112 if (!strcmp(tarName, "-"))
@@ -1114,7 +1114,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
1114 else 1114 else
1115 tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); 1115 tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
1116 if (tbInfo.tarFd < 0) { 1116 if (tbInfo.tarFd < 0) {
1117 errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno)); 1117 error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
1118 freeHardLinkInfo(&tbInfo.hlInfoHead); 1118 freeHardLinkInfo(&tbInfo.hlInfoHead);
1119 return ( FALSE); 1119 return ( FALSE);
1120 } 1120 }
@@ -1122,7 +1122,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
1122 /* Store the stat info for the tarball's file, so 1122 /* Store the stat info for the tarball's file, so
1123 * can avoid including the tarball into itself.... */ 1123 * can avoid including the tarball into itself.... */
1124 if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0) 1124 if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
1125 fatalError(io_error, tarName, strerror(errno)); 1125 error_msg_and_die(io_error, tarName, strerror(errno));
1126 1126
1127 /* Set the umask for this process so it doesn't 1127 /* Set the umask for this process so it doesn't
1128 * screw up permission setting for us later. */ 1128 * screw up permission setting for us later. */
@@ -1130,7 +1130,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
1130 1130
1131 /* Read the directory/files and iterate over them one at a time */ 1131 /* Read the directory/files and iterate over them one at a time */
1132 while (*argv != NULL) { 1132 while (*argv != NULL) {
1133 if (recursiveAction(*argv++, TRUE, FALSE, FALSE, 1133 if (recursive_action(*argv++, TRUE, FALSE, FALSE,
1134 writeFileToTarball, writeFileToTarball, 1134 writeFileToTarball, writeFileToTarball,
1135 (void*) &tbInfo) == FALSE) { 1135 (void*) &tbInfo) == FALSE) {
1136 errorFlag = TRUE; 1136 errorFlag = TRUE;
@@ -1149,7 +1149,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
1149 /* Hang up the tools, close up shop, head home */ 1149 /* Hang up the tools, close up shop, head home */
1150 close(tarFd); 1150 close(tarFd);
1151 if (errorFlag == TRUE) { 1151 if (errorFlag == TRUE) {
1152 errorMsg("Error exit delayed from previous errors\n"); 1152 error_msg("Error exit delayed from previous errors\n");
1153 freeHardLinkInfo(&tbInfo.hlInfoHead); 1153 freeHardLinkInfo(&tbInfo.hlInfoHead);
1154 return(FALSE); 1154 return(FALSE);
1155 } 1155 }