zoom.h File Reference

Header for ZOOM. More...

#include <stdlib.h>
#include <yaz/yconfig.h>

Go to the source code of this file.

Defines

#define ZOOM_BEGIN_CDECL   YAZ_BEGIN_CDECL
#define ZOOM_END_CDECL   YAZ_END_CDECL
#define ZOOM_API(x)   x
#define ZOOM_ERROR_NONE   0
#define ZOOM_ERROR_CONNECT   10000
#define ZOOM_ERROR_MEMORY   10001
#define ZOOM_ERROR_ENCODE   10002
#define ZOOM_ERROR_DECODE   10003
#define ZOOM_ERROR_CONNECTION_LOST   10004
#define ZOOM_ERROR_INIT   10005
#define ZOOM_ERROR_INTERNAL   10006
#define ZOOM_ERROR_TIMEOUT   10007
#define ZOOM_ERROR_UNSUPPORTED_PROTOCOL   10008
#define ZOOM_ERROR_UNSUPPORTED_QUERY   10009
#define ZOOM_ERROR_INVALID_QUERY   10010
#define ZOOM_ERROR_CQL_PARSE   10011
#define ZOOM_ERROR_CQL_TRANSFORM   10012
#define ZOOM_ERROR_CCL_CONFIG   10013
#define ZOOM_ERROR_CCL_PARSE   10014
#define ZOOM_EVENT_NONE   0
#define ZOOM_EVENT_CONNECT   1
#define ZOOM_EVENT_SEND_DATA   2
#define ZOOM_EVENT_RECV_DATA   3
#define ZOOM_EVENT_TIMEOUT   4
#define ZOOM_EVENT_UNKNOWN   5
#define ZOOM_EVENT_SEND_APDU   6
#define ZOOM_EVENT_RECV_APDU   7
#define ZOOM_EVENT_RECV_RECORD   8
#define ZOOM_EVENT_RECV_SEARCH   9
#define ZOOM_EVENT_END   10
#define ZOOM_SELECT_READ   1
 select/poll socket mask: read
#define ZOOM_SELECT_WRITE   2
 select/poll socket mask: write
#define ZOOM_SELECT_EXCEPT   4
 select/poll socket mask: except

Typedefs

typedef
typedefZOOM_BEGIN_CDECL struct
ZOOM_options_p
ZOOM_options
typedef struct ZOOM_query_pZOOM_query
typedef struct ZOOM_connection_pZOOM_connection
typedef struct ZOOM_resultset_pZOOM_resultset
typedef struct ZOOM_record_pZOOM_record
typedef struct ZOOM_scanset_pZOOM_scanset
typedef struct ZOOM_package_pZOOM_package
typedef const char *(* ZOOM_options_callback )(void *handle, const char *name)

Functions

 ZOOM_connection_new (const char *host, int portnum)
 ZOOM_connection_create (ZOOM_options options)
 ZOOM_connection_connect (ZOOM_connection c, const char *host, int portnum)
 ZOOM_connection_destroy (ZOOM_connection c)
 ZOOM_connection_option_get (ZOOM_connection c, const char *key)
 ZOOM_connection_option_getl (ZOOM_connection c, const char *key, int *lenp)
 ZOOM_connection_option_set (ZOOM_connection c, const char *key, const char *val)
 ZOOM_connection_option_setl (ZOOM_connection c, const char *key, const char *val, int len)
 ZOOM_connection_error (ZOOM_connection c, const char **cp, const char **addinfo)
 ZOOM_connection_error_x (ZOOM_connection c, const char **cp, const char **addinfo, const char **diagset)
 ZOOM_connection_errcode (ZOOM_connection c)
 ZOOM_connection_errmsg (ZOOM_connection c)
 ZOOM_connection_addinfo (ZOOM_connection c)
 ZOOM_connection_diagset (ZOOM_connection c)
 ZOOM_diag_str (int error)
 ZOOM_connection_last_event (ZOOM_connection cs)
 ZOOM_connection_search (ZOOM_connection, ZOOM_query q)
 ZOOM_connection_search_pqf (ZOOM_connection c, const char *q)
 ZOOM_resultset_destroy (ZOOM_resultset r)
 ZOOM_resultset_option_get (ZOOM_resultset r, const char *key)
 ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val)
 ZOOM_resultset_size (ZOOM_resultset r)
 ZOOM_resultset_records (ZOOM_resultset r, ZOOM_record *recs, size_t start, size_t count)
 ZOOM_resultset_record (ZOOM_resultset s, size_t pos)
 ZOOM_resultset_record_immediate (ZOOM_resultset s, size_t pos)
 ZOOM_resultset_cache_reset (ZOOM_resultset r)
 ZOOM_record_get (ZOOM_record rec, const char *type, int *len)
 ZOOM_record_destroy (ZOOM_record rec)
 ZOOM_record_clone (ZOOM_record srec)
 ZOOM_record_error (ZOOM_record rec, const char **msg, const char **addinfo, const char **diagset)
 ZOOM_query_create (void)
 ZOOM_query_destroy (ZOOM_query s)
 ZOOM_query_cql (ZOOM_query s, const char *str)
 ZOOM_query_cql2rpn (ZOOM_query s, const char *str, ZOOM_connection conn)
 ZOOM_query_ccl2rpn (ZOOM_query s, const char *query_str, const char *config, int *ccl_error, const char **error_string, int *error_pos)
 ZOOM_query_prefix (ZOOM_query s, const char *str)
 ZOOM_query_sortby (ZOOM_query s, const char *criteria)
 ZOOM_connection_scan (ZOOM_connection c, const char *startterm)
 ZOOM_connection_scan1 (ZOOM_connection c, ZOOM_query startterm)
 ZOOM_scanset_term (ZOOM_scanset scan, size_t pos, int *occ, int *len)
 ZOOM_scanset_display_term (ZOOM_scanset scan, size_t pos, int *occ, int *len)
 ZOOM_scanset_size (ZOOM_scanset scan)
 ZOOM_scanset_destroy (ZOOM_scanset scan)
 ZOOM_scanset_option_get (ZOOM_scanset scan, const char *key)
 ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key, const char *val)
 ZOOM_connection_package (ZOOM_connection c, ZOOM_options options)
 ZOOM_package_destroy (ZOOM_package p)
 ZOOM_package_send (ZOOM_package p, const char *type)
 ZOOM_package_option_get (ZOOM_package p, const char *key)
 ZOOM_package_option_getl (ZOOM_package p, const char *key, int *lenp)
 ZOOM_package_option_set (ZOOM_package p, const char *key, const char *val)
 ZOOM_package_option_setl (ZOOM_package p, const char *key, const char *val, int len)
 ZOOM_resultset_sort (ZOOM_resultset r, const char *sort_type, const char *sort_spec)
 ZOOM_resultset_sort1 (ZOOM_resultset r, const char *sort_type, const char *sort_spec)
 ZOOM_options_set_callback (ZOOM_options opt, ZOOM_options_callback c, void *handle)
 ZOOM_options_create (void)
 ZOOM_options_create_with_parent (ZOOM_options parent)
 ZOOM_options_create_with_parent2 (ZOOM_options parent1, ZOOM_options parent2)
 ZOOM_options_dup (ZOOM_options src)
 ZOOM_options_get (ZOOM_options opt, const char *name)
 ZOOM_options_getl (ZOOM_options opt, const char *name, int *lenp)
 ZOOM_options_set (ZOOM_options opt, const char *name, const char *v)
 ZOOM_options_setl (ZOOM_options opt, const char *name, const char *value, int len)
 ZOOM_options_destroy (ZOOM_options opt)
 ZOOM_options_get_bool (ZOOM_options opt, const char *name, int defa)
 ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa)
 ZOOM_options_set_int (ZOOM_options opt, const char *name, int value)
 ZOOM_event (int no, ZOOM_connection *cs)
 wait for events on connection(s) (BLOCKING)
 ZOOM_connection_is_idle (ZOOM_connection c)
 determines if connection is idle (no active or pending work)
 ZOOM_event_nonblock (int no, ZOOM_connection *cs)
 process one event for one of connections given
 ZOOM_connection_process (ZOOM_connection c)
 process one event for connection
 ZOOM_connection_get_socket (ZOOM_connection c)
 get socket fd for ZOOM connection
 ZOOM_connection_get_mask (ZOOM_connection c)
 get socket mask for connection
 ZOOM_connection_set_mask (ZOOM_connection c, int mask)
 set socket mask for connection (DO NOT call outside zoom)
 ZOOM_connection_get_timeout (ZOOM_connection c)
 get timeout in seconds for ZOOM connection
 ZOOM_connection_fire_event_timeout (ZOOM_connection c)
 fire socket event timeout
 ZOOM_connection_fire_event_socket (ZOOM_connection c, int mask)
 fire socket event activity (read,write,except)
 ZOOM_connection_peek_event (ZOOM_connection c)
 peek at next event


Detailed Description

Header for ZOOM.

Definition in file zoom.h.


Define Documentation

#define ZOOM_API (  )     x

Definition at line 42 of file zoom.h.

#define ZOOM_BEGIN_CDECL   YAZ_BEGIN_CDECL

Definition at line 36 of file zoom.h.

#define ZOOM_END_CDECL   YAZ_END_CDECL

Definition at line 37 of file zoom.h.

#define ZOOM_ERROR_CCL_CONFIG   10013

Definition at line 137 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_CCL_PARSE   10014

Definition at line 138 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_CONNECT   10000

Definition at line 124 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_CONNECTION_LOST   10004

Definition at line 128 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_CQL_PARSE   10011

Definition at line 135 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_CQL_TRANSFORM   10012

Definition at line 136 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_DECODE   10003

Definition at line 127 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_ENCODE   10002

Definition at line 126 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_INIT   10005

Definition at line 129 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_INTERNAL   10006

Definition at line 130 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_INVALID_QUERY   10010

Definition at line 134 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_MEMORY   10001

Definition at line 125 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_NONE   0

Definition at line 123 of file zoom.h.

Referenced by ZOOM_connection_connect(), ZOOM_connection_create(), and ZOOM_diag_str().

#define ZOOM_ERROR_TIMEOUT   10007

Definition at line 131 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_UNSUPPORTED_PROTOCOL   10008

Definition at line 132 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_ERROR_UNSUPPORTED_QUERY   10009

Definition at line 133 of file zoom.h.

Referenced by ZOOM_diag_str().

#define ZOOM_EVENT_CONNECT   1

Definition at line 144 of file zoom.h.

#define ZOOM_EVENT_END   10

Definition at line 153 of file zoom.h.

Referenced by ZOOM_connection_remove_task().

#define ZOOM_EVENT_NONE   0

Definition at line 143 of file zoom.h.

Referenced by ZOOM_API(), ZOOM_connection_create(), and ZOOM_connection_last_event().

#define ZOOM_EVENT_RECV_APDU   7

Definition at line 150 of file zoom.h.

#define ZOOM_EVENT_RECV_DATA   3

Definition at line 146 of file zoom.h.

#define ZOOM_EVENT_RECV_RECORD   8

Definition at line 151 of file zoom.h.

#define ZOOM_EVENT_RECV_SEARCH   9

Definition at line 152 of file zoom.h.

#define ZOOM_EVENT_SEND_APDU   6

Definition at line 149 of file zoom.h.

#define ZOOM_EVENT_SEND_DATA   2

Definition at line 145 of file zoom.h.

#define ZOOM_EVENT_TIMEOUT   4

Definition at line 147 of file zoom.h.

#define ZOOM_EVENT_UNKNOWN   5

Definition at line 148 of file zoom.h.

#define ZOOM_SELECT_EXCEPT   4

select/poll socket mask: except

Definition at line 356 of file zoom.h.

Referenced by ZOOM_event_sys_yaz_poll().

#define ZOOM_SELECT_READ   1

select/poll socket mask: read

Definition at line 352 of file zoom.h.

Referenced by ZOOM_event_sys_yaz_poll().

#define ZOOM_SELECT_WRITE   2

select/poll socket mask: write

Definition at line 354 of file zoom.h.

Referenced by ZOOM_event_sys_yaz_poll().


Typedef Documentation

Definition at line 52 of file zoom.h.

typedef typedefZOOM_BEGIN_CDECL struct ZOOM_options_p* ZOOM_options

Definition at line 50 of file zoom.h.

typedef const char*(* ZOOM_options_callback)(void *handle, const char *name)

Definition at line 58 of file zoom.h.

typedef struct ZOOM_package_p* ZOOM_package

Definition at line 56 of file zoom.h.

typedef struct ZOOM_query_p* ZOOM_query

Definition at line 51 of file zoom.h.

typedef struct ZOOM_record_p* ZOOM_record

Definition at line 54 of file zoom.h.

Definition at line 53 of file zoom.h.

typedef struct ZOOM_scanset_p* ZOOM_scanset

Definition at line 55 of file zoom.h.


Function Documentation

ZOOM_connection_addinfo ( ZOOM_connection  c  ) 

Definition at line 4206 of file zoom-c.c.

References ZOOM_connection_error().

ZOOM_connection_connect ( ZOOM_connection  c,
const char *  host,
int  portnum 
)

ZOOM_connection_create ( ZOOM_options  options  ) 

ZOOM_connection_destroy ( ZOOM_connection  c  ) 

ZOOM_connection_diagset ( ZOOM_connection  c  ) 

Definition at line 4214 of file zoom-c.c.

References ZOOM_connection_error_x().

ZOOM_connection_errcode ( ZOOM_connection  c  ) 

Definition at line 4192 of file zoom-c.c.

References ZOOM_connection_error().

ZOOM_connection_errmsg ( ZOOM_connection  c  ) 

Definition at line 4198 of file zoom-c.c.

References ZOOM_connection_error().

ZOOM_connection_error ( ZOOM_connection  c,
const char **  cp,
const char **  addinfo 
)

ZOOM_connection_error_x ( ZOOM_connection  c,
const char **  cp,
const char **  addinfo,
const char **  diagset 
)

Definition at line 4264 of file zoom-c.c.

References yaz_diag_srw_str(), z_HTTP_errmsg(), and ZOOM_diag_str().

Referenced by ZOOM_connection_diagset(), and ZOOM_connection_error().

ZOOM_connection_fire_event_socket ( ZOOM_connection  c,
int  mask 
)

fire socket event activity (read,write,except)

Parameters:
c connection
mask or'ed mask of ZOOM_SELECT_.. values
Return values:
0 event was fired OK
-1 event was not fired

Referenced by ZOOM_event_sys_yaz_poll().

ZOOM_connection_fire_event_timeout ( ZOOM_connection  c  ) 

fire socket event timeout

Parameters:
c connection
Return values:
0 event was fired OK
-1 event was not fired
Call this function when a timeout occurs - for example in the case of select(2) returning 0.

Referenced by ZOOM_event_sys_yaz_poll().

ZOOM_connection_get_mask ( ZOOM_connection  c  ) 

get socket mask for connection

Parameters:
c connection
Returns:
mask for connection (possibly 0)
Use this function when preparing for socket select/poll and in conjunction with ZOOM_connection_get_socket.

Referenced by ZOOM_event_sys_yaz_poll().

ZOOM_connection_get_socket ( ZOOM_connection  c  ) 

get socket fd for ZOOM connection

Parameters:
c connection
Return values:
-1 no socket assigned for connection
>=0 socket for connection
Use this function when preparing for socket/poll and in conjunction with ZOOM_connection_get_mask.

Referenced by ZOOM_event_sys_yaz_poll().

ZOOM_connection_get_timeout ( ZOOM_connection  c  ) 

get timeout in seconds for ZOOM connection

Parameters:
c connection
Returns:
timeout value in seconds
Use this function when preparing for socket/poll and in conjunction with ZOOM_connection_get_socket.

Referenced by ZOOM_event_sys_yaz_poll().

ZOOM_connection_is_idle ( ZOOM_connection  c  ) 

determines if connection is idle (no active or pending work)

Parameters:
c connection
Return values:
1 is idle
0 is non-idle (active)

ZOOM_connection_last_event ( ZOOM_connection  cs  ) 

Definition at line 4367 of file zoom-c.c.

References ZOOM_EVENT_NONE.

ZOOM_connection_new ( const char *  host,
int  portnum 
)

Definition at line 429 of file zoom-c.c.

References ZOOM_connection_connect(), and ZOOM_connection_create().

ZOOM_connection_option_get ( ZOOM_connection  c,
const char *  key 
)

Definition at line 4152 of file zoom-c.c.

References ZOOM_options_get().

ZOOM_connection_option_getl ( ZOOM_connection  c,
const char *  key,
int *  lenp 
)

Definition at line 4158 of file zoom-c.c.

References ZOOM_options_getl().

ZOOM_connection_option_set ( ZOOM_connection  c,
const char *  key,
const char *  val 
)

Definition at line 4164 of file zoom-c.c.

References ZOOM_options_set().

Referenced by ZOOM_connection_connect().

ZOOM_connection_option_setl ( ZOOM_connection  c,
const char *  key,
const char *  val,
int  len 
)

Definition at line 4171 of file zoom-c.c.

References ZOOM_options_setl().

ZOOM_connection_package ( ZOOM_connection  c,
ZOOM_options  options 
)

ZOOM_connection_peek_event ( ZOOM_connection  c  ) 

peek at next event

Parameters:
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_connection_process ( ZOOM_connection  c  ) 

process one event for connection

Parameters:
c connection
Return values:
0 no event was processed
1 event was processed for connection
This function attemps to deal with outstandings events in 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. If an event was processed call this function again.

Definition at line 4452 of file zoom-c.c.

Referenced by ZOOM_event_nonblock().

ZOOM_connection_scan ( ZOOM_connection  c,
const char *  startterm 
)

ZOOM_connection_scan1 ( ZOOM_connection  c,
ZOOM_query  startterm 
)

ZOOM_connection_search ( ZOOM_connection  ,
ZOOM_query  q 
)

ZOOM_connection_search_pqf ( ZOOM_connection  c,
const char *  q 
)

ZOOM_connection_set_mask ( ZOOM_connection  c,
int  mask 
)

set socket mask for connection (DO NOT call outside zoom)

Referenced by ZOOM_connection_create().

ZOOM_diag_str ( int  error  ) 

ZOOM_event ( int  no,
ZOOM_connection cs 
)

wait for events on connection(s) (BLOCKING)

Parameters:
no number of connections (size of cs)
cs connection array
Return values:
0 no event was fired
>0 event was fired for connection at (retval-1)
blocking poll for events on a number of connections. Returns positive integer if event occurred ; zero if none occurred and no more events are pending. The positive integer specifies the connection for which the event occurred.

Definition at line 96 of file zoom-socket.c.

References ZOOM_event_nonblock(), and ZOOM_event_sys_yaz_poll().

Referenced by ZOOM_connection_connect(), ZOOM_connection_scan1(), ZOOM_connection_search(), ZOOM_package_send(), and ZOOM_resultset_sort1().

ZOOM_event_nonblock ( int  no,
ZOOM_connection cs 
)

process one event for one of connections given

Parameters:
no number of connections (size of cs)
cs connection array
Return values:
0 no event was processed
>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.

Definition at line 4475 of file zoom-c.c.

References yaz_log(), and ZOOM_connection_process().

Referenced by ZOOM_event().

ZOOM_options_create ( void   ) 

Definition at line 67 of file zoom-opt.c.

References ZOOM_options_create_with_parent().

Referenced by ZOOM_options_dup().

ZOOM_options_create_with_parent ( ZOOM_options  parent  ) 

ZOOM_options_create_with_parent2 ( ZOOM_options  parent1,
ZOOM_options  parent2 
)

Definition at line 74 of file zoom-opt.c.

References opt, and xmalloc.

Referenced by ZOOM_connection_package(), and ZOOM_options_create_with_parent().

ZOOM_options_destroy ( ZOOM_options  opt  ) 

ZOOM_options_dup ( ZOOM_options  src  ) 

ZOOM_options_get ( ZOOM_options  opt,
const char *  name 
)

ZOOM_options_get_bool ( ZOOM_optio