2 This file is part of usb_modeswitch, a mode switching tool for controlling
3 flip flop (multiple device) USB gear
5 Version 2.0.1, 2013/09/03
6 Copyright (C) 2007 - 2013 Josua Dietze
8 Config file parsing stuff borrowed from Guillaume Dargaud
9 (http://www.gdargaud.net/Hack/SourceCode.html)
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details:
21 http://www.gnu.org/licenses/gpl.txt
28 void readConfigFile(const char *configFilename
);
30 int switchSendMessage();
31 int switchConfiguration();
32 int switchAltSetting();
33 void switchHuaweiMode();
35 void switchSierraMode();
37 void switchKobilMode();
38 void switchQisdaMode();
39 void switchQuantaMode();
40 void switchSequansMode();
41 void switchActionMode();
42 void switchBlackberryMode();
43 void switchPantechMode();
44 void switchCiscoMode();
48 int sendMessage(char* message
, int count
);
49 int write_bulk(int endpoint
, char *message
, int length
);
50 int read_bulk(int endpoint
, char *buffer
, int length
);
51 void release_usb_device(int dummy
);
52 struct libusb_device
* search_devices( int *numFound
, int vendor
, char* productList
,
53 int targetClass
, int configuration
, int mode
);
54 int find_first_bulk_output_endpoint(struct libusb_device
*dev
);
55 int find_first_bulk_input_endpoint(struct libusb_device
*dev
);
56 int get_current_configuration(struct libusb_device_handle
* devh
);
57 int get_interface_class(struct libusb_config_descriptor
*cfg
, int ifcNumber
);
58 char* ReadParseParam(const char* FileName
, char *VariableName
);
60 int hex2byte(const char *hex
);
61 int hexstr2bin(const char *hex
, char *buffer
, int len
);
64 int readArguments(int argc
, char **argv
);
65 void deviceDescription();
68 void release_usb_device(int dummy
);
69 int findMBIMConfig(int vendor
, int product
, int mode
);
89 extern char* ReadParseParam(const char* FileName
, char *VariableName
);
93 #define ParseParamString(ParamFileName, Str) \
94 if ((TempPP=ReadParseParam((ParamFileName), #Str))!=NULL) \
95 strcpy(Str, TempPP); else Str[0]='\0'
97 #define ParseParamInt(ParamFileName, Int) \
98 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
101 #define ParseParamHex(ParamFileName, Int) \
102 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
103 Int=strtol(TempPP, NULL, 16)
105 #define ParseParamFloat(ParamFileName, Flt) \
106 if ((TempPP=ReadParseParam((ParamFileName), #Flt))!=NULL) \
109 #define ParseParamBool(ParamFileName, B) \
110 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
111 B=(toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1'); else B=0
113 #define ParseParamBoolMap(ParamFileName, B, M, Const) \
114 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
115 if (toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1') \