summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-08-02 21:49:49 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-10-05 12:25:47 +0200
commitc77d1a573fc9c9d27ccc8c80a5a67245a3cf0e1b (patch)
tree18e205b6579b3a1cda3c591826b43369d5221868 /src
parent5c6a00ee93e54cc044aee5146e9fcfbcb732a2ee (diff)
downloadcalcurse-c77d1a573fc9c9d27ccc8c80a5a67245a3cf0e1b.tar.gz
calcurse-c77d1a573fc9c9d27ccc8c80a5a67245a3cf0e1b.zip
Use hash-based file names in ical_read_note()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r--src/io.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/io.c b/src/io.c
index feaeb0a..20dab48 100644
--- a/src/io.c
+++ b/src/io.c
@@ -45,6 +45,7 @@
#include <errno.h>
#include "calcurse.h"
+#include "sha1.h"
#define ICALDATEFMT "%Y%m%d"
#define ICALDATETIMEFMT "%Y%m%dT%H%M%S"
@@ -2308,43 +2309,37 @@ static char *
ical_read_note (char *line, unsigned *noskipped, ical_vevent_e item_type,
const int itemline, FILE *log)
{
- char *p, *notestr, *notename, fullnotename[BUFSIZ];
+ char *sha1 = mem_malloc (SHA1_DIGESTLEN * 2 + 1);
+ char *p, *notestr, fullnotename[BUFSIZ];
FILE *fdo;
if ((p = strchr (line, ':')) != NULL)
{
- notename = new_tempfile (path_notes, TMPEXTSIZ);
- EXIT_IF (notename == NULL,
- _("Warning: could not create new note file to store "
- "description. Aborting...\n"));
- (void)snprintf (fullnotename, BUFSIZ, "%s%s", path_notes, notename);
- fdo = fopen (fullnotename, "w");
- EXIT_IF (fdo == NULL, _("Warning: could not open %s, Aborting..."),
- fullnotename);
p++;
notestr = ical_unformat_line (p);
if (notestr == NULL)
{
ical_log (log, item_type, itemline,
_("could not get entire item description."));
- file_close (fdo, __FILE_POS__);
- erase_note (&notename, ERASE_FORCE);
(*noskipped)++;
return NULL;
}
else if (strlen (notestr) == 0)
{
- file_close (fdo, __FILE_POS__);
- erase_note (&notename, ERASE_FORCE);
mem_free (notestr);
return NULL;
}
else
{
+ sha1_digest (notestr, sha1);
+ (void)snprintf (fullnotename, BUFSIZ, "%s%s", path_notes, sha1);
+ fdo = fopen (fullnotename, "w");
+ EXIT_IF (fdo == NULL, _("Warning: could not open %s, Aborting..."),
+ fullnotename);
(void)fprintf (fdo, "%s", notestr);
file_close (fdo, __FILE_POS__);
mem_free (notestr);
- return notename;
+ return sha1;
}
}
else