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

clientlib.c File Reference

client library functions More...

#include "config.h"
#include "defines.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <dlfcn.h>
#include <locale.h>
#include <pthread.h>
#include <pwd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include "semaphores.h"
#include "hashlib.h"
#include "utils.h"
#include "configparser.h"
#include "template.h"
#include "readline.h"
#include "charconvert.h"
#include "clientlib.h"

Go to the source code of this file.

Functions

void * reget_shm_ptr ()
void * get_shm_ptr ()
u_char * get_uconf_name (const u_char *uname)
int set_us_up_the_socket (void)
void generate_tpl_name (u_char buff[], int len, t_name_value *v)
void cf_set_variable (t_cf_template *tpl, t_name_value *cs, u_char *vname, const u_char *val, size_t len, int html)
void str_error_message (const u_char *err, FILE *out, int rd,...)
u_char * get_error_message (const u_char *err, int rd, size_t *len,...)
t_messagedelete_subtree (t_message *msg)
void cleanup_struct (t_cl_thread *thr)
u_char * get_link (u_int64_t tid, u_int64_t mid)
int has_answers (t_message *msg)
int handle_thread_list_posting (t_message *p, t_cf_hash *head, u_int64_t tid, int mode)
int handle_thread (t_cl_thread *thr, t_cf_hash *head, int mode)
int handle_posting_filters (t_cf_hash *head, t_cl_thread *thr, t_cf_template *tpl)
u_char * get_time (t_configuration *cfg, const u_char *symbol, int *len, time_t *date)
int cf_get_next_thread_through_sock (int sock, rline_t *tsd, t_cl_thread *thr, const u_char *tplname)
void * cf_get_next_thread_through_shm (void *shm_ptr, t_cl_thread *thr, const u_char *tplname)
int cf_get_message_through_sock (int sock, rline_t *tsd, t_cl_thread *thr, const u_char *tplname, u_int64_t tid, u_int64_t mid, int del)
int cf_get_message_through_shm (void *shm_ptr, t_cl_thread *thr, const u_char *tplname, u_int64_t tid, u_int64_t mid, int del)
int cf_register_mod_api_ent (const u_char *mod_name, const u_char *unique_identifier, t_mod_api func)
int cf_unregister_mod_api_ent (const u_char *unid)
t_mod_api cf_get_mod_api_ent (const u_char *unid)
void destroy_entry (void *elem)
void cf_init (void)
void cf_fini (void)

Variables

t_cf_hashGlobalValues = NULL
t_cf_hashAPIEntries = NULL
u_char ErrorString [50]


Detailed Description

client library functions

Author:
Christian Kruse, <cjk@wwwtech.de>
This file contains some functions and datatypes used in client modus, e.g. delete_subtree() or generate_tpl_name() or something like that

Definition in file clientlib.c.


Function Documentation

void cf_fini void   ) 
 

library destructor function

Definition at line 1197 of file clientlib.c.

int cf_get_message_through_shm void *  shm_ptr,
t_cl_thread thr,
const u_char *  tplname,
u_int64_t  tid,
u_int64_t  mid,
int  del
 

This function gets a message from the server

Parameters:
shm_ptr The pointer to the shared memory segment
thr The thread structure
tplname The template name
tid The thread id
mid The message id
del Boolean. If CF_KILL_DELETED, deleted messages will be killed. If CF_KEEP_DELETED, deleted messages will not be killed
Returns:
0 on success, -1 on failure

Definition at line 1002 of file clientlib.c.

int cf_get_message_through_sock int  sock,
rline_t tsd,
t_cl_thread thr,
const u_char *  tplname,
u_int64_t  tid,
u_int64_t  mid,
int  del
 

This function gets a message from the server

Parameters:
sock The socket
tsd The readline buffer
thr The thread structure
tplname The template name
tid The thread id
mid The message id
del Boolean. If CF_KILL_DELETED, deleted messages will be killed. If CF_KEEP_DELETED, deleted messages will not be killed
Returns:
0 on success, -1 on failure

Definition at line 947 of file clientlib.c.

t_mod_api cf_get_mod_api_ent const u_char *  unid  ) 
 

This function returns a pointer to an API hook function

Parameters:
unid The unique id of the API hook
Returns:
The pointer on success, NULL on failure

Definition at line 1158 of file clientlib.c.

void* cf_get_next_thread_through_shm void *  shm_ptr,
t_cl_thread thr,
const u_char *  tplname
 

This function reads the next thread from the shared memory segment

Parameters:
shm_ptr The pointer to the shared memory segment
thr The thread structure
tplname The path to the template
Returns:
NULL on failure, the modified pointer on success

Definition at line 809 of file clientlib.c.

int cf_get_next_thread_through_sock int  sock,
rline_t tsd,
t_cl_thread thr,
const u_char *  tplname
 

This function reads the next thread from a socket

Parameters:
sock The socket
tsd The readline buffer
thr The thread structure
tplname The template name

Definition at line 706 of file clientlib.c.

void cf_init void   ) 
 

library constructor function

Definition at line 1186 of file clientlib.c.

int cf_register_mod_api_ent const u_char *  mod_name,
const u_char *  unique_identifier,
t_mod_api  func
 

This function registeres a module API entry

Parameters:
mod_name The name of the module which registeres
unique_identifier A unique string to identify this API hook
func A pointer to the API function
Returns:
Returns 0 on success and -1 on failure (e.g. doubly entries)

Definition at line 1117 of file clientlib.c.

void cf_set_variable t_cf_template tpl,
t_name_value cs,
u_char *  vname,
const u_char *  val,
size_t  len,
int  html
 

This function sets a variable in a template. The value will be converted to the output charset

Parameters:
tpl The template object
cs The charset configuration entry
vname The variable name
val The template variable value
len The length of the value
html 1 if output should be html escaped, 0 if not

Definition at line 236 of file clientlib.c.

int cf_unregister_mod_api_ent const u_char *  unid  ) 
 

This function deletes a module API hook

Parameters:
unid The unique identifier of the API hook
Returns:
0 on success, -1 on failure (e.g. not found)

Definition at line 1144 of file clientlib.c.

void cleanup_struct t_cl_thread thr  ) 
 

This function frees the complete thread structure

Parameters:
thr The thread structure

Definition at line 492 of file clientlib.c.

t_message* delete_subtree t_message msg  ) 
 

This function deletes a posting subtree

Parameters:
msg The message structure
Returns:
Returns the next posting which has not been deleted

Definition at line 473 of file clientlib.c.

void destroy_entry void *  elem  ) 
 

private function for destroying a module api entry

Parameters:
elem The element

Definition at line 1175 of file clientlib.c.

void generate_tpl_name u_char  buff[],
int  len,
t_name_value v
 

This function generates a template name

Parameters:
buff The buffer in which the name should be saved
len The maximal length of the buffer
v The configuration entry of the template

Definition at line 223 of file clientlib.c.

u_char* get_error_message const u_char *  msg,
int  rd,
size_t *  len,
... 
 

This function returns an error message

Parameters:
msg The error string
rd The length of the error string
len A reference to a size_t-variable. This variable will be set to the length of the error message.
Returns:
NULL on error or a u_char pointer to the error message on success.
Attention:
You have to free() the returned u_char pointer!

Definition at line 389 of file clientlib.c.

u_char* get_link u_int64_t  tid,
u_int64_t  mid
 

This function generates a link to a thread

Parameters:
tid The thread id
mid The message id
Returns:
Returns NULL on failure or the link string on success

Definition at line 540 of file clientlib.c.

void* get_shm_ptr void   ) 
 

This function gets a pointer to the shared memory segment

Returns:
Returns NULL if segment does not exist, otherwise it returns the pointer

Definition at line 101 of file clientlib.c.

u_char* get_time t_configuration cfg,
const u_char *  symbol,
int *  len,
time_t *  date
 

This function creates a date string

Parameters:
cfg The configuration structure
symbol The configuration symbol. E.g. "DateFormatThreadView"
len In this variable the length of the string will be stored
date The date
Returns:
Returns NULL on failure or the string on success

Definition at line 678 of file clientlib.c.

u_char* get_uconf_name const u_char *  uname  ) 
 

This function tries to find the path to the user configuration file

Parameters:
uname The username
Returns:
NULL If the configuration file of the user could not be found, the full path if it could be found

Definition at line 145 of file clientlib.c.

int handle_posting_filters t_cf_hash head,
t_cl_thread thr,
t_cf_template tpl
 

This function runs POSTING_HANDLER plugins

Parameters:
head The CGI hash
thr The thread structure
tpl The template structure

Definition at line 651 of file clientlib.c.

int handle_thread t_cl_thread thr,
t_cf_hash head,
int  mode
 

This function runs VIEW_HANDLER plugins on a completely read thread.

Parameters:
thr Thread structure
head The CGI hash
mode 0 if in thread list, 1 if in thread view
Returns:
Returns the return value of the last plugin

Definition at line 632 of file clientlib.c.

int handle_thread_list_posting t_message p,
t_cf_hash head,
u_int64_t  tid,
int  mode
 

This function runs VIEW_LIST_HANDLER plugins

Parameters:
p The posting structure
head The CGI hash
tid The ID of the thread
mode 0 if in thread list, 1 if in thread view
Returns:
Returns the return value of the last plugin

Definition at line 606 of file clientlib.c.

int has_answers t_message msg  ) 
 

This function checks if a message has answers

Parameters:
msg The message structure
Returns:

Definition at line 563 of file clientlib.c.

void* reget_shm_ptr  ) 
 

This function re-gets the pointer to the shared memory segment

Returns:
Returns NULL if segment does not exist, otherwise it returns the pointer

Definition at line 75 of file clientlib.c.

int set_us_up_the_socket void   ) 
 

This function creates a socket handle an connects to the server

Returns:
-1 on error, the socket on success

Definition at line 186 of file clientlib.c.

void str_error_message const u_char *  msg,
FILE *  out,
int  rd,
... 
 

This function spits out an error message by a error string

Parameters:
msg The error string
out A file handle to write to. If NULL, stdout will be used
rd The length of the error string

Definition at line 278 of file clientlib.c.


Variable Documentation

t_cf_hash* APIEntries = NULL
 

In this hash the module API entries will be saved

Definition at line 63 of file clientlib.c.

u_char ErrorString[50]
 

contains error string in failure case

Definition at line 66 of file clientlib.c.

t_cf_hash* GlobalValues = NULL
 

In this hash global values can be saved, e.g. the username of logged in users

Definition at line 61 of file clientlib.c.


Generated on Sun Apr 25 16:37:39 2004 for Classic Forum by doxygen 1.3.5