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)  

main.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include "main.h"
#include "mygetopt.h"
#include "convert.h"
#include "commands.h"
#include "chars.h"
#include "l2r_fonts.h"
#include "stack.h"
#include "direct.h"
#include "ignore.h"
#include "version.h"
#include "funct1.h"
#include "cfg.h"
#include "encode.h"
#include "util.h"
#include "parser.h"
#include "lengths.h"
#include "counters.h"
#include "preamble.h"
#include "xref.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

static void OpenRtfFile (char *filename, FILE **f)
 
static void CloseRtf (FILE **f)
 
static void ConvertLatexPreamble (void)
 
static void InitializeLatexLengths (void)
 
static void SetEndianness (void)
 
static void ConvertWholeDocument (void)
 
static void print_usage (void)
 
static void print_version (void)
 
int main (int argc, char **argv)
 
void diagnostics (int level, char *format,...)
 
static void RemoveInterpretCommentString (char *s)
 
void putRtfChar (char cThis)
 
void fprintRTF (char *format,...)
 
char * getTmpPath (void)
 
char * my_strdup (const char *str)
 
FILEmy_fopen (char *path, char *mode)
 
void debug_malloc (void)
 

Variables

FILEfRtf = NULL
 
char * g_tex_name = NULL
 
char * g_rtf_name = NULL
 
char * g_aux_name = NULL
 
char * g_bbl_name = NULL
 
char * g_home_dir = NULL
 
const char * InterpretCommentString = "latex2rtf:"
 
char * progname
 
bool GermanMode = 0
 
bool FrenchMode = 0
 
bool RussianMode = 0
 
bool CzechMode = 0
 
char g_charset_encoding_name [20] = "cp1252"
 
int g_fcharset_number = 0
 
bool twoside = 0
 
int g_verbosity_level = 1
 
bool g_little_endian = 0
 
int g_dots_per_inch = 300
 
bool pagenumbering = 1
 
int headings = 0
 
bool g_processing_preamble = 1
 
bool g_processing_figure = 0
 
bool g_processing_eqnarray = 0
 
int g_processing_arrays = 0
 
int g_processing_fields = 0
 
bool g_show_equation_number = 0
 
int g_enumerate_depth = 0
 
bool g_suppress_equation_number = 0
 
bool g_aux_file_missing = 0
 
bool g_document_type = 1
 
int g_document_bibstyle = 1
 
bool g_fields_use_EQ = 1
 
bool g_fields_use_REF = 1
 
int g_safety_braces = 0
 
bool g_processing_equation = 0
 
bool g_RTF_warnings = 0
 
char * g_config_path = NULL
 
char * g_script_path = NULL
 
char * g_tmp_path = NULL
 
char * g_preamble = NULL
 
char g_field_separator = ','
 
bool g_escape_parent = 1
 
bool g_equation_display_rtf = 1
 
bool g_equation_inline_rtf = 1
 
bool g_equation_inline_bitmap = 0
 
bool g_equation_display_bitmap = 0
 
bool g_equation_comment = 0
 
double g_png_equation_scale =1.22
 
double g_png_figure_scale =1.35
 
bool g_latex_figures = 0
 
int indent = 0
 
char alignment = 'j'
 
int RecursionLevel = 0
 
bool twocolumn = 0
 
bool titlepage = 0
 

Function Documentation

◆ CloseRtf()

void CloseRtf ( FILE **  f)
static

purpose: closes output file. params: f - pointer to filepointer to invalidate globals: g_tex_name;

Definition at line 675 of file main.c.

References BraceLevel, CmdEndParagraph(), diagnostics(), EOF, f, fclose, fprintf, g_safety_braces, g_tex_name, i, NULL, fc-lang::stdout, and WARNING__.

Referenced by diagnostics(), and main().

◆ ConvertLatexPreamble()

static void ConvertLatexPreamble ( void  )
static

purpose: reads the LaTeX preamble (to \begin{document} ) for the file

Definition at line 620 of file main.c.

References ConvertString(), diagnostics(), FILE, fRtf, g_preamble, getTexUntil(), and RemoveInterpretCommentString().

Referenced by ConvertWholeDocument().

◆ ConvertWholeDocument()

◆ debug_malloc()

void debug_malloc ( void  )

Definition at line 850 of file main.c.

References c, diagnostics(), fflush, and NULL.

◆ diagnostics()

void diagnostics ( int  level,
char *  format,
  ... 
)

purpose: Writes the message to stderr depending on debugging level

Definition at line 469 of file main.c.

References BraceLevel, buffer, CloseRtf(), CurrentEnvironmentCount(), CurrentFileName(), CurrentLineNumber(), exit(), EXIT_FAILURE, fflush, format, fprintf, fprintRTF(), fRtf, g_RTF_warnings, g_verbosity_level, i, iEnvCount, input, level, linenumber, putRtfChar(), RecursionLevel, va_end, and va_start.

Referenced by BasicPop(), BasicPush(), CallCommandFunc(), CallParamFunc(), citation_used(), CleanStack(), CloseRtf(), CmdAlign(), CmdApaCite(), CmdArray(), CmdBCAY(), CmdBeginEnd(), CmdBibitem(), CmdBibliography(), CmdBox(), CmdCaption(), CmdCite(), CmdCiteName(), CmdClosing(), CmdColsep(), CmdCounter(), CmdDocumentStyle(), CmdEmphasize(), CmdEndParagraph(), CmdEquation(), CmdFigure(), CmdFontFamily(), CmdFontSeries(), CmdFontShape(), CmdFontSize(), CmdFootNote(), CmdFraction(), CmdGraphics(), CmdHeader(), CmdHeadFoot(), CmdInclude(), CmdIndent(), CmdIndex(), CmdIntegral(), CmdItem(), CmdLabel(), CmdLeftRight(), CmdLength(), CmdLink(), CmdMultiCol(), CmdMusic(), CmdNewEnvironment(), CmdNewTheorem(), CmdOaccentChar(), CmdOpening(), CmdPagestyle(), CmdPreambleBeginEnd(), CmdQuote(), CmdSection(), CmdSetTexLength(), CmdStackrel(), CmdStartParagraph(), CmdTabbing(), CmdTabular(), CmdTextColor(), CmdTextNormal(), CmdThePage(), CmdUnderline(), CmdUsepackage(), CmdVerb(), CmdVerbatim(), CmdVerse(), Convert(), ConvertAllttString(), ConvertFormatString(), ConvertLatexPreamble(), ConvertNatbib(), ConvertOverToFrac(), ConvertString(), ConvertWholeDocument(), CurrentCyrillicFontFamily(), CurrentFontFamily(), CurrentFontSeries(), CurrentFontShape(), CurrentFontSize(), debug_malloc(), DefaultFontFamily(), DefaultFontSeries(), DefaultFontShape(), DefaultFontSize(), Environment(), eps_to_emf(), eps_to_pict(), eps_to_png(), exists_with_extension(), existsDefinition(), existsEnvironment(), existsTheorem(), expandDefinition(), expandEnvironment(), expandmacro(), ExtractAndRemoveTag(), ExtractLabelTag(), FinishRtfEquation(), getAngleParam(), GetBaseline(), getLength(), GetPngSize(), Ignore_Environment(), InitializeDocumentFont(), InsertBookmark(), main(), maybeDefinition(), maybeEnvironment(), MonitorFontChanges(), my_fopen(), my_getopt(), my_strdup(), newDefinition(), newEnvironment(), newLength(), newTheorem(), open_cfg(), OpenRtfFile(), pdf_to_png(), PopBrace(), PopEnvironment(), PopFontSettings(), PopSource(), PopTrackLineNumber(), PrepareRtfEquation(), PushEnvironment(), PushFontSettings(), PushLevels(), PushSource(), PushTrackLineNumber(), PutEmfFile(), PutEpsFile(), PutGifFile(), PutJpegFile(), PutLatexFile(), PutPdfFile(), PutPictFile(), PutPngFile(), PutTiffFile(), PutWmfFile(), read_cfg(), ReadCfg(), ReadLanguage(), ReadUptoMatch(), RecordBookmark(), renewDefinition(), renewEnvironment(), RtfFontNumber(), RtfHeader(), SaveEquationAsFile(), ScanAux(), setDocumentOptions(), setPackageInputenc(), SetTexMode(), SlurpEquation(), strdup_together(), StyleCount(), SubSupWorker(), TabbingWriteRow(), TabularCountVert(), TabularGetRow(), TabularMultiParameters(), TabularWriteRow(), TranslateCommand(), try_path(), TryDirectConvert(), TryStyleConvert(), TryVariableIgnore(), WriteEightBitChar(), WriteFontName(), WriteLatexAsBitmap(), WritePageSize(), WriteRtfHeader(), and WriteStyleHeader().

◆ fprintRTF()

void fprintRTF ( char *  format,
  ... 
)

purpose: output filter to track of brace depth and font settings all output to the RTF file passes through this routine or the one above

Definition at line 722 of file main.c.

References buffer, format, fRtf, isknj(), MonitorFontChanges(), PopFontSettings(), PushFontSettings(), text, va_end, va_start, and WriteEightBitChar().

Referenced by applemac_enc(), BeginCell(), CmdAbstract(), CmdAlign(), CmdApaCite(), CmdArray(), CmdArrows(), CmdBCAY(), CmdBeginEnd(), CmdBibitem(), CmdBreveChar(), CmdCaption(), CmdCedillaChar(), CmdCite(), CmdClosing(), CmdColsep(), CmdColumn(), CmdEmphasize(), CmdEndParagraph(), CmdFontFamily(), CmdFontSeries(), CmdFontShape(), CmdFontSize(), CmdFootNote(), CmdFraction(), CmdHacekChar(), CmdHatChar(), CmdHtml(), CmdIndex(), CmdIntegral(), CmdItem(), CmdLabel(), CmdLApostrophChar(), CmdLdots(), CmdLeftRight(), CmdLim(), CmdLink(), CmdMacronChar(), CmdMakeTitle(), CmdMatrix(), CmdMultiCol(), CmdNewPage(), CmdNonBreakSpace(), CmdOaccentChar(), CmdOpening(), CmdPagestyle(), CmdPrintIndex(), CmdQuad(), CmdRApostrophChar(), CmdRoot(), CmdSection(), CmdSlashSlash(), CmdSpace(), CmdStackrel(), CmdStartParagraph(), CmdSubscript(), CmdSuperscript(), CmdTabbing(), CmdTabjump(), CmdTabular(), CmdTextColor(), CmdTextNormal(), CmdThebibliography(), CmdThePage(), CmdTildeChar(), CmdTitlepage(), CmdToday(), CmdUmlauteChar(), CmdUnderdotChar(), CmdUnderline(), CmdVecChar(), CmdVerb(), CmdVerbatim(), Convert(), ConvertAllttString(), ConvertNatbib(), cp1250_enc(), cp1252_enc(), cp437_enc(), cp850_enc(), cp852_enc(), cp865_enc(), decmulti_enc(), diagnostics(), EndCell(), FinishRtfEquation(), GermanPrint(), Ignore_Environment(), InsertBasicStyle(), InsertBookmark(), latin1_enc(), latin2_enc(), latin3_enc(), latin4_enc(), latin5_enc(), latin9_enc(), next_enc(), PlainPagestyle(), PrepareRtfEquation(), put_acute_char(), put_breve_char(), put_cedilla_char(), put_dot_char(), put_macron_char(), put_ring_char(), put_tilde_char(), PutEmfFile(), PutHexFile(), PutJpegFile(), PutPictFile(), PutPngFile(), PutWmfFile(), RtfHeader(), SubSupWorker(), TabbingBeginRow(), TabbingWriteRow(), TabularBeginRow(), TabularEndRow(), TabularPreamble(), TabularWriteRow(), TranslateCommand(), TranslateGerman(), TryDirectConvert(), WriteColorTable(), WriteEightBitChar(), WriteEquationAsComment(), WriteFontHeader(), WriteFontName(), WriteHeadFoot(), WritePageSize(), WriteRtfHeader(), and WriteStyleHeader().

◆ getTmpPath()

char* getTmpPath ( void  )

purpose: return the directory to store temporary files

Definition at line 762 of file main.c.

References free, g_tmp_path, getenv(), NULL, PATHSEP, strdup, strdup_together(), strlen(), t, and u.

Referenced by SaveEquationAsFile(), and strdup_tmp_path().

◆ InitializeLatexLengths()

static void InitializeLatexLengths ( void  )
static

Definition at line 536 of file main.c.

References setCounter(), and setLength().

Referenced by main().

◆ main()

◆ my_fopen()

FILE* my_fopen ( char *  path,
char *  mode 
)

purpose: opens "g_home_dir/path" and

Definition at line 817 of file main.c.

References diagnostics(), FALSE, fflush, FILE, fopen, free, g_home_dir, mode, name, NULL, open_cfg(), p, strdup, strdup_together(), strstr(), and WARNING__.

Referenced by PushSource(), and ScanAux().

◆ my_strdup()

char* my_strdup ( const char *  str)

purpose: duplicate string — exists to ease porting

Definition at line 798 of file main.c.

References diagnostics(), ERROR, malloc, NULL, s, str, strcpy(), and strlen().

◆ OpenRtfFile()

void OpenRtfFile ( char *  filename,
FILE **  f 
)
static

purpose: creates output file and writes RTF-header. params: filename - name of outputfile, possibly NULL for already open file f - pointer to filepointer to store file ID

Definition at line 644 of file main.c.

References diagnostics(), ERROR, f, filename, fopen, free, g_home_dir, name, NULL, fc-lang::stdout, strdup, and strdup_together().

Referenced by main().

◆ print_usage()

static void print_usage ( void  )
static

Definition at line 408 of file main.c.

References CFGDIR, exit(), fprintf, getenv(), progname, s, fc-lang::stdout, and Version.

Referenced by main().

◆ print_version()

static void print_version ( void  )
static

Definition at line 396 of file main.c.

References fprintf, fc-lang::stdout, and Version.

Referenced by main().

◆ putRtfChar()

void putRtfChar ( char  cThis)

purpose: output filter to escape characters written to an RTF file all output to the RTF file passes through this routine or the one below

Definition at line 703 of file main.c.

References fprintf, and fRtf.

Referenced by CmdLeftRight(), CmdTabular(), CmdVerb(), CmdVerbatim(), ConvertAllttString(), diagnostics(), and WriteEquationAsComment().

◆ RemoveInterpretCommentString()

static void RemoveInterpretCommentString ( char *  s)
static

purpose: removes InterpretCommentString from preamble (usually "%latex2rtf:")

Definition at line 604 of file main.c.

References InterpretCommentString, n, p, s, strcpy(), strlen(), strstr(), and t.

Referenced by ConvertLatexPreamble().

◆ SetEndianness()

static void SetEndianness ( void  )
static

Definition at line 340 of file main.c.

References g_little_endian, int(), and TRUE.

Referenced by main().

Variable Documentation

◆ alignment

◆ CzechMode

bool CzechMode = 0

Definition at line 68 of file main.c.

Referenced by setPackageBabel().

◆ FrenchMode

bool FrenchMode = 0

Definition at line 66 of file main.c.

Referenced by CmdItem(), CmdStartParagraph(), Convert(), and setPackageBabel().

◆ fRtf

FILE* fRtf = NULL

Definition at line 54 of file main.c.

Referenced by Convert(), ConvertLatexPreamble(), diagnostics(), fprintRTF(), main(), and putRtfChar().

◆ g_aux_file_missing

bool g_aux_file_missing = 0

Definition at line 90 of file main.c.

Referenced by ScanAux().

◆ g_aux_name

char* g_aux_name = NULL

Definition at line 57 of file main.c.

Referenced by main(), and ScanAux().

◆ g_bbl_name

char* g_bbl_name = NULL

Definition at line 58 of file main.c.

Referenced by CmdBibliography(), and main().

◆ g_charset_encoding_name

char g_charset_encoding_name[20] = "cp1252"

Definition at line 70 of file main.c.

Referenced by setPackageBabel(), setPackageInputenc(), and WriteEightBitChar().

◆ g_config_path

char* g_config_path = NULL

Definition at line 101 of file main.c.

Referenced by main(), and open_cfg().

◆ g_document_bibstyle

int g_document_bibstyle = 1

Definition at line 93 of file main.c.

Referenced by CmdBibitem(), CmdCite(), CmdUsepackage(), and setDocumentOptions().

◆ g_document_type

bool g_document_type = 1

◆ g_dots_per_inch

int g_dots_per_inch = 300

Definition at line 76 of file main.c.

Referenced by eps_to_pict(), eps_to_png(), main(), pdf_to_png(), PutEpsFile(), PutLatexFile(), and PutPdfFile().

◆ g_enumerate_depth

int g_enumerate_depth = 0

Definition at line 88 of file main.c.

Referenced by CmdItem(), and CmdList().

◆ g_equation_comment

bool g_equation_comment = 0

Definition at line 112 of file main.c.

Referenced by CmdEquation(), and main().

◆ g_equation_display_bitmap

bool g_equation_display_bitmap = 0

Definition at line 111 of file main.c.

Referenced by CmdEquation(), and main().

◆ g_equation_display_rtf

bool g_equation_display_rtf = 1

Definition at line 108 of file main.c.

Referenced by CmdEquation(), and main().

◆ g_equation_inline_bitmap

bool g_equation_inline_bitmap = 0

Definition at line 110 of file main.c.

Referenced by CmdEquation(), and main().

◆ g_equation_inline_rtf

bool g_equation_inline_rtf = 1

Definition at line 109 of file main.c.

Referenced by CmdEquation(), and main().

◆ g_escape_parent

bool g_escape_parent = 1

Definition at line 106 of file main.c.

Referenced by Convert(), and main().

◆ g_fcharset_number

int g_fcharset_number = 0

Definition at line 71 of file main.c.

Referenced by setPackageBabel(), setPackageInputenc(), and WriteFontHeader().

◆ g_field_separator

◆ g_fields_use_EQ

◆ g_fields_use_REF

bool g_fields_use_REF = 1

Definition at line 96 of file main.c.

Referenced by CmdCite(), CmdLabel(), InsertBookmark(), and main().

◆ g_home_dir

◆ g_latex_figures

bool g_latex_figures = 0

Definition at line 116 of file main.c.

Referenced by CmdFigure(), and main().

◆ g_little_endian

bool g_little_endian = 0

◆ g_png_equation_scale

double g_png_equation_scale =1.22

Definition at line 114 of file main.c.

Referenced by main(), and WriteLatexAsBitmap().

◆ g_png_figure_scale

double g_png_figure_scale =1.35

Definition at line 115 of file main.c.

Referenced by main(), and WriteLatexAsBitmap().

◆ g_preamble

char* g_preamble = NULL

Definition at line 104 of file main.c.

Referenced by ConvertLatexPreamble(), and SaveEquationAsFile().

◆ g_processing_arrays

int g_processing_arrays = 0

Definition at line 84 of file main.c.

Referenced by CmdArray(), CmdSlashSlash(), and Convert().

◆ g_processing_eqnarray

bool g_processing_eqnarray = 0

Definition at line 83 of file main.c.

Referenced by CmdNonumber(), CmdSlashSlash(), FinishRtfEquation(), and PrepareRtfEquation().

◆ g_processing_equation

bool g_processing_equation = 0

Definition at line 99 of file main.c.

◆ g_processing_fields

◆ g_processing_figure

bool g_processing_figure = 0

Definition at line 82 of file main.c.

Referenced by CmdCaption(), CmdFigure(), and CmdLabel().

◆ g_processing_preamble

bool g_processing_preamble = 1

Definition at line 81 of file main.c.

Referenced by CmdHeadFoot(), and ConvertWholeDocument().

◆ g_rtf_name

char* g_rtf_name = NULL

Definition at line 56 of file main.c.

Referenced by main().

◆ g_RTF_warnings

bool g_RTF_warnings = 0

Definition at line 100 of file main.c.

Referenced by diagnostics(), and main().

◆ g_safety_braces

int g_safety_braces = 0

Definition at line 98 of file main.c.

Referenced by CloseRtf(), and main().

◆ g_script_path

char* g_script_path = NULL

Definition at line 102 of file main.c.

Referenced by get_latex2png_name(), and main().

◆ g_show_equation_number

bool g_show_equation_number = 0

Definition at line 87 of file main.c.

Referenced by CmdSlashSlash(), FinishRtfEquation(), and PrepareRtfEquation().

◆ g_suppress_equation_number

bool g_suppress_equation_number = 0

Definition at line 89 of file main.c.

Referenced by CmdEquation(), CmdNonumber(), CmdSlashSlash(), and FinishRtfEquation().

◆ g_tex_name

char* g_tex_name = NULL

Definition at line 55 of file main.c.

Referenced by CloseRtf(), and main().

◆ g_tmp_path

char* g_tmp_path = NULL

Definition at line 103 of file main.c.

Referenced by getTmpPath(), and main().

◆ g_verbosity_level

int g_verbosity_level = 1

Definition at line 74 of file main.c.

Referenced by CmdVerbosityLevel(), diagnostics(), and main().

◆ GermanMode

bool GermanMode = 0

Definition at line 65 of file main.c.

Referenced by Convert(), and setPackageBabel().

◆ headings

int headings = 0

Definition at line 79 of file main.c.

Referenced by CmdPagestyle().

◆ indent

◆ InterpretCommentString

const char* InterpretCommentString = "latex2rtf:"

Definition at line 62 of file main.c.

Referenced by RemoveInterpretCommentString().

◆ pagenumbering

bool pagenumbering = 1

Definition at line 78 of file main.c.

Referenced by CmdPagestyle(), and PlainPagestyle().

◆ progname

char* progname

Definition at line 64 of file main.c.

Referenced by main(), and print_usage().

◆ RecursionLevel

◆ RussianMode

bool RussianMode = 0

Definition at line 67 of file main.c.

Referenced by setPackageBabel().

◆ titlepage

bool titlepage = 0

Definition at line 122 of file main.c.

Referenced by CmdAbstract().

◆ twocolumn

bool twocolumn = 0

Definition at line 121 of file main.c.

Referenced by CmdColumn(), and CmdNewPage().

◆ twoside

bool twoside = 0

Definition at line 73 of file main.c.