summaryrefslogtreecommitdiff
path: root/other/Kermit/src/writesym.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/Kermit/src/writesym.cpp')
-rw-r--r--other/Kermit/src/writesym.cpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/other/Kermit/src/writesym.cpp b/other/Kermit/src/writesym.cpp
new file mode 100644
index 0000000..13d521e
--- /dev/null
+++ b/other/Kermit/src/writesym.cpp
@@ -0,0 +1,95 @@
1/*
2 * readsym.cpp:
3 * written by palmers / teso
4 */
5#include <Kermit>
6#include <iostream>
7#include <fstream>
8
9#define PROGRAM "writesym"
10#define VERSION "0.1"
11#define AUTHOR "palmers / teso"
12
13
14void
15usage (char *a)
16{
17 cout << PROGRAM << VERSION << " by " << AUTHOR << endl;
18 cout << endl;
19 cout << "Usage: " << a << " [options] <d|p> <offset> <length>" << endl;
20 cout << "Options:" << endl;
21 cout << "\t-x:\t where x is 1, 2, 3: ... " << endl;
22 cout << endl;
23 exit (0);
24}
25
26
27int
28main (int argc, char **argv)
29{
30 rwKernel *rw = NULL;
31 char *inBuf = NULL;
32 unsigned long y = 0,
33 length = 0,
34 out_offset = 0,
35 offset = CONF_1GB;
36 int x = 0;
37
38 if (argc < 4)
39 usage (argv[0]);
40
41 while (x < argc)
42 {
43 if (argv[x][0] == '-')
44 {
45 switch (argv[x][1])
46 {
47 case '1':
48 offset = CONF_1GB;
49 break;
50 case '2':
51 offset = CONF_2GB;
52 break;
53 case '3':
54 offset = CONF_3GB;
55 break;
56 case 'h':
57 usage (argv[0]);
58 break;
59 default:
60 usage (argv[0]);
61 break;
62 }
63 }
64 x++;
65 }
66
67 if (argv[argc - 3][0] == 'd')
68 rw = new rwKernel (DEVMEM, offset);
69 else if (argv[argc - 3][0] == 'p')
70 rw = new rwKernel (PROCKCORE, offset);
71
72 out_offset = stoi16 (string (argv[argc - 2]));
73 length = stoi16 (string (argv[argc - 1]));
74
75 if (length == 0)
76 {
77 cerr << "HaHa" << endl;
78 abort ();
79 }
80
81 inBuf = new char[length + 1];
82
83 cin.setf (ios::hex, ios::basefield);
84 while (!cin.eof ())
85 {
86 cin >> x;
87 if (y < length)
88 inBuf[y++] = (x & 0xff);
89 }
90 cin.setf (ios::dec, ios::basefield);
91
92 rw->write (inBuf, length, out_offset);
93 delete inBuf;
94 return 0;
95}