1 /***************************************************************************
2 tclplugin.h - TCL plugin header file
3 -------------------------------------------------
4 begin : Sat Nov 9 17:31:20 MST 2002
5 copyright : Copyright 2002-2012 Daniel P. Stasinski
6 email : daniel@GenericInbox.com
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #define BADARGS(nl,nh,example) \
19 if ((argc<(nl)) || (argc>(nh))) { \
20 Tcl_AppendResult(irp,"wrong # args: should be \"",argv[0], \
21 (example),"\"",NULL); \
25 #define CHECKCTX(ctx) \
27 Tcl_AppendResult(irp, "No such server/channel/nick", NULL); \
51 #define MAX_TIMERS 512
52 #define MAX_COMPLETES 128
54 static char *StrDup(const char *string
, int *length
);
55 static char *myitoa(long value
);
56 static xchat_context
*xchat_smart_context(const char *arg1
, const char *arg2
);
57 static void queue_nexttimer();
58 static int insert_timer(int seconds
, int count
, const char *script
);
59 static void do_timer();
60 static int Server_raw_line(char *word
[], char *word_eol
[], void *userdata
);
61 static int Print_Hook(char *word
[], void *userdata
);
62 static int tcl_timerexists(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
63 static int tcl_killtimer(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
64 static int tcl_timers(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
65 static int tcl_timer(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
66 static int tcl_on(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
67 static int tcl_off(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
68 static int tcl_alias(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
69 static int tcl_complete(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
70 static int tcl_raw(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
71 static int tcl_command(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
72 static int tcl_xchat_puts(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
73 static int tcl_print(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
74 static int tcl_channels(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
75 static int tcl_servers(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
76 static int tcl_queries(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
77 static int tcl_users(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
78 static int tcl_chats(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
79 static int tcl_ignores(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
80 static int tcl_dcclist(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
81 static int tcl_me(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
82 static int tcl_xchat_nickcmp(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
83 static int tcl_strip(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
84 static int tcl_topic(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
85 static int tcl_word(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
86 static int tcl_word_eol(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
87 static int tcl_notifylist(ClientData cd
, Tcl_Interp
* irp
, int argc
, const char *argv
[]);
88 static int Command_Alias(char *word
[], char *word_eol
[], void *userdata
);
89 static int Null_Command_Alias(char *word
[], char *word_eol
[], void *userdata
);
90 static int Command_TCL(char *word
[], char *word_eol
[], void *userdata
);
91 static int Command_Source(char *word
[], char *word_eol
[], void *userdata
);
92 static int Command_Reload(char *word
[], char *word_eol
[], void *userdata
);
93 static int TCL_Event_Handler(void *userdata
);
94 static void Tcl_Plugin_Init();
95 static void Tcl_Plugin_DeInit();
97 int xchat_plugin_init(xchat_plugin
* plugin_handle
, char **plugin_name
, char **plugin_desc
, char **plugin_version
, char *arg
);
98 int xchat_plugin_deinit();