<commit_before>//
//
// The MIT License (MIT)
//
// Copyright (c) 2015  <NAME>
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include <getopt.h>

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>

#include <sys/types.h>
#include <sys/stat.h>

#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/lexical_cast.hpp>

#include <configurator.h>

#include "Application.h"
#include "Antenna.h"
#include "CGGTTS.h"
#include "Counter.h"
#include "CounterMeasurement.h"
#include "Debug.h"
#include "Javad.h"
#include "MeasurementPair.h"
#include "NVS.h"
#include "Receiver.h"
#include "ReceiverMeasurement.h"
#include "RINEX.h"
#include "SVMeasurement.h"
#include "Timer.h"
#include "TrimbleResolution.h"
#include "Ublox.h"
#include "Utility.h"

extern Application *app;
extern ostream *debugStream;
extern string   debugFileName;
extern ofstream debugLog;
extern int verbosity;
extern bool shortDebugMessage;

Application *app;

static struct option longOptions[] = {
		{"configuration",required_argument, 0,  0 },
		{"counter-path",required_argument, 0,  0 },
		{"comment",  required_argument, 0,  0 },
		{"debug",         required_argument, 0,  0 },
		{"disable-tic", no_argument, 0,  0 },
		{"help",          no_argument, 0, 0 },
		{"no-navigation", no_argument, 0,  0 },
		{"receiver-path",required_argument, 0,  0 },
		{"verbosity",     required_argument, 0,  0 },
		{"timing-diagnostics",no_argument, 0,  0 },
		{"version",       no_argument, 0,  0 },
		{"sv-diagnostics",no_argument, 0,  0 },
		{"short-debug-message",no_argument, 0,  0 },
		{0,         			0,0,  0 }
};

using boost::lexical_cast;
using boost::bad_lexical_cast;

#define MPAIRS_SIZE 86400

//
//	Public
//

Application::Application(int argc,char **argv)
{
	app = this;
	
	init();

	// Process the command line options
	// These override anything in the configuration file, default or specified
	int longIndex;
	char c;
	string RINEXHeaderFile("");
	
	while ((c=getopt_long(argc,argv,"hm:",longOptions,&longIndex)) != -1)
	{
		switch(c)
		{
			case 0: // long options
				{
					switch (longIndex)
					{
						case 0:
							configurationFile=optarg;
							break;
							
						case 1:
							counterPath=optarg;
							break;
						
						case 2:
							//CGGTSComment=optarg;
							break;
						case 3:<commit_msg>Fixed the usual bug. char is unsigned on ARM.<commit_after>//
//
// The MIT License (MIT)
//
// Copyright (c) 2015  <NAME>
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include <getopt.h>

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>

#include <sys/types.h>
#include <sys/stat.h>

#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/lexical_cast.hpp>

#include <configurator.h>

#include "Application.h"
#include "Antenna.h"
#include "CGGTTS.h"
#include "Counter.h"
#include "CounterMeasurement.h"
#include "Debug.h"
#include "Javad.h"
#include "MeasurementPair.h"
#include "NVS.h"
#include "Receiver.h"
#include "ReceiverMeasurement.h"
#include "RINEX.h"
#include "SVMeasurement.h"
#include "Timer.h"
#include "TrimbleResolution.h"
#include "Ublox.h"
#include "Utility.h"

extern Application *app;
extern ostream *debugStream;
extern string   debugFileName;
extern ofstream debugLog;
extern int verbosity;
extern bool shortDebugMessage;

Application *app;

static struct option longOptions[] = {
		{"configuration",required_argument, 0,  0 },
		{"counter-path",required_argument, 0,  0 },
		{"comment",  required_argument, 0,  0 },
		{"debug",         required_argument, 0,  0 },
		{"disable-tic", no_argument, 0,  0 },
		{"help",          no_argument, 0, 0 },
		{"no-navigation", no_argument, 0,  0 },
		{"receiver-path",required_argument, 0,  0 },
		{"verbosity",     required_argument, 0,  0 },
		{"timing-diagnostics",no_argument, 0,  0 },
		{"version",       no_argument, 0,  0 },
		{"sv-diagnostics",no_argument, 0,  0 },
		{"short-debug-message",no_argument, 0,  0 },
		{0,         			0,0,  0 }
};

using boost::lexical_cast;
using boost::bad_lexical_cast;

#define MPAIRS_SIZE 86400

//
//	Public
//

Application::Application(int argc,char **argv)
{
	app = this;
	
	init();

	// Process the command line options
	// These override anything in the configuration file, default or specified
	int longIndex;
	int c;
	string RINEXHeaderFile("");
	
	while ((c=getopt_long(argc,argv,"hm:",longOptions,&longIndex)) != -1)
	{
		switch(c)
		{
			case 0: // long options
				{
					switch (longIndex)
					{
						case 0:
							configurationFile=optarg;
							break;
							
						case 1:
							counterPath=optarg;
							break;
						
						case 2:
							//CGGTSComment=optarg;
							break;
						case 3:
{'fraction_non_alphanumeric': 0.12470225584979683, 'fraction_numerical': 0.012610340479192938, 'mean_word_length': 3.730284956925116, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6643046', 'n_tokens_mistral': 2544, 'n_tokens_neox': 2235, 'n_words': 753}