pazpar2  1.13.0
Data Structures | Macros | Functions | Variables
http_command.c File Reference
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <yaz/snprintf.h>
#include <yaz/yaz-util.h>
#include <yaz/malloc_info.h>
#include "ppmutex.h"
#include "eventl.h"
#include "parameters.h"
#include "session.h"
#include "http.h"
#include "settings.h"
#include "client.h"

Go to the source code of this file.

Data Structures

struct  http_session
 
struct  http_sessions
 

Macros

#define PAZPAR2_PROTOCOL_VERSION   "1"
 
#define HTTP_COMMAND_RESPONSE_PREFIX   "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
 

Functions

static void show_records_ready (void *data)
 
int get_version (struct http_request *rq)
 
int http_session_use (int delta)
 
http_sessions_t http_sessions_create (void)
 
void http_sessions_destroy (http_sessions_t hs)
 
void http_session_destroy (struct http_session *s)
 
static void session_timeout (IOCHAN i, int event)
 
struct http_sessionhttp_session_create (struct conf_service *service, http_sessions_t http_sessions, unsigned int sesid)
 
static const char * get_msg (enum pazpar2_error_code code)
 
static void error2 (struct http_response *rs, enum pazpar2_error_code code, const char *addinfo, const char *addinfo2)
 
static void error (struct http_response *rs, enum pazpar2_error_code code, const char *addinfo)
 
static void response_open_command (struct http_channel *c, const char *command)
 
static void response_open_ok (struct http_channel *c, const char *command)
 
static void response_close (struct http_channel *c, const char *command)
 
unsigned int make_sessionid (void)
 
static struct http_sessionlocate_session (struct http_channel *c)
 
static void release_session (struct http_channel *c, struct http_session *session)
 
static int process_settings (struct session *se, struct http_request *rq, struct http_response *rs)
 
static void cmd_exit (struct http_channel *c)
 
static void cmd_init (struct http_channel *c)
 
static void apply_local_setting (void *client_data, struct setting *set)
 
static void cmd_settings (struct http_channel *c)
 
static void termlist_response (struct http_channel *c, struct http_session *s, const char *cmd_status)
 
static void termlist_result_ready (void *data)
 
static void cmd_termlist (struct http_channel *c)
 
size_t session_get_memory_status (struct session *session)
 
static void session_status (struct http_channel *c, struct http_session *s)
 
static void cmd_service (struct http_channel *c)
 
static void cmd_session_status (struct http_channel *c)
 
static void bytarget_response (struct http_channel *c, struct http_session *s, const char *cmd_status)
 
static void bytarget_result_ready (void *data)
 
static void cmd_bytarget (struct http_channel *c)
 
static void write_metadata (WRBUF w, struct conf_service *service, struct record_metadata **ml, unsigned flags, int indent)
 
static void write_subrecord (struct record *r, WRBUF w, struct conf_service *service, unsigned flags, int indent)
 
static void show_raw_record_error (void *data, const char *addinfo)
 
static void show_raw_record_ok (void *data, const char *buf, size_t sz)
 
static void show_raw_record_ok_binary (void *data, const char *buf, size_t sz)
 
void show_raw_reset (void *data, struct http_channel *c, void *data2)
 
static void cmd_record_ready (void *data)
 
static void show_record (struct http_channel *c, struct http_session *s)
 
static void cmd_record (struct http_channel *c)
 
static void show_records (struct http_channel *c, struct http_session *s, int active)
 
static void cmd_show (struct http_channel *c)
 
static void cmd_ping (struct http_channel *c)
 
static void cmd_search (struct http_channel *c)
 
static void cmd_stat (struct http_channel *c)
 
static void cmd_stop (struct http_channel *c)
 
static void cmd_info (struct http_channel *c)
 
void http_command (struct http_channel *c)
 

Variables

static YAZ_MUTEX g_http_session_mutex = 0
 
static int g_http_sessions = 0
 
struct {
   char *   name
 
   void(*   fun )(struct http_channel *c)
 
commands []
 

Macro Definition Documentation

#define HTTP_COMMAND_RESPONSE_PREFIX   "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"

Definition at line 48 of file http_command.c.

Referenced by error2(), and response_open_command().

#define PAZPAR2_PROTOCOL_VERSION   "1"

Definition at line 46 of file http_command.c.

Referenced by cmd_init().

Function Documentation

static void apply_local_setting ( void *  client_data,
struct setting set 
)
static

Definition at line 482 of file http_command.c.

References session_apply_setting().

Referenced by cmd_settings().

static void bytarget_response ( struct http_channel c,
struct http_session s,
const char *  cmd_status 
)
static
static void bytarget_result_ready ( void *  data)
static
static void cmd_bytarget ( struct http_channel c)
static
static void cmd_exit ( struct http_channel c)
static
static void cmd_info ( struct http_channel c)
static
static void cmd_init ( struct http_channel c)
static
static void cmd_ping ( struct http_channel c)
static
static void cmd_record ( struct http_channel c)
static

Definition at line 1081 of file http_command.c.

References locate_session(), release_session(), and show_record().

static void cmd_record_ready ( void *  data)
static
static void cmd_search ( struct http_channel c)
static
static void cmd_service ( struct http_channel c)
static
static void cmd_session_status ( struct http_channel c)
static
static void cmd_settings ( struct http_channel c)
static
static void cmd_show ( struct http_channel c)
static
static void cmd_stat ( struct http_channel c)
static
static void cmd_stop ( struct http_channel c)
static
static void cmd_termlist ( struct http_channel c)
static
static void error ( struct http_response rs,
enum pazpar2_error_code  code,
const char *  addinfo 
)
static
static void error2 ( struct http_response rs,
enum pazpar2_error_code  code,
const char *  addinfo,
const char *  addinfo2 
)
static
static const char* get_msg ( enum pazpar2_error_code  code)
static
int get_version ( struct http_request rq)

Definition at line 73 of file http_command.c.

References http_argbyname().

Referenced by bytarget_response(), show_records(), and termlist_response().

void http_command ( struct http_channel c)
struct http_session* http_session_create ( struct conf_service service,
http_sessions_t  http_sessions,
unsigned int  sesid 
)
void http_session_destroy ( struct http_session s)
int http_session_use ( int  delta)

Definition at line 83 of file http_command.c.

References g_http_session_mutex, and g_http_sessions.

Referenced by http_session_create(), and http_session_destroy().

http_sessions_t http_sessions_create ( void  )
void http_sessions_destroy ( http_sessions_t  hs)
static struct http_session* locate_session ( struct http_channel c)
static
unsigned int make_sessionid ( void  )

Definition at line 304 of file http_command.c.

References global_parameters, and parameters::predictable_sessions.

Referenced by cmd_init().

static int process_settings ( struct session se,
struct http_request rq,
struct http_response rs 
)
static
static void release_session ( struct http_channel c,
struct http_session session 
)
static
static void response_close ( struct http_channel c,
const char *  command 
)
static
static void response_open_command ( struct http_channel c,
const char *  command 
)
static
static void response_open_ok ( struct http_channel c,
const char *  command 
)
static
size_t session_get_memory_status ( struct session session)

Definition at line 1082 of file session.c.

References session::nmem, session_enter(), and session_leave().

Referenced by cmd_termlist(), and session_status().

static void session_status ( struct http_channel c,
struct http_session s 
)
static
static void session_timeout ( IOCHAN  i,
int  event 
)
static

Definition at line 128 of file http_command.c.

References http_session_destroy(), and iochan_getdata.

Referenced by http_session_create().

static void show_raw_record_error ( void *  data,
const char *  addinfo 
)
static
static void show_raw_record_ok ( void *  data,
const char *  buf,
size_t  sz 
)
static
static void show_raw_record_ok_binary ( void *  data,
const char *  buf,
size_t  sz 
)
static
void show_raw_reset ( void *  data,
struct http_channel c,
void *  data2 
)

Definition at line 947 of file http_command.c.

References cmd_record_ready().

Referenced by show_record().

static void show_record ( struct http_channel c,
struct http_session s 
)
static
static void show_records ( struct http_channel c,
struct http_session s,
int  active 
)
static
static void show_records_ready ( void *  data)
static
static void termlist_response ( struct http_channel c,
struct http_session s,
const char *  cmd_status 
)
static
static void termlist_result_ready ( void *  data)
static
static void write_metadata ( WRBUF  w,
struct conf_service service,
struct record_metadata **  ml,
unsigned  flags,
int  indent 
)
static
static void write_subrecord ( struct record r,
WRBUF  w,
struct conf_service service,
unsigned  flags,
int  indent 
)
static

Variable Documentation

struct { ... } commands[]
Initial value:
= {
{ "init", cmd_init },
{ "settings", cmd_settings },
{ "stat", cmd_stat },
{ "bytarget", cmd_bytarget },
{ "show", cmd_show },
{ "search", cmd_search },
{ "termlist", cmd_termlist },
{ "exit", cmd_exit },
{ "session-status", cmd_session_status },
{ "service", cmd_service },
{ "ping", cmd_ping },
{ "record", cmd_record },
{ "info", cmd_info },
{ "stop", cmd_stop },
{0,0}
}
static void cmd_settings(struct http_channel *c)
Definition: http_command.c:490
static void cmd_session_status(struct http_channel *c)
Definition: http_command.c:660
static void cmd_stop(struct http_channel *c)
static void cmd_bytarget(struct http_channel *c)
Definition: http_command.c:778
static void cmd_info(struct http_channel *c)
static void cmd_ping(struct http_channel *c)
static void cmd_search(struct http_channel *c)
static void cmd_show(struct http_channel *c)
static void cmd_stat(struct http_channel *c)
static void cmd_exit(struct http_channel *c)
Definition: http_command.c:405
static void cmd_service(struct http_channel *c)
Definition: http_command.c:647
static void cmd_termlist(struct http_channel *c)
Definition: http_command.c:576
static void cmd_record(struct http_channel *c)
static void cmd_init(struct http_channel *c)
Definition: http_command.c:415

Referenced by http_command().

void(* fun) (struct http_channel *c)
YAZ_MUTEX g_http_session_mutex = 0
static

Definition at line 68 of file http_command.c.

Referenced by http_session_use().

int g_http_sessions = 0
static

Definition at line 69 of file http_command.c.

Referenced by http_session_use().

char* name