00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <barry/barry.h>
00023 #include <iostream>
00024 #include <iomanip>
00025 #include <getopt.h>
00026
00027 using namespace std;
00028 using namespace Barry;
00029
00030 void Usage()
00031 {
00032 int major, minor;
00033 const char *Version = Barry::Version(major, minor);
00034
00035 cerr
00036 << "bidentify - USB Blackberry Identifier Tool\n"
00037 << " Copyright 2005-2008, Net Direct Inc. (http://www.netdirect.ca/)\n"
00038 << " Using: " << Version << "\n"
00039 << "\n"
00040 << " -B bus Specify which USB bus to search on\n"
00041 << " -N dev Specify which system device, using system specific string\n"
00042 << "\n"
00043 << " -h This help\n"
00044 << " -v Dump protocol data during operation\n"
00045 << endl;
00046 }
00047
00048 int main(int argc, char *argv[])
00049 {
00050 cout.sync_with_stdio(true);
00051
00052
00053 try {
00054
00055 bool data_dump = false;
00056 string busname;
00057 string devname;
00058
00059
00060 for(;;) {
00061 int cmd = getopt(argc, argv, "B:hN:v");
00062 if( cmd == -1 )
00063 break;
00064
00065 switch( cmd )
00066 {
00067 case 'B':
00068 busname = optarg;
00069 break;
00070
00071 case 'N':
00072 devname = optarg;
00073 break;
00074
00075 case 'v':
00076 data_dump = true;
00077 break;
00078
00079 case 'h':
00080 default:
00081 Usage();
00082 return 0;
00083 }
00084 }
00085
00086 Barry::Init(data_dump);
00087 Barry::Probe probe(busname.c_str(), devname.c_str());
00088
00089
00090 if( probe.GetFailCount() ) {
00091 cerr << "Blackberry device errors with errors during probe:" << endl;
00092 for( int i = 0; i < probe.GetFailCount(); i++ ) {
00093 cerr << probe.GetFailMsg(i) << endl;
00094 }
00095 }
00096
00097
00098 for( int i = 0; i < probe.GetCount(); i++ ) {
00099 const ProbeResult &pr = probe.Get(i);
00100 cout << hex << pr.m_pin << ", "
00101 << pr.m_description << endl;
00102 }
00103
00104 return probe.GetFailCount();
00105
00106 }
00107 catch( std::exception &e ) {
00108 cerr << "exception caught: " << e.what() << endl;
00109 return 1;
00110 }
00111 }
00112