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