YAZ  5.34.0
Macros | Functions | Variables
statserv.c File Reference

Implements GFS logic. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <yaz/sc.h>
#include <yaz/tpath.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xinclude.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <yaz/comstack.h>
#include <yaz/tcpip.h>
#include <yaz/options.h>
#include <yaz/log.h>
#include "eventl.h"
#include "session.h"
#include <yaz/statserv.h>
#include <yaz/daemon.h>
#include <yaz/yaz-iconv.h>

Go to the source code of this file.

Macros

#define STAT_DEFAULT_LOG_LEVEL   "server,session,request"
 

Functions

int check_options (int argc, char **argv)
 
static void get_logbits (int force)
 
static int add_listener (char *where, int listen_id)
 
static xmlNodePtr xml_config_get_root (void)
 
static char * nmem_dup_xml_content (NMEM n, xmlNodePtr ptr)
 
static struct gfs_servergfs_server_new (const char *id)
 
static struct gfs_listengfs_listen_new (const char *id, const char *address)
 
static void gfs_server_chdir (struct gfs_server *gfs)
 
int control_association (association *assoc, const char *host, int force_open)
 
static void xml_config_read (const char *base_path)
 
static int xml_config_open (void)
 
static void xml_config_close (void)
 
static int xml_config_add_listeners (void)
 
static void xml_config_bend_start (void)
 
static void xml_config_bend_stop (void)
 
static void remove_listeners (void)
 
void statserv_remove (IOCHAN pIOChannel)
 
static void statserv_closedown (void)
 
static void * new_session (void *vp)
 
static void listener (IOCHAN h, int event)
 
static void inetd_connection (int what)
 
static void catchchld (int num)
 
statserv_options_blockstatserv_getcontrol (void)
 
void statserv_setcontrol (statserv_options_block *block)
 
static void statserv_reset (void)
 
static void normal_stop_handler (int num)
 
static void daemon_handler (void *data)
 
static void show_version (void)
 
static int statserv_sc_main (yaz_sc_t s, int argc, char **argv)
 
static void option_copy (char *dst, const char *src)
 
void statserv_sc_stop (yaz_sc_t s)
 
int statserv_main (int argc, char **argv, bend_initresult *(*bend_init)(bend_initrequest *r), void(*bend_close)(void *handle))
 

Variables

static IOCHAN pListener = NULL
 
static char gfs_root_dir [FILENAME_MAX+1]
 
static struct gfs_servergfs_server_list = 0
 
static struct gfs_listengfs_listen_list = 0
 
static NMEM gfs_nmem = 0
 
static char * me = "statserver"
 
static char * programname ="statserver"
 
static statserv_options_blockcurrent_control_block = 0
 
statserv_options_block control_block
 
static int max_sessions = 0
 
static int logbits_set = 0
 
static int log_session = 0
 
static int log_sessiondetail = 0
 
static int log_server = 0
 
static xmlDocPtr xml_config_doc = 0
 
static int no_sessions = 0
 
static int sig_received = 0
 

Detailed Description

Implements GFS logic.

Definition in file statserv.c.

Macro Definition Documentation

◆ STAT_DEFAULT_LOG_LEVEL

#define STAT_DEFAULT_LOG_LEVEL   "server,session,request"

Definition at line 91 of file statserv.c.

Function Documentation

◆ add_listener()

static int add_listener ( char *  where,
int  listen_id 
)
static

◆ catchchld()

static void catchchld ( int  num)
static

Definition at line 1207 of file statserv.c.

Referenced by statserv_sc_main().

◆ check_options()

int check_options ( int  argc,
char **  argv 
)

◆ control_association()

int control_association ( association assoc,
const char *  host,
int  force_open 
)

◆ daemon_handler()

static void daemon_handler ( void *  data)
static

Definition at line 1266 of file statserv.c.

References iochan_event_loop(), pListener, and sig_received.

Referenced by statserv_sc_main().

◆ get_logbits()

static void get_logbits ( int  force)
static

get_logbits sets global loglevel bits

Definition at line 135 of file statserv.c.

References log_server, log_session, log_sessiondetail, logbits_set, and yaz_log_module_level().

Referenced by check_options().

◆ gfs_listen_new()

static struct gfs_listen* gfs_listen_new ( const char *  id,
const char *  address 
)
static

◆ gfs_server_chdir()

static void gfs_server_chdir ( struct gfs_server gfs)
static

◆ gfs_server_new()

static struct gfs_server* gfs_server_new ( const char *  id)
static

◆ inetd_connection()

static void inetd_connection ( int  what)
static

◆ listener()

static void listener ( IOCHAN  h,
int  event 
)
static

◆ new_session()

static void * new_session ( void *  vp)
static

◆ nmem_dup_xml_content()

static char* nmem_dup_xml_content ( NMEM  n,
xmlNodePtr  ptr 
)
static

Definition at line 173 of file statserv.c.

References nmem_malloc(), and yaz_isspace.

Referenced by xml_config_read().

◆ normal_stop_handler()

static void normal_stop_handler ( int  num)
static

Definition at line 1260 of file statserv.c.

References sig_received.

Referenced by statserv_sc_main().

◆ option_copy()

static void option_copy ( char *  dst,
const char *  src 
)
static

Definition at line 1353 of file statserv.c.

References BEND_NAME_MAX.

Referenced by check_options().

◆ remove_listeners()

static void remove_listeners ( void  )
static

Definition at line 1198 of file statserv.c.

References iochan_destroy, iochan::next, and pListener.

Referenced by listener().

◆ show_version()

static void show_version ( void  )
static

Definition at line 1272 of file statserv.c.

References yaz_version(), YAZ_VERSION, and YAZ_VERSION_SHA1.

Referenced by check_options().

◆ statserv_closedown()

static void statserv_closedown ( void  )
static

Definition at line 932 of file statserv.c.

References iochan_destroy, iochan::next, pListener, xml_config_bend_stop(), and xml_config_close().

Referenced by statserv_sc_stop().

◆ statserv_getcontrol()

statserv_options_block* statserv_getcontrol ( void  )

Definition at line 1215 of file statserv.c.

References control_block, and current_control_block.

Referenced by destroy_association(), process_initRequest(), and srw_bend_init().

◆ statserv_main()

int statserv_main ( int  argc,
char **  argv,
bend_initresult *(*)(bend_initrequest *r)  bend_init,
void(*)(void *handle)  bend_close 
)

◆ statserv_remove()

void statserv_remove ( IOCHAN  pIOChannel)

Definition at line 928 of file statserv.c.

Referenced by iochan_event_loop().

◆ statserv_reset()

static void statserv_reset ( void  )
static

Definition at line 1253 of file statserv.c.

Referenced by statserv_sc_stop().

◆ statserv_sc_main()

static int statserv_sc_main ( yaz_sc_t  s,
int  argc,
char **  argv 
)
static

◆ statserv_sc_stop()

void statserv_sc_stop ( yaz_sc_t  s)

Definition at line 1498 of file statserv.c.

References statserv_closedown(), and statserv_reset().

Referenced by statserv_main().

◆ statserv_setcontrol()

void statserv_setcontrol ( statserv_options_block block)

◆ xml_config_add_listeners()

static int xml_config_add_listeners ( void  )
static

Definition at line 611 of file statserv.c.

References add_listener(), gfs_listen::address, gfs_listen_list, and gfs_listen::next.

Referenced by statserv_sc_main().

◆ xml_config_bend_start()

static void xml_config_bend_start ( void  )
static

◆ xml_config_bend_stop()

static void xml_config_bend_stop ( void  )
static

◆ xml_config_close()

static void xml_config_close ( void  )
static

Definition at line 591 of file statserv.c.

References gfs_nmem, gfs_server_list, nmem_destroy(), and xml_config_doc.

Referenced by statserv_closedown().

◆ xml_config_get_root()

static xmlNodePtr xml_config_get_root ( void  )
static

◆ xml_config_open()

static int xml_config_open ( void  )
static

◆ xml_config_read()

static void xml_config_read ( const char *  base_path)
static

Variable Documentation

◆ control_block

statserv_options_block control_block

◆ current_control_block

statserv_options_block* current_control_block = 0
static

Definition at line 85 of file statserv.c.

Referenced by statserv_getcontrol(), and statserv_setcontrol().

◆ gfs_listen_list

struct gfs_listen* gfs_listen_list = 0
static

Definition at line 73 of file statserv.c.

Referenced by xml_config_add_listeners(), and xml_config_read().

◆ gfs_nmem

NMEM gfs_nmem = 0
static

◆ gfs_root_dir

char gfs_root_dir[FILENAME_MAX+1]
static

Definition at line 71 of file statserv.c.

Referenced by gfs_server_chdir(), statserv_setcontrol(), and xml_config_open().

◆ gfs_server_list

struct gfs_server* gfs_server_list = 0
static

◆ log_server

int log_server = 0
static

Definition at line 132 of file statserv.c.

Referenced by add_listener(), get_logbits(), and listener().

◆ log_session

int log_session = 0
static

Definition at line 130 of file statserv.c.

Referenced by get_logbits(), and new_session().

◆ log_sessiondetail

int log_sessiondetail = 0
static

Definition at line 131 of file statserv.c.

Referenced by get_logbits(), inetd_connection(), and listener().

◆ logbits_set

int logbits_set = 0
static

Definition at line 129 of file statserv.c.

Referenced by get_logbits().

◆ max_sessions

int max_sessions = 0
static

Definition at line 127 of file statserv.c.

Referenced by check_options(), and new_session().

◆ me

char* me = "statserver"
static

Definition at line 76 of file statserv.c.

Referenced by check_options(), listener(), and statserv_sc_main().

◆ no_sessions

int no_sessions = 0
static

Definition at line 945 of file statserv.c.

Referenced by listener(), and new_session().

◆ pListener

IOCHAN pListener = NULL
static

◆ programname

char* programname ="statserver"
static

Definition at line 77 of file statserv.c.

Referenced by statserv_sc_main().

◆ sig_received

int sig_received = 0
static

Definition at line 1257 of file statserv.c.

Referenced by daemon_handler(), normal_stop_handler(), and statserv_sc_main().

◆ xml_config_doc

xmlDocPtr xml_config_doc = 0
static

Definition at line 150 of file statserv.c.

Referenced by xml_config_close(), xml_config_get_root(), and xml_config_open().