libtar: use libtar tag in logging
Change-Id: I292366a237f9c8464f791d4d3cddaffc0d854577
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
(cherry picked from commit 566ef6bcaab4b038956ccff73876876aedda65eb)
diff --git a/libtar/android_utils.c b/libtar/android_utils.c
index 4aa3425..b854604 100644
--- a/libtar/android_utils.c
+++ b/libtar/android_utils.c
@@ -78,7 +78,7 @@
struct stat buf;
memset(&buf, 0, sizeof(buf));
if (stat(path, &buf) != 0) {
- printf("failed to stat %s\n", path);
+ LOG("failed to stat %s\n", path);
return -1;
}
*inode = buf.st_ino;
@@ -97,7 +97,7 @@
snprintf(path, PATH_MAX, "%s/%s", parent, name);
if (mkdirhier(path) == -1) {
- printf("failed to mkdirhier for %s\n", path);
+ LOG("failed to mkdirhier for %s\n", path);
return -1;
}
@@ -114,9 +114,9 @@
}
inode_raw = inode;
- printf("setting %s on %s pointing to %s\n", inode_xattr, parent, path);
+ LOG("setting %s on %s pointing to %s\n", inode_xattr, parent, path);
if (setxattr(parent, inode_xattr, &inode_raw, sizeof(inode_raw), 0) != 0 && errno != EOPNOTSUPP) {
- printf("Failed to write xattr %s at %s (%s)\n", inode_xattr, parent, strerror(errno));
+ LOG("Failed to write xattr %s at %s (%s)\n", inode_xattr, parent, strerror(errno));
return -1;
}
return 0;
diff --git a/libtar/append.c b/libtar/append.c
index 7557158..8c70aa1 100755
--- a/libtar/append.c
+++ b/libtar/append.c
@@ -84,7 +84,7 @@
char path[MAXPATHLEN];
#ifdef DEBUG
- printf("==> tar_append_file(TAR=0x%p (\"%s\"), realname=\"%s\", "
+ LOG("==> tar_append_file(TAR=0x%p (\"%s\"), realname=\"%s\", "
"savename=\"%s\")\n", (void*) t, t->pathname, realname,
(savename ? savename : "[NULL]"));
#endif
@@ -99,14 +99,14 @@
/* set header block */
#ifdef DEBUG
- puts("tar_append_file(): setting header block...");
+ LOG("tar_append_file(): setting header block...");
#endif
memset(&(t->th_buf), 0, sizeof(struct tar_header));
th_set_from_stat(t, &s);
/* set the header path */
#ifdef DEBUG
- puts("tar_append_file(): setting header path...");
+ LOG("tar_append_file(): setting header path...");
#endif
th_set_path(t, (savename ? savename : realname));
@@ -123,7 +123,7 @@
if (lgetfilecon(realname, &selinux_context) >= 0)
{
t->th_buf.selinux_context = strdup(selinux_context);
- printf(" ==> set selinux context: %s\n", selinux_context);
+ LOG(" ==> set selinux context: %s\n", selinux_context);
freecon(selinux_context);
}
else
@@ -148,7 +148,7 @@
t->th_buf.fep = (struct fscrypt_policy_v2 *)malloc(sizeof(struct fscrypt_policy_v2));
#endif
if (!t->th_buf.fep) {
- printf("malloc fs_encryption_policy\n");
+ LOG("malloc fs_encryption_policy\n");
return -1;
}
@@ -172,18 +172,18 @@
|| strncmp((char *) tar_policy, SYSTEM_DE_FSCRYPT_POLICY, sizeof(SYSTEM_DE_FSCRYPT_POLICY)) == 0) {
#ifdef USE_FSCRYPT_POLICY_V1
memcpy(t->th_buf.fep->master_key_descriptor, tar_policy, FS_KEY_DESCRIPTOR_SIZE);
- printf("found fscrypt policy '%s' - '%s' - '%s'\n", realname, t->th_buf.fep->master_key_descriptor, policy_hex);
+ LOG("found fscrypt policy '%s' - '%s' - '%s'\n", realname, t->th_buf.fep->master_key_descriptor, policy_hex);
#else
memcpy(t->th_buf.fep->master_key_identifier, tar_policy, FSCRYPT_KEY_IDENTIFIER_SIZE);
- printf("found fscrypt policy '%s' - '%s' - '%s'\n", realname, t->th_buf.fep->master_key_identifier, policy_hex);
+ LOG("found fscrypt policy '%s' - '%s' - '%s'\n", realname, t->th_buf.fep->master_key_identifier, policy_hex);
#endif
} else {
- printf("failed to match fscrypt tar policy for '%s' - '%s'\n", realname, policy_hex);
+ LOG("failed to match fscrypt tar policy for '%s' - '%s'\n", realname, policy_hex);
free(t->th_buf.fep);
t->th_buf.fep = NULL;
}
} else {
- printf("failed to lookup fscrypt tar policy for '%s' - '%s'\n", realname, policy_hex);
+ LOG("failed to lookup fscrypt tar policy for '%s' - '%s'\n", realname, policy_hex);
free(t->th_buf.fep);
t->th_buf.fep = NULL;
}
@@ -221,28 +221,28 @@
{
t->th_buf.has_user_default = 1;
#if 1 //def DEBUG
- printf("storing xattr user.default\n");
+ LOG("storing xattr user.default\n");
#endif
}
if (getxattr(realname, "user.inode_cache", NULL, 0) >= 0)
{
t->th_buf.has_user_cache = 1;
#if 1 //def DEBUG
- printf("storing xattr user.inode_cache\n");
+ LOG("storing xattr user.inode_cache\n");
#endif
}
if (getxattr(realname, "user.inode_code_cache", NULL, 0) >= 0)
{
t->th_buf.has_user_code_cache = 1;
#if 1 //def DEBUG
- printf("storing xattr user.inode_code_cache\n");
+ LOG("storing xattr user.inode_code_cache\n");
#endif
}
}
/* check if it's a hardlink */
#ifdef DEBUG
- puts("tar_append_file(): checking inode cache for hardlink...");
+ LOG("tar_append_file(): checking inode cache for hardlink...");
#endif
libtar_hashptr_reset(&hp);
if (libtar_hash_getkey(t->h, &hp, &(s.st_dev),
@@ -251,7 +251,7 @@
else
{
#ifdef DEBUG
- printf("+++ adding hash for device (0x%x, 0x%x)...\n",
+ LOG("+++ adding hash for device (0x%x, 0x%x)...\n",
major(s.st_dev), minor(s.st_dev));
#endif
td = (tar_dev_t *)calloc(1, sizeof(tar_dev_t));
@@ -268,7 +268,7 @@
{
ti = (tar_ino_t *)libtar_hashptr_data(&hp);
#ifdef DEBUG
- printf(" tar_append_file(): encoding hard link \"%s\" "
+ LOG(" tar_append_file(): encoding hard link \"%s\" "
"to \"%s\"...\n", realname, ti->ti_name);
#endif
t->th_buf.typeflag = LNKTYPE;
@@ -277,7 +277,7 @@
else
{
#ifdef DEBUG
- printf("+++ adding entry: device (0x%d,0x%x), inode %lu"
+ LOG("+++ adding entry: device (0x%d,0x%x), inode %lu"
"(\"%s\")...\n", major(s.st_dev), minor(s.st_dev),
(unsigned long) s.st_ino, realname);
#endif
@@ -300,7 +300,7 @@
i = MAXPATHLEN - 1;
path[i] = '\0';
#ifdef DEBUG
- printf("tar_append_file(): encoding symlink \"%s\" -> "
+ LOG("tar_append_file(): encoding symlink \"%s\" -> "
"\"%s\"...\n", realname, path);
#endif
th_set_link(t, path);
@@ -308,21 +308,21 @@
/* print file info */
if (t->options & TAR_VERBOSE)
- printf("%s\n", th_get_pathname(t));
+ LOG("%s\n", th_get_pathname(t));
#ifdef DEBUG
- puts("tar_append_file(): writing header");
+ LOG("tar_append_file(): writing header");
#endif
/* write header */
if (th_write(t) != 0)
{
#ifdef DEBUG
- printf("t->fd = %ld\n", t->fd);
+ LOG("t->fd = %ld\n", t->fd);
#endif
return -1;
}
#ifdef DEBUG
- puts("tar_append_file(): back from th_write()");
+ LOG("tar_append_file(): back from th_write()");
#endif
/* if it's a regular file, write the contents as well */
diff --git a/libtar/block.c b/libtar/block.c
index b46d55a..91342c2 100755
--- a/libtar/block.c
+++ b/libtar/block.c
@@ -72,7 +72,7 @@
int num_zero_blocks = 0;
#ifdef DEBUG
- printf("==> th_read_internal(TAR=\"%s\")\n", t->pathname);
+ LOG("==> th_read_internal(TAR=\"%s\")\n", t->pathname);
#endif
while ((i = tar_block_read(t, &(t->th_buf))) == T_BLOCKSIZE)
@@ -93,7 +93,7 @@
&& strncmp(t->th_buf.magic, TMAGIC, TMAGLEN - 1) != 0)
{
#ifdef DEBUG
- puts("!!! unknown magic value in tar header");
+ LOG("!!! unknown magic value in tar header");
#endif
return -2;
}
@@ -102,7 +102,7 @@
&& strncmp(t->th_buf.version, TVERSION, TVERSLEN) != 0)
{
#ifdef DEBUG
- puts("!!! unknown version value in tar header");
+ LOG("!!! unknown version value in tar header");
#endif
return -2;
}
@@ -112,7 +112,7 @@
&& !th_crc_ok(t))
{
#ifdef DEBUG
- puts("!!! tar header checksum error");
+ LOG("!!! tar header checksum error");
#endif
return -2;
}
@@ -121,7 +121,7 @@
}
#ifdef DEBUG
- printf("<== th_read_internal(): returning %d\n", i);
+ LOG("<== th_read_internal(): returning %d\n", i);
#endif
return i;
}
@@ -136,7 +136,7 @@
char *ptr;
#ifdef DEBUG
- printf("==> th_read(t=0x%p)\n", (void *)t);
+ LOG("==> th_read(t=0x%p)\n", (void *)t);
#endif
if (t->th_buf.gnu_longname != NULL)
@@ -183,7 +183,7 @@
return -1;
}
#ifdef DEBUG
- printf(" th_read(): GNU long linkname detected "
+ LOG(" th_read(): GNU long linkname detected "
"(%zu bytes, %zu blocks)\n", sz, blocks);
#endif
t->th_buf.gnu_longlink = (char *)malloc(blocks * T_BLOCKSIZE);
@@ -194,7 +194,7 @@
j++, ptr += T_BLOCKSIZE)
{
#ifdef DEBUG
- printf(" th_read(): reading long linkname "
+ LOG(" th_read(): reading long linkname "
"(%zu blocks left, ptr == %p)\n", blocks-j, (void *) ptr);
#endif
i = tar_block_read(t, ptr);
@@ -205,11 +205,11 @@
return -1;
}
#ifdef DEBUG
- printf(" th_read(): read block == \"%s\"\n", ptr);
+ LOG(" th_read(): read block == \"%s\"\n", ptr);
#endif
}
#ifdef DEBUG
- printf(" th_read(): t->th_buf.gnu_longlink == \"%s\"\n",
+ LOG(" th_read(): t->th_buf.gnu_longlink == \"%s\"\n",
t->th_buf.gnu_longlink);
#endif
@@ -233,7 +233,7 @@
return -1;
}
#ifdef DEBUG
- printf(" th_read(): GNU long filename detected "
+ LOG(" th_read(): GNU long filename detected "
"(%zu bytes, %zu blocks)\n", sz, blocks);
#endif
t->th_buf.gnu_longname = (char *)malloc(blocks * T_BLOCKSIZE);
@@ -244,7 +244,7 @@
j++, ptr += T_BLOCKSIZE)
{
#ifdef DEBUG
- printf(" th_read(): reading long filename "
+ LOG(" th_read(): reading long filename "
"(%zu blocks left, ptr == %p)\n", blocks-j, (void *) ptr);
#endif
i = tar_block_read(t, ptr);
@@ -255,11 +255,11 @@
return -1;
}
#ifdef DEBUG
- printf(" th_read(): read block == \"%s\"\n", ptr);
+ LOG(" th_read(): read block == \"%s\"\n", ptr);
#endif
}
#ifdef DEBUG
- printf(" th_read(): t->th_buf.gnu_longname == \"%s\"\n",
+ LOG(" th_read(): t->th_buf.gnu_longname == \"%s\"\n",
t->th_buf.gnu_longname);
#endif
@@ -280,7 +280,7 @@
if(sz >= T_BLOCKSIZE) // Not supported
{
#ifdef DEBUG
- printf(" th_read(): Extended header is too long!\n");
+ LOG(" th_read(): Extended header is too long!\n");
#endif
}
else
@@ -306,7 +306,7 @@
memcpy(&t->th_buf.cap_data, start, sizeof(struct vfs_cap_data));
t->th_buf.has_cap_data = 1;
#ifdef DEBUG
- printf(" th_read(): Posix capabilities detected\n");
+ LOG(" th_read(): Posix capabilities detected\n");
#endif
} // end posix capabilities
// selinux contexts
@@ -319,7 +319,7 @@
{
t->th_buf.selinux_context = strndup(start, end-start);
#ifdef DEBUG
- printf(" th_read(): SELinux context xattr detected: %s\n", t->th_buf.selinux_context);
+ LOG(" th_read(): SELinux context xattr detected: %s\n", t->th_buf.selinux_context);
#endif
}
} // end selinux contexts
@@ -329,7 +329,7 @@
{
t->th_buf.has_user_default = 1;
#ifdef DEBUG
- printf(" th_read(): android user.default xattr detected\n");
+ LOG(" th_read(): android user.default xattr detected\n");
#endif
} // end android user.default xattr
// android user.inode_cache xattr
@@ -338,7 +338,7 @@
{
t->th_buf.has_user_cache = 1;
#ifdef DEBUG
- printf(" th_read(): android user.inode_cache xattr detected\n");
+ LOG(" th_read(): android user.inode_cache xattr detected\n");
#endif
} // end android user.inode_cache xattr
// android user.inode_code_cache xattr
@@ -347,7 +347,7 @@
{
t->th_buf.has_user_code_cache = 1;
#ifdef DEBUG
- printf(" th_read(): android user.inode_code_cache xattr detected\n");
+ LOG(" th_read(): android user.inode_code_cache xattr detected\n");
#endif
} // end android user.inode_code_cache xattr
@@ -360,7 +360,7 @@
t->th_buf.fep = (struct fscrypt_policy_v2*)malloc(sizeof(struct fscrypt_policy_v2));
#endif
if (!t->th_buf.fep) {
- printf("malloc failed for fscrypt policy\n");
+ LOG("malloc failed for fscrypt policy\n");
return -1;
}
start += FSCRYPT_TAG_LEN;
@@ -372,14 +372,14 @@
char *newline_check = start + sizeof(struct fscrypt_policy_v2);
#endif
if (*newline_check != '\n')
- printf("did not find newline char in expected location, continuing anyway...\n");
+ LOG("did not find newline char in expected location, continuing anyway...\n");
#ifdef USE_FSCRYPT_POLICY_V1
memcpy(t->th_buf.fep, start, sizeof(struct fscrypt_policy_v1));
#else
memcpy(t->th_buf.fep, start, sizeof(struct fscrypt_policy_v2));
#endif
#ifdef DEBUG
- printf(" th_read(): FSCrypt policy detected: %i %i %i %i %s\n",
+ LOG(" th_read(): FSCrypt policy detected: %i %i %i %i %s\n",
(int)t->th_buf.fep->version,
(int)t->th_buf.fep->contents_encryption_mode,
(int)t->th_buf.fep->filenames_encryption_mode,
@@ -392,7 +392,7 @@
#endif
}
else {
- printf(" invalid fscrypt header found\n");
+ LOG(" invalid fscrypt header found\n");
}
}
#endif // USE_FSCRYPT
@@ -467,14 +467,14 @@
char buf[T_BLOCKSIZE];
#ifdef DEBUG
- printf("==> th_write(TAR=\"%s\")\n", t->pathname);
+ LOG("==> th_write(TAR=\"%s\")\n", t->pathname);
th_print(t);
#endif
if ((t->options & TAR_GNU) && t->th_buf.gnu_longlink != NULL)
{
#ifdef DEBUG
- printf("th_write(): using gnu_longlink (\"%s\")\n",
+ LOG("th_write(): using gnu_longlink (\"%s\")\n",
t->th_buf.gnu_longlink);
#endif
/* save old size and type */
@@ -525,7 +525,7 @@
if ((t->options & TAR_GNU) && t->th_buf.gnu_longname != NULL)
{
#ifdef DEBUG
- printf("th_write(): using gnu_longname (\"%s\")\n",
+ LOG("th_write(): using gnu_longname (\"%s\")\n",
t->th_buf.gnu_longname);
#endif
/* save old size and type */
@@ -579,7 +579,7 @@
if((t->options & TAR_STORE_SELINUX) && t->th_buf.selinux_context != NULL)
{
#ifdef DEBUG
- printf("th_write(): using selinux_context (\"%s\")\n",
+ LOG("th_write(): using selinux_context (\"%s\")\n",
t->th_buf.selinux_context);
#endif
/* setup size - EXT header has format "*size of this whole tag as ascii numbers* *space* *content* *newline* */
@@ -599,10 +599,10 @@
{
#ifdef DEBUG
#ifdef USE_FSCRYPT_POLICY_V1
- printf("th_write(): using fscrypt_policy %s\n",
+ LOG("th_write(): using fscrypt_policy %s\n",
t->th_buf.fep->master_key_descriptor);
#else
- printf("th_write(): using fscrypt_policy %s\n",
+ LOG("th_write(): using fscrypt_policy %s\n",
t->th_buf.fep->master_key_identifier);
#endif
#endif
@@ -642,7 +642,7 @@
if((t->options & TAR_STORE_POSIX_CAP) && t->th_buf.has_cap_data)
{
#ifdef DEBUG
- printf("th_write(): has a posix capability\n");
+ LOG("th_write(): has a posix capability\n");
#endif
sz = CAPABILITIES_TAG_LEN + sizeof(struct vfs_cap_data) + 3 + 1;
@@ -669,7 +669,7 @@
{
if (t->th_buf.has_user_default) {
#ifdef DEBUG
- printf("th_write(): has android user.default xattr\n");
+ LOG("th_write(): has android user.default xattr\n");
#endif
sz = ANDROID_USER_DEFAULT_TAG_LEN + 3 + 1;
@@ -690,7 +690,7 @@
}
if (t->th_buf.has_user_cache) {
#ifdef DEBUG
- printf("th_write(): has android user.inode_cache xattr\n");
+ LOG("th_write(): has android user.inode_cache xattr\n");
#endif
sz = ANDROID_USER_CACHE_TAG_LEN + 3 + 1;
@@ -711,7 +711,7 @@
}
if (t->th_buf.has_user_code_cache) {
#ifdef DEBUG
- printf("th_write(): has android user.inode_code_cache xattr\n");
+ LOG("th_write(): has android user.inode_code_cache xattr\n");
#endif
sz = ANDROID_USER_CODE_CACHE_TAG_LEN + 3 + 1;
@@ -750,7 +750,7 @@
}
#ifdef DEBUG
- puts("th_write(): returning 0");
+ LOG("th_write(): returning 0");
#endif
return 0;
}
diff --git a/libtar/encode.c b/libtar/encode.c
index 1e679d8..c64a71c 100644
--- a/libtar/encode.c
+++ b/libtar/encode.c
@@ -76,7 +76,7 @@
size_t pathname_len = strlen(pathname);
#ifdef DEBUG
- printf("in th_set_path(th, pathname=\"%s\")\n", pathname);
+ LOG("in th_set_path(th, pathname=\"%s\")\n", pathname);
#endif
if (t->th_buf.gnu_longname != NULL)
@@ -106,7 +106,7 @@
tmp = strchr(&(pathname[pathname_len - T_NAMELEN]), '/');
if (tmp == NULL)
{
- printf("!!! '/' not found in \"%s\"\n", pathname);
+ LOG("!!! '/' not found in \"%s\"\n", pathname);
return;
}
snprintf(tail_path, T_NAMELEN + 1, "%s%s", &tmp[1], suffix);
@@ -128,7 +128,7 @@
}
#ifdef DEBUG
- puts("returning from th_set_path()...");
+ LOG("returning from th_set_path()...");
#endif
}
@@ -138,7 +138,7 @@
th_set_link(TAR *t, const char *linkname)
{
#ifdef DEBUG
- printf("==> th_set_link(th, linkname=\"%s\")\n", linkname);
+ LOG("==> th_set_link(th, linkname=\"%s\")\n", linkname);
#endif
if (strlen(linkname) >= T_NAMELEN && (t->options & TAR_GNU))
@@ -169,7 +169,7 @@
th_set_device(TAR *t, dev_t device)
{
#ifdef DEBUG
- printf("th_set_device(): major = %d, minor = %d\n",
+ LOG("th_set_device(): major = %d, minor = %d\n",
major(device), minor(device));
#endif
int_to_oct(major(device), t->th_buf.devmajor, 8);
diff --git a/libtar/extract.c b/libtar/extract.c
index 08e2914..85e3e40 100755
--- a/libtar/extract.c
+++ b/libtar/extract.c
@@ -65,7 +65,7 @@
ut.modtime = ut.actime = th_get_mtime(t);
#ifdef DEBUG
- printf("tar_set_file_perms(): setting perms: %s (mode %04o, uid %d, gid %d)\n",
+ LOG("tar_set_file_perms(): setting perms: %s (mode %04o, uid %d, gid %d)\n",
filename, mode, uid, gid);
#endif
@@ -167,7 +167,7 @@
if((t->options & TAR_STORE_SELINUX) && t->th_buf.selinux_context != NULL)
{
#ifdef DEBUG
- printf("tar_extract_file(): restoring SELinux context %s to file %s\n", t->th_buf.selinux_context, realname);
+ LOG("tar_extract_file(): restoring SELinux context %s to file %s\n", t->th_buf.selinux_context, realname);
#endif
if (lsetfilecon(realname, t->th_buf.selinux_context) < 0)
fprintf(stderr, "tar_extract_file(): failed to restore SELinux context %s to file %s !!!\n", t->th_buf.selinux_context, realname);
@@ -176,7 +176,7 @@
if((t->options & TAR_STORE_POSIX_CAP) && t->th_buf.has_cap_data)
{
#if 1 //def DEBUG
- printf("tar_extract_file(): restoring posix capabilities to file %s\n", realname);
+ LOG("tar_extract_file(): restoring posix capabilities to file %s\n", realname);
print_caps(&t->th_buf.cap_data);
#endif
if (setxattr(realname, XATTR_NAME_CAPS, &t->th_buf.cap_data, sizeof(struct vfs_cap_data), 0) < 0)
@@ -193,7 +193,7 @@
strcpy(&lnp[0], pn);
strcpy(&lnp[pathname_len], realname);
#ifdef DEBUG
- printf("tar_extract_file(): calling libtar_hash_add(): key=\"%s\", "
+ LOG("tar_extract_file(): calling libtar_hash_add(): key=\"%s\", "
"value=\"%s\"\n", pn, realname);
#endif
if (libtar_hash_add(t->h, lnp) != 0)
@@ -217,7 +217,7 @@
char *pn;
#ifdef DEBUG
- printf(" ==> tar_extract_regfile(realname=\"%s\")\n", realname);
+ LOG(" ==> tar_extract_regfile(realname=\"%s\")\n", realname);
#endif
if (!TH_ISREG(t))
@@ -233,7 +233,7 @@
if (mkdirhier(dirname(filename)) == -1)
return -1;
- printf(" ==> extracting: %s (file size %" PRId64 " bytes)\n",
+ LOG(" ==> extracting: %s (file size %" PRId64 " bytes)\n",
filename, size);
fdout = open(filename, O_WRONLY | O_CREAT | O_TRUNC
@@ -280,7 +280,7 @@
return -1;
#ifdef DEBUG
- printf("### done extracting %s\n", filename);
+ LOG("### done extracting %s\n", filename);
#endif
return 0;
@@ -353,7 +353,7 @@
newtgt = strdup(linktgt);
sprintf(linktgt, "%s/%s", prefix, newtgt);
- printf(" ==> extracting: %s (link to %s)\n", filename, linktgt);
+ LOG(" ==> extracting: %s (link to %s)\n", filename, linktgt);
if (link(linktgt, filename) == -1)
{
@@ -386,7 +386,7 @@
if (unlink(filename) == -1 && errno != ENOENT)
return -1;
- printf(" ==> extracting: %s (symlink to %s)\n",
+ LOG(" ==> extracting: %s (symlink to %s)\n",
filename, th_get_linkname(t));
if (symlink(th_get_linkname(t), filename) == -1)
@@ -425,7 +425,7 @@
if (mkdirhier(dirname(filename)) == -1)
return -1;
- printf(" ==> extracting: %s (character device %ld,%ld)\n",
+ LOG(" ==> extracting: %s (character device %ld,%ld)\n",
filename, devmaj, devmin);
if (mknod(filename, mode | S_IFCHR,
@@ -463,7 +463,7 @@
if (mkdirhier(dirname(filename)) == -1)
return -1;
- printf(" ==> extracting: %s (block device %ld,%ld)\n",
+ LOG(" ==> extracting: %s (block device %ld,%ld)\n",
filename, devmaj, devmin);
if (mknod(filename, mode | S_IFBLK,
@@ -496,7 +496,7 @@
if (mkdirhier(dirname(filename)) == -1)
return -1;
- printf(" ==> extracting: %s (mode %04o, directory)\n", filename,
+ LOG(" ==> extracting: %s (mode %04o, directory)\n", filename,
mode);
if (mkdir(filename, mode) == -1)
@@ -531,7 +531,7 @@
{
if (t->th_buf.has_user_default) {
#if 1 //def DEBUG
- printf("tar_extract_file(): restoring android user.default xattr to %s\n", realname);
+ LOG("tar_extract_file(): restoring android user.default xattr to %s\n", realname);
#endif
if (setxattr(realname, "user.default", NULL, 0, 0) < 0) {
fprintf(stderr, "tar_extract_file(): failed to restore android user.default to file %s !!!\n", realname);
@@ -540,14 +540,14 @@
}
if (t->th_buf.has_user_cache) {
#if 1 //def DEBUG
- printf("tar_extract_file(): restoring android user.inode_cache xattr to %s\n", realname);
+ LOG("tar_extract_file(): restoring android user.inode_cache xattr to %s\n", realname);
#endif
if (write_path_inode(realname, "cache", "user.inode_cache"))
return -1;
}
if (t->th_buf.has_user_code_cache) {
#if 1 //def DEBUG
- printf("tar_extract_file(): restoring android user.inode_code_cache xattr to %s\n", realname);
+ LOG("tar_extract_file(): restoring android user.inode_code_cache xattr to %s\n", realname);
#endif
if (write_path_inode(realname, "code_cache", "user.inode_code_cache"))
return -1;
@@ -568,7 +568,7 @@
#else
bytes_to_hex(t->th_buf.fep->master_key_identifier, FSCRYPT_KEY_IDENTIFIER_SIZE, policy_hex);
#endif
- printf("tar_extract_dir(): restoring fscrypt policy %s to dir %s\n", (char *)policy_hex, realname);
+ LOG("tar_extract_dir(): restoring fscrypt policy %s to dir %s\n", (char *)policy_hex, realname);
#endif
bool policy_lookup_error = false;
#ifdef USE_FSCRYPT_POLICY_V1
@@ -581,14 +581,14 @@
#ifdef USE_FSCRYPT_POLICY_V1
if (!lookup_ref_tar(t->th_buf.fep->master_key_descriptor, &binary_policy[0])) {
- printf("error looking up fscrypt policy for '%s' - %s\n", realname, t->th_buf.fep->master_key_descriptor);
+ LOG("error looking up fscrypt policy for '%s' - %s\n", realname, t->th_buf.fep->master_key_descriptor);
policy_lookup_error = true;
}
memcpy(&t->th_buf.fep->master_key_descriptor, binary_policy, FS_KEY_DESCRIPTOR_SIZE);
bytes_to_hex(t->th_buf.fep->master_key_descriptor, FS_KEY_DESCRIPTOR_SIZE, policy_hex);
#else
if (!lookup_ref_tar(t->th_buf.fep->master_key_identifier, &binary_policy[0])) {
- printf("error looking up fscrypt policy for '%s' - %s\n", realname, t->th_buf.fep->master_key_identifier);
+ LOG("error looking up fscrypt policy for '%s' - %s\n", realname, t->th_buf.fep->master_key_identifier);
policy_lookup_error = true;
}
memcpy(&t->th_buf.fep->master_key_identifier, binary_policy, FSCRYPT_KEY_IDENTIFIER_SIZE);
@@ -596,17 +596,17 @@
#endif
if (!policy_lookup_error)
{
- printf("attempting to restore policy: %s\n", policy_hex);
+ LOG("attempting to restore policy: %s\n", policy_hex);
if (!fscrypt_policy_set_struct(realname, t->th_buf.fep))
{
- printf("tar_extract_file(): failed to restore fscrypt policy to dir '%s' '%s'!!!\n", realname, policy_hex);
+ LOG("tar_extract_file(): failed to restore fscrypt policy to dir '%s' '%s'!!!\n", realname, policy_hex);
//return -1; // This may not be an error in some cases, so log and ignore
}
} else
- printf("No policy was found. Continuing restore.");
+ LOG("No policy was found. Continuing restore.");
}
else
- printf("NULL FSCRYPT\n");
+ LOG("NULL FSCRYPT\n");
#endif
return 0;
@@ -635,7 +635,7 @@
return -1;
- printf(" ==> extracting: %s (fifo)\n", filename);
+ LOG(" ==> extracting: %s (fifo)\n", filename);
if (mkfifo(filename, mode) == -1)
{
@@ -657,7 +657,7 @@
ssize_t k;
#ifdef DEBUG
- printf(" ==> tar_extract_file_contents\n");
+ LOG(" ==> tar_extract_file_contents\n");
#endif
if (!TH_ISREG(t))
@@ -698,7 +698,7 @@
*lenp = (size_t)size;
#ifdef DEBUG
- printf("### done extracting contents\n");
+ LOG("### done extracting contents\n");
#endif
return 0;
}
diff --git a/libtar/libtar.h b/libtar/libtar.h
index 04782b2..8013e61 100755
--- a/libtar/libtar.h
+++ b/libtar/libtar.h
@@ -45,6 +45,8 @@
#define TH_EXT_TYPE 'x'
#define TH_POL_TYPE_DO_NOT_USE 'p'
+#define LOG(...) printf("libtar: " __VA_ARGS__)
+
/* our version of the tar header structure */
struct tar_header
{
diff --git a/libtar/libtar_hash.c b/libtar/libtar_hash.c
index 796ebbe..17ba854 100644
--- a/libtar/libtar_hash.c
+++ b/libtar/libtar_hash.c
@@ -122,7 +122,7 @@
libtar_hashptr_t *hp)
{
#ifdef DS_DEBUG
- printf("==> libtar_hash_next(h=0x%lx, hp={%d,0x%lx})\n",
+ LOG("==> libtar_hash_next(h=0x%lx, hp={%d,0x%lx})\n",
h, hp->bucket, hp->node);
#endif
@@ -130,7 +130,7 @@
libtar_list_next(h->table[hp->bucket], &(hp->node)) != 0)
{
#ifdef DS_DEBUG
- printf(" libtar_hash_next(): found additional "
+ LOG(" libtar_hash_next(): found additional "
"data in current bucket (%d), returing 1\n",
hp->bucket);
#endif
@@ -138,14 +138,14 @@
}
#ifdef DS_DEBUG
- printf(" libtar_hash_next(): done with bucket %d\n",
+ LOG(" libtar_hash_next(): done with bucket %d\n",
hp->bucket);
#endif
for (hp->bucket++; hp->bucket < h->numbuckets; hp->bucket++)
{
#ifdef DS_DEBUG
- printf(" libtar_hash_next(): "
+ LOG(" libtar_hash_next(): "
"checking bucket %d\n", hp->bucket);
#endif
hp->node = NULL;
@@ -154,7 +154,7 @@
&(hp->node)) != 0)
{
#ifdef DS_DEBUG
- printf(" libtar_hash_next(): "
+ LOG(" libtar_hash_next(): "
"found data in bucket %d, returing 1\n",
hp->bucket);
#endif
@@ -165,7 +165,7 @@
if (hp->bucket == h->numbuckets)
{
#ifdef DS_DEBUG
- printf(" libtar_hash_next(): hash pointer "
+ LOG(" libtar_hash_next(): hash pointer "
"wrapped to 0\n");
#endif
hp->bucket = -1;
@@ -173,7 +173,7 @@
}
#ifdef DS_DEBUG
- printf("<== libtar_hash_next(): no more data, "
+ LOG("<== libtar_hash_next(): no more data, "
"returning 0\n");
#endif
return 0;
@@ -269,7 +269,7 @@
libtar_matchfunc_t matchfunc)
{
#ifdef DS_DEBUG
- printf("==> libtar_hash_getkey(h=0x%lx, hp={%d,0x%lx}, "
+ LOG("==> libtar_hash_getkey(h=0x%lx, hp={%d,0x%lx}, "
"key=0x%lx, matchfunc=0x%lx)\n",
h, hp->bucket, hp->node, key, matchfunc);
#endif
@@ -278,7 +278,7 @@
{
hp->bucket = (*(h->hashfunc))(key, h->numbuckets);
#ifdef DS_DEBUG
- printf(" libtar_hash_getkey(): hp->bucket "
+ LOG(" libtar_hash_getkey(): hp->bucket "
"set to %d\n", hp->bucket);
#endif
}
@@ -286,7 +286,7 @@
if (h->table[hp->bucket] == NULL)
{
#ifdef DS_DEBUG
- printf(" libtar_hash_getkey(): no list "
+ LOG(" libtar_hash_getkey(): no list "
"for bucket %d, returning 0\n", hp->bucket);
#endif
hp->bucket = -1;
@@ -294,7 +294,7 @@
}
#ifdef DS_DEBUG
- printf("<== libtar_hash_getkey(): "
+ LOG("<== libtar_hash_getkey(): "
"returning libtar_list_search()\n");
#endif
return libtar_list_search(h->table[hp->bucket], &(hp->node),
@@ -314,25 +314,25 @@
int bucket, i;
#ifdef DS_DEBUG
- printf("==> libtar_hash_add(h=0x%lx, data=0x%lx)\n",
+ LOG("==> libtar_hash_add(h=0x%lx, data=0x%lx)\n",
h, data);
#endif
bucket = (*(h->hashfunc))(data, h->numbuckets);
#ifdef DS_DEBUG
- printf(" libtar_hash_add(): inserting in bucket %d\n",
+ LOG(" libtar_hash_add(): inserting in bucket %d\n",
bucket);
#endif
if (h->table[bucket] == NULL)
{
#ifdef DS_DEBUG
- printf(" libtar_hash_add(): creating new list\n");
+ LOG(" libtar_hash_add(): creating new list\n");
#endif
h->table[bucket] = libtar_list_new(LIST_QUEUE, NULL);
}
#ifdef DS_DEBUG
- printf("<== libtar_hash_add(): "
+ LOG("<== libtar_hash_add(): "
"returning libtar_list_add()\n");
#endif
i = libtar_list_add(h->table[bucket], data);
diff --git a/libtar/libtar_list.c b/libtar/libtar_list.c
index 2c5febb..4e3cc19 100644
--- a/libtar/libtar_list.c
+++ b/libtar/libtar_list.c
@@ -56,7 +56,7 @@
libtar_list_t *newlist;
#ifdef DS_DEBUG
- printf("in libtar_list_new(%d, 0x%lx)\n", flags, cmpfunc);
+ LOG("in libtar_list_new(%d, 0x%lx)\n", flags, cmpfunc);
#endif
if (flags != LIST_USERFUNC
@@ -155,7 +155,7 @@
libtar_listptr_t n, m;
#ifdef DS_DEBUG
- printf("==> libtar_list_add(\"%s\")\n", (char *)data);
+ LOG("==> libtar_list_add(\"%s\")\n", (char *)data);
#endif
n = (libtar_listptr_t)malloc(sizeof(struct libtar_node));
@@ -165,7 +165,7 @@
l->nents++;
#ifdef DS_DEBUG
- printf(" libtar_list_add(): allocated data\n");
+ LOG(" libtar_list_add(): allocated data\n");
#endif
/* if the list is empty */
@@ -174,14 +174,14 @@
l->last = l->first = n;
n->next = n->prev = NULL;
#ifdef DS_DEBUG
- printf("<== libtar_list_add(): list was empty; "
+ LOG("<== libtar_list_add(): list was empty; "
"added first element and returning 0\n");
#endif
return 0;
}
#ifdef DS_DEBUG
- printf(" libtar_list_add(): list not empty\n");
+ LOG(" libtar_list_add(): list not empty\n");
#endif
if (l->flags == LIST_STACK)
@@ -192,7 +192,7 @@
l->first->prev = n;
l->first = n;
#ifdef DS_DEBUG
- printf("<== libtar_list_add(): LIST_STACK set; "
+ LOG("<== libtar_list_add(): LIST_STACK set; "
"added in front\n");
#endif
return 0;
@@ -206,7 +206,7 @@
l->last->next = n;
l->last = n;
#ifdef DS_DEBUG
- printf("<== libtar_list_add(): LIST_QUEUE set; "
+ LOG("<== libtar_list_add(): LIST_QUEUE set; "
"added at end\n");
#endif
return 0;
@@ -220,7 +220,7 @@
** insert data before it
*/
#ifdef DS_DEBUG
- printf(" libtar_list_add(): gotcha..."
+ LOG(" libtar_list_add(): gotcha..."
"inserting data\n");
#endif
if (m == l->first)
@@ -230,7 +230,7 @@
m->prev = n;
n->next = m;
#ifdef DS_DEBUG
- printf("<== libtar_list_add(): "
+ LOG("<== libtar_list_add(): "
"added first, returning 0\n");
#endif
return 0;
@@ -240,14 +240,14 @@
m->prev = n;
n->next = m;
#ifdef DS_DEBUG
- printf("<== libtar_list_add(): added middle,"
+ LOG("<== libtar_list_add(): added middle,"
" returning 0\n");
#endif
return 0;
}
#ifdef DS_DEBUG
- printf(" libtar_list_add(): new data larger than current "
+ LOG(" libtar_list_add(): new data larger than current "
"list elements\n");
#endif
@@ -257,7 +257,7 @@
l->last = n;
n->next = NULL;
#ifdef DS_DEBUG
- printf("<== libtar_list_add(): added end, returning 0\n");
+ LOG("<== libtar_list_add(): added end, returning 0\n");
#endif
return 0;
}
@@ -273,7 +273,7 @@
libtar_listptr_t m;
#ifdef DS_DEBUG
- printf("==> libtar_list_del()\n");
+ LOG("==> libtar_list_del()\n");
#endif
l->nents--;
@@ -384,7 +384,7 @@
libtar_matchfunc_t matchfunc)
{
#ifdef DS_DEBUG
- printf("==> libtar_list_search(l=0x%lx, n=0x%lx, \"%s\")\n",
+ LOG("==> libtar_list_search(l=0x%lx, n=0x%lx, \"%s\")\n",
l, n, (char *)data);
#endif
@@ -399,14 +399,14 @@
for (; *n != NULL; *n = (*n)->next)
{
#ifdef DS_DEBUG
- printf("checking against \"%s\"\n", (char *)(*n)->data);
+ LOG("checking against \"%s\"\n", (char *)(*n)->data);
#endif
if ((*(matchfunc))(data, (*n)->data) != 0)
return 1;
}
#ifdef DS_DEBUG
- printf("no matches found\n");
+ LOG("no matches found\n");
#endif
return 0;
}
@@ -426,7 +426,7 @@
libtar_list_add(newlist, n->data);
#ifdef DS_DEBUG
- printf("returning from libtar_list_dup()\n");
+ LOG("returning from libtar_list_dup()\n");
#endif
return newlist;
}
diff --git a/libtar/output.c b/libtar/output.c
index 015179d..8611b41 100755
--- a/libtar/output.c
+++ b/libtar/output.c
@@ -36,37 +36,37 @@
void
th_print(TAR *t)
{
- puts("\nPrinting tar header:");
- printf(" name = \"%.100s\"\n", t->th_buf.name);
- printf(" mode = \"%.8s\"\n", t->th_buf.mode);
- printf(" uid = \"%.8s\"\n", t->th_buf.uid);
- printf(" gid = \"%.8s\"\n", t->th_buf.gid);
- printf(" size = \"%.12s\"\n", t->th_buf.size);
- printf(" mtime = \"%.12s\"\n", t->th_buf.mtime);
- printf(" chksum = \"%.8s\"\n", t->th_buf.chksum);
- printf(" typeflag = \'%c\'\n", t->th_buf.typeflag);
- printf(" linkname = \"%.100s\"\n", t->th_buf.linkname);
- printf(" magic = \"%.6s\"\n", t->th_buf.magic);
- /*printf(" version = \"%.2s\"\n", t->th_buf.version); */
- /*printf(" version[0] = \'%c\',version[1] = \'%c\'\n",
+ LOG("Printing tar header:");
+ LOG(" name = \"%.100s\"\n", t->th_buf.name);
+ LOG(" mode = \"%.8s\"\n", t->th_buf.mode);
+ LOG(" uid = \"%.8s\"\n", t->th_buf.uid);
+ LOG(" gid = \"%.8s\"\n", t->th_buf.gid);
+ LOG(" size = \"%.12s\"\n", t->th_buf.size);
+ LOG(" mtime = \"%.12s\"\n", t->th_buf.mtime);
+ LOG(" chksum = \"%.8s\"\n", t->th_buf.chksum);
+ LOG(" typeflag = \'%c\'\n", t->th_buf.typeflag);
+ LOG(" linkname = \"%.100s\"\n", t->th_buf.linkname);
+ LOG(" magic = \"%.6s\"\n", t->th_buf.magic);
+ /*LOG(" version = \"%.2s\"\n", t->th_buf.version); */
+ /*LOG(" version[0] = \'%c\',version[1] = \'%c\'\n",
t->th_buf.version[0], t->th_buf.version[1]);*/
- printf(" uname = \"%.32s\"\n", t->th_buf.uname);
- printf(" gname = \"%.32s\"\n", t->th_buf.gname);
- printf(" devmajor = \"%.8s\"\n", t->th_buf.devmajor);
- printf(" devminor = \"%.8s\"\n", t->th_buf.devminor);
- printf(" prefix = \"%.155s\"\n", t->th_buf.prefix);
- printf(" padding = \"%.12s\"\n", t->th_buf.padding);
- printf(" gnu_longname = \"%s\"\n",
+ LOG(" uname = \"%.32s\"\n", t->th_buf.uname);
+ LOG(" gname = \"%.32s\"\n", t->th_buf.gname);
+ LOG(" devmajor = \"%.8s\"\n", t->th_buf.devmajor);
+ LOG(" devminor = \"%.8s\"\n", t->th_buf.devminor);
+ LOG(" prefix = \"%.155s\"\n", t->th_buf.prefix);
+ LOG(" padding = \"%.12s\"\n", t->th_buf.padding);
+ LOG(" gnu_longname = \"%s\"\n",
(t->th_buf.gnu_longname ? t->th_buf.gnu_longname : "[NULL]"));
- printf(" gnu_longlink = \"%s\"\n",
+ LOG(" gnu_longlink = \"%s\"\n",
(t->th_buf.gnu_longlink ? t->th_buf.gnu_longlink : "[NULL]"));
#ifdef USE_FSCRYPT
#ifdef USE_FSCRYPT_POLICY_V1
- printf(" fep = \"%s\"\n",
+ LOG(" fep = \"%s\"\n",
(t->th_buf.fep ? t->th_buf.fep->master_key_descriptor : (uint8_t*) "[NULL]"));
#else
- printf(" fep = \"%s\"\n",
+ LOG(" fep = \"%s\"\n",
(t->th_buf.fep ? t->th_buf.fep->master_key_identifier : (uint8_t*) "[NULL]"));
#endif
#endif
@@ -110,36 +110,36 @@
strlcpy(groupname, gr->gr_name, sizeof(groupname));
strmode(th_get_mode(t), modestring);
- printf("%.10s %-8.8s %-8.8s ", modestring, username, groupname);
+ LOG("%.10s %-8.8s %-8.8s ", modestring, username, groupname);
if (TH_ISCHR(t) || TH_ISBLK(t))
- printf(" %3d, %3d ", (int)th_get_devmajor(t), (int)th_get_devminor(t));
+ LOG(" %3d, %3d ", (int)th_get_devmajor(t), (int)th_get_devminor(t));
else
- printf("%9ld ", (long)th_get_size(t));
+ LOG("%9ld ", (long)th_get_size(t));
mtime = th_get_mtime(t);
mtm = localtime(&mtime);
#ifdef HAVE_STRFTIME
strftime(timebuf, sizeof(timebuf), "%h %e %H:%M %Y", mtm);
- printf("%s", timebuf);
+ LOG("%s", timebuf);
#else
- printf("%.3s %2d %2d:%02d %4d",
+ LOG("%.3s %2d %2d:%02d %4d",
months[mtm->tm_mon],
mtm->tm_mday, mtm->tm_hour, mtm->tm_min, mtm->tm_year + 1900);
#endif
- printf(" %s", th_get_pathname(t));
+ LOG(" %s", th_get_pathname(t));
if (TH_ISSYM(t) || TH_ISLNK(t))
{
if (TH_ISSYM(t))
- printf(" -> ");
+ LOG(" -> ");
else
- printf(" link to ");
+ LOG(" link to ");
if ((t->options & TAR_GNU) && t->th_buf.gnu_longlink != NULL)
- printf("%s", t->th_buf.gnu_longlink);
+ LOG("%s", t->th_buf.gnu_longlink);
else
- printf("%.100s", t->th_buf.linkname);
+ LOG("%.100s", t->th_buf.linkname);
}
putchar('\n');
diff --git a/libtar/snprintf.c b/libtar/snprintf.c
index 8c228d4..c1cc8a6 100644
--- a/libtar/snprintf.c
+++ b/libtar/snprintf.c
@@ -734,7 +734,7 @@
sprintf (buf2, fp_fmt[x], fp_nums[y]);
if (strcmp (buf1, buf2))
{
- printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
+ LOG("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
fp_fmt[x], buf1, buf2);
fail++;
}
@@ -748,7 +748,7 @@
sprintf (buf2, int_fmt[x], int_nums[y]);
if (strcmp (buf1, buf2))
{
- printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
+ LOG("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
int_fmt[x], buf1, buf2);
fail++;
}
diff --git a/libtar/util.c b/libtar/util.c
index 7fb3f51..c904888 100644
--- a/libtar/util.c
+++ b/libtar/util.c
@@ -213,9 +213,9 @@
}
void print_caps(struct vfs_cap_data *cap_data) {
- printf(" magic_etc=%u \n", cap_data->magic_etc);
- printf(" data[0].permitted=%u \n", cap_data->data[0].permitted);
- printf(" data[0].inheritable=%u \n", cap_data->data[0].inheritable);
- printf(" data[1].permitted=%u \n", cap_data->data[1].permitted);
- printf(" data[1].inheritable=%u \n", cap_data->data[1].inheritable);
+ LOG(" magic_etc=%u \n", cap_data->magic_etc);
+ LOG(" data[0].permitted=%u \n", cap_data->data[0].permitted);
+ LOG(" data[0].inheritable=%u \n", cap_data->data[0].inheritable);
+ LOG(" data[1].permitted=%u \n", cap_data->data[1].permitted);
+ LOG(" data[1].inheritable=%u \n", cap_data->data[1].inheritable);
}
diff --git a/libtar/wrapper.c b/libtar/wrapper.c
index d3d285f..07befce 100644
--- a/libtar/wrapper.c
+++ b/libtar/wrapper.c
@@ -61,14 +61,14 @@
int i;
#ifdef DEBUG
- printf("==> tar_extract_all(TAR *t, \"%s\")\n",
+ LOG("==> tar_extract_all(TAR *t, \"%s\")\n",
(prefix ? prefix : "(null)"));
#endif
while ((i = th_read(t)) == 0)
{
#ifdef DEBUG
- puts(" tar_extract_all(): calling th_get_pathname()");
+ LOG(" tar_extract_all(): calling th_get_pathname()");
#endif
filename = th_get_pathname(t);
if (t->options & TAR_VERBOSE)
@@ -78,7 +78,7 @@
else
strlcpy(buf, filename, sizeof(buf));
#ifdef DEBUG
- printf(" tar_extract_all(): calling tar_extract_file(t, "
+ LOG(" tar_extract_all(): calling tar_extract_file(t, "
"\"%s\")\n", buf);
#endif
if (tar_extract_file(t, buf, prefix, progress_fd) != 0)
@@ -99,7 +99,7 @@
struct stat s;
#ifdef DEBUG
- printf("==> tar_append_tree(0x%lx, \"%s\", \"%s\")\n",
+ LOG("==> tar_append_tree(0x%lx, \"%s\", \"%s\")\n",
t, realdir, (savedir ? savedir : "[NULL]"));
#endif
@@ -107,7 +107,7 @@
return -1;
#ifdef DEBUG
- puts(" tar_append_tree(): done with tar_append_file()...");
+ LOG(" tar_append_tree(): done with tar_append_file()...");
#endif
dp = opendir(realdir);
@@ -160,21 +160,21 @@
char *filename;
int i, entryfound = 0;
#ifdef DEBUG
- printf("==> tar_find(0x%lx, %s)\n", (long unsigned int)t, searchstr);
+ LOG("==> tar_find(0x%lx, %s)\n", (long unsigned int)t, searchstr);
#endif
while ((i = th_read(t)) == 0) {
filename = th_get_pathname(t);
if (fnmatch(searchstr, filename, FNM_FILE_NAME | FNM_PERIOD) == 0) {
entryfound++;
#ifdef DEBUG
- printf("Found matching entry: %s\n", filename);
+ LOG("Found matching entry: %s\n", filename);
#endif
break;
}
}
#ifdef DEBUG
if (!entryfound)
- printf("No matching entry found.\n");
+ LOG("No matching entry found.\n");
#endif
return entryfound;