From b16ca3fa64fc1fa83d40d00d0090cc7fd27a9840 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Tue, 29 Nov 2011 20:15:56 +0100 Subject: initial plugin config framework, can't save multiple entries --- plugins/xchat-plugin.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'plugins/xchat-plugin.h') diff --git a/plugins/xchat-plugin.h b/plugins/xchat-plugin.h index 30b19295..e9dd1be8 100644 --- a/plugins/xchat-plugin.h +++ b/plugins/xchat-plugin.h @@ -137,6 +137,13 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); + int (*xchat_set_plugin_pref) (xchat_plugin *ph, + char *var, + char *value); + int (*xchat_get_plugin_pref) (xchat_plugin *ph, + char *var, + char *dest, + int dest_len); }; #endif @@ -292,6 +299,17 @@ void xchat_free (xchat_plugin *ph, void *ptr); +int +xchat_set_plugin_pref (xchat_plugin *ph, + char *var, + char *value); + +int +xchat_get_plugin_pref (xchat_plugin *ph, + char *var, + char *dest, + int dest_len); + #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE #define XCHAT_PLUGIN_HANDLE (ph) @@ -326,6 +344,8 @@ xchat_free (xchat_plugin *ph, #define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) +#define xchat_set_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref) +#define xchat_get_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref) #endif #ifdef __cplusplus -- cgit 1.4.1 From f9fa102690cef217b1565af35b34a727a9b58b33 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 30 Nov 2011 01:41:34 +0100 Subject: plugin config save is done via raw file access, now works with multiple vars --- plugins/xchat-plugin.h | 6 +- src/common/plugin.c | 143 ++++++++++++++++++++++++++++++++-------------- src/common/xchat-plugin.h | 6 +- 3 files changed, 105 insertions(+), 50 deletions(-) (limited to 'plugins/xchat-plugin.h') diff --git a/plugins/xchat-plugin.h b/plugins/xchat-plugin.h index e9dd1be8..c3606b19 100644 --- a/plugins/xchat-plugin.h +++ b/plugins/xchat-plugin.h @@ -142,8 +142,7 @@ struct _xchat_plugin char *value); int (*xchat_get_plugin_pref) (xchat_plugin *ph, char *var, - char *dest, - int dest_len); + char *dest); }; #endif @@ -307,8 +306,7 @@ xchat_set_plugin_pref (xchat_plugin *ph, int xchat_get_plugin_pref (xchat_plugin *ph, char *var, - char *dest, - int dest_len); + char *dest); #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE diff --git a/src/common/plugin.c b/src/common/plugin.c index ffdc013e..96510265 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -1578,38 +1578,104 @@ xchat_free (xchat_plugin *ph, void *ptr) int xchat_set_plugin_pref (xchat_plugin *pl, char *var, char *value) { - int fh; - char confname[32]; + FILE *fpIn; + int fhOut; + int prevConfig; + char confname[64]; + char confname_tmp[69]; + char buffer[512]; /* the same as in cfg_put_str */ + char buffer_tmp[512]; char *canon; canon = g_strdup (pl->name); canonalize_key (canon); sprintf (confname, "plugin_%s.conf", canon); g_free (canon); + sprintf (confname_tmp, "%s.new", confname); - /* partly borrowed from palette.c */ - fh = xchat_open_file (confname, O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE); - if (fh != -1) + fhOut = xchat_open_file (confname_tmp, O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE); + fpIn = xchat_fopen_file (confname, "r", 0); + + if (fhOut == -1) /* unable to save, abort */ { - cfg_put_str (fh, var, value); - close (fh); + return 0; + } + else if (fpIn == NULL) /* no previous config, no parsing */ + { + sprintf (buffer, "%s = %s\n", var, value); + write (fhOut, buffer, strlen (buffer)); + close (fhOut); - return 1; +#ifdef WIN32 + sprintf (buffer, "%s/%s", get_xdir_fs (), confname); + unlink (buffer); +#endif + + sprintf (buffer_tmp, "%s/%s", get_xdir_fs (), confname_tmp); + if (rename (buffer_tmp, buffer) == 0) + { + return 1; + } + else + { + return 0; + } } - else + else /* existing config, preserve settings and find & replace current var value if any */ { - return 0; + prevConfig = 0; + + while (fscanf (fpIn, " %[^\n]", &buffer) != EOF) /* read whole lines including whitespaces */ + { + sprintf (buffer_tmp, "%s ", var); /* add one space, this way it works against var - var2 checks too */ + + if (strncmp (buffer_tmp, buffer, strlen (var) + 1) == 0) /* given setting already exists */ + { + sprintf (buffer, "%s = %s\n", var, value); + prevConfig = 1; + } + else + { + strcat (buffer, "\n"); + } + + write (fhOut, buffer, strlen (buffer)); + } + + fclose (fpIn); + + if (!prevConfig) + { + sprintf (buffer, "%s = %s\n", var, value); + write (fhOut, buffer, strlen (buffer)); + } + + close (fhOut); + +#ifdef WIN32 + sprintf (buffer, "%s/%s", get_xdir_fs (), confname); + unlink (buffer); +#endif + + sprintf (buffer_tmp, "%s/%s", get_xdir_fs (), confname_tmp); + + if (rename (buffer_tmp, buffer) == 0) + { + return 1; + } + else + { + return 0; + } } } int -xchat_get_plugin_pref (xchat_plugin *pl, char *var, char *dest, int dest_len) +xchat_get_plugin_pref (xchat_plugin *pl, char *var, char *dest) { - //cfg_get_str (char *cfg, char *var, char *dest, int dest_len) int fh; int l; - char confname[32]; - //char *buffer; + char confname[64]; char *canon; char *cfg; struct stat st; @@ -1619,43 +1685,36 @@ xchat_get_plugin_pref (xchat_plugin *pl, char *var, char *dest, int dest_len) sprintf (confname, "plugin_%s.conf", canon); g_free (canon); - //buffer = (char*) malloc (dest_len); - /* partly borrowed from palette.c */ - fh = xchat_open_file (confname, O_RDONLY, 0, 0); + fh = xchat_open_file (confname, _O_RDONLY, 0, 0); - if (fh != -1) + if (fh == -1) { - fstat (fh, &st); - cfg = malloc (st.st_size + 1); - - if (cfg) - { - cfg[0] = '\0'; - l = read (fh, cfg, st.st_size); + return 0; + } - if (l >= 0) - { - cfg[l] = '\0'; - } + fstat (fh, &st); + cfg = malloc (st.st_size + 1); - if (!cfg_get_str (cfg, var, dest, dest_len)) - { - return 0; - } + if (!cfg) + { + return 0; + } - free (cfg); - } - else - { - return 0; - } + cfg[0] = '\0'; + l = read (fh, cfg, st.st_size); - close (fh); - return 1; + if (l >= 0) + { + cfg[l] = '\0'; } - else + + if (!cfg_get_str (cfg, var, dest, 512)) /* dest_len is the same as buffer size in set */ { return 0; } + + free (cfg); + close (fh); + return 1; } diff --git a/src/common/xchat-plugin.h b/src/common/xchat-plugin.h index e9dd1be8..c3606b19 100644 --- a/src/common/xchat-plugin.h +++ b/src/common/xchat-plugin.h @@ -142,8 +142,7 @@ struct _xchat_plugin char *value); int (*xchat_get_plugin_pref) (xchat_plugin *ph, char *var, - char *dest, - int dest_len); + char *dest); }; #endif @@ -307,8 +306,7 @@ xchat_set_plugin_pref (xchat_plugin *ph, int xchat_get_plugin_pref (xchat_plugin *ph, char *var, - char *dest, - int dest_len); + char *dest); #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE -- cgit 1.4.1 From 1567d326971811fd956042aaa43c932d247b4681 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 30 Nov 2011 08:28:19 +0100 Subject: plugin config - separate string and int functions --- plugins/xchat-plugin.h | 27 +++++++++++++++++++++------ src/common/plugin.c | 26 ++++++++++++++++++++++---- src/common/plugin.h | 12 ++++++++---- src/common/xchat-plugin.h | 27 +++++++++++++++++++++------ 4 files changed, 72 insertions(+), 20 deletions(-) (limited to 'plugins/xchat-plugin.h') diff --git a/plugins/xchat-plugin.h b/plugins/xchat-plugin.h index c3606b19..c278012a 100644 --- a/plugins/xchat-plugin.h +++ b/plugins/xchat-plugin.h @@ -137,12 +137,17 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - int (*xchat_set_plugin_pref) (xchat_plugin *ph, + int (*xchat_set_plugin_pref_str) (xchat_plugin *ph, char *var, char *value); - int (*xchat_get_plugin_pref) (xchat_plugin *ph, + int (*xchat_get_plugin_pref_str) (xchat_plugin *ph, char *var, char *dest); + int (*xchat_set_plugin_pref_int) (xchat_plugin *ph, + char *var, + int value); + int (*xchat_get_plugin_pref_int) (xchat_plugin *ph, + char *var); }; #endif @@ -299,15 +304,23 @@ xchat_free (xchat_plugin *ph, void *ptr); int -xchat_set_plugin_pref (xchat_plugin *ph, +xchat_set_plugin_pref_str (xchat_plugin *ph, char *var, char *value); int -xchat_get_plugin_pref (xchat_plugin *ph, +xchat_get_plugin_pref_str (xchat_plugin *ph, char *var, char *dest); +int +xchat_set_plugin_pref_int (xchat_plugin *ph, + char *var, + int value); +int +xchat_get_plugin_pref_int (xchat_plugin *ph, + char *var); + #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE #define XCHAT_PLUGIN_HANDLE (ph) @@ -342,8 +355,10 @@ xchat_get_plugin_pref (xchat_plugin *ph, #define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#define xchat_set_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref) -#define xchat_get_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref) +#define xchat_set_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_str) +#define xchat_get_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref_str) +#define xchat_set_plugin_pref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_int) +#define xchat_get_plugin_pref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref_int) #endif #ifdef __cplusplus diff --git a/src/common/plugin.c b/src/common/plugin.c index 41690038..bd960ea5 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -270,8 +270,10 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func, pl->xchat_send_modes = xchat_send_modes; pl->xchat_strip = xchat_strip; pl->xchat_free = xchat_free; - pl->xchat_set_plugin_pref = xchat_set_plugin_pref; - pl->xchat_get_plugin_pref = xchat_get_plugin_pref; + pl->xchat_set_plugin_pref_str = xchat_set_plugin_pref_str; + pl->xchat_get_plugin_pref_str = xchat_get_plugin_pref_str; + pl->xchat_set_plugin_pref_int = xchat_set_plugin_pref_int; + pl->xchat_get_plugin_pref_int= xchat_get_plugin_pref_int; /* incase new plugins are loaded on older xchat */ pl->xchat_dummy4 = xchat_dummy; @@ -1582,7 +1584,7 @@ xchat_free (xchat_plugin *ph, void *ptr) } int -xchat_set_plugin_pref (xchat_plugin *pl, char *var, char *value) +xchat_set_plugin_pref_str (xchat_plugin *pl, char *var, char *value) { FILE *fpIn; int fhOut; @@ -1678,7 +1680,7 @@ xchat_set_plugin_pref (xchat_plugin *pl, char *var, char *value) } int -xchat_get_plugin_pref (xchat_plugin *pl, char *var, char *dest) +xchat_get_plugin_pref_str (xchat_plugin *pl, char *var, char *dest) { int fh; int l; @@ -1728,3 +1730,19 @@ xchat_get_plugin_pref (xchat_plugin *pl, char *var, char *dest) close (fh); return 1; } + +int +xchat_set_plugin_pref_int (xchat_plugin *pl, char *var, int value) +{ + char buffer[12]; + sprintf (buffer, "%d", value); + return xchat_set_plugin_pref_str (pl, var, buffer); +} + +int +xchat_get_plugin_pref_int (xchat_plugin *pl, char *var) +{ + char buffer[12]; + xchat_get_plugin_pref_str (pl, var, buffer); + return atoi (buffer); +} diff --git a/src/common/plugin.h b/src/common/plugin.h index 6a2d62e2..f0ae6fc4 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -98,13 +98,17 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - int (*xchat_set_plugin_pref) (xchat_plugin *ph, + int (*xchat_set_plugin_pref_str) (xchat_plugin *ph, char *var, char *value); - int (*xchat_get_plugin_pref) (xchat_plugin *ph, + int (*xchat_get_plugin_pref_str) (xchat_plugin *ph, char *var, - char *dest, - int dest_len); + char *dest); + int (*xchat_set_plugin_pref_int) (xchat_plugin *ph, + char *var, + int value); + int (*xchat_get_plugin_pref_int) (xchat_plugin *ph, + char *var); void *(*xchat_dummy4) (xchat_plugin *ph); void *(*xchat_dummy3) (xchat_plugin *ph); void *(*xchat_dummy2) (xchat_plugin *ph); diff --git a/src/common/xchat-plugin.h b/src/common/xchat-plugin.h index c3606b19..c278012a 100644 --- a/src/common/xchat-plugin.h +++ b/src/common/xchat-plugin.h @@ -137,12 +137,17 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - int (*xchat_set_plugin_pref) (xchat_plugin *ph, + int (*xchat_set_plugin_pref_str) (xchat_plugin *ph, char *var, char *value); - int (*xchat_get_plugin_pref) (xchat_plugin *ph, + int (*xchat_get_plugin_pref_str) (xchat_plugin *ph, char *var, char *dest); + int (*xchat_set_plugin_pref_int) (xchat_plugin *ph, + char *var, + int value); + int (*xchat_get_plugin_pref_int) (xchat_plugin *ph, + char *var); }; #endif @@ -299,15 +304,23 @@ xchat_free (xchat_plugin *ph, void *ptr); int -xchat_set_plugin_pref (xchat_plugin *ph, +xchat_set_plugin_pref_str (xchat_plugin *ph, char *var, char *value); int -xchat_get_plugin_pref (xchat_plugin *ph, +xchat_get_plugin_pref_str (xchat_plugin *ph, char *var, char *dest); +int +xchat_set_plugin_pref_int (xchat_plugin *ph, + char *var, + int value); +int +xchat_get_plugin_pref_int (xchat_plugin *ph, + char *var); + #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE #define XCHAT_PLUGIN_HANDLE (ph) @@ -342,8 +355,10 @@ xchat_get_plugin_pref (xchat_plugin *ph, #define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#define xchat_set_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref) -#define xchat_get_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref) +#define xchat_set_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_str) +#define xchat_get_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref_str) +#define xchat_set_plugin_pref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_int) +#define xchat_get_plugin_pref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref_int) #endif #ifdef __cplusplus -- cgit 1.4.1 From b692172aa907243c7543015468da0fb077a9ac99 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 30 Nov 2011 08:59:40 +0100 Subject: refactoring --- plugins/xchat-plugin.h | 24 ++++++++++++------------ src/common/plugin.c | 20 ++++++++++---------- src/common/plugin.h | 8 ++++---- src/common/xchat-plugin.h | 24 ++++++++++++------------ src/version-script | 8 ++++---- 5 files changed, 42 insertions(+), 42 deletions(-) (limited to 'plugins/xchat-plugin.h') diff --git a/plugins/xchat-plugin.h b/plugins/xchat-plugin.h index c278012a..48e3bc02 100644 --- a/plugins/xchat-plugin.h +++ b/plugins/xchat-plugin.h @@ -137,16 +137,16 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - int (*xchat_set_plugin_pref_str) (xchat_plugin *ph, + int (*xchat_set_pluginpref_str) (xchat_plugin *ph, char *var, char *value); - int (*xchat_get_plugin_pref_str) (xchat_plugin *ph, + int (*xchat_get_pluginpref_str) (xchat_plugin *ph, char *var, char *dest); - int (*xchat_set_plugin_pref_int) (xchat_plugin *ph, + int (*xchat_set_pluginpref_int) (xchat_plugin *ph, char *var, int value); - int (*xchat_get_plugin_pref_int) (xchat_plugin *ph, + int (*xchat_get_pluginpref_int) (xchat_plugin *ph, char *var); }; #endif @@ -304,21 +304,21 @@ xchat_free (xchat_plugin *ph, void *ptr); int -xchat_set_plugin_pref_str (xchat_plugin *ph, +xchat_set_pluginpref_str (xchat_plugin *ph, char *var, char *value); int -xchat_get_plugin_pref_str (xchat_plugin *ph, +xchat_get_pluginpref_str (xchat_plugin *ph, char *var, char *dest); int -xchat_set_plugin_pref_int (xchat_plugin *ph, +xchat_set_pluginpref_int (xchat_plugin *ph, char *var, int value); int -xchat_get_plugin_pref_int (xchat_plugin *ph, +xchat_get_pluginpref_int (xchat_plugin *ph, char *var); #if !defined(PLUGIN_C) && defined(WIN32) @@ -355,10 +355,10 @@ xchat_get_plugin_pref_int (xchat_plugin *ph, #define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#define xchat_set_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_str) -#define xchat_get_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref_str) -#define xchat_set_plugin_pref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_int) -#define xchat_get_plugin_pref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref_int) +#define xchat_set_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_str) +#define xchat_get_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_str) +#define xchat_set_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_int) +#define xchat_get_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_int) #endif #ifdef __cplusplus diff --git a/src/common/plugin.c b/src/common/plugin.c index d1493ccd..b5b10a0e 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -270,10 +270,10 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func, pl->xchat_send_modes = xchat_send_modes; pl->xchat_strip = xchat_strip; pl->xchat_free = xchat_free; - pl->xchat_set_plugin_pref_str = xchat_set_plugin_pref_str; - pl->xchat_get_plugin_pref_str = xchat_get_plugin_pref_str; - pl->xchat_set_plugin_pref_int = xchat_set_plugin_pref_int; - pl->xchat_get_plugin_pref_int = xchat_get_plugin_pref_int; + pl->xchat_set_pluginpref_str = xchat_set_pluginpref_str; + pl->xchat_get_pluginpref_str = xchat_get_pluginpref_str; + pl->xchat_set_pluginpref_int = xchat_set_pluginpref_int; + pl->xchat_get_pluginpref_int = xchat_get_pluginpref_int; /* incase new plugins are loaded on older xchat */ pl->xchat_dummy4 = xchat_dummy; @@ -1584,7 +1584,7 @@ xchat_free (xchat_plugin *ph, void *ptr) } int -xchat_set_plugin_pref_str (xchat_plugin *pl, char *var, char *value) +xchat_set_pluginpref_str (xchat_plugin *pl, char *var, char *value) { FILE *fpIn; int fhOut; @@ -1680,7 +1680,7 @@ xchat_set_plugin_pref_str (xchat_plugin *pl, char *var, char *value) } int -xchat_get_plugin_pref_str (xchat_plugin *pl, char *var, char *dest) +xchat_get_pluginpref_str (xchat_plugin *pl, char *var, char *dest) { int fh; int l; @@ -1732,20 +1732,20 @@ xchat_get_plugin_pref_str (xchat_plugin *pl, char *var, char *dest) } int -xchat_set_plugin_pref_int (xchat_plugin *pl, char *var, int value) +xchat_set_pluginpref_int (xchat_plugin *pl, char *var, int value) { char buffer[12]; sprintf (buffer, "%d", value); - return xchat_set_plugin_pref_str (pl, var, buffer); + return xchat_set_pluginpref_str (pl, var, buffer); } int -xchat_get_plugin_pref_int (xchat_plugin *pl, char *var) +xchat_get_pluginpref_int (xchat_plugin *pl, char *var) { char buffer[12]; - if (xchat_get_plugin_pref_str (pl, var, buffer)) + if (xchat_get_pluginpref_str (pl, var, buffer)) { return atoi (buffer); } diff --git a/src/common/plugin.h b/src/common/plugin.h index f0ae6fc4..858ed815 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -98,16 +98,16 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - int (*xchat_set_plugin_pref_str) (xchat_plugin *ph, + int (*xchat_set_pluginpref_str) (xchat_plugin *ph, char *var, char *value); - int (*xchat_get_plugin_pref_str) (xchat_plugin *ph, + int (*xchat_get_pluginpref_str) (xchat_plugin *ph, char *var, char *dest); - int (*xchat_set_plugin_pref_int) (xchat_plugin *ph, + int (*xchat_set_pluginpref_int) (xchat_plugin *ph, char *var, int value); - int (*xchat_get_plugin_pref_int) (xchat_plugin *ph, + int (*xchat_get_pluginpref_int) (xchat_plugin *ph, char *var); void *(*xchat_dummy4) (xchat_plugin *ph); void *(*xchat_dummy3) (xchat_plugin *ph); diff --git a/src/common/xchat-plugin.h b/src/common/xchat-plugin.h index c278012a..48e3bc02 100644 --- a/src/common/xchat-plugin.h +++ b/src/common/xchat-plugin.h @@ -137,16 +137,16 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - int (*xchat_set_plugin_pref_str) (xchat_plugin *ph, + int (*xchat_set_pluginpref_str) (xchat_plugin *ph, char *var, char *value); - int (*xchat_get_plugin_pref_str) (xchat_plugin *ph, + int (*xchat_get_pluginpref_str) (xchat_plugin *ph, char *var, char *dest); - int (*xchat_set_plugin_pref_int) (xchat_plugin *ph, + int (*xchat_set_pluginpref_int) (xchat_plugin *ph, char *var, int value); - int (*xchat_get_plugin_pref_int) (xchat_plugin *ph, + int (*xchat_get_pluginpref_int) (xchat_plugin *ph, char *var); }; #endif @@ -304,21 +304,21 @@ xchat_free (xchat_plugin *ph, void *ptr); int -xchat_set_plugin_pref_str (xchat_plugin *ph, +xchat_set_pluginpref_str (xchat_plugin *ph, char *var, char *value); int -xchat_get_plugin_pref_str (xchat_plugin *ph, +xchat_get_pluginpref_str (xchat_plugin *ph, char *var, char *dest); int -xchat_set_plugin_pref_int (xchat_plugin *ph, +xchat_set_pluginpref_int (xchat_plugin *ph, char *var, int value); int -xchat_get_plugin_pref_int (xchat_plugin *ph, +xchat_get_pluginpref_int (xchat_plugin *ph, char *var); #if !defined(PLUGIN_C) && defined(WIN32) @@ -355,10 +355,10 @@ xchat_get_plugin_pref_int (xchat_plugin *ph, #define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#define xchat_set_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_str) -#define xchat_get_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref_str) -#define xchat_set_plugin_pref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_int) -#define xchat_get_plugin_pref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref_int) +#define xchat_set_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_str) +#define xchat_get_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_str) +#define xchat_set_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_int) +#define xchat_get_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_int) #endif #ifdef __cplusplus diff --git a/src/version-script b/src/version-script index 94a95a0b..e76f4fe9 100644 --- a/src/version-script +++ b/src/version-script @@ -30,9 +30,9 @@ EXPORTED { xchat_send_modes; xchat_strip; xchat_free; - xchat_set_plugin_pref_str; - xchat_get_plugin_pref_str; - xchat_set_plugin_pref_int; - xchat_get_plugin_pref_int; + xchat_set_pluginpref_str; + xchat_get_pluginpref_str; + xchat_set_pluginpref_int; + xchat_get_pluginpref_int; local: *; }; -- cgit 1.4.1 From 455032938a9d5336e55684692113fbca8a156810 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Thu, 1 Dec 2011 21:24:58 +0100 Subject: plugin api conformance --- plugins/xchat-plugin.h | 20 ++++++++++---------- src/common/plugin.c | 10 +++++----- src/common/plugin.h | 10 +++++----- src/common/xchat-plugin.h | 20 ++++++++++---------- 4 files changed, 30 insertions(+), 30 deletions(-) (limited to 'plugins/xchat-plugin.h') diff --git a/plugins/xchat-plugin.h b/plugins/xchat-plugin.h index 48e3bc02..15799424 100644 --- a/plugins/xchat-plugin.h +++ b/plugins/xchat-plugin.h @@ -138,16 +138,16 @@ struct _xchat_plugin void (*xchat_free) (xchat_plugin *ph, void *ptr); int (*xchat_set_pluginpref_str) (xchat_plugin *ph, - char *var, - char *value); + const char *var, + const char *value); int (*xchat_get_pluginpref_str) (xchat_plugin *ph, - char *var, + const char *var, char *dest); int (*xchat_set_pluginpref_int) (xchat_plugin *ph, - char *var, + const char *var, int value); int (*xchat_get_pluginpref_int) (xchat_plugin *ph, - char *var); + const char *var); }; #endif @@ -305,21 +305,21 @@ xchat_free (xchat_plugin *ph, int xchat_set_pluginpref_str (xchat_plugin *ph, - char *var, - char *value); + const char *var, + const char *value); int xchat_get_pluginpref_str (xchat_plugin *ph, - char *var, + const char *var, char *dest); int xchat_set_pluginpref_int (xchat_plugin *ph, - char *var, + const char *var, int value); int xchat_get_pluginpref_int (xchat_plugin *ph, - char *var); + const char *var); #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE diff --git a/src/common/plugin.c b/src/common/plugin.c index b5b10a0e..b443b586 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -1584,7 +1584,7 @@ xchat_free (xchat_plugin *ph, void *ptr) } int -xchat_set_pluginpref_str (xchat_plugin *pl, char *var, char *value) +xchat_set_pluginpref_str (xchat_plugin *pl, const char *var, const char *value) { FILE *fpIn; int fhOut; @@ -1653,7 +1653,7 @@ xchat_set_pluginpref_str (xchat_plugin *pl, char *var, char *value) fclose (fpIn); - if (!prevConfig) + if (!prevConfig) /* var doesn't exist currently, append */ { sprintf (buffer, "%s = %s\n", var, value); write (fhOut, buffer, strlen (buffer)); @@ -1680,7 +1680,7 @@ xchat_set_pluginpref_str (xchat_plugin *pl, char *var, char *value) } int -xchat_get_pluginpref_str (xchat_plugin *pl, char *var, char *dest) +xchat_get_pluginpref_str (xchat_plugin *pl, const char *var, char *dest) { int fh; int l; @@ -1732,7 +1732,7 @@ xchat_get_pluginpref_str (xchat_plugin *pl, char *var, char *dest) } int -xchat_set_pluginpref_int (xchat_plugin *pl, char *var, int value) +xchat_set_pluginpref_int (xchat_plugin *pl, const char *var, int value) { char buffer[12]; @@ -1741,7 +1741,7 @@ xchat_set_pluginpref_int (xchat_plugin *pl, char *var, int value) } int -xchat_get_pluginpref_int (xchat_plugin *pl, char *var) +xchat_get_pluginpref_int (xchat_plugin *pl, const char *var) { char buffer[12]; diff --git a/src/common/plugin.h b/src/common/plugin.h index 858ed815..cddb86fb 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -99,16 +99,16 @@ struct _xchat_plugin void (*xchat_free) (xchat_plugin *ph, void *ptr); int (*xchat_set_pluginpref_str) (xchat_plugin *ph, - char *var, - char *value); + const char *var, + const char *value); int (*xchat_get_pluginpref_str) (xchat_plugin *ph, - char *var, + const char *var, char *dest); int (*xchat_set_pluginpref_int) (xchat_plugin *ph, - char *var, + const char *var, int value); int (*xchat_get_pluginpref_int) (xchat_plugin *ph, - char *var); + const char *var); void *(*xchat_dummy4) (xchat_plugin *ph); void *(*xchat_dummy3) (xchat_plugin *ph); void *(*xchat_dummy2) (xchat_plugin *ph); diff --git a/src/common/xchat-plugin.h b/src/common/xchat-plugin.h index 48e3bc02..15799424 100644 --- a/src/common/xchat-plugin.h +++ b/src/common/xchat-plugin.h @@ -138,16 +138,16 @@ struct _xchat_plugin void (*xchat_free) (xchat_plugin *ph, void *ptr); int (*xchat_set_pluginpref_str) (xchat_plugin *ph, - char *var, - char *value); + const char *var, + const char *value); int (*xchat_get_pluginpref_str) (xchat_plugin *ph, - char *var, + const char *var, char *dest); int (*xchat_set_pluginpref_int) (xchat_plugin *ph, - char *var, + const char *var, int value); int (*xchat_get_pluginpref_int) (xchat_plugin *ph, - char *var); + const char *var); }; #endif @@ -305,21 +305,21 @@ xchat_free (xchat_plugin *ph, int xchat_set_pluginpref_str (xchat_plugin *ph, - char *var, - char *value); + const char *var, + const char *value); int xchat_get_pluginpref_str (xchat_plugin *ph, - char *var, + const char *var, char *dest); int xchat_set_pluginpref_int (xchat_plugin *ph, - char *var, + const char *var, int value); int xchat_get_pluginpref_int (xchat_plugin *ph, - char *var); + const char *var); #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE -- cgit 1.4.1 From c3821b6316c3d25ef6affd5215796d3abbefd2fe Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sat, 14 Jan 2012 00:29:01 +0100 Subject: skeleton for xchat_del_pluginpref --- plugins/xchat-plugin.h | 7 +++++++ src/common/plugin.c | 21 ++++++++++++++++++--- src/common/plugin.h | 2 ++ src/common/xchat-plugin.h | 7 +++++++ src/version-script | 1 + 5 files changed, 35 insertions(+), 3 deletions(-) (limited to 'plugins/xchat-plugin.h') diff --git a/plugins/xchat-plugin.h b/plugins/xchat-plugin.h index 15799424..373c664e 100644 --- a/plugins/xchat-plugin.h +++ b/plugins/xchat-plugin.h @@ -148,6 +148,8 @@ struct _xchat_plugin int value); int (*xchat_get_pluginpref_int) (xchat_plugin *ph, const char *var); + int (*xchat_del_pluginpref) (xchat_plugin *ph, + const char *var); }; #endif @@ -321,6 +323,10 @@ int xchat_get_pluginpref_int (xchat_plugin *ph, const char *var); +int +xchat_del_pluginpref (xchat_plugin *ph, + const char *var); + #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE #define XCHAT_PLUGIN_HANDLE (ph) @@ -359,6 +365,7 @@ xchat_get_pluginpref_int (xchat_plugin *ph, #define xchat_get_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_str) #define xchat_set_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_int) #define xchat_get_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_int) +#define xchat_del_pluginpref ((XCHAT_PLUGIN_HANDLE)->xchat_del_pluginpref) #endif #ifdef __cplusplus diff --git a/src/common/plugin.c b/src/common/plugin.c index 5ed20b87..02cdcce5 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -274,6 +274,7 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func, pl->xchat_get_pluginpref_str = xchat_get_pluginpref_str; pl->xchat_set_pluginpref_int = xchat_set_pluginpref_int; pl->xchat_get_pluginpref_int = xchat_get_pluginpref_int; + pl->xchat_del_pluginpref = xchat_del_pluginpref; /* incase new plugins are loaded on older xchat */ pl->xchat_dummy4 = xchat_dummy; @@ -1587,9 +1588,11 @@ xchat_free (xchat_plugin *ph, void *ptr) g_free (ptr); } -int -xchat_set_pluginpref_str (xchat_plugin *pl, const char *var, const char *value) +static int +xchat_set_pluginpref_str_real (xchat_plugin *pl, const char *var, const char *value, int mode) { + /* mode: 0 = delete, 1 = save */ + FILE *fpIn; int fhOut; int prevConfig; @@ -1683,6 +1686,12 @@ xchat_set_pluginpref_str (xchat_plugin *pl, const char *var, const char *value) } } +int +xchat_set_pluginpref_str (xchat_plugin *pl, const char *var, const char *value) +{ + return xchat_set_pluginpref_str (pl, var, value, 1); +} + int xchat_get_pluginpref_str (xchat_plugin *pl, const char *var, char *dest) { @@ -1741,7 +1750,7 @@ xchat_set_pluginpref_int (xchat_plugin *pl, const char *var, int value) char buffer[12]; sprintf (buffer, "%d", value); - return xchat_set_pluginpref_str (pl, var, buffer); + return xchat_set_pluginpref_str_real (pl, var, buffer, 1); } int @@ -1758,3 +1767,9 @@ xchat_get_pluginpref_int (xchat_plugin *pl, const char *var) return -1; } } + +int +xchat_del_pluginpref (xchat_plugin *pl, const char *var) +{ + xchat_set_pluginpref_str_real (pl, var, 0, 0); +} diff --git a/src/common/plugin.h b/src/common/plugin.h index cddb86fb..bb86f0a3 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -109,6 +109,8 @@ struct _xchat_plugin int value); int (*xchat_get_pluginpref_int) (xchat_plugin *ph, const char *var); + int (*xchat_del_pluginpref) (xchat_plugin *ph, + const char *var); void *(*xchat_dummy4) (xchat_plugin *ph); void *(*xchat_dummy3) (xchat_plugin *ph); void *(*xchat_dummy2) (xchat_plugin *ph); diff --git a/src/common/xchat-plugin.h b/src/common/xchat-plugin.h index 15799424..373c664e 100644 --- a/src/common/xchat-plugin.h +++ b/src/common/xchat-plugin.h @@ -148,6 +148,8 @@ struct _xchat_plugin int value); int (*xchat_get_pluginpref_int) (xchat_plugin *ph, const char *var); + int (*xchat_del_pluginpref) (xchat_plugin *ph, + const char *var); }; #endif @@ -321,6 +323,10 @@ int xchat_get_pluginpref_int (xchat_plugin *ph, const char *var); +int +xchat_del_pluginpref (xchat_plugin *ph, + const char *var); + #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE #define XCHAT_PLUGIN_HANDLE (ph) @@ -359,6 +365,7 @@ xchat_get_pluginpref_int (xchat_plugin *ph, #define xchat_get_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_str) #define xchat_set_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_int) #define xchat_get_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_int) +#define xchat_del_pluginpref ((XCHAT_PLUGIN_HANDLE)->xchat_del_pluginpref) #endif #ifdef __cplusplus diff --git a/src/version-script b/src/version-script index e76f4fe9..fe04dd46 100644 --- a/src/version-script +++ b/src/version-script @@ -34,5 +34,6 @@ EXPORTED { xchat_get_pluginpref_str; xchat_set_pluginpref_int; xchat_get_pluginpref_int; + xchat_del_pluginpref; local: *; }; -- cgit 1.4.1 From 4942dc667f3ff40601b7afd2efd91dff1f73789a Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sun, 15 Jan 2012 19:07:48 +0100 Subject: refactor plugin config API and add skeleton for xchat_pluginpref_list --- plugins/plugin20.html | 61 ++++++++++++++++++++++++++++++++++------------- plugins/xchat-plugin.h | 37 ++++++++++++++++------------ src/common/plugin.c | 37 ++++++++++++++++------------ src/common/plugin.h | 12 ++++++---- src/common/xchat-plugin.h | 37 ++++++++++++++++------------ src/version-script | 11 +++++---- 6 files changed, 124 insertions(+), 71 deletions(-) (limited to 'plugins/xchat-plugin.h') diff --git a/plugins/plugin20.html b/plugins/plugin20.html index a9aaaace..6323cd80 100644 --- a/plugins/plugin20.html +++ b/plugins/plugin20.html @@ -81,10 +81,12 @@ margin-right: 32px;
xchat_strip
xchat_free
-
xchat_set_pluginpref_str -
xchat_get_pluginpref_str -
xchat_set_pluginpref_int -
xchat_get_pluginpref_int +
xchat_pluginpref_set_str +
xchat_pluginpref_get_str +
xchat_pluginpref_set_int +
xchat_pluginpref_get_int +
xchat_pluginpref_delete +
xchat_pluginpref_list

xchat_list_get
xchat_list_free @@ -1003,8 +1005,8 @@ A newly allocated string or NULL for failure. You must free this string with xch

-

 xchat_set_pluginpref_str() (new for 2.8.10)

-Prototype: int xchat_set_pluginpref_str (xchat_plugin *ph, const char *var, const char *value); +

 xchat_pluginpref_set_str() (new for 2.8.10)

+Prototype: int xchat_pluginpref_set_str (xchat_plugin *ph, const char *var, const char *value);

Description: Saves a plugin-specific setting with string value to a plugin-specific config file.
@@ -1028,8 +1030,8 @@ A newly allocated string or NULL for failure. You must free this string with xch *plugin_desc = "Testing stuff"; *plugin_version = "1.0"; - xchat_set_pluginpref_str (ph, "myvar1", "I want to save this string!"); - xchat_set_pluginpref_str (ph, "myvar2", "This is important, too."); + xchat_pluginpref_set_str (ph, "myvar1", "I want to save this string!"); + xchat_pluginpref_set_str (ph, "myvar2", "This is important, too."); return 1; /* return 1 for success */ } @@ -1042,8 +1044,8 @@ myvar2 = This is important, too. You should never need to edit this file manually.


-

 xchat_get_pluginpref_str() (new for 2.8.10)

-Prototype: int xchat_get_pluginpref_str (xchat_plugin *ph, const char *var, char *dest); +

 xchat_pluginpref_get_str() (new for 2.8.10)

+Prototype: int xchat_pluginpref_get_str (xchat_plugin *ph, const char *var, char *dest);

Description: Loads a plugin-specific setting with string value from a plugin-specific config file.
@@ -1056,8 +1058,8 @@ You should never need to edit this file manually. Returns: 1 for success, 0 for failure.


-

 xchat_set_pluginpref_int() (new for 2.8.10)

-Prototype: int xchat_set_pluginpref_int (xchat_plugin *ph, const char *var, int value); +

 xchat_pluginpref_set_int() (new for 2.8.10)

+Prototype: int xchat_pluginpref_set_int (xchat_plugin *ph, const char *var, int value);

Description: Saves a plugin-specific setting with decimal value to a plugin-specific config file.
@@ -1076,7 +1078,7 @@ You should never need to edit this file manually. if (buffer > 0 && buffer < INT_MAX) { - if (xchat_set_pluginpref_int (ph, "myint1", buffer)) + if (xchat_pluginpref_set_int (ph, "myint1", buffer)) { xchat_printf (ph, "Setting successfully saved!\n"); } @@ -1093,10 +1095,11 @@ You should never need to edit this file manually. return XCHAT_EAT_XCHAT; } -

+You only need these kind of complex checks if you're saving user input, which can be non-numeric. +


-

 xchat_get_pluginpref_int() (new for 2.8.10)

-Prototype: int xchat_get_pluginpref_int (xchat_plugin *ph, const char *var); +

 xchat_pluginpref_get_int() (new for 2.8.10)

+Prototype: int xchat_pluginpref_get_int (xchat_plugin *ph, const char *var);

Description: Loads a plugin-specific setting with decimal value from a plugin-specific config file.
@@ -1108,5 +1111,31 @@ You should never need to edit this file manually. Returns: The decimal value of the requested setting upon success, -1 for failure.


+

 xchat_pluginpref_delete() (new for 2.8.10)

+Prototype: int xchat_pluginpref_delete (xchat_plugin *ph, const char *var); +
+
Description: Deletes a plugin-specific setting from a plugin-specific config file. +
+
Arguments: +
ph: Plugin handle (as given to xchat_plugin_init). +
var: Name of the setting to delete. +
+
+Returns: 1 for success, 0 for failure. If the given setting didn't exist, it also returns 1, so 1 only indicates that the setting won't exist after the call. +


+ +

 xchat_pluginpref_list() (new for 2.8.10)

+Prototype: int xchat_pluginpref_list (xchat_plugin *ph, const char *dest); +
+
Description: Builds a comma-separated list of the currently saved settings from a plugin-specific config file. +
+
Arguments: +
ph: Plugin handle (as given to xchat_plugin_init). +
dest: Array to save the list to. +
+
+Returns: 1 for success, 0 for failure. +


+ diff --git a/plugins/xchat-plugin.h b/plugins/xchat-plugin.h index 373c664e..1b7da8fb 100644 --- a/plugins/xchat-plugin.h +++ b/plugins/xchat-plugin.h @@ -137,19 +137,21 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - int (*xchat_set_pluginpref_str) (xchat_plugin *ph, + int (*xchat_pluginpref_set_str) (xchat_plugin *ph, const char *var, const char *value); - int (*xchat_get_pluginpref_str) (xchat_plugin *ph, + int (*xchat_pluginpref_get_str) (xchat_plugin *ph, const char *var, char *dest); - int (*xchat_set_pluginpref_int) (xchat_plugin *ph, + int (*xchat_pluginpref_set_int) (xchat_plugin *ph, const char *var, int value); - int (*xchat_get_pluginpref_int) (xchat_plugin *ph, + int (*xchat_pluginpref_get_int) (xchat_plugin *ph, const char *var); - int (*xchat_del_pluginpref) (xchat_plugin *ph, + int (*xchat_pluginpref_delete) (xchat_plugin *ph, const char *var); + int (*xchat_pluginpref_list) (xchat_plugin *ph, + char *dest); }; #endif @@ -306,27 +308,31 @@ xchat_free (xchat_plugin *ph, void *ptr); int -xchat_set_pluginpref_str (xchat_plugin *ph, +xchat_pluginpref_set_str (xchat_plugin *ph, const char *var, const char *value); int -xchat_get_pluginpref_str (xchat_plugin *ph, +xchat_pluginpref_get_str (xchat_plugin *ph, const char *var, char *dest); int -xchat_set_pluginpref_int (xchat_plugin *ph, +xchat_pluginpref_set_int (xchat_plugin *ph, const char *var, int value); int -xchat_get_pluginpref_int (xchat_plugin *ph, +xchat_pluginpref_get_int (xchat_plugin *ph, const char *var); int -xchat_del_pluginpref (xchat_plugin *ph, +xchat_pluginpref_delete (xchat_plugin *ph, const char *var); +int +xchat_pluginpref_list (xchat_plugin *ph, + char *dest); + #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE #define XCHAT_PLUGIN_HANDLE (ph) @@ -361,11 +367,12 @@ xchat_del_pluginpref (xchat_plugin *ph, #define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#define xchat_set_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_str) -#define xchat_get_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_str) -#define xchat_set_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_int) -#define xchat_get_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_int) -#define xchat_del_pluginpref ((XCHAT_PLUGIN_HANDLE)->xchat_del_pluginpref) +#define xchat_pluginpref_set_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_str) +#define xchat_pluginpref_get_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_str) +#define xchat_pluginpref_set_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_int) +#define xchat_pluginpref_get_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_int) +#define xchat_pluginpref_delete ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_delete) +#define xchat_pluginpref_list ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_list) #endif #ifdef __cplusplus diff --git a/src/common/plugin.c b/src/common/plugin.c index b08143e0..cff8d49b 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -270,11 +270,12 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func, pl->xchat_send_modes = xchat_send_modes; pl->xchat_strip = xchat_strip; pl->xchat_free = xchat_free; - pl->xchat_set_pluginpref_str = xchat_set_pluginpref_str; - pl->xchat_get_pluginpref_str = xchat_get_pluginpref_str; - pl->xchat_set_pluginpref_int = xchat_set_pluginpref_int; - pl->xchat_get_pluginpref_int = xchat_get_pluginpref_int; - pl->xchat_del_pluginpref = xchat_del_pluginpref; + pl->xchat_pluginpref_set_str = xchat_pluginpref_set_str; + pl->xchat_pluginpref_get_str = xchat_pluginpref_get_str; + pl->xchat_pluginpref_set_int = xchat_pluginpref_set_int; + pl->xchat_pluginpref_get_int = xchat_pluginpref_get_int; + pl->xchat_pluginpref_delete = xchat_pluginpref_delete; + pl->xchat_pluginpref_list = xchat_pluginpref_list; /* incase new plugins are loaded on older xchat */ pl->xchat_dummy4 = xchat_dummy; @@ -1589,7 +1590,7 @@ xchat_free (xchat_plugin *ph, void *ptr) } static int -xchat_set_pluginpref_str_real (xchat_plugin *pl, const char *var, const char *value, int mode) /* mode: 0 = delete, 1 = save */ +xchat_pluginpref_set_str_real (xchat_plugin *pl, const char *var, const char *value, int mode) /* mode: 0 = delete, 1 = save */ { FILE *fpIn; int fhOut; @@ -1702,13 +1703,13 @@ xchat_set_pluginpref_str_real (xchat_plugin *pl, const char *var, const char *va } int -xchat_set_pluginpref_str (xchat_plugin *pl, const char *var, const char *value) +xchat_pluginpref_set_str (xchat_plugin *pl, const char *var, const char *value) { - return xchat_set_pluginpref_str_real (pl, var, value, 1); + return xchat_pluginpref_set_str_real (pl, var, value, 1); } int -xchat_get_pluginpref_str (xchat_plugin *pl, const char *var, char *dest) +xchat_pluginpref_get_str (xchat_plugin *pl, const char *var, char *dest) { int fh; int l; @@ -1760,20 +1761,20 @@ xchat_get_pluginpref_str (xchat_plugin *pl, const char *var, char *dest) } int -xchat_set_pluginpref_int (xchat_plugin *pl, const char *var, int value) +xchat_pluginpref_set_int (xchat_plugin *pl, const char *var, int value) { char buffer[12]; sprintf (buffer, "%d", value); - return xchat_set_pluginpref_str_real (pl, var, buffer, 1); + return xchat_pluginpref_set_str_real (pl, var, buffer, 1); } int -xchat_get_pluginpref_int (xchat_plugin *pl, const char *var) +xchat_pluginpref_get_int (xchat_plugin *pl, const char *var) { char buffer[12]; - if (xchat_get_pluginpref_str (pl, var, buffer)) + if (xchat_pluginpref_get_str (pl, var, buffer)) { return atoi (buffer); } @@ -1784,7 +1785,13 @@ xchat_get_pluginpref_int (xchat_plugin *pl, const char *var) } int -xchat_del_pluginpref (xchat_plugin *pl, const char *var) +xchat_pluginpref_delete (xchat_plugin *pl, const char *var) { - return xchat_set_pluginpref_str_real (pl, var, 0, 0); + return xchat_pluginpref_set_str_real (pl, var, 0, 0); } + +int +xchat_pluginpref_list (char* dest) +{ + return 0; +} \ No newline at end of file diff --git a/src/common/plugin.h b/src/common/plugin.h index bb86f0a3..8c347d51 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -98,19 +98,21 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - int (*xchat_set_pluginpref_str) (xchat_plugin *ph, + int (*xchat_pluginpref_set_str) (xchat_plugin *ph, const char *var, const char *value); - int (*xchat_get_pluginpref_str) (xchat_plugin *ph, + int (*xchat_pluginpref_get_str) (xchat_plugin *ph, const char *var, char *dest); - int (*xchat_set_pluginpref_int) (xchat_plugin *ph, + int (*xchat_pluginpref_set_int) (xchat_plugin *ph, const char *var, int value); - int (*xchat_get_pluginpref_int) (xchat_plugin *ph, + int (*xchat_pluginpref_get_int) (xchat_plugin *ph, const char *var); - int (*xchat_del_pluginpref) (xchat_plugin *ph, + int (*xchat_pluginpref_delete) (xchat_plugin *ph, const char *var); + int (*xchat_pluginpref_list) (xchat_plugin *ph, + char *dest); void *(*xchat_dummy4) (xchat_plugin *ph); void *(*xchat_dummy3) (xchat_plugin *ph); void *(*xchat_dummy2) (xchat_plugin *ph); diff --git a/src/common/xchat-plugin.h b/src/common/xchat-plugin.h index 373c664e..1b7da8fb 100644 --- a/src/common/xchat-plugin.h +++ b/src/common/xchat-plugin.h @@ -137,19 +137,21 @@ struct _xchat_plugin int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - int (*xchat_set_pluginpref_str) (xchat_plugin *ph, + int (*xchat_pluginpref_set_str) (xchat_plugin *ph, const char *var, const char *value); - int (*xchat_get_pluginpref_str) (xchat_plugin *ph, + int (*xchat_pluginpref_get_str) (xchat_plugin *ph, const char *var, char *dest); - int (*xchat_set_pluginpref_int) (xchat_plugin *ph, + int (*xchat_pluginpref_set_int) (xchat_plugin *ph, const char *var, int value); - int (*xchat_get_pluginpref_int) (xchat_plugin *ph, + int (*xchat_pluginpref_get_int) (xchat_plugin *ph, const char *var); - int (*xchat_del_pluginpref) (xchat_plugin *ph, + int (*xchat_pluginpref_delete) (xchat_plugin *ph, const char *var); + int (*xchat_pluginpref_list) (xchat_plugin *ph, + char *dest); }; #endif @@ -306,27 +308,31 @@ xchat_free (xchat_plugin *ph, void *ptr); int -xchat_set_pluginpref_str (xchat_plugin *ph, +xchat_pluginpref_set_str (xchat_plugin *ph, const char *var, const char *value); int -xchat_get_pluginpref_str (xchat_plugin *ph, +xchat_pluginpref_get_str (xchat_plugin *ph, const char *var, char *dest); int -xchat_set_pluginpref_int (xchat_plugin *ph, +xchat_pluginpref_set_int (xchat_plugin *ph, const char *var, int value); int -xchat_get_pluginpref_int (xchat_plugin *ph, +xchat_pluginpref_get_int (xchat_plugin *ph, const char *var); int -xchat_del_pluginpref (xchat_plugin *ph, +xchat_pluginpref_delete (xchat_plugin *ph, const char *var); +int +xchat_pluginpref_list (xchat_plugin *ph, + char *dest); + #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE #define XCHAT_PLUGIN_HANDLE (ph) @@ -361,11 +367,12 @@ xchat_del_pluginpref (xchat_plugin *ph, #define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#define xchat_set_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_str) -#define xchat_get_pluginpref_str ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_str) -#define xchat_set_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_set_pluginpref_int) -#define xchat_get_pluginpref_int ((XCHAT_PLUGIN_HANDLE)->xchat_get_pluginpref_int) -#define xchat_del_pluginpref ((XCHAT_PLUGIN_HANDLE)->xchat_del_pluginpref) +#define xchat_pluginpref_set_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_str) +#define xchat_pluginpref_get_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_str) +#define xchat_pluginpref_set_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_int) +#define xchat_pluginpref_get_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_int) +#define xchat_pluginpref_delete ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_delete) +#define xchat_pluginpref_list ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_list) #endif #ifdef __cplusplus diff --git a/src/version-script b/src/version-script index fe04dd46..4441aeae 100644 --- a/src/version-script +++ b/src/version-script @@ -30,10 +30,11 @@ EXPORTED { xchat_send_modes; xchat_strip; xchat_free; - xchat_set_pluginpref_str; - xchat_get_pluginpref_str; - xchat_set_pluginpref_int; - xchat_get_pluginpref_int; - xchat_del_pluginpref; + xchat_pluginpref_set_str; + xchat_pluginpref_get_str; + xchat_pluginpref_set_int; + xchat_pluginpref_get_int; + xchat_pluginpref_delete; + xchat_pluginpref_list; local: *; }; -- cgit 1.4.1