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