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.2, 2010/04/18
6 Copyright (C) 2007, 2008, 2009, 2010 Josua Dietze
9 Created with help from usbsnoop2libusb.pl (http://iki.fi/lindi/usb/usbsnoop2libusb.pl)
11 Config file parsing stuff borrowed from Guillaume Dargaud
12 (http://www.gdargaud.net/Hack/SourceCode.html)
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details:
24 http://www.gnu.org/licenses/gpl.txt
32 void readConfigFile(const char *configFilename
);
34 int switchSendMessage();
35 int switchConfiguration();
36 int switchAltSetting();
37 void switchHuaweiMode();
38 void switchSierraMode();
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 usb_device
* search_devices( int *numFound
, int vendor
, int product
, char* productList
, int targetClass
, int mode
);
49 int find_first_bulk_output_endpoint(struct usb_device
*dev
);
50 int find_first_bulk_input_endpoint(struct usb_device
*dev
);
51 char* ReadParseParam(const char* FileName
, char *VariableName
);
53 int hex2byte(const char *hex
);
54 int hexstr2bin(const char *hex
, char *buffer
, int len
);
56 int readArguments(int argc
, char **argv
);
57 void deviceDescription();
60 void release_usb_device(int dummy
);
79 extern char* ReadParseParam(const char* FileName
, char *VariableName
);
83 #define ParseParamString(ParamFileName, Str) \
84 if ((TempPP=ReadParseParam((ParamFileName), #Str))!=NULL) \
85 strcpy(Str, TempPP); else Str[0]='\0'
87 #define ParseParamInt(ParamFileName, Int) \
88 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
91 #define ParseParamHex(ParamFileName, Int) \
92 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
93 Int=strtol(TempPP, NULL, 16)
95 #define ParseParamFloat(ParamFileName, Flt) \
96 if ((TempPP=ReadParseParam((ParamFileName), #Flt))!=NULL) \
99 #define ParseParamBool(ParamFileName, B) \
100 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
101 B=(toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1'); else B=0