[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
Classes | Macros | Enumerations | Functions | Variables
main.cpp File Reference

main() function for klatexformula [NOT part of klfapp] More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <time.h>
#include <signal.h>
#include <QApplication>
#include <QDebug>
#include <QTranslator>
#include <QFileInfo>
#include <QDir>
#include <QResource>
#include <QProcess>
#include <QPluginLoader>
#include <QMessageBox>
#include <QLibraryInfo>
#include <QMetaType>
#include <QClipboard>
#include <QFontDatabase>
#include <klfbackend.h>
#include <klfutil.h>
#include <klfcolorchooser.h>
#include "klflib.h"
#include "klflibdbengine.h"
#include "klfliblegacyengine.h"
#include "klflibview.h"
#include "klfmain.h"
#include "klfconfig.h"
#include "klfmainwin.h"
#include "klfdbus.h"
#include "klfpluginiface.h"
Include dependency graph for main.cpp:

Go to the source code of this file.

Classes

class  VersionCompareWithPrefixGreaterThan
 

Macros

#define KLF_RESOURCES_ENVNAM   "KLF_RESOURCES"
 
#define EXIT_ERR_FILEINPUT   100
 
#define EXIT_ERR_FILESAVE   101
 
#define EXIT_ERR_OPT   102
 

Enumerations

enum  {
  OPT_INTERACTIVE = 'I', OPT_INPUT = 'i', OPT_LATEXINPUT = 'l', OPT_PASTE_CLIPBOARD = 'P',
  OPT_PASTE_SELECTION = 'S', OPT_NOEVAL = 'n', OPT_BASE64ARG = 'B', OPT_OUTPUT = 'o',
  OPT_FORMAT = 'F', OPT_FGCOLOR = 'f', OPT_BGCOLOR = 'b', OPT_DPI = 'X',
  OPT_MATHMODE = 'm', OPT_PREAMBLE = 'p', OPT_QUIET = 'q', OPT_DAEMONIZE = 'd',
  OPT_HELP = 'h', OPT_VERSION = 'V', OPT_QTOPT = 'Q', OPT_OUTLINEFONTS = 127,
  OPT_LBORDEROFFSET, OPT_TBORDEROFFSET, OPT_RBORDEROFFSET, OPT_BBORDEROFFSET,
  OPT_TEMPDIR, OPT_LATEX, OPT_DVIPS, OPT_GS,
  OPT_EPSTOPDF, OPT_DBUS_EXPORT_MAINWIN, OPT_SKIP_PLUGINS, OPT_REDIRECT_DEBUG
}
 

Functions

void signal_act (int sig)
 
void klf_qt_message (QtMsgType type, const char *msg)
 
void main_parse_options (int argc, char *argv[])
 
void main_cleanup ()
 
void main_exit (int code)
 
QString main_get_input (char *input, char *latexinput, int paste)
 
void main_save (KLFBackend::klfOutput klfoutput, const QString &f_output, QString format)
 
void main_load_extra_resources ()
 
void dumpDir (const QDir &d, int indent=0)
 
void main_load_plugins (QApplication *app, KLFMainWin *mainWin)
 
void main_setup_app (QCoreApplication *a)
 
int main (int argc, char **argv)
 
FILE * main_msg_get_fp_arg (const char *arg)
 
static bool __klf_parse_bool_arg (const char *arg, bool defaultvalue)
 

Variables

int opt_interactive = -1
 
char * opt_input = NULL
 
char * opt_latexinput = NULL
 
int opt_paste = -1
 
bool opt_noeval = false
 
bool opt_base64arg = false
 
char * opt_output = NULL
 
char * opt_format = NULL
 
char * opt_fgcolor = NULL
 
char * opt_bgcolor = NULL
 
int opt_dpi = -1
 
char * opt_mathmode = NULL
 
char * opt_preamble = NULL
 
bool opt_quiet = false
 
char * opt_redirect_debug = NULL
 
bool opt_daemonize = false
 
bool opt_dbus_export_mainwin = false
 
bool opt_skip_plugins = false
 
int opt_outlinefonts = -1
 
int opt_lborderoffset = -1
 
int opt_tborderoffset = -1
 
int opt_rborderoffset = -1
 
int opt_bborderoffset = -1
 
char * opt_tempdir
 
char * opt_latex
 
char * opt_dvips
 
char * opt_gs
 
char * opt_epstopdf
 
bool opt_help_requested = false
 
FILE * opt_help_fp = stderr
 
bool opt_version_requested = false
 
FILE * opt_version_fp = stderr
 
char * opt_version_format = (char*)"KLatexFormula: Version %k using Qt %q\n"
 
char ** klf_args
 
int qt_argc
 
char * qt_argv [1024]
 
char * opt_strdup_free_list [64] = { NULL }
 
int opt_strdup_free_list_n = 0
 
struct {
   bool   has_error
 
   int   retcode
 
opt_error
 
static struct option klfcmdl_optlist []
 
static FILE * klf_qt_msg_fp = NULL
 
static FILE * klf_fp_tty = NULL
 
static bool klf_fp_tty_failed = false
 

Detailed Description

main() function for klatexformula [NOT part of klfapp]

NOTE: If this file appears in the klfapp library documentation, it is to be noted that all definitions contained in this file are compiled SEPARATELY into klatexformula itself, and NOT into the klfapp library. In other words, the functions defined here are NOT available in the klfapp API.

The documentation for this file is just provided for convenient source browsing. It is not meant to be part of a public API.

Definition in file main.cpp.

Macro Definition Documentation

#define EXIT_ERR_FILEINPUT   100

Definition at line 81 of file main.cpp.

Referenced by main_get_input().

#define EXIT_ERR_FILESAVE   101

Definition at line 82 of file main.cpp.

#define EXIT_ERR_OPT   102

Definition at line 83 of file main.cpp.

Referenced by main().

#define KLF_RESOURCES_ENVNAM   "KLF_RESOURCES"

Definition at line 76 of file main.cpp.

Referenced by main_load_extra_resources().

Enumeration Type Documentation

anonymous enum
Enumerator
OPT_INTERACTIVE 
OPT_INPUT 
OPT_LATEXINPUT 
OPT_PASTE_CLIPBOARD 
OPT_PASTE_SELECTION 
OPT_NOEVAL 
OPT_BASE64ARG 
OPT_OUTPUT 
OPT_FORMAT 
OPT_FGCOLOR 
OPT_BGCOLOR 
OPT_DPI 
OPT_MATHMODE 
OPT_PREAMBLE 
OPT_QUIET 
OPT_DAEMONIZE 
OPT_HELP 
OPT_VERSION 
OPT_QTOPT 
OPT_OUTLINEFONTS 
OPT_LBORDEROFFSET 
OPT_TBORDEROFFSET 
OPT_RBORDEROFFSET 
OPT_BBORDEROFFSET 
OPT_TEMPDIR 
OPT_LATEX 
OPT_DVIPS 
OPT_GS 
OPT_EPSTOPDF 
OPT_DBUS_EXPORT_MAINWIN 
OPT_SKIP_PLUGINS 
OPT_REDIRECT_DEBUG 

Definition at line 141 of file main.cpp.

Function Documentation

static bool __klf_parse_bool_arg ( const char *  arg,
bool  defaultvalue 
)
static

Definition at line 1307 of file main.cpp.

References QRegExp::exactMatch(), KLF_FUNC_NAME, and opt_error.

Referenced by main_parse_options().

void dumpDir ( const QDir d,
int  indent = 0 
)

Definition at line 527 of file main.cpp.

References QDir::absoluteFilePath(), and QDir::entryList().

Referenced by main_load_extra_resources().

void klf_qt_message ( QtMsgType  type,
const char *  msg 
)
int main ( int  argc,
char **  argv 
)

Definition at line 784 of file main.cpp.

References __klf_init_the_macpasteboardmime(), QFontDatabase::addApplicationFont(), KLFMainWin::alterSetting(), KLFMainWin::altersetting_BBorderOffset, KLFMainWin::altersetting_Dvips, KLFMainWin::altersetting_Epstopdf, KLFMainWin::altersetting_Gs, KLFMainWin::altersetting_Latex, KLFMainWin::altersetting_LBorderOffset, KLFMainWin::altersetting_OutlineFonts, KLFMainWin::altersetting_RBorderOffset, KLFMainWin::altersetting_TBorderOffset, KLFMainWin::altersetting_TempDir, QCoreApplication::applicationFilePath(), KLFConfig::applicationFont, KLFConfig::BackendSettings, KLFBackend::klfSettings::bborderoffset, KLFBackend::klfInput::bg_color, KLFConfig::colorChooseWidgetCustom, KLFConfig::colorChooseWidgetRecent, QDateTime::currentDateTime(), QDir::currentPath(), KLFConfig::detectMissingSettings(), KLFBackend::klfInput::dpi, KLFBackend::klfSettings::dvipsexec, QDir::entryInfoList(), KLFBackend::klfSettings::epstopdfexec, KLFBackend::klfOutput::errorstr, KLFDBusAppInterface::evaluateAndSave(), QApplication::exec(), KLFConfig::execDvips, KLFConfig::execEpstopdf, KLFConfig::execGs, KLFConfig::execLatex, EXIT_ERR_OPT, KLFBackend::klfInput::fg_color, QString::fromLatin1(), QString::fromLocal8Bit(), QString::fromUtf8(), KLFBackend::getLatexFormula(), KLFBackend::klfSettings::gsexec, QMetaObject::invokeMethod(), QString::isEmpty(), QString::isNull(), QDBusAbstractInterface::isValid(), klf_args, KLF_ASSERT_NOT_NULL, KLF_FUNC_NAME, klf_qt_message(), klf_qt_msg_fp, klf_reload_translations(), klfconfig, klfDbg, klfDbgT, klfFindTranslatedDataFile(), KLFBackend::klfInput::latex, KLFBackend::klfSettings::latexexec, KLFBackend::klfSettings::lborderoffset, KLFConfig::loadDefaults(), KLFConfig::locale, main_cleanup(), main_exit(), main_get_input(), main_load_extra_resources(), main_load_plugins(), main_parse_options(), main_save(), main_setup_app(), KLFBackend::klfInput::mathmode, KLFConfig::maxUserColors, QString::number(), QFile::open(), KLFDBusAppInterface::openFiles(), opt_bborderoffset, opt_bgcolor, opt_daemonize, opt_dbus_export_mainwin, opt_dpi, opt_dvips, opt_epstopdf, opt_error, opt_fgcolor, opt_format, opt_gs, opt_help_fp, opt_help_requested, opt_input, opt_interactive, opt_latex, opt_latexinput, opt_lborderoffset, opt_mathmode, opt_noeval, opt_outlinefonts, opt_output, opt_paste, opt_preamble, opt_quiet, opt_rborderoffset, opt_redirect_debug, opt_skip_plugins, opt_strdup_free_list, opt_strdup_free_list_n, opt_tborderoffset, opt_tempdir, opt_version_format, opt_version_fp, opt_version_requested, KLFBackend::klfSettings::outlineFonts, KLFBackend::klfInput::preamble, qt_argc, qt_argv, KLFDBusAppInterface::raiseWindow(), KLFBackend::klfSettings::rborderoffset, KLFConfig::readFromConfig(), KLFMainWin::refreshWindowSizes(), QDBusConnection::registerObject(), QDBusConnection::registerService(), QString::replace(), QColor::rgb(), QColor::rgba(), QDBusConnection::sessionBus(), KLFDBusAppInterface::setAlterSetting_i(), KLFDBusAppInterface::setAlterSetting_s(), KLFColorChooser::setColorList(), QApplication::setFont(), KLFDBusAppInterface::setInputData(), QColor::setNamedColor(), KLFColorChooseWidget::setRecentCustomColors(), QColor::setRgb(), KLFColorChooser::setUserMaxColors(), QWidget::show(), signal_act(), KLFMainWin::slotEvaluateAndSave(), KLFMainWin::slotSetBgColor(), KLFMainWin::slotSetDPI(), KLFMainWin::slotSetFgColor(), KLFMainWin::slotSetLatex(), KLFMainWin::slotSetMathMode(), KLFMainWin::slotSetPreamble(), QProcess::startDetached(), KLFMainWin::startupFinished(), KLFBackend::klfOutput::status, KLFBackend::klfSettings::tborderoffset, KLFBackend::klfSettings::tempdir, KLFConfig::tempDir, QString::toLocal8Bit(), QObject::tr(), KLFConfig::UI, KLFConfig::userColorList, and KLFConfig::useSystemAppFont.

void main_cleanup ( )

Free some memory we have persistently allocated

Bug:
................ BUG IN WINDOWS HERE? .................... ????

Definition at line 373 of file main.cpp.

References QDir::absoluteFilePath(), QDir::entryList(), KLFConfig::homeConfigDirPlugins, klfconfig, opt_strdup_free_list, opt_strdup_free_list_n, and QFile::remove().

Referenced by main(), and main_exit().

void main_exit ( int  code)

Perform clean-up and ::exit()

Definition at line 390 of file main.cpp.

References main_cleanup().

Referenced by main(), and main_get_input().

QString main_get_input ( char *  input,
char *  latexinput,
int  paste 
)

Determine from where to get input (direct input, from file, stdin) and read latex code; return the latex code as QString.

We can count on a QCoreApplication or QApplication running.

Definition at line 401 of file main.cpp.

References QApplication::clipboard(), EXIT_ERR_FILEINPUT, QString::fromLocal8Bit(), main_exit(), QFile::open(), QFile::setFileName(), and QObject::tr().

Referenced by main().

void main_load_extra_resources ( )
void main_load_plugins ( QApplication app,
KLFMainWin mainWin 
)
FILE* main_msg_get_fp_arg ( const char *  arg)

Definition at line 1279 of file main.cpp.

Referenced by main_parse_options().

void main_parse_options ( int  argc,
char *  argv[] 
)
void main_save ( KLFBackend::klfOutput  klfoutput,
const QString f_output,
QString  format 
)

Saves a klfbackend result (KLFBackend::klfOutput) to a file or stdout with given format. format is guessed if not provided, and defaults to PNG.

Definition at line 444 of file main.cpp.

References KLFBackend::saveOutputToFile().

Referenced by main().

void main_setup_app ( QCoreApplication a)
void signal_act ( int  sig)

Definition at line 231 of file main.cpp.

Referenced by main().

Variable Documentation

bool has_error

Definition at line 138 of file main.cpp.

char** klf_args

Definition at line 127 of file main.cpp.

Referenced by main(), and main_parse_options().

FILE* klf_fp_tty = NULL
static

Definition at line 275 of file main.cpp.

Referenced by klf_qt_message().

bool klf_fp_tty_failed = false
static

Definition at line 276 of file main.cpp.

Referenced by klf_qt_message().

FILE* klf_qt_msg_fp = NULL
static

Definition at line 272 of file main.cpp.

Referenced by klf_qt_message(), and main().

struct option klfcmdl_optlist[]
static

A List of command-line options klatexformula accepts.

NOTE: Remember to forward any NEW OPTIONS to the daemonized process when the new option is used with –daemonize (!) (search for opt_daemonize).

Definition at line 186 of file main.cpp.

Referenced by main_parse_options().

bool opt_base64arg = false

Definition at line 95 of file main.cpp.

Referenced by main_parse_options().

int opt_bborderoffset = -1

Definition at line 113 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_bgcolor = NULL

Definition at line 99 of file main.cpp.

Referenced by main(), and main_parse_options().

bool opt_daemonize = false

Definition at line 105 of file main.cpp.

Referenced by main(), and main_parse_options().

bool opt_dbus_export_mainwin = false

Definition at line 106 of file main.cpp.

Referenced by main(), and main_parse_options().

int opt_dpi = -1

Definition at line 100 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_dvips

Definition at line 117 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_epstopdf

Definition at line 119 of file main.cpp.

Referenced by main(), and main_parse_options().

struct { ... } opt_error
char* opt_fgcolor = NULL

Definition at line 98 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_format = NULL

Definition at line 97 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_gs

Definition at line 118 of file main.cpp.

Referenced by main(), and main_parse_options().

FILE* opt_help_fp = stderr

Definition at line 122 of file main.cpp.

Referenced by main(), and main_parse_options().

bool opt_help_requested = false

Definition at line 121 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_input = NULL

Definition at line 91 of file main.cpp.

Referenced by main(), and main_parse_options().

int opt_interactive = -1

Definition at line 90 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_latex

Definition at line 116 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_latexinput = NULL

Definition at line 92 of file main.cpp.

Referenced by main(), and main_parse_options().

int opt_lborderoffset = -1

Definition at line 110 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_mathmode = NULL

Definition at line 101 of file main.cpp.

Referenced by main(), and main_parse_options().

bool opt_noeval = false

Definition at line 94 of file main.cpp.

Referenced by main(), and main_parse_options().

int opt_outlinefonts = -1

Definition at line 109 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_output = NULL

Definition at line 96 of file main.cpp.

Referenced by main(), and main_parse_options().

int opt_paste = -1

Definition at line 93 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_preamble = NULL

Definition at line 102 of file main.cpp.

Referenced by main(), and main_parse_options().

bool opt_quiet = false

Definition at line 103 of file main.cpp.

Referenced by klf_qt_message(), main(), and main_parse_options().

int opt_rborderoffset = -1

Definition at line 112 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_redirect_debug = NULL

Definition at line 104 of file main.cpp.

Referenced by main(), and main_parse_options().

bool opt_skip_plugins = false

Definition at line 107 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_strdup_free_list[64] = { NULL }

Definition at line 134 of file main.cpp.

Referenced by main(), main_cleanup(), and main_parse_options().

int opt_strdup_free_list_n = 0

Definition at line 135 of file main.cpp.

Referenced by main(), main_cleanup(), and main_parse_options().

int opt_tborderoffset = -1

Definition at line 111 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_tempdir

Definition at line 115 of file main.cpp.

Referenced by main(), and main_parse_options().

char* opt_version_format = (char*)"KLatexFormula: Version %k using Qt %q\n"

Definition at line 125 of file main.cpp.

Referenced by main(), and main_parse_options().

FILE* opt_version_fp = stderr

Definition at line 124 of file main.cpp.

Referenced by main(), and main_parse_options().

bool opt_version_requested = false

Definition at line 123 of file main.cpp.

Referenced by main(), and main_parse_options().

int qt_argc

Definition at line 129 of file main.cpp.

Referenced by main(), and main_parse_options().

char* qt_argv[1024]

Definition at line 130 of file main.cpp.

Referenced by main(), and main_parse_options().

int retcode

Definition at line 138 of file main.cpp.


Generated by doxygen 1.8.6