bt_gethostbyname bt_gethostbyaddr bt_gethostent bt_sethostent bt_endhostent bt_getprotobyname bt_getprotobynumber bt_getprotoent bt_setprotoent bt_endprotoent bt_aton bt_ntoa bdaddr_same bdaddr_any bdaddr_copy - Bluetooth routines
Lb libbluetooth
The
Fa name
argument passed to
bt_gethostbyname ();
should point to a
NUL -terminated
hostname.
The
Fa addr
argument passed to
bt_gethostbyaddr ();
should point to an address which is
Fa len
bytes long,
in binary form
(i.e., not a Bluetooth BD_ADDR in human readable
ASCII
form).
The
Fa type
argument specifies the address family of this address and must be set to
AF_BLUETOOTH
The structure returned contains the information obtained from a line in /etc/bluetooth/hosts file.
The
bt_sethostent ();
function controls whether
/etc/bluetooth/hosts
file should stay open after each call to
bt_gethostbyname ();
or
bt_gethostbyaddr (.);
If the
Fa stayopen
flag is non-zero, the file will not be closed.
The
bt_endhostent ();
function closes the
/etc/bluetooth/hosts
file.
The
bt_getprotoent (,);
bt_getprotobyname ();
and
bt_getprotobynumber ();
functions each return a pointer to an object with the
Vt protoent
structure describing a Bluetooth Protocol Service Multiplexor referenced
by name or number, respectively.
The
Fa name
argument passed to
bt_getprotobyname ();
should point to a
NUL -terminated
Bluetooth Protocol Service Multiplexor name.
The
Fa proto
argument passed to
bt_getprotobynumber ();
should have numeric value of the desired Bluetooth Protocol Service Multiplexor.
The structure returned contains the information obtained from a line in /etc/bluetooth/protocols file.
The
bt_setprotoent ();
function controls whether
/etc/bluetooth/protocols
file should stay open after each call to
bt_getprotobyname ();
or
bt_getprotobynumber (.);
If the
Fa stayopen
flag is non-zero, the file will not be closed.
The
bt_endprotoent ();
function closes the
/etc/bluetooth/protocols
file.
The
bt_aton ();
routine interprets the specified character string as a Bluetooth address,
placing the address into the structure provided.
It returns 1 if the string was successfully interpreted,
or 0 if the string is invalid.
The routine
bt_ntoa ();
takes a Bluetooth address and places an
ASCII
string representing the address into the buffer provided.
It is up to the caller to ensure that provided buffer has enough space.
If no buffer was provided then internal static buffer will be used.
The
bdaddr_same (,);
bdaddr_any ();
and
bdaddr_copy ();
are handy shorthand Bluetooth address utility functions.
The
bdaddr_same ();
function will test if two provided BD_ADDRs are the same.
The
bdaddr_any ();
function will test if provided BD_ADDR is
ANY
BD_ADDR.
The
bdaddr_copy ();
function will copy provided
Fa src
BD_ADDR into provided
Fa dst
BD_ADDR.
const char *bdstr = "00:01:02:03:04:05"; bdaddr_t bd; struct hostent *hp; if (!bt_aton(bdstr, &bd)) errx(1, "can't parse BD_ADDR %s", bdstr); if ((hp = bt_gethostbyaddr((const char *)&bd, sizeof(bd), AF_BLUETOOTH)) == NULL) errx(1, "no name associated with %s", bdstr); printf("name associated with %s is %s\n", bdstr, hp->h_name);
The variable h_errno can have the following values:
The
bt_getprotoent (,);
bt_getprotobyname ();
and
bt_getprotobynumber ();
return
NULL
on EOF or error.
The
bt_sethostent ();
function opens and/or rewinds the
/etc/bluetooth/hosts
file.
The
bt_getprotoent ();
function reads the next line of
/etc/bluetooth/protocols
opening the file if necessary.
The
bt_setprotoent ();
function opens and/or rewinds the
/etc/bluetooth/protocols
file.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |