The substates create situations where this function name doesn't fit anymore.
To avoid confusion, it is renamed to OBEX_Work(). The timeout argument is
now in milliseconds, the previous argument was in seconds which may be not
fine enough.
---
 doc/openobex.coverpage        |    2 +-
 include/openobex/obex.h       |    3 ++-
 include/openobex/obex_const.h |    2 +-
 lib/fdobex.c                  |   10 ++++++++--
 lib/obex.c                    |    6 +++---
 lib/obex.sym                  |    2 +-
 lib/obex_main.c               |    2 +-
 lib/obex_main.h               |    2 +-
 lib/obex_transport.c          |   12 +++++++++---
 lib/obex_transport.h          |    4 ++--
 lib/usb1obex.c                |    6 +++---
 lib/usbobex.c                 |    6 +++---
 12 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/doc/openobex.coverpage b/doc/openobex.coverpage
index 1f7715b..d90075f 100644
--- a/doc/openobex.coverpage
+++ b/doc/openobex.coverpage
@@ -35,7 +35,7 @@ First of all you must create an OBEX instance by calling 
#OBEX_New.
 In this call you specify what transport you want to use, an event callback, 
and optional flags.
 #OBEX_New will return a handle which shall be passed to almost all other 
functions.
 
-To let the parser do some work you must call #OBEX_HandleInput.
+To let the parser do some work you must call #OBEX_Work.
 It will block for at-most the specified timeout for read and write actions.
 You can call #OBEX_GetFD if you want to do select() yourself (this may not 
work with all transports).
 
diff --git a/include/openobex/obex.h b/include/openobex/obex.h
index ae91f6e..096d5a2 100644
--- a/include/openobex/obex.h
+++ b/include/openobex/obex.h
@@ -84,6 +84,7 @@ OPENOBEX_SYMBOL(void)     OBEX_SetUserCallBack(obex_t *self,
                                               void * data);
 OPENOBEX_SYMBOL(obex_t *) OBEX_ServerAccept(obex_t *server,
                                            obex_event_t eventcb, void * data);
+#define OBEX_HandleInput(self, timeout) OBEX_Work((self), ((timeout)*1000L))
 
 /*
  *  OBEX API
@@ -116,7 +117,7 @@ OPENOBEX_SYMBOL(void *) OBEX_GetCustomData(obex_t *self);
 OPENOBEX_SYMBOL(int) OBEX_TransportConnect(obex_t *self, struct sockaddr 
*saddr, int addlen);
 OPENOBEX_SYMBOL(int) OBEX_TransportDisconnect(obex_t *self);
 OPENOBEX_SYMBOL(int) OBEX_CustomDataFeed(obex_t *self, uint8_t *inputbuf, int 
actual);
-OPENOBEX_SYMBOL(int) OBEX_HandleInput(obex_t *self, int timeout);
+OPENOBEX_SYMBOL(int) OBEX_Work(obex_t *self, long timeout);
 
 OPENOBEX_SYMBOL(int)      OBEX_ServerRegister(obex_t *self, struct sockaddr 
*saddr, int addrlen);
 OPENOBEX_SYMBOL(obex_t *) OBEX_Accept(obex_t *server);
diff --git a/include/openobex/obex_const.h b/include/openobex/obex_const.h
index cdcd823..f0cbbf0 100644
--- a/include/openobex/obex_const.h
+++ b/include/openobex/obex_const.h
@@ -66,7 +66,7 @@ typedef struct {
        int (*read)(obex_t *handle, void *customdata, uint8_t *buf, int size);
        /** remote connection output */
        int (*write)(obex_t *handle, void *customdata, uint8_t *buf, int len);
-       /** directly called by #OBEX_HandleInput */
+       /** eventually called by OBEX_Work() */
        int (*handleinput)(obex_t *handle, void *customdata, int timeout);
        void *customdata;
 } obex_ctrans_t;
diff --git a/lib/fdobex.c b/lib/fdobex.c
index 70ae791..e057562 100644
--- a/lib/fdobex.c
+++ b/lib/fdobex.c
@@ -70,7 +70,10 @@ static int fdobex_write(obex_t *self, buf_t *msg)
        size_t size = msg->data_size;
        int status;
        fd_set fdset;
-       struct timeval time = {trans->timeout, 0};
+       struct timeval time = {
+               trans->timeout / 1000,
+               (trans->timeout % 1000) * 1000
+       };
 
        if (size == 0)
                return 0;
@@ -108,7 +111,10 @@ static int fdobex_read(obex_t *self, void *buf, int buflen)
        int status;
        int fd = trans->fd;
        fd_set fdset;
-       struct timeval time = {trans->timeout, 0};
+       struct timeval time = {
+               trans->timeout / 1000,
+               (trans->timeout % 1000) * 1000
+       };
 
        FD_ZERO(&fdset);
        FD_SET(fd, &fdset);
diff --git a/lib/obex.c b/lib/obex.c
index 460b0be..04016e1 100644
--- a/lib/obex.c
+++ b/lib/obex.c
@@ -390,7 +390,7 @@ obex_t *CALLAPI OBEX_Accept(obex_t *server)
 /**
        Let the OBEX parser do some work.
        \param self OBEX handle
-       \param timeout Maximum time to wait in seconds (-1 for infinite)
+       \param timeout Maximum time to wait in milliseconds (-1 for infinite)
        \return -1 on error, 0 on timeout, positive on success
 
        Let the OBEX parser read and process incoming data. If no data
@@ -404,7 +404,7 @@ obex_t *CALLAPI OBEX_Accept(obex_t *server)
        positive on success.
  */
 LIB_SYMBOL
-int CALLAPI OBEX_HandleInput(obex_t *self, int timeout)
+int CALLAPI OBEX_Work(obex_t *self, long timeout)
 {
        DEBUG(4, "\n");
        obex_return_val_if_fail(self != NULL, -1);
@@ -482,7 +482,7 @@ int CALLAPI OBEX_TransportDisconnect(obex_t *self)
        USB and custom transports do not.
 
        The returned filehandle can be used to do select() on, before
-       calling OBEX_HandleInput()
+       calling OBEX_Work()
 
        There is one subtelty about this function. When the OBEX connection is
        established, it returns the connection filedescriptor, while for
diff --git a/lib/obex.sym b/lib/obex.sym
index 6483738..3de52c7 100644
--- a/lib/obex.sym
+++ b/lib/obex.sym
@@ -13,7 +13,7 @@ OBEX_GetCustomData
 OBEX_TransportConnect
 OBEX_TransportDisconnect
 OBEX_CustomDataFeed
-OBEX_HandleInput
+OBEX_Work
 OBEX_ServerRegister
 OBEX_ServerAccept
 OBEX_Accept
diff --git a/lib/obex_main.c b/lib/obex_main.c
index 1233120..714571a 100644
--- a/lib/obex_main.c
+++ b/lib/obex_main.c
@@ -386,7 +386,7 @@ static int obex_mode(obex_t *self)
  *    Do some work on the current transferred object.
  *
  */
-int obex_work(obex_t *self, int timeout)
+int obex_work(obex_t *self, long timeout)
 {
        int ret;
 
diff --git a/lib/obex_main.h b/lib/obex_main.h
index d880bb8..be154d1 100644
--- a/lib/obex_main.h
+++ b/lib/obex_main.h
@@ -71,7 +71,7 @@ socket_t obex_create_packet_socket(obex_t *self, int domain);
 int obex_delete_socket(struct obex *self, socket_t fd);
 
 void obex_deliver_event(struct obex *self, int event, int cmd, int rsp, int 
del);
-int obex_work(struct obex *self, int timeout);
+int obex_work(struct obex *self, long timeout);
 int obex_get_buffer_status(buf_t *msg);
 int obex_data_indication(struct obex *self);
 buf_t* obex_data_receive(obex_t *self);
diff --git a/lib/obex_transport.c b/lib/obex_transport.c
index a41f6e6..1c03baa 100644
--- a/lib/obex_transport.c
+++ b/lib/obex_transport.c
@@ -207,7 +207,10 @@ int obex_transport_standard_handle_input(obex_t *self)
 
        /* Wait for input */
        if (trans->timeout >= 0) {
-               struct timeval time = { trans->timeout, 0 };
+               struct timeval time = {
+                       trans->timeout / 1000,
+                       (trans->timeout % 1000) * 1000
+               };
                ret = select((int) highestfd + 1, &fdset, NULL, NULL, &time);
        } else {
                ret = select((int) highestfd + 1, &fdset, NULL, NULL, NULL);
@@ -245,7 +248,7 @@ int obex_transport_standard_handle_input(obex_t *self)
  *    Used when working in synchronous mode.
  *
  */
-int obex_transport_handle_input(obex_t *self, int timeout)
+int obex_transport_handle_input(obex_t *self, long timeout)
 {
        DEBUG(4, "\n");
        self->trans.timeout = timeout;
@@ -369,7 +372,10 @@ int obex_transport_do_send (obex_t *self, buf_t *msg)
        int status;
        fd_set fdset;
        struct timeval *time_ptr = NULL;
-       struct timeval timeout = {trans->timeout, 0};
+       struct timeval timeout = {
+               trans->timeout / 1000,
+               (trans->timeout % 1000) * 1000
+       };
 
        if (size == 0)
                return 0;
diff --git a/lib/obex_transport.h b/lib/obex_transport.h
index b7a4423..8c3d7cb 100644
--- a/lib/obex_transport.h
+++ b/lib/obex_transport.h
@@ -110,7 +110,7 @@ typedef struct obex_transport {
        socket_t fd;            /* Socket descriptor */
        socket_t serverfd;
 
-       int timeout;            /* set timeout */
+       long timeout;           /* timeout in milliseconds */
 
        int connected;          /* Link connection state */
        unsigned int mtu;       /* Tx MTU of the link */
@@ -122,7 +122,7 @@ void obex_transport_cleanup(obex_t *self);
 void obex_transport_clone(obex_t *self, obex_t *old);
 void obex_transport_split(obex_t *self, obex_t *server);
 
-int obex_transport_handle_input(struct obex *self, int timeout);
+int obex_transport_handle_input(struct obex *self, long timeout);
 int obex_transport_connect_request(struct obex *self);
 void obex_transport_disconnect_request(struct obex *self);
 int obex_transport_listen(struct obex *self);
diff --git a/lib/usb1obex.c b/lib/usb1obex.c
index c00b55a..26f0c41 100644
--- a/lib/usb1obex.c
+++ b/lib/usb1obex.c
@@ -479,17 +479,17 @@ static int usbobex_disconnect_request(obex_t *self)
        return 1;
 }
 
-static unsigned int usbobex_get_timeout(int timeout)
+static unsigned int usbobex_get_timeout(long timeout)
 {
        /* uses closest to zero, 0 itself means infinite */
        if (timeout == 0) {
                return 1;
 
        } else if (timeout > 0) {
-               if ((unsigned int)timeout > UINT_MAX/1000)
+               if ((unsigned int)timeout > UINT_MAX)
                        return UINT_MAX;
                else
-                       return timeout * 1000;
+                       return timeout;
 
        }
        return 0;
diff --git a/lib/usbobex.c b/lib/usbobex.c
index 2ed26e1..a5f63f0 100644
--- a/lib/usbobex.c
+++ b/lib/usbobex.c
@@ -448,15 +448,15 @@ static int usbobex_disconnect_request(obex_t *self)
        return ret;
 }
 
-static int usbobex_get_timeout(int timeout)
+static int usbobex_get_timeout(long timeout)
 {
-       if (timeout < 0 || timeout > INT_MAX/1000) {
+       if (timeout < 0 || timeout > INT_MAX) {
                /* libusb-0.x doesn't know about waiting infinitely
                 * so we try with the largest value possible
                 */
                return INT_MAX;
        }
-       return timeout*1000;
+       return timeout;
 }
 
 static int usbobex_write(obex_t *self, buf_t *msg)
-- 
1.7.5.4


------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to