diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 1999-10-06 20:25:32 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 1999-10-06 20:25:32 +0000 |
commit | 45a5bf7181676899fe5d65378ff9d3afa27926c1 (patch) | |
tree | 64e24302dc2575867d8a78897500e5a5b2a48398 /archival | |
parent | f8d0f3d467b901565d22400f547af32b099d9db4 (diff) | |
download | busybox-w32-45a5bf7181676899fe5d65378ff9d3afa27926c1.tar.gz busybox-w32-45a5bf7181676899fe5d65378ff9d3afa27926c1.tar.bz2 busybox-w32-45a5bf7181676899fe5d65378ff9d3afa27926c1.zip |
More stuff.
git-svn-id: svn://busybox.net/trunk/busybox@13 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'archival')
-rw-r--r-- | archival/gzip.c | 18 | ||||
-rw-r--r-- | archival/tar.c | 167 |
2 files changed, 10 insertions, 175 deletions
diff --git a/archival/gzip.c b/archival/gzip.c index 6fd2e3971..4b1d32ddd 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -380,7 +380,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */ | |||
380 | # undef LZW | 380 | # undef LZW |
381 | #endif | 381 | #endif |
382 | 382 | ||
383 | /* $Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $ */ | 383 | /* $Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $ */ |
384 | /* tailor.h -- target dependent definitions | 384 | /* tailor.h -- target dependent definitions |
385 | * Copyright (C) 1992-1993 Jean-loup Gailly. | 385 | * Copyright (C) 1992-1993 Jean-loup Gailly. |
386 | * This is free software; you can redistribute it and/or modify it under the | 386 | * This is free software; you can redistribute it and/or modify it under the |
@@ -391,7 +391,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */ | |||
391 | * The target dependent functions should be defined in tailor.c. | 391 | * The target dependent functions should be defined in tailor.c. |
392 | */ | 392 | */ |
393 | 393 | ||
394 | /* $Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $ */ | 394 | /* $Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $ */ |
395 | 395 | ||
396 | #if defined(__MSDOS__) && !defined(MSDOS) | 396 | #if defined(__MSDOS__) && !defined(MSDOS) |
397 | # define MSDOS | 397 | # define MSDOS |
@@ -767,7 +767,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */ | |||
767 | #endif | 767 | #endif |
768 | 768 | ||
769 | #ifdef RCSID | 769 | #ifdef RCSID |
770 | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; | 770 | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
771 | #endif | 771 | #endif |
772 | 772 | ||
773 | /* =========================================================================== | 773 | /* =========================================================================== |
@@ -976,7 +976,7 @@ void copy_block(buf, len, header) | |||
976 | #include <stdio.h> | 976 | #include <stdio.h> |
977 | 977 | ||
978 | #ifdef RCSID | 978 | #ifdef RCSID |
979 | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; | 979 | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
980 | #endif | 980 | #endif |
981 | 981 | ||
982 | /* =========================================================================== | 982 | /* =========================================================================== |
@@ -1592,7 +1592,7 @@ ulg deflate() | |||
1592 | */ | 1592 | */ |
1593 | 1593 | ||
1594 | #ifdef RCSID | 1594 | #ifdef RCSID |
1595 | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; | 1595 | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
1596 | #endif | 1596 | #endif |
1597 | 1597 | ||
1598 | #include <ctype.h> | 1598 | #include <ctype.h> |
@@ -1781,7 +1781,7 @@ static int (*work) OF((int infile, int outfile)) = zip; /* function to call */ | |||
1781 | // int main (argc, argv) | 1781 | // int main (argc, argv) |
1782 | // int argc; | 1782 | // int argc; |
1783 | // char **argv; | 1783 | // char **argv; |
1784 | int gzip_main(struct FileInfo * i, int argc, char * * argv) | 1784 | int gzip_main(int argc, char * * argv) |
1785 | { | 1785 | { |
1786 | foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; | 1786 | foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; |
1787 | if (foreground) { | 1787 | if (foreground) { |
@@ -1925,7 +1925,7 @@ local void do_exit(int exitcode) | |||
1925 | #include <ctype.h> | 1925 | #include <ctype.h> |
1926 | 1926 | ||
1927 | #ifdef RCSID | 1927 | #ifdef RCSID |
1928 | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; | 1928 | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
1929 | #endif | 1929 | #endif |
1930 | 1930 | ||
1931 | /* =========================================================================== | 1931 | /* =========================================================================== |
@@ -2943,7 +2943,7 @@ local void set_file_type() | |||
2943 | */ | 2943 | */ |
2944 | 2944 | ||
2945 | #ifdef RCSID | 2945 | #ifdef RCSID |
2946 | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; | 2946 | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
2947 | #endif | 2947 | #endif |
2948 | 2948 | ||
2949 | #include <ctype.h> | 2949 | #include <ctype.h> |
@@ -3142,7 +3142,7 @@ void display_ratio(num, den, file) | |||
3142 | */ | 3142 | */ |
3143 | 3143 | ||
3144 | #ifdef RCSID | 3144 | #ifdef RCSID |
3145 | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; | 3145 | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
3146 | #endif | 3146 | #endif |
3147 | 3147 | ||
3148 | #include <ctype.h> | 3148 | #include <ctype.h> |
diff --git a/archival/tar.c b/archival/tar.c index 03da96735..498d4a300 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -131,14 +131,10 @@ static void writeHeader(const char * fileName, | |||
131 | static void writeTarFile(int fileCount, char ** fileTable); | 131 | static void writeTarFile(int fileCount, char ** fileTable); |
132 | static void writeTarBlock(const char * buf, int len); | 132 | static void writeTarBlock(const char * buf, int len); |
133 | static BOOL putOctal(char * cp, int len, long value); | 133 | static BOOL putOctal(char * cp, int len, long value); |
134 | extern const char * modeString(int mode); | ||
135 | extern const char * timeString(time_t timeVal); | ||
136 | extern int fullWrite(int fd, const char * buf, int len); | ||
137 | extern int fullRead(int fd, char * buf, int len); | ||
138 | 134 | ||
139 | 135 | ||
140 | extern int | 136 | extern int |
141 | tar_main(struct FileInfo *unused, int argc, char ** argv) | 137 | tar_main(int argc, char ** argv) |
142 | { | 138 | { |
143 | const char * options; | 139 | const char * options; |
144 | 140 | ||
@@ -1258,167 +1254,6 @@ wantFileName(const char * fileName, int fileCount, char ** fileTable) | |||
1258 | 1254 | ||
1259 | 1255 | ||
1260 | 1256 | ||
1261 | /* | ||
1262 | * Return the standard ls-like mode string from a file mode. | ||
1263 | * This is static and so is overwritten on each call. | ||
1264 | */ | ||
1265 | const char * | ||
1266 | modeString(int mode) | ||
1267 | { | ||
1268 | static char buf[12]; | ||
1269 | |||
1270 | strcpy(buf, "----------"); | ||
1271 | |||
1272 | /* | ||
1273 | * Fill in the file type. | ||
1274 | */ | ||
1275 | if (S_ISDIR(mode)) | ||
1276 | buf[0] = 'd'; | ||
1277 | if (S_ISCHR(mode)) | ||
1278 | buf[0] = 'c'; | ||
1279 | if (S_ISBLK(mode)) | ||
1280 | buf[0] = 'b'; | ||
1281 | if (S_ISFIFO(mode)) | ||
1282 | buf[0] = 'p'; | ||
1283 | #ifdef S_ISLNK | ||
1284 | if (S_ISLNK(mode)) | ||
1285 | buf[0] = 'l'; | ||
1286 | #endif | ||
1287 | #ifdef S_ISSOCK | ||
1288 | if (S_ISSOCK(mode)) | ||
1289 | buf[0] = 's'; | ||
1290 | #endif | ||
1291 | |||
1292 | /* | ||
1293 | * Now fill in the normal file permissions. | ||
1294 | */ | ||
1295 | if (mode & S_IRUSR) | ||
1296 | buf[1] = 'r'; | ||
1297 | if (mode & S_IWUSR) | ||
1298 | buf[2] = 'w'; | ||
1299 | if (mode & S_IXUSR) | ||
1300 | buf[3] = 'x'; | ||
1301 | if (mode & S_IRGRP) | ||
1302 | buf[4] = 'r'; | ||
1303 | if (mode & S_IWGRP) | ||
1304 | buf[5] = 'w'; | ||
1305 | if (mode & S_IXGRP) | ||
1306 | buf[6] = 'x'; | ||
1307 | if (mode & S_IROTH) | ||
1308 | buf[7] = 'r'; | ||
1309 | if (mode & S_IWOTH) | ||
1310 | buf[8] = 'w'; | ||
1311 | if (mode & S_IXOTH) | ||
1312 | buf[9] = 'x'; | ||
1313 | |||
1314 | /* | ||
1315 | * Finally fill in magic stuff like suid and sticky text. | ||
1316 | */ | ||
1317 | if (mode & S_ISUID) | ||
1318 | buf[3] = ((mode & S_IXUSR) ? 's' : 'S'); | ||
1319 | if (mode & S_ISGID) | ||
1320 | buf[6] = ((mode & S_IXGRP) ? 's' : 'S'); | ||
1321 | if (mode & S_ISVTX) | ||
1322 | buf[9] = ((mode & S_IXOTH) ? 't' : 'T'); | ||
1323 | |||
1324 | return buf; | ||
1325 | } | ||
1326 | |||
1327 | |||
1328 | /* | ||
1329 | * Get the time string to be used for a file. | ||
1330 | * This is down to the minute for new files, but only the date for old files. | ||
1331 | * The string is returned from a static buffer, and so is overwritten for | ||
1332 | * each call. | ||
1333 | */ | ||
1334 | const char * | ||
1335 | timeString(time_t timeVal) | ||
1336 | { | ||
1337 | time_t now; | ||
1338 | char * str; | ||
1339 | static char buf[26]; | ||
1340 | |||
1341 | time(&now); | ||
1342 | |||
1343 | str = ctime(&timeVal); | ||
1344 | |||
1345 | strcpy(buf, &str[4]); | ||
1346 | buf[12] = '\0'; | ||
1347 | |||
1348 | if ((timeVal > now) || (timeVal < now - 365*24*60*60L)) | ||
1349 | { | ||
1350 | strcpy(&buf[7], &str[20]); | ||
1351 | buf[11] = '\0'; | ||
1352 | } | ||
1353 | |||
1354 | return buf; | ||
1355 | } | ||
1356 | |||
1357 | |||
1358 | |||
1359 | /* | ||
1360 | * Write all of the supplied buffer out to a file. | ||
1361 | * This does multiple writes as necessary. | ||
1362 | * Returns the amount written, or -1 on an error. | ||
1363 | */ | ||
1364 | int | ||
1365 | fullWrite(int fd, const char * buf, int len) | ||
1366 | { | ||
1367 | int cc; | ||
1368 | int total; | ||
1369 | |||
1370 | total = 0; | ||
1371 | |||
1372 | while (len > 0) | ||
1373 | { | ||
1374 | cc = write(fd, buf, len); | ||
1375 | |||
1376 | if (cc < 0) | ||
1377 | return -1; | ||
1378 | |||
1379 | buf += cc; | ||
1380 | total+= cc; | ||
1381 | len -= cc; | ||
1382 | } | ||
1383 | |||
1384 | return total; | ||
1385 | } | ||
1386 | |||
1387 | |||
1388 | /* | ||
1389 | * Read all of the supplied buffer from a file. | ||
1390 | * This does multiple reads as necessary. | ||
1391 | * Returns the amount read, or -1 on an error. | ||
1392 | * A short read is returned on an end of file. | ||
1393 | */ | ||
1394 | int | ||
1395 | fullRead(int fd, char * buf, int len) | ||
1396 | { | ||
1397 | int cc; | ||
1398 | int total; | ||
1399 | |||
1400 | total = 0; | ||
1401 | |||
1402 | while (len > 0) | ||
1403 | { | ||
1404 | cc = read(fd, buf, len); | ||
1405 | |||
1406 | if (cc < 0) | ||
1407 | return -1; | ||
1408 | |||
1409 | if (cc == 0) | ||
1410 | break; | ||
1411 | |||
1412 | buf += cc; | ||
1413 | total+= cc; | ||
1414 | len -= cc; | ||
1415 | } | ||
1416 | |||
1417 | return total; | ||
1418 | } | ||
1419 | |||
1420 | |||
1421 | |||
1422 | #endif | 1257 | #endif |
1423 | /* END CODE */ | 1258 | /* END CODE */ |
1424 | 1259 | ||