Merge branch 'misc-fixes'

This commit is contained in:
Micke Prag 2012-03-30 16:29:59 +02:00
commit c77fd899a1
7 changed files with 17 additions and 13 deletions

View file

@ -44,7 +44,7 @@
* \code * \code
* int intNumberOfDevices = tdGetNumberOfDevices(); * int intNumberOfDevices = tdGetNumberOfDevices();
* for (int i = 0; i < intNumberOfDevices; i++) { * for (int i = 0; i < intNumberOfDevices; i++) {
* int id = tdGetDeviceId( index ); * int id = tdGetDeviceId( i );
* char *name = tdGetName( id ); * char *name = tdGetName( id );
* printf("%d\t%s\n", id, name); * printf("%d\t%s\n", id, name);
* tdReleaseString(name); * tdReleaseString(name);

View file

@ -58,11 +58,11 @@ def rawcallbackfunction(data, controllerId, callbackId, context):
print string_at(data) print string_at(data)
if (platform.system() == 'Windows'): if (platform.system() == 'Windows'):
CMPFUNC = WINFUNCTYPE(c_void_p, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p) #first is return type CMPFUNC = WINFUNCTYPE(None, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p) #first is return type
CMPFUNCRAW = WINFUNCTYPE(c_void_p, POINTER(c_ubyte), c_int, c_int, c_void_p) CMPFUNCRAW = WINFUNCTYPE(None, POINTER(c_ubyte), c_int, c_int, c_void_p)
else: else:
CMPFUNC = CFUNCTYPE(c_void_p, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p) CMPFUNC = CFUNCTYPE(None, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p)
CMPFUNCRAW = CFUNCTYPE(c_void_p, POINTER(c_ubyte), c_int, c_int, c_void_p) CMPFUNCRAW = CFUNCTYPE(None, POINTER(c_ubyte), c_int, c_int, c_void_p)
cmp_func = CMPFUNC(callbackfunction) cmp_func = CMPFUNC(callbackfunction)
cmp_funcraw = CMPFUNCRAW(rawcallbackfunction) cmp_funcraw = CMPFUNCRAW(rawcallbackfunction)

View file

@ -29,9 +29,9 @@ def callbackfunction(protocol, model, id, dataType, value, timestamp, callbackId
if (platform.system() == 'Windows'): if (platform.system() == 'Windows'):
CMPFUNC = WINFUNCTYPE(c_void_p, POINTER(c_ubyte), POINTER(c_ubyte), c_int, c_int, POINTER(c_ubyte), c_int, c_int, c_void_p) #first is return type CMPFUNC = WINFUNCTYPE(None, POINTER(c_ubyte), POINTER(c_ubyte), c_int, c_int, POINTER(c_ubyte), c_int, c_int, c_void_p) #first is return type
else: else:
CMPFUNC = CFUNCTYPE(c_void_p, POINTER(c_ubyte), POINTER(c_ubyte), c_int, c_int, POINTER(c_ubyte), c_int, c_int, c_void_p) CMPFUNC = CFUNCTYPE(None, POINTER(c_ubyte), POINTER(c_ubyte), c_int, c_int, POINTER(c_ubyte), c_int, c_int, c_void_p)
cmp_func = CMPFUNC(callbackfunction) cmp_func = CMPFUNC(callbackfunction)

View file

@ -332,7 +332,7 @@ void WINAPI tdInit(void) {
* @since Version 2.0.0 * @since Version 2.0.0
**/ **/
int WINAPI tdRegisterDeviceEvent( TDDeviceEvent eventFunction, void *context ) { int WINAPI tdRegisterDeviceEvent( TDDeviceEvent eventFunction, void *context ) {
eventFunction; Client *client = Client::getInstance(); Client *client = Client::getInstance();
return client->registerEvent( CallbackStruct::DeviceEvent, (void *)eventFunction, context ); return client->registerEvent( CallbackStruct::DeviceEvent, (void *)eventFunction, context );
} }
@ -1013,7 +1013,7 @@ char * WINAPI tdGetErrorString(int intErrorNo) {
"Received an unknown response", "Received an unknown response",
"Syntax error", "Syntax error",
"Broken pipe" "Broken pipe"
"An error occured while communicating with the Telldus Service" "An error occurred while communicating with the Telldus Service"
}; };
std::string strReturn; std::string strReturn;
intErrorNo = abs(intErrorNo); //We don't use negative values here. intErrorNo = abs(intErrorNo); //We don't use negative values here.

View file

@ -39,7 +39,7 @@ std::wstring TelldusCore::charToWstring(const char *value) {
size_t outbytesLeft = utf8Length*sizeof(wchar_t); size_t outbytesLeft = utf8Length*sizeof(wchar_t);
//Copy the instring //Copy the instring
char *inString = new char[strlen(value)+1]; char *inString = new char[utf8Length+1];
strcpy(inString, value); strcpy(inString, value);
//Create buffer for output //Create buffer for output

View file

@ -199,9 +199,10 @@ void ControllerManager::loadStoredControllers() {
int id = d->settings.getNodeId(Settings::Controller, i); int id = d->settings.getNodeId(Settings::Controller, i);
d->controllers[id].controller = NULL; d->controllers[id].controller = NULL;
d->controllers[id].name = d->settings.getName(Settings::Controller, id); d->controllers[id].name = d->settings.getName(Settings::Controller, id);
d->controllers[id].type = d->settings.getControllerType(id); const int type = d->settings.getControllerType(id);
d->controllers[id].type = type;
d->controllers[id].serial = d->settings.getControllerSerial(id); d->controllers[id].serial = d->settings.getControllerSerial(id);
signalControllerEvent(id, TELLSTICK_DEVICE_ADDED, 0, L""); signalControllerEvent(id, TELLSTICK_DEVICE_ADDED, type, L"");
} }
} }

View file

@ -47,6 +47,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
argp_usage (state); argp_usage (state);
case ARGP_KEY_ARG: case ARGP_KEY_ARG:
if (state->next == state->argc) {
argp_usage (state);
}
command = arg; command = arg;
action = state->argv[state->next]; action = state->argv[state->next];
state->next = state->argc; state->next = state->argc;