Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

fifo_server.c File Reference

#include <limits.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include <string.h>
#include <time.h>
#include <stdarg.h>
#include "../../dprint.h"
#include "../../ut.h"
#include "../../error.h"
#include "../../config.h"
#include "../../globals.h"
#include "../../mem/mem.h"
#include "../../mem/shm_mem.h"
#include "../../sr_module.h"
#include "../../pt.h"
#include "../../rpc.h"
#include "../../cfg/cfg_struct.h"
#include "fifo_server.h"

Go to the source code of this file.

Data Structures

struct  text_chunk
struct  rpc_struct_out
struct  rpc_struct
 The structure represents a XML-RPC document structure. More...
struct  rpc_context

Defines

#define MAX_FIFO_COMMAND   128
#define MAX_CONSUME_BUFFER   1024
#define MAX_LINE_BUFFER   2048
#define DEFAULT_REPLY_RETRIES   4
#define DEFAULT_REPLY_WAIT   80000
#define DEFAULT_FIFO_DIR   "/tmp/"
#define REASON_BUF_LEN   1024
#define RPC_BUF_SIZE   1024

Typedefs

typedef rpc_context rpc_ctx_t

Enumerations

enum  text_flags { CHUNK_SEEN = (1 << 0), CHUNK_POSITIONAL = (1 << 1), CHUNK_MEMBER_NAME = (1 << 2), CHUNK_MEMBER_VALUE = (1 << 3) }

Functions

int rpc_send (rpc_ctx_t *ctx)
void rpc_fault (rpc_ctx_t *ctx, int code, char *fmt,...)
int rpc_add (rpc_ctx_t *ctx, char *fmt,...)
int rpc_scan (rpc_ctx_t *ctx, char *fmt,...)
int rpc_printf (rpc_ctx_t *ctx, char *fmt,...)
int rpc_struct_add (struct text_chunk *s, char *fmt,...)
int rpc_struct_scan (struct rpc_struct *s, char *fmt,...)
int rpc_struct_printf (struct text_chunk *s, char *name, char *fmt,...)
void escape (str *dst, char *r, int len, int all)
int unescape (str *dst, char *r, int len)
text_chunknew_chunk_escape (str *src, int escape_all)
text_chunknew_chunk (str *src)
text_chunknew_chunk_unescape (str *src)
void free_chunk (struct text_chunk *c)
void free_struct (struct rpc_struct *s)
rpc_structnew_struct (rpc_ctx_t *ctx, str *line)
int read_line (char *b, int max, FILE *stream, int *read)
char * trim_filename (char *file)
void consume_request (FILE *stream)
int fifo_check (int fd, char *fname)
FILE * open_reply_pipe (char *pipe_name)
void fifo_server (FILE *fifo_stream)
int init_fifo_server (void)
int start_fifo_server (void)
void destroy_fifo (void)
int safe_write (FILE *f, char *fmt,...)
void append_chunk (rpc_ctx_t *ctx, struct text_chunk *l)
int print_value (rpc_ctx_t *ctx, char fmt, va_list *ap)
int find_member (struct text_chunk **value, struct rpc_struct *s, str *member_name)

Variables

char * fifo = 0
char * fifo_dir = DEFAULT_FIFO_DIR
char * fifo_user = 0
char * fifo_group = 0
int fifo_reply_retries = DEFAULT_REPLY_RETRIES
int fifo_reply_wait = DEFAULT_REPLY_WAIT
int fifo_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
pid_t fifo_pid
int fifo_uid = -1
int fifo_gid = -1
int fifo_read = 0
int fifo_write = 0
int line_no = 0
FILE * fifo_stream = 0
rpc_t func_param
rpc_ctx_t context


Define Documentation

#define DEFAULT_FIFO_DIR   "/tmp/"
 

Definition at line 106 of file fifo_server.c.

#define DEFAULT_REPLY_RETRIES   4
 

Definition at line 104 of file fifo_server.c.

#define DEFAULT_REPLY_WAIT   80000
 

Definition at line 105 of file fifo_server.c.

#define MAX_CONSUME_BUFFER   1024
 

Definition at line 102 of file fifo_server.c.

Referenced by consume_request().

#define MAX_FIFO_COMMAND   128
 

Definition at line 101 of file fifo_server.c.

Referenced by fifo_server().

#define MAX_LINE_BUFFER   2048
 

Definition at line 103 of file fifo_server.c.

Referenced by rpc_scan().

#define REASON_BUF_LEN   1024
 

Definition at line 983 of file fifo_server.c.

Referenced by rpc_fault(), and set_fault().

#define RPC_BUF_SIZE   1024
 

Definition at line 1193 of file fifo_server.c.

Referenced by rpc_printf(), and rpc_struct_printf().


Typedef Documentation

typedef struct rpc_context rpc_ctx_t
 

Referenced by append_chunk(), clean_context(), close_doc(), init_context(), new_struct(), open_doc(), print_value(), rpc_add(), rpc_fault(), rpc_printf(), rpc_scan(), and rpc_send().


Enumeration Type Documentation

enum text_flags
 

Enumeration values:
CHUNK_SEEN 
CHUNK_POSITIONAL 
CHUNK_MEMBER_NAME 
CHUNK_MEMBER_VALUE 

Definition at line 109 of file fifo_server.c.


Function Documentation

void append_chunk rpc_ctx_t ctx,
struct text_chunk l
[static]
 

Definition at line 1072 of file fifo_server.c.

References ctx, and rpc_ctx_t.

Referenced by print_value(), rpc_add(), and rpc_printf().

void consume_request FILE *  stream  )  [static]
 

Definition at line 572 of file fifo_server.c.

References len, MAX_CONSUME_BUFFER, and read_line().

Referenced by fifo_server().

void destroy_fifo void   ) 
 

Definition at line 968 of file fifo_server.c.

References fifo, fifo_stream, and WARN.

Referenced by mod_destroy().

void escape str dst,
char *  r,
int  len,
int  all
[static]
 

Definition at line 208 of file fifo_server.c.

References _str::len, _str::s, and str.

Referenced by new_chunk_escape().

int fifo_check int  fd,
char *  fname
[static]
 

Definition at line 586 of file fifo_server.c.

References ERR.

Referenced by open_reply_pipe().

void fifo_server FILE *  fifo_stream  )  [static]
 

Definition at line 710 of file fifo_server.c.

References rpc_context::body, buf, cfg_update, CMD_SEPARATOR, rpc_context::code, consume_request(), context, DBG, ERR, fifo_stream, find_rpc_export(), free_chunk(), free_struct(), func_param, rpc_export::function, INFO, rpc_context::last, line_no, MAX_FIFO_COMMAND, rpc_context::method, rpc_struct::next, text_chunk::next, pkg_free, read_line(), rpc_context::reason, rpc_context::reply_file, rpc_context::reply_sent, rpc_export_t, rpc_fault(), rpc_send(), s, rpc_context::strs, rpc_context::structs, and trim_filename().

Referenced by start_fifo_server().

int find_member struct text_chunk **  value,
struct rpc_struct s,
str member_name
[static]
 

Definition at line 1497 of file fifo_server.c.

References text_chunk::flags, _str::len, rpc_struct::names, text_chunk::next, _str::s, text_chunk::s, s, str, and rpc_struct::values.

void free_chunk struct text_chunk c  )  [static]
 

Definition at line 383 of file fifo_server.c.

References pkg_free, _str::s, and text_chunk::s.

Referenced by fifo_server(), free_struct(), rpc_send(), rpc_struct_add(), and rpc_struct_printf().

void free_struct struct rpc_struct s  )  [static]
 

Definition at line 390 of file fifo_server.c.

References free_chunk(), rpc_struct::names, text_chunk::next, pkg_free, s, and rpc_struct::values.

Referenced by fifo_server(), and new_struct().

int init_fifo_server void   ) 
 

Definition at line 822 of file fifo_server.c.

References rpc::add, DBG, ERR, rpc::fault, fifo, fifo_gid, fifo_group, fifo_mode, fifo_read, fifo_stream, fifo_uid, fifo_user, fifo_write, func_param, group2gid(), open, rpc::printf, rpc::scan, rpc::send, rpc::struct_add, rpc::struct_printf, rpc::struct_scan, and user2uid().

Referenced by mod_init().

struct text_chunk* new_chunk str src  ) 
 

Definition at line 326 of file fifo_server.c.

References ERR, text_chunk::flags, _str::len, text_chunk::next, pkg_free, pkg_malloc, _str::s, text_chunk::s, and str.

Referenced by print_value(), rpc_add(), and rpc_struct_add().

struct text_chunk* new_chunk_escape str src,
int  escape_all
 

Definition at line 298 of file fifo_server.c.

References ERR, escape(), text_chunk::flags, _str::len, text_chunk::next, pkg_free, pkg_malloc, _str::s, text_chunk::s, and str.

Referenced by print_value(), rpc_printf(), rpc_struct_add(), and rpc_struct_printf().

struct text_chunk* new_chunk_unescape str src  ) 
 

Definition at line 355 of file fifo_server.c.

References ERR, text_chunk::flags, _str::len, text_chunk::next, pkg_free, pkg_malloc, _str::s, text_chunk::s, str, and unescape().

Referenced by new_struct(), and rpc_scan().

struct rpc_struct* new_struct rpc_ctx_t ctx,
str line
[static]
 

Definition at line 414 of file fifo_server.c.

References rpc_struct::ctx, ctx, free_struct(), _str::len, line, line_no, rpc_struct::names, new_chunk_unescape(), text_chunk::next, pkg_malloc, q_memchr(), rpc_ctx_t, rpc_fault(), _str::s, s, str, rpc_struct::values, and ZSW.

Referenced by rpc_scan().

FILE* open_reply_pipe char *  pipe_name  )  [static]
 

Definition at line 634 of file fifo_server.c.

References DBG, ERR, fifo_check(), fifo_reply_wait, flags, open, and sleep_us().

Referenced by rpc_send().

int print_value rpc_ctx_t ctx,
char  fmt,
va_list *  ap
[static]
 

Definition at line 1087 of file fifo_server.c.

References append_chunk(), buf, ctx, ERR, text_chunk::flags, int2str(), _str::len, line_no, new_chunk(), new_chunk_escape(), rpc_ctx_t, rpc_fault(), _str::s, snprintf, and str.

int read_line char *  b,
int  max,
FILE *  stream,
int read
[static]
 

Definition at line 490 of file fifo_server.c.

References ERR, len, line_no, and max.

Referenced by consume_request(), fifo_server(), and rpc_scan().

int rpc_add rpc_ctx_t ctx,
char *  fmt,
  ...
[static]
 

Definition at line 1163 of file fifo_server.c.

References append_chunk(), ctx, new_chunk(), print_value(), rpc_ctx_t, rpc_fault(), s, and str.

void rpc_fault rpc_ctx_t ctx,
int  code,
char *  fmt,
  ...
[static]
 

Definition at line 989 of file fifo_server.c.

References buf, ctx, REASON_BUF_LEN, rpc_ctx_t, and vsnprintf.

int rpc_printf rpc_ctx_t ctx,
char *  fmt,
  ...
[static]
 

Definition at line 1266 of file fifo_server.c.

References append_chunk(), buf, buf_size, ctx, ERR, _str::len, new_chunk_escape(), pkg_free, pkg_malloc, pkg_realloc, RPC_BUF_SIZE, rpc_ctx_t, rpc_fault(), _str::s, s, str, and vsnprintf.

int rpc_scan rpc_ctx_t ctx,
char *  fmt,
  ...
[static]
 

Definition at line 1320 of file fifo_server.c.

References buf, ctx, ERR, fifo_stream, _str::len, line, line_no, MAX_LINE_BUFFER, new_chunk_unescape(), new_struct(), rpc_struct::next, text_chunk::next, read_line(), rpc_ctx_t, rpc_fault(), s, text_chunk::s, _str::s, and str.

int rpc_send rpc_ctx_t ctx  )  [static]
 

Definition at line 1026 of file fifo_server.c.

References ctx, ERR, text_chunk::flags, free_chunk(), _str::len, text_chunk::next, open_reply_pipe(), rpc_ctx_t, _str::s, text_chunk::s, safe_write(), and ZSW.

int rpc_struct_add struct text_chunk s,
char *  fmt,
  ...
[static]
 

Definition at line 1413 of file fifo_server.c.

References buf, context, ERR, text_chunk::flags, free_chunk(), int2str(), rpc_context::last, _str::len, new_chunk(), new_chunk_escape(), text_chunk::next, rpc_fault(), s, _str::s, snprintf, st, and str.

int rpc_struct_printf struct text_chunk s,
char *  name,
char *  fmt,
  ...
[static]
 

Definition at line 1195 of file fifo_server.c.

References buf, buf_size, context, ERR, text_chunk::flags, free_chunk(), rpc_context::last, _str::len, new_chunk_escape(), text_chunk::next, pkg_free, pkg_malloc, pkg_realloc, RPC_BUF_SIZE, rpc_fault(), s, _str::s, str, and vsnprintf.

int rpc_struct_scan struct rpc_struct s,
char *  fmt,
  ...
[static]
 

Definition at line 1522 of file fifo_server.c.

References rpc_struct::ctx, ERR, find_member(), _str::len, rpc_fault(), text_chunk::s, s, _str::s, and str.

int safe_write FILE *  f,
char *  fmt,
  ...
[inline, static]
 

Definition at line 1001 of file fifo_server.c.

References ERR, and fifo.

Referenced by rpc_send().

int start_fifo_server void   ) 
 

Definition at line 936 of file fifo_server.c.

References cfg_child_init(), ERR, fifo, fifo_pid, fifo_server(), fifo_stream, fork_process(), INFO, is_main, MAX_PT_DESC, PROC_FIFO, process_no, pt, and snprintf.

Referenced by child_init().

char* trim_filename char *  file  )  [static]
 

Definition at line 541 of file fifo_server.c.

References ERR, fifo_dir, file, and pkg_malloc.

Referenced by fifo_server().

int unescape str dst,
char *  r,
int  len
[static]
 

Definition at line 258 of file fifo_server.c.

References _str::len, _str::s, and str.

Referenced by new_chunk_unescape().


Variable Documentation

rpc_ctx_t context [static]
 

Definition at line 183 of file fifo_server.c.

Referenced by fifo_server(), rpc_struct_add(), and rpc_struct_printf().

char* fifo = 0
 

Definition at line 166 of file fifo_server.c.

Referenced by destroy_fifo(), init_fifo_server(), safe_write(), start_fifo_server(), and write_to_fifo().

char* fifo_dir = DEFAULT_FIFO_DIR
 

Definition at line 167 of file fifo_server.c.

int fifo_gid = -1 [static]
 

Definition at line 177 of file fifo_server.c.

Referenced by init_fifo_server().

char* fifo_group = 0
 

Definition at line 169 of file fifo_server.c.

Referenced by init_fifo_server().

int fifo_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
 

Definition at line 172 of file fifo_server.c.

Referenced by init_fifo_server().

pid_t fifo_pid [static]
 

Definition at line 175 of file fifo_server.c.

Referenced by start_fifo_server().

int fifo_read = 0 [static]
 

Definition at line 178 of file fifo_server.c.

Referenced by init_fifo_server().

int fifo_reply_retries = DEFAULT_REPLY_RETRIES
 

Definition at line 170 of file fifo_server.c.

int fifo_reply_wait = DEFAULT_REPLY_WAIT
 

Definition at line 171 of file fifo_server.c.

FILE* fifo_stream = 0 [static]
 

Definition at line 181 of file fifo_server.c.

Referenced by destroy_fifo(), fifo_server(), init_fifo_server(), rpc_scan(), and start_fifo_server().

int fifo_uid = -1 [static]
 

Definition at line 176 of file fifo_server.c.

Referenced by init_fifo_server().

char* fifo_user = 0
 

Definition at line 168 of file fifo_server.c.

Referenced by init_fifo_server().

int fifo_write = 0 [static]
 

Definition at line 179 of file fifo_server.c.

Referenced by init_fifo_server().

rpc_t func_param [static]
 

Definition at line 182 of file fifo_server.c.

Referenced by fifo_server(), and init_fifo_server().

int line_no = 0 [static]
 

Definition at line 180 of file fifo_server.c.

Referenced by fifo_server(), new_struct(), print_value(), read_line(), and rpc_scan().


Generated on Thu Sep 9 04:16:13 2010 for SIPExpressRouter by  doxygen 1.3.9.1