|
jabberd14 1.6.2
|
implements storage in XML files More...
Data Structures | |
| struct | cacher_struct |
| struct | xdbf_struct |
Defines | |
| #define | FILES_PRIME 509 |
Typedefs | |
| typedef struct cacher_struct * | cacher |
| typedef struct cacher_struct | _cacher |
| typedef struct xdbf_struct * | xdbf |
| typedef struct xdbf_struct | _xdbf |
Functions | |
| void | _xdb_file_purge (xht h, const char *key, void *data, void *arg) |
| result | xdb_file_purge (void *arg) |
| xmlnode | xdb_file_load (char *host, char *fname, xht cache) |
| void | _xdb_get_hashes (const char *filename, char digit01[3], char digit23[3]) |
| char * | xdb_file_full (int create, pool p, const char *spl, char const *host, const char *file, char const *ext, int use_subdirs) |
| result | xdb_file_phandler (instance i, dpacket p, void *arg) |
| void | xdb_file_cleanup (void *arg) |
| void | _xdb_convert_hostspool (pool p, const char *spoolroot, char *host) |
| void | xdb_convert_spool (const char *spoolroot) |
| void | xdb_file (instance i, xmlnode x) |
implements storage in XML files
The xdb_file module can be used to store XML in files - one per user. It is the traditional storage module of the jabberd14 server.
| #define FILES_PRIME 509 |
Referenced by xdb_file().
| typedef struct cacher_struct _cacher |
| typedef struct xdbf_struct _xdbf |
| typedef struct cacher_struct * cacher |
an item in the hash of cached data
| typedef struct xdbf_struct * xdbf |
xdb_file internal data
created for each instance of xdb_file
| void _xdb_convert_hostspool | ( | pool | p, |
| const char * | spoolroot, | ||
| char * | host | ||
| ) |
convert a spool directory for a given host from the old format to the new one which distributes the files over several subdirs
| p | the memory pool we can use |
| spoolroot | the root folder of the spool |
| host | the host for which we should try to convert |
References _xdb_get_hashes(), j_strcmp(), log_error, and log_notice().
Referenced by xdb_convert_spool().
| void _xdb_file_purge | ( | xht | h, |
| const char * | key, | ||
| void * | data, | ||
| void * | arg | ||
| ) |
xhash_walker function. Called for each cached content. Decides if it has to be expired.
| h | the xhash containing the cached content of xdb_file |
| key | key in the hash (filename of the cached file) |
| data | value in the hash (type is cacher) |
| arg | pointer to the xdb_file internal component instance data |
References xdbf_struct::cache, cacher_struct::file, cacher_struct::fname, cacher_struct::lastset, log_debug2, LOGT_STORAGE, xdbf_struct::timeout, xhash_zap(), xmlnode_free(), and ZONE.
Referenced by xdb_file_purge().
| void _xdb_get_hashes | ( | const char * | filename, |
| char | digit01[3], | ||
| char | digit23[3] | ||
| ) |
calculate the left-most four digits of the SHA-1 hash over a filename
| filename | the filename |
| digit01 | where to place the first two digits (size 3 chars!) |
| digit23 | where to place the next two digits (size 3 chars!) |
References crc32_r(), log_debug2, LOGT_STORAGE, and ZONE.
Referenced by _xdb_convert_hostspool(), and xdb_file_full().
| void xdb_convert_spool | ( | const char * | spoolroot | ) |
convert a spool directory from the old format to the new one which distributes the files over several subdirs
| spoolroot | the root folder of the spool |
References _xdb_convert_hostspool(), log_debug2, LOGT_STORAGE, pool_free(), pool_new, and ZONE.
load the xdb_file module
This gets called by the component loader of jabberd. It configures the instance, and registers all callbacks with jabberd.
References xdbf_struct::cache, FILES_PRIME, xdbf_struct::i, instance_struct::id, j_atoi(), jid_new(), log_debug2, log_error, LOGT_INIT, NS_JABBERD_CONFIG_XDBFILE, NS_JABBERD_XDB, o_DELIVER, instance_struct::p, pmalloco(), pool_cleanup(), pstrdup(), register_beat(), register_phandler(), xdbf_struct::sizelimit, xdbf_struct::spool, xdbf_struct::std_ns_prefixes, xdbf_struct::timeout, xdbf_struct::use_hashspool, xdb_cache(), xdb_convert_spool, xdb_file_cleanup(), xdb_file_phandler(), xdb_file_purge(), xdb_get(), xhash_new(), xhash_put(), xmlnode_free(), xmlnode_get_data(), xmlnode_get_list_item(), xmlnode_get_list_item_data(), xmlnode_get_tags(), xmlnode_pool(), xmlnode_serialize_string(), and ZONE.
| void xdb_file_cleanup | ( | void * | arg | ) |
cleanup xdb_file on server shutdown
| arg | the instance configuration of this component |
References xdbf_struct::cache, and xhash_free().
Referenced by xdb_file().
| char* xdb_file_full | ( | int | create, |
| pool | p, | ||
| const char * | spl, | ||
| char const * | host, | ||
| const char * | file, | ||
| char const * | ext, | ||
| int | use_subdirs | ||
| ) |
utility that generates the filename for a spool file
| create | true if the directory for the file should be generated |
| p | pool that should be used for string operations |
| spl | location for the spool root |
| host | host of the xdb request (the 'spool folder') |
| file | the basename of the xdb file |
| ext | the extension for the xdb file |
| use_subdirs | true if file should be located in subdirectories |
References _xdb_get_hashes(), log_error, and pstrdup().
load an XML file
| host | the host to load the file for (just for generating log messages) |
| fname | the filename of the file, that should be loaded |
| cache | a hash containing the cached files, that do not need to get loaded and parsed again |
References cacher_struct::file, cacher_struct::fname, j_strcmp(), cacher_struct::lastset, log_debug2, log_warn(), LOGT_STORAGE, NS_JABBERD_XDB, NS_SERVER, pmalloco(), pstrdup(), xhash_get(), xhash_put(), xmlnode_change_namespace(), xmlnode_file(), xmlnode_get_namespace(), xmlnode_new_tag_ns(), xmlnode_pool(), and ZONE.
handle packets (request) we get from the XML router inside of jabberd
This function is the heart of xdb_file. It gets the requests of jabberd14, processes them, and sends replies
| i | the instance data of this instance of the component |
| p | the dpacket that contains the request |
| arg | xdb_file internal data of this instance of xdb::file (type is xdbf) |
References xdbf_struct::cache, deliver(), dpacket_new(), xmppd::jabberid::get_domain(), xmppd::jabberid::get_node(), xmppd::jabberid::get_resource(), xmppd::jabberid::has_node(), xmppd::jabberid::has_resource(), dpacket_struct::host, dpacket_struct::id, j_strcmp(), j_strlen(), jid_full(), log_debug2, log_error, log_notice(), log_warn(), LOGT_DELIVER, LOGT_STORAGE, NS_JABBERD_XDB, dpacket_struct::p, pool_free(), pool_new, r_DONE, r_ERR, xdbf_struct::sizelimit, xdbf_struct::spool, xdbf_struct::std_ns_prefixes, xdbf_struct::timeout, xdbf_struct::use_hashspool, dpacket_struct::x, xdb_file_full, xdb_file_load, xhash_free(), xhash_from_xml(), xhash_zap(), xmlnode2file_limited(), xmlnode_free(), xmlnode_get_attrib(), xmlnode_get_attrib_ns(), xmlnode_get_data(), xmlnode_get_firstchild(), xmlnode_get_list_item(), xmlnode_get_tag(), xmlnode_get_tags(), xmlnode_hide(), xmlnode_hide_attrib_ns(), xmlnode_insert_tag_node(), xmlnode_insert_tag_ns(), xmlnode_put_attrib_ns(), xmlnode_serialize_string(), xmlnode_str(), and ZONE.
Referenced by xdb_file().
| result xdb_file_purge | ( | void * | arg | ) |
check for cached content, that has expired
This function gets called regulary as a function, that is registered with heartbeat. It removes expired content from the caching hash.
| arg | pointer to xdb_local component instance data (type is xdbf) |
References _xdb_file_purge(), xdbf_struct::cache, log_debug2, LOGT_STORAGE, r_DONE, xhash_walk(), and ZONE.
Referenced by xdb_file().
1.7.4