File: prerex.h

package info (click to toggle)
prerex 6.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 548 kB
  • sloc: ansic: 2,750; sh: 865; makefile: 14
file content (234 lines) | stat: -rw-r--r-- 7,086 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*  
  prerex.h  -- header file for an interactive editor of prerequisite-chart 
               descriptions
  Copyright (c) 2005-19  R. D. Tennent   
  School of Computing, Queen's University, rdt@cs.queensu.ca 

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

# include "config.h"
# include <stdlib.h>
# include <stdio.h>
# include <math.h>
# include <ctype.h>
# include <limits.h>
# include <string.h>
# ifdef HAVE_LIBREADLINE
# include <readline/readline.h>
# include <readline/history.h>
# else
# include <editline/readline.h>
# include <histedit.h>
# endif
# include <unistd.h>
# include <signal.h>
# include <unistd.h>
# include <sys/types.h>
# include <assert.h> 
# include <getopt.h>

# define bool    _Bool
# define true    1
# define false   0

# define LINE_LEN 1023
# define FILE_LEN 127
# define COMMAND_LEN 63
# define CODE_LEN 31
# define TITLE_LEN 127
# define TIMETABLE_LEN 31
# define COLOR_LEN 31

# define PRIVATE static

typedef int coord;

typedef struct point
{
  coord x, y;
} point;

typedef enum req_opt_type
{ NEITHER, REQ, OPT} req_opt_type;

typedef struct box
{
  bool half;
  req_opt_type req_opt;
  char title[TITLE_LEN + 1];
  char timetable[TIMETABLE_LEN + 1];
  char color[COLOR_LEN +1];  /* null string for default color */
} box;

typedef enum triv_type
{ TRIV } triv_type;

typedef struct mini
{
  triv_type t;
} mini;

typedef struct text
{
  char txt[LINE_LEN+1];
} text;

typedef char CourseCode[CODE_LEN + 1];
typedef enum node_type
{ BOX, MINI, TEXT } node_type;
typedef struct node
{
  point at;
  CourseCode code;
  node_type tag;
  union
  {
    box b;
    mini m;
    text t;
  } u;
} node;

typedef struct element *element_ptr;
typedef enum arrow_type
{ PREREQ, COREQ, RECOMM } arrow_type;
typedef struct arrow
{
  element_ptr source, target;
  bool DefaultCurvature;
  coord curvature;		
  arrow_type tag;
} arrow;

typedef enum element_type
{ NODE, ARROW } element_type;
typedef struct element
{
  element_ptr next;		/* to next element of linked list */
  element_type tag;
  union
  {
    node n;
    arrow a;
  } u;
} element;


typedef struct done *done_ptr;  /* declarations to support undo commands */
typedef enum done_type
{ 
  NODE_CREATE, NODE_EDIT, NODE_DELETE, NODE_SHIFT, NODE_RAISE,
  ARROW_CREATE, ARROW_EDIT, ARROW_DELETE,
  SHIFT_ALL, RAISE_ALL, CUT, PASTE,
  COMPOSITE 
} done_type;
typedef struct done
{
  done_ptr next;
  done_type tag;
  int i;
  node n;
  arrow a;
  point p;
  element_ptr e;
} done;
  

/******************************************************************************************/
/*                                                                                        */
/* defined in utils.c:                                                                    */
/*                                                                                        */
/******************************************************************************************/

extern size_t append (char *dst, char **offset, const char *src, size_t n);
/*  Copies src to *offset and updates *offset accordingly (if possible). 
 *  Assumes *offset is dst if offset == NULL.
 *  The src string must be null-terminated.
 *  Execution aborts unless **offset == '\0'. 
 *  Returns (original offset - dst) + strlen(src);  if >= n, the string was truncated.
 */

extern bool prefix (const char *cs, const char *ct); /* is string cs[] a prefix of ct[]?  */
extern bool suffix (const char *cs, const char *ct); /* is string cs[] a suffix of ct[]?  */

extern void error (char msg[]);	/* abort with stderr message msg */

extern void copy (FILE * f, FILE * g);

extern bool inrange ( coord x, coord x0, coord x1);
/* is coordinate x in the range x0:x1? */

/******************************************************************************************/
/*                                                                                        */
/* defined in prerex.c:                                                                   */
/*                                                                                        */
/******************************************************************************************/

# ifdef HAVE_LIBEDIT
extern EditLine *el;
extern History *hist;
extern HistEvent ev;
# endif

extern bool grid;       /* should the background grid be enabled? */
extern bool reprocess;  /* should the tex file be re-processed after the current command? */

extern char chartfilename[FILE_LEN];
extern char *chartfilename_n;
extern char backup_filename[FILE_LEN + 1];
extern char *backup_filename_n;

extern FILE *tex_file;
extern FILE *backup_tex_file;

extern void regenerate_and_process (void); /* internal rep. -> tex file -> pdf file  */

/******************************************************************************************/
/*                                                                                        */
/* defined in inout.c:                                                                    */
/*                                                                                        */
/******************************************************************************************/

extern element *first_node;
extern bool insert_node (element * pc);

extern element *first_arrow;
extern bool insert_arrow (element * pa);

extern bool eq (point p, point q);  /* p == q ? */

extern element *node_at (point p);

extern void analyze_tex_file (void);       /* tex file -> internal representation  */
extern void regenerate_tex_file (void);    /* internal representation -> tex file  */

extern void close_files (void);

/******************************************************************************************/
/*                                                                                        */
/* defined in edit.c:                                                                     */
/*                                                                                        */
/******************************************************************************************/

extern char deftext[LINE_LEN];		  /* buffer for default input */
# ifdef HAVE_LIBREADLINE
extern int set_deftext (void); /* used by readline to output defaults */
# else
extern char * prompt_f (void);            /* used to output prompts */
# endif
extern char * Readline ( char * str );

extern void process_commands (void);      /* command-processing loop  */