summaryrefslogtreecommitdiff
path: root/util/cpp_compress_main.cc
blob: f4b4937f3202e312e38712afbcd5ec742065bff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <cstdio>
#include <iostream>
#include "cpp_compress.hh"

int main(int argc, char* argv[])
{
    std::string out;
    for(;;)
    {
        char Buf[32768];
        if(!std::fgets(Buf, sizeof(Buf), stdin)) break;
        Buf[(sizeof Buf)-1] = '\0';
        out += Buf;
    }
    CPPcompressor Compressor;

    std::string prefix;
    if(argc == 2 && argv[1][0] != '-') prefix = argv[1];
    std::cout << Compressor.Compress(out, prefix);
}