plugin config - separate string and int functions

This commit is contained in:
Berke Viktor 2011-11-30 08:28:19 +01:00
parent f49caf67f6
commit 1567d32697
4 changed files with 72 additions and 20 deletions

View File

@ -137,12 +137,17 @@ struct _xchat_plugin
int flags); int flags);
void (*xchat_free) (xchat_plugin *ph, void (*xchat_free) (xchat_plugin *ph,
void *ptr); void *ptr);
int (*xchat_set_plugin_pref) (xchat_plugin *ph, int (*xchat_set_plugin_pref_str) (xchat_plugin *ph,
char *var, char *var,
char *value); char *value);
int (*xchat_get_plugin_pref) (xchat_plugin *ph, int (*xchat_get_plugin_pref_str) (xchat_plugin *ph,
char *var, char *var,
char *dest); 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 #endif
@ -299,15 +304,23 @@ xchat_free (xchat_plugin *ph,
void *ptr); void *ptr);
int int
xchat_set_plugin_pref (xchat_plugin *ph, xchat_set_plugin_pref_str (xchat_plugin *ph,
char *var, char *var,
char *value); char *value);
int int
xchat_get_plugin_pref (xchat_plugin *ph, xchat_get_plugin_pref_str (xchat_plugin *ph,
char *var, char *var,
char *dest); 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) #if !defined(PLUGIN_C) && defined(WIN32)
#ifndef XCHAT_PLUGIN_HANDLE #ifndef XCHAT_PLUGIN_HANDLE
#define XCHAT_PLUGIN_HANDLE (ph) #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_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes)
#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip)
#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free)
#define xchat_set_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref) #define xchat_set_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_str)
#define xchat_get_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref) #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 #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -270,8 +270,10 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func,
pl->xchat_send_modes = xchat_send_modes; pl->xchat_send_modes = xchat_send_modes;
pl->xchat_strip = xchat_strip; pl->xchat_strip = xchat_strip;
pl->xchat_free = xchat_free; pl->xchat_free = xchat_free;
pl->xchat_set_plugin_pref = xchat_set_plugin_pref; pl->xchat_set_plugin_pref_str = xchat_set_plugin_pref_str;
pl->xchat_get_plugin_pref = xchat_get_plugin_pref; 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 */ /* incase new plugins are loaded on older xchat */
pl->xchat_dummy4 = xchat_dummy; pl->xchat_dummy4 = xchat_dummy;
@ -1582,7 +1584,7 @@ xchat_free (xchat_plugin *ph, void *ptr)
} }
int 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; FILE *fpIn;
int fhOut; int fhOut;
@ -1678,7 +1680,7 @@ xchat_set_plugin_pref (xchat_plugin *pl, char *var, char *value)
} }
int 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 fh;
int l; int l;
@ -1728,3 +1730,19 @@ xchat_get_plugin_pref (xchat_plugin *pl, char *var, char *dest)
close (fh); close (fh);
return 1; 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);
}

View File

@ -98,13 +98,17 @@ struct _xchat_plugin
int flags); int flags);
void (*xchat_free) (xchat_plugin *ph, void (*xchat_free) (xchat_plugin *ph,
void *ptr); void *ptr);
int (*xchat_set_plugin_pref) (xchat_plugin *ph, int (*xchat_set_plugin_pref_str) (xchat_plugin *ph,
char *var, char *var,
char *value); char *value);
int (*xchat_get_plugin_pref) (xchat_plugin *ph, int (*xchat_get_plugin_pref_str) (xchat_plugin *ph,
char *var, char *var,
char *dest, char *dest);
int dest_len); 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_dummy4) (xchat_plugin *ph);
void *(*xchat_dummy3) (xchat_plugin *ph); void *(*xchat_dummy3) (xchat_plugin *ph);
void *(*xchat_dummy2) (xchat_plugin *ph); void *(*xchat_dummy2) (xchat_plugin *ph);

View File

@ -137,12 +137,17 @@ struct _xchat_plugin
int flags); int flags);
void (*xchat_free) (xchat_plugin *ph, void (*xchat_free) (xchat_plugin *ph,
void *ptr); void *ptr);
int (*xchat_set_plugin_pref) (xchat_plugin *ph, int (*xchat_set_plugin_pref_str) (xchat_plugin *ph,
char *var, char *var,
char *value); char *value);
int (*xchat_get_plugin_pref) (xchat_plugin *ph, int (*xchat_get_plugin_pref_str) (xchat_plugin *ph,
char *var, char *var,
char *dest); 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 #endif
@ -299,15 +304,23 @@ xchat_free (xchat_plugin *ph,
void *ptr); void *ptr);
int int
xchat_set_plugin_pref (xchat_plugin *ph, xchat_set_plugin_pref_str (xchat_plugin *ph,
char *var, char *var,
char *value); char *value);
int int
xchat_get_plugin_pref (xchat_plugin *ph, xchat_get_plugin_pref_str (xchat_plugin *ph,
char *var, char *var,
char *dest); 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) #if !defined(PLUGIN_C) && defined(WIN32)
#ifndef XCHAT_PLUGIN_HANDLE #ifndef XCHAT_PLUGIN_HANDLE
#define XCHAT_PLUGIN_HANDLE (ph) #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_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes)
#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip)
#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free)
#define xchat_set_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref) #define xchat_set_plugin_pref_str ((XCHAT_PLUGIN_HANDLE)->xchat_set_plugin_pref_str)
#define xchat_get_plugin_pref ((XCHAT_PLUGIN_HANDLE)->xchat_get_plugin_pref) #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 #endif
#ifdef __cplusplus #ifdef __cplusplus