aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchatty2002-02-08 19:07:47 +0000
committerchatty2002-02-08 19:07:47 +0000
commitae2bb985b765881561437beccf3e50d4e52b5ff2 (patch)
treed27bfcfcf5f23741209e23a106b27449f155b03e
parent1b082e5191d09062bbb19d4c898c28192f08f0c2 (diff)
downloadivy-xchat-plugin-master.zip
ivy-xchat-plugin-master.tar.gz
ivy-xchat-plugin-master.tar.bz2
ivy-xchat-plugin-master.tar.xz
Now read bus address from config fileHEADmaster
-rw-r--r--include/cfgfiles.h38
-rw-r--r--redhat/changelog6
-rw-r--r--src/ivy-xchat-plugin.c17
3 files changed, 59 insertions, 2 deletions
diff --git a/include/cfgfiles.h b/include/cfgfiles.h
new file mode 100644
index 0000000..85c3f3e
--- /dev/null
+++ b/include/cfgfiles.h
@@ -0,0 +1,38 @@
+/* cfgfiles.h */
+
+extern char *xdir;
+
+char *cfg_get_str (char *cfg, char *var, char *dest);
+int cfg_get_bool (char *var);
+int cfg_get_int_with_result (char *cfg, char *var, int *result);
+int cfg_get_int (char *cfg, char *var);
+void cfg_put_int (int fh, int value, char *var);
+char *get_xdir (void);
+char *default_file (void);
+void check_prefs_dir (void);
+void load_config (void);
+int save_config (void);
+void list_free (GSList ** list);
+void list_loadconf (char *file, GSList ** list, char *defaultconf);
+int list_delentry (GSList ** list, char *name);
+void list_addentry (GSList ** list, char *cmd, char *name);
+
+#define STRUCT_OFFSET_STR(type,field) \
+( (unsigned int) (((char *) (&(((type *) NULL)->field)))- ((char *) NULL)) )
+
+#define STRUCT_OFFSET_INT(type,field) \
+( (unsigned int) (((int *) (&(((type *) NULL)->field)))- ((int *) NULL)) )
+
+#define PREFS_OFFSET(field) STRUCT_OFFSET_STR(struct xchatprefs, field)
+#define PREFS_OFFINT(field) STRUCT_OFFSET_INT(struct xchatprefs, field)
+
+struct prefs
+{
+ char *name;
+ unsigned short offset;
+ unsigned short type;
+};
+
+#define TYPE_STR 1
+#define TYPE_INT 2
+#define TYPE_BOOL 3
diff --git a/redhat/changelog b/redhat/changelog
index 1058aeb..72e26a2 100644
--- a/redhat/changelog
+++ b/redhat/changelog
@@ -1,4 +1,4 @@
-$Version = "0.1";
+$Version = "0.2";
$Release = 1;
$ChangeLog = '
@@ -7,4 +7,8 @@ $ChangeLog = '
- Generation of version 0.1-1
- First release
+ * Fri Feb 8 2002 Stéphane Chatty <chatty@cena.fr>
+- Generation of version 0.2-1
+- Version 0.2 : ivy bus is read from config file
+
';
diff --git a/src/ivy-xchat-plugin.c b/src/ivy-xchat-plugin.c
index ba67c5d..da27fdf 100644
--- a/src/ivy-xchat-plugin.c
+++ b/src/ivy-xchat-plugin.c
@@ -25,6 +25,7 @@
#include "plugin.h"
#include "text.h"
#include "inbound.h"
+#include "cfgfiles.h"
extern struct module *module_find (char *name);
extern void module_add_cmds (struct module_cmd_set *xc_cmds);
@@ -178,6 +179,11 @@ cmd_bind (struct session *sess, char *tbuf, char *word[], char *word_eol[])
int
module_init (int ver, struct module *mod, struct session *sess)
{
+ FILE* conf;
+ char optionfile[256];
+ char* bus = 0;
+ char busbuf[512];
+
/** first let's do our connection work as an xchat plugin **/
/* version check */
@@ -210,9 +216,18 @@ module_init (int ver, struct module *mod, struct session *sess)
hook_signal (&chanmsg_sig);
/** then let's connect to Ivy **/
+
+ /* read bus configuration file */
+ snprintf (optionfile, sizeof (optionfile), "%s/ivy.conf", get_xdir ());
+ conf = fopen (optionfile, "r");
+ if (conf) {
+ if (fscanf (conf, "bus = %512s", busbuf) == 1)
+ bus = busbuf;
+ }
+
IvyGtkChannelInit ();
IvyInit ("ivy-xchat-plugin", 0, 0, 0, 0, 0);
- IvyStart (0);
+ IvyStart (bus);
return 0;
}