w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

direct.c
Go to the documentation of this file.
1 /* direct.c - Convert simple LaTeX commands using direct.cfg
2 
3 Copyright (C) 1995-2002 The Free Software Foundation
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 This file is available from http://sourceforge.net/projects/latex2rtf/
20 
21 Authors:
22  1995-1997 Ralf Schlatterbeck
23  1998-2000 Georg Lehner
24  2001-2002 Scott Prahl
25 */
26 
27 #include <stdlib.h>
28 #include <string.h>
29 #include "main.h"
30 #include "direct.h"
31 #include "l2r_fonts.h"
32 #include "cfg.h"
33 #include "util.h"
34 
35 #define MAXFONTLEN 100
36 
37 void WriteFontName(const char **buffpoint)
38 /******************************************************************************
39  purpose: reads the fontname at buffpoint and writes the appropriate font
40  number into the RTF stream. This supports the *FONTNAME* syntax
41  found in direct.cfg and in style.cfg
42  ******************************************************************************/
43 {
44  char fontname[MAXFONTLEN + 1];
45  int i;
46  int fnumber;
47  const char *buff;
48 
49  (*buffpoint)++; /* move past initial '*' */
50 
51  buff = *buffpoint;
52  if (**buffpoint == '*') {
53  fprintRTF("*");
54  return;
55  }
56 
57  i = 0;
58  while (**buffpoint != '*') {
59  if ((i >= MAXFONTLEN) || (**buffpoint == '\0'))
60  diagnostics(ERROR, "No terminating '*' in font name\nFound in cfg file command <%s>",buff);
61 
62  fontname[i] = **buffpoint;
63  i++;
64  (*buffpoint)++;
65  }
66 
67  fontname[i] = '\0';
68  fnumber = RtfFontNumber(fontname);
69 
70  if (fnumber< 0)
71  diagnostics(ERROR,"Unknown font <%s>\nFound in cfg file command <%s>",fontname,buff);
72  else
73  fprintRTF("%u", (unsigned int) fnumber);
74 }
75 
76 bool
78 /******************************************************************************
79  purpose: uses data from direct.cfg to try and immediately convert some
80  LaTeX commands into RTF commands.
81  ******************************************************************************/
82 {
83  const char *buffpoint;
84  const char *RtfCommand;
85  char *TexCommand;
86 
87  TexCommand = strdup_together("\\",command);
88  RtfCommand = SearchRtfCmd(TexCommand, DIRECT_A);
89  if (RtfCommand == NULL)
90  return FALSE;
91 
92  buffpoint = RtfCommand;
93  diagnostics(4, "Directly converting %s to %s", TexCommand, RtfCommand);
94  while (buffpoint[0] != '\0') {
95  if (buffpoint[0] == '*')
96  WriteFontName(&buffpoint);
97  else
98  fprintRTF("%c", *buffpoint);
99 
100  ++buffpoint;
101 
102  }
103  free(TexCommand);
104  return TRUE;
105 }
const char * fontname
Definition: afm2pl.c:186
char * SearchRtfCmd(const char *theTexCommand, int WhichCfg)
Definition: cfg.c:344
#define DIRECT_A
Definition: cfg.h:1
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define free(a)
Definition: decNumber.cpp:310
void WriteFontName(const char **buffpoint)
Definition: direct.c:37
bool TryDirectConvert(char *command)
Definition: direct.c:77
#define MAXFONTLEN
Definition: direct.c:35
static char buff[2 *10240]
Definition: genind.c:46
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
#define ERROR(string)
Definition: error.h:36
void diagnostics(int level, char *format,...)
Definition: main.c:469
void fprintRTF(char *format,...)
Definition: main.c:722
int RtfFontNumber(char *Fname)
Definition: l2r_fonts.c:103
char * strdup_together(char *s, char *t)
Definition: util.c:95