| 1 |
% $Id: tex4ht-htcmd.tex 748 2020-06-29 22:18:30Z karl $ |
| 2 |
% tex tex4ht-htcmd |
| 3 |
% or ht tex tex4ht-htcmd |
| 4 |
% |
| 5 |
% htcmd is apparently not used for anything, but this .tex file is |
| 6 |
% preserved for history. |
| 7 |
% |
| 8 |
% htcmd OPTFLAG CMDLINE passed CMDLINE to system(), translating each |
| 9 |
% forward slash into a single or double backslash for OPTFLAG set to |
| 10 |
% -slash or -dslash respectively. |
| 11 |
% |
| 12 |
% Copyright 2009-2020 TeX Users Group |
| 13 |
% Copyright 1996-2009 Eitan M. Gurari |
| 14 |
% Released under LPPL 1.3c+. |
| 15 |
% See tex4ht-cpright.tex for license text. |
| 16 |
|
| 17 |
\input common |
| 18 |
\input tex4ht.sty |
| 19 |
|
| 20 |
\Preamble{xhtml,th4,sections+,xhtml}\EndPreamble |
| 21 |
|
| 22 |
\input ProTex.sty |
| 23 |
\AlProTex{c,<<<>>>,`,title,list,_^} |
| 24 |
|
| 25 |
%\input tex4ht-cpright.tex (see below) |
| 26 |
|
| 27 |
\Comment{ |
| 28 |
}{} |
| 29 |
\def\CodeId#1#2{} |
| 30 |
|
| 31 |
|
| 32 |
\def\UnderLine#1{\ifHtml |
| 33 |
\HCode{<strong>}#1\HCode{</strong>}\else\underbar{#1}\fi} |
| 34 |
\let\CModifyShowCode=\ModifyShowCode |
| 35 |
\let\CModifyOutputCode=\ModifyOutputCode |
| 36 |
\def\ModifyShowCode{\def\[##1({##1\UnderLine{(}}\def |
| 37 |
\;{\UnderLine{;}}\CModifyShowCode} |
| 38 |
\catcode`\^=7 \catcode`\@=6 \catcode`\#=12 \catcode`\^^M=13\relax% |
| 39 |
\def\ModifyOutputCode{% |
| 40 |
\def\;{ SEP }% |
| 41 |
\def\[@@1(@@2)@@3;{@@1 |
| 42 |
#ifdef ANSI |
| 43 |
#define SEP , |
| 44 |
(@@3) |
| 45 |
#undef SEP |
| 46 |
#else |
| 47 |
#define SEP ; |
| 48 |
(@@2)@@3; |
| 49 |
#undef SEP |
| 50 |
#endif |
| 51 |
}% |
| 52 |
\CModifyOutputCode}% |
| 53 |
\catcode`\^^M=5 \catcode`\@=12 \catcode`\#=6 \catcode`\^=13 |
| 54 |
|
| 55 |
|
| 56 |
\let\'=\Verb |
| 57 |
\def\`{\expandafter\expandafter\expandafter\qts\Verb} |
| 58 |
\def\qts#1{`#1\aftergroup'} |
| 59 |
|
| 60 |
\def\FTP{http://www.cse.ohio-state.edu/\string~gurari/tpf/} |
| 61 |
|
| 62 |
\input tex4ht-cpright |
| 63 |
|
| 64 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 65 |
|
| 66 |
|
| 67 |
\<htcmd.c\><<< |
| 68 |
/* htcmd.c (`version), generated from `jobname.tex |
| 69 |
Copyright 2009-2020 TeX Users Group |
| 70 |
Copyright `CopyYear.1996. Eitan M. Gurari |
| 71 |
`<TeX4ht copyright`> */ |
| 72 |
`<htcmd.h`> |
| 73 |
`<defines`> |
| 74 |
`<vars`> |
| 75 |
`<header functions`> |
| 76 |
`<functions`> |
| 77 |
`[ |
| 78 |
int `<CDECL`> main(argc, argv) |
| 79 |
int argc`; |
| 80 |
Q_CHAR **argv |
| 81 |
;{ `<main's vars`> |
| 82 |
`<set signals`> |
| 83 |
#ifdef PLATFORM |
| 84 |
(IGNORED) printf("htcmd.c (`version %s)\n",PLATFORM); |
| 85 |
#else |
| 86 |
(IGNORED) printf("htcmd.c (`version)\n"); |
| 87 |
#endif |
| 88 |
`<main's init`> |
| 89 |
`<command = job args`> |
| 90 |
`<make system call`> |
| 91 |
return 0; |
| 92 |
} |
| 93 |
>>> |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
\<htcmd.h\><<< |
| 98 |
/* ********************************************** |
| 99 |
Compiler options * |
| 100 |
(uncommented | command line) * |
| 101 |
------------------------------------------------* |
| 102 |
Clasic C (CC) default |
| 103 |
#define ANSI ansi-c, c++ |
| 104 |
#define DOS_C |
| 105 |
#define HAVE_STRING_H <string.h> |
| 106 |
#define HAVE_DIRENT_H <dirent.h> |
| 107 |
#define HAVE_SYS_NDIR_H <sys/ndir.h> |
| 108 |
#define HAVE_SYS_DIR_H <sys/dir.h> |
| 109 |
#define HAVE_NDIR_H <ndir.h> |
| 110 |
#define HAVE_IO_H <io.h> |
| 111 |
#define HAVE_UNISTD_H <unistd.h> |
| 112 |
#define WIN32 |
| 113 |
#define KPATHSEA |
| 114 |
#define SYSTEM_FUNCTION_OK |
| 115 |
#define CDECL .......... |
| 116 |
#define BCC32 bordland c++ |
| 117 |
|
| 118 |
************************************************* |
| 119 |
Tex4ht variables * |
| 120 |
(uncommented | command line) * |
| 121 |
----------------------------------------------- */ |
| 122 |
`<h-defines`> |
| 123 |
/* ******************************************** */ |
| 124 |
`<define MSVC-1-52`> |
| 125 |
`<bordland: bcc32 -DBCC32 htcmd`> |
| 126 |
`<bordland: bcc -DBCC tex4ht`> |
| 127 |
`<DJGPP`> |
| 128 |
#ifdef DOS_C |
| 129 |
#define DOS |
| 130 |
#endif |
| 131 |
#ifdef DOS |
| 132 |
#define DOS_WIN32 |
| 133 |
#ifndef HAVE_STRING_H |
| 134 |
#define HAVE_STRING_H |
| 135 |
#endif |
| 136 |
#endif |
| 137 |
#ifdef WIN32 |
| 138 |
#define DOS_WIN32 |
| 139 |
#endif |
| 140 |
`<h-defines DOS-WIN32`> |
| 141 |
`<h-defines KWIN32`> |
| 142 |
`<h-include`> |
| 143 |
`<h-defines 2`> |
| 144 |
>>> |
| 145 |
|
| 146 |
\<htcmd.h\><<< |
| 147 |
#ifdef DOS |
| 148 |
#define PROTOTYP |
| 149 |
#endif |
| 150 |
#ifdef ANSI |
| 151 |
#define PROTOTYP |
| 152 |
#endif |
| 153 |
#ifdef KWIN32 |
| 154 |
#define PROTOTYP |
| 155 |
#endif |
| 156 |
>>> |
| 157 |
|
| 158 |
|
| 159 |
\<htcmd.h\><<< |
| 160 |
#ifdef KPATHSEA |
| 161 |
#ifdef WIN32 |
| 162 |
#undef CDECL |
| 163 |
#define CDECL __cdecl |
| 164 |
#else |
| 165 |
#define CDECL |
| 166 |
#endif |
| 167 |
#endif |
| 168 |
>>> |
| 169 |
|
| 170 |
\<h-defines KWIN32\><<< |
| 171 |
#ifdef KPATHSEA |
| 172 |
#ifdef WIN32 |
| 173 |
#define KWIN32 |
| 174 |
#endif |
| 175 |
#endif |
| 176 |
>>> |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
\''open(file, ..._FLAGS)': All |
| 181 |
text files should be opened with "r" or "w"; all binary files with "rb" |
| 182 |
or "wb". This is the portable way and will work both under Unix and DOS; |
| 183 |
as Unix doesn't distinguish between text and binary files, its compilers |
| 184 |
will simply ignore the "b" part. |
| 185 |
|
| 186 |
On the subject of the .lg file: you open the tex4ht.env file in binary |
| 187 |
mode ("rb"), which results in strange line endings in the .lg file |
| 188 |
(CR/CR/LF). Changing the mode to "r" fixes this. |
| 189 |
|
| 190 |
|
| 191 |
\<htcmd.h\><<< |
| 192 |
#if defined(DOS_WIN32) || defined(__MSDOS__) |
| 193 |
#define READ_BIN_FLAGS "rb" |
| 194 |
#define READ_TEXT_FLAGS "r" |
| 195 |
#define WRITE_BIN_FLAGS "wb" |
| 196 |
#define WRITE_TEXT_FLAGS "w" |
| 197 |
#else |
| 198 |
#define READ_BIN_FLAGS "r" |
| 199 |
#define READ_TEXT_FLAGS "r" |
| 200 |
#define WRITE_BIN_FLAGS "w" |
| 201 |
#define WRITE_TEXT_FLAGS "w" |
| 202 |
#endif |
| 203 |
>>> |
| 204 |
|
| 205 |
\<defines\><<< |
| 206 |
#define Q_CHAR char |
| 207 |
#define U_CHAR char |
| 208 |
#define C_CHAR char |
| 209 |
#define Q_NULL (Q_CHAR *) 0 |
| 210 |
#define U_NULL (U_CHAR *) 0 |
| 211 |
#define C_NULL (C_CHAR *) 0 |
| 212 |
>>> |
| 213 |
|
| 214 |
|
| 215 |
\<defines\><<< |
| 216 |
#define IGNORED void |
| 217 |
>>> |
| 218 |
|
| 219 |
\<defines\><<< |
| 220 |
#ifndef EXIT_FAILURE |
| 221 |
#define EXIT_FAILURE 1 |
| 222 |
#endif |
| 223 |
>>> |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
\<defines\><<< |
| 228 |
#ifdef PROTOTYP |
| 229 |
#define VOID void |
| 230 |
#define ARG_I(x) x |
| 231 |
#define ARG_II(x,y) x,y |
| 232 |
#define ARG_III(x,y,z) x,y,z |
| 233 |
#define ARG_IV(x,y,z,w) x,y,z,w |
| 234 |
#define ARG_V(x,y,z,w,u) x,y,z,w,u |
| 235 |
#else |
| 236 |
#define VOID |
| 237 |
#define ARG_I(x) |
| 238 |
#define ARG_II(x,y) |
| 239 |
#define ARG_III(x,y,z) |
| 240 |
#define ARG_IV(x,y,z,w) |
| 241 |
#define ARG_V(x,y,z,w,u) |
| 242 |
#endif |
| 243 |
>>> |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
\<defines\><<< |
| 248 |
struct sys_call_rec{ |
| 249 |
Q_CHAR * filter; |
| 250 |
struct sys_call_rec *next; |
| 251 |
}; |
| 252 |
>>> |
| 253 |
|
| 254 |
|
| 255 |
\<vars\><<< |
| 256 |
static BOOL system_yes; |
| 257 |
>>> |
| 258 |
|
| 259 |
|
| 260 |
\<defines\><<< |
| 261 |
struct script_struct{ |
| 262 |
Q_CHAR *command; |
| 263 |
struct script_struct *next; |
| 264 |
}; |
| 265 |
>>> |
| 266 |
|
| 267 |
\<defines\><<< |
| 268 |
#define NULL_SCRIPT (struct script_struct *) 0 |
| 269 |
>>> |
| 270 |
|
| 271 |
|
| 272 |
\SubSection{Signals} |
| 273 |
|
| 274 |
\<h-include\><<< |
| 275 |
#include <signal.h> |
| 276 |
>>> |
| 277 |
|
| 278 |
\<header functions\><<< |
| 279 |
static void |
| 280 |
`<CDECL`> |
| 281 |
sig_err(ARG_I(int)); |
| 282 |
>>> |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
\<functions\><<< |
| 288 |
`[ |
| 289 |
static void |
| 290 |
`<CDECL`> |
| 291 |
sig_err(s) int s |
| 292 |
;{ |
| 293 |
(void) signal(s,SIG_IGN); `%ignore the signal`% |
| 294 |
switch( s ){ |
| 295 |
#ifdef SIGSEGV |
| 296 |
case SIGSEGV: err_i(2); |
| 297 |
#endif |
| 298 |
case SIGFPE : err_i(3); |
| 299 |
#if defined(SIGINT) && !defined(WIN32) |
| 300 |
case SIGINT : err_i(4); |
| 301 |
#endif |
| 302 |
} |
| 303 |
`<DJGPP signals`> |
| 304 |
} |
| 305 |
>>> |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
Forgetting \`'_pascal' and \`'_cdecl' modifiers: Each C function may |
| 311 |
be either \`'_pascal' or \`'_cdecl'. This modifier defines how |
| 312 |
parameters are passed to it. Default for Smalltalk definition is |
| 313 |
\`'_cdecl'. Default for C functions depends on compiler settings, and |
| 314 |
you can use other types uncompatible with Smalltalk. In Windows API |
| 315 |
16-bit functions are \`'_pascal' and 32-bit \`'_cdecl'. |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
\<CDECL\><<< |
| 320 |
#ifdef CDECL |
| 321 |
CDECL |
| 322 |
#endif |
| 323 |
>>> |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
\<set signals\><<< |
| 329 |
|
| 330 |
#ifdef SIGSEGV |
| 331 |
(void) signal(SIGSEGV,sig_err); |
| 332 |
#endif |
| 333 |
(void) signal(SIGFPE,sig_err); |
| 334 |
#ifdef KWIN32 |
| 335 |
`<KWIN32 signals`> |
| 336 |
#else |
| 337 |
#ifdef SIGINT |
| 338 |
(void) signal(SIGINT,sig_err); `%Control-c, user interrupt`% |
| 339 |
#endif |
| 340 |
#endif |
| 341 |
>>> |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
SIGFPE is handled by the C library, SIGSEGV too but not generated by |
| 346 |
the system, so it does nothing but is harmless |
| 347 |
|
| 348 |
SetConsoleCtrlHandler is need to catch Ctrl+C and Ctrl+Break under |
| 349 |
Windows, SIGINT is not generated by the system. |
| 350 |
|
| 351 |
\<KWIN32 signals\><<< |
| 352 |
SetConsoleCtrlHandler((PHANDLER_ROUTINE)sigint_handler, TRUE); |
| 353 |
>>> |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
SIGSEGV, SIGILL, SIGTERM not implemented in MS-DOS. They are supplied just for |
| 358 |
compatibility. Looks like that SIGINT is defined for windows but not for dos. |
| 359 |
|
| 360 |
\<vars\><<< |
| 361 |
static int system_return; |
| 362 |
>>> |
| 363 |
|
| 364 |
\<main's vars\><<< |
| 365 |
int i; |
| 366 |
BOOL slash, dslash; |
| 367 |
char *in_command, *command, *p, *q; |
| 368 |
>>> |
| 369 |
|
| 370 |
\<command = job args\><<< |
| 371 |
in_command = (char *) malloc(1024); |
| 372 |
command = (char *) malloc(1024); |
| 373 |
in_command[0] = '\0'; |
| 374 |
`<kpathsea arg 0`> |
| 375 |
if( argc == 1 ){ bad_arg; } |
| 376 |
slash = eq_str(argv[1],"-slash") ; |
| 377 |
dslash = eq_str(argv[1],"-dslash") ; |
| 378 |
for(i=1+slash+dslash; i<argc; i++){ |
| 379 |
(IGNORED) printf("%s ", argv[i]); |
| 380 |
(IGNORED) strct(in_command,argv[i]); |
| 381 |
(IGNORED) strct(in_command," "); |
| 382 |
} |
| 383 |
(IGNORED) printf("\n"); |
| 384 |
>>> |
| 385 |
|
| 386 |
|
| 387 |
\<make system call\><<< |
| 388 |
p = in_command; |
| 389 |
q = command; |
| 390 |
do{ |
| 391 |
if( (*p != '"' ) && (*p != '\'' ) && (*p != '``' ) ){ |
| 392 |
if(slash && (*p == '/')) { |
| 393 |
*(q++) = '\\'; |
| 394 |
} |
| 395 |
else if(dslash && (*p == '/')) { |
| 396 |
*(q++) = '\\'; |
| 397 |
*(q++) = '\\'; |
| 398 |
} |
| 399 |
else { *(q++) = *p; } |
| 400 |
} |
| 401 |
} while (*(p++) != '\0'); |
| 402 |
(IGNORED) call_sys(command); |
| 403 |
>>> |
| 404 |
|
| 405 |
|
| 406 |
\SubSection{PreProcessor Directives} |
| 407 |
|
| 408 |
|
| 409 |
Symantec C++ for wid95: |
| 410 |
\''sc htcmd.c -mn -o+time -WA -3 -a8 -c -D_CONSOLE=1 -ohtcmd.obj' |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
\<bordland: bcc32 -DBCC32 htcmd\><<< |
| 418 |
#ifdef BCC32 |
| 419 |
#define WIN32 |
| 420 |
#define ANSI |
| 421 |
#define HAVE_IO_H |
| 422 |
#define HAVE_STRING_H |
| 423 |
#define PLATFORM "ms-win32" |
| 424 |
#endif |
| 425 |
>>> |
| 426 |
|
| 427 |
% |
| 428 |
|
| 429 |
\<bordland: bcc -DBCC tex4ht\><<< |
| 430 |
#ifdef BCC |
| 431 |
#define DOS_C |
| 432 |
#define ANSI |
| 433 |
#define HAVE_IO_H |
| 434 |
#define PLATFORM "ms-dos" |
| 435 |
#endif |
| 436 |
>>> |
| 437 |
|
| 438 |
|
| 439 |
\<h-include\><<< |
| 440 |
#include <stdio.h> `% EOF, FILE `% |
| 441 |
#include <stdlib.h> `% EXIT_FAILURE `% |
| 442 |
>>> |
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
Under ANSI C, all malloc stuff is declared in \`'<stdlib.h>' (which you |
| 447 |
also include), hence this non-standard header is redundant. |
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
\<h-include\><<< |
| 454 |
#ifdef HAVE_STRING_H |
| 455 |
#include <string.h> |
| 456 |
#endif |
| 457 |
>>> |
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
\<h-defines DOS-WIN32\><<< |
| 465 |
#ifdef DOS_WIN32 |
| 466 |
#define STRUCT_DIRENT |
| 467 |
#endif |
| 468 |
>>> |
| 469 |
|
| 470 |
|
| 471 |
\<h-include\><<< |
| 472 |
#ifdef HAVE_DIRENT_H |
| 473 |
`<needs dirent.h`> |
| 474 |
#else |
| 475 |
#ifndef STRUCT_DIRENT |
| 476 |
#define STRUCT_DIRECT |
| 477 |
#endif |
| 478 |
`<needs simulated dirent.h`> |
| 479 |
#endif |
| 480 |
>>> |
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
\<needs dirent.h\><<< |
| 485 |
#include <dirent.h> |
| 486 |
>>> |
| 487 |
|
| 488 |
|
| 489 |
\<needs simulated dirent.h\><<< |
| 490 |
#ifdef HAVE_SYS_NDIR_H |
| 491 |
#include <sys/ndir.h> |
| 492 |
#endif |
| 493 |
#ifdef HAVE_SYS_DIR_H |
| 494 |
#include <sys/dir.h> |
| 495 |
#endif |
| 496 |
#ifdef HAVE_NDIR_H |
| 497 |
#include <ndir.h> |
| 498 |
#endif |
| 499 |
>>> |
| 500 |
|
| 501 |
|
| 502 |
REPLACE EXIT with somthing that DOS also accept. |
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
\SubSection{KPATHSEA} |
| 511 |
|
| 512 |
\<h-defines 2NO\><<< |
| 513 |
`<h-include before KPATHSEA`> |
| 514 |
#ifdef KPATHSEA |
| 515 |
#ifndef HAVE_STRCHR |
| 516 |
#define strchr index |
| 517 |
#endif |
| 518 |
#ifndef HAVE_STRRCHR |
| 519 |
#define strrchr rindex |
| 520 |
#endif |
| 521 |
#include <kpathsea/config.h> |
| 522 |
#include <kpathsea/c-errno.h> |
| 523 |
#include <kpathsea/c-ctype.h> |
| 524 |
#include <kpathsea/c-fopen.h> |
| 525 |
#include <kpathsea/c-pathmx.h> |
| 526 |
#include <kpathsea/proginit.h> |
| 527 |
#include <kpathsea/tex-file.h> |
| 528 |
#include <kpathsea/tex-make.h> |
| 529 |
#include <signal.h> |
| 530 |
#if !defined(_AMIGA) && !defined(WIN32) |
| 531 |
#include <sys/time.h> |
| 532 |
#endif |
| 533 |
#include <fcntl.h> |
| 534 |
#include <setjmp.h> |
| 535 |
#endif `%/* KPATHSEA */`% |
| 536 |
`<h-include after KPATHSEA`> |
| 537 |
>>> |
| 538 |
|
| 539 |
\<h-defines 2\><<< |
| 540 |
`<h-include before KPATHSEA`> |
| 541 |
#ifdef KPATHSEA |
| 542 |
#include <kpathsea/config.h> |
| 543 |
#include <kpathsea/c-errno.h> |
| 544 |
#include <kpathsea/c-ctype.h> |
| 545 |
#include <kpathsea/c-fopen.h> |
| 546 |
#include <kpathsea/c-pathmx.h> |
| 547 |
#include <kpathsea/proginit.h> |
| 548 |
#include <kpathsea/tex-file.h> |
| 549 |
#include <kpathsea/tex-make.h> |
| 550 |
#include <signal.h> |
| 551 |
#if !defined(_AMIGA) && !defined(WIN32) |
| 552 |
#include <sys/time.h> |
| 553 |
#endif |
| 554 |
#include <fcntl.h> |
| 555 |
#include <setjmp.h> |
| 556 |
#endif `%/* KPATHSEA */`% |
| 557 |
`<h-include after KPATHSEA`> |
| 558 |
>>> |
| 559 |
|
| 560 |
|
| 561 |
The \`'__cdecl' is defined in KPATHSEA: kpathsea/c-protos.h |
| 562 |
is defined to nothing for compilers |
| 563 |
other than MS. |
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
\<DJGPP\><<< |
| 572 |
#ifdef __DJGPP__ |
| 573 |
#define DOS_WIN32 |
| 574 |
#define ANSI |
| 575 |
#endif |
| 576 |
>>> |
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
\<DJGPP signals\><<< |
| 582 |
#ifdef __DJGPP__ |
| 583 |
if (s != SIGINT && s != SIGQUIT) |
| 584 |
exit(EXIT_FAILURE); |
| 585 |
#endif |
| 586 |
>>> |
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
\<h-include before KPATHSEA\><<< |
| 591 |
#ifndef __DJGPP__ |
| 592 |
`<h-include near KPATHSEA`> |
| 593 |
#endif |
| 594 |
>>> |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
The following is because \`'<unistd.h> |
| 599 |
defines F_OK in DJGPP'. |
| 600 |
|
| 601 |
\<h-include after KPATHSEA\><<< |
| 602 |
#ifdef __DJGPP__ |
| 603 |
`<h-include near KPATHSEA`> |
| 604 |
#endif |
| 605 |
>>> |
| 606 |
|
| 607 |
\<h-include near KPATHSEANO\><<< |
| 608 |
#ifndef F_OK |
| 609 |
#ifdef DOS_WIN32 |
| 610 |
#define F_OK 0 `% does file exist `% |
| 611 |
#endif |
| 612 |
#ifndef DOS_WIN32 |
| 613 |
#define HAVE_UNISTD_H |
| 614 |
#endif |
| 615 |
#endif |
| 616 |
#ifdef HAVE_IO_H |
| 617 |
#include <io.h> |
| 618 |
#endif |
| 619 |
#ifdef HAVE_UNISTD_H |
| 620 |
#include <unistd.h> |
| 621 |
#endif |
| 622 |
>>> |
| 623 |
|
| 624 |
\<h-include near KPATHSEA\><<< |
| 625 |
#ifndef F_OK |
| 626 |
#ifdef DOS_WIN32 |
| 627 |
#define F_OK 0 `% does file exist `% |
| 628 |
#endif |
| 629 |
#ifndef KPATHSEA |
| 630 |
#ifndef DOS_WIN32 |
| 631 |
#define HAVE_UNISTD_H |
| 632 |
#endif |
| 633 |
#endif |
| 634 |
#endif |
| 635 |
#ifdef HAVE_IO_H |
| 636 |
#include <io.h> |
| 637 |
#endif |
| 638 |
#ifndef KPATHSEA |
| 639 |
#ifdef HAVE_UNISTD_H |
| 640 |
#include <unistd.h> |
| 641 |
#endif |
| 642 |
#endif |
| 643 |
>>> |
| 644 |
|
| 645 |
|
| 646 |
\<defines\><<< |
| 647 |
#ifndef TRUE |
| 648 |
#define TRUE 1 |
| 649 |
#endif |
| 650 |
#ifndef FALSE |
| 651 |
#define FALSE 0 |
| 652 |
#endif |
| 653 |
#ifndef BOOL |
| 654 |
#define BOOL int |
| 655 |
#endif |
| 656 |
>>> |
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
\<defines\><<< |
| 662 |
#define bad_arg err_arg(0) |
| 663 |
#define bad_mem err_i(1) |
| 664 |
>>> |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
\<header functions\><<< |
| 672 |
static void err_i( ARG_I(int) ); |
| 673 |
>>> |
| 674 |
|
| 675 |
\<functions\><<< |
| 676 |
`[ |
| 677 |
static void err_i(n) int n |
| 678 |
|
| 679 |
;{ (IGNORED) fprintf(stderr,"--- error --- "); |
| 680 |
(IGNORED) fprintf(stderr, "%s", warn_err_mssg[n]); |
| 681 |
exit(EXIT_FAILURE); |
| 682 |
} |
| 683 |
>>> |
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
\<header functions\><<< |
| 688 |
static void err_arg( ARG_I(int) ); |
| 689 |
>>> |
| 690 |
|
| 691 |
\<functions\><<< |
| 692 |
`[ |
| 693 |
static void err_arg(n) int n |
| 694 |
|
| 695 |
;{ (IGNORED) fprintf(stderr,"--- error --- "); |
| 696 |
(IGNORED) fprintf(stderr, "%s", warn_err_mssg[n]); |
| 697 |
exit(EXIT_FAILURE); |
| 698 |
} |
| 699 |
>>> |
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
\<vars\><<< |
| 704 |
static C_CHAR *warn_err_mssg[]={ `<warn and err messages`> "" }; |
| 705 |
>>> |
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
\<warn and err messages\><<< |
| 710 |
"\n---------------------------------------------------------------\n\ |
| 711 |
htcmd optional-flag command-line\n\n\ |
| 712 |
optional-flag:\n\ |
| 713 |
-slash translate '/' into '\\'\n\ |
| 714 |
-dslash translate '/' into '\\\\'\n\n\ |
| 715 |
Example: \n\ |
| 716 |
htcmd t4ht name -d/WWW/temp/ -etex4ht-32.env -m644\n\ |
| 717 |
---------------------------------------------------------------\n" |
| 718 |
>>> |
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
\<system exist?\><<< |
| 725 |
#ifdef SYSTEM_FUNCTION_OK |
| 726 |
0 |
| 727 |
#else |
| 728 |
system( yes ) != 0 |
| 729 |
#endif |
| 730 |
>>> |
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
\<header functions\><<< |
| 740 |
static void call_sys(ARG_I(Q_CHAR *)); |
| 741 |
>>> |
| 742 |
|
| 743 |
\<functions\><<< |
| 744 |
`[ |
| 745 |
static void call_sys(command) Q_CHAR * command |
| 746 |
;{ |
| 747 |
if( *command ){ |
| 748 |
(IGNORED) printf("htcmd calls: %s\n", command); |
| 749 |
system_return = system_yes? (int) system(command) : -1; |
| 750 |
(IGNORED) printf("%shtcmd returns: %d\n", |
| 751 |
system_return? "--- Warning --- " : "", system_return ); |
| 752 |
} |
| 753 |
} |
| 754 |
>>> |
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
strcat should be in string.h, but c++ doesn't find it there. |
| 761 |
We use it just for concatenating an extension of |
| 762 |
file name. Should have the interface |
| 763 |
\`'char *strcat( ARG_II(C_CHAR *, const Q_CHAR *) );'. |
| 764 |
|
| 765 |
\<header functions\><<< |
| 766 |
static void strct( ARG_II(C_CHAR *, C_CHAR *) ); |
| 767 |
>>> |
| 768 |
|
| 769 |
\<functions\><<< |
| 770 |
`[ |
| 771 |
static void strct( str1, str2 ) |
| 772 |
Q_CHAR * str1`; |
| 773 |
Q_CHAR * str2 |
| 774 |
|
| 775 |
;{ Q_CHAR * ch; |
| 776 |
ch = str1 + (int) strlen(str1); |
| 777 |
(IGNORED) strcpy( ch, str2 ); |
| 778 |
} |
| 779 |
>>> |
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
\<main's init\><<< |
| 784 |
{ C_CHAR *yes = NULL; |
| 785 |
system_yes = (`<system exist?`>); |
| 786 |
} |
| 787 |
>>> |
| 788 |
|
| 789 |
\<defines\><<< |
| 790 |
#define eq_str(x,y) (!strcmp(x,y)) |
| 791 |
>>> |
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
%---------------------------------------------------- |
| 799 |
|
| 800 |
\OutputCodE\<htcmd.c\> |
| 801 |
|
| 802 |
|
| 803 |
\bye |