#define WEEKMIN (24*60*7)
#define val(x) (( (x) < 48 || (x) > 57) ? 0 : ((x) - 48))
+#if 0 /* Set to 1 if you're a developer and want to debug this code */
+# define timestr_debug DEBUG2
+#else
+# define timestr_debug if (0) printf
+#endif
+
/*
* String code.
*/
int i;
size_t l;
- DEBUG2("strcode %s called\n", *str);
+ timestr_debug("strcode %s called\n", *str);
for (i = 0; i < 10; i++) {
l = strlen(days[i]);
break;
}
}
- DEBUG2("strcode result %d\n", i);
+ timestr_debug("strcode result %d\n", i);
return (i >= 10) ? -1 : i;
int start, end;
int i, bit, byte;
- DEBUG2("hour_fill called for %s\n", tm);
+ timestr_debug("hour_fill called for %s\n", tm);
/*
* Get timerange in start and end.
if (end >= DAYMIN) end = DAYMIN - 1;
if (start >= DAYMIN) start = DAYMIN - 1;
- DEBUG2("hour_fill: range from %d to %d\n", start, end);
+ timestr_debug("hour_fill: range from %d to %d\n", start, end);
/*
* Fill bitmap.
while (1) {
byte = (i / 8);
bit = i % 8;
- DEBUG2("setting byte %d, bit %d\n", byte, bit);
+ timestr_debug("setting byte %d, bit %d\n", byte, bit);
bitmap[byte] |= (1 << bit);
if (i == end) break;
i++;
if (hr == tm)
tm = "Al";
- DEBUG2("dayfill: hr %s tm %s\n", hr, tm);
+ timestr_debug("dayfill: hr %s tm %s\n", hr, tm);
while ((start = strcode(&tm)) >= 0) {
/*
end = 6;
}
n = start;
- DEBUG2("day_fill: range from %d to %d\n", start, end);
+ timestr_debug("day_fill: range from %d to %d\n", start, end);
while (1) {
hour_fill(bitmap + 180 * n, hr);
if (n == end) break;
char bitmap[WEEKMIN / 8];
int now, tot, i;
int byte, bit;
-#ifdef DEBUG2
+#ifdef timestr_debug
int y;
char *s;
char null[8];
memset(bitmap, 0, sizeof(bitmap));
week_fill(bitmap, tmstr);
-#ifdef DEBUG2
+#ifdef timestr_debug
memset(null, 0, 8);
for (i = 0; i < 7; i++) {
printf("%d: ", i);
while (1) {
byte = i / 8;
bit = i % 8;
- DEBUG2("READ: checking byte %d bit %d\n", byte, bit);
+ timestr_debug("READ: checking byte %d bit %d\n", byte, bit);
if (!(bitmap[byte] & (1 << bit)))
break;
tot += 60;