summaryrefslogtreecommitdiff
path: root/src/core/wee-hdata.h
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-06-26 18:15:42 +0200
committerSebastien Helleu <flashcode@flashtux.org>2011-06-26 18:15:42 +0200
commit19bc95b96189de5a645adbe7b3487d5de1b835e7 (patch)
treeb68d3d98d3d643bc02fba218db7f7ed6cd07ea2c /src/core/wee-hdata.h
parent2a630031fd3c868733e3038c3e19ad4b53a8d8ce (diff)
downloadweechat-19bc95b96189de5a645adbe7b3487d5de1b835e7.zip
core: many improvements on hdata
New features: - add optional hdata name for variables in hdata - add plugin API functions: hdata_get_var_hdata - use hashtable to store hdata (created by WeeChat and plugins) - free hdata and infolists created by plugin on plugin unload - free all hdata on exit - add "free" option to command /debug hdata - remove hdata for hooks
Diffstat (limited to 'src/core/wee-hdata.h')
-rw-r--r--src/core/wee-hdata.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/core/wee-hdata.h b/src/core/wee-hdata.h
index ce9b96f4d..bf7e9fd47 100644
--- a/src/core/wee-hdata.h
+++ b/src/core/wee-hdata.h
@@ -20,40 +20,42 @@
#ifndef __WEECHAT_HDATA_H
#define __WEECHAT_HDATA_H 1
-#define HDATA_VAR(__struct, __name, __type) \
+#define HDATA_VAR(__struct, __name, __type, __hdata_name) \
hdata_new_var (hdata, #__name, offsetof (__struct, __name), \
- WEECHAT_HDATA_##__type);
+ WEECHAT_HDATA_##__type, __hdata_name)
#define HDATA_LIST(__name) hdata_new_list (hdata, #__name, &(__name));
struct t_hdata
{
- char *name; /* name of hdata */
+ struct t_weechat_plugin *plugin; /* plugin which created this hdata */
+ /* (NULL if created by WeeChat) */
struct t_hashtable *hash_var; /* hashtable with offset of vars */
char *var_prev; /* name of var with pointer to */
/* previous element in list */
char *var_next; /* name of var with pointer to */
/* next element in list */
+ struct t_hashtable *hash_var_hdata; /* hashtable with hdata names */
struct t_hashtable *hash_list; /* hashtable with pointers on lists */
/* (used to search objects) */
- struct t_hdata *prev_hdata; /* link to previous hdata */
- struct t_hdata *next_hdata; /* link to next hdata */
};
-extern struct t_hdata *weechat_hdata;
-extern struct t_hdata *last_weechat_hdata;
+extern struct t_hashtable *weechat_hdata;
extern char *hdata_type_string[];
-extern struct t_hdata *hdata_new (const char *hdata_name, const char *var_prev,
+extern struct t_hdata *hdata_new (struct t_weechat_plugin *plugin,
+ const char *hdata_name, const char *var_prev,
const char *var_next);
extern void hdata_new_var (struct t_hdata *hdata, const char *name, int offset,
- int type);
+ int type, const char *hdata_name);
extern void hdata_new_list (struct t_hdata *hdata, const char *name,
void *pointer);
extern int hdata_get_var_offset (struct t_hdata *hdata, const char *name);
extern int hdata_get_var_type (struct t_hdata *hdata, const char *name);
extern const char *hdata_get_var_type_string (struct t_hdata *hdata,
const char *name);
+extern const char *hdata_get_var_hdata (struct t_hdata *hdata,
+ const char *name);
extern void *hdata_get_var (struct t_hdata *hdata, void *pointer,
const char *name);
extern void *hdata_get_var_at_offset (struct t_hdata *hdata, void *pointer,
@@ -72,6 +74,10 @@ extern time_t hdata_time (struct t_hdata *hdata, void *pointer,
const char *name);
extern const char *hdata_get_string (struct t_hdata *hdata,
const char *property);
+extern void hdata_free_all_plugin (struct t_weechat_plugin *plugin);
+extern void hdata_free_all ();
extern void hdata_print_log ();
+extern void hdata_init ();
+extern void hdata_end ();
#endif /* __WEECHAT_HDATA_H */