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.9, 2011/08/05
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
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 switchSequansMode();
39 int switchActionMode();
41 int switchCiscoMode();
44 int sendMessage(char* message
, int count
);
45 int write_bulk(int endpoint
, char *message
, int length
);
46 int read_bulk(int endpoint
, char *buffer
, int length
);
47 void release_usb_device(int dummy
);
48 struct libusb_device
* search_devices( int *numFound
, int vendor
, int product
, char* productList
,
49 int targetClass
, int configuration
, int mode
);
50 int find_first_bulk_output_endpoint(struct libusb_device
*dev
);
51 int find_first_bulk_input_endpoint(struct libusb_device
*dev
);
52 int get_current_configuration(struct libusb_device_handle
* devh
);
53 int get_interface0_class(struct libusb_device
*dev
, int devconfig
);
54 char* ReadParseParam(const char* FileName
, char *VariableName
);
56 int hex2byte(const char *hex
);
57 int hexstr2bin(const char *hex
, char *buffer
, int len
);
60 int readArguments(int argc
, char **argv
);
61 void deviceDescription();
64 void release_usb_device(int dummy
);
83 extern char* ReadParseParam(const char* FileName
, char *VariableName
);
87 #define ParseParamString(ParamFileName, Str) \
88 if ((TempPP=ReadParseParam((ParamFileName), #Str))!=NULL) \
89 strcpy(Str, TempPP); else Str[0]='\0'
91 #define ParseParamInt(ParamFileName, Int) \
92 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
95 #define ParseParamHex(ParamFileName, Int) \
96 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
97 Int=strtol(TempPP, NULL, 16)
99 #define ParseParamFloat(ParamFileName, Flt) \
100 if ((TempPP=ReadParseParam((ParamFileName), #Flt))!=NULL) \
103 #define ParseParamBool(ParamFileName, B) \
104 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
105 B=(toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1'); else B=0