ARB
Classes | Macros | Typedefs | Functions | Variables
server.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <limits.h>
#include "trace.h"
#include <signal.h>
#include <sys/time.h>
#include <netdb.h>
#include <setjmp.h>
#include <aisc_com.h>
#include "server.h"
#include <SigHandler.h>
#include <arb_cs.h>
#include <static_assert.h>
Include dependency graph for server.c:

Go to the source code of this file.

Classes

struct  Socinf
 
struct  Hs_struct
 
struct  aisc_bytes_list
 
struct  aisc_static_set_mem
 

Macros

#define FD_SET_TYPE
 
#define aisc_assert(cond)   arb_assert(cond)
 
#define AISC_SERVER_OK   1
 
#define AISC_SERVER_FAULT   0
 
#define MAX_QUEUE_LEN   5
 
#define AISC_MAGIC_NUMBER_FILTER   0xffffff00
 

Typedefs

typedef long(* aisc_talking_function_type )(long *, int, long *, int)
 

Functions

void aisc_server_errorf (const char *templat,...)
 
static const chartest_address_valid (void *address, long key)
 
static __ATTR__NORETURN void aisc_server_sigsegv (int sig)
 
const charaisc_get_object_names (long i)
 
static const charaisc_get_object_attribute (long i, long j)
 
Hs_structopen_aisc_server (const char *path, int timeout, int fork)
 
static void aisc_s_add_to_bytes_queue (char *data, int size)
 
static int aisc_s_send_bytes_queue (int socket)
 
static long aisc_talking_get (long *in_buf, int size, long *out_buf, int)
 
static void aisc_talking_set_index (int *, int i)
 
int aisc_talking_get_index (int u, int o)
 
static long aisc_talking_sets (long *in_buf, int size, long *out_buf, long *object, int object_type)
 
static long aisc_talking_set (long *in_buf, int size, long *out_buf, int)
 
static long aisc_talking_nset (long *in_buf, int size, long *out_buf, int)
 
long aisc_make_sets (long *obj)
 
static long aisc_talking_create (long *in_buf, int size, long *out_buf, int)
 
static long aisc_talking_copy (long *in_buf, int size, long *out_buf, int)
 
static long aisc_talking_find (long *in_buf, int, long *out_buf, int)
 
static long aisc_talking_init (long *, int, long *out_buf, int)
 
static long aisc_fork_server (long *, int, long *, int)
 
static long aisc_talking_delete (long *in_buf, int, long *out_buf, int)
 
static long aisc_talking_debug_info (long *in_buf, int, long *out_buf, int)
 
int aisc_broadcast (Hs_struct *hs, int message_type, const char *message)
 
static int aisc_talking (int con)
 
Hs_structaisc_accept_calls (Hs_struct *hs)
 
void aisc_server_shutdown (Hs_struct *&hs)
 
int aisc_add_destroy_callback (aisc_destroy_callback callback, long clientdata)
 
void aisc_remove_destroy_callback ()
 
int aisc_server_save_token (FILE *fd, const char *buffer, int maxsize)
 
int aisc_server_load_token (FILE *fd, char *buffer, int maxsize)
 

Variables

static aisc_bytes_listaisc_server_bytes_first
 
static aisc_bytes_listaisc_server_bytes_last
 
charaisc_object_names []
 
char ** aisc_attribute_names_list []
 
aisc_talking_func_long * aisc_talking_functions_get []
 
aisc_talking_func_long * aisc_talking_functions_set []
 
aisc_talking_func_longp * aisc_talking_functions_copy []
 
aisc_talking_func_longp * aisc_talking_functions_find []
 
aisc_talking_func_longp * aisc_talking_functions_create []
 
aisc_talking_func_long aisc_talking_functions_delete []
 
const charaisc_server_error
 
const int ERRORBUFSIZE = 256
 
static char error_buf [ERRORBUFSIZE]
 
static int aisc_server_con
 
static Hs_structaisc_server_hs
 
static bool sigsegv_occurred = false
 
static bool catch_sigsegv = 0
 
static jmp_buf return_after_segv
 
static SigHandler old_sigsegv_handler
 
static int aisc_server_index = -1
 
static struct aisc_static_set_mem md
 
intaisc_main
 
static aisc_talking_function_type aisc_talking_functions []
 

Macro Definition Documentation

#define FD_SET_TYPE

Definition at line 17 of file server.c.

Referenced by aisc_accept_calls().

#define aisc_assert (   cond)    arb_assert(cond)

Definition at line 40 of file server.c.

Referenced by aisc_broadcast(), aisc_server_sigsegv(), aisc_talking(), and test_address_valid().

#define AISC_SERVER_OK   1

Definition at line 42 of file server.c.

Referenced by aisc_accept_calls(), and aisc_talking().

#define AISC_SERVER_FAULT   0

Definition at line 43 of file server.c.

Referenced by aisc_talking().

#define MAX_QUEUE_LEN   5

Definition at line 44 of file server.c.

Referenced by open_aisc_server().

#define AISC_MAGIC_NUMBER_FILTER   0xffffff00

Definition at line 46 of file server.c.

Referenced by aisc_talking().

Typedef Documentation

typedef long(* aisc_talking_function_type)(long *, int, long *, int)

Definition at line 948 of file server.c.

Function Documentation

void aisc_server_errorf ( const char templat,
  ... 
)

Definition at line 122 of file server.c.

References error_buf, EXIT_FAILURE, fflush(), fputs(), va_end(), va_start(), and vfprintf().

static const char* test_address_valid ( void *  address,
long  key 
)
static
static __ATTR__NORETURN void aisc_server_sigsegv ( int  sig)
static
const char* aisc_get_object_names ( long  i)
static const char* aisc_get_object_attribute ( long  i,
long  j 
)
static
Hs_struct* open_aisc_server ( const char path,
int  timeout,
int  fork 
)
static void aisc_s_add_to_bytes_queue ( char data,
int  size 
)
static

Definition at line 270 of file server.c.

References aisc_bytes_list::data, aisc_bytes_list::next, and aisc_bytes_list::size.

Referenced by aisc_talking_get().

static int aisc_s_send_bytes_queue ( int  socket)
static
static long aisc_talking_get ( long in_buf,
int  size,
long out_buf,
int   
)
static
static void aisc_talking_set_index ( int ,
int  i 
)
static

Definition at line 425 of file server.c.

Referenced by aisc_talking_sets().

int aisc_talking_get_index ( int  u,
int  o 
)

Definition at line 429 of file server.c.

References AISC_DUMP, aisc_server_index, aisc_talking_get_index(), and error_buf.

Referenced by aisc_talking_get_index().

static long aisc_talking_sets ( long in_buf,
int  size,
long out_buf,
long object,
int  object_type 
)
static
static long aisc_talking_set ( long in_buf,
int  size,
long out_buf,
int   
)
static

Definition at line 573 of file server.c.

References AISC_OBJ_TYPE_MASK, aisc_talking_sets(), and NULp.

static long aisc_talking_nset ( long in_buf,
int  size,
long out_buf,
int   
)
static

Definition at line 583 of file server.c.

References AISC_NO_ANSWER, AISC_OBJ_TYPE_MASK, aisc_talking_sets(), and NULp.

long aisc_make_sets ( long obj)
static long aisc_talking_create ( long in_buf,
int  size,
long out_buf,
int   
)
static
static long aisc_talking_copy ( long in_buf,
int  size,
long out_buf,
int   
)
static
static long aisc_talking_find ( long in_buf,
int  ,
long out_buf,
int   
)
static
static long aisc_talking_init ( long ,
int  ,
long out_buf,
int   
)
static

Definition at line 782 of file server.c.

References long, and NULp.

static long aisc_fork_server ( long ,
int  ,
long ,
int   
)
static

Definition at line 788 of file server.c.

static long aisc_talking_delete ( long in_buf,
int  ,
long out_buf,
int   
)
static
static long aisc_talking_debug_info ( long in_buf,
int  ,
long out_buf,
int   
)
static
int aisc_broadcast ( Hs_struct hs,
int  message_type,
const char message 
)
static int aisc_talking ( int  con)
static
Hs_struct* aisc_accept_calls ( Hs_struct hs)
void aisc_server_shutdown ( Hs_struct *&  hs)
int aisc_add_destroy_callback ( aisc_destroy_callback  callback,
long  clientdata 
)
void aisc_remove_destroy_callback ( void  )
int aisc_server_save_token ( FILE *  fd,
const char buffer,
int  maxsize 
)

Definition at line 1186 of file server.c.

References buffer.

int aisc_server_load_token ( FILE *  fd,
char buffer,
int  maxsize 
)

Definition at line 1199 of file server.c.

References buffer, and result.

Variable Documentation

aisc_bytes_list* aisc_server_bytes_first
static

Definition at line 97 of file server.c.

aisc_bytes_list* aisc_server_bytes_last
static

Definition at line 98 of file server.c.

char* aisc_object_names[]
char** aisc_attribute_names_list[]
aisc_talking_func_long* aisc_talking_functions_get[]
aisc_talking_func_long* aisc_talking_functions_set[]
aisc_talking_func_longp* aisc_talking_functions_copy[]
aisc_talking_func_longp* aisc_talking_functions_find[]
aisc_talking_func_longp* aisc_talking_functions_create[]
aisc_talking_func_long aisc_talking_functions_delete[]
const char* aisc_server_error

Definition at line 111 of file server.c.

const int ERRORBUFSIZE = 256

Definition at line 113 of file server.c.

char error_buf[ERRORBUFSIZE]
static
int aisc_server_con
static

Definition at line 116 of file server.c.

Referenced by aisc_add_destroy_callback(), and aisc_remove_destroy_callback().

Hs_struct* aisc_server_hs
static

Definition at line 117 of file server.c.

Referenced by aisc_add_destroy_callback(), and aisc_remove_destroy_callback().

bool sigsegv_occurred = false
static

Definition at line 147 of file server.c.

Referenced by aisc_server_sigsegv(), and test_address_valid().

bool catch_sigsegv = 0
static

Definition at line 148 of file server.c.

Referenced by aisc_server_sigsegv(), and test_address_valid().

jmp_buf return_after_segv
static

Definition at line 149 of file server.c.

Referenced by aisc_server_sigsegv(), and test_address_valid().

SigHandler old_sigsegv_handler
static

Definition at line 198 of file server.c.

Referenced by aisc_server_sigsegv(), and open_aisc_server().

int aisc_server_index = -1
static

Definition at line 423 of file server.c.

Referenced by aisc_talking_get_index().

struct aisc_static_set_mem md
static
int* aisc_main

Definition at line 64 of file names.cxx.

aisc_talking_function_type aisc_talking_functions[]
static
Initial value:
= {
}
static long aisc_talking_get(long *in_buf, int size, long *out_buf, int)
Definition: server.c:297
static long aisc_fork_server(long *, int, long *, int)
Definition: server.c:788
static long aisc_talking_create(long *in_buf, int size, long *out_buf, int)
Definition: server.c:608
static long aisc_talking_delete(long *in_buf, int, long *out_buf, int)
Definition: server.c:793
static long aisc_talking_nset(long *in_buf, int size, long *out_buf, int)
Definition: server.c:583
static long aisc_talking_init(long *, int, long *out_buf, int)
Definition: server.c:782
static long aisc_talking_copy(long *in_buf, int size, long *out_buf, int)
Definition: server.c:665
static long aisc_talking_find(long *in_buf, int, long *out_buf, int)
Definition: server.c:725
static long aisc_talking_set(long *in_buf, int size, long *out_buf, int)
Definition: server.c:573
static long aisc_talking_debug_info(long *in_buf, int, long *out_buf, int)
Definition: server.c:834

Definition at line 954 of file server.c.

Referenced by aisc_talking().