blob: f009c2b76dedc1e99048cf5027bb8c6b4f6aecb5 (
plain)
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
39
40
41
42
43
44
45
46
|
#include <kpathsea/kpathsea.h>
#include "stackenv.h"
char *progname = NULL;
void
usage()
{
fprintf(stderr, "usage: %s ocp_filename\n", progname);
exit(1);
}
int
main (int argc, char *argv[])
{
char cmd[4096];
int newfd[3], ret;
FILE *f = fopen("nul", "r");
char *basename;
progname = xbasename(argv[0]);
if (argc != 2) {
usage();
}
SetConsoleCtrlHandler((PHANDLER_ROUTINE)mt_exit, TRUE);
basename = xbasename(argv[1]);
if (strlen(basename) > strlen(".ocp")
&& _stricmp(basename + strlen(basename) - strlen(".ocp"), ".ocp") == 0) {
basename[strlen(basename) - strlen(".ocp")] = '\0';
}
newfd[0] = fileno(f);
newfd[1] = fileno(stderr);
newfd[2] = fileno(stderr);
push_fd(newfd);
sprintf(cmd, "otp2ocp %s", basename);
ret = system(cmd);
pop_fd();
fclose(f);
if (ret == 0) {
printf("%s.ocp\n", basename);
}
return ret;
}
|