common_util.h File Reference

#include <winsock2.h>
#include <bthdef.h>
#include <Ws2bth.h>
#include <Bthsdpdef.h>
#include <BluetoothAPIs.h>
#include <string.h>
#include <malloc.h>
#include <stdio.h>
#include <tchar.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

int asciiToUnicode (char *string, int length, wchar_t *outString, int size)
 Ascii to unicode string conversion function.
int authenticate (char *address, char *pinInput, BLUETOOTH_DEVICE_INFO *deviceInfo, int xml)
 Authenticates device.
int checkForWinSock ()
 Check for WinSock and Initialize it.
char * findDevice (BLUETOOTH_DEVICE_INFO *bdi, char *address)
 Finds Bluetooth Device.
ULONGLONG htoi (char *string)
 Converts Hex string to int.
int removeAuthentication (char *address)
 removes authentication
char * removeNonprintableChars (WCHAR *Input, SIZE_T Length)
 Remove non printable characters from unicode string.
BLUETOOTH_ADDRESS stringToAddress (char *address)
 Turns nullterminated string to BLUETOOTH_ADDRESS.
void takeOffStrangeMarks (char *string, int max)
 Takes off strange marks from string.
int utf8ToUnicode (char *string, int length, wchar_t *outString, int size)
 UTF-8 to unicode string conversion function.


Function Documentation

int asciiToUnicode ( char *  string,
int  length,
wchar_t *  outString,
int  size 
)

Ascii to unicode string conversion function.

Take ascii string and convert it into unicode string

Parameters:
string char*, Pointer to the string to convert
length int, Length of the string to convert
outString wchar_t*, Pointer to the string receiving the converted string
size int, Size of the outString in bytes
Returns:
The length of the string in characters or zero.

int authenticate ( char *  address,
char *  pinInput,
BLUETOOTH_DEVICE_INFO *  deviceInfo,
int  xml 
)

Authenticates device.

Tries to authenticate device, if already authenticated this does nothing. If pinInput is Null tries to authenticate with most common pin codes: 0000, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 1234 If pinInput is not null tries to authenticate with that one.

Parameters:
address Address to device
pinInput null terminated string as Pin Code
deviceInfo Bluetooth device info
xml tells that xml print wanted
Returns:
Returns zero if no error, -1 if error, -2 if already authenticated

int checkForWinSock (  ) 

Check for WinSock and Initialize it.

This function checks for WinSock 2.0 and Initializes it.

Returns:
int, 1 If succesful. 0 If failed.

char* findDevice ( BLUETOOTH_DEVICE_INFO *  bdi,
char *  address 
)

Finds Bluetooth Device.

Tries to find device by Bluetooth Device Name or by address

Remarks:
*name always returns device name
Parameters:
bdi BLUETOOTH_DEVICE_INFO*
address char*, null terminated string, Can be either address or name
Returns:
Returns device address, if error happens returns NULL

ULONGLONG htoi ( char *  string  ) 

Converts Hex string to int.

Converts null terminated string to Int

Parameters:
string char *
Returns:
int

int removeAuthentication ( char *  address  ) 

removes authentication

Tries to remove authentication from device using device address

Parameters:
address char*, Address to device
Returns:
Returns zero if no error, otherwise -1

char* removeNonprintableChars ( WCHAR *  Input,
SIZE_T  Length 
)

Remove non printable characters from unicode string.

Take unicode string and remove non printable characters

Parameters:
Input WCHAR*, Unicode string
Length SIZE_T, integer value of maxium size of string
Returns:
Null terminated string or NULL pointer if error occurs

BLUETOOTH_ADDRESS stringToAddress ( char *  address  ) 

Turns nullterminated string to BLUETOOTH_ADDRESS.

Changes nullterminated string to Bluetooth Address

Parameters:
address char *
Returns:
BLUETOOTH_ADDRESS

void takeOffStrangeMarks ( char *  string,
int  max 
)

Takes off strange marks from string.

Take ascii string and remove strange marks from it.

Parameters:
string char*, looking for string
max int, value of maxium size of string

int utf8ToUnicode ( char *  string,
int  length,
wchar_t *  outString,
int  size 
)

UTF-8 to unicode string conversion function.

Take UTF-8 encoded string and convert it into unicode string

Parameters:
string char*, Pointer to the string to convert
length int, Length of the string to convert in characters
outString wchar_t*, Pointer to the string receiving the converted string
size int, Size of the outString in bytes
Returns:
The length of the string in characters or zero.

footer


 SourceForge.net Logo