fixes, fully translated tomato, with english dictionary and Polish translation
[tomato.git] / release / src / router / usbmodeswitch / usb_modeswitch.h
blob80e8e9c9ac040a6fc75bcd6d5bb78c88e5abc70e
1 /*
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
26 #include <stdlib.h>
27 #ifndef LIBUSB10
28 #include <usb.h>
29 #else
30 #include <libusb.h>
31 #endif
33 void readConfigFile(const char *configFilename);
34 void printConfig();
35 int switchSendMessage();
36 int switchConfiguration();
37 int switchAltSetting();
38 void switchHuaweiMode();
39 void switchSierraMode();
40 void switchGCTMode();
41 int switchKobilMode();
42 int switchSonyMode();
43 int detachDriver();
44 int checkSuccess();
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);
56 int hex2num(char c);
57 int hex2byte(const char *hex);
58 int hexstr2bin(const char *hex, char *buffer, int len);
59 void printVersion();
60 void printHelp();
61 int readArguments(int argc, char **argv);
62 void deviceDescription();
63 int deviceInquire();
64 void resetUSB();
65 void release_usb_device(int dummy);
67 // Boolean
68 #define and &&
69 #define or ||
70 #define not !
72 // Bitwise
73 #define bitand &
74 #define bitor |
75 #define compl ~
76 #define xor ^
78 // Equals
79 #define and_eq &=
80 #define not_eq !=
81 #define or_eq |=
82 #define xor_eq ^=
84 extern char* ReadParseParam(const char* FileName, char *VariableName);
86 extern char *TempPP;
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) \
94 Int=atoi(TempPP)
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) \
102 Flt=atof(TempPP)
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