2
/**********************************************************/
3
/* htcmd.c 2004-12-16-16:20 */
4
/* Copyright (C) 1996--2004 Eitan M. Gurari */
6
/* This work may be distributed and/or modified under the */
7
/* conditions of the LaTeX Project Public License, either */
8
/* version 1.3 of this license or (at your option) any */
9
/* later version. The latest version of this license is */
11
/* http://www.latex-project.org/lppl.txt */
12
/* and version 1.3 or later is part of all distributions */
13
/* of LaTeX version 2003/12/01 or later. */
15
/* This work has the LPPL maintenance status "maintained".*/
17
/* This Current Maintainer of this work */
18
/* is Eitan M. Gurari. */
20
/* However, you are allowed to modify this program */
21
/* without changing its name, if you modify its */
22
/* signature. Changes to the signature can be */
23
/* introduced with a directive of the form */
24
/* #define PLATFORM "signature" */
26
/* gurari@cse.ohio-state.edu */
27
/* http://www.cse.ohio-state.edu/~gurari */
28
/**********************************************************/
30
/* **********************************************
32
(uncommented | command line) *
33
------------------------------------------------*
35
#define ANSI ansi-c, c++
37
#define HAVE_STRING_H <string.h>
38
#define HAVE_DIRENT_H <dirent.h>
39
#define HAVE_SYS_NDIR_H <sys/ndir.h>
40
#define HAVE_SYS_DIR_H <sys/dir.h>
41
#define HAVE_NDIR_H <ndir.h>
42
#define HAVE_IO_H <io.h>
43
#define HAVE_UNISTD_H <unistd.h>
46
#define SYSTEM_FUNCTION_OK
47
#define CDECL ..........
48
#define BCC32 bordland c++
50
*************************************************
52
(uncommented | command line) *
53
----------------------------------------------- */
55
/* ******************************************** */
63
#define PLATFORM "ms-win32"
72
#define PLATFORM "ms-dos"
128
#ifndef STRUCT_DIRENT
129
#define STRUCT_DIRECT
132
#ifdef HAVE_SYS_NDIR_H
133
#include <sys/ndir.h>
135
#ifdef HAVE_SYS_DIR_H
156
#define HAVE_UNISTD_H
174
#include <kpathsea/config.h>
175
#include <kpathsea/c-errno.h>
176
#include <kpathsea/c-ctype.h>
177
#include <kpathsea/c-fopen.h>
178
#include <kpathsea/c-pathmx.h>
179
#include <kpathsea/proginit.h>
180
#include <kpathsea/tex-file.h>
181
#include <kpathsea/tex-make.h>
183
#if !defined(_AMIGA) && !defined(WIN32)
184
#include <sys/time.h>
198
#define HAVE_UNISTD_H
233
#define CDECL __cdecl
240
#if defined(DOS_WIN32) || defined(__MSDOS__)
241
#define READ_BIN_FLAGS "rb"
242
#define READ_TEXT_FLAGS "r"
243
#define WRITE_BIN_FLAGS "wb"
244
#define WRITE_TEXT_FLAGS "w"
246
#define READ_BIN_FLAGS "r"
247
#define READ_TEXT_FLAGS "r"
248
#define WRITE_BIN_FLAGS "w"
249
#define WRITE_TEXT_FLAGS "w"
257
#define Q_NULL (Q_CHAR *) 0
258
#define U_NULL (U_CHAR *) 0
259
#define C_NULL (C_CHAR *) 0
266
#define EXIT_FAILURE 1
273
#define ARG_II(x,y) x,y
274
#define ARG_III(x,y,z) x,y,z
275
#define ARG_IV(x,y,z,w) x,y,z,w
276
#define ARG_V(x,y,z,w,u) x,y,z,w,u
281
#define ARG_III(x,y,z)
282
#define ARG_IV(x,y,z,w)
283
#define ARG_V(x,y,z,w,u)
289
struct sys_call_rec *next;
293
struct script_struct{
295
struct script_struct *next;
299
#define NULL_SCRIPT (struct script_struct *) 0
313
#define bad_arg err_arg(0)
314
#define bad_mem err_i(1)
317
#define eq_str(x,y) (!strcmp(x,y))
321
static BOOL system_yes;
324
static int system_return;
327
static C_CHAR *warn_err_mssg[]={
328
"\n---------------------------------------------------------------\n\
329
htcmd optional-flag command-line\n\n\
331
-slash translate '/' into '\\'\n\
332
-dslash translate '/' into '\\\\'\n\n\
334
htcmd t4ht name -d/WWW/temp/ -etex4ht-32.env -m644\n\
335
---------------------------------------------------------------\n"
351
static void err_i( ARG_I(int) );
354
static void err_arg( ARG_I(int) );
357
static void call_sys(ARG_I(Q_CHAR *));
360
static void strct( ARG_II(C_CHAR *, C_CHAR *) );
385
(void) signal(s,SIG_IGN);
388
case SIGSEGV: err_i(2);
390
case SIGFPE : err_i(3);
391
#if defined(SIGINT) && !defined(WIN32)
392
case SIGINT : err_i(4);
397
if (s != SIGINT && s != SIGQUIT)
420
{ (IGNORED) fprintf(stderr,"--- error --- ");
421
(IGNORED) fprintf(stderr, warn_err_mssg[n]);
441
{ (IGNORED) fprintf(stderr,"--- error --- ");
442
(IGNORED) fprintf(stderr, warn_err_mssg[n]);
456
(command) Q_CHAR * command
462
(IGNORED) printf("htcmd calls: %s\n", command);
463
system_return = system_yes? (int) system(command) : -1;
464
(IGNORED) printf("%shtcmd returns: %d\n",
465
system_return? "--- Warning --- " : "", system_return );
490
ch = str1 + (int) strlen(str1);
491
(IGNORED) strcpy( ch, str2 );
520
char *in_command, *command, *p, *q;
526
(void) signal(SIGSEGV,sig_err);
528
(void) signal(SIGFPE,sig_err);
531
SetConsoleCtrlHandler((PHANDLER_ROUTINE)sigint_handler, TRUE);
536
(void) signal(SIGINT,sig_err);
542
(IGNORED) printf("htcmd.c (2004-12-16-16:20 %s)\n",PLATFORM);
544
(IGNORED) printf("htcmd.c (2004-12-16-16:20)\n");
547
{ C_CHAR *yes = NULL;
549
#ifdef SYSTEM_FUNCTION_OK
560
in_command = (char *) malloc(1024);
561
command = (char *) malloc(1024);
562
in_command[0] = '\0';
564
if( argc == 1 ){ bad_arg; }
565
slash = eq_str(argv[1],"-slash") ;
566
dslash = eq_str(argv[1],"-dslash") ;
567
for(i=1+slash+dslash; i<argc; i++){
568
(IGNORED) printf("%s ", argv[i]);
569
(IGNORED) strct(in_command,argv[i]);
570
(IGNORED) strct(in_command," ");
572
(IGNORED) printf("\n");
579
if( (*p != '"' ) && (*p != '\'' ) && (*p != '`' ) ){
580
if(slash && (*p == '/')) {
583
else if(dslash && (*p == '/')) {
587
else { *(q++) = *p; }
589
} while (*(p++) != '\0');
590
(IGNORED) call_sys(command);