pazpar2  1.14.1
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

◆ HTTP_COMMAND_RESPONSE_PREFIX

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

Definition at line 48 of file http_command.c.

◆ PAZPAR2_PROTOCOL_VERSION

#define PAZPAR2_PROTOCOL_VERSION   "1"

Definition at line 46 of file http_command.c.

Function Documentation

◆ apply_local_setting()

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

Definition at line 489 of file http_command.c.

References setting::name, session_apply_setting(), setting::target, and setting::value.

Referenced by cmd_settings().

◆ bytarget_response()

static void bytarget_response ( struct http_channel c,
struct http_session s,
const char *  cmd_status 
)
static

◆ bytarget_result_ready()

static void bytarget_result_ready ( void *  data)
static

◆ cmd_bytarget()

static void cmd_bytarget ( struct http_channel c)
static

◆ cmd_exit()

static void cmd_exit ( struct http_channel c)
static

◆ cmd_info()

static void cmd_info ( struct http_channel c)
static

◆ cmd_init()

static void cmd_init ( struct http_channel c)
static

◆ cmd_ping()

static void cmd_ping ( struct http_channel c)
static

◆ cmd_record()

static void cmd_record ( struct http_channel c)
static

Definition at line 1095 of file http_command.c.

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

◆ cmd_record_ready()

static void cmd_record_ready ( void *  data)
static

◆ cmd_search()

static void cmd_search ( struct http_channel c)
static

◆ cmd_service()

static void cmd_service ( struct http_channel c)
static

◆ cmd_session_status()

static void cmd_session_status ( struct http_channel c)
static

◆ cmd_settings()

static void cmd_settings ( struct http_channel c)
static

◆ cmd_show()

static void cmd_show ( struct http_channel c)
static

◆ cmd_stat()

static void cmd_stat ( struct http_channel c)
static

◆ cmd_stop()

static void cmd_stop ( struct http_channel c)
static

◆ cmd_termlist()

static void cmd_termlist ( struct http_channel c)
static

◆ error()

static void error ( struct http_response rs,
enum pazpar2_error_code  code,
const char *  addinfo 
)
static

◆ error2()

static void error2 ( struct http_response rs,
enum pazpar2_error_code  code,
const char *  addinfo,
const char *  addinfo2 
)
static

◆ get_msg()

static const char* get_msg ( enum pazpar2_error_code  code)
static

◆ get_version()

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().

◆ http_command()

void http_command ( struct http_channel c)

◆ http_session_create()

struct http_session* http_session_create ( struct conf_service service,
http_sessions_t  http_sessions,
unsigned int  sesid 
)

◆ http_session_destroy()

void http_session_destroy ( struct http_session s)

◆ http_session_use()

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_create()

http_sessions_t http_sessions_create ( void  )

◆ http_sessions_destroy()

void http_sessions_destroy ( http_sessions_t  hs)

◆ locate_session()

static struct http_session* locate_session ( struct http_channel c)
static

◆ make_sessionid()

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().

◆ process_settings()

static int process_settings ( struct session se,
struct http_request rq,
struct http_response rs 
)
static

◆ release_session()

static void release_session ( struct http_channel c,
struct http_session session 
)
static

◆ response_close()

static void response_close ( struct http_channel c,
const char *  command 
)
static

◆ response_open_command()

static void response_open_command ( struct http_channel c,
const char *  command 
)
static

◆ response_open_ok()

static void response_open_ok ( struct http_channel c,
const char *  command 
)
static

◆ session_get_memory_status()

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 session_status().

◆ session_status()

static void session_status ( struct http_channel c,
struct http_session s 
)
static

◆ session_timeout()

static void session_timeout ( IOCHAN  i,
int  event 
)
static

◆ show_raw_record_error()

static void show_raw_record_error ( void *  data,
const char *  addinfo 
)
static

◆ show_raw_record_ok()

static void show_raw_record_ok ( void *  data,
const char *  buf,
size_t  sz 
)
static

◆ show_raw_record_ok_binary()

static void show_raw_record_ok_binary ( void *  data,
const char *  buf,
size_t  sz 
)
static

◆ show_raw_reset()

void show_raw_reset ( void *  data,
struct http_channel c,
void *  data2 
)

Definition at line 961 of file http_command.c.

Referenced by show_record().

◆ show_record()

static void show_record ( struct http_channel c,
struct http_session s 
)
static

◆ show_records()

static void show_records ( struct http_channel c,
struct http_session s,
int  active 
)
static

◆ show_records_ready()

static void show_records_ready ( void *  data)
static

◆ termlist_response()

static void termlist_response ( struct http_channel c,
struct http_session s,
const char *  cmd_status 
)
static

◆ termlist_result_ready()

static void termlist_result_ready ( void *  data)
static

◆ write_metadata()

static void write_metadata ( WRBUF  w,
struct conf_service service,
struct record_metadata **  ml,
unsigned  flags,
int  indent 
)
static

◆ write_subrecord()

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_record(struct http_channel *c)
static void cmd_ping(struct http_channel *c)
static void cmd_bytarget(struct http_channel *c)
Definition: http_command.c:792
static void cmd_termlist(struct http_channel *c)
Definition: http_command.c:590
static void cmd_service(struct http_channel *c)
Definition: http_command.c:661
static void cmd_settings(struct http_channel *c)
Definition: http_command.c:497
static void cmd_init(struct http_channel *c)
Definition: http_command.c:415
static void cmd_info(struct http_channel *c)
static void cmd_stat(struct http_channel *c)
static void cmd_session_status(struct http_channel *c)
Definition: http_command.c:674
static void cmd_search(struct http_channel *c)
static void cmd_stop(struct http_channel *c)
static void cmd_exit(struct http_channel *c)
Definition: http_command.c:405
static void cmd_show(struct http_channel *c)

Referenced by http_command().

◆ fun

void(* fun) (struct http_channel *c) ( struct http_channel c)

◆ g_http_session_mutex

YAZ_MUTEX g_http_session_mutex = 0
static

Definition at line 68 of file http_command.c.

Referenced by http_session_use().

◆ g_http_sessions

int g_http_sessions = 0
static

Definition at line 69 of file http_command.c.

Referenced by http_session_use().

◆ name

char* name