2 This file is part of usb_modeswitch, a mode switching tool for controlling
3 flip flop (multiple device) USB gear
5 Version 1.2.6, 2013/06/02
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
29 void readConfigFile(const char *configFilename
);
31 int switchSendMessage();
32 int switchConfiguration();
33 int switchAltSetting();
34 void switchHuaweiMode();
35 void switchSierraMode();
37 int switchKobilMode();
38 int switchQisdaMode();
39 void switchQuantaMode();
40 int switchSequansMode();
41 int switchActionMode();
43 int switchCiscoMode();
46 int sendMessage(char* message
, int count
);
47 int write_bulk(int endpoint
, char *message
, int length
);
48 int read_bulk(int endpoint
, char *buffer
, int length
);
49 void release_usb_device(int dummy
);
50 struct libusb_device
* search_devices( int *numFound
, int vendor
, int product
, char* productList
,
51 int targetClass
, int configuration
, int mode
);
52 int find_first_bulk_output_endpoint(struct libusb_device
*dev
);
53 int find_first_bulk_input_endpoint(struct libusb_device
*dev
);
54 int get_current_configuration(struct libusb_device_handle
* devh
);
55 int get_interface_class(struct libusb_config_descriptor
*cfg
, int ifcNumber
);
56 char* ReadParseParam(const char* FileName
, char *VariableName
);
58 int hex2byte(const char *hex
);
59 int hexstr2bin(const char *hex
, char *buffer
, int len
);
62 int readArguments(int argc
, char **argv
);
63 void deviceDescription();
66 void release_usb_device(int dummy
);
67 int findMBIMConfig(int vendor
, int product
, int mode
);
87 extern char* ReadParseParam(const char* FileName
, char *VariableName
);
91 #define ParseParamString(ParamFileName, Str) \
92 if ((TempPP=ReadParseParam((ParamFileName), #Str))!=NULL) \
93 strcpy(Str, TempPP); else Str[0]='\0'
95 #define ParseParamInt(ParamFileName, Int) \
96 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
99 #define ParseParamHex(ParamFileName, Int) \
100 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
101 Int=strtol(TempPP, NULL, 16)
103 #define ParseParamFloat(ParamFileName, Flt) \
104 if ((TempPP=ReadParseParam((ParamFileName), #Flt))!=NULL) \
107 #define ParseParamBool(ParamFileName, B) \
108 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
109 B=(toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1'); else B=0