Switch to unified view

a/src/common/unacpp.cpp b/src/common/unacpp.cpp
...
...
86
86
87
using namespace std;
87
using namespace std;
88
88
89
#include "unacpp.h"
89
#include "unacpp.h"
90
#include "readfile.h"
90
#include "readfile.h"
91
#include "rclinit.h"
91
92
92
int main(int argc, char **argv)
93
int main(int argc, char **argv)
93
{
94
{
94
    bool dofold = true;
95
    bool dofold = true;
95
    if (argc != 4) {
96
    if (argc != 4) {
96
    cerr << "Usage: unacpp  <encoding> <infile> <outfile>" << endl;
97
    cerr << "Usage: unacpp  <encoding> <infile> <outfile>" << endl;
97
    exit(1);
98
    exit(1);
98
    }
99
    }
99
    const char *encoding = argv[1];
100
    const char *encoding = argv[1];
100
    string ifn = argv[2];
101
    string ifn = argv[2];
102
    if (!ifn.compare("stdin"))
103
  ifn.clear();
101
    const char *ofn = argv[3];
104
    const char *ofn = argv[3];
105
106
    string reason;
107
    (void)recollinit(RCLINIT_NONE, 0, 0, reason, 0);
102
108
103
    string odata;
109
    string odata;
104
    if (!file_to_string(ifn, odata)) {
110
    if (!file_to_string(ifn, odata)) {
105
    cerr << "file_to_string: " << odata << endl;
111
    cerr << "file_to_string: " << odata << endl;
106
    exit(1);
112
    exit(1);
...
...
109
    if (!unacmaybefold(odata, ndata, encoding, dofold)) {
115
    if (!unacmaybefold(odata, ndata, encoding, dofold)) {
110
    cerr << "unac: " << ndata << endl;
116
    cerr << "unac: " << ndata << endl;
111
    exit(1);
117
    exit(1);
112
    }
118
    }
113
    
119
    
120
    int fd;
121
    if (strcmp(ofn, "stdout")) {
114
    int fd = open(ofn, O_CREAT|O_EXCL|O_WRONLY, 0666);
122
  fd = open(ofn, O_CREAT|O_EXCL|O_WRONLY, 0666);
123
    } else {
124
  fd = 1;
125
    }
115
    if (fd < 0) {
126
    if (fd < 0) {
116
    cerr << "Open/Create " << ofn << " failed: " << strerror(errno) 
127
    cerr << "Open/Create " << ofn << " failed: " << strerror(errno) 
117
         << endl;
128
         << endl;
118
    exit(1);
129
    exit(1);
119
    }
130
    }