1 /*
2  *  ChkTeX, operating system specific code for ChkTeX.
3  *  Copyright (C) 1995-96 Jens T. Berger Thielemann
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU 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 02110-1301, USA.
18  *
19  *  Contact the author at:
20  *		Jens Berger
21  *		Spektrumvn. 4
22  *		N-0666 Oslo
23  *		Norway
24  *		E-mail: <jensthi@ifi.uio.no>
25  *
26  *
27  */
28 
29 #ifndef OPSYS_H
30 #define OPSYS_H
31 
32 #include "ChkTeX.h"
33 #include "Utility.h"
34 
35 /********************************************************************/
36 /**************** START OF USER SETTABLE PREFERENCES ****************/
37 
38 /*
39  * Note: This file contains most defines you'll wish to change if you
40  * wish to adopt ChkTeX to a new system. It is, as you might notice,
41  * heavily documented. If you wish to get into the internals of ChkTeX,
42  * the interesting stuff is at the bottom of this file, and in the .c
43  * files. However, you should also take a look at the "config.h.in" file
44  * in this directory if you haven't got a shell able to run the "configure"
45  * script.
46  *
47  * This program relies heavily on that the system which
48  * automagically free()'s all malloc()'ed memory, works. The program
49  * itself does not call free() very much. This is because we're doing
50  * lots of tiny allocations, and a properly designed pooling system will
51  * hopefully do a quicker job than we'll be able to do. So there.
52  *
53  * To keep things simple, we trust that the fclose()'ing of fopen()'ed
54  * also happens automagically.
55  *
56  * Please use the getopt included, as we will modify optarg during
57  * command processing.
58  *
59  * You may wish to modify the SetupVars() (OpSys.c) to better suit your
60  * preferences. In any case, it should put the filename (and full path)
61  * of the `.chktexrc' file into the ConfigFile array. The array is sized
62  * BUFSIZ bytes.
63  *
64  * The program does also assume that __unix__ is defined if the source is
65  * compiled on a UNIX machine.
66  *
67  */
68 
69 
70 /*  -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=-  */
71 
72 /*
73  * Here you should define what codes which should be returned to the
74  * shell upon success/failure.
75  *
76  */
77 
78 #ifndef EXIT_FAILURE
79 #    define  EXIT_FAILURE    1
80 #endif
81 
82 #ifndef EXIT_SUCCESS
83 #  define  EXIT_SUCCESS    0
84 #endif
85 
86 /*  -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=-  */
87 
88 /*
89  * SLASH should be defined to the character your computer uses to
90  * separate files/directories. Most systems use '/', messydos uses
91  * '\'.
92  *
93  * DIRCHARS should be defined to the characters a directory entry
94  * may end on. On Amigas, this is ":/" (either "FOO:BAR/" or "FOO:"),
95  * Unix uses only "/", while messydos uses ":\\".
96  *
97  * This data will be used to automatically concatenate a directory
98  * path and a filename.
99  *
100  * Adjust both to suit your needs.
101  */
102 
103 
104 #ifdef TEX_LIVE
105 #if defined(__MSDOS__) || defined(WIN32)
106 #  define SLASH   '\\'
107 #  define DIRCHARS ":\\"
108 #else
109 #  define  SLASH  '/'
110 #  define DIRCHARS "/"
111 #endif
112 #else /* TEX_LIVE */
113 #if defined(__unix__)
114 #  define  SLASH  '/'
115 #elif defined(__MSDOS__)
116 #  define SLASH   '\\'
117 #endif
118 
119 #if defined(__unix__)
120 #  define DIRCHARS "/"
121 #elif defined(__MSDOS__)
122 #  define DIRCHARS ":\\"
123 #endif
124 #endif /* TEX_LIVE */
125 
126 /*  -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=-  */
127 
128 /*
129  * Here, define what key-combination which is used to abort stdin
130  * keyboard input. It should be a string, as we we'll type it out as
131  * information to the user.
132  */
133 
134 #if defined(__unix__)
135 #  define STDIN_BREAK "Ctrl-D"
136 #elif defined(__MSDOS__)
137 #  define STDIN_BREAK "Ctrl-Z + Enter"
138 #else
139 #  define STDIN_BREAK "stdin break combination"
140 #endif
141 
142 /*  -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=-  */
143 
144 /*
145  * For fancy printing of commands, we'll use these strings to turn
146  * on/off the error indication. The codes listed here are ANSI
147  * compatible; if you don't have that type of terminal, you may wish
148  * to adjust this. Use "chktex -v2 Test.tex" to check the effects of
149  * these macros. Note: These strings will be printf()'ed, so watch your
150  * %'s.
151  *
152  * Under UNIX, we'll ignore these values and use termcap instead, where
153  * that is installed.
154  *
155  * If these strings can't be specified statically, you'll have to add
156  * code in the SetupTerm() function.
157  *
158  * PRE_ERROR_STR is of course printed in front of each location we
159  * wish to show as an error, and POST_ERROR_STR after each location.
160  *
161  * The codes #defined here, will switch back- and foreground colours.
162  * We're using '\033[' as escape character, some terminals may like
163  * '\233' better.
164  *
165  */
166 
167 #  define PRE_ERROR_STR   "\033[7m"
168 #  define POST_ERROR_STR  "\033[0m"
169 
170 
171 /*  -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=-  */
172 
173 /*
174  * This macro should contain the appendix for backup files, which
175  * will be appended onto the original filename. It should contain
176  * a leading dot.
177  */
178 
179 #ifdef __MSDOS__
180 #  define BAKAPPENDIX ".$cl"
181 #else
182 #  define BAKAPPENDIX ".bak"
183 #endif
184 
185 /***************** END OF USER SETTABLE PREFERENCES *****************/
186 /********************************************************************/
187 
188 #ifndef WORDLIST_DEFINED
189 struct WordList;
190 #endif
191 /* Sorry; there are now cyclic dependencies in the
192 * source tree. :-/
193 */
194 
195 extern const char *ReverseOn;
196 extern const char *ReverseOff;
197 extern char ConfigFile[BUFSIZ];
198 
199 char *MatchFileName(char *String);
200 int SetupVars(void);
201 void SetupTerm(void);
202 void AddAppendix(char *Name, const char *App);
203 void tackon(char *, const char *);
204 int LocateFile(const char *Filename, char *Dest, const char *App,
205                struct WordList *wl);
206 
207 #endif /* OPSYS_H */
208