Index: r2L_version.h Prereq: 1.3 *** rtf2LaTeX.1.3/r2L_version.h Mon Apr 26 11:24:16 1993 --- rtf2LaTeX/r2L_version.h Mon Aug 16 10:26:17 1993 *************** *** 1,8 **** /* ! * $Id: r2L_version.h,v 1.3 1993/04/26 09:15:38 ralf Exp $ * This file gives the current version number for rtf2LaTeX * History: * $Log: r2L_version.h,v $ * Revision 1.3 1993/04/26 09:15:38 ralf * Corrected bug in selection of Standard vs. Normal Style * Corrected bug of writing into strings in Error Message --- 1,22 ---- /* ! * $Id: r2L_version.h,v 1.5 1993/08/16 08:24:45 ralf Exp $ * This file gives the current version number for rtf2LaTeX * History: * $Log: r2L_version.h,v $ + * Revision 1.5 1993/08/16 08:24:45 ralf + * Minor corrections for THINKC port + * + * Revision 1.4 1993/07/02 08:23:26 ralf + * Fixed bug with endless loop on compilers with unsigned char + * (declared variable c for getopt() as int instead of char) + * Added support for skipping pictures correctly + * (sorry can't do more about pictures for now) + * Incorporated changes for the macintosh port by Alex Viskovatoff + * viskov@harvard.edu + * Removed some fixed boundaries for filenames + * Added some configuration hints in the Makefile.2LaTeX + * Incorporated support for stdarg by Alex Viskovatoff + * * Revision 1.3 1993/04/26 09:15:38 ralf * Corrected bug in selection of Standard vs. Normal Style * Corrected bug of writing into strings in Error Message *************** *** 22,25 **** * Initial revision * */ ! static char *version = "Version $Revision: 1.3 $; $Date: 1993/04/26 09:15:38 $ $State: Exp $"; --- 36,39 ---- * Initial revision * */ ! static char *version = "Version $Revision: 1.5 $; $Date: 1993/08/16 08:24:45 $ $State: Exp $"; Index: Makefile.2LaTeX *** rtf2LaTeX.1.3/Makefile.2LaTeX Mon Apr 26 11:20:36 1993 --- rtf2LaTeX/Makefile.2LaTeX Fri Jul 2 10:13:05 1993 *************** *** 2,14 **** CP=cp CC = gcc CFLAGS = -g ! COMMONOBJS = reader.o # BINDIR = /usr/local/bin MANDIR = /usr/local/man/man1 RTFDIR = /usr/local/lib/rtf # RTF-to-LaTeX translator LATEXOBJS = rtf2LaTeX.o $(COMMONOBJS) SOURCES = rtf.h Makefile.2LaTeX fonts.h rtf2LaTeX.c r2L_version.h \ rtf2LaTeX.h reader.c --- 2,36 ---- CP=cp CC = gcc CFLAGS = -g ! LDFLAGS = ! LD = gcc ! # if your compiler needs -o option for creating .o files uncomment this line: ! #OOPT = -o $@ # + # XCFLAGS holds a combination of -DNO_MALLOC_H -DSTDARG -DVARARGS -DSYSV. + # -DSTDARG and -DVARARGS are mutually exclusive. -DNO_MALLOC_H is only + # needed if you don't have a standard C compiler AND you don't have malloc.h + # if you have a standard C compiler, it is automatically asumed you have stdarg + # you can override this by specifying -DVARARGS. If you don't specify + # any of -DSTDARG and -DVARARGS, an uggly replacement that works on most + # K&R compilers will be used. + # -DSYSV is currently used only for defining index to strchr. You may + # want to specify this for ULTRIX - ULTRIX has both, strchr and index but + # lacks prototypes for the latter. + # + # uncomment this line and delete unneccesary flags if needed. + #XCFLAGS=-DNO_MALLOC_H -DSTDARG -DVARARGS -DSYSV + XCFLAGS = -DSYSV + + # This is where executables, man-pages and support files are installed BINDIR = /usr/local/bin MANDIR = /usr/local/man/man1 RTFDIR = /usr/local/lib/rtf + ############### No configuration parameters below this line ############### + # RTF-to-LaTeX translator + COMMONOBJS = reader.o LATEXOBJS = rtf2LaTeX.o $(COMMONOBJS) SOURCES = rtf.h Makefile.2LaTeX fonts.h rtf2LaTeX.c r2L_version.h \ rtf2LaTeX.h reader.c *************** *** 15,23 **** SUPPORT = mac.code ansi.code english.land german.land DOCFILS = Copyright interna.tex README.2LaTeX interna.rtf rtf2LaTeX.man \ INSTALL.2LaTeX rtf2LaTeX: $(LATEXOBJS) ! $(CC) -o $@ $(LATEXOBJS) install: rtf2LaTeX $(DOCFILS) $(SUPPORT) $(CP) rtf2LaTeX $(BINDIR) $(CP) rtf2LaTeX.man $(MANDIR)/rtf2LaTeX.1 --- 37,46 ---- SUPPORT = mac.code ansi.code english.land german.land DOCFILS = Copyright interna.tex README.2LaTeX interna.rtf rtf2LaTeX.man \ INSTALL.2LaTeX + MACFILES = getopt.c macintosh.h macintosh.c readme.mac rtf2LaTeX: $(LATEXOBJS) ! $(LD) $(LDFLAGS) -o $@ $(LATEXOBJS) install: rtf2LaTeX $(DOCFILS) $(SUPPORT) $(CP) rtf2LaTeX $(BINDIR) $(CP) rtf2LaTeX.man $(MANDIR)/rtf2LaTeX.1 *************** *** 27,33 **** etags -et *.[ch] clean:: -rm -f rtf2LaTeX *~ core *.o *.aux *.log *.dvi TAGS \ ! rtf2LaTeX.tar.z test: ./rtf2LaTeX interna.rtf > interna.test diff interna.test interna.tex --- 50,56 ---- etags -et *.[ch] clean:: -rm -f rtf2LaTeX *~ core *.o *.aux *.log *.dvi TAGS \ ! rtf2LaTeX.tar.z rtf2LaTeX.tar.gz test: ./rtf2LaTeX interna.rtf > interna.test diff interna.test interna.tex *************** *** 34,49 **** rm interna.test # reader.o : rtf.h rtf2LaTeX.o : fonts.h r2L_version.h rtf2LaTeX.h rtf.h ! gcc -g -c -DRTFDIR=\"$(RTFDIR)\" rtf2LaTeX.c ! sources: $(SOURCES) $(DOCFILS) $(SUPPORT) ! $(SOURCES) $(DOCFILS) $(SUPPORT): co $@ dist: sources mkdir rtf2LaTeX ! ln $(SOURCES) $(DOCFILS) $(SUPPORT) rtf2LaTeX ! tar cf - rtf2LaTeX | gzip -best > rtf2LaTeX.tar.z rm -rf rtf2LaTeX --- 57,74 ---- rm interna.test # reader.o : rtf.h + $(CC) $(CFLAGS) $(XCFLAGS) -c $(OOPT) reader.c + rtf2LaTeX.o : fonts.h r2L_version.h rtf2LaTeX.h rtf.h ! $(CC) $(CFLAGS) $(XCFLAGS) -c -DRTFDIR=\"$(RTFDIR)\" $(OOPT) rtf2LaTeX.c ! sources: $(SOURCES) $(DOCFILS) $(SUPPORT) $(MACFILES) ! $(SOURCES) $(DOCFILS) $(SUPPORT) $(MACFILES): co $@ dist: sources mkdir rtf2LaTeX ! ln $(SOURCES) $(DOCFILS) $(SUPPORT) $(MACFILES) rtf2LaTeX ! tar cf - rtf2LaTeX | gzip -best > rtf2LaTeX.tar.gz rm -rf rtf2LaTeX Index: README.2LaTeX *** rtf2LaTeX.1.3/README.2LaTeX Tue Apr 13 12:01:19 1993 --- rtf2LaTeX/README.2LaTeX Mon Aug 16 10:24:10 1993 *************** *** 10,16 **** Your options are: -c No character formatting stuff -C file Use another translation-file for characters above 128 ! -d Use WORD formates within special WORD styles like heading, footnote text, ... -H Use LaTeX header and footer, not as default WORD header -h Help message --- 10,16 ---- Your options are: -c No character formatting stuff -C file Use another translation-file for characters above 128 ! -d Use WORD formats within special WORD styles like heading, footnote text, ... -H Use LaTeX header and footer, not as default WORD header -h Help message Index: english.land *** rtf2LaTeX.1.3/english.land Tue Apr 13 12:03:25 1993 --- rtf2LaTeX/english.land Thu Jul 1 14:34:17 1993 *************** *** 1,13 **** ! winword-name latex-begin-command latex-end-command commentar heading 1 \section{ } heading 1 will be translated as section heading 2 \subsection{ } heading 2 will be translated as subsection heading 3 \subsubsection{ } heading 3 will be translated as subsection heading 4 heading 4 will be ignored heading 5 heading 5 will be ignored header header will be ignored footer footer will be ignored footnote text footnote text will be ignored Normal Normal will be ignored footnote character footnote character will be ignored footnote reference footnote reference will be ignored page number page number will be ignored --- 1,20 ---- ! winword-name latex-begin-command latex-end-command comment heading 1 \section{ } heading 1 will be translated as section heading 2 \subsection{ } heading 2 will be translated as subsection heading 3 \subsubsection{ } heading 3 will be translated as subsection heading 4 heading 4 will be ignored heading 5 heading 5 will be ignored + heading 6 heading 6 will be ignored + heading 7 heading 7 will be ignored + heading 8 heading 8 will be ignored + heading 9 heading 9 will be ignored header header will be ignored footer footer will be ignored footnote text footnote text will be ignored Normal Normal will be ignored + par par will be ignored + parnoind parnoind will be ignored + quote \begin{quote} \end{quote} quote will be tranlated as quote footnote character footnote character will be ignored footnote reference footnote reference will be ignored page number page number will be ignored Index: german.land *** rtf2LaTeX.1.3/german.land Tue Apr 13 12:03:26 1993 --- rtf2LaTeX/german.land Thu Jul 1 14:35:28 1993 *************** *** 4,9 **** --- 4,13 ---- Gliederung 3 \subsubsection{ } Gliederung 3 wird als subsubsection uebersetzt Gliederung 4 Gliederung 4 wird ignoriert Gliederung 5 Gliederung 5 wird ignoriert + Gliederung 6 Gliederung 6 wird ignoriert + Gliederung 7 Gliederung 7 wird ignoriert + Gliederung 8 Gliederung 8 wird ignoriert + Gliederung 9 Gliederung 9 wird ignoriert Kopfzeile Kopfzeile wird ignoriert Fu?zeile Fuázeile wird ignoriert Fu?notenzeichen Fuánotenzeichen wird ignoriert Index: getopt.c *** /dev/null Mon Aug 16 10:53:16 1993 --- rtf2LaTeX/getopt.c Fri Jul 2 10:21:36 1993 *************** *** 0 **** --- 1,124 ---- + /* getopt.c + * Modified slightly to port to Think C by AV 4.5.1993. + */ + + /* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + #if defined(LIBC_SCCS) && !defined(lint) + static char sccsid[] = "@(#)getopt.c 4.13 (Berkeley) 2/23/91"; + #endif /* LIBC_SCCS and not lint */ + + #include + #include + #include + #include "macintosh.h" + + /* + * get option letter from argument vector + */ + int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt; /* character checked for validity */ + char *optarg; /* argument associated with option */ + + #define BADCH (int)'?' + #define EMSG "" + + int + getopt(nargc, nargv, ostr) + int nargc; + char * const *nargv; + const char *ostr; + { + static char *place = EMSG; /* option letter processing */ + register char *oli; /* option letter list index */ + char *p; + if (!*place) { /* update scanning pointer */ + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return(EOF); + } + if (place[1] && *++place == '-') { /* found "--" */ + ++optind; + place = EMSG; + return(EOF); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = index(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means EOF. + */ + if (optopt == (int)'-') + return(EOF); + if (!*place) + ++optind; + if (opterr) { + if (!(p = rindex(*nargv, '/'))) + p = *nargv; + else + ++p; + (void)fprintf(stderr, "%s: illegal option -- %c\n", + p, optopt); + } + return(BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (!(p = rindex(*nargv, '/'))) + p = *nargv; + else + ++p; + if (opterr) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + p, optopt); + return(BADCH); + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return(optopt); /* dump back option letter */ + } Index: macintosh.c *** /dev/null Mon Aug 16 10:53:16 1993 --- rtf2LaTeX/macintosh.c Fri Jul 2 10:21:38 1993 *************** *** 0 **** --- 1,88 ---- + /* macintosh.c 4.5.1993 + * + * Functions calling Macintosh file system and user interface + * routines for use by rtf2LaTeX by Erwin Wechtl. + * + * Written and copyright (c) 1993 by Alex Viskovatoff + * (visko@harvard.edu). Permission is granted to + * distribute and modify this file. + */ + + #include + #include "macintosh.h" + + static char home_pathname_buf[PATHNAME_LENGTH]; + + static char *make_pathname(char *q,long dir_id, int vol_num) + { + CInfoPBRec directory; + Str31 dir_name; + int n; + directory.dirInfo.ioDrDirID = dir_id; + directory.dirInfo.ioVRefNum = vol_num; + directory.dirInfo.ioFDirIndex = -1; + directory.dirInfo.ioNamePtr = dir_name; + for (;;directory.dirInfo.ioDrDirID = directory.dirInfo.ioDrParID) { + *q-- = ':'; + PBGetCatInfoSync(&directory); + for (n=*dir_name; n; n--) *q-- = (char) dir_name[n]; + if (directory.dirInfo.ioDrDirID == 2) break; + } + return q+1; + } + + char *get_home_dir() + { + FCBPBRec home_dir; + Str31 dir_name; + Str31 apName; + int pathRefNum; + Handle apParam; + char *p = home_pathname_buf+PATHNAME_LENGTH-1; + GetAppParms(&apName,&pathRefNum,&apParam); + home_dir.ioRefNum = pathRefNum; + home_dir.ioFCBIndx = 0; + home_dir.ioNamePtr = dir_name; + PBGetFCBInfoSync(&home_dir); + *p-- = 0; + return make_pathname(p,home_dir.ioFCBParID,home_dir.ioFCBVRefNum); + } + + static pascal Boolean not_rtf_file_p(ioParam *parms) + { + StringPtr name = parms->ioNamePtr; + char *p, *q; + static char extension[] = ".rtf"; + int i; + if (name[0] < 5) return TRUE; + for (i=4, p = (char*) name + name[0] - 3, q=extension; i; i--) + if (*p++ != *q++) return TRUE; + return FALSE; + } + + char *get_file_from_dialog() + { + static char buf[PATHNAME_LENGTH]; + SFReply reply; + Point dialog_loc = {100,100}; + long text_file_type = 'TEXT'; + SFGetFile(dialog_loc,"\p0",¬_rtf_file_p,1,&text_file_type,NULL,&reply); + if (reply.good) { + WDPBRec working_dir; + CInfoPBRec directory; + Str31 ioName; + int n; + unsigned char *p; + char *pname_start; + char *q = buf+PATHNAME_LENGTH-1; + unsigned char *filename = reply.fName; + *q-- = 0; + for (n=*filename; n; n--) *q-- = filename[n]; + working_dir.ioVRefNum = reply.vRefNum; + working_dir.ioNamePtr = filename; + working_dir.ioWDIndex = 0; + PBGetWDInfoSync(&working_dir); + return make_pathname(q,working_dir.ioWDDirID,working_dir.ioWDVRefNum); + } + else return NULL; + } Index: macintosh.h *** /dev/null Mon Aug 16 10:53:16 1993 --- rtf2LaTeX/macintosh.h Mon Aug 16 10:24:15 1993 *************** *** 0 **** --- 1,19 ---- + /* macintosh.h 4.5.1993 + * + * Header file for Think C port of rtf2LaTeX by Erwin Wechtl. + * + * Written and copyright (c) 1993 by Alex Viskovatoff + * (visko@harvard.edu). Permission is granted to + * distribute and modify this file. + */ + + #define index strchr + #define rindex strrchr + + #define isascii(c) (((unsigned) c) <= 0x7f) + + #define PATHNAME_LENGTH 256 + + int getopt(int nargc, char * const *nargv, const char *ostr); + char *get_home_dir(void); + char *get_file_from_dialog(void); Index: reader.c *** rtf2LaTeX.1.3/reader.c Mon Apr 26 11:24:20 1993 --- rtf2LaTeX/reader.c Fri Jul 2 10:13:56 1993 *************** *** 19,27 **** # include # include ! # ifdef VARARGS ! # include ! # endif /* VARARGS */ # include "rtf.h" --- 19,48 ---- # include # include ! # include ! # ifdef THINK_C ! # include "macintosh.h" ! # endif /* THINK_C */ ! # ifdef __STDC__ ! # include ! /* if it is a standard compiler, you should have stdarg. */ ! # ifndef VARARGS ! # define STDARG ! # endif /* !VARARGS */ ! # else /* !__STDC__ */ ! # ifdef NO_MALLOC_H ! extern char *malloc (); ! # else /* NO_MALLOC_H */ ! # include ! # endif /* NO_MALLOC_H */ ! # endif /* !__STDC__ */ ! # ifdef STDARG ! # include ! # else /* !STDARG */ ! # ifdef VARARGS ! # include ! # endif /* VARARGS */ ! # endif /* !STDARG */ # include "rtf.h" *************** *** 37,47 **** # define index strchr # endif ! extern char *index (); ! extern char *strcpy (); ! extern char *malloc (); ! ! static void _RTFGetToken (); static int GetChar (); static int HexVal (); --- 58,78 ---- # define index strchr # endif ! /* The templates are needed, at least for the mac */ ! # ifdef __STDC__ ! static void _RTFGetToken (void); ! static int GetChar (void); ! static int HexVal (char); ! static void ReadFontTbl (void); ! static void ReadColorTbl (void); ! static void ReadStyleSheet (void); ! static void ReadInfoGroup (void); ! static void ReadPictGroup (void); ! static void LookupInit (void); ! static void Lookup (char*); ! static int Hash (char*); ! static void Error (char *format, ...); ! # else /* !__STDC__ */ static void _RTFGetToken (); static int GetChar (); static int HexVal (); *************** *** 54,59 **** --- 85,91 ---- static void Lookup (); static int Hash (); static void Error (); + # endif /* !__STDC__ */ /* *************** *** 1378,1383 **** --- 1410,1432 ---- Print helpful error message and give up */ + # ifdef STDARG + + /* + * This version is for systems with stdarg + */ + + static void Error (char *fmt, ...) + { + va_list args; + va_start (args,fmt); + vfprintf (stderr, fmt, args); + va_end (args); + fprintf (stderr, "\nLast token read was \"%s\"\n", rtfTextBuf); + exit (1); + } + + # else /* !STDARG */ # ifdef VARARGS /* *************** *** 1387,1401 **** static void Error (va_alist) va_dcl { ! va_list args; ! char *fmt; ! va_start (args); ! fmt = va_arg (args, char *); ! vfprintf (stderr, fmt, args); ! va_end (args); ! fprintf (stderr, "\nLast token read was \"%s\"\n", rtfTextBuf); ! exit (1); } # else /* !VARARGS */ --- 1436,1450 ---- static void Error (va_alist) va_dcl { ! va_list args; ! char *fmt; ! va_start (args); ! fmt = va_arg (args, char *); ! vfprintf (stderr, fmt, args); ! va_end (args); ! fprintf (stderr, "\nLast token read was \"%s\"\n", rtfTextBuf); ! exit (1); } # else /* !VARARGS */ *************** *** 1405,1419 **** */ static void Error (fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9) ! char *fmt; ! char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9; { ! fprintf (stderr, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9); ! fprintf (stderr, "\nLast token read was \"%s\"\n", rtfTextBuf); ! exit (1); } ! # endif /* VARARGS */ /* ---------------------------------------------------------------------- */ --- 1454,1469 ---- */ static void Error (fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9) ! char *fmt; ! char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9; { ! fprintf (stderr, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9); ! fprintf (stderr, "\nLast token read was \"%s\"\n", rtfTextBuf); ! exit (1); } ! # endif /* !VARARGS */ ! # endif /* !STDARG */ /* ---------------------------------------------------------------------- */ Index: readme.mac *** /dev/null Mon Aug 16 10:53:16 1993 --- rtf2LaTeX/readme.mac Mon Aug 16 10:24:17 1993 *************** *** 0 **** --- 1,34 ---- + The Macintosh port of rtf2LaTeX makes minimal use of the + Macintosh user interface, although it does use the + standard Macintosh file dialog. When rtf2LaTeX is + launched, a dialog comes up emulating the way the program + is used under UNIX - by entering a command line to the + shell. When the dialog comes up, options and the rtf file + path name can be entered in the way described in + README.2LaTeX. If a path name consisting of just a file + name is given, the folder containing rtf2LaTeX will be + searched. If a path name containing directories (folders) + is given, the Macintosh file system syntax must be + followed, with directory names followed by colons (e.g., + "Hard Drive:writing:my novel.rtf"). If no pathname is + given however, the standard Macintosh file dialog comes up + (showing only text file with names ending with ".rtf"), + and the file can be selected in that way. The command line + dialog defaults to directing the output to a window (the + "console"). Since one will usually wish the output to be + directed to a file, it is necessary to select the button + "file" or "console+file" for "Standard Output" before + hitting return when the command line dialog is up. (Do not + select "file" for "Standard Input".) + + The usual and simplest way to use rtf2LaTeX on the Mac is + to double click on its icon, select "file" on the right + hand side of the dialog that comes up, specify the name + and location of the output file which are then requested, + type return to make the dialog which is still there go + away, and finally locate the input file. + + Data files used by rtf2LaTeX, such as mac.data or + english.land, must reside in the same folder as the + program. The file rtf2LaTeX.proj is used by Think C to + source files. Index: rtf.h *** rtf2LaTeX.1.3/rtf.h Thu Apr 15 10:38:51 1993 --- rtf2LaTeX/rtf.h Fri Jul 2 10:14:48 1993 *************** *** 480,486 **** --- 480,490 ---- }; + # ifdef __STDC__ + typedef void (*RTFFuncPtr) (void); /* generic function pointer */ + # else /* !__STDC__ */ typedef void (*RTFFuncPtr) (); /* generic function pointer */ + # endif /* !__STDC__ */ /* *************** *** 487,492 **** --- 491,523 ---- Public RTF reader routines */ + # ifdef __STDC__ + void RTFInit (void); + void RTFSetStream (FILE*); + void RTFSetClassCallback(int, RTFFuncPtr); + RTFFuncPtr RTFGetClassCallback (int); + void RTFSetDestinationCallback(int, RTFFuncPtr); + RTFFuncPtr RTFGetDestinationCallback (int); + void RTFRead (void); + int RTFGetToken (void); /* writer should rarely need this */ + void RTFUngetToken (void); + int RTFPeekToken (void); + void RTFSetToken (int,int,int,int,char*); + void RTFSetReadHook (RTFFuncPtr); + RTFFuncPtr RTFGetReadHook (void); + void RTFRouteToken (void); + void RTFSkipGroup (void); + void RTFExpandStyle (int); + int RTFCheckCM (int,int); + int RTFCheckCMM (int,int,int); + int RTFCheckMM (int,int); + RTFFont *RTFGetFont (int); + RTFColor *RTFGetColor (int); + RTFStyle *RTFGetStyle (int); + char *RTFAlloc (int); + char *RTFStrSave (char*); + void RTFFree (char*); + # else /* !__STDC__ */ extern void RTFInit (); extern void RTFSetStream (); extern void RTFSetClassCallback (); *************** *** 512,514 **** --- 543,546 ---- extern char *RTFAlloc (); extern char *RTFStrSave (); extern void RTFFree (); + # endif /* !__STDC__ */ Index: rtf2LaTeX.c *** rtf2LaTeX.1.3/rtf2LaTeX.c Mon Apr 26 11:24:15 1993 --- rtf2LaTeX/rtf2LaTeX.c Mon Aug 16 10:24:24 1993 *************** *** 21,31 **** */ #include #include #ifdef __STDC__ # include ! # include #else /* !__STDC__ */ ! # include #endif /* !__STDC__ */ #ifndef SEEK_SET # define SEEK_SET 0 --- 21,38 ---- */ #include #include + #include #ifdef __STDC__ # include ! # ifndef THINK_C ! # include ! # endif #else /* !__STDC__ */ ! # ifdef NO_MALLOC_H ! extern char *malloc (); ! # else /* NO_MALLOC_H */ ! # include ! # endif /* NO_MALLOC_H */ #endif /* !__STDC__ */ #ifndef SEEK_SET # define SEEK_SET 0 *************** *** 35,44 **** --- 42,62 ---- #include "rtf2LaTeX.h" #include "rtf.h" + #ifdef THINK_C + #include + #include "macintosh.h" + static char * RTFDIR; + #endif + char *progname; /* Used in Error messages */ RTFFuncPtr default_read_font = NULL; /* default func to read style table */ RTFFuncPtr default_read_style = NULL; /* default func to read style table */ + + /* This forward declaration isn't possible in the header file because + * RTFStyle isn't defined there yet. + */ + static int is_specialWORDstyle A((RTFStyle*,LATEXStyle*)); /*****************************************************************************/ int main(ac,av) *************** *** 61,73 **** FILE *fil = NULL; extern int optind; extern char *optarg; ! char c; ! char codefile[20],landfile[20]; char *str = "12345.67"; progname = av[0]; - strcpy(codefile,"mac"); - strcpy(landfile,"english"); while((c = getopt(ac,av,"cC:dhgGHL:npqrstT:uv:V")) != EOF) { switch (c) --- 79,95 ---- FILE *fil = NULL; extern int optind; extern char *optarg; ! int c; ! char *codefile = "mac", *landfile = "english"; char *str = "12345.67"; + char *rtf_filename = NULL; + #ifdef THINK_C + RTFDIR = get_home_dir(); + ac = ccommand(&av); + #endif /* THINK_C */ + progname = av[0]; while((c = getopt(ac,av,"cC:dhgGHL:npqrstT:uv:V")) != EOF) { switch (c) *************** *** 82,88 **** translate_quotes = 1; break; case 'C': ! strcpy(codefile,optarg); break; case 'c': /* don't do character formating */ formatting_char= 0; --- 104,110 ---- translate_quotes = 1; break; case 'C': ! codefile = optarg; break; case 'c': /* don't do character formating */ formatting_char= 0; *************** *** 97,103 **** header_on = 0; break; case 'L': ! strcpy(landfile,optarg); break; case 'n': other_linebreak = 1; /* use \hfil\break instead of \\ */ --- 119,125 ---- header_on = 0; break; case 'L': ! landfile = optarg; break; case 'n': other_linebreak = 1; /* use \hfil\break instead of \\ */ *************** *** 146,161 **** } } if (optind1) ! msg_not_yet(rtfTextBuf+1); } /***************************************************************************** * --- 1387,1399 ---- { static int count=0; if (verbose && count++==0) ! fprintf(stderr,"%s: Don't support any picture-things yet; be patient\n", ! progname); if (verbose>1) ! msg_not_yet(rtfTextBuf+1); ! RTFSkipGroup (); ! RTFRouteToken (); /* feed "}" back to router */ ! } /***************************************************************************** * *************** *** 1854,1860 **** * * change fontsize */ ! set_fontsize(fontsize) int fontsize; /* size of fonts default 10 */ { if (fontsize<0) --- 1895,1901 ---- * * change fontsize */ ! void set_fontsize(fontsize) int fontsize; /* size of fonts default 10 */ { if (fontsize<0) *************** *** 2178,2184 **** int c; { char *str; - char buff[20]; help=list_8bit; while(help->nr!=c && help->next!=NULL) /* search for the character*/ --- 2219,2224 ---- *************** *** 2208,2214 **** static void read_code_file(codefile) ! char codefile[20]; { char line[line_length]; --- 2248,2254 ---- static void read_code_file(codefile) ! char *codefile; { char line[line_length]; *************** *** 2312,2318 **** LATEXStyle *LaTeXstyleList; /* we can't use the RTFstylelist because we need more variables */ ! DefineStyles() { RTFStyle *rtfstyle; /* the style to deel with */ LATEXStyle *LaTeXstyle; /* the style to deel with */ --- 2352,2358 ---- LATEXStyle *LaTeXstyleList; /* we can't use the RTFstylelist because we need more variables */ ! void DefineStyles() { RTFStyle *rtfstyle; /* the style to deel with */ LATEXStyle *LaTeXstyle; /* the style to deel with */ *************** *** 2382,2388 **** */ ! setstylecommand(n) int n; /* rtfStyleNumber */ { LATEXStyle *LaTeXstyle; --- 2422,2428 ---- */ ! void setstylecommand(n) int n; /* rtfStyleNumber */ { LATEXStyle *LaTeXstyle; *************** *** 2475,2481 **** */ ! char *StrSave (s) char *s; { char *p; --- 2515,2521 ---- */ ! static char *StrSave (s) char *s; { char *p; *************** *** 2591,2597 **** * Now the LaTeX stacks. Use the stack in the current rtf_ptr frame */ static LATEX_STACK *myTeX_free_list = NULL; ! int pop_LaTeX_stack() { char *str; --- 2631,2637 ---- * Now the LaTeX stacks. Use the stack in the current rtf_ptr frame */ static LATEX_STACK *myTeX_free_list = NULL; ! static int pop_LaTeX_stack() { char *str; *************** *** 2646,2652 **** * * Return the flags of the proper type for the top element of the LaTeX stack */ ! int top_LaTeX_flags(type) int type; { --- 2686,2692 ---- * * Return the flags of the proper type for the top element of the LaTeX stack */ ! static int top_LaTeX_flags(type) int type; { *************** *** 2656,2670 **** /*****************************************************************************/ - char filename[80]; static void open_code_file (codefile) ! char codefile[20]; { ! char line[line_length]; ! char c; strcpy(filename,RTFDIR); strcat(filename,"/"); strcat(filename,codefile); if ((strchr(codefile,'.')) == NULL) strcat(filename,".code"); --- 2696,2717 ---- /*****************************************************************************/ static void open_code_file (codefile) ! char *codefile; { ! char *filename; ! char line[line_length]; ! char c; ! if((filename = malloc(strlen(codefile) + strlen(RTFDIR) + 7)) == NULL) ! { ! fprintf(stderr,"%s: Error in malloc\n",progname); ! exit(3); ! } strcpy(filename,RTFDIR); + #if !defined (THINK_C) strcat(filename,"/"); + #endif /* !THINK_C */ strcat(filename,codefile); if ((strchr(codefile,'.')) == NULL) strcat(filename,".code"); *************** *** 2673,2679 **** fprintf(stderr,"%s: Can't open %s\n",progname,filename); exit(1); } ! if (fgets(line,line_length,fpcode)==NULL) { fprintf(stderr,"\n%s: Incorrect file a8bit \ \nthere must be a comment in the first line\n", --- 2720,2727 ---- fprintf(stderr,"%s: Can't open %s\n",progname,filename); exit(1); } ! free(filename); ! if (fgets(line,line_length,fpcode)==NULL) { fprintf(stderr,"\n%s: Incorrect file a8bit \ \nthere must be a comment in the first line\n", *************** *** 2683,2692 **** } static void open_land_file (landfile) ! char landfile[20]; { strcpy(filename,RTFDIR); strcat(filename,"/"); strcat(filename,landfile); if ((strchr(landfile,'.')) == NULL) strcat(filename,".land"); --- 2731,2748 ---- } static void open_land_file (landfile) ! char *landfile; { + char *filename; + if((filename = malloc(strlen(landfile) + strlen(RTFDIR) + 7)) == NULL) + { + fprintf(stderr,"%s: Error in malloc\n",progname); + exit(3); + } strcpy(filename,RTFDIR); + #if !defined (THINK_C) strcat(filename,"/"); + #endif /* !THINK_C */ strcat(filename,landfile); if ((strchr(landfile,'.')) == NULL) strcat(filename,".land"); *************** *** 2694,2697 **** --- 2750,2754 ---- fprintf(stderr,"%s: Can't open %s\n",progname,filename); exit(1); } + free(filename); } Index: rtf2LaTeX.h *** rtf2LaTeX.1.3/rtf2LaTeX.h Mon Apr 26 11:24:17 1993 --- rtf2LaTeX/rtf2LaTeX.h Fri Jul 2 10:15:20 1993 *************** *** 21,28 **** --- 21,30 ---- */ #ifdef __STDC__ /* Convert to a string */ # define STR(S) #S /* ANSI */ + # define A(x) x /* for prototypes */ #else # define STR(S) "S" /* often works... */ + # define A(x) /* no prototypes */ #endif #define TW_TO_CA(I) ((I)/(4,5*20.0)) /* convert twips to number of characters */ #define CA_TO_TW(I) ((I)*(4,5*20.0)) /* convert twips to number of characters */ *************** *** 46,53 **** int type; /* type of centering */ }TABSTOPS; #define NTABS 12 /* maximum number of tabs */ ! static void tabstopsInit(); ! static void start_tabstops(); static int tab=0; static TABSTOPS tabstops[NTABS], /* the current values */ old_tabstops[NTABS]; /* and the old ones */ --- 48,55 ---- int type; /* type of centering */ }TABSTOPS; #define NTABS 12 /* maximum number of tabs */ ! static void tabstopsInit A((void)); ! static void start_tabstops A((void)); static int tab=0; static TABSTOPS tabstops[NTABS], /* the current values */ old_tabstops[NTABS]; /* and the old ones */ *************** *** 56,62 **** static int old_ntabs = 0; /* number of tabstops in old_tapstops*/ static tab_num = 0; /* the number of the next tab */ ! static void end_table(); static char tabinitold[80]; /* parameters of the last table */ static char tabinitnew[80]; /* parameters of the current table */ static float smaller_cell_factor = 0.7; /* to de/encrease the width of the cells */ --- 58,64 ---- static int old_ntabs = 0; /* number of tabstops in old_tapstops*/ static tab_num = 0; /* the number of the next tab */ ! static void end_table A((void)); static char tabinitold[80]; /* parameters of the last table */ static char tabinitnew[80]; /* parameters of the current table */ static float smaller_cell_factor = 0.7; /* to de/encrease the width of the cells */ *************** *** 66,97 **** static int endOfLastCell; static int table_mode = 0; /* Are we in a table */ ! static void output_8bit(); ! static void output_str(); /* output commands, commentars... */ ! static void output(); /* output a character and looking for special ones */ ! static void p6(); #define TRUE 1; #define FALSE 0; ! static void UnknownClass(); ! static void GroupClass(); ! static void TblAttr(); ! static void TextClass(); ! static void CharSet(); ! static void ControlClass(); ! static void Destination(); ! static void SpecialChar(); ! static void DocAttr(); ! static void SectAttr(); ! static void ParAttr(); ! static void CharAttr(); ! static void PictAttr(); ! static void FieldAttr(); ! static void TOCAttr(); ! static void PosAttr(); /*****************************************************************************/ /* * The flag values for the RTF and LaTeX group stacks --- 68,99 ---- static int endOfLastCell; static int table_mode = 0; /* Are we in a table */ ! static void output_8bit A((int)); /* output a char with 8th bit set */ ! static void output_str A((char *, int));/* output commands, comments... */ ! static void output A((int, int)); /* output a character and looking for special ones */ ! static void p6 A((char *)); #define TRUE 1; #define FALSE 0; ! static void UnknownClass A((void)); ! static void GroupClass A((void)); ! static void TblAttr A((void)); ! static void TextClass A((void)); ! static void CharSet A((void)); ! static void ControlClass A((void)); ! static void Destination A((void)); ! static void SpecialChar A((void)); ! static void DocAttr A((void)); ! static void SectAttr A((void)); ! static void ParAttr A((void)); ! static void CharAttr A((void)); ! static void PictAttr A((void)); ! static void FieldAttr A((void)); ! static void TOCAttr A((void)); ! static void PosAttr A((void)); /*****************************************************************************/ /* * The flag values for the RTF and LaTeX group stacks *************** *** 209,220 **** ! static void InitStack(); ! static void pop_rtf_group(); /* pop the status group */ ! static void push_rtf_group(); /* push the status group */ ! static int pop_LaTeX_stack(); /* pop the LaTeX stack */ ! static void push_LaTeX_stack(); /* push the LaTeX stack */ ! static int top_LaTeX_flags(); /* return the flags of the stack top */ static RTF_STACK *rtf_ptr; static RTF_STACK rtf_current; /* current values of things that get pushed on rtf stack */ --- 211,221 ---- ! static void pop_rtf_group A((void)); /* pop the status group */ ! static void push_rtf_group A((void)); /* push the status group */ ! static int pop_LaTeX_stack A((void)); /* pop the LaTeX stack */ ! static void push_LaTeX_stack A((char *, int, long)); ! static int top_LaTeX_flags A((int)); /* return the flags of the stack top */ static RTF_STACK *rtf_ptr; static RTF_STACK rtf_current; /* current values of things that get pushed on rtf stack */ *************** *** 241,268 **** /*****************************************************************************/ ! static void end_para(); /* print the end-of-para string */ ! static void msg_map_to(); /* treat one keyword as another */ ! static void msg_not_needed(); /* LaTeX doesn't need this keyword */ ! static void msg_not_supported(); /* LaTeX can't use this keyword */ ! static void msg_not_yet(); /* Not yet supported */ ! static void in_math(); /* output must be in math mode */ ! static void initialise(); /* initialise the document */ ! static void output_endline(); /* end a line if not at eol */ ! static void output_8bit(); /* output a char with 8th bit set */ ! static char *page_num(); /* a string giving the current pageno*/ ! static void print_text(); /* print some text (char *text[]) */ ! static void read_font(); /* read the font table */ ! static void read_pict(); /* read an rtfPict destination */ ! static void set_font(); /* switch to a new font */ ! static void set_headfoot_lines(); /* set \head/footline */ ! static void start_para(); /* Called at the start of each para */ ! static char *LaTeX_name(); /* remove spaces from a word */ ! static void update_current(); /* update the current state */ ! static void set_subsuper(); ! static void set_smallcaps(); ! static void usage(); /* print a helpful message */ ! static char *StrSave(); static char buff[100]; /* temporary scratch space */ --- 242,269 ---- /*****************************************************************************/ ! static void end_para A((void)); /* print the end-of-para string */ ! static void msg_map_to A((char *, char *));/* treat one keyword as another */ ! static void msg_not_needed A((char *)); /* LaTeX doesn't need this keyword */ ! static void msg_not_supported A((char *));/* LaTeX can't use this keyword */ ! static void msg_not_yet A((char *)); /* Not yet supported */ ! static void in_math A((char *)); /* output must be in math mode */ ! static void initialise A((void)); /* initialise the document */ ! static char *page_num A((void)); /* a string giving the current pageno*/ ! static void print_text A((char **, FILE *));/* print some text (char *text[]) */ ! static void read_pict A((void)); /* read an rtfPict destination */ ! static void set_font A((int, int, char *, char *));/* switch to a new font */ ! static void set_headfoot_lines A((void));/* set \head/footline */ ! static void start_para A((void)); /* Called at the start of each para */ ! static char *LaTeX_name A((char *)); /* remove spaces from a word */ ! static void update_current A((void)); /* update the current state */ ! static void set_subsuper A((int)); ! static void set_smallcaps A((void)); ! static void usage A((void)); /* print a helpful message */ ! static char *StrSave A((char *)); ! static void DefineStyles A((void)); ! static void setstylecommand A((int)); ! static void set_fontsize A((int)); static char buff[100]; /* temporary scratch space */ *************** *** 302,309 **** */ #define line_length 255 /* the parameter for fgets */ ! static void read_code_file(); /* file with the characters above 128 */ ! static void open_code_file(); /* file with the characters above 128 */ ! static void open_land_file(); /* file with the special WORD styles */ static FILE *fpcode, *fpland; --- 303,310 ---- */ #define line_length 255 /* the parameter for fgets */ ! static void read_code_file A((char *)); /* file with the characters above 128 */ ! static void open_code_file A((char *)); /* file with the characters above 128 */ ! static void open_land_file A((char *)); /* file with the special WORD styles */ static FILE *fpcode, *fpland;