revamp for 21st Century

This commit is contained in:
Bernard Quatermass 2019-11-30 16:37:28 +00:00
parent 59a096572e
commit 3eec70880e
137 changed files with 1496 additions and 8421 deletions

View file

@ -1,94 +0,0 @@
#ifndef MPLIB1_BPO_ALLOC_PRIV
#define MPLIB1_BPO_ALLOC_PRIV
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#ifndef MPLIB1_BPO_LOCK
#include <mplib1/bpo_lock.h>
#endif
#ifndef MPLIB1_BPO_LIST
#include <mplib1/bpo_list.h>
#endif
#ifndef MPLIB1_BPO_INIT
#include <mplib1/bpo_init.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#define MIN_SHALLOC_SIZE 32
#define MIN_SHALLOC_MASK 0xffffffe0
#define STD_NUM_TRACK_BLKS 100
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
struct shalloc_track_head
{
off_t lno_me;
off_t next_track_head;
size_t head_and_tracks;
size_t num_tracks;
size_t num_empty;
int sth_flags;
};
struct shalloc_track
{
off_t sh_off;
size_t sh_size;
};
struct shalloc_base
{
off_t lno_me;
size_t sh_size;
off_t lno_first_free;
off_t lno_first_used;
b_lock_t sb_lock;
struct shalloc_track emergency_used;
struct sodb_resource shalloc_resource;
char shalloc_name[10];
};
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern struct sodb_resource *
shalloc_init( void *seg_base, off_t shalloc_base_off, size_t shalloc_sz );
#endif
/* -- End of File -- */

View file

@ -1,142 +0,0 @@
#ifndef MPLIB1_BPO_INIT_INTERNAL
#define MPLIB1_BPO_INIT_INTERNAL
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#include <sys/ipc.h>
#endif
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#ifndef MPLIB1_DL_LIST
#include <mplib1/dl_list.h>
#endif
#ifndef MPLIB1_BPO_LOCK
#include <mplib1/bpo_lock.h>
#endif
#ifndef MPLIB1_BPO_LIST
#include <mplib1/bpo_list.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#define SODB_MAGIC 0x536d6567
#define SODB_VERSION_1 1
#define SODB_VERSION_2 2
#define SODB_VERSION_4 4
#define SODB_CURRENT_VERSION SODB_VERSION_4
#define SODB_NAME_SIZE1 512
enum sodb_types
{
SODB_T_UNKNOWN,
SODB_T_MMAP,
SODB_T_IPC
};
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
struct sodb_resource
{
bpo_Node_t res_node;
off_t res_off;
};
struct sodb
{
int sodb_magic;
char sodb_use_name[SODB_NAME_SIZE1];
size_t sodb_size;
enum sodb_types sodb_type;
int sodb_version;
int sodb_flags;
struct stat mmap_stat;
int mmap_fd;
int mmap_prot;
int mmap_flags;
off_t mmap_off;
char mmap_name[SODB_NAME_SIZE1];
key_t ipc_key;
char ipc_path[SODB_NAME_SIZE1];
char ipc_tok_id;
int ipc_id;
struct bpo_pid_lock res_p_lock;
bpo_List_t sodb_resource_list;
struct sodb_resource sodb_resource;
char sodb_res_name[10]; /* this has "SODB Base" copied into it */
off_t shalloc_offset;
size_t shalloc_size;
};
struct sodb_track
{
dl_Node_t st_Node;
struct sodb *sodbp;
int mmap_fd;
const char *upper;
mode_t access_mode;
char fname[1];
};
struct sodb_res_find
{
struct sodb *sodbp;
const char *name;
void *ptr;
void *obj;
int flags;
int ierrno;
off_t rv;
};
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern void Init_SODB_Resources( struct sodb *sodbp );
#endif
/* -- End of File -- */

346
include/bpo_internal.h Normal file
View file

@ -0,0 +1,346 @@
#ifndef MPLIB1_BPO_INTERNAL
#define MPLIB1_BPO_INTERNAL
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
*******************************************************************************
*/
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#ifndef MPLIB1_DL_LIST
#include <mplib1/dl_list.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <mplib1/bpo.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#define GNNODE(n,off) ((bpo_Node_t *)GRPTR(n,off))
#define GANNODE(bp,off) (bpo_Node_t *)((void *)bp+off)
#define SODB_MAGIC 0x536d6567
#define SODB_VERSION_1 1
#define SODB_VERSION_2 2
#define SODB_VERSION_4 4
#define SODB_CURRENT_VERSION SODB_VERSION_4
#define SODB_NAME_SIZE1 512
enum sodb_types
{
SODB_T_UNKNOWN,
SODB_T_MMAP,
SODB_T_IPC
};
#define MIN_SHALLOC_SIZE 32
#define MIN_SHALLOC_MASK 0xffffffe0
#define STD_NUM_TRACK_BLKS 100
#ifndef BIT
#define BIT(n) (1<<(n))
#endif
#define SHM_INHERIT_GROUP BIT(0)
#define SHM_INHERIT_PROGRAM BIT(1)
#define SHM_AUTOMAGIC_PIPE BIT(2)
#define SHM_CHECK_ALL_PROCESSES 1
#define SHM_CHECK_THIS_PROCESS 2
#define SHM_CHECK_DEAD_PROCESSES 3
/* Return values to the validate processes inform call */
#define SHM_LEAVE_PROC 0
#define SHM_DELETE_PROC 1
#ifndef PID_STR_LEN
#define PID_STR_LEN 12
#endif
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
struct sodb_resource
{
bpo_Node_t res_node;
off_t res_off;
};
struct sodb
{
int sodb_magic;
char sodb_use_name[SODB_NAME_SIZE1];
size_t sodb_size;
enum sodb_types sodb_type;
int sodb_version;
int sodb_flags;
struct stat mmap_stat;
int mmap_fd;
int mmap_prot;
int mmap_flags;
off_t mmap_off;
char mmap_name[SODB_NAME_SIZE1];
key_t ipc_key;
char ipc_path[SODB_NAME_SIZE1];
char ipc_tok_id;
int ipc_id;
struct bpo_pid_lock res_p_lock;
bpo_List_t sodb_resource_list;
struct sodb_resource sodb_resource;
char sodb_res_name[10]; /* this has "SODB Base" copied into it */
off_t shalloc_offset;
size_t shalloc_size;
};
struct sodb_track
{
dl_Node_t st_Node;
struct sodb *sodbp;
int mmap_fd;
const char *upper;
mode_t access_mode;
char fname[1];
};
struct sodb_res_find
{
struct sodb *sodbp;
const char *name;
void *ptr;
void *obj;
int flags;
int ierrno;
off_t rv;
};
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern void Init_SODB_Resources( struct sodb *sodbp );
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
struct shalloc_track_head
{
off_t lno_me;
off_t next_track_head;
size_t head_and_tracks;
size_t num_tracks;
size_t num_empty;
int sth_flags;
};
struct shalloc_track
{
off_t sh_off;
size_t sh_size;
};
struct shalloc_base
{
off_t lno_me;
size_t sh_size;
off_t lno_first_free;
off_t lno_first_used;
b_lock_t sb_lock;
struct shalloc_track emergency_used;
struct sodb_resource shalloc_resource;
char shalloc_name[10];
};
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern struct sodb_resource *
shalloc_init( void *seg_base, off_t shalloc_base_off, size_t shalloc_sz );
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
struct Q_Head
{
off_t lno_me;
bpo_List_t Qh_List;
};
struct bpo_Q_pid
{
bpo_Node_t Q_pid_Node;
pid_t Q_pid;
char Q_pidstr[PID_STR_LEN];
};
struct bpo_private_pid
{
dl_Node_t q_Node;
pid_t pid;
char pid_str[PID_STR_LEN];
};
struct bpo_private_q
{
dl_Node_t q_Node;
int Q_max_count;
int Q_Count;
int Q_notify;
int Q_flags;
pid_t Q_sole_pid;
dl_List_t private_pids;
unsigned long pid_ser_nbr;
dl_List_t old_pids;
struct bpo_Q *qp;
char Q_name[1];
};
struct cache_queue_list
{
dl_Node_t lnk_node;
char ptr_str[40];
unsigned long serial_nbr;
time_t update_tm;
struct Q_Head *qh;
dl_List_t q_list;
dl_List_t old_q_list;
};
typedef int (*Validate_Queues_t)(struct bpo_private_q *pqp, void *param1 );
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern struct Q_Head *
get_Q_resource( const void *hint );
extern struct cache_queue_list *
cache_queues( struct Q_Head *qh, const char *q_name );
extern void
free_q_stuff( struct bpo_Q *qp );
extern void
free_this_private_q( struct bpo_private_q *pqp );
extern int
Validate_Queues( const void *hint,
int p_which_queues,
Validate_Queues_t disp,
void *param1 );
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
struct shm_proc_list
{
off_t lno_me;
int serial_nbr;
time_t update_tm;
bpo_List_t proc_List;
};
struct shm_process
{
off_t lno_me;
bpo_Node_t proc_Node;
pid_t pid;
time_t pid_start_tm;
bpo_List_t pid_resources;
char pid_str[PID_STR_LEN];
off_t pid_grp_o;
off_t pid_nm_o;
off_t pid_fifo_o;
};
struct shm_process_private
{
dl_Node_t spp_Node;
pid_t pid;
char pid_str[PID_STR_LEN];
char *pid_grp;
char *pid_nm;
char *pid_fifo;
int fifo_fd;
int fifo_created;
mode_t fifo_mode;
time_t pid_start_tm;
struct shm_process *spp;
};
struct cache_proc_list
{
dl_Node_t lnk_node;
char ptr_str[40];
unsigned long serial_nbr;
time_t update_tm;
struct shm_proc_list *splp;
dl_List_t proc_list;
dl_List_t old_proc_list;
};
typedef int (* Validate_Processes_t)( struct shm_process_private *shmpp,
void *param1 );
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
/* Allocate functions */
extern struct shm_process_private *
alloc_private_process( pid_t the_pid, const char *pid_grp,
const char *pid_nm, const char *pid_fifo );
extern void
free_private_process( struct shm_process_private *sppp );
#ifndef MPLIB1_BPO_PROC
extern struct shm_process_private * Get_My_Proc_Details( mode_t privs );
extern struct shm_process_private * Check_My_Proc_Details( void );
#endif
extern int
Validate_Processes( const void * hint, int which_procs,
Validate_Processes_t disp,
void *param1 );
extern struct shm_proc_list *Find_Proc_List( const void *hint );
extern struct cache_proc_list *Get_Cache_Procs( const void *hint );
#endif
/* -- End of File -- */

View file

@ -1,50 +0,0 @@
#ifndef MPLIB1_BPO_INIT_INTERNAL
#define MPLIB1_BPO_INIT_INTERNAL
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#define GNNODE(n,off) ((bpo_Node_t *)GRPTR(n,off))
#define GANNODE(bp,off) (bpo_Node_t *)((char *)bp+off)
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
#endif
/* -- End of File -- */

View file

@ -1,183 +0,0 @@
#ifndef MPLIB1_BPO_LOCK_INTERNAL
#define MPLIB1_BPO_LOCK_INTERNAL
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#ifndef MPLIB1_BPO_LOCK
#include <mplib1/bpo_lock.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
/* Only one of the following ifdef blocks should be enabled */
#ifdef HAVE_PTHREADS
/* No explicit defines needed */
#endif
#ifdef HAVE_MSEM
/* XPG4 varient */
/*#define Xchg(a) msem_lock(a,0)*/
/*#define Clr(a) msem_unlock(a)*/
#endif
#ifdef HAVE_MUTEX
#define Xchg(a) acquire_lock(a)
#define Clr(a) release_lock(a)
#define Lckval(a) ((long)(a->abi_lock))
#endif
#ifdef HAVE_SYS_ATOMIC
#include <sys/atomic.h>
#define Xchg(a) atomic_xchg_long((long *)a,1)
#define Clr(a) atomic_xchg_long((long *)a,0)
#define Lckval(a) ((long)(*(long *)a))
#endif
#ifdef HAVE_GCC_I386
/* The following was swiped from <asm/bitops.h> in the linux distribution */
/*
* Some hacks to defeat gcc over-optimizations..
*/
struct __dummy { unsigned long a[100]; };
#define ADDR (*(struct __dummy *) addr)
__inline__ static int Xchg(volatile void * addr)
{
int oldbit;
__asm__ __volatile__("btsl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"=m" (ADDR)
:"r" (0));
return oldbit;
}
__inline__ static int Clr( volatile void * addr)
{
int oldbit;
__asm__ __volatile__("btrl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"=m" (ADDR)
:"r" (0));
return oldbit;
}
#define Lckval(a) ((long)(*a))
#endif
#ifdef HAVE_SVR4_I386
/* The following were grabbed from <sys/mp/mpmacros.h> on NCR 3000 */
asm int
Xchg(lp)
{
% mem lp;
movl lp,%eax
xchgl %eax,(%eax)
}
asm void
Clr(lp)
{
% mem lp;
movl lp,%eax
movl $0,(%eax)
% reg lp;
movl $0,(lp)
}
#define Lckval(a) ((long)(*a))
#endif
#ifdef HAVE_SVR4_I386B
/* The following was grabbed from <sys/atomic.h> on Sequent Ptx4.2.0 */
/*
* atomic_xchg_long
*
* Atomically exchange the specified value with that at the specified
* address, returning the old value.
* The only reason for having both atomic_xchg_*() and atomic_xchg_u*()
* primitives is to keep the compiler and lint happy without huge
* numbers of error-hiding casts.
*
* Parameters:
* long *longptr; Address of long to exchange
* long newval; New value to exchange into *longptr.
*/
#ifdef __STDC__
__asm long atomic_xchg_long(volatile long *const longptr, long const newval)
#else
asm long atomic_xchg_long(longptr, newval)
#endif
{
%con longptr, newval;
movl longptr, %ecx /* Get addr to known register. */
movl newval, %eax /* Get new value to known register. */
xchgl %eax, (%ecx) /* Perform the exchange. */
%con longptr; mem newval;
movl longptr, %ecx /* Get addr to known register. */
movl newval, %eax /* Get new value to known register. */
xchgl %eax, (%ecx) /* Perform the exchange. */
%mem longptr; con newval;
movl longptr, %ecx /* Get addr to known register. */
movl newval, %eax /* Get new value to known register. */
xchgl %eax, (%ecx) /* Perform the exchange. */
%mem longptr, newval;
movl longptr, %ecx /* Get addr to known register. */
movl newval, %eax /* Get new value to known register. */
xchgl %eax, (%ecx) /* Perform the exchange. */
}
#define Xchg(a) atomic_xchg_long((long *)a,1)
#define Clr(a) atomic_xchg_long((long *)a,0)
#define Lckval(a) ((long)(*(long *)a))
#endif
#endif
/* -- End of File -- */

View file

@ -1,156 +0,0 @@
#ifndef MPLIB1_BPO_PROC_INTERNAL
#define MPLIB1_BPO_PROC_INTERNAL
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#include <mplib1/dl_list.h>
#endif
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#ifndef MPLIB1_BPO_LOCK
#include <mplib1/bpo_lock.h>
#endif
#ifndef MPLIB1_BPO_LIST
#include <mplib1/bpo_list.h>
#endif
#ifndef MPLIB1_BPO_INIT
#include <mplib1/bpo_init.h>
#endif
#ifndef MPLIB1_BPO_ALLOC
#include <mplib1/bpo_alloc.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#ifndef BIT
#define BIT(n) (1<<(n))
#endif
#define SHM_INHERIT_GROUP BIT(0)
#define SHM_INHERIT_PROGRAM BIT(1)
#define SHM_AUTOMAGIC_PIPE BIT(2)
#define SHM_CHECK_ALL_PROCESSES 1
#define SHM_CHECK_THIS_PROCESS 2
#define SHM_CHECK_DEAD_PROCESSES 3
/* Return values to the validate processes inform call */
#define SHM_LEAVE_PROC 0
#define SHM_DELETE_PROC 1
#ifndef PID_STR_LEN
#define PID_STR_LEN 12
#endif
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
struct shm_proc_list
{
off_t lno_me;
int serial_nbr;
time_t update_tm;
bpo_List_t proc_List;
};
struct shm_process
{
off_t lno_me;
bpo_Node_t proc_Node;
pid_t pid;
time_t pid_start_tm;
bpo_List_t pid_resources;
char pid_str[PID_STR_LEN];
off_t pid_grp_o;
off_t pid_nm_o;
off_t pid_fifo_o;
};
struct shm_process_private
{
dl_Node_t spp_Node;
pid_t pid;
char pid_str[PID_STR_LEN];
char *pid_grp;
char *pid_nm;
char *pid_fifo;
int fifo_fd;
int fifo_created;
mode_t fifo_mode;
time_t pid_start_tm;
struct shm_process *spp;
};
struct cache_proc_list
{
dl_Node_t lnk_node;
char ptr_str[40];
unsigned long serial_nbr;
time_t update_tm;
struct shm_proc_list *splp;
dl_List_t proc_list;
dl_List_t old_proc_list;
};
typedef int (* Validate_Processes_t)( struct shm_process_private *shmpp,
void *param1 );
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
/* Allocate functions */
extern struct shm_process_private *
alloc_private_process( pid_t the_pid, const char *pid_grp,
const char *pid_nm, const char *pid_fifo );
extern void
free_private_process( struct shm_process_private *sppp );
#ifndef MPLIB1_BPO_PROC
extern struct shm_process_private * Get_My_Proc_Details( mode_t privs );
extern struct shm_process_private * Check_My_Proc_Details( void );
#endif
extern int
Validate_Processes( const void * hint, int which_procs,
Validate_Processes_t disp,
void *param1 );
extern struct shm_proc_list *Find_Proc_List( const void *hint );
extern struct cache_proc_list *Get_Cache_Procs( const void *hint );
#endif
/* -- End of File -- */

View file

@ -1,140 +0,0 @@
#ifndef MPLIB1_BPO_Q_INTERNAL
#define MPLIB1_BPO_Q_INTERNAL
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#include <mplib1/dl_list.h>
#endif
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#ifndef MPLIB1_BPO_LOCK
#include <mplib1/bpo_lock.h>
#endif
#ifndef MPLIB1_BPO_LIST
#include <mplib1/bpo_list.h>
#endif
#ifndef MPLIB1_BPO_INIT
#include <mplib1/bpo_init.h>
#endif
#ifndef MPLIB1_BPO_ALLOC
#include <mplib1/bpo_alloc.h>
#endif
#ifndef MPLIB1_BPO_PROC
#include <mplib1/bpo_proc.h>
#endif
#ifndef MPLIB1_BPO_QUEUE
#include <mplib1/bpo_queue.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
struct Q_Head
{
off_t lno_me;
bpo_List_t Qh_List;
};
struct bpo_Q_pid
{
bpo_Node_t Q_pid_Node;
pid_t Q_pid;
char Q_pidstr[PID_STR_LEN];
};
struct bpo_private_pid
{
dl_Node_t q_Node;
pid_t pid;
char pid_str[PID_STR_LEN];
};
struct bpo_private_q
{
dl_Node_t q_Node;
int Q_max_count;
int Q_Count;
int Q_notify;
int Q_flags;
pid_t Q_sole_pid;
dl_List_t private_pids;
unsigned long pid_ser_nbr;
dl_List_t old_pids;
struct bpo_Q *qp;
char Q_name[1];
};
struct cache_queue_list
{
dl_Node_t lnk_node;
char ptr_str[40];
unsigned long serial_nbr;
time_t update_tm;
struct Q_Head *qh;
dl_List_t q_list;
dl_List_t old_q_list;
};
typedef int (*Validate_Queues_t)(struct bpo_private_q *pqp, void *param1 );
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern struct Q_Head *
get_Q_resource( const void *hint );
extern struct cache_queue_list *
cache_queues( struct Q_Head *qh, const char *q_name );
extern void
free_q_stuff( struct bpo_Q *qp );
extern void
free_this_private_q( struct bpo_private_q *pqp );
extern int
Validate_Queues( const void *hint,
int p_which_queues,
Validate_Queues_t disp,
void *param1 );
#endif
/* -- End of File -- */

View file

@ -5,35 +5,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#include <mplib1/dl_list.h>
#endif
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -1,179 +0,0 @@
#ifndef MPLIB1_DL_LRU_PRIVATE_H
#define MPLIB1_DL_LRU_PRIVATE_H
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : private definitions for the cache routines
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#include <mplib1/dl_list.h>
#include <mplib1/data_align.h>
#endif
struct Full_List
{
List_t fl_Search_List;
List_t fl_LRU_List;
const char *fl_Name;
};
#define FULL_LIST_SIZE sizeof(struct Full_List)
struct Cache_List
{
Node_t cl_Node; /* links us into the Master List */
char *cl_Name; /* Name of this list, (cursor name) */
List_t cl_Fields; /* List of fields (definitions) */
struct Full_List cl_Items; /* List of items */
List_t cl_Free; /* free items */
List_t cl_Free_cgi; /* free cgi items */
List_t cl_Build; /* build list for new items */
List_t cl_Missing; /* list for missing items */
int cl_flags; /* how we will check this list */
size_t cl_data_size; /* size of data block allocated for each item */
int cl_max_items; /* How many items allowed on list */
int cl_curr_items; /* how many so far */
int cl_max_field_num; /* current maximum field number */
int cl_cache_replaces; /* how many times did we re-use */
int cl_cache_hits; /* found an entry */
int cl_cache_misses; /* oh dear */
int cl_complete_misses; /* If they care to tell us */
int cl_expire_seconds; /* How long an item is allowed to live */
int cl_num_search_rules; /* How many rules in the next array */
struct full_search_rule *cl_search_rules; /* How to search */
time_t cl_create_time; /* when was this created */
int cl_expire_time; /* How many seconds till expiry */
};
struct Cache_Field
{
Node_t cf_Node; /* to link into cl_Field list */
char *cf_Name;
int cf_field_num;
int cf_field_type;
#define CF_INT 1
#define CF_DOUBLE 2
#define CF_CHAR 3
#define CF_STRING 4
#define CF_VARCHAR 5
#define CF_NUM_FIELD_TYPES 6
int cf_field_flags;
#define CF_FLG_IGNORECASE BIT(0)
int cf_f_offset; /* field offset from item base */
size_t cf_field_size; /* and length within data block */
};
struct Cache_Item
{
Node_t ci_S_Node; /* to link us into the cl_Items Search list */
Node_t ci_L_Node; /* to link us into the cl_Items LRU list */
char *ci_Name; /* index field */
size_t ci_data_size; /* size of allocated block */
size_t ci_str_size; /* size of the original string */
void *ci_Item; /* pointer to block containing data */
time_t ci_expire_time; /* When this item is to be aged */
};
struct Cache_Group_Item
{
struct Cache_Item cgi_Item; /* Allow for normal data */
struct Full_List cgi_Items; /* Next list for searching */
int cgi_Flags;
int cgi_cache_replaces; /* how many times did we re-use */
int cgi_cache_hits; /* found an entry */
int cgi_cache_misses; /* oh dear */
int cgi_complete_misses; /* If they care to tell us */
};
struct full_search_rule
{
struct Cache_Field *cf;
int comparison_method;
int (*cmpfunc)( void *, void * );
/*off_t cf_f_offset;*/
};
#define CGI_COMPLETE_MISS BIT(0)
#define CACHE_LIST_SIZE sizeof(struct Cache_List)
#define CACHE_FIELD_SIZE sizeof(struct Cache_Field)
#define CACHE_ITEM_SIZE STRUCT_PAD(sizeof(struct Cache_Item))
/* In dl_lru (normal caching) ------------------------------ */
extern struct Full_List *
Init_Full_List ( struct Full_List *list, const char *name, int flags );
extern void *
Find_Full_Item ( struct Full_List *flist, const char *name );
extern List_t *
Get_Cache_Master_List( void );
extern void *
Cache_Alloc_Lump( size_t sz, const char *name, char **new_name );
extern struct Cache_List *
New_Cache_List( const char *list_name, int max_items,
int flags, int defaults, int last_ditch );
extern int
Cache_Build_Field_List( struct Cache_List *cl,
const char *format_str,
const char *field_names );
extern struct Cache_Item *
Cache_Find_Simple_Item( struct Cache_List *cl,
const char *keys,
int *rv );
/* In dl_lru_range (range caching) ------------------------------ */
extern struct Cache_Item *
Cache_Find_Requested_Item( struct Cache_List *cl, const void *keys, int *rv );
extern struct Cache_Item *
Cache_Get_Item_From_Free( struct Cache_List *cl );
extern int
Cache_End_Of_Many( struct Cache_List *cl );
extern int
Range_Complete_Miss( struct Cache_List *cl, const void *keys );
extern int
Range_Flush( struct Cache_List *cl );
#endif
/* -- End of File -- */

View file

@ -4,22 +4,10 @@
include ../make_include
MPLIB1=$(LIBDIR)/libmplib1.a
MPLIB1SO_BASE=libmplib1.so
MPLIB1SO_BASE=libmplib1.$(DYNLIBSUFFIX)
MPLIB1SO=$(LIBDIR)/$(MPLIB1SO_BASE)
ifndef MAJOR_VERSION
MAJOR_VERSION=4
endif
ifndef MINOR_VERSION
MINOR_VERSION=1
endif
VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)
ifdef BUILD_SHARED
TARGETS=$(MPLIB1) $(MPLIB1SO)
else
TARGETS=$(MPLIB1)
endif
TARGETS=$(MPLIB1SO)
PUBHEADERS=$(wildcard $(LIBINC_DIR)/mplib1/*.h)
PUBHEADERS_BASE=$(patsubst $(LIBINC_DIR)/mplib1/%, %, $(PUBHEADERS))
@ -40,15 +28,10 @@ OBJECTS= \
cfg_file.o \
cfg_watch.o \
lock_file.o \
vre_alloc.o \
vre_disp.o \
vre_parse.o \
vre_loop.o \
fgetline.o \
fgetline2.o \
match_tok.o \
lmsort.o \
lmsort_m.o \
dl_sort_i.o \
dl_sort_n.o \
dumphex.o \
@ -64,12 +47,9 @@ OBJECTS= \
$(COMPAT_OBJS)
LIBOBJECTS=$(patsubst %.o,$(MPLIB1)(%.o),$(OBJECTS))
SO_OBJECTS=$(patsubst %.o,$(MPLIB1SO)(%.o),$(OBJECTS))
LIBSOURCE=$(patsubst %.o,%.c,$(OBJECTS))
LIBDEPEND=$(patsubst %.o,DEPENDS/%.d,$(OBJECTS))
all: $(TARGETS)
@ -78,46 +58,77 @@ all: $(TARGETS)
clean:
@rm -f $(TARGETS)
@rm -f $(OBJECTS)
@rm -f $(LIBDEPEND)
install:
cp $(MPLIB1) $(INSTALL_LIB)
@mkdir $(INSTALL_INCLUDE)
cp $(PUBHEADERS) $(INSTALL_INCLUDE)
ifdef BUILD_SHARED
cp $(MPLIB1SO) $(INSTALL_LIB)/$(MPLIB1SO_BASE).$(VERSION)
ln -s $(MPLIB1SO_BASE).$(VERSION) $(INSTALL_LIB)/$(MPLIB1SO_BASE)
ln -s $(MPLIB1SO_BASE).$(VERSION) $(INSTALL_LIB)/$(MPLIB1SO_BASE).$(MAJOR_VERSION)
cp $(MPLIB1SO) $(INSTALL_LIB)/$(MPLIB1SO_BASE).$(MAJMIN_VERSION)
ln -s $(MPLIB1SO_BASE).$(MAJMIN_VERSION) $(INSTALL_LIB)/$(MPLIB1SO_BASE)
ln -s $(MPLIB1SO_BASE).$(MAJMIN_VERSION) $(INSTALL_LIB)/$(MPLIB1SO_BASE).$(MAJOR_VERSION)
ifeq ($(NEEDSONAME),yes)
SONAMEVAR = $(SONAMEOPT)$(MPLIB1SO_BASE).$(MAJOR_VERSION)
else
SONAMEVAR =
endif
docs: docs_xref docs_src
docs_xref:
cxref $(LIBSOURCE) -xref-all -index-all -Osrc_doc -Nmplib1 -R.. -I$(LIBINC_DIR)
cxref $(PUBHEADERS) -xref-all -index-all -Osrc_doc -Nmplib1 -R.. -I$(LIBINC_DIR) -- -DCXREF
cxref $(PRIVATE_H) -xref-all -index-all -Osrc_doc -Nmplib1 -R.. -I$(LIBINC_DIR) -- -DCXREF
cxref $(LIBSOURCE) -xref-all -index-all -Osrc_doc -Nmplib1 -R.. -html -html-body include/body_part.html -I$(LIBINC_DIR)
cxref $(PUBHEADERS) -xref-all -index-all -Osrc_doc -Nmplib1 -R.. -html -html-body include/body_part.html -I$(LIBINC_DIR) -- -DCXREF
cxref $(PRIVATE_H) -xref-all -index-all -Osrc_doc -Nmplib1 -R.. -html -html-body include/body_part.html -I$(LIBINC_DIR) -- -DCXREF
docs_src:
../gen_html_index $(LIBSOURCE) . Makefile
(cd ../mplib1; ../gen_html_index $(PUBHEADERS_BASE) )
(cd ../include; ../gen_html_index $(PRIVATE_H_BASE) )
docs_clean:
rm -f ../src_doc/mplib1.*
rm -rf ../src_doc/mplib1 ../src_doc/include ../src_doc/libsrc
rm -f index.html ../mplib1/index.html ../include/index.html
$(MPLIB1): ../mplib1/mplib1_config.h $(LIBOBJECTS)
$(MPLIB1SO): $(OBJECTS)
$(CC) -shared -Wl,-soname,$(MPLIB1SO_BASE).$(MAJOR_VERSION) \
$(CC) $(DYNLIBOPT) $(SONAMEVAR) \
-o $(MPLIB1SO) \
$(OBJECTS)
ifndef DOING_CLEAN
include $(LIBDEPEND)
endif
build_argv.o: build_argv.c \
../mplib1/mplib1_config.h ../mplib1/build_argv.h ../mplib1/dl_list.h \
../mplib1/mpstrtok.h ../mplib1/cfg_file.h
cfg_file.o: cfg_file.c \
../mplib1/mplib1_config.h ../mplib1/safe_string.h ../mplib1/fgetline.h \
../mplib1/dl_list.h ../mplib1/cfg_file.h ../mplib1/timestamp.h \
../include/cfg_file_internal.h
cfg_watch.o: cfg_watch.c \
../mplib1/mplib1_config.h ../mplib1/cfg_file.h ../mplib1/fprintfile.h \
../mplib1/timestamp.h
cpustopwatch.o: cpustopwatch.c \
../mplib1/mplib1_config.h ../mplib1/stopwatch.h
daemonloop.o: daemonloop.c \
../mplib1/cfg_file.h ../mplib1/daemon.h ../mplib1/mplib1_config.h
daemonsleep.o: daemonsleep.c \
../mplib1/mplib1_config.h ../mplib1/dl_list.h \
../mplib1/bpo.h \
../mplib1/daemon.h
dl_list.o: dl_list.c \
../mplib1/mplib1_config.h ../mplib1/dl_list.h
dl_sort_i.o: dl_sort_i.c \
../mplib1/mplib1_config.h ../mplib1/dl_list.h
dl_sort_n.o: dl_sort_n.c \
../mplib1/mplib1_config.h ../mplib1/dl_list.h
dumphex.o: dumphex.c \
../mplib1/dumphex.h
fgetline.o: fgetline.c \
../mplib1/fgetline.h
fgetline2.o: fgetline2.c \
../mplib1/fgetline.h
inthand.o: inthand.c \
../mplib1/daemon.h ../mplib1/mplib1_config.h
leavesub.o: leavesub.c \
../mplib1/cfg_file.h ../mplib1/daemon.h ../mplib1/mplib1_config.h
lmsort.o: lmsort.c \
../mplib1/mplib1_config.h ../mplib1/lmsort.h
lock_file.o: lock_file.c \
../mplib1/mplib1_config.h ../mplib1/pid_check.h ../mplib1/fprintfile.h \
../mplib1/timestamp.h ../mplib1/lock_file.h
match_tok.o: match_tok.c \
../mplib1/mplib1_config.h ../mplib1/match_tok.h
min_list.o: min_list.c ../mplib1/mplib1_config.h ../mplib1/min_list.h
mpbasename.o: mpbasename.c \
../mplib1/mplib1_config.h ../mplib1/mpbasename.h
mpstrtok.o: mpstrtok.c \
../mplib1/mplib1_config.h ../mplib1/mpstrtok.h
pidstr.o: pidstr.c \
../mplib1/mplib1_config.h ../mplib1/pid_check.h
safe_string.o: safe_string.c \
../mplib1/mplib1_config.h ../mplib1/safe_string.h
stopwatch.o: stopwatch.c \
../mplib1/mplib1_config.h ../mplib1/stopwatch.h
stopwatch_c.o: stopwatch_c.c \
../mplib1/mplib1_config.h ../mplib1/stopwatch.h

View file

@ -3,30 +3,9 @@
* Copyright (c) 1997 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,30 +3,9 @@
* Copyright (c) 1997 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,28 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* *
* $Source$
* $Author$
* $Date$
* $Revision$
* *
*******************************************************************************
* *
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,31 +3,9 @@
* Copyright (c) 1997 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,31 +3,9 @@
* Copyright (c) 1997 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -48,7 +26,7 @@
#endif
#include <mplib1/dl_list.h>
#include <mplib1/bpo_proc.h>
#include <mplib1/bpo.h>
#include <mplib1/daemon.h>
/* ------------------------------------------------------------------

View file

@ -3,31 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : Double-linked list handling
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -1,940 +0,0 @@
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <memory.h>
#include <time.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/mpstrtok.h>
#include <mplib1/dl_list.h>
#include <mplib1/dl_lru.h>
#include <mplib1/data_align.h>
#include "../include/dl_lru_private.h"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
struct vchar_gen
{
unsigned short len;
unsigned char arr[1];
};
typedef struct vchar_gen *vchar_ptr;
struct cps
{
struct Cache_List *cl;
int nrl;
struct full_search_rule *srp;
void **sv;
struct Cache_Item *ci;
struct Cache_Item *si;
struct Cache_Item *rv;
};
/* ------------------------------------------------------------------
Some static variables
------------------------------------------------------------------ */
static List_t *Master_List=NULL;
static int default_flags=CACHE_USE_DEFAULT;
#ifdef CACHE_DEBUG
static int cache_debug=0;
#endif
#define SEARCH_MISSING_LIST BIT(0)
#define SEARCH_FREE_LIST BIT(1)
#define SEARCH_LRU_LIST BIT(2)
#define SEARCH_ALL_LISTS (SEARCH_MISSING_LIST|SEARCH_FREE_LIST|SEARCH_LRU_LIST)
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */
struct Full_List *
Init_Full_List ( struct Full_List *list, const char *name, int flags )
{
size_t ms=(size_t)0;
char *mp=NULL;
if ( list==NULL )
ms += FULL_LIST_SIZE;
if ( name )
ms += (size_t)(strlen(name) + 1);
if ( ms
&& ( mp = (char *)malloc( ms )) == NULL
)
return(NULL);
if ( list==NULL )
{
list = (struct Full_List *) mp;
mp += FULL_LIST_SIZE;
}
if ( name )
{
strcpy( mp , name );
name = mp;
}
Init_List( &list->fl_Search_List, flags );
Init_List( &list->fl_LRU_List, flags );
list->fl_Name = name;
return(list);
}
void *
Find_Full_Item ( struct Full_List *flist, const char *name )
{
void *item;
dl_Node_t *node;
if ( (item = Find_Item_By_Name( &flist->fl_Search_List, name )) )
{
if( (node = Find_Node_By_Item( &flist->fl_LRU_List, item )) )
{
Add_Head( &flist->fl_LRU_List, node );
}
}
return(item);
}
static int
Local_Cache_Init( List_t **cml )
{
List_t *ml=*cml;
int rv=0;
static int init_done=0;
if ( (ml == NULL)
&& (ml = (List_t *)malloc(LIST_SIZE))
)
{
*cml = ml;
Init_List ( ml, 0 );
init_done = 1;
rv=1;
}
return(rv);
}
List_t *
Get_Cache_Master_List( void )
{
Local_Cache_Init(&Master_List);
return( Master_List );
}
static int
Cache_Flag_Gen( int new_flags, int alt_flags )
{
int cl_flags=CACHE_USE_DEFAULT;
int t_flags;
/* the object here is to generate a set of cache flags
that is the composite of the default and the new
and that there is a bit set in each grouping
In order for the lines to read simply (and since they
are just variations of each other) a macro will now be
defined
*/
#define C_MODE(r,n,a,t,m,d) {t= (n & m) ? (n & m) : (a & m);if (t==m) t= (d & m); r |= t;}
C_MODE(cl_flags,new_flags,alt_flags,t_flags,CACHE_MODE_MASK,CACHE_DEFAULTS);
C_MODE(cl_flags,new_flags,alt_flags,t_flags,CACHE_CASE_MASK,CACHE_DEFAULTS);
C_MODE(cl_flags,new_flags,alt_flags,t_flags,CACHE_ALLOC_MASK,CACHE_DEFAULTS);
C_MODE(cl_flags,new_flags,alt_flags,t_flags,CACHE_MISS_MASK,CACHE_DEFAULTS);
C_MODE(cl_flags,new_flags,alt_flags,t_flags,CACHE_INSERT_MASK,CACHE_DEFAULTS);
C_MODE(cl_flags,new_flags,alt_flags,t_flags,CACHE_FLUSH_MASK,CACHE_DEFAULTS);
return(cl_flags);
}
int Cache_Init( int def_flags)
{
if (default_flags == CACHE_USE_DEFAULT)
{
default_flags = Cache_Flag_Gen( def_flags, CACHE_DEFAULTS );
#ifdef CACHE_DEBUG
if (def_flags & 0x40000000)
{
cache_debug=1;
fprintf(stderr,"cache debug is on\n");
}
#endif
}
return(Local_Cache_Init(&Master_List));
}
struct Cache_Item *
Cache_Find_Simple_Item( struct Cache_List *cl, const char *list_key, int *rv )
{
struct Cache_Item *ci;
ci = (struct Cache_Item *) Find_Full_Item( &cl->cl_Items, list_key );
if (ci)
{
*rv = CACHE_FOUND_ITEM;
}else
{
/* check the complete miss list */
ci = (struct Cache_Item *) Find_Item_By_Name( &cl->cl_Missing, list_key );
*rv = (ci) ? CACHE_COMPLETE_MISS : CACHE_MISSED;
ci=NULL;
}
return(ci);
}
int
Find_Cache_Item( const char *list_name,
const void *list_key,
const char *field_list, ... )
{
int rv=CACHE_MISSED;
struct Cache_List *cl;
struct Cache_Item *ci;
struct Cache_Field *cf;
va_list ap;
void *vp,*ftok1;
char *cp;
char *field_list_copy;
vchar_ptr vcp1,vcp2;
static char sep_list[]=" \t\r\n,";
if (Master_List==NULL)
Local_Cache_Init(&Master_List); /* just in case we haven't done it before */
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"Find_Cache_Item: <%s> <%p> ", list_name, list_key );
#endif
cl = (struct Cache_List *)Find_Item_By_Name( Master_List, list_name );
if (cl)
{
if ( cl->cl_search_rules != NULL )
{
ci = Cache_Find_Requested_Item( cl, list_key, &rv );
}else
{
ci = Cache_Find_Simple_Item( cl, list_key, &rv );
/* ci = (struct Cache_Item *) Find_Full_Item( &cl->cl_Items, list_key );*/
}
if ( ci != NULL )
{
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"Found\n");
#endif
/* now to transfer the relevant fields
we do this by parsing the field list using strtok,
and then finding the named field in the cf list,
and then finding the item field with the corresponding field_num
the value is then returned into the next vararg
*/
cl->cl_cache_hits++;
if (cl->cl_flags & CACHE_CACHE_ON)
{
field_list_copy = strdup(field_list);
va_start(ap,field_list);
cp=mpstrtok(field_list_copy,&ftok1,sep_list);
while (cp)
{
vp = va_arg(ap, void* );
/* find this in the cf list */
cf = (struct Cache_Field *)Find_Item_By_Name( &cl->cl_Fields, cp );
if (cf)
{
/* now generate a pointer to the data in the data segment */
cp = (char *)(ci->ci_Item) + cf->cf_f_offset;
/* we know where it is and what it is, so copy it */
switch(cf->cf_field_type)
{
case CF_INT :
*((int *)vp) = *((int *)cp);
break;
case CF_DOUBLE :
*((double *)vp) = *((double *)cp);
break;
case CF_CHAR :
*((char *)vp) = *cp;
break;
case CF_STRING :
strcpy( (char *)vp, cp );
break;
case CF_VARCHAR :
vcp1 = (vchar_ptr)vp;
vcp2 = (vchar_ptr)cp;
vcp1->len = vcp2->len;
memcpy(vcp1->arr, vcp2->arr, vcp2->len );
break;
}
}
rv=CACHE_FOUND_ITEM;
cp = mpstrtok( NULL, &ftok1, sep_list);
};
(void)mpstrtok( NULL, &ftok1, NULL );
va_end( ap );
}
}else
{
cl->cl_cache_misses++;
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"Not Found\n");
#endif
}
}
#ifdef CACHE_DEBUG
else if (cache_debug)
fprintf(stderr," List not Found\n");
#endif
return(rv);
}
static int
Init_Item( struct Cache_Item *ci,
struct Cache_List *cl,
char *new_name,
size_t name_len )
{
if (ci && cl)
{
/* inititalise the various parts of this beast */
Init_Node( &ci->ci_S_Node, new_name, ci );
Init_Node( &ci->ci_L_Node, new_name, ci );
ci->ci_Name = new_name;
ci->ci_str_size = name_len;
ci->ci_Item = (void *) (((char *)ci) + CACHE_ITEM_SIZE);
/* cl->cl_curr_items++;*/
/* Add_Head( &cl->cl_Items.fl_LRU_List, &ci->ci_L_Node );*/
/* Add_Head( &cl->cl_Items.fl_Search_List, &ci->ci_S_Node );*/
}
return(0);
}
void *
Cache_Alloc_Lump( size_t sz, const char *name, char **new_name )
{
void *vp;
char *np;
size_t osz = sz;
if (name)
sz += (size_t)(strlen(name) + 1);
vp = (void *)malloc( sz );
if (vp)
{
memset( vp, '\0', sz );
if (name)
{
np = (char *)vp + osz;
strcpy(np,name);
if (new_name)
*new_name = np;
}
}
return(vp);
}
static int
Alloc_Many( struct Cache_List *cl, size_t key_size )
{
struct Cache_Item *ci;
size_t osz,asz;
int ni,rv=0;
char *cp,*np;
if ( cl->cl_max_items > 0 )
{
if (key_size < 1)
key_size = 40;
osz = CACHE_ITEM_SIZE + cl->cl_data_size + key_size + 1;
osz += (osz & 1); /* adjust object size to next word boundary */
asz = osz * cl->cl_max_items;
if ( (cp=malloc(asz)) )
{
memset( cp, '\0', asz );
/* now init each item and store on list */
ni = cl->cl_max_items;
while(ni--)
{
ci = (struct Cache_Item *)cp;
np = cp + CACHE_ITEM_SIZE + cl->cl_data_size;
Init_Item( ci, cl, np, key_size );
Add_Head( &cl->cl_Free, &ci->ci_S_Node );
cp += osz;
};
}
}
return(rv);
}
struct Cache_List *
New_Cache_List( const char *list_name, int max_items,
int flags, int defaults, int last_ditch )
{
struct Cache_List *cl;
char *new_name;
cl = Cache_Alloc_Lump( CACHE_LIST_SIZE, list_name, &new_name );
if (cl)
{
/* inititalise the various parts of this beast */
Init_Node( &cl->cl_Node, new_name, cl );
cl->cl_Name = new_name;
/* now generate the cl-flags */
cl->cl_flags = Cache_Flag_Gen( Cache_Flag_Gen( flags, defaults ), last_ditch );
Init_List( &cl->cl_Fields, (cl->cl_flags & CACHE_IGNORE_CASE)?LN_IGNORECASE:0 );
Init_List( &cl->cl_Free, 0 );
Init_List( &cl->cl_Free_cgi, 0 );
Init_List( &cl->cl_Build, 0 );
Init_List( &cl->cl_Missing, 0 );
Init_Full_List( &cl->cl_Items, NULL,
((cl->cl_flags & CACHE_IGNORE_CASE)?LN_IGNORECASE:0) );
cl->cl_max_field_num = 0;
cl->cl_max_items = max_items;
cl->cl_curr_items = 0;
cl->cl_cache_replaces = 0;
cl->cl_cache_hits = 0;
cl->cl_cache_misses = 0;
cl->cl_complete_misses = 0;
cl->cl_data_size = 0;
cl->cl_search_rules = NULL;
}
return(cl);
}
int
Cache_Build_Field_List( struct Cache_List *cl,
const char *format_str,
const char *field_names )
{
int rv=0;
struct Cache_Field *cf;
char *fnames = NULL;
char *fstr = NULL;
char *cp,*cp2;
void *ftok1,*ftok2;
static char fs_sep[]="%";
static char fn_sep[]=",";
int dsz=0; /* count up the space used by the data */
int psz; /* parameter size so far */
int ft; /* field type */
int flags; /* Various flags. eg Ignore case when matching? */
int align;
if ( (fstr = strdup(format_str))
&& (fnames = strdup(field_names))
)
{
/* Now parse and allocate Field structures */
cp = mpstrtok( fstr, &ftok1, fs_sep );
cp2 = mpstrtok( fnames, &ftok2, fn_sep );
while (cp && cp2)
{
/* grab any size specifier */
psz = 0;
ft = 0;
flags = 0;
align=0;
while(isdigit(*cp))
psz = psz * 10 + (*cp++ & 0x0f);
if (*cp=='i' || *cp=='I')
{
flags |= CF_FLG_IGNORECASE;
cp++;
}
switch(*cp)
{
case 's' :
ft = CF_STRING;
if (psz == 0)
psz = 40;
break;
case 'c' :
ft = CF_CHAR;
psz = sizeof(char);
flags &= ~CF_FLG_IGNORECASE;
align=MPLIB_ALIGN_SPC_CHAR;
break;
case 'd' :
case 'x' :
ft = CF_INT;
psz = sizeof(int);
flags &= ~CF_FLG_IGNORECASE;
align=MPLIB_ALIGN_SPC_INT;
break;
case 'f' :
ft = CF_DOUBLE;
psz = sizeof(double);
flags &= ~CF_FLG_IGNORECASE;
align=MPLIB_ALIGN_SPC_DOUBLE;
break;
case 'S' :
ft = CF_VARCHAR;
if (psz == 0)
psz = 40;
psz += sizeof(unsigned short);
break;
}
if ( ft
&& (cf = Cache_Alloc_Lump( CACHE_FIELD_SIZE, cp2, &cp ))
)
{
/* do something with this */
Init_Node( &cf->cf_Node, cp, cf );
cf->cf_Name = cp;
cf->cf_field_num = cl->cl_max_field_num++;
cf->cf_field_type = ft;
if (align && (dsz & (align-1)))
{
/* Adjust data position to ensure correct alignment */
dsz = (dsz + align -1) & ~(align-1);
}
cf->cf_f_offset = dsz;
cf->cf_field_size = psz;
cf->cf_field_flags = flags;
dsz += ( (psz + 1) & ~1); /* adjust size to next word boundary */
cl->cl_data_size = dsz;
Add_Tail( &cl->cl_Fields, &cf->cf_Node );
rv = 1;
}else
{
/* Something wrong, throw everything away and return error */
while ( (cf=Remove_Head_Item(&cl->cl_Fields)) )
free(cf);
rv = 0;
break;
}
cp = mpstrtok( NULL, &ftok1, fs_sep );
cp2 = mpstrtok( NULL, &ftok2, fn_sep );
};
(void) mpstrtok( NULL, &ftok1, NULL );
(void) mpstrtok( NULL, &ftok2, NULL );
}
if (fstr)
free(fstr);
if (fnames)
free(fnames);
return(rv);
}
int
Create_Cache_List( const char *list_name, int max_items,
int list_flags, size_t key_size,
const char *format_str, const char *field_names )
{
int rv=0;
struct Cache_List *cl;
Local_Cache_Init(&Master_List); /* just in case we haven't done it before */
#ifdef CACHE_DEBUG
if (cache_debug)
{
fprintf(stderr,"Create_Cache_List: <%s> <%d> <%s> <%s> ",
list_name,max_items,format_str,field_names);
fflush(stderr);
}
#endif
cl = (struct Cache_List *)Find_Item_By_Name( Master_List, list_name );
if ( cl == NULL
&& (cl=New_Cache_List( list_name, max_items,list_flags, default_flags, CACHE_DEFAULTS ))
)
{
rv = Cache_Build_Field_List( cl, format_str, field_names );
if (rv==1 && (cl->cl_flags & CACHE_PRE_ALLOCATE) && cl->cl_max_items > 0 )
{
/* time to pre-allocate the cache items */
Alloc_Many( cl, key_size );
}
if (rv==1)
Add_Head( Master_List, &cl->cl_Node );
}
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"%s\n",(rv)?"successful":"failed");
#endif
return(rv);
}
static struct Cache_Item *
New_Cache_Item( struct Cache_List *cl, char *item_name )
{
struct Cache_Item *ci;
char *new_name;
ci = Cache_Alloc_Lump( CACHE_ITEM_SIZE + cl->cl_data_size, item_name, &new_name );
if (ci)
{
/* inititalise the various parts of this beast */
Init_Item( ci, cl, new_name, strlen(new_name) );
}
return(ci);
}
static struct Cache_Item *
Obtain_Cache_Item( struct Cache_List *cl, const char *list_key,
List_t *L_List, int i_flags )
{
struct Cache_Item *ci=NULL;
/* anything on the free queue? */
if ( (i_flags & SEARCH_MISSING_LIST)
&& (cl->cl_search_rules==NULL)
&& list_key
)
ci = Find_Item_By_Name( &cl->cl_Missing, list_key );
if ( ci==NULL && (i_flags & SEARCH_FREE_LIST) )
ci = Remove_Head_Item( &cl->cl_Free );
if (ci)
{
/* adjust ? */
cl->cl_curr_items++;
if (list_key && strlen(list_key) > ci->ci_str_size )
{
cl->cl_curr_items--;
Add_Tail( &cl->cl_Free, &ci->ci_S_Node );
ci = NULL;
}else
{
if (list_key)
strcpy(ci->ci_Name, list_key);
memset(ci->ci_Item, '\0', ci->ci_data_size );
}
}
/* alloc new item or re-use */
if ( ci==NULL
&& L_List
&& (i_flags & SEARCH_LRU_LIST)
&& cl->cl_max_items
&& cl->cl_curr_items >= cl->cl_max_items
)
{
/* Re-Use last on LRU chain */
ci = Remove_Tail_Item( L_List );
if (ci)
{
cl->cl_cache_replaces++;
Remove_Node( &ci->ci_S_Node ); /* and remove from search chain */
if ( strlen(list_key) > ci->ci_str_size )
{
cl->cl_curr_items--;
Add_Tail( &cl->cl_Free, &ci->ci_S_Node );
ci = NULL;
}else
{
/* re-using, so adjust name */
if (list_key)
strcpy(ci->ci_Name, list_key);
memset(ci->ci_Item, '\0', ci->ci_data_size );
}
}
}
if (ci==NULL)
{
ci = New_Cache_Item( cl, list_key );
}
return(ci);
}
int
Add_Cache_Item( const char *list_name, const void *list_key, ... )
{
struct Cache_List *cl;
struct Cache_Item *ci;
struct Cache_Field *cf;
void *vp;
vchar_ptr vcp1,vcp2;
int rv=0;
va_list ap;
Local_Cache_Init(&Master_List); /* just in case we haven't done it before */
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"Add_Cache_Item: <%s> <%p> ", list_name, list_key );
#endif
cl = (struct Cache_List *)Find_Item_By_Name( Master_List, list_name );
if (cl)
{
if (list_key == CACHE_ONE_OF_ONE)
{
/* get an item and be ready to use it */
ci = Cache_Get_Item_From_Free( cl );
}else
if (list_key == CACHE_END_OF_MANY)
{
/* time to link all those created so far into the real list */
return( Cache_End_Of_Many( cl ) );
}
else if (list_key == CACHE_ONE_OF_MANY)
{
/* get an item and be ready to use it */
ci = Cache_Get_Item_From_Free( cl );
}else
{
ci = Find_Full_Item( &cl->cl_Items, list_key );
if (ci==NULL)
{
ci = Obtain_Cache_Item( cl, list_key,
&cl->cl_Items.fl_LRU_List,
(SEARCH_ALL_LISTS) );
if (ci)
{
/* If we got an item, it is hanging free so...
Put it on the relevant lists
*/
Add_Head( &cl->cl_Items.fl_LRU_List, &ci->ci_L_Node );
Add_Head( &cl->cl_Items.fl_Search_List, &ci->ci_S_Node );
cl->cl_curr_items++;
}
}
}
if (ci)
{
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"Added\n");
#endif
/* now insert the new values */
cf = (struct Cache_Field *)cl->cl_Fields.ln_Head.ln_Succ;
va_start(ap, list_key );
while (cf->cf_Node.ln_Succ)
{
switch( cf->cf_field_type )
{
case CF_INT :
/* fprintf(stderr,"Fetch int ");*/
*(int *)((char *)ci->ci_Item + cf->cf_f_offset) = (int)va_arg(ap, int );
/* fprintf(stderr,"- done\n");*/
break;
case CF_DOUBLE :
/* fprintf(stderr,"Fetch double ");*/
*(double *)((char *)ci->ci_Item + cf->cf_f_offset) = (double)va_arg(ap, double );
/* fprintf(stderr,"- done\n");*/
break;
case CF_CHAR :
/* fprintf(stderr,"Fetch char ");*/
*(char *)((char *)ci->ci_Item + cf->cf_f_offset) = (char)va_arg(ap, char );
/* fprintf(stderr,"- done\n");*/
break;
case CF_STRING :
/* fprintf(stderr,"Fetch string ");*/
vp = va_arg(ap, void* );
strcpy( (char *)ci->ci_Item + cf->cf_f_offset, (char *)vp );
/* fprintf(stderr,"- done\n");*/
break;
case CF_VARCHAR :
/* fprintf(stderr,"Fetch varchar ");*/
vp = va_arg(ap, vchar_ptr );
vcp1 = (vchar_ptr)((char *)ci->ci_Item + cf->cf_f_offset);
vcp2 = (vchar_ptr)vp;
vcp1->len = vcp2->len;
memcpy(vcp1->arr, vcp2->arr, vcp2->len );
/* fprintf(stderr,"- done\n");*/
break;
}
cf = (struct Cache_Field *)cf->cf_Node.ln_Succ;
rv=1;
};
va_end(ap);
if (list_key == CACHE_ONE_OF_ONE)
{
/* get an item and be ready to use it */
rv = Cache_End_Of_Many( cl );
}
/*hex_dump(stderr, ci->ci_Item, cl->cl_data_size );*/
}
#ifdef CACHE_DEBUG
else
if (cache_debug)
fprintf(stderr,"not added\n");
#endif
}
#ifdef CACHE_DEBUG
else
if (cache_debug)
fprintf(stderr,"List not found\n");
#endif
return(rv);
}
int
Cache_Complete_Miss( const char *list_name, const void* list_key )
{
struct Cache_List *cl;
struct Cache_Item *ci;
Node_t *node;
Local_Cache_Init(&Master_List); /* just in case we haven't done it before */
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"Cache_Complete_Miss: ");
#endif
cl = (struct Cache_List *)Find_Item_By_Name( Master_List, list_name );
if (cl)
{
cl->cl_complete_misses ++;
if ( cl->cl_search_rules != NULL )
{
Range_Complete_Miss( cl, list_key );
}else
{
ci = Find_Item_By_Name( &cl->cl_Missing, list_key );
if (ci)
{
node = Find_Node_By_Item( &cl->cl_Missing, ci );
Remove_Node( node );
Add_Head( &cl->cl_Missing, node );
}
else
{
/* Allocate a node and add it to the missing chain */
ci = Remove_Head_Item( &cl->cl_Free );
if (ci==NULL)
ci = Remove_Head_Item( &cl->cl_Missing );
if (ci==NULL)
{
/* allocate one ? */
}
if (ci)
{
/* put on complete miss list */
Add_Head( &cl->cl_Missing, &ci->ci_S_Node );
}
}
}
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"OK\n");
#endif
}
#ifdef CACHE_DEBUG
else
if (cache_debug)
fprintf(stderr,"Failed\n");
#endif
return(1);
}
int
Cache_Flush( const char *list_name )
{
struct Cache_List *cl;
struct Cache_Item *ci;
int rv=0;
Local_Cache_Init(&Master_List); /* just in case we haven't done it before */
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"Cache_Flush: ");
#endif
cl = (struct Cache_List *)Find_Item_By_Name( Master_List, list_name );
if (cl && (cl->cl_flags & CACHE_FLUSHABLE) )
{
if ( cl->cl_search_rules != NULL )
{
rv = Range_Flush( cl );
}else
{
while ( (ci = Remove_Head_Item( &cl->cl_Items.fl_Search_List )) )
{
Remove_Node( &ci->ci_L_Node );
Add_Tail( &cl->cl_Free, &ci->ci_S_Node );
};
while( (ci = Remove_Head_Item( &cl->cl_Missing )) )
{
Add_Tail( &cl->cl_Free, &ci->ci_S_Node );
}
cl->cl_curr_items = 0;
rv = 1;
}
}
#ifdef CACHE_DEBUG
else
if (cache_debug)
fprintf(stderr,"Failed\n");
#endif
return(rv);
}
/* -- End of File -- */

View file

@ -1,739 +0,0 @@
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <memory.h>
#include <time.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/data_align.h>
#include <mplib1/dl_list.h>
#include <mplib1/dl_lru.h>
#include "../include/dl_lru_private.h"
#include <mplib1/stricmp.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#ifndef NULL
#define NULL ((void *)0)
#endif
struct vchar_gen
{
unsigned short len;
unsigned char arr[1];
};
typedef struct vchar_gen *vchar_ptr;
struct cps
{
struct Cache_List *cl;
int nrl;
struct full_search_rule *srp;
void **sv;
struct Cache_Item *ci;
struct Cache_Item *si;
struct Cache_Item *rv;
};
/* ------------------------------------------------------------------
Some static variables
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */
static int
vcharcmp( vchar_ptr vp1, vchar_ptr vp2 )
{
int t,rv=0;
unsigned char *cp;
static char estr[]="\0";
t=vp1->len;
if (vp2->len != t)
{
if (vp2->len < t)
{
t=vp2->len;
cp=vp1->arr + t;
}else
{
cp=vp2->arr + t;
}
rv = memcmp( vp1->arr, vp2->arr, (size_t)t );
if (rv==0)
{
/* Check remainder */
rv=memcmp( cp, estr, 1 );
}
}else
{
/* same length, may be equal, have to check */
rv = memcmp( vp1->arr, vp2->arr, (size_t)t );
}
return(rv);
}
static int
vcharcasecmp( vchar_ptr vp1, vchar_ptr vp2 )
{
return(0);
}
static int fail( void *vp1, void *vp2 ) { return(0); }
#define COMP_FUNC(a,b,c) static int a##_##b (void *p1, void *p2){return( *(a *)p1 c *(a *)p2 ); }
#define COMP_FFUNC(a,b,c,d,e) static int a##_##b (void *p1, void *p2){return( d ( p1, p2 ) c e ); }
COMP_FUNC( int, eq, == )
COMP_FUNC( int, gt, > )
COMP_FUNC( int, ge, >= )
COMP_FUNC( int, lt, < )
COMP_FUNC( int, le, <= )
COMP_FUNC( int, ne, != )
COMP_FUNC( double, eq, == )
COMP_FUNC( double, gt, > )
COMP_FUNC( double, ge, >= )
COMP_FUNC( double, lt, < )
COMP_FUNC( double, le, <= )
COMP_FUNC( double, ne, != )
COMP_FUNC( char, eq, == )
COMP_FUNC( char, gt, > )
COMP_FUNC( char, ge, >= )
COMP_FUNC( char, lt, < )
COMP_FUNC( char, le, <= )
COMP_FUNC( char, ne, != )
COMP_FFUNC( string, eq, ==, strcmp, 0 )
COMP_FFUNC( string, gt, >, strcmp, 0 )
COMP_FFUNC( string, ge, >=, strcmp, 0 )
COMP_FFUNC( string, lt, <, strcmp, 0 )
COMP_FFUNC( string, le, <=, strcmp, 0 )
COMP_FFUNC( string, ne, !=, strcmp, 0 )
COMP_FFUNC( casestring, eq, ==, stricmp, 0 )
COMP_FFUNC( casestring, gt, >, stricmp, 0 )
COMP_FFUNC( casestring, ge, >=, stricmp, 0 )
COMP_FFUNC( casestring, lt, <, stricmp, 0 )
COMP_FFUNC( casestring, le, <=, stricmp, 0 )
COMP_FFUNC( casestring, ne, !=, stricmp, 0 )
COMP_FFUNC( varchar, eq, ==, vcharcmp, 0 )
COMP_FFUNC( varchar, gt, >, vcharcmp, 0 )
COMP_FFUNC( varchar, ge, >=, vcharcmp, 0 )
COMP_FFUNC( varchar, lt, <, vcharcmp, 0 )
COMP_FFUNC( varchar, le, <=, vcharcmp, 0 )
COMP_FFUNC( varchar, ne, !=, vcharcmp, 0 )
COMP_FFUNC( casevarchar, eq, ==, vcharcasecmp, 0 )
COMP_FFUNC( casevarchar, gt, >, vcharcasecmp, 0 )
COMP_FFUNC( casevarchar, ge, >=, vcharcasecmp, 0 )
COMP_FFUNC( casevarchar, lt, <, vcharcasecmp, 0 )
COMP_FFUNC( casevarchar, le, <=, vcharcasecmp, 0 )
COMP_FFUNC( casevarchar, ne, !=, vcharcasecmp, 0 )
/* Sorry about putting a data structure here, but I didn't want to
have to type in all the function definitions again
*/
static (* comp_funcs[NUM_SEARCH_COMPS][CF_NUM_FIELD_TYPES*2])(void *,void *) =
{
{ fail, int_eq, double_eq, char_eq, string_eq, varchar_eq,
fail, int_eq, double_eq, char_eq, casestring_eq, casevarchar_eq },
{ fail, int_ge, double_ge, char_ge, string_ge, varchar_ge,
fail, int_ge, double_ge, char_ge, casestring_ge, casevarchar_ge },
{ fail, int_gt, double_gt, char_gt, string_gt, varchar_gt,
fail, int_gt, double_gt, char_gt, casestring_gt, casevarchar_gt },
{ fail, int_le, double_le, char_le, string_le, varchar_le,
fail, int_le, double_le, char_le, casestring_le, casevarchar_le },
{ fail, int_lt, double_lt, char_lt, string_lt, varchar_lt,
fail, int_lt, double_lt, char_lt, casestring_lt, casevarchar_lt },
{ fail, int_ne, double_ne, char_ne, string_ne, varchar_ne,
fail, int_ne, double_ne, char_ne, casestring_ne, casevarchar_ne }
};
static int
multi_match( struct Cache_Item *ci,
struct cps *cpsp )
{
struct full_search_rule *srp;
int nrl;
int rv=1;
nrl = cpsp->nrl;
srp = cpsp->srp;
/* fprintf(stderr,"multi_match: entry\n");*/
while (nrl && rv)
{
/* fprintf(stderr,"matching: multi_match: %s\n", search_rule_strs[srp->comparison_method] );*/
/* hex_dump( stderr, (char *)(ci->ci_Item) + srp->cf->cf_f_offset, srp->cf->cf_field_size );*/
/* hex_dump( stderr, (char *)(cpsp->si->ci_Item) + srp->cf->cf_f_offset, srp->cf->cf_field_size );*/
rv = (* srp->cmpfunc)( (char *)(ci->ci_Item) + srp->cf->cf_f_offset,
(char *)(cpsp->si->ci_Item) + srp->cf->cf_f_offset
);
nrl--;
srp++;
};
if (rv)
cpsp->rv = ci;
return(rv);
}
static int
Find_This_Item( struct Cache_Item *ci,
struct cps *cpsp )
{
int rv=0;
/* fprintf(stderr,"matching: Find_This_Item\n");*/
/* hex_dump( stderr, (char *)(ci->ci_Item) + cpsp->srp->cf->cf_f_offset, cpsp->srp->cf->cf_field_size );*/
/* hex_dump( stderr, (char *)(cpsp->si->ci_Item) + cpsp->srp->cf->cf_f_offset, cpsp->srp->cf->cf_field_size );*/
rv = (* cpsp->srp->cmpfunc)( (char *)(ci->ci_Item) + cpsp->srp->cf->cf_f_offset,
(char *)(cpsp->si->ci_Item) + cpsp->srp->cf->cf_f_offset
);
if (rv)
cpsp->rv = ci;
return(rv);
}
static int
Init_This_Item( struct Cache_Item *ci,
size_t data_size,
void *data_item,
int expire_time
)
{
Init_Node( &ci->ci_S_Node, NULL, ci );
Init_Node( &ci->ci_L_Node, NULL, ci );
ci->ci_data_size = data_size;
ci->ci_str_size = 0;
ci->ci_Item = data_item;
/*fprintf(stderr,"Init Item: %p,%p\n", ci, ci->ci_Item );*/
ci->ci_Name = NULL;
ci->ci_expire_time = (expire_time)
? time(NULL) + expire_time
: 0;
return(1);
}
static struct Cache_Group_Item *
New_CGI( struct Cache_List *cl, size_t data_size )
{
struct Cache_Group_Item *cgi;
if ( (cgi = Remove_Head_Item( &cl->cl_Free_cgi )) ==NULL )
{
cgi = malloc( sizeof(struct Cache_Group_Item) + data_size );
}
return(cgi);
}
static struct Cache_Group_Item *
Find_CGI( struct Cache_List *cl,
struct Full_List *flp,
struct full_search_rule *fsrp,
struct Cache_Item *ci,
size_t data_size,
int expire_time )
{
struct cps my_cps;
struct Cache_Group_Item *cgi;
my_cps.ci = NULL;
my_cps.srp = fsrp;
my_cps.rv = NULL;
my_cps.si = ci;
/*fprintf(stderr,"About to search %p for %p - First = %p\n", flp, ci, flp->fl_Search_List.ln_Head.ln_Succ );*/
Walk_List2( &flp->fl_Search_List, (Walk_List2_t)Find_This_Item, &my_cps );
if (my_cps.rv==NULL)
{
/* Doesn't exist. allocate this one */
cgi = New_CGI( cl, data_size );
if (cgi!=NULL)
{
/* init this cgi */
Init_This_Item( &cgi->cgi_Item, data_size,
cgi + 1, expire_time );
Init_Full_List( &cgi->cgi_Items, NULL, 0 );
/*hex_dump( stderr, ci->ci_Item, data_size );*/
memcpy( cgi+1, ci->ci_Item, data_size );
Add_Head( &flp->fl_Search_List, &cgi->cgi_Item.ci_S_Node );
Add_Head( &flp->fl_LRU_List, &cgi->cgi_Item.ci_L_Node );
cgi->cgi_Flags = 0;
}
}else
{
cgi = (struct Cache_Group_Item *)my_cps.rv;
/*fprintf(stderr, "cgi already exists\n");*/
}
return(cgi);
}
static struct Cache_Item *
Build_Search_Item( struct Cache_List *cl, void **keys )
{
struct Cache_Item *sci;
struct full_search_rule *srp;
int nrl;
char *tp;
sci = malloc( CACHE_ITEM_SIZE + cl->cl_data_size );
/*fprintf(stderr,"search item: %p %d %d\n", sci, CACHE_ITEM_SIZE, cl->cl_data_size );*/
if (sci)
{
/* copy the various fields */
Init_This_Item( sci, cl->cl_data_size, sci + 1, cl->cl_expire_time );
srp = cl->cl_search_rules;
nrl = cl->cl_num_search_rules;
tp = (char *)(sci +1);
while(nrl--)
{
/* copy each field in turn */
memcpy( tp + srp->cf->cf_f_offset, *keys++, srp->cf->cf_field_size );
/*hex_dump( stderr, tp + srp->cf->cf_f_offset, srp->cf->cf_field_size );*/
srp++;
};
}
return(sci);
}
struct Cache_Item *
Cache_Find_Requested_Item( struct Cache_List *cl, const void *keys, int *rv )
{
char *single_key;
struct Cache_Item *ci;
struct Cache_Item *sci;
struct Cache_Group_Item *cgi;
int nrl;
struct full_search_rule *srp;
struct Full_List *flp;
*rv = CACHE_MISSED;
if (cl->cl_num_search_rules == 0)
{
/* Ah, an old style enquiry. */
single_key = keys;
ci = (struct Cache_Item *)Find_Full_Item( &cl->cl_Items, single_key );
*rv = (ci) ? CACHE_FOUND_ITEM : CACHE_MISSED;
}else
{
sci = Build_Search_Item( cl, (void **)keys );
if (sci==NULL)
return(NULL);
/* time to search done multiple lists */
nrl = cl->cl_num_search_rules;
srp = cl->cl_search_rules;
flp = &cl->cl_Items;
ci = NULL;
/* Now, we walk each list in turn, checking each equality item */
do
{
cgi = Find_CGI( cl, flp, srp, sci,
cl->cl_data_size, cl->cl_expire_time );
nrl--;
srp++;
flp = &cgi->cgi_Items;
}
while ( nrl
&& srp->comparison_method == SEARCH_EQ
&& cgi
);
if (cgi && (nrl==0 || srp->comparison_method != SEARCH_EQ) )
{
if (cgi->cgi_Flags & CGI_COMPLETE_MISS)
{
/*fprintf(stderr,"cgi (%p) marked as complete miss\n",cgi);*/
*rv = CACHE_COMPLETE_MISS;
}
else
if (nrl==0)
{
ci = Remove_Head_Item( &cgi->cgi_Items.fl_Search_List );
Add_Head( &cgi->cgi_Items.fl_Search_List, &ci->ci_S_Node );
*rv = CACHE_FOUND_ITEM;
}
else
{
/* Time to do partial check */
struct cps my_cps;
my_cps.nrl = nrl;
my_cps.srp = srp;
my_cps.si = sci;
my_cps.rv = NULL;
if (Walk_List2( &flp->fl_Search_List, (Walk_List2_t)multi_match, &my_cps ))
{
*rv = CACHE_FOUND_ITEM;
ci = my_cps.rv;
}else
{
ci = Remove_Head_Item( &flp->fl_Search_List );
if (ci)
Add_Head( &flp->fl_Search_List, &ci->ci_S_Node );
*rv = ((cl->cl_flags & CACHE_INSERT_MANY) && ci )
? CACHE_COMPLETE_MISS : CACHE_MISSED;
ci = NULL;
}
}
}
/*else fprintf(stderr,"cannot find cgi before end of search\n");*/
/*fprintf(stderr,"Freeing: %p\n", sci );*/
free(sci);
}
return(ci);
}
static int
Build_Search_Rules( struct Cache_List *cl, struct search_rule *srulep )
{
int rv=0;
/* struct Cache_Field *cf;*/
struct search_rule *trulep;
struct full_search_rule *fsrp,*tfsrp;
int num_rules=0,toff;
#ifdef CACHE_DEBUG
/* fprintf(stderr, "Build_Search_Rules: Entry\n" );*/
#endif
trulep = srulep;
while (trulep->field_name)
{
trulep++;
num_rules++;
};
#ifdef CACHE_DEBUG
/* fprintf(stderr, "Build_Search_Rules: %d number of rules\n", num_rules );*/
#endif
/* Now allocate the correct number of full rules */
fsrp = malloc( num_rules * sizeof(struct full_search_rule) );
if (fsrp)
{
#ifdef CACHE_DEBUG
/* fprintf(stderr, "Build_Search_Rules: rules: <%p>\n", fsrp );*/
#endif
tfsrp = fsrp;
/* Now initialise each rule */
while(srulep->field_name)
{
tfsrp->cf = Find_Item_By_Name( &cl->cl_Fields, srulep->field_name );
if (tfsrp->cf == NULL)
{
free( fsrp );
return(0);
}
#ifdef CACHE_DEBUG
/* fprintf(stderr, "Build_Search_Rules: <%s> <%p> <%d>\n",*/
/* srulep->field_name, tfsrp->cf, srulep->comparison_method );*/
#endif
tfsrp->comparison_method = srulep->comparison_method;
if ( tfsrp->comparison_method < 0
|| tfsrp->comparison_method >= NUM_SEARCH_COMPS
)
{
/* bad vbalue */
free( fsrp );
return(0);
}
toff = (tfsrp->cf->cf_field_flags & CF_FLG_IGNORECASE) ? CF_NUM_FIELD_TYPES:0;
tfsrp->cmpfunc = comp_funcs[srulep->comparison_method]
[tfsrp->cf->cf_field_type + toff];
srulep++;
tfsrp++;
};
cl->cl_search_rules = fsrp;
cl->cl_num_search_rules = num_rules;
rv = 1;
}
#ifdef CACHE_DEBUG
/* fprintf(stderr, "Build_Search_Rules: returns %d\n", rv );*/
#endif
return(rv);
}
int
Create_Range_Cache( const char *list_name, int max_items,
int list_flags, struct search_rule *srulep,
const char *format_str, const char *field_names )
{
int rv=0;
struct Cache_List *cl;
List_t *Master_List;
Master_List = Get_Cache_Master_List();
cl = (struct Cache_List *)Find_Item_By_Name( Master_List, list_name );
if ( cl == NULL
&& (cl=New_Cache_List( list_name, max_items, list_flags,
CACHE_RANGE_DEFAULTS, CACHE_RANGE_DEFAULTS ))
)
{
/*fprintf(stderr, "flags: %x %x %x\n", cl->cl_flags,*/
/* list_flags, CACHE_RANGE_DEFAULTS );*/
/* Build the field list */
rv = Cache_Build_Field_List( cl, format_str, field_names );
/* Now parse the search rules */
if (rv==1)
rv = Build_Search_Rules( cl, srulep );
if (rv==1)
Add_Head( Master_List, &cl->cl_Node );
}
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr,"%s\n",(rv)?"successfull":"failed");
#endif
return(rv);
}
struct Cache_Item *
Cache_Get_Item_From_Free( struct Cache_List *cl )
{
struct Cache_Item *ci;
ci = Remove_Head_Item( &cl->cl_Free );
if ( ci == NULL )
{
/* Need a new one so allocate */
ci = malloc( CACHE_ITEM_SIZE + cl->cl_data_size );
#ifdef CACHE_DEBUG
fprintf(stderr, "malloc item %p (from %d & %d)\n", ci, CACHE_ITEM_SIZE, cl->cl_data_size );
#endif
Init_This_Item( ci, cl->cl_data_size, ci + 1, cl->cl_expire_time );
#ifdef CACHE_DEBUG
fprintf(stderr, "inited\n" );
#endif
}
if (ci)
{
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr, "About to add to build list\n" );
#endif
/* clear this one out */
Add_Tail( &cl->cl_Build, &ci->ci_S_Node );
#ifdef CACHE_DEBUG
if (cache_debug)
fprintf(stderr, "added to build list\n" );
#endif
}
return(ci);
}
int
Cache_End_Of_Many( struct Cache_List *cl )
{
struct Cache_Item *ci;
/* struct Cache_Field *cf;*/
struct Cache_Group_Item *cgi;
struct full_search_rule *fsrp;
struct Full_List *flp;
int nrl;
/*fprintf(stderr,"End_Of_Many: starting\n");*/
ci = Remove_Head_Item( &cl->cl_Build );
if (ci==NULL)
return(0);
Add_Head( &cl->cl_Build, &ci->ci_S_Node );
/*fprintf(stderr," There are items to add\n");*/
while( (ci = Remove_Head_Item( &cl->cl_Build )) )
{
flp = &cl->cl_Items;
fsrp = cl->cl_search_rules;
nrl = cl->cl_num_search_rules;
while ( nrl
&& fsrp->comparison_method == SEARCH_EQ
)
{
cgi = Find_CGI( cl, flp, fsrp, ci, cl->cl_data_size, cl->cl_expire_time );
/*fprintf(stderr,"Found cgi %p\n", cgi );*/
if (cgi==NULL)
{
/* big problem. Can't allocate cgi for adding this list, so
return items on build list to free list and return failure
*/
while( (ci = Remove_Head_Item( &cl->cl_Build )) )
{
Add_Tail( &cl->cl_Free, &ci->ci_S_Node );
};
return(0);
}
flp = &cgi->cgi_Items;
cgi->cgi_Flags &= ~CGI_COMPLETE_MISS;
nrl--;
fsrp++;
};
/*fprintf(stderr,"About to add items to CGI %p\n", cgi );*/
/* We now have the cgi which will take the current item from the build list */
cgi->cgi_Flags &= ~CGI_COMPLETE_MISS;
cl->cl_curr_items++;
Add_Tail( &cgi->cgi_Items.fl_Search_List, &ci->ci_S_Node );
Add_Head( &cgi->cgi_Items.fl_LRU_List, &ci->ci_L_Node );
};
return( 1 );
}
int
Range_Complete_Miss( struct Cache_List *cl, const void *keys )
{
struct Cache_Item *ci;
struct Cache_Item *sci;
struct Cache_Group_Item *cgi;
int nrl;
struct full_search_rule *srp;
struct Full_List *flp;
sci = Build_Search_Item( cl, (void **)keys );
if (sci==NULL)
return(0);
/* time to search done multiple lists */
nrl = cl->cl_num_search_rules;
srp = cl->cl_search_rules;
flp = &cl->cl_Items;
ci = NULL;
/* Now, we walk each list in turn, checking each equality item */
do
{
cgi = Find_CGI( cl, flp, srp, sci,
cl->cl_data_size, cl->cl_expire_time );
nrl--;
srp++;
flp = &cgi->cgi_Items;
}
while ( nrl
&& srp->comparison_method == SEARCH_EQ
&& cgi
);
if (cgi && (nrl==0 || srp->comparison_method != SEARCH_EQ) )
cgi->cgi_Flags |= CGI_COMPLETE_MISS;
return(1);
}
static void
Flush_Items( struct Cache_Item *ci,
struct Cache_List *cl )
{
Remove_Node( &ci->ci_S_Node );
Remove_Node( &ci->ci_L_Node );
Add_Tail( &cl->cl_Free, &ci->ci_S_Node );
return;
}
static void
Flush_CGI( struct Cache_Group_Item *cgi,
struct cps *cpsp )
{
struct cps my_cps;
struct full_search_rule *srp;
srp = cpsp->srp;
memcpy( &my_cps, cpsp, sizeof(struct cps) );
srp++;
my_cps.nrl--;
my_cps.srp = srp;
if (my_cps.nrl==0 || srp->comparison_method != SEARCH_EQ)
{
/* End of the line */
Walk_List( &cgi->cgi_Items.fl_Search_List,
(Walk_List_t)Flush_Items, cpsp->cl );
}else
{
Walk_List( &cgi->cgi_Items.fl_Search_List,
(Walk_List_t)Flush_CGI, &my_cps );
}
/* whichever varient it is, this cgi is now redundant */
Remove_Node( &cgi->cgi_Item.ci_S_Node );
Remove_Node( &cgi->cgi_Item.ci_L_Node );
Add_Tail( &cpsp->cl->cl_Free_cgi, &cgi->cgi_Item.ci_S_Node );
return;
}
int
Range_Flush( struct Cache_List *cl )
{
struct Cache_Item *ci;
int nrl;
struct full_search_rule *srp;
struct Full_List *flp;
struct cps my_cps;
/* time to search done multiple lists */
nrl = cl->cl_num_search_rules;
srp = cl->cl_search_rules;
flp = &cl->cl_Items;
ci = NULL;
if (srp->comparison_method == SEARCH_EQ)
{
/* Time to walk each cgi list until we meet real items */
my_cps.cl = cl;
my_cps.nrl = nrl;
my_cps.srp = srp;
Walk_List( &flp->fl_Search_List, (Walk_List_t)Flush_CGI, &my_cps );
}else
{
Walk_List( &flp->fl_Search_List, (Walk_List_t)Flush_Items, cl );
}
return(1);
}
/* -- End of File -- */

View file

@ -1,285 +0,0 @@
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <memory.h>
#include <time.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/dl_list.h>
#include <mplib1/dl_lru.h>
#include "../include/dl_lru_private.h"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#ifndef NULL
#define NULL ((void *)0)
#endif
struct vchar_gen
{
unsigned short len;
unsigned char arr[1];
};
typedef struct vchar_gen *vchar_ptr;
struct cache_stat
{
struct Cache_List *cl;
struct Cache_Group_Item *cgi;
struct Cache_Item *ci;
struct Cache_Field *cf;
int num_search_rules;
struct full_search_rule *fsrp;
FILE *fp;
};
/* ------------------------------------------------------------------
Some static variables
------------------------------------------------------------------ */
static const char *search_rule_strs[]=
{ "==", ">=", ">", "<=", "<", "!=" };
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */
static void
Print_Field( void *vp1, void *vp2 )
{
struct Cache_Field *cf;
struct cache_stat *cs;
char *cp;
vchar_ptr vp;
char cbuf[240];
cf = vp1;
cs = vp2;
cp = (char *)(cs->ci->ci_Item) + cf->cf_f_offset;
memset( cbuf, '\0', 240 );
switch(cf->cf_field_type)
{
case CF_INT :
fprintf( cs->fp, " %d", *((int *)cp) );
break;
case CF_DOUBLE :
fprintf( cs->fp, " %f", *((double *)cp) );
break;
case CF_CHAR :
fprintf( cs->fp, " %c", *cp );
break;
case CF_STRING :
fprintf( cs->fp, " %*.*s", cf->cf_field_size,
(int)cf->cf_field_size, cp );
break;
case CF_VARCHAR :
vp = (vchar_ptr)cp;
fprintf( cs->fp, " <%d>", vp->len );
memcpy(cbuf,&vp->arr[0],vp->len);
cbuf[vp->len]='\0';
fprintf( cs->fp, " %s", cbuf );
break;
}
return;
}
static void
Print_CI( struct Cache_Item *ci,
struct cache_stat *cs )
{
cs->ci = ci;
if (ci->ci_Name)
fprintf( cs->fp, " Item: %s\n", ci->ci_Name );
Walk_List( &cs->cl->cl_Fields, (Walk_List_t)Print_Field, cs );
fprintf( cs->fp, "\n" );
return;
}
static void
Print_Rules( FILE *fp, struct full_search_rule *frsp, int num_rules )
{
fprintf( fp, "Search Rules:\n" );
while (num_rules--)
{
fprintf( fp, " : <%s> %s\n",
frsp->cf->cf_Name, search_rule_strs[frsp->comparison_method] );
frsp++;
};
return;
}
static void
Print_CGI_Header( FILE *fp, struct full_search_rule *frsp, int num_rules )
{
if (frsp->comparison_method== SEARCH_EQ)
{
fprintf( fp, " CGI List: <%s> %s\n",
frsp->cf->cf_Name, search_rule_strs[frsp->comparison_method] );
}else
{
while (num_rules--)
{
fprintf( fp, " CGI List: <%s> %s\n",
frsp->cf->cf_Name, search_rule_strs[frsp->comparison_method] );
frsp++;
};
}
return;
}
static void
Print_CGI( struct Cache_Group_Item *cgi,
struct cache_stat *cs )
{
cs->cgi = cgi;
fprintf( cs->fp, " CGI: %x %d ", cgi->cgi_Flags, cs->num_search_rules );
cs->ci = &cgi->cgi_Item;
Print_Field( cs->fsrp->cf, cs );
fprintf( cs->fp, "\n" );
cs->num_search_rules--;
cs->fsrp++;
if (cs->num_search_rules==0 || cs->fsrp->comparison_method != SEARCH_EQ)
Walk_List( &cgi->cgi_Items.fl_Search_List, (Walk_List_t)Print_CI, cs );
else
{
Print_CGI_Header( cs->fp, cs->fsrp, cs->num_search_rules );
Walk_List( &cgi->cgi_Items.fl_Search_List, (Walk_List_t)Print_CGI, cs );
}
cs->num_search_rules++;
cs->fsrp--;
return;
}
static void
Print_Fields( struct Cache_Field *cf,
FILE *fp )
{
fprintf( fp, " <%-40.40s> <%d> <%d> <%d> <%d>\n",
cf->cf_Name, cf->cf_field_type,
cf->cf_field_size, cf->cf_field_num,
cf->cf_f_offset );
return;
}
static void
Cache_List_Stat( FILE *fp, struct Cache_List *cl, int contents )
{
struct cache_stat my_stat;
fprintf( fp, "List: \"%s\"\n\n", cl->cl_Name );
fprintf( fp, " Max: %8d\tCurr: %8d\n", cl->cl_max_items, cl->cl_curr_items );
fprintf( fp, " Size: %8d\tFlags: %8d\n", cl->cl_data_size, cl->cl_flags );
fprintf( fp, " Mode: %s\n", (cl->cl_flags & CACHE_CACHE_ON)?"Caching":"Statistics");
fprintf( fp, " Case: %s\n", (cl->cl_flags & CACHE_IGNORE_CASE)?"Ignore":"Check");
fprintf( fp, " Alloc: %s\n", (cl->cl_flags & CACHE_DEMAND_ALLOC)?"Demand":"Pre-Allocate");
fprintf( fp, " Flush: %s\n", (cl->cl_flags & CACHE_FLUSHABLE)?"Flushable":"NOT Flushable");
if (cl->cl_search_rules)
fprintf( fp, " Insert: %s\n", (cl->cl_flags & CACHE_INSERT_MANY)?"Many":"Single");
fprintf( fp, " Hit: %8d\tMiss: %8d\n", cl->cl_cache_hits, cl->cl_cache_misses );
fprintf( fp, " Rep: %8d\tFail: %8d\n", cl->cl_cache_replaces, cl->cl_complete_misses );
fprintf( fp, " Fields\n" );
Walk_List( &cl->cl_Fields, (Walk_List_t)Print_Fields, fp );
if ( contents )
{
if ( cl->cl_search_rules==NULL
|| cl->cl_search_rules->comparison_method!=SEARCH_EQ
)
{
my_stat.cl = cl;
my_stat.fp = fp;
Walk_List( &cl->cl_Items.fl_Search_List,
(Walk_List_t)Print_CI,
&my_stat );
}else
{
my_stat.cl = cl;
my_stat.fp = fp;
my_stat.fsrp = cl->cl_search_rules;
my_stat.num_search_rules = cl->cl_num_search_rules;
Print_Rules( fp, my_stat.fsrp, my_stat.num_search_rules );
Print_CGI_Header( fp, my_stat.fsrp, my_stat.num_search_rules );
Walk_List( &cl->cl_Items.fl_Search_List,
(Walk_List_t)Print_CGI,
&my_stat );
}
}
fprintf( fp, "\n" );
return;
}
int
Cache_Stats( FILE *fp, const char *list_name, int contents )
{
struct Cache_List *cl;
List_t *Master_List;
Master_List = Get_Cache_Master_List();
if (list_name)
{
cl = (struct Cache_List *)Find_Item_By_Name( Master_List, list_name );
if (cl)
Cache_List_Stat( fp, cl, contents );
}
else
{
cl = (struct Cache_List *)Master_List->ln_Head.ln_Succ;
while (cl->cl_Node.ln_Succ)
{
Cache_List_Stat( fp, cl, contents );
cl = (struct Cache_List *)cl->cl_Node.ln_Succ;
};
}
return(0);
}
/* -- End of File -- */

View file

@ -10,26 +10,9 @@
*
* And now adapted for Amiga style double linked lists.
*
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* $Source$
* $Author$
* $Date$
* $Revision$
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -10,26 +10,9 @@
*
* And now adapted for Amiga style double linked lists.
*
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* $Source$
* $Author$
* $Date$
* $Revision$
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -3,33 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* System :
* Subsystem :
* Module :
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -54,7 +30,7 @@ static char *find_eos( char *where )
}
int
do_hex_dump( FILE *fp, off_t curoff, const char *where, int how_much )
do_hex_dump( FILE *fp, off_t curoff, const char *where, ssize_t how_much )
{
char linebuf[80];
char charbuf[20];
@ -99,7 +75,7 @@ do_hex_dump( FILE *fp, off_t curoff, const char *where, int how_much )
}
int
hex_dump( FILE *fp, const char *where, int how_much )
hex_dump( FILE *fp, const char *where, ssize_t how_much )
{
return(do_hex_dump( fp, 0, where, how_much ));
}

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,24 +3,6 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* *
* $Source$
* $Author$
* $Date$
* $Revision$
* *
*******************************************************************************
* *
* $Log$
*
*******************************************************************************
*/
/* ------------------------------------------------------------------
@ -36,7 +18,6 @@
#include <string.h>
#include <stdarg.h>
#include <memory.h>
#include <malloc.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/timestamp.h>

View file

@ -3,23 +3,6 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* $Log$
*
*******************************************************************************
*/
@ -36,7 +19,6 @@
#include <string.h>
#include <stdarg.h>
#include <memory.h>
#include <malloc.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/timestamp.h>

View file

@ -3,23 +3,6 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* *
* $Source$
* $Author$
* $Date$
* $Revision$
* *
*******************************************************************************
* *
* $Log$
*
*******************************************************************************
*/
@ -28,6 +11,7 @@
------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
@ -35,7 +19,6 @@
#include <time.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/timestamp.h>

View file

@ -3,34 +3,9 @@
* Copyright (c) 1994 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* System :
* Subsystem :
* Module :
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -108,13 +83,12 @@ check_signalling( void )
static void
allow_thisint( int this_sig, struct sigaction *sigactp )
{
int rv;
struct sigaction prep_sigaction;
rv = sigaction( this_sig, NULL, sigactp );
(void)sigaction( this_sig, NULL, sigactp );
memcpy( &prep_sigaction, sigactp, sizeof(struct sigaction) );
prep_sigaction.sa_flags &= ~SA_RESTART;
rv = sigaction( this_sig, &prep_sigaction, NULL );
(void)sigaction( this_sig, &prep_sigaction, NULL );
return;
}

View file

@ -3,34 +3,9 @@
* Copyright (c) 1995 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* System :
* Subsystem :
* Module :
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -8,26 +8,9 @@
*
* Adapted into toolkit by Martin Poole mpoole@cix.compulink.co.uk
*
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* $Source$
* $Author$
* $Date$
* $Revision$
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
@ -223,4 +206,39 @@ lmsort( struct lmsortp * start, int (*compar)(const void *, const void *) )
}
struct lmsortp *
lmsort_init( void* base, size_t nel, size_t width, struct lmsortp *dp )
{
struct lmsortp *dp2;
int i;
if (dp==NULL)
dp = malloc( nel * sizeof(struct lmsortp) );
if (dp)
{
/* we can only sort if there is enough memory */
dp2=dp;
for (i=0; i<nel; i++)
{
dp2->next = dp2+1;
dp2->dp = base;
dp2++;
base = (void *)( ((char *)base) + width );
}
dp2--;
dp2->next=NULL;
}
return(dp);
}
void
lmsort_end( struct lmsortp *dp )
{
if (dp)
{
free(dp);
}
return;
}
/* -- End of File -- */

View file

@ -1,88 +0,0 @@
/*
*
* Optimal list-merge sorting algorithm with exponential merge schedule.
*
* From: Software Development International, Winter 1991.
*
* This implementation by Jeremy Harris jgh@imptld.com
*
* Adapted into toolkit by Martin Poole mpoole@cix.compulink.co.uk
*
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* $Source$
* $Author$
* $Date$
* $Revision$
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
includes
------------------------------------------------------------------ */
#include <sys/types.h>
#include <stdlib.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/lmsort.h>
/* ------------------------------------------------------------------
variables
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
code starts here
------------------------------------------------------------------ */
struct lmsortp *
lmsort_init( void* base, size_t nel, size_t width, struct lmsortp *dp )
{
struct lmsortp *dp2;
int i;
if (dp==NULL)
dp = malloc( nel * sizeof(struct lmsortp) );
if (dp)
{
/* we can only sort if there is enough memory */
dp2=dp;
for (i=0; i<nel; i++)
{
dp2->next = dp2+1;
dp2->dp = base;
dp2++;
base = (void *)( ((char *)base) + width );
}
dp2--;
dp2->next=NULL;
}
return(dp);
}
void
lmsort_end( struct lmsortp *dp )
{
if (dp)
{
free(dp);
}
return;
}
/* -- End of File -- */

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,23 +3,6 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* $Log$
*
*******************************************************************************
*/
@ -28,6 +11,7 @@
------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
@ -36,7 +20,6 @@
#include <string.h>
#include <stdarg.h>
#include <memory.h>
#include <malloc.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/timestamp.h>

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,31 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : min list handling
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,31 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,31 +3,9 @@
* Copyright (c) 1997 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : Safe strlen
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,28 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* *
* $Source$
* $Author$
* $Date$
* $Revision$
* *
*******************************************************************************
* *
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,28 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* *
* $Source$
* $Author$
* $Date$
* $Revision$
* *
*******************************************************************************
* *
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -3,23 +3,6 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* *
* $Source$
* $Author$
* $Date$
* $Revision$
* *
*******************************************************************************
* *
* $Log$
*
*******************************************************************************
*/
@ -28,6 +11,7 @@
------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
@ -36,7 +20,6 @@
#include <string.h>
#include <stdarg.h>
#include <memory.h>
#include <malloc.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/timestamp.h>

View file

@ -1,535 +0,0 @@
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_alloc.c,v $
* $Author: mpoole $
* $Date: 2002/10/07 09:37:40 $
* $Revision: 1.2 $
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log: vre_alloc.c,v $
* Revision 1.2 2002/10/07 09:37:40 mpoole
* Initial checkin of mplib1-3.1.0
*
* Revision 1.1 2002/10/07 09:36:57 mpoole
* Initial checkin of mplib1-3.1.0
*
*
*******************************************************************************
*/
#ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_alloc.c,v 1.2 2002/10/07 09:37:40 mpoole Exp $"
/* vre2disp.c
vogon record editor. Display only version
********************************************************************
Copyright 1989,90,91,94,95 Martin Poole
Released for use by Y2 Computing Limited - 1990
Released for use by Perot Systems Europe Limited - 1995.
********************************************************************
*/
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <sys/types.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/dl_list.h>
#include <mplib1/mpstrtok.h>
#include <mplib1/fgetline.h>
#include <mplib1/vre.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
static dl_List_t object_list;
static int done_init=0;
static FILE *err_fp=NULL;
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */
static int
init_obj_list( void )
{
if (done_init==0)
{
done_init=1;
dl_Init_List( &object_list, 0 );
}
return(0);
}
int
vre_Init_VRE( FILE *fp )
{
err_fp = fp;
init_obj_list();
return(0);
}
static struct vre_type_obj *
alloc_type( const char *nm )
{
struct vre_type_obj *top;
top = (struct vre_type_obj *)malloc( sizeof(struct vre_type_obj) + strlen(nm) );
if (top)
{
dl_Init_Node( &top->to_Node, top->to_Name, top );
top->to_Flags = 0;
top->to_Disp = (vre_disp_t)NULL;
dl_Init_List( &top->to_Elems, 0 );
strcpy( top->to_Name, nm );
}
return(top);
}
struct vre_type_obj *
vre_Find_Type( const char *nm )
{
init_obj_list( );
return( (struct vre_type_obj *) dl_Find_Item_By_Name( &object_list, nm ));
}
int
vre_Add_Type( struct vre_type_obj *top )
{
int rv=0;
init_obj_list( );
if (!dl_Find_Item_By_Name( &object_list, top->to_Name ))
{
dl_Add_Tail( &object_list, &top->to_Node );
rv = 1;
}
return(rv);
}
struct vre_type_obj *
vre_Type_Synonym( const char *nm, const char *synm )
{
struct vre_type_obj *top=NULL,*top2;
init_obj_list( );
top2 = (struct vre_type_obj *)dl_Find_Item_By_Name( &object_list, synm );
if (top2)
{
top = (struct vre_type_obj *)dl_Find_Item_By_Name( &object_list, nm );
if (top)
return(NULL);
top = alloc_type( nm );
if (top)
{
top->to_Flags = TO_TYPEDEF;
top->to_Disp = (vre_disp_t)top2;
top->to_Size = top2->to_Size;
top->to_Align = top2->to_Align;
dl_Add_Tail( &object_list, &top->to_Node );
}
}
return(top);
}
struct vre_type_obj *
vre_New_Type( const char *nm,
vre_disp_t disp,
size_t isize,
int ialign,
int add )
{
struct vre_type_obj *top;
init_obj_list( );
top = (struct vre_type_obj *)dl_Find_Item_By_Name( &object_list, nm );
if (top)
return(NULL);
top = alloc_type( nm );
if (top)
{
if (disp)
{
top->to_Flags = TO_DISPLAY;
top->to_Disp = disp;
}
else
{
top->to_Flags = TO_COMPOSITE;
top->to_Disp = (vre_disp_t)NULL;
}
top->to_Size = isize;
top->to_Align = ialign;
if (add)
dl_Add_Tail( &object_list, &top->to_Node );
}
return(top);
}
struct vre_elem_obj *
vre_New_Elem( const char *nm,
const char *typ,
off_t offset,
int arr_sz )
{
struct vre_elem_obj *eop=NULL;
size_t als;
init_obj_list( );
if (dl_Find_Item_By_Name( &object_list, typ ))
{
/* Type exists so allow creation */
als = sizeof(struct vre_elem_obj)
+ (size_t)(strlen(nm) + strlen(typ) + 1);
eop = malloc( als );
if (eop)
{
strcpy( eop->eo_Type, typ );
eop->eo_Name = eop->eo_Type + strlen(eop->eo_Type) + 1;
strcpy( eop->eo_Name, nm );
dl_Init_Node( &eop->eo_Node, eop->eo_Name, eop );
eop->eo_Offset = offset;
eop->eo_Arr_sz = arr_sz;
}
}else
if (err_fp)
fprintf( err_fp, "Cannot find type <%s\n", typ );
return(eop);
}
struct vre_elem_obj *
vre_Cat_New_Elem( struct vre_type_obj *ntyp,
const char *el_nm,
const char *el_typ,
int arr_sz )
{
struct vre_elem_obj *eop=NULL;
struct vre_type_obj *top;
off_t offset;
top = vre_Find_Type( el_typ );
if (ntyp && top)
{
offset = (ntyp->to_Size + (top->to_Align - 1)) & ~(top->to_Align - 1);
eop = vre_New_Elem( el_nm, top->to_Name, offset, arr_sz );
if (eop)
{
dl_Add_Tail( &ntyp->to_Elems, &eop->eo_Node );
/* and now adjust the typ size */
if (ntyp->to_Align < top->to_Align)
{
/* set the align acording to the largest alignment */
ntyp->to_Align = top->to_Align;
}
if (offset>= ntyp->to_Size)
{
/* it's on the end of the structure */
if (arr_sz > 1)
ntyp->to_Size = (size_t)offset + (top->to_Size * (size_t)arr_sz);
else
ntyp->to_Size = (size_t)offset + top->to_Size;
}
}else
{
if (err_fp)
fprintf( stderr, "Unable to create new element <%s>\n", el_nm );
}
}else
{
/* not enough specified */
if (err_fp)
fprintf( stderr, "Unable to add element <%s><%s>\n", el_nm, el_typ );
}
return(eop);
}
static void
disp_this_type( struct vre_type_obj *top,
struct vre_disp_walk_item *dwip ); /* forward definition */
static void
disp_elems( struct vre_elem_obj *eop,
struct vre_disp_walk_item *dwip )
{
struct vre_type_obj *top;
const void *optr;
const char *olds;
char *cp;
top = dl_Find_Item_By_Name( &object_list, eop->eo_Type );
if (top)
{
cp = malloc( strlen(dwip->prefix)
+ strlen(eop->eo_Name) + 1 );
if (cp)
{
optr = dwip->ptr;
dwip->ptr = ((const char *)dwip->ptr + eop->eo_Offset);
olds = dwip->prefix;
dwip->prefix = cp;
sprintf( cp, "%s%s", olds, eop->eo_Name );
dwip->eop = eop;
dwip->top = top;
disp_this_type( top, dwip );
free( cp );
dwip->prefix = olds;
dwip->ptr = optr;
}else
{
fprintf( dwip->fp, " ** Cannot allocate for recursion **\n" );
}
}
return;
}
int
vre_Disp_Prefix( FILE *fp,
const void *ptr,
const void *base,
const char *prefix,
const char *suffix )
{
static char e_str[]="\0";
fprintf( fp, "%08x %s%s ",
(int)((const char *)ptr - (const char *)base),
(prefix)?prefix:e_str, (suffix)?suffix:e_str );
return(0);
}
static void
disp_this_type( struct vre_type_obj *top,
struct vre_disp_walk_item *dwip )
{
const char *olds;
char *cp;
if (dwip->flags & VRE_DISP_ELEM_NAMES)
vre_Disp_Prefix( dwip->fp, dwip->ptr, dwip->base, dwip->prefix, NULL );
while ( top && (top->to_Flags & TO_TYPEDEF))
top = (struct vre_type_obj *)top->to_Disp;
if (top)
{
if (top->to_Flags & TO_DISPLAY)
{
(* top->to_Disp)( dwip->ptr, dwip );
fputc( '\n', dwip->fp );
}else
{
cp = malloc( strlen(dwip->prefix)
+ strlen(top->to_Name) + 2 );
if (cp)
{
olds = dwip->prefix;
dwip->prefix = cp;
if (dwip->flags & VRE_DISP_ELEM_NAMES)
sprintf( cp, "%s.", olds );
fputc( '\n', dwip->fp );
dl_Walk_List( &top->to_Elems,
(dl_Walk_List_t)disp_elems, dwip );
free( cp );
dwip->prefix = olds;
}else
{
fprintf( dwip->fp, " ** Cannot allocate for recursion **\n" );
}
}
}else
{
fprintf( dwip->fp, " ** Cannot find type for display **\n" );
}
return;
}
int
vre_Get_Info( const char *el_nm,
size_t *isize,
int *ialign,
off_t *offset,
int *arr_sz,
int *flags )
{
struct vre_type_obj *top;
struct vre_elem_obj *eop;
int rv=0;
off_t soff;
char *pstr;
char *cp;
void *tokptr;
static char seps[]=".";
pstr = strdup(el_nm);
if (pstr)
{
/* mark off the single word */
cp = strstr( pstr, "\t " );
if (cp)
*cp = '\0';
/* set things up and walk the elements adding up the details */
cp=mpstrtok( pstr, &tokptr, seps );
if (cp)
{
top = vre_Find_Type( cp );
if (top)
{
soff=0;
eop = (struct vre_elem_obj *) -1;
while ( (cp = mpstrtok( NULL, &tokptr, seps ))
&& eop
&& top
)
{
eop = (struct vre_elem_obj *)dl_Find_Item_By_Name( &top->to_Elems, cp );
if (eop)
{
soff += eop->eo_Offset;
top = vre_Find_Type( eop->eo_Type );
}
};
if (eop && top)
{
if (offset)
*offset = soff;
if (isize)
*isize = top->to_Size;
if (arr_sz)
*arr_sz = eop->eo_Arr_sz;
if (ialign)
*ialign = top->to_Align;
rv = 1;
}
}
}
(void)mpstrtok( NULL, &tokptr, NULL );
free(pstr);
}
return(rv);
}
off_t
vre_Get_Offset( const char *el_nm )
{
off_t offset= -1,soff;
if ( vre_Get_Info( el_nm, NULL, NULL, &soff, NULL, NULL ))
offset=soff;
return(offset);
}
int
vre_Disp_Item( FILE *fp,
const char *type,
const char *name,
const void *ptr,
const void *base,
int flags,
void *u_param )
{
struct vre_type_obj *top;
struct vre_disp_walk_item dwi;
init_obj_list( );
top = (struct vre_type_obj *)dl_Find_Item_By_Name( &object_list, type );
if (top)
{
dwi.fp = fp;
dwi.prefix = (name)?name:type;
dwi.ptr = ptr;
dwi.base = base;
dwi.flags = flags;
dwi.u_param = u_param;
disp_this_type( top, &dwi );
}else
{
fprintf(fp, "Cannot find object of type <%s>\n", type );
}
return(0);
}
static void
disp_elem( void *vp1, void *vp2 )
{
FILE *fp;
struct vre_elem_obj *eop;
eop = vp1;
fp = vp2;
fprintf( fp, " Name: %s Offset: %08lx Arr: %08x Type: %s\n",
eop->eo_Name, eop->eo_Offset, eop->eo_Arr_sz, eop->eo_Type );
return;
}
static void
disp_type( void *vp1, void *vp2 )
{
FILE *fp;
struct vre_type_obj *top;
top = vp1;
fp = vp2;
if (top->to_Flags & TO_TYPEDEF)
{
struct vre_type_obj *top2;
top2 = top;
if (top2 && (top2->to_Flags & TO_TYPEDEF));
top2 = (struct vre_type_obj *) top2->to_Disp;
fprintf( fp, "Type: %s\n Flags: %08x Display: %p (%s)\n",
top->to_Name, top->to_Flags, top->to_Disp, top2->to_Name );
}else
fprintf( fp, "Type: %s\n Flags: %08x Display: %p\n",
top->to_Name, top->to_Flags, top->to_Disp );
fprintf( fp, " Size: %16zx Align: %08x\n",
top->to_Size, top->to_Align );
dl_Walk_List( &top->to_Elems, (dl_Walk_List_t)disp_elem, fp );
return;
}
int
vre_Disp_Types( FILE *fp, int flags )
{
dl_Walk_List( &object_list, (dl_Walk_List_t)disp_type, fp );
return(0);
}
/* -- End of File -- */

View file

@ -1,201 +0,0 @@
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_disp.c,v $
* $Author: mpoole $
* $Date: 2002/10/07 09:37:40 $
* $Revision: 1.2 $
*
*******************************************************************************
*
* Change History
*
* $Log: vre_disp.c,v $
* Revision 1.2 2002/10/07 09:37:40 mpoole
* Initial checkin of mplib1-3.1.0
*
* Revision 1.1 2002/10/07 09:36:57 mpoole
* Initial checkin of mplib1-3.1.0
*
*
*******************************************************************************
*/
#ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_disp.c,v 1.2 2002/10/07 09:37:40 mpoole Exp $"
/* vre2disp.c
vogon record editor. Display only version
********************************************************************
Copyright 1989,90,91,94,95 Martin Poole
Released for use by Y2 Computing Limited - 1990
Released for use by Perot Systems Europe Limited - 1995.
********************************************************************
*/
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <sys/types.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/dl_list.h>
#include <mplib1/vre.h>
#include <mplib1/data_align.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
static int done_init=0;
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */
/* let's cut to the chase */
static int
disp_char( void *ptr, struct vre_disp_walk_item *dwip )
{
int boring=1,tlen,mlen;
char *cp;
if (dwip->eop->eo_Arr_sz>0)
{
/* might be a printable string */
cp = ptr;
tlen=0;
mlen = (dwip->eop->eo_Arr_sz==1)?512 : dwip->eop->eo_Arr_sz;
while (*cp++ && ++tlen < mlen);
if (tlen < mlen)
{
fprintf( dwip->fp, "\"%s\"", (char *)ptr );
boring=0;
}
}
if (boring)
fprintf( dwip->fp, "'%c'",(char) (*(char *)ptr >= ' ' && *(char *)ptr < 0x7f)
? *(char *)ptr : '.' );
return(0);
}
static int
disp_byte( void *ptr, struct vre_disp_walk_item *dwip )
{
fprintf( dwip->fp, "%02x",(int) *(unsigned char *)ptr );
return(0);
}
static int
disp_word( void *ptr, struct vre_disp_walk_item *dwip )
{
fprintf( dwip->fp, "%04x",(int) *(unsigned short *)ptr );
return(0);
}
static int
disp_long( void *ptr, struct vre_disp_walk_item *dwip )
{
fprintf( dwip->fp, "%08x",(int) *(unsigned int *)ptr );
return(0);
}
static int
disp_double( void *ptr, struct vre_disp_walk_item *dwip )
{
fprintf( dwip->fp, "%f", *(double *)ptr );
return(0);
}
static int
disp_string( void *ptr, struct vre_disp_walk_item *dwip )
{
fprintf( dwip->fp, "%s", (char *)ptr );
return(0);
}
static int
disp_char_ptr( void *ptr, struct vre_disp_walk_item *dwip )
{
fprintf( dwip->fp, "%s", *(char **)ptr );
return(0);
}
static int
disp_ptr( void *ptr, struct vre_disp_walk_item *dwip )
{
fprintf( dwip->fp, "%p", *(void **)ptr );
return(0);
}
#ifndef NO_VLONG
static int
disp_vlong( void *ptr, struct vre_disp_walk_item *dwip )
{
/* fprintf( dwip->fp, "%qx",(long long) *(unsigned long long *)ptr );*/
#ifdef L_FOR_LONGLONG
fprintf( dwip->fp, "%Lx",(long long) *(unsigned long long *)ptr );
#else
fprintf( dwip->fp, "%llx",(long long) *(unsigned long long *)ptr );
#endif
return(0);
}
#endif
int
vre_Init_Disp_Primitives( FILE *fp )
{
vre_Init_VRE( fp );
if (done_init==0)
{
done_init=1;
vre_New_Type( "char", (vre_disp_t)disp_char,
1, MPLIB_ALIGN_SPC_CHAR, 1 );
vre_New_Type( "byte", (vre_disp_t)disp_byte,
1, MPLIB_ALIGN_SPC_CHAR, 1 );
vre_New_Type( "word", (vre_disp_t)disp_word,
2, MPLIB_ALIGN_SPC_SHORT, 1 );
vre_New_Type( "short", (vre_disp_t)disp_word,
2, MPLIB_ALIGN_SPC_SHORT, 1 );
vre_New_Type( "long", (vre_disp_t)disp_long,
4, MPLIB_ALIGN_SPC_LONG, 1 );
vre_New_Type( "int", (vre_disp_t)disp_long,
4, MPLIB_ALIGN_SPC_INT, 1 );
vre_New_Type( "double", (vre_disp_t)disp_double,
8, MPLIB_ALIGN_SPC_DOUBLE, 1 );
vre_New_Type( "string", (vre_disp_t)disp_string,
0, MPLIB_ALIGN_SPC_CHAR, 1 );
vre_New_Type( "char*", (vre_disp_t)disp_char_ptr,
4, MPLIB_ALIGN_SPC_PTR, 1 );
vre_New_Type( "pointer", (vre_disp_t)disp_ptr,
4, MPLIB_ALIGN_SPC_PTR, 1 );
#ifndef NO_VLONG
vre_New_Type( "vlong", (vre_disp_t)disp_vlong,
8, MPLIB_ALIGN_SPC_VLONG, 1 );
#endif
}
return(0);
}
/* -- End of File -- */

View file

@ -1,360 +0,0 @@
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_loop.c,v $
* $Author: mpoole $
* $Date: 2002/10/07 09:37:40 $
* $Revision: 1.2 $
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log: vre_loop.c,v $
* Revision 1.2 2002/10/07 09:37:40 mpoole
* Initial checkin of mplib1-3.1.0
*
* Revision 1.1 2002/10/07 09:36:57 mpoole
* Initial checkin of mplib1-3.1.0
*
*
*
*******************************************************************************
*/
#ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_loop.c,v 1.2 2002/10/07 09:37:40 mpoole Exp $"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <stdio.h>
#ifdef INCLUDE_GETOPT
#include <getopt.h>
#endif
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <signal.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/dl_list.h>
#include <mplib1/cfg_file.h>
#include <mplib1/mpstrtok.h>
#include <mplib1/match_tok.h>
#include <mplib1/fgetline.h>
#include <mplib1/vre.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
static struct match_token com_2[] =
{
{ 1, "^set" },
{ 2, "^show" },
{ 3, "^define" },
{ 4, "^read" },
{ 5, "^vars" },
{ 6, "^types" },
{ 0, NULL }
};
static struct match_token mod_sizes[] =
{
{ 1, "^byte" },
{ 2, "^word" },
{ 3, "^long" },
{ 4, "^string" },
{ 0, NULL }
};
static char last_list[]="Last values";
static char ADDR[]="addr";
static char TYPE[]="type";
static char whitespace[]="\t ";
static void *my_seg_base=NULL;
static char *last_type=NULL;
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */
static int
get_last_int( char *key )
{
return( get_private_int( last_list, key ));
}
static char *
get_last_str( char *key )
{
return( get_private_string( last_list, key ));
}
static int
set_last_int( char *key, int newval )
{
return( set_private_int( last_list, key, newval ));
}
static int
set_last_str( char *key, char *newval )
{
return( set_private_string( last_list, key, newval ));
}
static int
get_hex_param( char *np, char **nnp )
{
int rv;
rv = strtol( np, nnp, 16 );
return(rv);
}
static int
get_val_at( int pval, size_t isize )
{
int rv;
if ( isize == 1 || pval & 1)
{
/* char boundary */
rv = *(unsigned char *)((unsigned char *)my_seg_base + pval);
}else if ( isize==2 || pval & 2)
{
rv = *(unsigned short *)((unsigned char *)my_seg_base + pval);
}else
{
rv = *(unsigned long *)((unsigned char *)my_seg_base + pval);
}
return(rv);
}
int
vre_Get_ADDR( char *np, char **nnp )
{
int use_contents=0;
size_t isize=(size_t)4;
int last_val;
off_t offv;
void *tokptr;
last_val = get_last_int( ADDR );
if ( np
&& (np = mpstrtok( np, &tokptr, whitespace ))
&& np
&& *np == '@')
{
use_contents=1;
np++;
}
if (np && *np)
{
/* is it an element */
if ( vre_Get_Info( np, &isize, NULL, &offv, NULL, NULL ))
{
/* it is, so add it to the last value */
last_val += offv;
}else
{
int new_val;
char *tp;
new_val = get_hex_param( np, &tp );
if (tp!=np)
last_val = new_val;
}
np = mpstrtok( NULL, &tokptr, whitespace );
}
(void) mpstrtok( NULL, &tokptr, NULL );
if (nnp)
*nnp = np;
if (use_contents)
last_val = get_val_at( last_val, isize );
set_last_int( ADDR, last_val );
return(last_val);
}
static int
change_a_loc( FILE *fp, void *vp, char *np )
{
char *nnp;
off_t offst;
int what,ln;
size_t isize;
void *tokptr;
what = match_a_string( np, mod_sizes, &nnp );
if (what==0)
{
nnp = mpstrtok( np, &tokptr, whitespace );
if( vre_Get_Info( nnp, &isize, NULL, &offst, NULL, NULL ))
{
if (isize==4)
isize--;
what = isize;
offst += vre_Get_ADDR( NULL, NULL );
nnp = mpstrtok( NULL, &tokptr, whitespace );
}
(void) mpstrtok( NULL, &tokptr, NULL );
}else
{
offst = (off_t)get_hex_param( nnp, &nnp );
}
switch (what)
{
case 1 : /* byte */
ln = get_hex_param( nnp, NULL );
*(unsigned char *)((char *)vp + offst) = ln;
break;
case 2 : /* word */
ln = get_hex_param( nnp, NULL );
*(unsigned short *)((char *)vp + offst) = ln;
break;
case 3 : /* long */
ln = get_hex_param( nnp, NULL );
*(unsigned long *)((char *)vp + offst) = ln;
break;
case 4 : /* string */
strcpy( (char *)vp + offst, nnp );
break;
default :
fprintf( fp, "Unknown size\n" );
break;
}
return(1);
}
static char *
get_last_type( char *np, char **nnp )
{
char *cp;
char *rv;
void *tokptr;
rv = get_last_str( TYPE );
np = mpstrtok( np, &tokptr, whitespace );
if (np && *np)
{
cp = mpstrtok( NULL, &tokptr, whitespace );
if (vre_Find_Type(np))
{
/* got a valid type */
rv = np;
}
if (nnp)
{
*nnp = (cp)?cp:(np+strlen(np));
}
}else
{
if (nnp)
*nnp = np;
}
mpstrtok( NULL, &tokptr, NULL );
if (last_type!=NULL)
free( last_type );
if (rv)
{
last_type = strdup(rv);
set_last_str( TYPE, rv );
}else
last_type = rv;
return(last_type);
}
static int
show_something( FILE *fp, void *vp, char *np )
{
char *tp_nm,*of_pt;
off_t offst;
tp_nm = get_last_type( np, &of_pt );
if (tp_nm)
{
offst = vre_Get_ADDR( of_pt, NULL );
vre_Disp_Item( fp, tp_nm, NULL, (char *)vp + offst, vp, VRE_DISP_ELEM_NAMES, NULL );
}
return(0);
}
static int
list_vars( FILE *fp, char *np )
{
fprintf( fp, "ADDR=%x\n", get_last_int( ADDR ) );
fprintf( fp, "TYPE=%s\n", get_last_str( TYPE ) );
return(0);
}
int
vre_Interactive_Loop( char *line, FILE *fp, void *base )
{
char *lbuf;
char *np=NULL;
int sv;
off_t soff;
my_seg_base = base;
lbuf=strdup(line);
if (lbuf)
{
sv = match_a_string( lbuf, com_2, &np );
switch( sv )
{
case 1 : /* set */
change_a_loc( fp, base, np );
break;
case 2 : /* show */
show_something( fp, base, np );
break;
case 3 : /* define */
vre_Parse_Line( fp, np );
break;
case 4 : /* read */
vre_Parse_File( fp, eval_config_default( NULL, np ) );
break;
case 5 : /* list variables */
list_vars( fp, np );
break;
case 6 : /* list types */
vre_Disp_Types( fp, 0 );
break;
default :
if (strlen(lbuf))
{
soff = vre_Get_ADDR( lbuf, NULL );
fprintf( fp, "ADDR=%x\n", (int)soff );
}
}
free(lbuf);
}
return(1);
}
/* -- End of File -- */

View file

@ -1,377 +0,0 @@
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_parse.c,v $
* $Author: mpoole $
* $Date: 2002/10/07 09:37:40 $
* $Revision: 1.2 $
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log: vre_parse.c,v $
* Revision 1.2 2002/10/07 09:37:40 mpoole
* Initial checkin of mplib1-3.1.0
*
* Revision 1.1 2002/10/07 09:36:57 mpoole
* Initial checkin of mplib1-3.1.0
*
*
*******************************************************************************
*/
#ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_parse.c,v 1.2 2002/10/07 09:37:40 mpoole Exp $"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/dl_list.h>
#include <mplib1/match_tok.h>
#include <mplib1/fgetline.h>
#include <mplib1/vre.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
static struct match_token vre_strs[] =
{
{ 1, "^struct" },
{ 2, "^};" },
{ 3, "^{" },
{ 4, "^typedef" },
{ 5, "^extern" },
{ 6, "^#" },
{ 7, "^static" },
{ 0, NULL }
};
struct achunk
{
dl_Node_t ac_Node;
char ac_Name[1];
};
static struct vre_type_obj *ntyp=NULL;
static int doing_struct=0, achunk_init=0;
static dl_List_t achunks;
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */
static int
init_achunks( void )
{
if(achunk_init==0)
{
achunk_init=1;
dl_Init_List( &achunks, 0 );
}
return(0);
}
static int
check_ptr( char *raw, char **after )
{
int rv;
while (*raw==' ' || *raw=='\t' || *raw=='(' )
raw++;
rv = (*raw=='*');
if (rv)
raw++;
if (after)
*after = raw;
return(rv);
}
static int
get_arr_sz( char *cp, char **ncp )
{
int rv=0;
/* skip whitespace */
while (*cp==' ' || *cp=='\t')
cp++;
if (*cp == '[')
{
/* it's an array */
cp++;
rv = strtol( cp, ncp, 0 );
}else
{
if (ncp)
*ncp = cp;
}
return(rv);
}
static char *
get_c_var( char *raw, char **after, int *arr_szp )
{
struct achunk *achp;
char *sp, *cp;
init_achunks();
sp = raw;
while (*sp==' ' || *sp=='\t')
sp++;
cp = sp;
if (after)
*after = cp;
while( isalnum(*cp) || *cp=='_' )
cp++;
if (cp - sp)
{
achp = (struct achunk *)malloc( sizeof(struct achunk) + (cp - sp) );
if (achp)
{
dl_Init_Node( &achp->ac_Node, achp->ac_Name, achp );
strncpy( achp->ac_Name, sp, (size_t)(cp - sp) );
achp->ac_Name[cp-sp] = '\0';
if (arr_szp)
*arr_szp = get_arr_sz( cp, &cp );
if (after)
*after = cp;
cp = achp->ac_Name;
}else
cp = NULL;
}else
cp = NULL;
return(cp);
}
static void
free_em( void *vp1, void *vp2 )
{
struct achunk *achp= vp1;
dl_Remove_Node( &achp->ac_Node );
free( achp );
return;
}
static void
free_c_vars( void )
{
init_achunks();
dl_Walk_List( &achunks, (dl_Walk_List_t)free_em, NULL );
return;
}
static void
free_elems( void *vp1, void *vp2 )
{
free(vp1);
return;
}
static int
End_New_Typ( FILE *fp )
{
if (ntyp)
{
if ( vre_Add_Type(ntyp)==0 )
{
fprintf(fp, "Unable to add type <%s>\n", ntyp->to_Name );
dl_Walk_List( &ntyp->to_Elems, (dl_Walk_List_t)free_elems, NULL );
free(ntyp);
}
ntyp = NULL;
}
doing_struct = 0;
return(0);
}
static int
get_type_and_var( char *dp, char **el_nm, char **tp_nm,
int *is_ptr, int *arr_szp,
struct vre_type_obj **top )
{
int rv=0;
char *cp;
if (match_string(dp, "^struct", &cp))
dp = cp;
if (match_string(dp, "^unsigned", &cp))
dp = cp;
*tp_nm = get_c_var( dp, &dp, NULL );
*is_ptr = check_ptr( dp, &dp );
*el_nm = get_c_var( dp, &dp, arr_szp );
if (*el_nm && *tp_nm)
{
if (*is_ptr)
*top = vre_Find_Type( "pointer" );
else
*top = vre_Find_Type( *tp_nm );
if (*top)
rv=1;
}
return(rv);
}
static int
Add_Struct_Elem( FILE *fp, char *dp )
{
/* struct vre_elem_obj *eop;*/
struct vre_type_obj *top;
char *tp_nm,*el_nm;
/* off_t offset;*/
int is_ptr, arr_sz;
if (ntyp)
{
if (get_type_and_var( dp, &el_nm, &tp_nm, &is_ptr, &arr_sz, &top ))
{
if (vre_Cat_New_Elem( ntyp, el_nm, top->to_Name, arr_sz )==NULL)
{
fprintf( fp, "Unable to create new element <%s>\n", el_nm );
}
}else
{
/* not enough specified */
fprintf( fp, "Unable to add element <%s>\n", (el_nm)?el_nm:"" );
}
free_c_vars();
}else
{
fprintf(fp, "No type currently being defined\n" );
}
return(0);
}
static int
do_typedef( FILE *fp, char *dp )
{
struct vre_type_obj *top;
char *tp_nm,*el_nm;
int is_ptr;
if (get_type_and_var( dp, &el_nm, &tp_nm, &is_ptr, NULL, &top ))
vre_Type_Synonym( el_nm, top->to_Name );
else
fprintf( fp, "No name and type for typedef <%s>\n", dp );
free_c_vars();
return(0);
}
static int
Start_New_Typ( FILE *fp, char *dp )
{
char *cp;
int rv=0;
cp = get_c_var( dp, NULL, NULL );
if (cp)
{
ntyp = vre_New_Type( cp, NULL, 0, 0, 0 );
if (ntyp==NULL)
{
fprintf( fp, "Unable to create new type <%s>\n", cp );
}else
rv = 1;
}
free_c_vars();
return(rv);
}
int
vre_Parse_Line( FILE *fp, char *line )
{
char *str,*dp;
str = strdup( line );
if(str)
{
/* skip leading whitespace */
while ( *str==' ' || *str=='\t' )
str++;
/* OK let's start cutting it up */
switch(match_a_string( str, vre_strs, &dp ))
{
case 1 : /* it's a type */
if (doing_struct)
{
Add_Struct_Elem( fp, dp );
}else
{
End_New_Typ( fp );
if (Start_New_Typ( fp, dp ))
doing_struct = 1;
}
break;
case 2 : /* end of structure */
End_New_Typ( fp );
break;
case 3 : /* ignore */
break;
case 4 : /* typedef */
do_typedef( fp, dp );
break;
case 5 : /* extern */
case 6 : /* hash */
case 7 : /* hash */
break;
default : /* whoops */
if (ntyp && doing_struct)
{
/* try and parse as structure element */
Add_Struct_Elem( fp, str );
}
else
{
fprintf( fp, "Unrecognised command <%s>\n", str );
}
break;
}
free(str);
}
return(0);
}
int
vre_Parse_File( FILE *fp, const char *fname )
{
FILE *ifh;
char tbuf[500],*cp;
ifh=fopen(fname,"r");
if (ifh)
{
while(fgetline(ifh,tbuf,500)==0)
{
cp = tbuf;
/* skip leading whitespace */
while ( *cp==' ' || *cp=='\t' )
cp++;
if (strlen(cp))
vre_Parse_Line( fp, cp );
}
fclose(ifh);
}
return(0);
}
/* -- End of File -- */

View file

@ -4,22 +4,10 @@
include ../make_include
MPLIB1BPO=$(LIBDIR)/libmplib1bpo.a
MPLIB1BPOSO_BASE=libmplib1bpo.so
MPLIB1BPOSO_BASE=libmplib1bpo.$(DYNLIBSUFFIX)
MPLIB1BPOSO=$(LIBDIR)/$(MPLIB1BPOSO_BASE)
ifndef MAJOR_VERSION
MAJOR_VERSION=4
endif
ifndef MINOR_VERSION
MINOR_VERSION=1
endif
VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)
ifdef BUILD_SHARED
TARGETS=$(MPLIB1BPO) $(MPLIB1BPOSO)
else
TARGETS=$(MPLIB1BPO)
endif
TARGETS=$(MPLIB1BPOSO)
PUBHEADERS=$(wildcard $(LIBINC_DIR)/mplib1/bpo*.h)
PUBHEADERS_BASE=$(patsubst $(LIBINC_DIR)/mplib1/%, %, $(PUBHEADERS))
@ -48,12 +36,10 @@ OBJECTS= \
bpo_daemonsleep.o
LIBOBJECTS=$(patsubst %.o,$(MPLIB1BPO)(%.o),$(OBJECTS))
SO_OBJECTS=$(patsubst %.o,$(MPLIB1BPOSO)(%.o),$(OBJECTS))
LIBSOURCE=$(patsubst %.o,%.c,$(OBJECTS))
LIBDEPEND=$(patsubst %.o,DEPENDS/%.d,$(OBJECTS))
all: $(TARGETS)
@ -62,32 +48,91 @@ all: $(TARGETS)
clean:
@rm -f $(TARGETS)
@rm -f $(OBJECTS)
@rm -f $(LIBDEPEND)
install:
cp $(MPLIB1BPO) $(INSTALL_LIB)
@mkdir $(INSTALL_INCLUDE)
cp $(PUBHEADERS) $(INSTALL_INCLUDE)
ifdef BUILD_SHARED
cp $(MPLIB1BPOSO) $(INSTALL_LIB)/$(MPLIB1BPOSO_BASE).$(VERSION)
ln -s $(MPLIB1BPOSO_BASE).$(VERSION) $(INSTALL_LIB)/$(MPLIB1BPOSO_BASE)
ln -s $(MPLIB1BPOSO_BASE).$(VERSION) $(INSTALL_LIB)/$(MPLIB1BPOSO_BASE).$(MAJOR_VERSION)
cp $(MPLIB1BPOSO) $(INSTALL_LIB)/$(MPLIB1BPOSO_BASE).$(MAJMIN_VERSION)
ln -s $(MPLIB1BPOSO_BASE).$(MAJMIN_VERSION) $(INSTALL_LIB)/$(MPLIB1BPOSO_BASE)
ln -s $(MPLIB1BPOSO_BASE).$(MAJMIN_VERSION) $(INSTALL_LIB)/$(MPLIB1BPOSO_BASE).$(MAJOR_VERSION)
ifeq ($(NEEDSONAME),yes)
SONAMEVAR = $(SONAMEOPT)$(MPLIB1BPOSO_BASE).$(MAJOR_VERSION)
else
SONAMEVAR = -L../lib -lmplib1
endif
docs:
true
docs_clean:
true
$(MPLIB1BPO): ../mplib1/mplib1_config.h $(LIBOBJECTS)
$(MPLIB1BPOSO): $(OBJECTS)
$(CC) -shared -Wl,-soname,$(MPLIB1BPOSO_BASE).$(MAJOR_VERSION) \
$(CC) $(DYNLIBOPT) $(SONAMEVAR) \
-o $(MPLIB1BPOSO) \
$(OBJECTS)
ifndef DOING_CLEAN
include $(LIBDEPEND)
endif
bpo_alloc.o: bpo_alloc.c \
../mplib1/mplib1_config.h ../mplib1/safe_string.h ../mplib1/cfg_file.h ../mplib1/dl_list.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_attach.o: bpo_attach.c \
../mplib1/mplib1_config.h ../mplib1/fprintfile.h ../mplib1/timestamp.h \
../mplib1/dl_list.h ../mplib1/cfg_file.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_daemonsleep.o: bpo_daemonsleep.c \
../mplib1/mplib1_config.h ../mplib1/dl_list.h ../mplib1/daemon.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_init.o: bpo_init.c \
../mplib1/mplib1_config.h ../mplib1/safe_string.h ../mplib1/dl_list.h \
../mplib1/fprintfile.h ../mplib1/timestamp.h ../mplib1/cfg_file.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_list.o: bpo_list.c \
../mplib1/mplib1_config.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_lock.o: bpo_lock.c \
../mplib1/mplib1_config.h ../mplib1/fprintfile.h ../mplib1/timestamp.h ../mplib1/cfg_file.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_lock_flg.o: bpo_lock_flg.c \
../mplib1/mplib1_config.h ../mplib1/fprintfile.h ../mplib1/timestamp.h ../mplib1/cfg_file.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_lock_pid.o: bpo_lock_pid.c \
../mplib1/mplib1_config.h ../mplib1/fprintfile.h ../mplib1/timestamp.h ../mplib1/cfg_file.h \
../mplib1/pid_check.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_lock_rw.o: bpo_lock_rw.c \
../mplib1/mplib1_config.h ../mplib1/fprintfile.h ../mplib1/timestamp.h ../mplib1/cfg_file.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_msg.o: bpo_msg.c \
../mplib1/mplib1_config.h ../mplib1/dl_list.h ../mplib1/cfg_file.h \
../mplib1/fprintfile.h ../mplib1/timestamp.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_nap.o: bpo_nap.c \
../mplib1/mplib1_config.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_proc.o: bpo_proc.c \
../mplib1/mplib1_config.h ../mplib1/pid_check.h ../mplib1/fprintfile.h \
../mplib1/timestamp.h ../mplib1/dl_list.h ../mplib1/cfg_file.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_proc_cln.o: bpo_proc_cln.c \
../mplib1/cfg_file.h ../mplib1/safe_string.h ../mplib1/pid_check.h \
../mplib1/mplib1_config.h ../mplib1/fprintfile.h ../mplib1/timestamp.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_proc_me.o: bpo_proc_me.c \
../mplib1/mplib1_config.h ../mplib1/pid_check.h ../mplib1/fprintfile.h \
../mplib1/timestamp.h ../mplib1/dl_list.h ../mplib1/cfg_file.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_queue.o: bpo_queue.c \
../mplib1/mplib1_config.h ../mplib1/safe_string.h ../mplib1/dl_list.h \
../mplib1/cfg_file.h ../mplib1/pid_check.h ../mplib1/fprintfile.h \
../mplib1/timestamp.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_resource.o: bpo_resource.c \
../mplib1/mplib1_config.h ../mplib1/safe_string.h ../mplib1/dl_list.h \
../mplib1/cfg_file.h ../mplib1/fprintfile.h ../mplib1/timestamp.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_sort_i.o: bpo_sort_i.c \
../mplib1/mplib1_config.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_sort_n.o: bpo_sort_n.c \
../mplib1/mplib1_config.h \
../include/bpo_internal.h ../mplib1/bpo.h
bpo_validate.o: bpo_validate.c \
../mplib1/mplib1_config.h ../mplib1/dl_list.h ../mplib1/cfg_file.h \
../mplib1/fprintfile.h ../mplib1/timestamp.h ../mplib1/pid_check.h \
../include/bpo_internal.h ../mplib1/bpo.h

View file

@ -2,31 +2,10 @@
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -45,9 +24,8 @@
#include <mplib1/safe_string.h>
#include <mplib1/cfg_file.h>
#include "../include/bpo_init_internal.h"
#include "../include/bpo_alloc_private.h"
#include <mplib1/bpo_alloc.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#ifdef SHALLOC_DEBUG
#include <mplib1/fprintfile.h>
@ -370,7 +348,7 @@ shalloc( const void *hint, size_t how_much )
/* First we check that the hint is in the permitted region */
char *seg_base;
struct shalloc_base *sh_base;
struct shalloc_track_head *free_head,*used_head;
struct shalloc_track_head *used_head;
off_t my_off;
void *ptr;
@ -387,7 +365,6 @@ shalloc( const void *hint, size_t how_much )
b_Lock( &sh_base->sb_lock );
free_head = GRPTR( sh_base, sh_base->lno_first_free );
used_head = GRPTR( sh_base, sh_base->lno_first_used );
/* now walk the free list looking for the smallest/first

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -51,8 +30,8 @@
#include <mplib1/dl_list.h>
#include <mplib1/cfg_file.h>
#include <mplib1/bpo_init.h>
#include <mplib1/bpo_proc.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
/* ------------------------------------------------------------------
defines

View file

@ -3,31 +3,9 @@
* Copyright (c) 1997 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -48,9 +26,9 @@
#endif
#include <mplib1/dl_list.h>
#include <mplib1/bpo_proc.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/daemon.h>
#include <mplib1/bpo_daemon.h>
/* ------------------------------------------------------------------
structures / defines

View file

@ -3,30 +3,8 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -49,11 +27,9 @@
#include <mplib1/safe_string.h>
#include <mplib1/dl_list.h>
#include "include/bpo_init_internal.h"
#include "include/bpo_alloc_private.h"
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/bpo_alloc.h>
#include <mplib1/bpo_init.h>
#include <mplib1/fprintfile.h>
#include <mplib1/cfg_file.h>
@ -319,8 +295,6 @@ Attach_SODB_image_raw( const char *fname, off_t foff, size_t fsize )
int fd;
struct sodb *sodbp = NULL;
struct stat tstat;
caddr_t mblock;
void *sodb_rv;
if (done_init==0)
Do_SODB_Init();
@ -344,22 +318,21 @@ Attach_SODB_image_raw( const char *fname, off_t foff, size_t fsize )
return(NULL);
}
/* File is now at least long enough to use */
mblock = mmap( (void *)0, (size_t)(fsize)?fsize:(size_t)tstat.st_size,
PROT_READ | PROT_WRITE, MAP_SHARED,
fd, foff );
if ( mblock == (caddr_t)-1 )
sodbp = (struct sodb *)mmap( (void *)0, (size_t)(fsize)?fsize:(size_t)tstat.st_size,
PROT_READ | PROT_WRITE, MAP_SHARED,
fd, foff );
if ( sodbp == (void *)-1 )
{
if (bpo_init_debug)
fprintfile(stderr,"Attach_SODB_image_raw: cannot mmap\n");
close(fd);
return(NULL);
}
sodbp = (struct sodb *)mblock;
sodb_rv = sodbp;
Add_Track( sodbp, ((char *)sodbp) + ((fsize)?(off_t)fsize:tstat.st_size),
fname, 1, fd, (mode_t)0600 );
return(sodb_rv);
return( (void *)sodbp );
}
void *
@ -378,7 +351,6 @@ Create_SODB_mmap_raw( const char *use_name,
struct sodb *sodbp = NULL;
struct sodb_resource *sodbrp;
struct stat tstat;
caddr_t mblock;
void *sodb_rv;
mode_t old_mask;
@ -423,13 +395,13 @@ Create_SODB_mmap_raw( const char *use_name,
return( NULL );
}
/* File is now at least long enough to use */
mblock = mmap( 0, msize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, moff );
if ( mblock == (caddr_t)-1 )
sodbp = (struct sodb *)mmap( 0, msize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, moff );
if ( sodbp == (void *)-1 )
{
close(fd);
return(NULL);
}
sodbp = (struct sodb *)mblock;
sodb_rv = (flags & SODB_ADD_HEADER) ? (void *)((char *)sodbp + sizeof(struct sodb)) : sodbp;
if (sodbp->sodb_magic != SODB_MAGIC)
{
@ -462,7 +434,7 @@ Create_SODB_mmap_raw( const char *use_name,
}
if (sodb_rv==NULL)
{
munmap( mblock, msize );
munmap( sodbp, msize );
close(fd);
return(NULL);
}
@ -532,7 +504,6 @@ Create_SODB_shm_raw( const char *use_name,
struct sodb *sodbp = NULL;
struct sodb_resource *sodbrp;
struct stat tstat;
caddr_t mblock;
key_t mipckey;
int mshmid;
void *sodb_rv;
@ -569,21 +540,22 @@ Create_SODB_shm_raw( const char *use_name,
fprintfile(stderr,"shmget CREAT: %x\n", mshmid);
if (mshmid==-1)
return(NULL);
mblock = shmat( mshmid, NULL, 0);
((struct sodb *)mblock)->sodb_magic = 0; /* Force new segment code */
sodbp = (struct sodb *)shmat( mshmid, NULL, 0);
if (bpo_init_debug)
fprintfile(stderr,"shmat: %p\n", mblock);
fprintfile(stderr,"shmat: %p\n", sodbp);
if (sodbp != (void *)-1)
sodbp->sodb_magic = 0; /* Force new segment code */
}else
{
/* segment exists, just look at it */
mblock = shmat( mshmid, NULL, 0);
sodbp = (struct sodb *)shmat( mshmid, NULL, 0);
if (bpo_init_debug)
fprintfile(stderr,"shmat(exists): %p\n", mblock);
fprintfile(stderr,"shmat(exists): %p\n", sodbp);
}
if (mblock == (void *)-1)
if (sodbp == (void *)-1)
return(NULL);
sodbp = (struct sodb *)mblock;
sodb_rv = (flags & SODB_ADD_HEADER) ? (void *)((char *)sodbp + sizeof(struct sodb)) : sodbp;
if (sodbp->sodb_magic != SODB_MAGIC)
@ -591,7 +563,7 @@ Create_SODB_shm_raw( const char *use_name,
if (bpo_init_debug)
fprintfile(stderr,"Clearing block\n" );
/* This is not yet an SODB */
memset( mblock, '\0', msize );
memset( sodbp, '\0', msize );
if (bpo_init_debug)
fprintfile(stderr,"Initing block\n" );
sodbp->sodb_magic = SODB_MAGIC;
@ -622,7 +594,7 @@ Create_SODB_shm_raw( const char *use_name,
sodbp->sodb_use_name, (use_name)?use_name:fname );
}
}
shmdt( mblock );
shmdt( sodbp );
/* shmctl( sodbp->ipc_id, IPC_RMID, NULL );*/
return(NULL);
}

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -43,11 +22,9 @@
#include <sys/shm.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/bpo_lock.h>
#include <mplib1/bpo_list.h>
#include <include/bpo_list_internal.h>
#include <mplib1/bpo_init.h>
#include <mplib1/bpo_alloc.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
/* ------------------------------------------------------------------
defines

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -39,9 +18,10 @@
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/fprintfile.h>
#include <mplib1/bpo_lock.h>
#include <include/bpo_lock_internal.h>
#include <mplib1/cfg_file.h>
/* ------------------------------------------------------------------

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -39,8 +18,10 @@
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/fprintfile.h>
#include <mplib1/bpo_lock.h>
#include <mplib1/cfg_file.h>
/* ------------------------------------------------------------------

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -41,9 +20,12 @@
#include <mplib1/fprintfile.h>
#include <mplib1/pid_check.h>
#include <mplib1/bpo_lock.h>
#include <include/bpo_lock_internal.h>
#include <mplib1/cfg_file.h>
#include <mplib1/timestamp.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
/* ------------------------------------------------------------------
defines

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -39,8 +18,10 @@
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/fprintfile.h>
#include <mplib1/bpo_lock.h>
#include <mplib1/cfg_file.h>
/* ------------------------------------------------------------------

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -47,10 +26,13 @@
#include <stdlib.h>
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/dl_list.h>
#include <mplib1/cfg_file.h>
#include <mplib1/fprintfile.h>
#include "include/bpo_q_internal.h"
/* ------------------------------------------------------------------
defines

View file

@ -3,43 +3,19 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/bpo_lock.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
/* ------------------------------------------------------------------
defines
@ -59,7 +35,7 @@ bpo_nap_a_while( long secs, long usecs )
struct timeval my_nap;
my_nap.tv_sec = secs;
my_nap.tv_usec = usecs;
my_nap.tv_usec = (suseconds_t)usecs;
return (select( 0, NULL, NULL, NULL, &my_nap ));

View file

@ -1,32 +1,11 @@
/*
dl_*******************************************************************************
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -47,14 +26,15 @@ dl_*****************************************************************************
#include <fcntl.h>
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/pid_check.h>
#include <mplib1/fprintfile.h>
#include <mplib1/dl_list.h>
#include <mplib1/cfg_file.h>
#include "include/bpo_proc_internal.h"
#include <mplib1/bpo_proc.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -3,33 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* System :
* Subsystem :
* Module :
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -47,10 +23,13 @@
#include <signal.h>
#include <dirent.h>
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/cfg_file.h>
#include <mplib1/safe_string.h>
#include <mplib1/pid_check.h>
#include <mplib1/bpo_proc.h>
#include <mplib1/fprintfile.h>
/* ------------------------------------------------------------------

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -47,14 +26,15 @@
#include <fcntl.h>
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/pid_check.h>
#include <mplib1/fprintfile.h>
#include <mplib1/dl_list.h>
#include <mplib1/cfg_file.h>
#include "include/bpo_proc_internal.h"
#include <mplib1/bpo_proc.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -47,12 +26,15 @@
#include <stdlib.h>
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/safe_string.h>
#include <mplib1/dl_list.h>
#include <mplib1/cfg_file.h>
#include <mplib1/pid_check.h>
#include <mplib1/fprintfile.h>
#include "include/bpo_q_internal.h"
/* ------------------------------------------------------------------
defines

View file

@ -3,30 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -46,11 +25,12 @@
#include <sys/shm.h>
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/safe_string.h>
#include <mplib1/dl_list.h>
#include "../include/bpo_init_internal.h"
#include "../include/bpo_alloc_private.h"
#include <mplib1/bpo_alloc.h>
#include <mplib1/cfg_file.h>
#include <mplib1/fprintfile.h>

View file

@ -11,26 +11,9 @@
* And now adapted for Amiga style double linked lists.
* and then again for bpo_ lists
*
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* $Source$
* $Author$
* $Date$
* $Revision$
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
@ -69,8 +52,9 @@
#endif
#include <mplib1/mplib1_config.h>
#include <mplib1/bpo_list.h>
#include <mplib1/bpo_init.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
/* ------------------------------------------------------------------
variables

View file

@ -11,26 +11,9 @@
* And now adapted for Amiga style double linked lists.
* and then again for bpo_ lists
*
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* $Source$
* $Author$
* $Date$
* $Revision$
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
@ -70,8 +53,9 @@
#endif
#include <mplib1/mplib1_config.h>
#include <mplib1/bpo_list.h>
#include <mplib1/bpo_init.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
/* ------------------------------------------------------------------
variables

View file

@ -3,38 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* System :
* Subsystem :
* Module :
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* Originally derived from V1.2 of sh_diag_i.c
*
* $Log$
*
*
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -58,18 +29,14 @@
#include <memory.h>
#include <unistd.h>
#include "include/bpo_init_internal.h"
#include "include/bpo_alloc_private.h"
#include "include/bpo_proc_internal.h"
#include "include/bpo_q_internal.h"
#include <mplib1/bpo_alloc.h>
#include <mplib1/bpo_init.h>
#include <mplib1/bpo_list.h>
#include <mplib1/bpo_proc.h>
#include <mplib1/mplib1_config.h>
#include "../include/bpo_internal.h"
#include <mplib1/bpo.h>
#include <mplib1/cfg_file.h>
#include <mplib1/dl_list.h>
#include <mplib1/fprintfile.h>
#include <mplib1/mplib1_config.h>
#include <mplib1/pid_check.h>
/* ------------------------------------------------------------------

View file

@ -4,38 +4,21 @@
include ../make_include
MPLIB1GDBM=$(LIBDIR)/libmplib1gdbm.a
MPLIB1GDBMSO_BASE=libmplib1gdbm.so
MPLIB1GDBMSO_BASE=libmplib1gdbm.$(DYNLIBSUFFIX)
MPLIB1GDBMSO=$(LIBDIR)/$(MPLIB1GDBMSO_BASE)
ifndef MAJOR_VERSION
MAJOR_VERSION=4
endif
ifndef MINOR_VERSION
MINOR_VERSION=1
endif
VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)
ifdef BUILD_SHARED
TARGETS=$(MPLIB1GDBM) $(MPLIB1GDBMSO)
else
TARGETS=$(MPLIB1GDBM)
endif
TARGETS=$(MPLIB1GDBMSO)
PUBHEADERS=$(wildcard $(LIBINC_DIR)/mplib1/gdbm*.h)
PUBHEADERS_BASE=$(patsubst $(LIBINC_DIR)/mplib1/%, %, $(PUBHEADERS))
PRIVATE_H=$(wildcard $(LIBINC_DIR)/include/*.h)
PRIVATE_H_BASE=$(patsubst $(LIBINC_DIR)/include/%, %, $(PRIVATE_H))
OBJECTS= \
gdbm_util.o \
gdbm_util2.o
LIBOBJECTS=$(patsubst %.o,$(MPLIB1GDBM)(%.o),$(OBJECTS))
OBJECTS= gdbm_util.o
SO_OBJECTS=$(patsubst %.o,$(MPLIB1GDBMSO)(%.o),$(OBJECTS))
LIBSOURCE=$(patsubst %.o,%.c,$(OBJECTS))
LIBDEPEND=$(patsubst %.o,DEPENDS/%.d,$(OBJECTS))
all: $(TARGETS)
@ -44,38 +27,27 @@ all: $(TARGETS)
clean:
@rm -f $(TARGETS)
@rm -f $(OBJECTS)
@rm -f $(LIBDEPEND)
install:
cp $(MPLIB1GDBM) $(INSTALL_LIB)
@mkdir $(INSTALL_INCLUDE)
cp $(PUBHEADERS) $(INSTALL_INCLUDE)
ifdef BUILD_SHARED
cp $(MPLIB1GDBMSO) $(INSTALL_LIB)/$(MPLIB1GDBMSO_BASE).$(VERSION)
ln -s $(MPLIB1GDBMSO_BASE).$(VERSION) $(INSTALL_LIB)/$(MPLIB1GDBMSO_BASE)
ln -s $(MPLIB1GDBMSO_BASE).$(VERSION) $(INSTALL_LIB)/$(MPLIB1GDBMSO_BASE).$(MAJOR_VERSION)
cp $(MPLIB1GDBMSO) $(INSTALL_LIB)/$(MPLIB1GDBMSO_BASE).$(MAJMIN_VERSION)
ln -s $(MPLIB1GDBMSO_BASE).$(MAJMIN_VERSION) $(INSTALL_LIB)/$(MPLIB1GDBMSO_BASE)
ln -s $(MPLIB1GDBMSO_BASE).$(MAJMIN_VERSION) $(INSTALL_LIB)/$(MPLIB1GDBMSO_BASE).$(MAJOR_VERSION)
ifeq ($(NEEDSONAME),yes)
SONAMEVAR = $(SONAMEOPT)$(MPLIB1GDBMSO_BASE).$(MAJOR_VERSION)
else
SONAMEVAR = -L../lib -lmplib1 -lgdbm
endif
docs:
true
docs_xref:
true
docs_src:
true
docs_clean:
true
$(MPLIB1GDBM): ../mplib1/mplib1_config.h $(LIBOBJECTS)
$(MPLIB1GDBMSO): $(OBJECTS)
$(CC) -shared -Wl,-soname,$(MPLIB1GDBMSO_BASE).$(MAJOR_VERSION) \
$(CC) $(DYNLIBOPT) $(SONAMEVAR) \
-o $(MPLIB1GDBMSO) \
$(OBJECTS)
ifndef DOING_CLEAN
include $(LIBDEPEND)
endif
gdbm_util.o: gdbm_util.c \
../mplib1/cfg_file.h ../mplib1/gdbm_util.h \
../mplib1/dl_list.h ../mplib1/fprintfile.h

View file

@ -3,32 +3,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* System :
* Subsystem :
* Module :
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
@ -266,4 +243,129 @@ delete_some_record( GDBM_FILE file, const char *format, ... )
}
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
struct walk_det
{
FILE *fh;
GDBM_FILE gfile;
int (* dfunc)(FILE *, char *, void *);
int do_data;
int flags;
};
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */
static void
disp_item( dl_Node_t *nptr, struct walk_det *wdp )
{
datum skey,sdata;
int rv;
skey.dptr = (char *)nptr->ln_Name;
skey.dsize = (int)strlen( nptr->ln_Name ) + 1;
if (wdp->dfunc)
{
if (wdp->do_data)
{
sdata = gdbm_fetch( wdp->gfile, skey );
rv = (*wdp->dfunc)( wdp->fh, skey.dptr, sdata.dptr );
if (sdata.dptr && (rv & GDBM_IDUMP_KEEP_DATA)==0)
free(sdata.dptr);
}
else
(*wdp->dfunc)( wdp->fh, skey.dptr, NULL );
}
else
fprintf( wdp->fh, "Key: %s\n", skey.dptr );
return;
}
static void
free_item( dl_Node_t *nptr )
{
/* Free the string and the node */
free( (char *)nptr->ln_Name );
free( nptr );
return;
}
static int
add_to_list( dl_List_t *lp, char *key )
{
dl_Node_t *nptr;
nptr = malloc( NODE_SIZE );
if (nptr)
{
dl_Init_Node( nptr, key, nptr );
dl_Add_Tail( lp, nptr );
}
return((nptr!=NULL));
}
int
gdbm_index_dump( FILE *fp,
struct gdbm_help *gptr,
int flags,
gdbm_index_dump_t dfunc )
{
GDBM_FILE gfile;
datum skey,nextkey;
int do_sort, do_hdr, do_data;
struct walk_det walk_details;
dl_List_t sort_list;
dl_Node_t tnode;
gfile = *gptr->file_ptr;
do_hdr = (flags & GDBM_IDUMP_HDR);
do_sort = (flags & GDBM_IDUMP_SORT);
do_data = (flags & GDBM_IDUMP_DATA);
dl_Init_List( &sort_list, 0 );
walk_details.fh = fp;
walk_details.gfile = gfile;
walk_details.dfunc = dfunc;
walk_details.do_data = do_data;
walk_details.flags = flags;
if (do_hdr)
fprintf( fp, " Index dump of %s\n", gptr->name );
skey = gdbm_firstkey ( gfile );
while ( skey.dptr )
{
if (do_sort)
{
add_to_list( &sort_list, skey.dptr );
}else
{
tnode.ln_Name = skey.dptr;
disp_item( &tnode, &walk_details );
}
nextkey = gdbm_nextkey ( gfile, skey );
if (do_sort==0)
free ( skey.dptr );
skey = nextkey;
};
if (do_sort)
{
dl_sort_n( &sort_list );
dl_Walk_List( &sort_list, (dl_Walk_List_t)disp_item, &walk_details );
dl_Walk_List( &sort_list, (dl_Walk_List_t)free_item, NULL );
}
if (do_hdr)
fprintf( fp, "\n" );
return(0);
}
/* -- End of File -- */

View file

@ -1,179 +0,0 @@
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* System :
* Subsystem :
* Module :
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <gdbm.h>
#include <mplib1/dl_list.h>
#include <mplib1/fprintfile.h>
#include <mplib1/cfg_file.h>
#include <mplib1/gdbm_util.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
struct walk_det
{
FILE *fh;
GDBM_FILE gfile;
int (* dfunc)(FILE *, char *, void *);
int do_data;
int flags;
};
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */
static void
disp_item( dl_Node_t *nptr, struct walk_det *wdp )
{
datum skey,sdata;
int rv;
skey.dptr = (char *)nptr->ln_Name;
skey.dsize = (int)strlen( nptr->ln_Name ) + 1;
if (wdp->dfunc)
{
if (wdp->do_data)
{
sdata = gdbm_fetch( wdp->gfile, skey );
rv = (*wdp->dfunc)( wdp->fh, skey.dptr, sdata.dptr );
if (sdata.dptr && (rv & GDBM_IDUMP_KEEP_DATA)==0)
free(sdata.dptr);
}
else
(*wdp->dfunc)( wdp->fh, skey.dptr, NULL );
}
else
fprintf( wdp->fh, "Key: %s\n", skey.dptr );
return;
}
static void
free_item( dl_Node_t *nptr )
{
/* Free the string and the node */
free( (char *)nptr->ln_Name );
free( nptr );
return;
}
static int
add_to_list( dl_List_t *lp, char *key )
{
dl_Node_t *nptr;
nptr = malloc( NODE_SIZE );
if (nptr)
{
dl_Init_Node( nptr, key, nptr );
dl_Add_Tail( lp, nptr );
}
return((nptr!=NULL));
}
int
gdbm_index_dump( FILE *fp,
struct gdbm_help *gptr,
int flags,
gdbm_index_dump_t dfunc )
{
GDBM_FILE gfile;
datum skey,nextkey;
int do_sort, do_hdr, do_data;
struct walk_det walk_details;
dl_List_t sort_list;
dl_Node_t tnode;
gfile = *gptr->file_ptr;
do_hdr = (flags & GDBM_IDUMP_HDR);
do_sort = (flags & GDBM_IDUMP_SORT);
do_data = (flags & GDBM_IDUMP_DATA);
dl_Init_List( &sort_list, 0 );
walk_details.fh = fp;
walk_details.gfile = gfile;
walk_details.dfunc = dfunc;
walk_details.do_data = do_data;
walk_details.flags = flags;
if (do_hdr)
fprintf( fp, " Index dump of %s\n", gptr->name );
skey = gdbm_firstkey ( gfile );
while ( skey.dptr )
{
if (do_sort)
{
add_to_list( &sort_list, skey.dptr );
}else
{
tnode.ln_Name = skey.dptr;
disp_item( &tnode, &walk_details );
}
nextkey = gdbm_nextkey ( gfile, skey );
if (do_sort==0)
free ( skey.dptr );
skey = nextkey;
};
if (do_sort)
{
dl_sort_n( &sort_list );
dl_Walk_List( &sort_list, (dl_Walk_List_t)disp_item, &walk_details );
dl_Walk_List( &sort_list, (dl_Walk_List_t)free_item, NULL );
}
if (do_hdr)
fprintf( fp, "\n" );
return(0);
}
/* -- End of File -- */

View file

@ -13,10 +13,13 @@ include ../make_site
endif
ifndef MAJOR_VERSION
MAJOR_VERSION=4
MAJOR_VERSION=5
endif
ifndef MINOR_VERSION
MINOR_VERSION=2
MINOR_VERSION=0
endif
ifndef MAJMIN_VERSION
MAJMIN_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)
endif
ifndef LIBDIR
@ -61,13 +64,10 @@ else
GDBM_LIB_DIR=.
endif
MPLIB1=$(LIBDIR)/libmplib1.a
MPLIB1_LINK= -L$(LIBDIR) -lmplib1
MPLIB1BPO=$(LIBDIR)/libmplib1bpo.a
MPLIB1BPO_LINK= -L$(LIBDIR) -lmplib1bpo
MPLIB1GDBM=$(LIBDIR)/libmplib1gdbm.a
MPLIB1GDBM_LINK= -L$(LIBDIR) -lmplib1gdbm
@ -80,9 +80,6 @@ ifndef DEPFLAGS
DEPFLAGS=-M
endif
ifndef CXREF
CXREF=cxref
endif
ifndef DEPENDRULE
%.d: %.c
@ -103,10 +100,6 @@ ifeq ($(CC),gcc)
-Wconversion -Waggregate-return -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations \
-Wnested-externs -fPIC
# CFLAGS += -Wall -Wcast-qual -Wcast-align -Wwrite-strings \
# -Wconversion -Waggregate-return -Wstrict-prototypes \
# -Wmissing-prototypes -Wmissing-declarations \
# -Wredundant-decls -Wnested-externs -fPIC
else
ifdef NCR3000
CFLAGS += -Hnocopyr -K PIC

605
mplib1/bpo.h Normal file
View file

@ -0,0 +1,605 @@
#ifndef MPLIB1_BPO
#define MPLIB1_BPO
/*
*******************************************************************************
** Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
*******************************************************************************
*/
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#define GOFF(base,obj) ((off_t)((const char *)(obj) - (const char *)(base)))
#define GPTR(base,off) ((void *)((char *)(base) + off))
#define GRPTR(obj,off) (void *)((off)?(void *)((char *)(obj) - \
*((off_t *)(obj)) + (off_t)(off)):NULL)
#ifndef BIT
#define BIT(x) (1<<(x))
#endif
#define SODB_USE_SHALLOC BIT(0)
#define SODB_USE_RESOURCES BIT(0)
#define SODB_USE_LIMIT BIT(1)
#define SODB_ADD_HEADER BIT(2)
#define SODB_BASE_NAME "SODB Base"
#define CHECK_ALL_RESOURCES 0
#ifndef SODB_MMAP_PRIV
#define SODB_MMAP_PRIV 0600
#endif
#ifndef SODB_IPC_PRIV
#define SODB_IPC_PRIV 0600
#endif
#define SODB_RES_NO_ALLOC_NM BIT(0)
#ifndef SODB_READ_CONFIG
#define SODB_READ_CONFIG BIT(0)
#endif
typedef int (*Validate_Resource_t)( const char * res_name,
off_t res_off,
void *param1 );
typedef void (*Fetch_SODB_Resource_t)( void *);
enum bpo_lock_mode
{
BPO_L_READ,
BPO_L_WRITE
};
#define BPO_PID_F_DEBUG BIT(0)
#define SHM_INHERIT_GROUP BIT(0)
#define SHM_INHERIT_PROGRAM BIT(1)
#define SHM_AUTOMAGIC_PIPE BIT(2)
#define SHM_CHECK_ALL_PROCESSES 1
#define SHM_CHECK_THIS_PROCESS 2
#define SHM_CHECK_DEAD_PROCESSES 3
/* Return values to the validate processes inform call */
#define SHM_LEAVE_PROC 0
#define SHM_DELETE_PROC 1
#ifndef PID_STR_LEN
#define PID_STR_LEN 12
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#define Q_NM_UNKNOWN 0
#define Q_NM_NONE 1
#define Q_NM_PIPE 2
#ifndef BIT
#define BIT(x) (1<<(x))
#endif
#define Q_SOLE_READER BIT(0)
#define Q_MULTI_READ BIT(1)
#define Q_WRITER BIT(2)
#define Q_PERSISTENT BIT(4)
#define Q_DELETED BIT(8)
#define Q_DEBUG BIT(15)
#define Q_CHECK_ALL_QUEUES 1
#define Q_CHECK_THIS_QUEUE 2
#define Q_CHECK_DEAD_QUEUES 3
/* Return values to the validate processes inform call */
#define Q_LEAVE_QUEUE 0
#define Q_DELETE_QUEUE 1
/* ------------------------------------------------------------------
bpo lock structures
------------------------------------------------------------------ */
struct bpo_thread_lock
{
pthread_mutex_t mp;
pthread_mutexattr_t mattr;
};
typedef struct bpo_thread_lock b_lock_t;
struct use_count_lock
{
b_lock_t ucl_b_lock;
int ucl_count;
};
struct bpo_fl_lock
{
b_lock_t bpo_fl_lock;
int r_cnt;
int w_cnt;
};
struct bpo_pid_lock
{
b_lock_t bpo_pid_lock;
pid_t lock_pid;
int pid_cnt;
b_lock_t bpo_unlock;
pid_t unlock_pid;
int flags;
struct timeval lock_time;
struct timeval lock_duration;
};
/* ------------------------------------------------------------------
bpo_list structures
These structures should never be directly modified.
The structures are included here so they can be incorporated
into larger application structures
------------------------------------------------------------------ */
#define BPO_NODE_TYPE bpo_Node_s
#define BPO_LIST_TYPE bpo_List_s
struct BPO_NODE_TYPE
{
off_t lno_me;
off_t lno_Succ;
off_t lno_Pred;
off_t lno_Name;
off_t lno_Item;
off_t lno_List;
int lno_Flags;
};
struct BPO_LIST_TYPE
{
off_t lno_me;
struct BPO_NODE_TYPE lno_Head;
struct BPO_NODE_TYPE lno_Tail;
int lno_Flags;
int lno_count;
unsigned long lno_serial_nbr;
#ifndef LN_IGNORECASE
#define LN_IGNORECASE BIT(0)
#endif
struct bpo_pid_lock lno_Pid_Lock;
};
typedef struct BPO_NODE_TYPE bpo_Node_t;
typedef struct BPO_LIST_TYPE bpo_List_t;
#define BPO_NODE_SIZE sizeof(bpo_Node_t)
#define BPO_LIST_SIZE sizeof(bpo_List_t)
#define BPO_REMOVE_NODES BIT(0)
#define BPO_FREE_NODES BIT(1)
#define BPO_FREE_ITEMS BIT(2)
#define BPO_FREE_NAMES BIT(3)
typedef void (*bpo_Walk_List_t) ( void *, void * );
typedef int (*bpo_Walk_List2_t) ( void *, void * );
typedef int (*bpo_Walk_List_N_t) ( bpo_Node_t *, void * );
typedef int (*bpo_Work_List_t) ( bpo_List_t *, void * );
typedef int (*bpo_Work_List2_t) ( bpo_List_t *, void *, void * );
typedef int (* bpo_sort_i_t)(const void *, const void *);
typedef int (*p_func_t)(FILE *,const char *,...);
/* ------------------------------------------------------------------
bpo_queue structures
------------------------------------------------------------------ */
/* The following is for convenience only. On no account should
user programs examine or modify this structure in any way.
Hell, for all you know, I've changed the structure internally.
Where would that get you ?
*/
struct bpo_Q
{
bpo_Node_t Q_Node;
bpo_List_t Q_List;
int Q_id;
int Q_Count;
int Q_max_count;
int Q_notify;
int Q_flags;
pid_t Q_sole_pid;
bpo_List_t Q_pid_r_list;
char Q_name[1];
};
struct bpo_Q_Mesg
{
bpo_Node_t Q_Node; /* Node for linking to Q */
off_t reply_Q; /* offset to reply Q */
int reply_id; /* id of reply Q (sanity check) */
};
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern void *
Create_SODB_mmap( const char *use_name, const char *mmap_name,
size_t msize, off_t moff, int flags );
extern void *
Create_SODB_shm( const char *use_name, const char *fname,
char id, size_t msize, int flags );
extern void *
Create_SODB_mmap_priv( const char *use_name,
const char *mmap_name,
size_t msize, off_t moff,
int flags, mode_t priv );
extern void *
Create_SODB_shm_priv( const char *use_name,
const char *fname,
char id, size_t msize,
int flags, mode_t priv );
extern int Detach_SODB_mmap( const void *hint );
extern int Detach_SODB_shm( const void *hint );
extern int Detach_SODB_lump( const void *hint );
extern void *Get_SODB_Pointer( const void *hint, off_t item_offset );
extern off_t Get_SODB_Offset( const void *vp );
extern mode_t Get_SODB_Privs( const void *vp );
extern void Do_SODB_Init( void );
extern void * Get_SODB_Base( const void *hint );
extern int SODB_in_Segment( const void *hint, const void *chk );
/* And the resource functions */
extern off_t
Add_SODB_Resource( void *object, const char *res_name );
extern void *
Find_SODB_Resource( const void *hint, const char *res_name );
extern void *
Fetch_SODB_Resource( const void *hint,
const char *name,
size_t s_size,
Fetch_SODB_Resource_t s_init );
/* and a resource list function */
extern int
Validate_Resources( const void * hint,
int p_which_procs,
Validate_Resource_t disp,
void *param1 );
/* For debugging use only, you have been warned ! */
extern void *
Attach_SODB_image( const char *fname );
extern void *
Attach_SODB_image_raw( const char *fname,
off_t foff,
size_t fsize );
/* ------------------------------------------------------------------
bpo memory allocation function definitions
------------------------------------------------------------------ */
extern void *shalloc( const void *hint, size_t size );
extern void shfree( void *ptr );
extern char *bpo_strdup( const void *hint, const char *s1 );
extern off_t bpo_strdup_offset( const void *hint, const char *s1 );
/* ------------------------------------------------------------------
bpo list handling function definitions
------------------------------------------------------------------ */
extern bpo_Node_t *
bpo_Init_Node( bpo_Node_t *node, const char *name, void *item );
extern bpo_List_t *
bpo_Init_List( bpo_List_t *list, int flags );
extern bpo_Node_t *
bpo_Remove_Node( bpo_Node_t *node1 );
extern bpo_Node_t *
bpo_Remove_Head( bpo_List_t *list );
extern bpo_Node_t *
bpo_Remove_Tail( bpo_List_t *list );
extern bpo_Node_t *
bpo_Add_Node_After( bpo_Node_t *node1, bpo_Node_t *node2 );
extern bpo_Node_t *
bpo_Add_Node_Before( bpo_Node_t *node1, bpo_Node_t *node2 );
extern bpo_Node_t *
bpo_Add_Head( bpo_List_t *list, bpo_Node_t *node );
extern bpo_Node_t *
bpo_Add_Tail( bpo_List_t *list, bpo_Node_t *node );
extern void *
bpo_Find_Item_By_Name( bpo_List_t *list, const char *name );
extern void *
bpo_Find_Next_Item_By_Name( bpo_Node_t *node, const char *name );
extern bpo_Node_t *
bpo_Find_Node_By_Item( bpo_List_t *list, void *item );
extern void *
bpo_Find_Item_From_Node( bpo_Node_t *node );
extern void *
bpo_Remove_Head_Item( bpo_List_t *list );
extern void *
bpo_Remove_Tail_Item( bpo_List_t *list );
extern void
bpo_Walk_List( bpo_List_t *l_ptr,
bpo_Walk_List_t disp,
void *param );
extern int
bpo_Walk_List2( bpo_List_t *l_ptr,
bpo_Walk_List2_t disp,
void *param );
extern int
bpo_Walk_List_N( bpo_List_t *l_ptr,
bpo_Walk_List_N_t disp,
void *param );
extern int
bpo_Work_List( bpo_List_t *list,
bpo_Work_List_t work,
void *param );
extern int
bpo_Work_List2( bpo_List_t *list,
bpo_Work_List2_t work,
void *param1, void *param2 );
extern int
bpo_May_Work_List( bpo_List_t *list,
unsigned long *last_ser_nbr,
bpo_Work_List_t work,
void *param );
extern int
bpo_May_Work_List2( bpo_List_t *list,
unsigned long *last_ser_nbr,
bpo_Work_List2_t work,
void *param1, void *param2 );
extern unsigned long bpo_Touch_List( bpo_List_t *list );
extern int bpo_Any_In_List( bpo_List_t *list );
extern int
bpo_Transfer_Lists( bpo_List_t *fl_ptr, bpo_List_t *tl_ptr );
extern int
bpo_free_list_contents( bpo_List_t *blp );
extern void
bpo_Free_Node( bpo_Node_t *bnp, int flags );
extern void
bpo_Free_List( bpo_List_t *blp, int flags );
/* The following four functions are especially for the SODB initialisation code
The object is being created and is not yet in the list of shared objects
and so the base cannot be looked up and must be passed in explicitly
Also, the Add_ functions assume that the nodes being added
are new & clean
*/
extern bpo_Node_t *
bpo_Init_Node_Raw( bpo_Node_t *node,
const void *base,
const char *name,
const void *item );
extern bpo_List_t *
bpo_Init_List_Raw( bpo_List_t *list, const void *base, int flags );
extern bpo_Node_t *
bpo_Add_Head_Raw( bpo_List_t *list, const void *base, bpo_Node_t *node );
extern bpo_Node_t *
bpo_Add_Tail_Raw( bpo_List_t *list, const void *base, bpo_Node_t *node );
/* And a couple of sort functions. */
extern int
bpo_sort_i( bpo_List_t *sort_list, bpo_sort_i_t compar );
extern int
bpo_sort_n( bpo_List_t *sort_list );
/* And for the suspicious */
extern int bpo_Validate_List( bpo_List_t *rlp );
extern int bpo_List_Chk( bpo_List_t *rlp,
p_func_t p_func,
FILE *fh );
extern int node_list_header( p_func_t p_func, FILE *fh );
extern int node_list_details( void *base, bpo_Node_t *bnp,
p_func_t p_func,
FILE *fh );
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern int bpo_nap_a_while( long secs, long usecs );
extern int bpo_take_a_nap( void );
extern long b_Lockval( b_lock_t *lockp );
extern void b_Init( b_lock_t *lockp );
extern int b_TryLock( b_lock_t *lockp );
extern void b_Lock( b_lock_t *lockp );
extern void b_Unlock( b_lock_t *lockp );
/* The following seven functions are now deprecated
and may be removed in a later release of library
*/
extern void bpo_RLock( struct bpo_fl_lock *bflp );
extern void bpo_WLock( struct bpo_fl_lock *bflp);
extern void bpo_RUnlock( struct bpo_fl_lock *bflp );
extern void bpo_WUnlock( struct bpo_fl_lock *bflp );
extern int bpo_RWLock( struct bpo_fl_lock *bflp );
extern void bpo_WRLock( struct bpo_fl_lock *bflp );
extern void bpo_Init_RWLock( struct bpo_fl_lock *bflp );
extern struct bpo_pid_lock *
bpo_Init_pid_lock( struct bpo_pid_lock *bplp,
struct timeval *udtp );
extern void bpo_pid_Lock( struct bpo_pid_lock *bplp );
extern void bpo_pid_Unlock( struct bpo_pid_lock *bplp );
extern int bpo_pid_set_flags( struct bpo_pid_lock *bplp, int set_bits );
extern int bpo_pid_clr_flags( struct bpo_pid_lock *bplp, int clr_bits );
extern int bpo_pid_get_flags( struct bpo_pid_lock *bplp );
/* ------------------------------------------------------------------
bpo function definitions
------------------------------------------------------------------ */
/* functions that deal exclusively with ourself */
extern int
Set_My_Proc_Details( const char *group_name,
const char *prog_name,
const char *fifo_prefix,
const char *fifo_name,
mode_t fifo_mode,
int flags );
#ifndef MPLIB1_BPO_INTERNAL
extern void * Get_My_Proc_Details( mode_t privs );
extern void * Check_My_Proc_Details( void );
#endif
extern ssize_t Wait_Process_Pipe( void );
extern int Get_Process_Pipe_fd( void );
/* Now related to a given segment */
extern int Remove_Shm_Process( const void *hint, const char *pid_str );
extern int Register_Process_Details( const void *hint );
extern int Deregister_Process_Details( const void *hint );
extern int Add_This_Pid_Resource( const void *hint, bpo_Node_t *nptr );
extern ssize_t Inform_Named_Pipe( const char *pipe_name );
extern ssize_t Inform_Process_Str( const void *hint, const char *pid_str );
extern ssize_t Inform_Process_Pid( const void *hint, pid_t pid );
extern int scan_dead_pipes( const char *dir_name );
/* And the higher level standard comms attached routine */
extern void *get_comms_hint( void );
extern void *comms_shm_attach( const char *config_name, int flags );
extern void comms_shm_detach( void );
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern int mpPutMsg( const char *q_name, bpo_Node_t *q_node );
extern void *mpGetMsg( const char *q_name, const void *hint );
extern int mpReplyMsg( struct bpo_Q_Mesg *mesp );
extern int mpPostMsg( const char *q_name,
struct bpo_Q_Mesg *mesp,
struct bpo_Q *reply_q );
extern void * mpFindQ( const char *q_name, const void *hint );
extern int mpCheckQ( const char *q_name, const void *hint );
extern int mpWaitQ( const char *name, const void *hint );
extern struct bpo_Q *
mpCreateQ( const void *hint, const char *q_name,
int q_max, int q_flags, int q_mech );
extern void *
bpo_send_and_get( const char *q_name,
struct bpo_Q_Mesg *bpo_msg,
struct bpo_Q *reply_q );
/* ------------------------------------------------------------------
daemon process function definition
------------------------------------------------------------------ */
extern int
bpo_daemon_sleep( int how_long );
#endif
/* -- End of File -- */

View file

@ -1,54 +0,0 @@
#ifndef MPLIB1_BPO_ALLOC
#define MPLIB1_BPO_ALLOC
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern void *shalloc( const void *hint, size_t size );
extern void shfree( void *ptr );
extern char *bpo_strdup( const void *hint, const char *s1 );
extern off_t bpo_strdup_offset( const void *hint, const char *s1 );
#endif
/* -- End of File -- */

View file

@ -1,56 +0,0 @@
#ifndef MPLIB1_BPO_DAEMON_H
#define MPLIB1_BPO_DAEMON_H
/*
*******************************************************************************
* Copyright (c) 1997 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#endif
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern int
bpo_daemon_sleep( int how_long );
#endif
/* -- End of File -- */

View file

@ -1,154 +0,0 @@
#ifndef MPLIB1_BPO_INIT
#define MPLIB1_BPO_INIT
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#endif
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#define GOFF(base,obj) ((off_t)((const char *)(obj) - (const char *)(base)))
#define GPTR(base,off) ((void *)((char *)(base) + off))
#define GRPTR(obj,off) (void *)((off)?(void *)((char *)(obj) - \
*((off_t *)(obj)) + (off_t)(off)):NULL)
#ifndef BIT
#define BIT(x) (1<<(x))
#endif
#define SODB_USE_SHALLOC BIT(0)
#define SODB_USE_RESOURCES BIT(0)
#define SODB_USE_LIMIT BIT(1)
#define SODB_ADD_HEADER BIT(2)
#define SODB_BASE_NAME "SODB Base"
#define CHECK_ALL_RESOURCES 0
#ifndef SODB_MMAP_PRIV
#define SODB_MMAP_PRIV 0600
#endif
#ifndef SODB_IPC_PRIV
#define SODB_IPC_PRIV 0600
#endif
#define SODB_RES_NO_ALLOC_NM BIT(0)
#ifndef SODB_READ_CONFIG
#define SODB_READ_CONFIG BIT(0)
#endif
typedef int (*Validate_Resource_t)( const char * res_name,
off_t res_off,
void *param1 );
typedef void (*Fetch_SODB_Resource_t)( void *);
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern void *
Create_SODB_mmap( const char *use_name, const char *mmap_name,
size_t msize, off_t moff, int flags );
extern void *
Create_SODB_shm( const char *use_name, const char *fname,
char id, size_t msize, int flags );
extern void *
Create_SODB_mmap_priv( const char *use_name,
const char *mmap_name,
size_t msize, off_t moff,
int flags, mode_t priv );
extern void *
Create_SODB_shm_priv( const char *use_name,
const char *fname,
char id, size_t msize,
int flags, mode_t priv );
extern int Detach_SODB_mmap( const void *hint );
extern int Detach_SODB_shm( const void *hint );
extern int Detach_SODB_lump( const void *hint );
extern void *Get_SODB_Pointer( const void *hint, off_t item_offset );
extern off_t Get_SODB_Offset( const void *vp );
extern mode_t Get_SODB_Privs( const void *vp );
extern void Do_SODB_Init( void );
extern void * Get_SODB_Base( const void *hint );
extern int SODB_in_Segment( const void *hint, const void *chk );
/* And the resource functions */
extern off_t
Add_SODB_Resource( void *object, const char *res_name );
extern void *
Find_SODB_Resource( const void *hint, const char *res_name );
extern void *
Fetch_SODB_Resource( const void *hint,
const char *name,
size_t s_size,
Fetch_SODB_Resource_t s_init );
/* and a resource list function */
extern int
Validate_Resources( const void * hint,
int p_which_procs,
Validate_Resource_t disp,
void *param1 );
/* For debugging use only, you have been warned ! */
extern void *
Attach_SODB_image( const char *fname );
extern void *
Attach_SODB_image_raw( const char *fname,
off_t foff,
size_t fsize );
#endif
/* -- End of File -- */

View file

@ -1,271 +0,0 @@
#ifndef MPLIB1_BPO_LIST
#define MPLIB1_BPO_LIST
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#include <stdio.h>
#endif
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#ifndef MPLIB1_BPO_LOCK
#include <mplib1/bpo_lock.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#ifndef BIT
#define BIT(n) (1<<(n))
#endif
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
#ifdef STRICT
#define BPO_NODE_TYPE bpo_Node_s
#define BPO_LIST_TYPE bpo_List_s
#else
#define BPO_NODE_TYPE bpo_Node
#define BPO_LIST_TYPE bpo_List
#endif
struct BPO_NODE_TYPE
{
off_t lno_me;
off_t lno_Succ;
off_t lno_Pred;
off_t lno_Name;
off_t lno_Item;
off_t lno_List;
int lno_Flags;
};
struct BPO_LIST_TYPE
{
off_t lno_me;
struct BPO_NODE_TYPE lno_Head;
struct BPO_NODE_TYPE lno_Tail;
int lno_Flags;
int lno_count;
unsigned long lno_serial_nbr;
#ifndef LN_IGNORECASE
#define LN_IGNORECASE BIT(0)
#endif
struct bpo_pid_lock lno_Pid_Lock;
};
typedef struct BPO_NODE_TYPE bpo_Node_t;
typedef struct BPO_LIST_TYPE bpo_List_t;
/* The following two typedefs are now deprecated
and may be removed in a later release of library
*/
#ifndef STRICT
typedef struct BPO_NODE_TYPE bpo_Node; /* deprecated */
typedef struct BPO_LIST_TYPE bpo_List; /* deprecated */
#endif
#define BPO_NODE_SIZE sizeof(bpo_Node_t)
#define BPO_LIST_SIZE sizeof(bpo_List_t)
#define BPO_REMOVE_NODES BIT(0)
#define BPO_FREE_NODES BIT(1)
#define BPO_FREE_ITEMS BIT(2)
#define BPO_FREE_NAMES BIT(3)
typedef void (*bpo_Walk_List_t) ( void *, void * );
typedef int (*bpo_Walk_List2_t) ( void *, void * );
typedef int (*bpo_Walk_List_N_t) ( bpo_Node_t *, void * );
typedef int (*bpo_Work_List_t) ( bpo_List_t *, void * );
typedef int (*bpo_Work_List2_t) ( bpo_List_t *, void *, void * );
typedef int (* bpo_sort_i_t)(const void *, const void *);
typedef int (*p_func_t)(FILE *,const char *,...);
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern bpo_Node_t *
bpo_Init_Node( bpo_Node_t *node, const char *name, void *item );
extern bpo_List_t *
bpo_Init_List( bpo_List_t *list, int flags );
extern bpo_Node_t *
bpo_Remove_Node( bpo_Node_t *node1 );
extern bpo_Node_t *
bpo_Remove_Head( bpo_List_t *list );
extern bpo_Node_t *
bpo_Remove_Tail( bpo_List_t *list );
extern bpo_Node_t *
bpo_Add_Node_After( bpo_Node_t *node1, bpo_Node_t *node2 );
extern bpo_Node_t *
bpo_Add_Node_Before( bpo_Node_t *node1, bpo_Node_t *node2 );
extern bpo_Node_t *
bpo_Add_Head( bpo_List_t *list, bpo_Node_t *node );
extern bpo_Node_t *
bpo_Add_Tail( bpo_List_t *list, bpo_Node_t *node );
extern void *
bpo_Find_Item_By_Name( bpo_List_t *list, const char *name );
extern void *
bpo_Find_Next_Item_By_Name( bpo_Node_t *node, const char *name );
extern bpo_Node_t *
bpo_Find_Node_By_Item( bpo_List_t *list, void *item );
extern void *
bpo_Find_Item_From_Node( bpo_Node_t *node );
extern void *
bpo_Remove_Head_Item( bpo_List_t *list );
extern void *
bpo_Remove_Tail_Item( bpo_List_t *list );
extern void
bpo_Walk_List( bpo_List_t *l_ptr,
bpo_Walk_List_t disp,
void *param );
extern int
bpo_Walk_List2( bpo_List_t *l_ptr,
bpo_Walk_List2_t disp,
void *param );
extern int
bpo_Walk_List_N( bpo_List_t *l_ptr,
bpo_Walk_List_N_t disp,
void *param );
extern int
bpo_Work_List( bpo_List_t *list,
bpo_Work_List_t work,
void *param );
extern int
bpo_Work_List2( bpo_List_t *list,
bpo_Work_List2_t work,
void *param1, void *param2 );
extern int
bpo_May_Work_List( bpo_List_t *list,
unsigned long *last_ser_nbr,
bpo_Work_List_t work,
void *param );
extern int
bpo_May_Work_List2( bpo_List_t *list,
unsigned long *last_ser_nbr,
bpo_Work_List2_t work,
void *param1, void *param2 );
extern unsigned long bpo_Touch_List( bpo_List_t *list );
extern int bpo_Any_In_List( bpo_List_t *list );
extern int
bpo_Transfer_Lists( bpo_List_t *fl_ptr, bpo_List_t *tl_ptr );
extern int
bpo_free_list_contents( bpo_List_t *blp );
extern void
bpo_Free_Node( bpo_Node_t *bnp, int flags );
extern void
bpo_Free_List( bpo_List_t *blp, int flags );
/* The following four functions are especially for the SODB initialisation code
The object is being created and is not yet in the list of shared objects
and so the base cannot be looked up and must be passed in explicitly
Also, the Add_ functions assume that the nodes being added
are new & clean
*/
extern bpo_Node_t *
bpo_Init_Node_Raw( bpo_Node_t *node,
const void *base,
const char *name,
const void *item );
extern bpo_List_t *
bpo_Init_List_Raw( bpo_List_t *list, const void *base, int flags );
extern bpo_Node_t *
bpo_Add_Head_Raw( bpo_List_t *list, const void *base, bpo_Node_t *node );
extern bpo_Node_t *
bpo_Add_Tail_Raw( bpo_List_t *list, const void *base, bpo_Node_t *node );
/* And a couple of sort functions. */
extern int
bpo_sort_i( bpo_List_t *sort_list, bpo_sort_i_t compar );
extern int
bpo_sort_n( bpo_List_t *sort_list );
/* And for the suspicious */
extern int bpo_Validate_List( bpo_List_t *rlp );
extern int bpo_List_Chk( bpo_List_t *rlp,
p_func_t p_func,
FILE *fh );
extern int node_list_header( p_func_t p_func, FILE *fh );
extern int node_list_details( void *base, bpo_Node_t *bnp,
p_func_t p_func,
FILE *fh );
#endif
/* -- End of File -- */

View file

@ -1,188 +0,0 @@
#ifndef MPLIB1_BPO_LOCK
#define MPLIB1_BPO_LOCK
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* #ifdef CXREF */
#include <sys/types.h>
/* #endif */
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
enum bpo_lock_mode
{
BPO_L_READ,
BPO_L_WRITE
};
#ifndef BIT
#define BIT(n) (1<<(n))
#endif
#define BPO_PID_F_DEBUG BIT(0)
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
/* Only one of the following ifdef blocks should be enabled */
#ifdef HAVE_PTHREADS
#define BPO_LOCK_MECH_DEFINED
#include <pthread.h>
struct bpo_thread_lock
{
pthread_mutex_t mp;
pthread_mutexattr_t mattr;
};
typedef struct bpo_thread_lock b_lock_t;
#ifndef STRICT
typedef struct bpo_thread_lock b_lock;
#endif
#endif
#ifdef HAVE_MSEM
#define BPO_LOCK_MECH_DEFINED
#include <sys/mman.h>
typedef msemaphore b_lock_t;
#ifndef STRICT
typedef msemaphore b_lock;
#endif
#endif
#ifdef HAVE_MUTEX
#define BPO_LOCK_MECH_DEFINED
#include <abi_mutex.h>
typedef abilock_t b_lock_t;
#ifndef STRICT
typedef abilock_t b_lock;
#endif
#endif
#if defined(HAVE_GCC_I386) || defined(HAVE_SVR4_I386) || \
defined(HAVE_SYS_ATOMIC) || defined(HAVE_SVR4_I386B)
#define BPO_LOCK_MECH_DEFINED
typedef volatile void * b_lock_t;
#ifndef STRICT
typedef volatile void * b_lock;
#endif
#endif
#ifndef BPO_LOCK_MECH_DEFINED
#error "BPO_LOCK_MECH not defined"
#endif
struct use_count_lock
{
b_lock_t ucl_b_lock;
int ucl_count;
};
struct bpo_fl_lock
{
b_lock_t bpo_fl_lock;
int r_cnt;
int w_cnt;
};
struct bpo_pid_lock
{
b_lock_t bpo_pid_lock;
pid_t lock_pid;
int pid_cnt;
b_lock_t bpo_unlock;
pid_t unlock_pid;
int flags;
struct timeval lock_time;
struct timeval lock_duration;
};
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern int bpo_nap_a_while( long secs, long usecs );
extern int bpo_take_a_nap( void );
extern long b_Lockval( b_lock_t *lockp );
extern void b_Init( b_lock_t *lockp );
extern int b_TryLock( b_lock_t *lockp );
extern void b_Lock( b_lock_t *lockp );
extern void b_Unlock( b_lock_t *lockp );
/* The following seven functions are now deprecated
and may be removed in a later release of library
*/
extern void bpo_RLock( struct bpo_fl_lock *bflp );
extern void bpo_WLock( struct bpo_fl_lock *bflp);
extern void bpo_RUnlock( struct bpo_fl_lock *bflp );
extern void bpo_WUnlock( struct bpo_fl_lock *bflp );
extern int bpo_RWLock( struct bpo_fl_lock *bflp );
extern void bpo_WRLock( struct bpo_fl_lock *bflp );
extern void bpo_Init_RWLock( struct bpo_fl_lock *bflp );
extern struct bpo_pid_lock *
bpo_Init_pid_lock( struct bpo_pid_lock *bplp,
struct timeval *udtp );
extern void bpo_pid_Lock( struct bpo_pid_lock *bplp );
extern void bpo_pid_Unlock( struct bpo_pid_lock *bplp );
extern int bpo_pid_set_flags( struct bpo_pid_lock *bplp, int set_bits );
extern int bpo_pid_clr_flags( struct bpo_pid_lock *bplp, int clr_bits );
extern int bpo_pid_get_flags( struct bpo_pid_lock *bplp );
#endif
/* -- End of File -- */

View file

@ -1,113 +0,0 @@
#ifndef MPLIB1_BPO_PROC
#define MPLIB1_BPO_PROC
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#ifndef MPLIB1_BPO_LOCK
#include <mplib1/bpo_lock.h>
#endif
#ifndef MPLIB1_BPO_LIST
#include <mplib1/bpo_list.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#ifndef BIT
#define BIT(n) (1<<(n))
#endif
#define SHM_INHERIT_GROUP BIT(0)
#define SHM_INHERIT_PROGRAM BIT(1)
#define SHM_AUTOMAGIC_PIPE BIT(2)
#define SHM_CHECK_ALL_PROCESSES 1
#define SHM_CHECK_THIS_PROCESS 2
#define SHM_CHECK_DEAD_PROCESSES 3
/* Return values to the validate processes inform call */
#define SHM_LEAVE_PROC 0
#define SHM_DELETE_PROC 1
#ifndef PID_STR_LEN
#define PID_STR_LEN 12
#endif
#ifndef SODB_READ_CONFIG
#define SODB_READ_CONFIG BIT(0)
#endif
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
/* functions that deal exclusively with ourself */
extern int
Set_My_Proc_Details( const char *group_name,
const char *prog_name,
const char *fifo_prefix,
const char *fifo_name,
mode_t fifo_mode,
int flags );
#ifndef MPLIB1_BPO_PROC_INTERNAL
extern void * Get_My_Proc_Details( mode_t privs );
extern void * Check_My_Proc_Details( void );
#endif
extern ssize_t Wait_Process_Pipe( void );
extern int Get_Process_Pipe_fd( void );
/* Now related to a given segment */
extern int Remove_Shm_Process( const void *hint, const char *pid_str );
extern int Register_Process_Details( const void *hint );
extern int Deregister_Process_Details( const void *hint );
extern int Add_This_Pid_Resource( const void *hint, bpo_Node_t *nptr );
extern ssize_t Inform_Named_Pipe( const char *pipe_name );
extern ssize_t Inform_Process_Str( const void *hint, const char *pid_str );
extern ssize_t Inform_Process_Pid( const void *hint, pid_t pid );
extern int scan_dead_pipes( const char *dir_name );
/* And the higher level standard comms attached routine */
extern void *get_comms_hint( void );
extern void *comms_shm_attach( const char *config_name, int flags );
extern void comms_shm_detach( void );
#endif
/* -- End of File -- */

View file

@ -1,145 +0,0 @@
#ifndef MPLIB1_BPO_QUEUE
#define MPLIB1_BPO_QUEUE
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
#ifndef MPLIB1_BPO_LOCK
#include <mplib1/bpo_lock.h>
#endif
#ifndef MPLIB1_BPO_LIST
#include <mplib1/bpo_list.h>
#endif
#ifndef MPLIB1_BPO_INIT
#include <mplib1/bpo_init.h>
#endif
#ifndef MPLIB1_BPO_ALLOC
#include <mplib1/bpo_alloc.h>
#endif
#ifndef MPLIB1_BPO_PROC
#include <mplib1/bpo_proc.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#define Q_NM_UNKNOWN 0
#define Q_NM_NONE 1
#define Q_NM_PIPE 2
#ifndef BIT
#define BIT(x) (1<<(x))
#endif
#define Q_SOLE_READER BIT(0)
#define Q_MULTI_READ BIT(1)
#define Q_WRITER BIT(2)
#define Q_PERSISTENT BIT(4)
#define Q_DELETED BIT(8)
#define Q_DEBUG BIT(15)
#define Q_CHECK_ALL_QUEUES 1
#define Q_CHECK_THIS_QUEUE 2
#define Q_CHECK_DEAD_QUEUES 3
/* Return values to the validate processes inform call */
#define Q_LEAVE_QUEUE 0
#define Q_DELETE_QUEUE 1
#ifndef PID_STR_LEN
#define PID_STR_LEN 12
#endif
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
/* The following is for convenience only. On no account should
user programs exmaine or modify this structure in any way.
Hell, for all you know, I've changed the structure internally.
Where would that get you ?
*/
struct bpo_Q
{
bpo_Node_t Q_Node;
bpo_List_t Q_List;
int Q_id;
int Q_Count;
int Q_max_count;
int Q_notify;
int Q_flags;
pid_t Q_sole_pid;
bpo_List_t Q_pid_r_list;
char Q_name[1];
};
struct bpo_Q_Mesg
{
bpo_Node_t Q_Node; /* Node for linking to Q */
off_t reply_Q; /* offset to reply Q */
int reply_id; /* id of reply Q (sanity check) */
};
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
extern int mpPutMsg( const char *q_name, bpo_Node_t *q_node );
extern void *mpGetMsg( const char *q_name, const void *hint );
extern int mpReplyMsg( struct bpo_Q_Mesg *mesp );
extern int mpPostMsg( const char *q_name,
struct bpo_Q_Mesg *mesp,
struct bpo_Q *reply_q );
extern void * mpFindQ( const char *q_name, const void *hint );
extern int mpCheckQ( const char *q_name, const void *hint );
extern int mpWaitQ( const char *name, const void *hint );
extern struct bpo_Q *
mpCreateQ( const void *hint, const char *q_name,
int q_max, int q_flags, int q_mech );
extern void *
bpo_send_and_get( const char *q_name,
struct bpo_Q_Mesg *bpo_msg,
struct bpo_Q *reply_q );
#endif
/* -- End of File -- */

View file

@ -5,37 +5,14 @@
* Copyright (c) 1997 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#ifndef MPLIB1_DL_LIST
#include <mplib1/dl_list.h>
#endif
/* ------------------------------------------------------------------
defines

View file

@ -5,34 +5,8 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <stdio.h>
#endif
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -5,38 +5,9 @@
* Copyright (c) 1997 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#endif
#ifndef MPLIB1_CONFIG
#include <mplib1/mplib1_config.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -5,30 +5,8 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -5,32 +5,10 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : Double-linked List/Node definitions
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -5,35 +5,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : External function definitions for Caching code
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <stdio.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -5,37 +5,10 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* System :
* Subsystem :
* Module :
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#include <stdio.h>
#endif
/* ------------------------------------------------------------------
Include files
@ -50,9 +23,9 @@
------------------------------------------------------------------ */
extern int do_hex_dump( FILE *fp, off_t curoff,
const char *where, int how_much );
const char *where, ssize_t how_much );
extern int hex_dump( FILE *fp, const char *where, int how_much );
extern int hex_dump( FILE *fp, const char *where, ssize_t how_much );
#endif
/* -- End of File -- */

View file

@ -5,34 +5,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <stdio.h>
#endif
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */

View file

@ -5,42 +5,15 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <stdio.h>
#endif
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#ifndef MPLIB1_TIMESTAMP
#include <mplib1/timestamp.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -5,39 +5,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* System :
* Subsystem :
* Module :
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#include <stdio.h>
#include <gdbm.h>
#endif
/* ------------------------------------------------------------------
defines

View file

@ -11,30 +11,9 @@
*
* Adapted into toolkit by Martin Poole mpoole@cix.compulink.co.uk
*
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
* $Source$
* $Author$
* $Date$
* $Revision$
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#endif
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -5,34 +5,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose :
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
#ifdef CXREF
#include <sys/types.h>
#endif
/* ------------------------------------------------------------------
defines

View file

@ -5,30 +5,8 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Code starts here
------------------------------------------------------------------ */

View file

@ -5,31 +5,8 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : Min List/Node definitions
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
struct Min_Node
{
struct Min_Node *ln_Succ;

View file

@ -5,30 +5,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : replacement for basename
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
extern char *mpbasename ( const char *full_name );

View file

@ -5,32 +5,8 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : replacement for strtok
* allows for concurrent analysis
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
extern char * mpstrtok( char *str, void **ftok, const char *seps );
#endif

View file

@ -5,33 +5,10 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* #ifdef CXREF */
#include <sys/types.h>
/* #endif */
/* ------------------------------------------------------------------
Include files

View file

@ -5,31 +5,9 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
* Purpose : Safe string functions
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
extern size_t Sstrlen( const char *str1 );
extern char *Sstrcpy( char *str1, const char *str2 );

View file

@ -5,34 +5,15 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <sys/time.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -5,34 +5,14 @@
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source$
* $Author$
* $Date$
* $Revision$
*
*******************************************************************************
*
* Change History
*
* $Log$
*
*******************************************************************************
*/
#ident "$Header$"
/* ------------------------------------------------------------------
Include files
------------------------------------------------------------------ */
#include <sys/time.h>
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */

View file

@ -1,198 +0,0 @@
#ifndef MPLIB1_VRE
#define MPLIB1_VRE
/*
*******************************************************************************
* Copyright (c) 1996 Martin Poole *
*******************************************************************************
**
** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
**
** Any changes to be made to this file should first be checked with
** mplib1 source control for library integrity.
**
** mplib1 source control can be reached at mplib1@quatermass.co.uk
**
*
* $Source: /home/cvs/cvsroot/onelan/onelan/src/mplib1/mplib1/vre.h,v $
* $Author: mpoole $
* $Date: 2002/10/07 09:37:44 $
* $Revision: 1.2 $
*
*******************************************************************************
*
* Change History
*
* $Log: vre.h,v $
* Revision 1.2 2002/10/07 09:37:44 mpoole
* Initial checkin of mplib1-3.1.0
*
* Revision 1.1 2002/10/07 09:37:00 mpoole
* Initial checkin of mplib1-3.1.0
*
*
*******************************************************************************
*/
#ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/mplib1/vre.h,v 1.2 2002/10/07 09:37:44 mpoole Exp $"
#ifdef CXREF
#include <sys/types.h>
#include <stdio.h>
#include <mplib1/dl_list.h>
#endif
/* vre2disp.c
vogon record editor. Display only version
********************************************************************
Copyright 1989,90,91 Martin Poole
Released for use by Y2 Computing Limited - 1989
Released for use by Perot Systems Europe Limited - 1995.
********************************************************************
*/
/* ------------------------------------------------------------------
defines
------------------------------------------------------------------ */
#define TO_COMPOSITE BIT(0)
#define TO_DISPLAY BIT(1)
#define TO_TYPEDEF BIT(2)
/* ------------------------------------------------------------------
structures
------------------------------------------------------------------ */
struct vre_disp_walk_item
{
FILE *fp;
const char *prefix;
const void *ptr;
const void *base;
int flags;
void *u_param;
struct vre_elem_obj *eop;
struct vre_type_obj *top;
};
typedef int (* vre_disp_t)( const void *, struct vre_disp_walk_item *dwip );
struct vre_type_obj
{
dl_Node_t to_Node;
int to_Flags;
vre_disp_t to_Disp;
size_t to_Size;
int to_Align;
dl_List_t to_Elems;
char to_Name[1]; /* with the strlen and this byte for the null */
};
struct vre_elem_obj
{
dl_Node_t eo_Node;
off_t eo_Offset;
char *eo_Name;
int eo_Arr_sz;
char eo_Type[1];
};
#define VRE_DISP_ELEM_NAMES BIT(0)
/* ------------------------------------------------------------------
function definitions
------------------------------------------------------------------ */
/* ---- vre_alloc ---- */
extern int
vre_Init_VRE( FILE *fp );
extern struct vre_type_obj *
vre_Find_Type( const char *nm );
extern int
vre_Add_Type( struct vre_type_obj *top );
extern struct vre_type_obj *
vre_Type_Synonym( const char *nm, const char *synm );
extern struct vre_type_obj *
vre_New_Type( const char *nm,
vre_disp_t disp,
size_t isize,
int ialign,
int add );
extern struct vre_elem_obj *
vre_New_Elem( const char *nm, const char *typ,
off_t offset, int arr_sz );
extern struct vre_elem_obj *
vre_Cat_New_Elem( struct vre_type_obj *ntyp,
const char *el_nm,
const char *el_typ,
int arr_sz );
extern int
vre_Get_Info( const char *el_nm,
size_t *isize,
int *ialign,
off_t *offset,
int *arr_sz,
int *flags );
extern off_t
vre_Get_Offset( const char *el_nm );
extern int
vre_Disp_Item( FILE *fp,
const char *type,
const char *name,
const void *ptr,
const void *base,
int flags,
void *u_param );
extern int
vre_Disp_Types( FILE *fp, int flags );
extern int
vre_Disp_Prefix( FILE *fp,
const void *ptr,
const void *base,
const char *prefix,
const char *suffix );
/* ---- vre_disp ---- */
extern int
vre_Init_Disp_Primitives( FILE *fp );
/* ---- vre_parse ---- */
extern int
vre_Parse_Line( FILE *fp, char *line );
extern int
vre_Parse_File( FILE *fp, const char *fname );
/* ---- vre_loop ---- */
extern int
vre_Interactive_Loop( char *line, FILE *fp, void *base );
extern int
vre_Get_ADDR( char *np, char **nnp );
#endif
/* -- End of File -- */

Some files were not shown because too many files have changed in this diff Show more