Added coefficient-handling routines
[pspp-builds.git] / src / getl.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #if !getl_h
21 #define getl_h 1
22
23 #include <stdbool.h>
24 #include <stdio.h>
25
26 /* Defines a list of lines used by DO REPEAT. */
27 /* Special case: if LEN is negative then it is a line number; in this
28    case LINE is a file name.  This is used to allow errors to be
29    reported for the correct file and line number when DO REPEAT spans
30    files. */
31 struct getl_line_list
32   {
33     char *line;                         /* Line contents. */
34     int len;                            /* Line length. */
35     struct getl_line_list *next;        /* Next line. */
36   };
37
38 /* Source file. */
39 struct getl_script
40   {
41     struct getl_script *included_from;  /* File that this is nested inside. */
42     struct getl_script *includes;       /* File nested inside this file. */
43     struct getl_script *next;           /* Next file in list. */
44     char *fn;                           /* Filename. */
45     int ln;                             /* Line number. */
46     int separate;                       /* !=0 means this is a separate job. */
47     FILE *f;                            /* File handle. */
48
49     /* Used only if F is NULL.  Used for DO REPEAT. */
50     struct getl_line_list *first_line;  /* First line in line buffer. */
51     struct getl_line_list *cur_line;    /* Current line in line buffer. */
52     int remaining_loops;                /* Number of remaining loops through LINES. */
53     int loop_index;                     /* Number of loops through LINES so far. */
54     void *macros;                       /* Pointer to macro table. */
55     int print;                          /* 1=Print lines as executed. */
56   };
57
58 /* List of script files. */
59 extern struct getl_script *getl_head;   /* Current file. */
60 extern struct getl_script *getl_tail;   /* End of list. */
61
62 /* If getl_head==0 and getl_interactive!=0, lines will be read from
63    the console rather than terminating. */
64 extern int getl_interactive;
65
66 /* 1=the welcome message has been printed. */
67 extern int getl_welcomed;
68
69 /* Prompt styles. */
70 enum
71   {
72     GETL_PRPT_STANDARD,         /* Just asks for a command. */
73     GETL_PRPT_CONTINUATION,     /* Continuation lines for a single command. */
74     GETL_PRPT_DATA              /* Between BEGIN DATA and END DATA. */
75   };
76
77 /* Current mode. */
78 enum
79   {
80     GETL_MODE_BATCH,            /* Batch mode. */
81     GETL_MODE_INTERACTIVE       /* Interactive mode. */
82   };
83
84 /* One of GETL_MODE_*, representing the current mode. */
85 extern int getl_mode;
86
87 /* Current prompting style: one of GETL_PRPT_*. */
88 extern int getl_prompt;
89
90 /* Are we reading a script? Are we interactive? */
91 #define getl_am_interactive (getl_head == NULL)
92
93 bool getl_reading_script (void);
94
95 /* Current line.  This line may be modified by modules other than
96    getl.c, and by lexer.c in particular. */
97 extern struct string getl_buf;
98
99 /* Name of the command history file. */
100 #if HAVE_LIBREADLINE && HAVE_LIBHISTORY
101 extern char *getl_history;
102 #endif
103
104 void getl_initialize (void);
105 void getl_uninitialize (void);
106 void getl_clear_include_path (void);
107 char *getl_get_current_directory (void);
108 void getl_add_include_dir (const char *);
109 void getl_add_file (const char *fn, int separate, int where);
110 void getl_include (const char *fn);
111 int getl_read_line (void);
112 void getl_close_file (void);
113 void getl_close_all (void);
114 int getl_perform_delayed_reset (void);
115 void getl_add_DO_REPEAT_file (struct getl_script *);
116 void getl_add_virtual_file (struct getl_script *);
117 void getl_location (const char **, int *);
118 int getl_handle_line_buffer (void);
119
120 bool getl_is_separate(void);
121
122 void getl_set_separate(bool sep);
123
124
125 #endif /* getl_h */