~mdw
/
ezmlm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Import ezmlm-idx 0.40
[ezmlm]
/
log.c
diff --git
a/log.c
b/log.c
index
15e732e
..
bf3c7a3
100644
(file)
--- a/
log.c
+++ b/
log.c
@@
-6,14
+6,21
@@
#include "fmt.h"
#include "open.h"
#include "fmt.h"
#include "open.h"
+/* appends (not crash-proof) a line to "Log". The format is: */
+/* "timestamp event address[ comment]\n". address is free of ' ' */
+/* Unprintable chars are changed to '?'. Comment may have spaces */
+
static substdio ss;
static char buf[1];
static char num[FMT_ULONG];
static stralloc line = {0};
static substdio ss;
static char buf[1];
static char num[FMT_ULONG];
static stralloc line = {0};
+static stralloc fn = {0};
-void log(event,addr)
+void log(dir,event,addr,comment)
+char *dir;
char *event;
char *addr;
char *event;
char *addr;
+char *comment;
{
char ch;
int fd;
{
char ch;
int fd;
@@
-26,9
+33,22
@@
char *addr;
if ((ch < 33) || (ch > 126)) ch = '?';
if (!stralloc_append(&line,&ch)) return;
}
if ((ch < 33) || (ch > 126)) ch = '?';
if (!stralloc_append(&line,&ch)) return;
}
+ if (comment && *comment) {
+ if (!stralloc_cats(&line," ")) return;
+ while (ch = *comment++) {
+ if (ch == '\t')
+ ch = ' ';
+ else
+ if ((ch < 32) || (ch > 126)) ch = '?';
+ if (!stralloc_append(&line,&ch)) return;
+ }
+ }
if (!stralloc_cats(&line,"\n")) return;
if (!stralloc_cats(&line,"\n")) return;
- fd = open_append("Log");
+ if (!stralloc_copys(&fn,dir)) return;
+ if (!stralloc_cats(&fn,"/Log")) return;
+ if (!stralloc_0(&fn)) return;
+ fd = open_append(fn.s);
if (fd == -1) return;
substdio_fdbuf(&ss,write,fd,buf,sizeof(buf));
substdio_putflush(&ss,line.s,line.len);
if (fd == -1) return;
substdio_fdbuf(&ss,write,fd,buf,sizeof(buf));
substdio_putflush(&ss,line.s,line.len);