Switch to unified view

a/src/utils/transcode.cpp b/src/utils/transcode.cpp
...
...
18
#ifndef TEST_TRANSCODE
18
#ifndef TEST_TRANSCODE
19
#include "autoconfig.h"
19
#include "autoconfig.h"
20
20
21
#include <string>
21
#include <string>
22
#include <iostream>
22
#include <iostream>
23
#ifndef NO_NAMESPACES
23
24
using std::string;
24
using std::string;
25
#endif /* NO_NAMESPACES */
26
25
27
#include <errno.h>
26
#include <errno.h>
28
#include <iconv.h>
27
#include <iconv.h>
29
28
30
#include "transcode.h"
29
#include "transcode.h"
...
...
163
#else
162
#else
164
163
165
#include <stdio.h>
164
#include <stdio.h>
166
#include <stdlib.h>
165
#include <stdlib.h>
167
#include <errno.h>
166
#include <errno.h>
168
#include <unistd.h>
169
#include <fcntl.h>
167
#include <fcntl.h>
170
168
171
#include <string>
169
#include <string>
172
#include <iostream>
170
#include <iostream>
173
171
...
...
217
    string out;
215
    string out;
218
    if (!transcode(text, out, icode, ocode)) {
216
    if (!transcode(text, out, icode, ocode)) {
219
    cerr << out << endl;
217
    cerr << out << endl;
220
    exit(1);
218
    exit(1);
221
    }
219
    }
222
    int fd = open(ofilename.c_str(), O_CREAT|O_TRUNC|O_WRONLY, 0666);
220
    FILE *fp = fopen(ofilename.c_str(), "wb");
223
    if (fd < 0) {
221
    if (fp == 0) {
224
    perror("Open/create output");
222
    perror("Open/create output");
225
    exit(1);
223
    exit(1);
226
    }
224
    }
227
    if (write(fd, out.c_str(), out.length()) != (int)out.length()) {
225
    if (fwrite(out.c_str(), 1, out.length(), fp) != (int)out.length()) {
228
    perror("write");
226
    perror("fwrite");
229
    exit(1);
227
    exit(1);
230
    }
228
    }
231
    close(fd);
229
    fclose(fp);
232
    exit(0);
230
    exit(0);
233
}
231
}
234
#endif
232
#endif