blob: a37f91ed615901af6f965e5b1fd014c619515eff (
plain) (
blame)
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
|
#include <iostream>
#include <string>
/*
* Read in all of stdin (should be piped from objdump), look for bytecode hex,
* and print this code, escaped in a C-string literal, to stdout.
*
* EG output: "\x01\x02\x03\x04"
*/
int main()
{
std::string tmp;
unsigned int hex;
std::cout << "\"";
while (true)
{
std::cin >> tmp;
if (std::cin.eof())
break;
if (tmp.size() == 2 &&
tmp.find(":") == std::string::npos &&
sscanf(tmp.c_str(), "%x", &hex) > 0)
std::cout << "\\x" << tmp;
}
std::cout << "\"\n";
return 0;
}
|