MIDAS
Loading...
Searching...
No Matches
odb.cxx File Reference
#include "midas.h"
#include "msystem.h"
#include "mxml.h"
#include "git-revision.h"
#include "mstrlcpy.h"
#include <assert.h>
#include <signal.h>
#include <math.h>
#include "mjson.h"
Include dependency graph for odb.cxx:

Go to the source code of this file.

Classes

struct  db_err_msg_struct
 
struct  print_key_info_buf
 
struct  UPDATE_OPEN_RECORDS
 

Macros

#define CHECK_OPEN_RECORD   1
 
#define S(x)   printf("assert(sizeof(%-20s) == %6d);\n", #x, (int)sizeof(x))
 

Typedefs

typedef struct db_err_msg_struct db_err_msg
 

Functions

INT db_save_xml_key (HNDLE hDB, HNDLE hKey, INT level, MXML_WRITER *writer)
 
static void db_msg (db_err_msg **msg, INT message_type, const char *filename, INT line, const char *routine, const char *format,...) MATTRPRINTF(6
 
static void static void db_print_msg (const db_err_msg *msg)
 
static void db_flush_msg (db_err_msg **msg)
 
static INT db_find_key_locked (const DATABASE_HEADER *pheader, HNDLE hKey, const char *key_name, HNDLE *subhKey, db_err_msg **msg)
 
static const KEYdb_find_pkey_locked (const DATABASE_HEADER *pheader, const KEY *pkey, const char *key_name, int *pstatus, db_err_msg **msg)
 
static std::string db_get_path_locked (const DATABASE_HEADER *pheader, HNDLE hKey)
 
static std::string db_get_path_locked (const DATABASE_HEADER *pheader, const KEY *pkey)
 
static int db_scan_tree_locked (const DATABASE_HEADER *pheader, const KEY *pkey, int level, int(*callback)(const DATABASE_HEADER *, const KEY *, int, void *, db_err_msg **), void *info, db_err_msg **msg)
 
static int db_set_mode_wlocked (DATABASE_HEADER *, KEY *, WORD mode, int recurse, db_err_msg **)
 
static const KEYdb_resolve_link_locked (const DATABASE_HEADER *, const KEY *, int *pstatus, db_err_msg **)
 
static int db_notify_clients_locked (const DATABASE_HEADER *pheader, HNDLE hDB, HNDLE hKeyMod, int index, BOOL bWalk, db_err_msg **msg)
 
static int db_create_key_wlocked (DATABASE_HEADER *pheader, KEY *parentKey, const char *key_name, DWORD type, KEY **pnewkey, db_err_msg **msg)
 
static int db_set_value_wlocked (DATABASE_HEADER *pheader, HNDLE hDB, KEY *pkey_root, const char *key_name, const void *data, INT data_size, INT num_values, DWORD type, db_err_msg **msg)
 
static INT db_get_data_locked (DATABASE_HEADER *pheader, const KEY *pkey, int idx, void *data, INT *buf_size, DWORD type, db_err_msg **msg)
 
static INT db_set_data_wlocked (DATABASE_HEADER *pheader, KEY *pkey, const void *data, INT data_size, INT num_values, DWORD type, const char *caller, db_err_msg **msg)
 
static INT db_set_data_index_wlocked (DATABASE_HEADER *pheader, KEY *pkey, int idx, const void *data, INT data_size, DWORD type, const char *caller, db_err_msg **msg)
 
static INT db_check_set_data_locked (DATABASE_HEADER *pheader, const KEY *pkey, const void *data, INT data_size, INT num_values, DWORD type, const char *caller, db_err_msg **msg)
 
static INT db_check_set_data_index_locked (DATABASE_HEADER *pheader, const KEY *pkey, int idx, const void *data, INT data_size, DWORD type, const char *caller, db_err_msg **msg)
 
static int db_remove_open_record_wlocked (DATABASE *pdb, DATABASE_HEADER *pheader, HNDLE hKey)
 
static bool db_validate_key_offset (const DATABASE_HEADER *pheader, int offset)
 
static voidmalloc_key (DATABASE_HEADER *pheader, INT size, const char *caller)
 
static void free_key (DATABASE_HEADER *pheader, void *address, INT size)
 
static int validate_free_data (DATABASE_HEADER *pheader, int free_data)
 
static voidmalloc_data (DATABASE_HEADER *pheader, INT size)
 
static int free_data (DATABASE_HEADER *pheader, void *address, INT size, const char *caller)
 
static voidrealloc_data (DATABASE_HEADER *pheader, void *address, INT old_size, INT new_size, const char *caller)
 
charstrcomb (const char **list)
 
std::string strcomb1 (const char **list)
 
static void add_to_buf (struct print_key_info_buf *buf, const char *s)
 
static INT print_key_info (HNDLE hDB, HNDLE hKey, KEY *pkey, INT level, void *info)
 
static bool db_validate_data_offset (const DATABASE_HEADER *pheader, int offset)
 
INT db_show_mem (HNDLE hDB, char **result, BOOL verbose)
 
INT db_get_free_mem (HNDLE hDB, INT *key_size, INT *data_size)
 
static bool is_utf8 (const char *string)
 
static int db_validate_name (const char *name, int maybe_path, const char *caller_name, db_err_msg **msg)
 
static bool db_validate_hkey (const DATABASE_HEADER *pheader, HNDLE hKey)
 
static const KEYdb_get_pkey (const DATABASE_HEADER *pheader, HNDLE hKey, int *pstatus, const char *caller, db_err_msg **msg)
 
static const KEYLISTdb_get_pkeylist (const DATABASE_HEADER *pheader, HNDLE hKey, const KEY *pkey, const char *caller, db_err_msg **msg, bool kludge_repair=false)
 
static HNDLE db_pkey_to_hkey (const DATABASE_HEADER *pheader, const KEY *pkey)
 
static const KEYdb_get_parent (const DATABASE_HEADER *pheader, const KEY *pkey, int *pstatus, const char *caller, db_err_msg **msg)
 
static const KEYdb_enum_first_locked (const DATABASE_HEADER *pheader, const KEY *pkey, db_err_msg **msg)
 
static const KEYdb_enum_next_locked (const DATABASE_HEADER *pheader, const KEY *pdir, const KEY *pkey, db_err_msg **msg)
 
static bool db_validate_and_repair_key_wlocked (DATABASE_HEADER *pheader, int recurse, const char *path, HNDLE parenthkeylist, HNDLE hkey, KEY *pkey, db_err_msg **msg)
 
DATABASE_CLIENTdb_get_my_client_locked (DATABASE *pdb)
 
static void db_validate_sizes ()
 
static int db_update_open_record_wlocked (const DATABASE_HEADER *xpheader, const KEY *xpkey, int level, void *voidp, db_err_msg **msg)
 
static int db_validate_open_records_wlocked (DATABASE_HEADER *pheader, db_err_msg **msg)
 
static bool db_validate_and_repair_db_wlocked (DATABASE_HEADER *pheader, db_err_msg **msg)
 
INT db_open_database (const char *xdatabase_name, INT database_size, HNDLE *hDB, const char *client_name)
 
INT db_close_database (HNDLE hDB)
 
INT db_flush_database (HNDLE hDB)
 
INT db_close_all_databases (void)
 
INT db_set_client_name (HNDLE hDB, const char *client_name)
 
INT db_lock_database (HNDLE hDB)
 
INT db_allow_write_locked (DATABASE *p, const char *caller_name)
 
INT db_unlock_database (HNDLE hDB)
 
INT db_set_lock_timeout (HNDLE hDB, int timeout_millisec)
 
INT db_update_last_activity (DWORD millitime)
 
static void db_delete_client_wlocked (DATABASE_HEADER *pheader, int jclient, db_err_msg **msg)
 
static int db_delete_client_info_wlocked (HNDLE hDB, DATABASE_HEADER *pheader, int pid, db_err_msg **msg)
 
int db_delete_client_info (HNDLE hDB, int pid)
 
void db_cleanup (const char *who, DWORD actual_time, BOOL wrong_interval)
 
void db_cleanup2 (const char *client_name, int ignore_timeout, DWORD actual_time, const char *who)
 
void db_set_watchdog_params (DWORD timeout)
 
INT db_get_watchdog_info (HNDLE hDB, const char *client_name, DWORD *timeout, DWORD *last)
 
INT db_check_client (HNDLE hDB, HNDLE hKeyClient)
 
INT db_protect_database (HNDLE hDB)
 
const charextract_key (const char *key_list, char *key_name, int key_name_length)
 
BOOL equal_ustring (const char *str1, const char *str2)
 
BOOL ends_with_ustring (const char *str, const char *suffix)
 
BOOL strmatch (char *pattern, char *str)
 
void strarrayindex (char *odbpath, int *index1, int *index2)
 
INT db_create_key (HNDLE hDB, HNDLE hKey, const char *key_name, DWORD type)
 
INT db_create_link (HNDLE hDB, HNDLE hKey, const char *link_name, const char *destination)
 
INT db_delete_key1 (HNDLE hDB, HNDLE hKey, INT level, BOOL follow_links)
 
INT db_delete_key (HNDLE hDB, HNDLE hKey, BOOL follow_links)
 
INT db_find_key (HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
 
INT db_find_key1 (HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
 
INT db_find_link (HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
 
INT db_find_link1 (HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
 
INT db_find_keys (HNDLE hDB, HNDLE hKeyRoot, char *odbpath, std::vector< HNDLE > &hKeyVector)
 
INT db_get_parent (HNDLE hDB, HNDLE hKey, HNDLE *parenthKey)
 
INT db_scan_tree (HNDLE hDB, HNDLE hKey, INT level, INT(*callback)(HNDLE, HNDLE, KEY *, INT, void *), void *info)
 
int db_scan_tree_locked (const DATABASE_HEADER *pheader, const KEY *pkey, int level, int(*callback)(const DATABASE_HEADER *pheader, const KEY *, int, void *, db_err_msg **msg), void *info, db_err_msg **msg)
 
INT db_scan_tree_link (HNDLE hDB, HNDLE hKey, INT level, void(*callback)(HNDLE, HNDLE, KEY *, INT, void *), void *info)
 
INT db_get_path (HNDLE hDB, HNDLE hKey, char *path, INT buf_size)
 
std::string db_get_path (HNDLE hDB, HNDLE hKey)
 
static int db_find_open_records (HNDLE hDB, HNDLE hKey, KEY *key, INT level, void *xresult)
 
static int db_fix_open_records (HNDLE hDB, HNDLE hKey, KEY *key, INT level, void *xresult)
 
INT db_get_open_records (HNDLE hDB, HNDLE hKey, char *str, INT buf_size, BOOL fix)
 
INT db_set_value (HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT num_values, DWORD type)
 
INT db_set_value_index (HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT idx, DWORD type, BOOL trunc)
 
INT db_get_value (HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
 
INT db_enum_key (HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
 
INT db_enum_link (HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
 
INT db_get_next_link (HNDLE hDB, HNDLE hKey, HNDLE *subkey_handle)
 
static INT db_get_key_locked (const DATABASE_HEADER *pheader, HNDLE hKey, KEY *key, db_err_msg **msg)
 
INT db_get_key (HNDLE hDB, HNDLE hKey, KEY *key)
 
INT db_get_link (HNDLE hDB, HNDLE hKey, KEY *key)
 
INT db_get_key_time (HNDLE hDB, HNDLE hKey, DWORD *delta)
 
INT db_get_key_info (HNDLE hDB, HNDLE hKey, char *name, INT name_size, INT *type, INT *num_values, INT *item_size)
 
INT db_rename_key (HNDLE hDB, HNDLE hKey, const char *name)
 
INT db_reorder_key (HNDLE hDB, HNDLE hKey, INT idx)
 
INT db_get_data (HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, DWORD type)
 
INT db_get_link_data (HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, DWORD type)
 
INT db_get_data1 (HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, DWORD type, INT *num_values)
 
INT db_get_data_index (HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT idx, DWORD type)
 
INT db_set_data (HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
 
INT db_set_data1 (HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
 
INT db_set_link_data (HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
 
INT db_set_num_values (HNDLE hDB, HNDLE hKey, INT num_values)
 
INT db_set_data_index (HNDLE hDB, HNDLE hKey, const void *data, INT data_size, INT idx, DWORD type)
 
INT db_set_link_data_index (HNDLE hDB, HNDLE hKey, const void *data, INT data_size, INT idx, DWORD type)
 
INT db_set_data_index1 (HNDLE hDB, HNDLE hKey, const void *data, INT data_size, INT idx, DWORD type, BOOL bNotify)
 
INT db_merge_data (HNDLE hDB, HNDLE hKeyRoot, const char *name, void *data, INT data_size, INT num_values, INT type)
 
INT db_set_mode (HNDLE hDB, HNDLE hKey, WORD mode, BOOL recurse)
 
INT db_load (HNDLE hDB, HNDLE hKeyRoot, const char *filename, BOOL bRemote)
 
INT db_copy (HNDLE hDB, HNDLE hKey, char *buffer, INT *buffer_size, const char *path)
 
INT db_paste (HNDLE hDB, HNDLE hKeyRoot, const char *buffer)
 
static int db_paste_node (HNDLE hDB, HNDLE hKeyRoot, PMXML_NODE node)
 
INT db_paste_xml (HNDLE hDB, HNDLE hKeyRoot, const char *buffer)
 
INT db_copy_xml (HNDLE hDB, HNDLE hKey, char *buffer, int *buffer_size, bool header)
 
void name2c (char *str)
 
static void db_save_tree_struct (HNDLE hDB, HNDLE hKey, int hfile, INT level)
 
INT db_save (HNDLE hDB, HNDLE hKey, const char *filename, BOOL bRemote)
 
void xml_encode (char *src, int size)
 
INT db_save_xml (HNDLE hDB, HNDLE hKey, const char *filename)
 
void json_write (char **buffer, int *buffer_size, int *buffer_end, int level, const char *s, int quoted)
 
static void json_ensure_decimal_dot (char *str)
 
static void json_write_data (char **buffer, int *buffer_size, int *buffer_end, int level, const KEY *key, const char *p)
 
static void json_write_key (HNDLE hDB, HNDLE hKey, const KEY *key, const char *link_path, char **buffer, int *buffer_size, int *buffer_end)
 
static int db_save_json_key_obsolete (HNDLE hDB, HNDLE hKey, INT level, char **buffer, int *buffer_size, int *buffer_end, int save_keys, int follow_links, int recurse)
 
INT db_copy_json_array (HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
 
INT db_copy_json_index (HNDLE hDB, HNDLE hKey, int index, char **buffer, int *buffer_size, int *buffer_end)
 
static int json_write_bare_key (HNDLE hDB, HNDLE hLink, const KEY &link, char **buffer, int *buffer_size, int *buffer_end, int level, int flags, time_t timestamp, bool need_comma)
 
int json_write_bare_subdir (HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end, int level, int flags, time_t timestamp)
 
int EXPRT json_write_anything (HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end, int level, int must_be_subdir, int flags, time_t timestamp)
 
INT db_copy_json_ls (HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
 
INT db_copy_json_values (HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end, int omit_names, int omit_last_written, time_t omit_old_timestamp, int preserve_case)
 
INT db_copy_json_save (HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
 
INT db_copy_json_obsolete (HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end, int save_keys, int follow_links, int recurse)
 
INT db_save_json (HNDLE hDB, HNDLE hKey, const char *filename, int flags)
 
INT db_save_struct (HNDLE hDB, HNDLE hKey, const char *file_name, const char *struct_name, BOOL append)
 
INT db_save_string (HNDLE hDB, HNDLE hKey, const char *file_name, const char *string_name, BOOL append)
 
INT db_sprintf (char *string, const void *data, INT data_size, INT idx, DWORD type)
 
INT db_sprintff (char *string, const char *format, const void *data, INT data_size, INT idx, DWORD type)
 
INT db_sprintfh (char *string, const void *data, INT data_size, INT idx, DWORD type)
 
std::string db_sprintf (const void *data, INT data_size, INT idx, DWORD type)
 
std::string db_sprintff (const char *format, const void *data, INT data_size, INT idx, DWORD type)
 
std::string db_sprintfh (const void *data, INT data_size, INT idx, DWORD type)
 
INT db_sscanf (const char *data_str, void *data, INT *data_size, INT i, DWORD tid)
 
static void db_recurse_record_tree_locked (HNDLE hDB, const DATABASE_HEADER *pheader, const KEY *pkey, void **data, INT *total_size, INT base_align, INT *max_align, BOOL bSet, INT convert_flags, db_err_msg **msg)
 
static void db_recurse_record_tree_locked (HNDLE hDB, HNDLE hKey, void **data, INT *total_size, INT base_align, INT *max_align, BOOL bSet, INT convert_flags, db_err_msg **msg)
 
INT db_get_record_size (HNDLE hDB, HNDLE hKey, INT align, INT *buf_size)
 
INT db_get_record (HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT align)
 
INT db_get_record1 (HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT align, const char *rec_str)
 
static int db_parse_record (const char *rec_str, const char **out_rec_str, char *title, int title_size, char *key_name, int key_name_size, int *tid, int *n_data, int *string_length)
 
static int db_get_record2_read_element (HNDLE hDB, HNDLE hKey, const char *key_name, int tid, int n_data, int string_length, char *buf_start, char **buf_ptr, int *buf_remain, BOOL correct)
 
INT db_get_record2 (HNDLE hDB, HNDLE hKey, void *data, INT *xbuf_size, INT align, const char *rec_str, BOOL correct)
 
INT db_set_record (HNDLE hDB, HNDLE hKey, void *data, INT buf_size, INT align)
 
INT db_add_open_record (HNDLE hDB, HNDLE hKey, WORD access_mode)
 
INT db_remove_open_record (HNDLE hDB, HNDLE hKey, BOOL lock)
 
INT db_notify_clients (HNDLE hDB, HNDLE hKeyMod, int index, BOOL bWalk)
 
INT db_notify_clients_array (HNDLE hDB, HNDLE hKeys[], INT size)
 
static void merge_records (HNDLE hDB, HNDLE hKey, KEY *pkey, INT level, void *info)
 
static void check_open_keys (HNDLE hDB, HNDLE hKey, KEY *pkey, INT level, void *info)
 
INT db_create_record (HNDLE hDB, HNDLE hKey, const char *orig_key_name, const char *init_str)
 
INT db_check_record (HNDLE hDB, HNDLE hKey, const char *keyname, const char *rec_str, BOOL correct)
 
INT db_open_record (HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info)
 
INT db_open_record1 (HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info, const char *rec_str)
 
INT db_close_record (HNDLE hDB, HNDLE hKey)
 
INT db_close_all_records ()
 
INT db_update_record_local (INT hDB, INT hKeyRoot, INT hKey, int index)
 
INT db_update_record_mserver (INT hDB, INT hKeyRoot, INT hKey, int index, int client_socket)
 
INT db_send_changed_records ()
 
INT db_watch (HNDLE hDB, HNDLE hKey, void(*dispatcher)(INT, INT, INT, void *), void *info)
 
INT db_unwatch (HNDLE hDB, HNDLE hKey)
 
INT db_unwatch_all ()
 
INT EXPRT db_get_value_string (HNDLE hdb, HNDLE hKeyRoot, const char *key_name, int index, std::string *s, BOOL create, int create_string_length)
 
INT EXPRT db_set_value_string (HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const std::string *s)
 
INT EXPRT db_resize_string (HNDLE hdb, HNDLE hKeyRoot, const char *key_name, int num_values, int max_string_length)
 
MJsonNode * db_scl (HNDLE hDB)
 
MJsonNode * db_sor (HNDLE hDB, const char *root_path)
 

Variables

static DATABASE_database
 
static INT _database_entries = 0
 
static RECORD_LIST_record_list
 
static INT _record_list_entries = 0
 
static WATCH_LIST_watch_list
 
static INT _watch_list_entries = 0
 
static db_err_msg_last_error_message = NULL
 
static int _global_open_count
 

Macro Definition Documentation

◆ S

#define S (   x)    printf("assert(sizeof(%-20s) == %6d);\n", #x, (int)sizeof(x))