Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / main.h
blob98639f2129585d5128bb36fcdaa5a4be37b0e8ab
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2009 Henrik Tidefelt
19 #pragma once
21 #include "Shapes_Kernel_decls.h"
23 #include "simplepdfi.h"
24 #include "simplepdfo.h"
25 #include "globals.h"
26 #include "consts.h"
27 #include "shapesexceptions.h"
28 #include "hottypes.h"
29 #include "multipage.h"
30 #include "continuations.h"
31 #include "charconverters.h"
32 #include "pagecontentstates.h"
33 #include "autoonoff.h"
34 #include "shapesscanner.h"
35 #include "texlabelmanager.h"
36 #include "debuglog.h"
38 #include <iostream>
39 #include <iomanip>
40 #include <fstream>
41 #include <string>
42 #include <unistd.h>
43 #include <stdlib.h>
44 #include <list>
45 #include <time.h>
46 #include <errno.h>
47 #include <limits>
48 #include <iconv.h>
50 int shapesparse( );
51 extern int shapesdebug;
52 void printHelp( );
53 void printVersion( );
55 enum SplitMode{ SPLIT_NO, SPLIT_FLAT, SPLIT_DIR };
57 void argcAssertion( const char * optionSpecifier, int argc, int argcMin );
58 bool strprefixcmp( char * str, const char * prefix, const char ** prefixDst, char ** endp );
59 bool strtobool( const char * str, const char * containingString, const char * trueLabel = 0, const char * falseLabel = 0 );
60 std::string absoluteFilename( const char * filename );
61 std::string absoluteDirectory( const char * filename );
62 void ensureTmpDirectoryExists( const std::string & dirname, bool allowCreate );
63 RefCountPtr< std::ifstream > performIterativeStartup( const std::string & texJobName );
64 void abortProcedure( int exitCode );
65 void setupGlobals( );
66 namespace Shapes
68 namespace Interaction
70 class PreviewOptions
72 public:
73 enum XpdfAction{ XPDF_DEFAULT, XPDF_RAISE, XPDF_RELOAD, XPDF_QUIT, XPDF_NOSERVER };
74 public:
75 bool launch_xpdf;
76 XpdfAction xpdfAction;
77 std::string xpdfServer;
78 bool do_open;
79 const char * do_open_application;
80 public:
81 PreviewOptions( );
82 void preview( const std::string & filename, bool splitNoLaunch = false ) const;
83 protected:
84 void xpdfHelper( const std::string & filename ) const;
85 void openHelper( const std::string & filename ) const;
88 class InteractionFormats
90 const char * prompt_;
91 const char * show_;
92 const char * file_;
93 const char * bye_;
94 public:
95 InteractionFormats( );
96 void setPrompt( const char * format );
97 void setShow( const char * format );
98 void setFile( const char * format );
99 void setBye( const char * format );
101 void formatPrompt( std::ostream & os, size_t inputNo ) const;
102 void formatShow( std::ostream & os, size_t inputNo ) const;
103 void formatFile( std::ostream & os, size_t inputNo ) const;
104 void formatBye( std::ostream & os, size_t inputNo ) const;
106 private:
107 void writePrompt( std::ostream & os, const char * format, size_t inputNo ) const;
108 void writeEscape( std::ostream & os, char c ) const;
113 namespace Kernel
115 class InteractionContinuation;
117 class WarmDebugger : public Kernel::State
119 public:
120 Kernel::Environment * env_;
121 Kernel::PassedDyn dyn_;
122 Kernel::ContRef resume_;
123 Ast::Expression * breakExpr_;
124 WarmDebugger( Kernel::Environment * env, Kernel::PassedDyn dyn, Kernel::ContRef resume, Ast::Expression * breakExpr );
125 virtual ~WarmDebugger( );
126 virtual void tackOnImpl( Kernel::EvalState * evalState, const RefCountPtr< const Lang::Value > & piece, const Ast::SourceLocation & callLoc );
127 virtual void peekImpl( Kernel::EvalState * evalState, const Ast::SourceLocation & callLoc );
128 virtual void freezeImpl( Kernel::EvalState * evalState, const Ast::SourceLocation & callLoc );
129 virtual void gcMark( Kernel::GCMarkedSet & marked );
130 TYPEINFODECL;
136 extern Shapes::Interaction::PreviewOptions previewOptions;
137 extern Shapes::Interaction::InteractionFormats interactionFormats;
139 void addDefaultNeedPath( );
140 void addDefaultFontMetricsPath( );
141 void destroyGlobals( );
142 void escapeExtGlobChars( const std::string & str, std::ostream & dst );
144 void rmSplitFiles( const std::string & outputName, const char * sep );
145 void mkSplitDir( const std::string & outputName );
146 void noSplitOpen( std::ofstream * oFile, const std::string & outputName );
147 std::string splitOpen( std::ofstream * oFile, const std::string outputName, const char * sep, size_t physicalPageNo );
148 void interactiveEvaluation( std::istream & in, std::ostream & out, const std::string & outputName, SplitMode splitMode,
149 bool evalTrace, bool evalBackTrace, bool cleanupMemory,
150 RefCountPtr< std::ifstream > & labelDBFile, const std::string & labelDBName );
151 void nonInteractiveEvaluation( Shapes::Kernel::WarmCatalog::ShipoutList & documents, SplitMode splitMode,
152 bool evalTrace, bool evalBackTrace, bool cleanupMemory,
153 RefCountPtr< std::ifstream > & labelDBFile, const std::string & labelDBName );
154 void initCore( RefCountPtr< std::ifstream > & labelDBFile, const std::string & labelDBName );