/* * Copyright (C) 1999-2009 Lorenzo Bettini <http://www.lorenzobettini.it> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifdef HAVE_CONFIG_H #include "config.h" // this is glib related so don't use it when compiling with qmake #include "progname.h" #else #define set_program_name(x) ; #endif #include <cstdlib> #include <iostream> #include <exception> #include <boost/shared_ptr.hpp> #include "srchilite/sourcehighlight.h" #include "srchilite/fileutil.h" #include "srchilite/verbosity.h" #include "srchilite/langmap.h" #include "srchilite/languageinfer.h" #include "srchilite/utils.h" #include "srchilite/highlightbuilderexception.h" #include "srchilite/parserexception.h" #include "srchilite/debuglistener.h" #include "srchilite/ctagsmanager.h" #include "srchilite/stopwatch.h" #include "srchilite/lineranges.h" #include "srchilite/regexranges.h" #include "srchilite/versions.h" #include "srchilite/settings.h" #include "cmdline.h" using namespace std; using namespace srchilite; /** * how language inference should be made: NOINFERENCE = no inference at all, * INFERFIRST = inference has priority (e.g., if --infer-lang is specified), * INFERATLAST = try inference as the last chance */ enum InferPolicy { NOINFERENCE = 0, INFERFIRST, INFERATLAST }; static void print_copyright(); static void print_reportbugs(); static void print_version(); static string inferLang(const string &inputFileName); static string getMappedLang(const string &s, LangMap &langmap); static void printError(const string &s); static void print_cgi_header(); /** * Exits for a generic error (i.e., file not found) */ static void exitError(const string &s); static string getLangFileName(InferPolicy infer, const string &inputFileName, const string &langFileName, const string &langName, LangMap &langMap); static bool verbose =