aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-02-10 15:38:04 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-02-10 15:38:04 +0100
commite619bc1e0f289ddc37b44afeac541450a1ed46a1 (patch)
tree46b6442d3c7dd33993f7371492b8e66feca9e60e
parentAdd PRINT macro. (diff)
downloadcalp-e619bc1e0f289ddc37b44afeac541450a1ed46a1.tar.gz
calp-e619bc1e0f289ddc37b44afeac541450a1ed46a1.tar.xz
Replace printf/puts with INFO/ERR.
-rw-r--r--calendar.c9
-rw-r--r--graphs.c6
-rw-r--r--main.c12
3 files changed, 15 insertions, 12 deletions
diff --git a/calendar.c b/calendar.c
index fef4ab28..de06276a 100644
--- a/calendar.c
+++ b/calendar.c
@@ -14,6 +14,7 @@
#include "macro.h"
#include "parse.h"
+#include "err.h"
/*
* Returns 0 if file has no extersion
@@ -92,11 +93,11 @@ int read_vcalendar(vcomponent* cal, char* path) {
int type = statbuf.st_mode & 0777000;
int chmod = statbuf.st_mode & 0777;
- printf("file has mode 0%o, with chmod = 0%o\n", type, chmod);
+ INFO_F("file has mode 0%o, with chmod = 0%o", type, chmod);
switch (type) {
case S_IFREG:
- puts("Parsing a single file");
+ INFO("Parsing a single file");
char ext[10];
int has_ext = get_extension(path, ext, 9);
@@ -118,12 +119,12 @@ int read_vcalendar(vcomponent* cal, char* path) {
break;
case S_IFDIR:
- puts("Parsing a directory");
+ INFO("Parsing a directory");
parse_dir (cal, path);
break;
case S_IFLNK:
- fputs("Found symlink, can't be bothered to check it further.", stderr);
+ ERR("Found symlink, can't be bothered to check it further.");
break;
default:
diff --git a/graphs.c b/graphs.c
index bcadd787..4f6955c3 100644
--- a/graphs.c
+++ b/graphs.c
@@ -2,6 +2,8 @@
#include <stdio.h>
#include <errno.h>
+#include <string.h>
+#include "err.h"
int create_graph_trie (vcomponent* ev, char* filename) {
FILE* f = fopen(filename, "w");
@@ -12,7 +14,6 @@ int create_graph_trie (vcomponent* ev, char* filename) {
fclose(f);
- printf("Wrote '%s' to '%s'\n", ev->filename, filename);
return 0;
}
@@ -36,6 +37,7 @@ int attr_helper(TRIE_NODE(content_line)* root, FILE* f) {
attr_helper(root->child, f);
child = child->next;
}
+ INFO_F("Wrote '%s' to '%s'", ev->filename, filename);
return 0;
}
@@ -80,7 +82,7 @@ int helper_vcomponent (vcomponent* root, FILE* f) {
int create_graph_vcomponent (vcomponent* root, char* outfile) {
FILE* f = fopen(outfile, "w");
if (f == NULL) {
- printf("Error opening file %s, errno = %i\n", outfile, errno);
+ ERR_F("Error opening file %s, errno = %i", outfile, errno);
return 1;
}
vcomponent* c = root;
diff --git a/main.c b/main.c
index 6b312ec1..042cc83d 100644
--- a/main.c
+++ b/main.c
@@ -7,6 +7,7 @@
#include "macro.h"
#include "vcal.h"
#include "graphs.h"
+#include "err.h"
typedef struct {
int argc;
@@ -25,7 +26,7 @@ int main (int argc, char* argv[argc]) {
arg args = { .argc = argc, .argv = argv };
if (arg_shift(&args) == 0) {
- puts("Please give vdir or a vcalendar file as first argument");
+ ERR("Please give vdir or a vcalendar file as first argument");
exit (1);
}
@@ -36,9 +37,8 @@ int main (int argc, char* argv[argc]) {
arg_shift(&args);
if (args.argc == 0 || strcmp(args.argv[0], "-p") == 0) {
- printf("\nParsed calendar file containing [%u] events\n",
- root.components.length
- );
+ INFO_F("\nParsed calendar file containing [%u] events",
+ root.components.length);
for (size_t i = 0; i < root.components.length; i++) {
vcomponent* cal = GET(VECT(vcomponent))(&root.components, i);
assert(strcmp(cal->type, "VCALENDAR") == 0);
@@ -73,8 +73,8 @@ int main (int argc, char* argv[argc]) {
}
} else {
// create_graph(FCHILD(FCHILD(&root)), args.argv[0]);
- puts("Creating graph for single file");
- printf("output = %s\n", args.argv[0]);
+ INFO("Creating graph for single file");
+ INFO_F("output = %s\n", args.argv[0]);
create_graph_vcomponent(&root, args.argv[0]);
}
}