summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brewer <ben.brewer@codethink.co.uk>2014-05-29 14:33:02 (GMT)
committerBen Brewer <ben.brewer@codethink.co.uk>2014-06-02 10:03:01 (GMT)
commit22af73f152d48af1b7ecc78b32ef3b7bc43ca3d3 (patch)
treedfc770f294848d58a73669b8ebe8b8792934e368
parent7a91ea67a98c54fcdb9d1b092bba524200c726dd (diff)
downloadtbdiff-22af73f152d48af1b7ecc78b32ef3b7bc43ca3d3.tar.gz
Use TBD_DEBUG macro instead of fprint for debug messages
We now use the TBD_DEBUG macro rather than fprintf, this means that debug messages aren't printed when debugging is disabled.
-rw-r--r--tbdiff/tbdiff-apply.c20
-rw-r--r--tbdiff/tbdiff-create.c22
2 files changed, 21 insertions, 21 deletions
diff --git a/tbdiff/tbdiff-apply.c b/tbdiff/tbdiff-apply.c
index 0a1fe7c..c5bb4ae 100644
--- a/tbdiff/tbdiff-apply.c
+++ b/tbdiff/tbdiff-apply.c
@@ -121,7 +121,7 @@ tbd_apply_cmd_dir_create(FILE *stream)
if(fread(dname, 1, dlen, stream) != dlen)
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
dname[dlen] = '\0';
- fprintf(stderr, "cmd_dir_create %s\n", dname);
+ TBD_DEBUGF("cmd_dir_create %s\n", dname);
if(strchr(dname, '/') != NULL)
return TBD_ERROR(TBD_ERROR_INVALID_PARAMETER);
@@ -165,7 +165,7 @@ tbd_apply_cmd_dir_enter(FILE *stream,
if(fread(dname, 1, dlen, stream) != dlen)
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
dname[dlen] = '\0';
- fprintf(stderr, "cmd_dir_enter %s\n", dname);
+ TBD_DEBUGF("cmd_dir_enter %s\n", dname);
if((strchr(dname, '/') != NULL) || (strcmp(dname, "..") == 0))
return TBD_ERROR(TBD_ERROR_UNABLE_TO_CHANGE_DIR);
if(depth != NULL)
@@ -188,7 +188,7 @@ tbd_apply_cmd_dir_leave(FILE *stream,
}
time.actime = time.modtime;/* not sure what the best atime to use is */
- fprintf(stderr, "cmd_dir_leave\n");
+ TBD_DEBUG("cmd_dir_leave\n");
/* test for leaving shallowest depth */
if ((depth != NULL) && (*depth < 1)) {
@@ -236,7 +236,7 @@ tbd_apply_cmd_file_create(FILE *stream)
tbd_read_uint32(&fsize, stream) != 1)
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
- fprintf(stderr, "cmd_file_create %s:%"PRId32"\n", fname, fsize);
+ TBD_DEBUGF("cmd_file_create %s:%"PRId32"\n", fname, fsize);
FILE *fp = fopen(fname, "rb");
if(fp != NULL) {
@@ -294,7 +294,7 @@ tbd_apply_cmd_file_delta(FILE *stream)
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
fname[flen] = '\0';
- fprintf(stderr, "cmd_file_delta %s\n", fname);
+ TBD_DEBUGF("cmd_file_delta %s\n", fname);
if((strchr(fname, '/') != NULL) ||
(strcmp(fname, "..") == 0))
@@ -485,7 +485,7 @@ tbd_apply_cmd_entity_delete(FILE *stream)
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
ename[elen] = '\0';
- fprintf(stderr, "cmd_entity_delete %s\n", ename);
+ TBD_DEBUGF("cmd_entity_delete %s\n", ename);
if((strchr(ename, '/') != NULL) || (strcmp(ename, "..") == 0))
return TBD_ERROR(TBD_ERROR_INVALID_PARAMETER);
@@ -523,7 +523,7 @@ tbd_apply_cmd_symlink_create(FILE *stream)
if(fread(linkpath, sizeof(char), len, stream) != len)
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
- fprintf(stderr, "cmd_symlink_create %s -> %s\n", linkname, linkpath);
+ TBD_DEBUGF("cmd_symlink_create %s -> %s\n", linkname, linkpath);
if(symlink(linkpath, linkname))
return TBD_ERROR(TBD_ERROR_UNABLE_TO_CREATE_SYMLINK);
@@ -559,7 +559,7 @@ tbd_apply_cmd_special_create(FILE *stream)
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
}
- fprintf(stderr, "cmd_special_create %s\n", name);
+ TBD_DEBUGF("cmd_special_create %s\n", name);
if(mknod(name, mode, (dev_t)dev) != 0) {
free(name);
@@ -596,7 +596,7 @@ tbd_apply_cmd_dir_delta(FILE *stream)
if(dname == NULL)
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
- fprintf(stderr, "cmd_dir_delta %s\n", dname);
+ TBD_DEBUGF("cmd_dir_delta %s\n", dname);
if(metadata_mask & TBD_METADATA_MTIME) {
struct utimbuf timebuff = { time(NULL), mtime };
@@ -631,7 +631,7 @@ tbd_apply_cmd_file_mdata_update(FILE *stream)
if(dname == NULL)
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
- fprintf(stderr, "cmd_metadata_update %s\n", dname);
+ TBD_DEBUGF("cmd_metadata_update %s\n", dname);
if(metadata_mask & TBD_METADATA_MTIME) {
struct utimbuf timebuff = { time(NULL), mtime };
diff --git a/tbdiff/tbdiff-create.c b/tbdiff/tbdiff-create.c
index 73a40bb..edfb985 100644
--- a/tbdiff/tbdiff-create.c
+++ b/tbdiff/tbdiff-create.c
@@ -685,7 +685,7 @@ tbd_create_impl(FILE *stream,
int err;
if(((b == NULL) || ((a != NULL) && (a->type != b->type)))) {
- fprintf(stderr, "file delete %s\n", a->name);
+ TBD_DEBUGF("file delete %s\n", a->name);
if((err = tbd_create_cmd_entity_delete(stream, a->name)) != 0)
return err;
}
@@ -693,21 +693,21 @@ tbd_create_impl(FILE *stream,
if((a == NULL) || ((b != NULL) && (a->type != b->type))) {
switch(b->type) {
case TBD_STAT_TYPE_FILE:
- fprintf(stderr, "file new %s\n", b->name);
+ TBD_DEBUGF("file new %s\n", b->name);
return tbd_create_cmd_file_create(stream, b);
case TBD_STAT_TYPE_DIR:
- fprintf(stderr, "dir new %s\n", b->name);
+ TBD_DEBUGF("dir new %s\n", b->name);
return tbd_create_dir(stream, b);
case TBD_STAT_TYPE_SYMLINK:
- fprintf(stderr, "symlink new %s\n", b->name);
+ TBD_DEBUGF("symlink new %s\n", b->name);
return tbd_create_cmd_symlink_create(stream, b);
case TBD_STAT_TYPE_CHRDEV:
case TBD_STAT_TYPE_BLKDEV:
case TBD_STAT_TYPE_FIFO:
- fprintf(stderr, "special new %s\n", b->name);
+ TBD_DEBUGF("special new %s\n", b->name);
return tbd_create_cmd_special_create(stream, b);
case TBD_STAT_TYPE_SOCKET:
- fprintf(stderr, "socket new %s\n", b->name);
+ TBD_DEBUGF("socket new %s\n", b->name);
return tbd_create_cmd_socket_create(stream, b);
default:
return TBD_ERROR(TBD_ERROR_FEATURE_NOT_IMPLEMENTED);
@@ -716,22 +716,22 @@ tbd_create_impl(FILE *stream,
switch(b->type) {
case TBD_STAT_TYPE_FILE:
- fprintf(stderr, "file delta %s\n", a->name);
+ TBD_DEBUGF("file delta %s\n", a->name);
return tbd_create_cmd_file_delta(stream, a, b);
case TBD_STAT_TYPE_SYMLINK:
- fprintf(stderr, "symlink delta %s\n", a->name);
+ TBD_DEBUGF("symlink delta %s\n", a->name);
return tbd_create_cmd_symlink_delta(stream, a, b);
case TBD_STAT_TYPE_CHRDEV:
case TBD_STAT_TYPE_BLKDEV:
case TBD_STAT_TYPE_FIFO:
- fprintf(stderr, "special delta %s\n", a->name);
+ TBD_DEBUGF("special delta %s\n", a->name);
return tbd_create_cmd_special_delta(stream, a, b);
case TBD_STAT_TYPE_SOCKET:
- fprintf(stderr, "socket delta %s\n", a->name);
+ TBD_DEBUGF("socket delta %s\n", a->name);
return tbd_create_cmd_socket_delta(stream, a, b);
case TBD_STAT_TYPE_DIR:
if(!top) {
- fprintf(stderr, "dir delta %s\n", a->name);
+ TBD_DEBUGF("dir delta %s\n", a->name);
if ((err = tbd_create_cmd_dir_delta(stream, a, b)) !=
TBD_ERROR_SUCCESS) {
return err;