-
Notifications
You must be signed in to change notification settings - Fork 8
/
ss_chc_decode.cc
38 lines (30 loc) · 1.02 KB
/
ss_chc_decode.cc
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;
}