projects
/
ptask.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
prepared code to add a way to change the notes directory
[ptask.git]
/
src
/
note.c
diff --git
a/src/note.c
b/src/note.c
index
c5b225a
..
77f98cf
100644
(file)
--- a/
src/note.c
+++ b/
src/note.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 201
0-2012
jeanfi@gmail.com
+ * Copyright (C) 201
2-2013
jeanfi@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@
-23,16
+23,17
@@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <log.h>
#include <note.h>
#include <note.h>
-static char *get_path(const char *uuid)
+static char *get_
default_
path(const char *uuid)
{
char *home, *dir, *path;
home = getenv("HOME");
if (!home) {
{
char *home, *dir, *path;
home = getenv("HOME");
if (!home) {
-
fprintf(stderr, "HOME environment variable not defined\n
");
+
log_err("HOME environment variable not defined
");
return NULL;
}
return NULL;
}
@@
-48,6
+49,11
@@
static char *get_path(const char *uuid)
return path;
}
return path;
}
+static char *get_path(const char *uuid)
+{
+ return get_default_path(uuid);
+}
+
void note_put(const char *uuid, const char *note)
{
char *path;
void note_put(const char *uuid, const char *note)
{
char *path;
@@
-58,7
+64,7
@@
void note_put(const char *uuid, const char *note)
if (!path)
return ;
if (!path)
return ;
-
printf("note_put %s %s %s\n
", path, uuid, note);
+
log_debug("note_put %s %s %s
", path, uuid, note);
f = fopen(path, "w");
f = fopen(path, "w");
@@
-66,7
+72,7
@@
void note_put(const char *uuid, const char *note)
fwrite(note, 1, strlen(note), f);
fclose(f);
} else {
fwrite(note, 1, strlen(note), f);
fclose(f);
} else {
-
fprintf(stderr, "Failed to open %s\n
", path);
+
log_err("Failed to open %s
", path);
}
free(path);
}
free(path);
@@
-99,7
+105,7
@@
char *note_get(const char *uuid)
}
fclose(f);
} else {
}
fclose(f);
} else {
-
fprintf(stderr, "Failed to open %s\n
", path);
+
log_debug("%s does not exist or cannot be opened
", path);
}
return str;
}
return str;