This repository has been archived by the owner on Sep 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
watch.h
73 lines (59 loc) · 1.5 KB
/
watch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// watch.h - watch item support
/*
This file is part of Tripover, a broad-search journey planner.
Copyright (C) 2014 Joris van der Geer.
*/
static ub8 rsids2log[8];
static ub4 rsid2logcnt;
static int rsid2log(ub4 rsid,ub4 lvl)
{
ub4 r,i = 0;
ub8 x;
for (i = 0; i < rsid2logcnt; i++) {
x = rsids2log[i];
r = (ub4)x;
if (r != rsid && r != hi32) continue;
if ((x >> 32) >= lvl) return 1;
}
return 0;
}
#define rsidlog(rsid,fmt,...) rsidlogfln(FLN,(rsid),(fmt),__VA_ARGS__)
static int __attribute__ ((format (printf,3,4))) rsidlogfln(ub4 fln,ub4 rsid,const char *fmt,...)
{
va_list ap;
char buf[2048];
if (rsid2logcnt && rsid2log(rsid,0)) {
va_start(ap, fmt);
myvsnprintf(buf,0,sizeof(buf),fmt,ap);
va_end(ap);
infofln(fln,0,"rsid \ax%u: %s",rsid,buf);
return 1;
} else return 0;
}
static ub8 hops2log[8];
static ub4 hop2logcnt;
static int hop2log(ub4 hop,ub4 lvl)
{
ub4 h,i = 0;
ub8 x;
while (i < hop2logcnt) {
x = hops2log[i++];
h = (ub4)x;
if (h != hop && h != hi32) continue;
if ((x >> 32) >= lvl) return 1;
}
return 0;
}
#define hoplog(hop,lvl,fmt,...) hoplogfln(FLN,(hop),(lvl),(fmt),__VA_ARGS__)
static int __attribute__ ((format (printf,4,5))) hoplogfln(ub4 fln,ub4 hop,ub4 lvl,const char *fmt,...)
{
va_list ap;
char buf[2048];
if (hop2logcnt && hop2log(hop,lvl)) {
va_start(ap, fmt);
myvsnprintf(buf,0,sizeof(buf),fmt,ap);
va_end(ap);
infofln(fln,0,"hop %u: %s",hop,buf);
return 1;
} else return 0;
}