include cxxabi include cstdio include cstdlib include unistd include c

 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
#include <cxxabi.h>
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <cstring>
int main(int argc, char **argv) noexcept {
if (argc != 2) {
return EXIT_FAILURE;
}
int status;
size_t length;
char buff[] = { 0 };
char *ret = abi::__cxa_demangle(argv[1], nullptr, &length, &status);
if (status != 0) {
printf("%s", argv[1]);
write(1, argv[1], strlen(argv[1]));
write(1, buff, sizeof(buff));
return status;
}
write(1, ret, length);
write(1, buff, sizeof(buff));
free(ret);
return EXIT_SUCCESS;
}