/usr/share/doc/source-highlight/examples/source-highlight-console-main.cpp is in source-highlight 3.1.8-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /*
* source-highlight-console.cpp
*
* Example of use of source-highlight library:
* highlights a source to the console
*
* Created on: May 7, 2009
* Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2008
* Copyright: See COPYING file that comes with this distribution
*/ //> TEXINFO
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream>
#include "srchilite/sourcehighlight.h"
#include "srchilite/langmap.h"
using namespace std;
#ifndef DATADIR
#define DATADIR ""
#endif
int main(int argc, char *argv[]) {
// we highlight to the console, through ANSI escape sequences
srchilite::SourceHighlight sourceHighlight("esc.outlang");
// make sure we find the .lang and .outlang files
sourceHighlight.setDataDir(DATADIR);
// by default we highlight C++ code
string inputLang = "cpp.lang";
if (argc > 1) {
// we have a file name so we detect the input source language
srchilite::LangMap langMap(DATADIR, "lang.map");
string lang = langMap.getMappedFileNameFromFileName(argv[1]);
if (lang != "") {
inputLang = lang;
} // otherwise we default to C++
// output file name is empty => cout
sourceHighlight.highlight(argv[1], "", inputLang);
} else {
// input file name is empty => cin
sourceHighlight.highlight("", "", inputLang);
}
return 0;
}
|