]> Joshua Wise's Git repositories - tdl.git/blob - tdl.h
Fall back on index for sort if the due date is the same, not just if both due dates...
[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   int idx; /* Keep your number, even after having been sorted. */
64   char flag;
65 };
66
67 extern struct links top;
68
69 /* Memory macros */
70
71 #define new_string(s) strcpy((char *) malloc(1+strlen(s)), (s))
72 #define extend_string(x,s) (strcat(realloc(x, (strlen(x)+strlen(s)+1)), s))
73 #define new(T) (T *) malloc(sizeof(T))
74 #define new_array(T, n) (T *) malloc(sizeof(T) * (n))
75 #define grow_array(T, n, oldX) (T *) ((oldX) ? realloc(oldX, (sizeof(T) * (n))) : malloc(sizeof(T) * (n)))
76
77 typedef char** (*Completer)(char *, int);
78
79 /* Command table (shared between dispatcher and readline completer) */
80 struct command {/*{{{*/
81   char *name; /* add, remove etc */
82   char *shortcut; /* tdla etc */
83   int (*func)(char **); /* ptr to function that actually does the work for this cmd */
84   char *descrip; /* One line description */
85   char *synopsis; /* Description of parameters */
86   char ** (*completer)(char *, int); /* Function to generate completions */
87   unsigned char  dirty; /* 1 if operation can dirty the database, 0 if it leaves it clean */
88   unsigned char  load_db; /* 1 if cmd requires current database to be loaded first */
89   unsigned char  matchlen; /* number of characters to make command unambiguous */
90   unsigned char  interactive_ok; /* 1 if OK to use interactively. */
91   unsigned char  non_interactive_ok; /* 1 if OK to use from command line */
92 };
93 /*}}}*/
94
95 extern struct command cmds[];
96 extern int n_cmds;
97
98 /* Function prototypes. */
99
100 /* In io.c */
101 int read_database(FILE *in, struct links *to);
102 void write_database(FILE *out, struct links *from);
103 struct node *new_node(void);
104 void append_node(struct node *n, struct links *l);
105 void append_child(struct node *child, struct node *parent);
106 void clear_flags(struct links *x);
107 int has_kids(struct node *x);
108
109 /* In list.c */
110 void do_indent(int indent);
111 void do_bullet_indent(int indent);
112 int process_list(char **x);
113
114 /* In report.c */
115 int process_report(char **x);
116 long read_interval(char *xx);
117
118 /* In util.c */
119 int count_args(char **x);
120 int include_descendents(char *x);
121 struct node *lookup_node(char *path, int allow_zero_index, struct node **parent);
122 enum Priority parse_priority(char *priority, int *error);
123 void clear_flags(struct links *x);
124 void mark_all_descendents(struct node *n);
125 int has_kids(struct node *x);
126 struct node *new_node(void);
127 void free_node(struct node *x);
128 void append_node(struct node *n, struct links *l);
129 void prepend_node(struct node *n, struct links *l);
130 void prepend_child(struct node *child, struct node *parent);
131
132 /* In done.c */
133 int has_open_child(struct node *y);
134 int process_done(char **x);
135 int process_ignore(char **x);
136 int process_undo(char **x);
137
138 /* In add.c */
139 int process_add(char **x);
140 int process_log(char **x);
141 int process_edit(char **x);
142 int process_postpone(char **x);
143 int process_open(char **x);
144 int process_defer(char **x);
145
146 /* In remove.c */
147 int process_remove(char **x);
148
149 /* In purge.c */
150 int process_purge(char **x);
151
152 /* In move.c */
153 int process_above(char **x);
154 int process_below(char **x);
155 int process_into(char **x);
156
157 /* In impexp.c */
158 int process_export(char **x);
159 int process_import(char **x);
160 int process_clone(char **x);
161 int process_copyto(char **x);
162
163 /* In dates.c */
164 time_t parse_date(char *d, time_t ref, int default_positive, int *error);
165
166 /* In main.c */
167 void dispatch(char **argv);
168 void free_database(struct links *x);
169 void load_database_if_not_loaded(void);
170
171 /* In inter.c */
172 void interactive(void);
173 char *interactive_text(char *prompt, char *initval, int *is_blank, int *error);
174 char **complete_help(char *, int);
175 char **complete_list(char *, int);
176 char **complete_priority(char *, int);
177 char **complete_postpone(char *, int);
178 char **complete_open(char *, int);
179 char **complete_done(char *, int);
180
181 /* In narrow.c */
182 struct node *get_narrow_top(void);
183 char *get_narrow_prefix(void);
184 int process_narrow(char **x);
185 int process_widen(char **x);
186
187 #endif /* TDL_H */
188           
This page took 0.034762 seconds and 4 git commands to generate.