]> Joshua Wise's Git repositories - tdl.git/blob - tdl.h
Initial import of tdl-1.6-pre1
[tdl.git] / tdl.h
1 /*
2    $Header: /cvs/src/tdl/tdl.h,v 1.22.2.1 2004/01/07 00:09:05 richard Exp $
3   
4    tdl - A console program for managing to-do lists
5    Copyright (C) 2001-2004  Richard P. Curnow
6
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.
11
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.
16
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
20    */
21
22 #ifndef TDL_H
23 #define TDL_H
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <time.h>
29 #include <limits.h>
30
31 enum Priority {
32   PRI_UNKNOWN = 0,
33   PRI_VERYLOW = 1,
34   PRI_LOW     = 2,
35   PRI_NORMAL  = 3,
36   PRI_HIGH    = 4,
37   PRI_URGENT  = 5
38 };
39
40 /* Magic time_t value used in the 'done' field to signify an ignored item */
41 #define IGNORED_TIME 1
42
43 #define POSTPONED_TIME LONG_MAX
44
45 struct node;
46
47 struct links {
48   struct node *next;
49   struct node *prev;
50 };
51
52 struct node {
53   struct links chain;
54   struct links kids;
55   char *text;
56   struct node *parent;
57   enum Priority priority;
58   long arrived;
59   long required_by;
60   long done;
61   char *scratch; /* For functions to attach stuff to nodes */
62   int iscratch;  /* More scratch space */
63   char flag;
64 };
65
66 extern struct links top;
67
68 /* Memory macros */
69
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)))
75
76 typedef char** (*Completer)(char *, int);
77
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 */
91 };
92 /*}}}*/
93
94 extern struct command cmds[];
95 extern int n_cmds;
96
97 /* Function prototypes. */
98
99 /* In io.c */
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);
107
108 /* In list.c */
109 void do_indent(int indent);
110 void do_bullet_indent(int indent);
111 int process_list(char **x);
112
113 /* In report.c */
114 int process_report(char **x);
115 long read_interval(char *xx);
116
117 /* In util.c */
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);
130
131 /* In done.c */
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);
136
137 /* In add.c */
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);
144
145 /* In remove.c */
146 int process_remove(char **x);
147
148 /* In purge.c */
149 int process_purge(char **x);
150
151 /* In move.c */
152 int process_above(char **x);
153 int process_below(char **x);
154 int process_into(char **x);
155
156 /* In impexp.c */
157 int process_export(char **x);
158 int process_import(char **x);
159 int process_clone(char **x);
160 int process_copyto(char **x);
161
162 /* In dates.c */
163 time_t parse_date(char *d, time_t ref, int default_positive, int *error);
164
165 /* In main.c */
166 void dispatch(char **argv);
167 void free_database(struct links *x);
168 void load_database_if_not_loaded(void);
169
170 /* In inter.c */
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);
179
180 /* In narrow.c */
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);
185
186 #endif /* TDL_H */
187           
This page took 0.033827 seconds and 4 git commands to generate.