]> Joshua Wise's Git repositories - tdl.git/blame - tdl.h
Initial import of tdl-1.6-pre1
[tdl.git] / tdl.h
CommitLineData
7024e37b
JW
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
31enum 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
45struct node;
46
47struct links {
48 struct node *next;
49 struct node *prev;
50};
51
52struct 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
66extern 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
76typedef char** (*Completer)(char *, int);
77
78/* Command table (shared between dispatcher and readline completer) */
79struct 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
94extern struct command cmds[];
95extern int n_cmds;
96
97/* Function prototypes. */
98
99/* In io.c */
100int read_database(FILE *in, struct links *to);
101void write_database(FILE *out, struct links *from);
102struct node *new_node(void);
103void append_node(struct node *n, struct links *l);
104void append_child(struct node *child, struct node *parent);
105void clear_flags(struct links *x);
106int has_kids(struct node *x);
107
108/* In list.c */
109void do_indent(int indent);
110void do_bullet_indent(int indent);
111int process_list(char **x);
112
113/* In report.c */
114int process_report(char **x);
115long read_interval(char *xx);
116
117/* In util.c */
118int count_args(char **x);
119int include_descendents(char *x);
120struct node *lookup_node(char *path, int allow_zero_index, struct node **parent);
121enum Priority parse_priority(char *priority, int *error);
122void clear_flags(struct links *x);
123void mark_all_descendents(struct node *n);
124int has_kids(struct node *x);
125struct node *new_node(void);
126void free_node(struct node *x);
127void append_node(struct node *n, struct links *l);
128void prepend_node(struct node *n, struct links *l);
129void prepend_child(struct node *child, struct node *parent);
130
131/* In done.c */
132int has_open_child(struct node *y);
133int process_done(char **x);
134int process_ignore(char **x);
135int process_undo(char **x);
136
137/* In add.c */
138int process_add(char **x);
139int process_log(char **x);
140int process_edit(char **x);
141int process_postpone(char **x);
142int process_open(char **x);
143int process_defer(char **x);
144
145/* In remove.c */
146int process_remove(char **x);
147
148/* In purge.c */
149int process_purge(char **x);
150
151/* In move.c */
152int process_above(char **x);
153int process_below(char **x);
154int process_into(char **x);
155
156/* In impexp.c */
157int process_export(char **x);
158int process_import(char **x);
159int process_clone(char **x);
160int process_copyto(char **x);
161
162/* In dates.c */
163time_t parse_date(char *d, time_t ref, int default_positive, int *error);
164
165/* In main.c */
166void dispatch(char **argv);
167void free_database(struct links *x);
168void load_database_if_not_loaded(void);
169
170/* In inter.c */
171void interactive(void);
172char *interactive_text(char *prompt, char *initval, int *is_blank, int *error);
173char **complete_help(char *, int);
174char **complete_list(char *, int);
175char **complete_priority(char *, int);
176char **complete_postpone(char *, int);
177char **complete_open(char *, int);
178char **complete_done(char *, int);
179
180/* In narrow.c */
181struct node *get_narrow_top(void);
182char *get_narrow_prefix(void);
183int process_narrow(char **x);
184int process_widen(char **x);
185
186#endif /* TDL_H */
187
This page took 0.03685 seconds and 4 git commands to generate.