1 /***************************************************************************** |
|
2 * |
|
3 * $Id$ |
|
4 * |
|
5 ****************************************************************************/ |
|
6 |
|
7 #include <iostream> |
|
8 using namespace std; |
|
9 |
|
10 #include "globals.h" |
|
11 |
|
12 /*****************************************************************************/ |
|
13 |
|
14 const char *help_data = |
|
15 "[OPTIONS]\n" |
|
16 "\n" |
|
17 "Output binary domain data.\n" |
|
18 "\n" |
|
19 "Command-specific options:\n" |
|
20 " --domain -d <index> Positive numerical domain index, or 'all' for\n" |
|
21 " all domains (default). In this case, data of all\n" |
|
22 " domains are concatenated.\n" |
|
23 "\n" |
|
24 "Numerical values can be specified either with decimal (no prefix),\n" |
|
25 "octal (prefix '0') or hexadecimal (prefix '0x') base.\n"; |
|
26 |
|
27 /****************************************************************************/ |
|
28 |
|
29 void outputDomainData(unsigned int); |
|
30 |
|
31 /****************************************************************************/ |
|
32 |
|
33 void command_data() |
|
34 { |
|
35 masterDev.open(MasterDevice::Read); |
|
36 |
|
37 if (domainIndex == -1) { |
|
38 unsigned int i; |
|
39 ec_ioctl_master_t master; |
|
40 |
|
41 masterDev.getMaster(&master); |
|
42 |
|
43 for (i = 0; i < master.domain_count; i++) { |
|
44 outputDomainData(i); |
|
45 } |
|
46 } else { |
|
47 outputDomainData(domainIndex); |
|
48 } |
|
49 } |
|
50 |
|
51 /****************************************************************************/ |
|
52 |
|
53 void outputDomainData(unsigned int domainIndex) |
|
54 { |
|
55 ec_ioctl_domain_t domain; |
|
56 ec_ioctl_domain_data_t data; |
|
57 unsigned char *processData; |
|
58 unsigned int i; |
|
59 |
|
60 masterDev.getDomain(&domain, domainIndex); |
|
61 |
|
62 if (!domain.data_size) |
|
63 return; |
|
64 |
|
65 processData = new unsigned char[domain.data_size]; |
|
66 |
|
67 try { |
|
68 masterDev.getData(&data, domainIndex, domain.data_size, processData); |
|
69 } catch (MasterDeviceException &e) { |
|
70 delete [] processData; |
|
71 throw e; |
|
72 } |
|
73 |
|
74 for (i = 0; i < data.data_size; i++) |
|
75 cout << processData[i]; |
|
76 cout.flush(); |
|
77 |
|
78 delete [] processData; |
|
79 } |
|
80 |
|
81 /****************************************************************************/ |
|