2 This file is part of usb_modeswitch, a mode switching tool for controlling
3 the mode of 'multi-state' USB devices
5 Version 2.2.5, 2015/07/16
6 Copyright (C) 2007 - 2015 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_endpoint(int direction
);
55 int get_current_configuration();
56 int get_interface_class();
57 char* ReadParseParam(const char* FileName
, char *VariableName
);
59 int hex2byte(const char *hex
);
60 int hexstr2bin(const char *hex
, char *buffer
, int len
);
65 int readArguments(int argc
, char **argv
);
66 void deviceDescription();
69 void release_usb_device(int dummy
);
70 int findMBIMConfig(int vendor
, int product
, int mode
);
90 extern char* ReadParseParam(const char* FileName
, char *VariableName
);
94 #define ParseParamString(ParamFileName, Str) \
95 if ((TempPP=ReadParseParam((ParamFileName), #Str))!=NULL) \
96 strcpy(Str, TempPP); else Str[0]='\0'
98 #define ParseParamInt(ParamFileName, Int) \
99 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
102 #define ParseParamHex(ParamFileName, Int) \
103 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
104 Int=strtol(TempPP, NULL, 16)
106 #define ParseParamFloat(ParamFileName, Flt) \
107 if ((TempPP=ReadParseParam((ParamFileName), #Flt))!=NULL) \
110 #define ParseParamBool(ParamFileName, B) \
111 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
112 B=(toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1'); else B=0
114 #define ParseParamBoolMap(ParamFileName, B, M, Const) \
115 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
116 if (toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1') \