obex.h
上传用户:detong
上传日期:2022-06-22
资源大小:20675k
文件大小:7k
源码类别:

系统编程

开发平台:

Unix_Linux

  1. /**
  2. file openobex/obex.h
  3. OpenOBEX library - Free implementation of the Object Exchange protocol.
  4. Copyright (C) 1999-2000  Dag Brattli <dagb@cs.uit.no>
  5. Copyright (C) 1999-2000  Pontus Fuchs <pontus.fuchs@tactel.se>
  6. Copyright (C) 2001-2002  Jean Tourrilhes <jt@hpl.hp.com>
  7. Copyright (C) 2002-2006  Marcel Holtmann <marcel@holtmann.org>
  8. Copyright (C) 2002-2008  Christian W. Zuckschwerdt <zany@triq.net>
  9. Copyright (C) 2002  Dmitry Kasatkin <dmitry.kasatkin@nokia.com>
  10. Copyright (C) 2005  Herton Ronaldo Krzesinski <herton@conectiva.com.br>
  11. Copyright (C) 2005-2008  Alex Kanavin <ak@sensi.org>
  12. Copyright (C) 2006  Johan Hedberg <johan.hedberg@nokia.com>
  13. Copyright (C) 2007-2008  Hendrik Sattler <post@hendrik-sattler.de>
  14. OpenOBEX is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU Lesser General Public License as
  16. published by the Free Software Foundation; either version 2.1 of
  17. the License, or (at your option) any later version.
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU Lesser General Public License for more details.
  22. You should have received a copy of the GNU Lesser General Public
  23. License along with OpenOBEX. If not, see <http://www.gnu.org/>.
  24.  */
  25. #ifndef OPENOBEX_OBEX_H
  26. #define OPENOBEX_OBEX_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #ifdef _WIN32
  31. #include <winsock2.h>
  32. #ifdef OPENOBEX_DLL
  33. #define OPENOBEX_SYMBOL(retval) __declspec(dllimport) retval WINAPI
  34. #else
  35. #define OPENOBEX_SYMBOL(retval) retval WINAPI
  36. #endif
  37. #else /* _WIN32 */
  38. #include <sys/socket.h>
  39. #endif /* _WIN32 */
  40. #include <inttypes.h>
  41. #ifndef OPENOBEX_SYMBOL
  42. #define OPENOBEX_SYMBOL(retval) retval
  43. #endif
  44. /* Hum... This would need to be autogenerated from configure,
  45.  * I hate hardcoding version numbers. Jean II */
  46. #define OPENOBEX_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
  47. // These are also defined in obex_main.h
  48. // They are defined here otherwise any app including it
  49. // would require obex_main.h which includes a lot of other 
  50. // unnecessary stuff.
  51. typedef void* obex_t;
  52. typedef void* obex_object_t;
  53. typedef void (*obex_event_t)(obex_t *handle, obex_object_t *obj, int mode, int event, int obex_cmd, int obex_rsp);
  54. // This is to workaround compilation without Bluetooth support. - Jean II
  55. #include <openobex/obex_const.h>
  56. /*
  57.  *  OBEX API
  58.  */
  59. OPENOBEX_SYMBOL(obex_t *) OBEX_Init(int transport, obex_event_t eventcb, unsigned int flags);
  60. OPENOBEX_SYMBOL(void)     OBEX_Cleanup(obex_t *self);
  61. OPENOBEX_SYMBOL(void)     OBEX_SetUserData(obex_t *self, void * data);
  62. OPENOBEX_SYMBOL(void *)   OBEX_GetUserData(obex_t *self);
  63. OPENOBEX_SYMBOL(void)     OBEX_SetUserCallBack(obex_t *self, obex_event_t eventcb, void * data);
  64. OPENOBEX_SYMBOL(int)      OBEX_SetTransportMTU(obex_t *self, uint16_t mtu_rx, uint16_t mtu_tx_max);
  65. OPENOBEX_SYMBOL(int)      OBEX_GetFD(obex_t *self);
  66. OPENOBEX_SYMBOL(int)    OBEX_RegisterCTransport(obex_t *self, obex_ctrans_t *ctrans);
  67. OPENOBEX_SYMBOL(void)   OBEX_SetCustomData(obex_t *self, void * data);
  68. OPENOBEX_SYMBOL(void *) OBEX_GetCustomData(obex_t *self);
  69. OPENOBEX_SYMBOL(int) OBEX_TransportConnect(obex_t *self, struct sockaddr *saddr, int addlen);
  70. OPENOBEX_SYMBOL(int) OBEX_TransportDisconnect(obex_t *self);
  71. OPENOBEX_SYMBOL(int) OBEX_CustomDataFeed(obex_t *self, uint8_t *inputbuf, int actual);
  72. OPENOBEX_SYMBOL(int) OBEX_HandleInput(obex_t *self, int timeout);
  73. OPENOBEX_SYMBOL(int)      OBEX_ServerRegister(obex_t *self, struct sockaddr *saddr, int addrlen);
  74. OPENOBEX_SYMBOL(obex_t *) OBEX_ServerAccept(obex_t *server, obex_event_t eventcb, void * data);
  75. OPENOBEX_SYMBOL(int) OBEX_Request(obex_t *self, obex_object_t *object);
  76. OPENOBEX_SYMBOL(int) OBEX_CancelRequest(obex_t *self, int nice);
  77. OPENOBEX_SYMBOL(int) OBEX_SuspendRequest(obex_t *self, obex_object_t *object);
  78. OPENOBEX_SYMBOL(int) OBEX_ResumeRequest(obex_t *self);
  79. OPENOBEX_SYMBOL(obex_object_t *) OBEX_ObjectNew(obex_t *self, uint8_t cmd);
  80. OPENOBEX_SYMBOL(int)             OBEX_ObjectDelete(obex_t *self, obex_object_t *object);
  81. OPENOBEX_SYMBOL(int) OBEX_ObjectAddHeader(obex_t *self, obex_object_t *object,
  82.     uint8_t hi, obex_headerdata_t hv, uint32_t hv_size,
  83.     unsigned int flags);
  84. OPENOBEX_SYMBOL(int) OBEX_ObjectGetNextHeader(obex_t *self, obex_object_t *object,
  85. uint8_t *hi, obex_headerdata_t *hv, uint32_t *hv_size);
  86. OPENOBEX_SYMBOL(int) OBEX_ObjectReParseHeaders(obex_t *self, obex_object_t *object);
  87. OPENOBEX_SYMBOL(int) OBEX_ObjectSetRsp(obex_object_t *object, uint8_t rsp, uint8_t lastrsp);
  88. OPENOBEX_SYMBOL(int) OBEX_ObjectGetNonHdrData(obex_object_t *object, uint8_t **buffer);
  89. OPENOBEX_SYMBOL(int) OBEX_ObjectSetNonHdrData(obex_object_t *object, const uint8_t *buffer, unsigned int len);
  90. OPENOBEX_SYMBOL(int) OBEX_ObjectSetHdrOffset(obex_object_t *object, unsigned int offset);
  91. OPENOBEX_SYMBOL(int) OBEX_ObjectReadStream(obex_t *self, obex_object_t *object, const uint8_t **buf);
  92. OPENOBEX_SYMBOL(int) OBEX_ObjectGetCommand(obex_t *self, obex_object_t *object);
  93. OPENOBEX_SYMBOL(int) OBEX_UnicodeToChar(uint8_t *c, const uint8_t *uc, int size);
  94. OPENOBEX_SYMBOL(int) OBEX_CharToUnicode(uint8_t *uc, const uint8_t *c, int size);
  95. OPENOBEX_SYMBOL(char *) OBEX_ResponseToString(int rsp);
  96. /*
  97.  * This function is deprecated and will be removed in OpenOBEX 1.1.0
  98.  *
  99.  * Please use the OBEX_ResponseToString instead.
  100.  *
  101.  */
  102. OPENOBEX_SYMBOL(char *) OBEX_GetResponseMessage(obex_t *self, int rsp);
  103. /*
  104.  * TcpOBEX API (IPv4/IPv6)
  105.  */
  106. OPENOBEX_SYMBOL(int) TcpOBEX_ServerRegister(obex_t *self, struct sockaddr *addr, int addrlen);
  107. OPENOBEX_SYMBOL(int) TcpOBEX_TransportConnect(obex_t *self, struct sockaddr *addr, int addrlen);
  108. /*
  109.  * InOBEX API (deprecated, maps to TcpOBEX_*)
  110.  */
  111. OPENOBEX_SYMBOL(int) InOBEX_ServerRegister(obex_t *self);
  112. OPENOBEX_SYMBOL(int) InOBEX_TransportConnect(obex_t *self, struct sockaddr *saddr, int addrlen);
  113. /*
  114.  * IrOBEX API 
  115.  */
  116. OPENOBEX_SYMBOL(int) IrOBEX_ServerRegister(obex_t *self, const char *service);
  117. OPENOBEX_SYMBOL(int) IrOBEX_TransportConnect(obex_t *self, const char *service);
  118. /*
  119.  * Bluetooth OBEX API
  120.  */
  121. #ifdef SOL_RFCOMM
  122. #ifdef _WIN32
  123. #define bdaddr_t BTH_ADDR
  124. #endif
  125. OPENOBEX_SYMBOL(int) BtOBEX_ServerRegister(obex_t *self, bdaddr_t *src, uint8_t channel);
  126. OPENOBEX_SYMBOL(int) BtOBEX_TransportConnect(obex_t *self, bdaddr_t *src, bdaddr_t *dst, uint8_t channel);
  127. #endif
  128. /*
  129.  * OBEX File API
  130.  */
  131. OPENOBEX_SYMBOL(int) FdOBEX_TransportSetup(obex_t *self, int rfd, int wfd, int mtu);
  132. /*  
  133.  * OBEX interface discovery API 
  134.  */
  135. OPENOBEX_SYMBOL(int)  OBEX_FindInterfaces(obex_t *self, obex_interface_t **intf);
  136. OPENOBEX_SYMBOL(int)  OBEX_InterfaceConnect(obex_t *self, obex_interface_t *intf);
  137. OPENOBEX_SYMBOL(void) OBEX_FreeInterfaces(obex_t *self);
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. #endif /* OPENOBEX_OBEX_H */