- Get oskittcp to compile on msvc.
[reactos.git] / msvc6 / def_converter / def_converter.cpp
1 // Uses hard-coded filenames to require a minimum of input.
2 // You think this file should be licensed? OK then,
3 // Copyright (C) 2004, Mike Nordell. Use as you whish.
4 #include <fstream>
5 #include <string>
6 #include <algorithm>
7
8 const char szSrc1[] = "..\\..\\reactos\\ntoskrnl\\ntoskrnl.def";
9 const char szDst1[] = "..\\ntoskrnl\\ntoskrnl.def";
10 const char szSrc2[] = "..\\..\\reactos\\hal\\hal\\hal.def";
11 const char szDst2[] = "..\\hal\\hal.def";
12
13 enum File
14 {
15 Kernel,
16 HAL
17 };
18
19 std::string do_kernel_replacements(std::string& s)
20 {
21 std::string s2 = s.c_str(); // to fixup size after replacements
22 if (s2 == "ExAllocateFromPagedLookasideList") {
23 s2 += "=ExiAllocateFromPagedLookasideList";
24 } else
25 if (s2 == "ExFreeToPagedLookasideList") {
26 s2 += "=ExiFreeToPagedLookasideList";
27 } else
28 if (s2 == "MmLockPagableImageSection") {
29 s2 += "=MmLockPagableDataSection";
30 }
31 return s2;
32 }
33
34 void convert_def(const char* szSrc, const char* szDst, File file)
35 {
36 using namespace std;
37 ifstream in(szSrc);
38 ofstream out(szDst);
39 string s;
40 while (getline(in, s).good()) {
41 if (!s.size()) {
42 continue;
43 }
44 if (s[0] != ';') { // only replace non-comment lines
45 if (s[0] == '@') {
46 s.erase(0, 1);
47 }
48 replace(s.begin(), s.end(), '@', '\0');
49 if (file == Kernel) {
50 s = do_kernel_replacements(s);
51 }
52 }
53 out << s << endl;
54 }
55 }
56
57
58 int main()
59 {
60 convert_def(szSrc1, szDst1, Kernel);
61 convert_def(szSrc2, szDst2, HAL);
62 return 0;
63 }
64