2 This file is part of usb_modeswitch, a mode switching tool for controlling
3 flip flop (multiple device) USB gear
5 Version 1.1.7, 2011/02/27
6 Copyright (C) 2007 - 2011 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
33 void readConfigFile(const char *configFilename
);
35 int switchSendMessage();
36 int switchConfiguration();
37 int switchAltSetting();
38 void switchHuaweiMode();
39 void switchSierraMode();
41 int switchKobilMode();
45 int sendMessage(char* message
, int count
);
46 int write_bulk(int endpoint
, char *message
, int length
);
47 int read_bulk(int endpoint
, char *buffer
, int length
);
48 void release_usb_device(int dummy
);
49 struct usb_device
* search_devices( int *numFound
, int vendor
, int product
, char* productList
,
50 int targetClass
, int configuration
, int mode
);
51 int find_first_bulk_output_endpoint(struct usb_device
*dev
);
52 int find_first_bulk_input_endpoint(struct usb_device
*dev
);
53 int get_current_configuration(struct usb_dev_handle
* devh
);
54 int get_interface0_class(struct usb_device
*dev
, int devconfig
);
55 char* ReadParseParam(const char* FileName
, char *VariableName
);
57 int hex2byte(const char *hex
);
58 int hexstr2bin(const char *hex
, char *buffer
, int len
);
61 int readArguments(int argc
, char **argv
);
62 void deviceDescription();
65 void release_usb_device(int dummy
);
84 extern char* ReadParseParam(const char* FileName
, char *VariableName
);
88 #define ParseParamString(ParamFileName, Str) \
89 if ((TempPP=ReadParseParam((ParamFileName), #Str))!=NULL) \
90 strcpy(Str, TempPP); else Str[0]='\0'
92 #define ParseParamInt(ParamFileName, Int) \
93 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
96 #define ParseParamHex(ParamFileName, Int) \
97 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
98 Int=strtol(TempPP, NULL, 16)
100 #define ParseParamFloat(ParamFileName, Flt) \
101 if ((TempPP=ReadParseParam((ParamFileName), #Flt))!=NULL) \
104 #define ParseParamBool(ParamFileName, B) \
105 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
106 B=(toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1'); else B=0