2 $Header: /cvs/src/tdl/report.c,v 1.5.2.1 2004/01/07 00:09:05 richard Exp $
4 tdl - A console program for managing to-do lists
5 Copyright (C) 2001-2004 Richard P. Curnow
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
25 static int mark_nodes_done_since(struct links *x, time_t start, time_t end)/*{{{*/
30 for (y = x->next; y != (struct node *) x; y = y->chain.next) {
31 if ((y->done >= start) && (y->done <= end)) {
37 if (mark_nodes_done_since(&y->kids, start, end)) {
46 static void print_report(struct links *x, int indent)/*{{{*/
51 for (y = x->next; y != (struct node *) x; y = y->chain.next) {
53 do_bullet_indent(indent+2);
54 if (!y->done) printf ("[[");
55 for (p = y->text; *p; p++) {
58 do_indent(indent + 2);
61 if (!y->done) printf ("]]");
65 print_report(&y->kids, indent + 3);
71 int process_report(char **x)/*{{{*/
73 time_t now, start, end;
79 start = end = now = time(NULL);
85 start = parse_date(d0, now, 0, &error);
86 if (error < 0) return error;
93 start = parse_date(d0, now, 0, &error);
94 if (error < 0) return error;
95 end = parse_date(d1, now, 0, &error);
96 if (error < 0) return error;
99 fprintf(stderr, "Usage: report <start_epoch> [<end_epoch>]\n");
104 mark_nodes_done_since(&top, start, end);
105 print_report(&top, 0);