cprover
converter.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Dario Cattaruzza
6 
7 Date: November 2017
8 
9 \*******************************************************************/
10 
11 #include <fstream>
12 #include <iostream>
13 #include <sstream>
14 #include <vector>
15 #include <cstring>
16 
36 int main(int argc, char *argv[])
37 {
38  if(argc<2 || strlen(argv[1])==0)
39  {
40  printf("Usage: converter VARNAME JAR_FILE\n\n");
41  return 1;
42  }
43 
44  std::size_t size=0;
45  const char *varname=argv[1];
46 
47  printf("// File automatically generated by " __FILE__ "\n\n");
48 
49  printf("#define %s_DATA \\\n ", varname);
50  std::ifstream src((argc>2) ? argv[2] : "core-models.jar",
52  std::istream &stream=(argc>2) ? src : std::cin;
53  if(!stream.eof())
54  {
55  size++;
56  printf("0x%02x", (unsigned char) stream.get());
57 
58  while(!stream.eof())
59  {
60  printf(", ");
61  if(size % 16 == 0)
62  printf("\\\n ");
63  printf("0x%02x", (unsigned char) stream.get());
64  size++;
65  }
66  printf("\n");
67  }
68 
69  std::cout << "\n#define " << varname << "_SIZE " << size << "\n";
70  src.close();
71  return 0;
72 }
binary
static std::string binary(const constant_exprt &src)
Definition: json_expr.cpp:204
main
int main(int argc, char *argv[])
Definition: converter.cpp:56