| 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: <[email protected]> |
| 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 |
* BUFFER_SIZE 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 |
#define EXIT_WARNINGS 2 |
| 87 |
#define EXIT_ERRORS 3 |
| 88 |
|
| 89 |
/* -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- */ |
| 90 |
|
| 91 |
/* |
| 92 |
* SLASH should be defined to the character your computer uses to |
| 93 |
* separate files/directories. Most systems use '/', messydos uses |
| 94 |
* '\'. |
| 95 |
* |
| 96 |
* DIRCHARS should be defined to the characters a directory entry |
| 97 |
* may end on. On Amigas, this is ":/" (either "FOO:BAR/" or "FOO:"), |
| 98 |
* Unix uses only "/", while messydos uses ":\\". |
| 99 |
* |
| 100 |
* This data will be used to automatically concatenate a directory |
| 101 |
* path and a filename. |
| 102 |
* |
| 103 |
* Adjust both to suit your needs. |
| 104 |
*/ |
| 105 |
|
| 106 |
|
| 107 |
#ifdef TEX_LIVE |
| 108 |
#if defined(__MSDOS__) || defined(WIN32) |
| 109 |
# define SLASH '\\' |
| 110 |
# define DIRCHARS ":\\" |
| 111 |
#else |
| 112 |
# define SLASH '/' |
| 113 |
# define DIRCHARS "/" |
| 114 |
#endif |
| 115 |
#else /* TEX_LIVE */ |
| 116 |
#if defined(__unix__) |
| 117 |
# define SLASH '/' |
| 118 |
#elif defined(__MSDOS__) |
| 119 |
# define SLASH '\\' |
| 120 |
#endif |
| 121 |
|
| 122 |
#if defined(__unix__) |
| 123 |
# define DIRCHARS "/" |
| 124 |
#elif defined(__MSDOS__) |
| 125 |
# define DIRCHARS ":\\" |
| 126 |
#endif |
| 127 |
#endif /* TEX_LIVE */ |
| 128 |
|
| 129 |
/* -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- */ |
| 130 |
|
| 131 |
/* |
| 132 |
* Here, define what key-combination which is used to abort stdin |
| 133 |
* keyboard input. It should be a string, as we we'll type it out as |
| 134 |
* information to the user. |
| 135 |
*/ |
| 136 |
|
| 137 |
#if defined(__unix__) |
| 138 |
# define STDIN_BREAK "Ctrl-D" |
| 139 |
#elif defined(__MSDOS__) |
| 140 |
# define STDIN_BREAK "Ctrl-Z + Enter" |
| 141 |
#else |
| 142 |
# define STDIN_BREAK "stdin break combination" |
| 143 |
#endif |
| 144 |
|
| 145 |
/* -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- */ |
| 146 |
|
| 147 |
/* |
| 148 |
* For fancy printing of commands, we'll use these strings to turn |
| 149 |
* on/off the error indication. The codes listed here are ANSI |
| 150 |
* compatible; if you don't have that type of terminal, you may wish |
| 151 |
* to adjust this. Use "chktex -v2 Test.tex" to check the effects of |
| 152 |
* these macros. Note: These strings will be printf()'ed, so watch your |
| 153 |
* %'s. |
| 154 |
* |
| 155 |
* Under UNIX, we'll ignore these values and use termcap instead, where |
| 156 |
* that is installed. |
| 157 |
* |
| 158 |
* If these strings can't be specified statically, you'll have to add |
| 159 |
* code in the SetupTerm() function. |
| 160 |
* |
| 161 |
* PRE_ERROR_STR is of course printed in front of each location we |
| 162 |
* wish to show as an error, and POST_ERROR_STR after each location. |
| 163 |
* |
| 164 |
* The codes #defined here, will switch back- and foreground colours. |
| 165 |
* We're using '\033[' as escape character, some terminals may like |
| 166 |
* '\233' better. |
| 167 |
* |
| 168 |
*/ |
| 169 |
|
| 170 |
# define PRE_ERROR_STR "\033[7m" |
| 171 |
# define POST_ERROR_STR "\033[0m" |
| 172 |
|
| 173 |
|
| 174 |
/* -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- */ |
| 175 |
|
| 176 |
/* |
| 177 |
* This macro should contain the appendix for backup files, which |
| 178 |
* will be appended onto the original filename. It should contain |
| 179 |
* a leading dot. |
| 180 |
*/ |
| 181 |
|
| 182 |
#ifdef __MSDOS__ |
| 183 |
# define BAKAPPENDIX ".$cl" |
| 184 |
#else |
| 185 |
# define BAKAPPENDIX ".bak" |
| 186 |
#endif |
| 187 |
|
| 188 |
|
| 189 |
/* -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- */ |
| 190 |
|
| 191 |
/* |
| 192 |
* This defines the buffer size used in many places. The biggest |
| 193 |
* limitation imposed by a small buffer is the size of a line which |
| 194 |
* can be accurately processed by chktex. On the other hand, a large |
| 195 |
* buffer size will waste memory. However, memory is quite cheap |
| 196 |
* these days, especially considering the amount needed by ChkTeX. |
| 197 |
* |
| 198 |
* ChkTeX used to use BUFSIZ which was 1024 (fairly reasonable) on |
| 199 |
* many UNIX-like systems, but was much smaller on Windows. So, |
| 200 |
* instead we create our own buffer size and hope that no-one has |
| 201 |
* lines longer than 4k. |
| 202 |
* |
| 203 |
*/ |
| 204 |
|
| 205 |
#define BUFFER_SIZE 4096 |
| 206 |
|
| 207 |
|
| 208 |
/***************** END OF USER SETTABLE PREFERENCES *****************/ |
| 209 |
/********************************************************************/ |
| 210 |
|
| 211 |
#ifndef WORDLIST_DEFINED |
| 212 |
struct WordList; |
| 213 |
#endif |
| 214 |
/* Sorry; there are now cyclic dependencies in the |
| 215 |
* source tree. :-/ |
| 216 |
*/ |
| 217 |
|
| 218 |
extern const char *ReverseOn; |
| 219 |
extern const char *ReverseOff; |
| 220 |
extern char ConfigFile[BUFFER_SIZE]; |
| 221 |
extern struct WordList ConfigFiles; |
| 222 |
|
| 223 |
int SetupVars(void); |
| 224 |
void SetupTerm(void); |
| 225 |
void AddAppendix(char *Name, const char *App); |
| 226 |
void tackon(char *, const char *); |
| 227 |
int LocateFile(const char *Filename, char *Dest, const char *App, |
| 228 |
struct WordList *wl); |
| 229 |
|
| 230 |
void AddDirectoryFromRelativeFile(const char * Filename, struct WordList *TeXInputs); |
| 231 |
int IsRegFile(const char *Filename); |
| 232 |
|
| 233 |
#endif /* OPSYS_H */ |