Define ZOOM_EVENT_MAX (max event ID)
[yaz-moved-to-github.git] / include / yaz / zoom.h
index 1128239..cdefb6f 100644 (file)
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 1995-2007, Index Data
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2008 Index Data.
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -24,7 +24,6 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: zoom.h,v 1.42 2007-01-09 13:56:48 adam Exp $ */
 
 /**
  * \file zoom.h
@@ -152,6 +151,7 @@ ZOOM_connection_last_event(ZOOM_connection cs);
 #define ZOOM_EVENT_RECV_RECORD 8
 #define ZOOM_EVENT_RECV_SEARCH 9
 #define ZOOM_EVENT_END 10
+#define ZOOM_EVENT_MAX 10
 
 /* ----------------------------------------------------------- */
 /* result sets */
@@ -173,7 +173,7 @@ ZOOM_resultset_option_get (ZOOM_resultset r, const char *key);
 ZOOM_API(void)
 ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val);
 
-/* return size of result set (alias hit count AKA result count) */
+/* return size of result set (alias hit count AKA result count) */
 ZOOM_API(size_t)
 ZOOM_resultset_size (ZOOM_resultset r);
 
@@ -284,10 +284,17 @@ ZOOM_API(void)
 ZOOM_API(const char *)
     ZOOM_package_option_get (ZOOM_package p, const char *key);
 
+ZOOM_API(const char *)
+    ZOOM_package_option_getl (ZOOM_package p, const char *key, int *lenp);
+
 ZOOM_API(void)
     ZOOM_package_option_set (ZOOM_package p, const char *key,
                              const char *val);
 
+ZOOM_API(void)
+    ZOOM_package_option_setl (ZOOM_package p, const char *key,
+                              const char *val, int len);
+
 /* ----------------------------------------------------------- */
 /* Sort.  First function is deprecated, use second instead */
 ZOOM_API(void)
@@ -314,6 +321,9 @@ ZOOM_API(ZOOM_options)
     ZOOM_options_create_with_parent2 (ZOOM_options parent1,
                                       ZOOM_options parent2);
 
+ZOOM_API(ZOOM_options)
+    ZOOM_options_dup(ZOOM_options src);
+
 ZOOM_API(const char *)
 ZOOM_options_get (ZOOM_options opt, const char *name);
 
@@ -370,21 +380,38 @@ ZOOM_API(int)
 ZOOM_connection_is_idle(ZOOM_connection c);
 
 
-/** \brief processes one event for one of connections given
+/** \brief process one event for one of connections given
     \param no number of connections (size of cs)
     \param cs connection array
     \retval 0 no event was processed
     \retval >0 event was processed for connection at (retval-1)
 
+    This function attemps to deal with outstandings events in a non-blocking
+    mode. If no events was processed (return value of 0),  then the system
+    should attempt to deal with sockets in blocking mode using socket
+    select/poll which means calling the following functions:
+    ZOOM_connection_get_socket, ZOOM_connection_get_mask,
+    ZOOM_connection_get_timeout.
+*/
+ZOOM_API(int)
+    ZOOM_event_nonblock(int no, ZOOM_connection *cs);
+
+
+/** \brief process one event for connection
+    \param c connection
+    \retval 0 no event was processed
+    \retval 1 event was processed for connection
+
     This function attemps to deal with outstandings events in 
-    a non-blocking fashion. If no events was processed (return value of 0),
+    a non-blocking fashion. If no event was processed (return value of 0),
     then the system should attempt to deal with sockets in blocking mode
     using socket select/poll which means calling the following functions:
     ZOOM_connection_get_socket, ZOOM_connection_get_mask,
-    ZOOM_connection_get_timeout.
+    ZOOM_connection_get_timeout. If an event was processed call this
+    function again.
 */
 ZOOM_API(int)
-    ZOOM_process_event(int no, ZOOM_connection *cs);
+    ZOOM_connection_process(ZOOM_connection c);
 
 
 /** \brief get socket fd for ZOOM connection
@@ -449,7 +476,22 @@ ZOOM_API(int)
 
 
 
+/** \brief peek at next event
+    \param c connection
+    \returns ZOOM_EVENT_NONE (for no events in queue), ZOOM_EVENT_CONNECT, ..
+
+    Does not actually remove the event from the event queue. ZOOM_event and
+    ZOOM_process_event removes one event.
+*/
+
+ZOOM_API(int)
+    ZOOM_connection_peek_event(ZOOM_connection c);
+
+ZOOM_API(const char *)
+    ZOOM_get_event_str(int event);
+
 ZOOM_END_CDECL
+
 /*
  * Local variables:
  * c-basic-offset: 4