home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / openobex / obex.h < prev   
Encoding:
C/C++ Source or Header  |  2008-11-11  |  5.2 KB  |  152 lines

  1. /*
  2.  *
  3.  *  OpenOBEX - Free implementation of the Object Exchange protocol
  4.  *
  5.  *  Copyright (C) 1999-2000  Dag Brattli <dagb@cs.uit.no>
  6.  *  Copyright (C) 1999-2000  Pontus Fuchs <pontus.fuchs@tactel.se>
  7.  *  Copyright (C) 2001-2002  Jean Tourrilhes <jt@hpl.hp.com>
  8.  *  Copyright (C) 2002-2006  Marcel Holtmann <marcel@holtmann.org>
  9.  *
  10.  *
  11.  *  This library is free software; you can redistribute it and/or
  12.  *  modify it under the terms of the GNU Lesser General Public
  13.  *  License as published by the Free Software Foundation; either
  14.  *  version 2.1 of the License, or (at your option) any later version.
  15.  *
  16.  *  This library 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 GNU
  19.  *  Lesser General Public License for more details.
  20.  *
  21.  *  You should have received a copy of the GNU Lesser General Public
  22.  *  License along with this library; if not, write to the Free Software
  23.  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  24.  *
  25.  */
  26.  
  27. #ifndef __OBEX_H
  28. #define __OBEX_H
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #include <inttypes.h>
  35.  
  36. #ifdef _WIN32
  37. #include <winsock.h>
  38. #else
  39. #include <sys/socket.h>
  40. #endif
  41.  
  42. /* Hum... This would need to be autogenerated from configure,
  43.  * I hate hardcoding version numbers. Jean II */
  44. #define OPENOBEX_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
  45. //#define OPENOBEX_VERSION_CODE    OPENOBEX_VERSION(1,0,0)
  46.  
  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. #ifndef SOL_RFCOMM
  56. typedef char* bdaddr_t;
  57. #endif
  58.  
  59. #include <openobex/obex_const.h>
  60.  
  61. /*
  62.  *  OBEX API
  63.  */
  64. obex_t *OBEX_Init(int transport, obex_event_t eventcb, unsigned int flags);
  65. void    OBEX_Cleanup(obex_t *self);
  66. void OBEX_SetUserData(obex_t *self, void * data);
  67. void * OBEX_GetUserData(obex_t *self);
  68. void OBEX_SetUserCallBack(obex_t *self, obex_event_t eventcb, void * data);
  69. int OBEX_SetTransportMTU(obex_t *self, uint16_t mtu_rx, uint16_t mtu_tx_max);
  70. int OBEX_GetFD(obex_t *self);
  71.  
  72. int OBEX_RegisterCTransport(obex_t *self, obex_ctrans_t *ctrans);
  73. void OBEX_SetCustomData(obex_t *self, void * data);
  74. void * OBEX_GetCustomData(obex_t *self);
  75.  
  76. int    OBEX_TransportConnect(obex_t *self, struct sockaddr *saddr, int addlen);
  77. int    OBEX_TransportDisconnect(obex_t *self);
  78. int    OBEX_CustomDataFeed(obex_t *self, uint8_t *inputbuf, int actual);
  79. int    OBEX_HandleInput(obex_t *self, int timeout);
  80.  
  81. int    OBEX_ServerRegister(obex_t *self, struct sockaddr *saddr, int addrlen);
  82. obex_t *OBEX_ServerAccept(obex_t *server, obex_event_t eventcb, void * data);
  83. int    OBEX_Request(obex_t *self, obex_object_t *object);
  84. int    OBEX_CancelRequest(obex_t *self, int nice);
  85. int    OBEX_SuspendRequest(obex_t *self, obex_object_t *object);
  86. int    OBEX_ResumeRequest(obex_t *self);
  87.  
  88. obex_object_t    *OBEX_ObjectNew(obex_t *self, uint8_t cmd);
  89. int        OBEX_ObjectDelete(obex_t *self, obex_object_t *object);
  90.  
  91. int        OBEX_ObjectAddHeader(obex_t *self, obex_object_t *object, uint8_t hi, 
  92.             obex_headerdata_t hv, uint32_t hv_size, unsigned int flags);
  93. int OBEX_ObjectGetNextHeader(obex_t *self, obex_object_t *object, uint8_t *hi,
  94.                     obex_headerdata_t *hv,
  95.                     uint32_t *hv_size);
  96. int OBEX_ObjectReParseHeaders(obex_t *self, obex_object_t *object);
  97. int OBEX_ObjectSetRsp(obex_object_t *object, uint8_t rsp, uint8_t lastrsp);
  98.  
  99. int OBEX_ObjectGetNonHdrData(obex_object_t *object, uint8_t **buffer);
  100. int OBEX_ObjectSetNonHdrData(obex_object_t *object, const uint8_t *buffer, unsigned int len);
  101. int OBEX_ObjectSetHdrOffset(obex_object_t *object, unsigned int offset);
  102. int OBEX_ObjectReadStream(obex_t *self, obex_object_t *object, const uint8_t **buf);
  103.  
  104. int OBEX_UnicodeToChar(uint8_t *c, const uint8_t *uc, int size);
  105. int OBEX_CharToUnicode(uint8_t *uc, const uint8_t *c, int size);
  106.  
  107. char *OBEX_ResponseToString(int rsp);
  108.  
  109. /*
  110.  * This function is deprecated and will be removed in OpenOBEX 1.1.0
  111.  *
  112.  * Please use the OBEX_ResponseToString instead.
  113.  *
  114.  */
  115. char* OBEX_GetResponseMessage(obex_t *self, int rsp);
  116.  
  117. /*
  118.  * InOBEX API (TCP/IP)
  119.  */
  120.  int InOBEX_ServerRegister(obex_t *self);
  121.  int InOBEX_TransportConnect(obex_t *self, struct sockaddr *saddr, int addrlen);
  122.  
  123. /*
  124.  * IrOBEX API 
  125.  */
  126.  int IrOBEX_ServerRegister(obex_t *self, const char *service);
  127.  int IrOBEX_TransportConnect(obex_t *self, const char *service);
  128.  
  129. /*
  130.  * Bluetooth OBEX API
  131.  */
  132.  int BtOBEX_ServerRegister(obex_t *self, bdaddr_t *src, uint8_t channel);
  133.  int BtOBEX_TransportConnect(obex_t *self, bdaddr_t *src, bdaddr_t *dst, uint8_t channel);
  134.  
  135. /*
  136.  * OBEX File API
  137.  */
  138. int FdOBEX_TransportSetup(obex_t *self, int rfd, int wfd, int mtu);
  139.  
  140. /*  
  141.  * OBEX interface discovery API 
  142.  */
  143.  int OBEX_FindInterfaces(obex_t *self, obex_interface_t **interfaces);
  144.  int OBEX_InterfaceConnect(obex_t *self, obex_interface_t *interface);
  145.  void OBEX_FreeInterfaces(obex_t *self);
  146.  
  147. #ifdef __cplusplus
  148. }
  149. #endif
  150.  
  151. #endif /* __OBEX_H */
  152.