File: ss_chc_decode.cc

package info (click to toggle)
performous 1.1%2Bgit20181118-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,736 kB
  • sloc: cpp: 30,008; ansic: 2,751; sh: 801; xml: 464; python: 374; makefile: 36
file content (38 lines) | stat: -rw-r--r-- 1,041 bytes parent folder | download | duplicates (5)
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
#include <cstdlib>
#include "chc_decode.hh"
#include <string>
#include <iostream>
#include <fstream>
#include <boost/lexical_cast.hpp>

int main(int argc, char ** argv) {
	if( argc != 7 ) {
		std::cout << "Usage: " << argv[0] << " chc_file key0 key1 key2 key4 track_id" << std::endl;
		return EXIT_FAILURE;
	}
	std::string key[4] = {argv[2], argv[3], argv[4], argv[5]};

	std::ifstream chc_file;
	chc_file.open(argv[1], std::ios_base::binary );

	// Get the file size
	chc_file.seekg(0, std::ios::end);
	unsigned int fileSize = chc_file.tellg();
	chc_file.seekg(0, std::ios::beg);

	// Reading inputfile
	char *buffer = new char[fileSize];
	std::cout << "Reading input file \"" << argv[1] << "\" (" << fileSize << " Bytes)... " << std::endl;
	chc_file.read(&buffer[0], fileSize);
	chc_file.close();

	ChcDecode chc_decoder;
	chc_decoder.load(key);
	std::string xmlMelody = chc_decoder.getMelody(buffer, fileSize, boost::lexical_cast<unsigned int>(argv[6]));

	std::cout << xmlMelody << std::endl;

	delete[] buffer;

	return EXIT_SUCCESS;
}