2 $Header: /cvs/src/tdl/tdl.h,v 1.22.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
40 /* Magic time_t value used in the 'done' field to signify an ignored item */
41 #define IGNORED_TIME 1
43 #define POSTPONED_TIME LONG_MAX
57 enum Priority priority;
61 char *scratch; /* For functions to attach stuff to nodes */
62 int iscratch; /* More scratch space */
66 extern struct links top;
70 #define new_string(s) strcpy((char *) malloc(1+strlen(s)), (s))
71 #define extend_string(x,s) (strcat(realloc(x, (strlen(x)+strlen(s)+1)), s))
72 #define new(T) (T *) malloc(sizeof(T))
73 #define new_array(T, n) (T *) malloc(sizeof(T) * (n))
74 #define grow_array(T, n, oldX) (T *) ((oldX) ? realloc(oldX, (sizeof(T) * (n))) : malloc(sizeof(T) * (n)))
76 typedef char** (*Completer)(char *, int);
78 /* Command table (shared between dispatcher and readline completer) */
79 struct command {/*{{{*/
80 char *name; /* add, remove etc */
81 char *shortcut; /* tdla etc */
82 int (*func)(char **); /* ptr to function that actually does the work for this cmd */
83 char *descrip; /* One line description */
84 char *synopsis; /* Description of parameters */
85 char ** (*completer)(char *, int); /* Function to generate completions */
86 unsigned char dirty; /* 1 if operation can dirty the database, 0 if it leaves it clean */
87 unsigned char load_db; /* 1 if cmd requires current database to be loaded first */
88 unsigned char matchlen; /* number of characters to make command unambiguous */
89 unsigned char interactive_ok; /* 1 if OK to use interactively. */
90 unsigned char non_interactive_ok; /* 1 if OK to use from command line */
94 extern struct command cmds[];
97 /* Function prototypes. */
100 int read_database(FILE *in, struct links *to);
101 void write_database(FILE *out, struct links *from);
102 struct node *new_node(void);
103 void append_node(struct node *n, struct links *l);
104 void append_child(struct node *child, struct node *parent);
105 void clear_flags(struct links *x);
106 int has_kids(struct node *x);
109 void do_indent(int indent);
110 void do_bullet_indent(int indent);
111 int process_list(char **x);
114 int process_report(char **x);
115 long read_interval(char *xx);
118 int count_args(char **x);
119 int include_descendents(char *x);
120 struct node *lookup_node(char *path, int allow_zero_index, struct node **parent);
121 enum Priority parse_priority(char *priority, int *error);
122 void clear_flags(struct links *x);
123 void mark_all_descendents(struct node *n);
124 int has_kids(struct node *x);
125 struct node *new_node(void);
126 void free_node(struct node *x);
127 void append_node(struct node *n, struct links *l);
128 void prepend_node(struct node *n, struct links *l);
129 void prepend_child(struct node *child, struct node *parent);
132 int has_open_child(struct node *y);
133 int process_done(char **x);
134 int process_ignore(char **x);
135 int process_undo(char **x);
138 int process_add(char **x);
139 int process_log(char **x);
140 int process_edit(char **x);
141 int process_postpone(char **x);
142 int process_open(char **x);
143 int process_defer(char **x);
146 int process_remove(char **x);
149 int process_purge(char **x);
152 int process_above(char **x);
153 int process_below(char **x);
154 int process_into(char **x);
157 int process_export(char **x);
158 int process_import(char **x);
159 int process_clone(char **x);
160 int process_copyto(char **x);
163 time_t parse_date(char *d, time_t ref, int default_positive, int *error);
166 void dispatch(char **argv);
167 void free_database(struct links *x);
168 void load_database_if_not_loaded(void);
171 void interactive(void);
172 char *interactive_text(char *prompt, char *initval, int *is_blank, int *error);
173 char **complete_help(char *, int);
174 char **complete_list(char *, int);
175 char **complete_priority(char *, int);
176 char **complete_postpone(char *, int);
177 char **complete_open(char *, int);
178 char **complete_done(char *, int);
181 struct node *get_narrow_top(void);
182 char *get_narrow_prefix(void);
183 int process_narrow(char **x);
184 int process_widen(char **x);