|
@@ -4,322 +4,6 @@
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
-static int tcl_channel_info(Tcl_Interp * irp, struct chanset_t *chan)
|
|
|
|
|
-{
|
|
|
|
|
- char a[121], b[121], s[121];
|
|
|
|
|
-#if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)) || (TCL_MAJOR_VERSION > 8))
|
|
|
|
|
- CONST char *args[2];
|
|
|
|
|
-#else
|
|
|
|
|
- char *args[2];
|
|
|
|
|
-#endif
|
|
|
|
|
- struct udef_struct *ul;
|
|
|
|
|
-
|
|
|
|
|
- get_mode_protect(chan, s);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d", chan->idle_kick);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d", chan->limitraise);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d", chan->stopnethack_mode);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d", chan->revenge_mode);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d:%d", chan->flood_pub_thr, chan->flood_pub_time);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d:%d", chan->flood_ctcp_thr, chan->flood_ctcp_time);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d:%d", chan->flood_join_thr, chan->flood_join_time);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d:%d", chan->flood_kick_thr, chan->flood_kick_time);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d:%d", chan->flood_deop_thr, chan->flood_deop_time);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d:%d", chan->flood_nick_thr, chan->flood_nick_time);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d", chan->ban_time);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%s", chan->closed_ban);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
-/* Chanint template
|
|
|
|
|
- *simple_sprintf(s, "%s", chan->temp);
|
|
|
|
|
- *Tcl_AppendElement(irp, s);
|
|
|
|
|
- */
|
|
|
|
|
- simple_sprintf(s, "%d", chan->exempt_time);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- simple_sprintf(s, "%d", chan->invite_time);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- if (chan->status & CHAN_ENFORCEBANS)
|
|
|
|
|
- Tcl_AppendElement(irp, "+enforcebans");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-enforcebans");
|
|
|
|
|
- if (chan->status & CHAN_DYNAMICBANS)
|
|
|
|
|
- Tcl_AppendElement(irp, "+dynamicbans");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-dynamicbans");
|
|
|
|
|
- if (chan->status & CHAN_NOUSERBANS)
|
|
|
|
|
- Tcl_AppendElement(irp, "-userbans");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "+userbans");
|
|
|
|
|
- if (chan->status & CHAN_BITCH)
|
|
|
|
|
- Tcl_AppendElement(irp, "+bitch");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-bitch");
|
|
|
|
|
- if (chan->status & CHAN_PROTECTOPS)
|
|
|
|
|
- Tcl_AppendElement(irp, "+protectops");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-protectops");
|
|
|
|
|
- if (chan->status & CHAN_INACTIVE)
|
|
|
|
|
- Tcl_AppendElement(irp, "+inactive");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-inactive");
|
|
|
|
|
- if (chan->status & CHAN_REVENGE)
|
|
|
|
|
- Tcl_AppendElement(irp, "+revenge");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-revenge");
|
|
|
|
|
- if (chan->status & CHAN_REVENGEBOT)
|
|
|
|
|
- Tcl_AppendElement(irp, "+revengebot");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-revengebot");
|
|
|
|
|
- if (chan->status & CHAN_SECRET)
|
|
|
|
|
- Tcl_AppendElement(irp, "+secret");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-secret");
|
|
|
|
|
- if (chan->status & CHAN_CYCLE)
|
|
|
|
|
- Tcl_AppendElement(irp, "+cycle");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-cycle");
|
|
|
|
|
- if (chan->ircnet_status& CHAN_DYNAMICEXEMPTS)
|
|
|
|
|
- Tcl_AppendElement(irp, "+dynamicexempts");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-dynamicexempts");
|
|
|
|
|
- if (chan->ircnet_status& CHAN_NOUSEREXEMPTS)
|
|
|
|
|
- Tcl_AppendElement(irp, "-userexempts");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "+userexempts");
|
|
|
|
|
- if (chan->ircnet_status& CHAN_DYNAMICINVITES)
|
|
|
|
|
- Tcl_AppendElement(irp, "+dynamicinvites");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-dynamicinvites");
|
|
|
|
|
- if (chan->ircnet_status& CHAN_NOUSERINVITES)
|
|
|
|
|
- Tcl_AppendElement(irp, "-userinvites");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "+userinvites");
|
|
|
|
|
- if (chan->status & CHAN_NODESYNCH)
|
|
|
|
|
- Tcl_AppendElement(irp, "+nodesynch");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-nodesynch");
|
|
|
|
|
- if (chan->status & CHAN_CLOSED)
|
|
|
|
|
- Tcl_AppendElement(irp, "+closed");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-closed");
|
|
|
|
|
- if (chan->status & CHAN_TAKE)
|
|
|
|
|
- Tcl_AppendElement(irp, "+take");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-take");
|
|
|
|
|
- if (chan->status & CHAN_NOMOP)
|
|
|
|
|
- Tcl_AppendElement(irp, "+nomop");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-nomop");
|
|
|
|
|
- if (chan->status & CHAN_MANOP)
|
|
|
|
|
- Tcl_AppendElement(irp, "+manop");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-manop");
|
|
|
|
|
- if (chan->status & CHAN_VOICE)
|
|
|
|
|
- Tcl_AppendElement(irp, "+voice");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-voice");
|
|
|
|
|
-/* Chanflag template
|
|
|
|
|
- *if (chan->status & CHAN_TEMP)
|
|
|
|
|
- * Tcl_AppendElement(irp, "+temp");
|
|
|
|
|
- *else
|
|
|
|
|
- * Tcl_AppendElement(irp, "-temp");
|
|
|
|
|
- */
|
|
|
|
|
- if (chan->status & CHAN_FASTOP)
|
|
|
|
|
- Tcl_AppendElement(irp, "+fastop");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-fastop");
|
|
|
|
|
- if (chan->status & CHAN_PRIVATE)
|
|
|
|
|
- Tcl_AppendElement(irp, "+private");
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendElement(irp, "-private");
|
|
|
|
|
-
|
|
|
|
|
- for (ul = udef; ul; ul = ul->next) {
|
|
|
|
|
- /* If it's undefined, skip it. */
|
|
|
|
|
- if (!ul->defined || !ul->name) continue;
|
|
|
|
|
-
|
|
|
|
|
- if (ul->type == UDEF_FLAG) {
|
|
|
|
|
- simple_sprintf(s, "%c%s", getudef(ul->values, chan->dname) ? '+' : '-',
|
|
|
|
|
- ul->name);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- } else if (ul->type == UDEF_INT) {
|
|
|
|
|
- char *x;
|
|
|
|
|
- egg_snprintf(a, sizeof a, "%s", ul->name);
|
|
|
|
|
- egg_snprintf(b, sizeof b, "%d", getudef(ul->values, chan->dname));
|
|
|
|
|
- args[0] = a;
|
|
|
|
|
- args[1] = b;
|
|
|
|
|
- x = Tcl_Merge(2, args);
|
|
|
|
|
- egg_snprintf(s, sizeof s, "%s", x);
|
|
|
|
|
- Tcl_Free((char *) x);
|
|
|
|
|
- Tcl_AppendElement(irp, s);
|
|
|
|
|
- } else
|
|
|
|
|
- debug1("UDEF-ERROR: unknown type %d", ul->type);
|
|
|
|
|
- }
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_channel_get(Tcl_Interp * irp, struct chanset_t *chan, char *setting)
|
|
|
|
|
-{
|
|
|
|
|
- char s[121];
|
|
|
|
|
- struct udef_struct *ul;
|
|
|
|
|
-
|
|
|
|
|
-#define CHECK(x) !strcmp(setting, x)
|
|
|
|
|
-
|
|
|
|
|
-#define CHKFLAG_POS(x,y,z) (!strcmp(setting, y)) { \
|
|
|
|
|
- if(z & x) simple_sprintf(s, "%d", 1); \
|
|
|
|
|
- else simple_sprintf(s, "%d", 0); }
|
|
|
|
|
-
|
|
|
|
|
-#define CHKFLAG_NEG(x,y,z) (!strcmp(setting, y)) { \
|
|
|
|
|
- if (z & x) simple_sprintf(s, "%d", 0); \
|
|
|
|
|
- else simple_sprintf(s, "%d", 1); }
|
|
|
|
|
-
|
|
|
|
|
- if (CHECK("chanmode")) get_mode_protect(chan, s);
|
|
|
|
|
-
|
|
|
|
|
- else if (CHECK("addedby")) simple_sprintf(s, "%s", chan->added_by);
|
|
|
|
|
- else if (CHECK("addedts")) simple_sprintf(s, "%lu", chan->added_ts);
|
|
|
|
|
- else if (CHECK("idle-kick")) simple_sprintf(s, "%d", chan->idle_kick);
|
|
|
|
|
- else if (CHECK("limit")) simple_sprintf(s, "%d", chan->limitraise);
|
|
|
|
|
- else if (CHECK("stop-net-hack")) simple_sprintf(s, "%d", chan->stopnethack_mode);
|
|
|
|
|
- else if (CHECK("revenge-mode")) simple_sprintf(s, "%d", chan->revenge_mode);
|
|
|
|
|
- else if (CHECK("flood-chan")) simple_sprintf(s, "%d %d", chan->flood_pub_thr, chan->flood_pub_time);
|
|
|
|
|
- else if (CHECK("flood-ctcp")) simple_sprintf(s, "%d %d", chan->flood_ctcp_thr, chan->flood_ctcp_time);
|
|
|
|
|
- else if (CHECK("flood-join")) simple_sprintf(s, "%d %d", chan->flood_join_thr, chan->flood_join_time);
|
|
|
|
|
- else if (CHECK("flood-kick")) simple_sprintf(s, "%d %d", chan->flood_kick_thr, chan->flood_kick_time);
|
|
|
|
|
- else if (CHECK("flood-deop")) simple_sprintf(s, "%d %d", chan->flood_deop_thr, chan->flood_deop_time);
|
|
|
|
|
- else if (CHECK("flood-nick")) simple_sprintf(s, "%d %d", chan->flood_nick_thr, chan->flood_nick_time);
|
|
|
|
|
-/* Chanint template
|
|
|
|
|
- *else if (CHECK("temp")) simple_sprintf(s, "%s", chan->temp);
|
|
|
|
|
- */
|
|
|
|
|
- else if (CHECK("closed-ban")) simple_sprintf(s, "%d", chan->closed_ban);
|
|
|
|
|
- else if (CHECK("ban-time")) simple_sprintf(s, "%d", chan->ban_time);
|
|
|
|
|
- else if (CHECK("exempt-time")) simple_sprintf(s, "%d", chan->exempt_time);
|
|
|
|
|
- else if (CHECK("invite-time")) simple_sprintf(s, "%d", chan->invite_time);
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_ENFORCEBANS, "enforcebans", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_DYNAMICBANS, "dynamicbans", chan->status)
|
|
|
|
|
- else if CHKFLAG_NEG(CHAN_NOUSERBANS, "userbans", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_BITCH, "bitch", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_PROTECTOPS, "protectops", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_INACTIVE, "inactive", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_REVENGE, "revenge", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_REVENGEBOT, "revengebot", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_SECRET, "secret", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_CYCLE, "cycle", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_NODESYNCH, "nodesynch", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_DYNAMICEXEMPTS, "dynamicexempts", chan->ircnet_status)
|
|
|
|
|
- else if CHKFLAG_NEG(CHAN_NOUSEREXEMPTS, "userexempts", chan->ircnet_status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_DYNAMICINVITES, "dynamicinvites", chan->ircnet_status)
|
|
|
|
|
- else if CHKFLAG_NEG(CHAN_NOUSERINVITES, "userinvites", chan->ircnet_status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_CLOSED, "closed", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_TAKE, "take", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_NOMOP, "nomop", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_MANOP, "manop", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_VOICE, "voice", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_FASTOP, "fastop", chan->status)
|
|
|
|
|
- else if CHKFLAG_POS(CHAN_PRIVATE, "private", chan->status)
|
|
|
|
|
-/* Chanflag template
|
|
|
|
|
- *else if CHKFLAG_POS(CHAN_TEMP, "temp", chan->status)
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
- else {
|
|
|
|
|
- /* Hopefully it's a user-defined flag. */
|
|
|
|
|
- for (ul = udef; ul && ul->name; ul = ul->next) {
|
|
|
|
|
- if (!strcmp(setting, ul->name)) break;
|
|
|
|
|
- }
|
|
|
|
|
- if (!ul || !ul->name) {
|
|
|
|
|
- /* Error if it wasn't found. */
|
|
|
|
|
- Tcl_AppendResult(irp, "Unknown channel setting.", NULL);
|
|
|
|
|
- return(TCL_ERROR);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /* Flag or int, all the same. */
|
|
|
|
|
- simple_sprintf(s, "%d", getudef(ul->values, chan->dname));
|
|
|
|
|
- Tcl_AppendResult(irp, s, NULL);
|
|
|
|
|
- return(TCL_OK);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /* Ok, if we make it this far, the result is "s". */
|
|
|
|
|
- Tcl_AppendResult(irp, s, NULL);
|
|
|
|
|
- return(TCL_OK);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_channel STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- struct chanset_t *chan;
|
|
|
|
|
- char buf2[1024];
|
|
|
|
|
- BADARGS(2, 999, " command ?options?");
|
|
|
|
|
- if (!strcmp(argv[1], "add")) {
|
|
|
|
|
- BADARGS(3, 4, " add channel-name ?options-list?");
|
|
|
|
|
- if (argc == 3) {
|
|
|
|
|
-
|
|
|
|
|
- egg_snprintf(buf2, sizeof buf2, "cjoin %s", argv[2]);
|
|
|
|
|
- if (!loading)
|
|
|
|
|
- putallbots(buf2);
|
|
|
|
|
- return tcl_channel_add(irp, argv[2], "");
|
|
|
|
|
- }
|
|
|
|
|
- egg_snprintf(buf2, sizeof buf2, "cjoin %s %s", argv[2], argv[3]);
|
|
|
|
|
- if (!loading)
|
|
|
|
|
- putallbots(buf2);
|
|
|
|
|
- return tcl_channel_add(irp, argv[2], argv[3]);
|
|
|
|
|
- }
|
|
|
|
|
- if (!strcmp(argv[1], "set")) {
|
|
|
|
|
- BADARGS(3, 999, " set channel-name ?options?");
|
|
|
|
|
- chan = findchan_by_dname(argv[2]);
|
|
|
|
|
- if (chan == NULL) {
|
|
|
|
|
- if (loading == 1)
|
|
|
|
|
- return TCL_OK; /* Ignore channel settings for a static
|
|
|
|
|
- * channel which has been removed from
|
|
|
|
|
- * the config */
|
|
|
|
|
- Tcl_AppendResult(irp, "no such channel record", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- do_chanset(chan, argv[3], 0);
|
|
|
|
|
- return tcl_channel_modify(irp, chan, argc - 3, &argv[3]);
|
|
|
|
|
- }
|
|
|
|
|
- if (!strcmp(argv[1], "get")) {
|
|
|
|
|
- BADARGS(4, 4, " get channel-name setting-name");
|
|
|
|
|
- chan = findchan_by_dname(argv[2]);
|
|
|
|
|
- if (chan == NULL) {
|
|
|
|
|
- Tcl_AppendResult(irp, "no such channel record", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- return(tcl_channel_get(irp, chan, argv[3]));
|
|
|
|
|
- }
|
|
|
|
|
- if (!strcmp(argv[1], "info")) {
|
|
|
|
|
- BADARGS(3, 3, " info channel-name");
|
|
|
|
|
- chan = findchan_by_dname(argv[2]);
|
|
|
|
|
- if (chan == NULL) {
|
|
|
|
|
- Tcl_AppendResult(irp, "no such channel record", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- return tcl_channel_info(irp, chan);
|
|
|
|
|
- }
|
|
|
|
|
- if (!strcmp(argv[1], "remove")) {
|
|
|
|
|
- BADARGS(3, 3, " remove channel-name");
|
|
|
|
|
- chan = findchan_by_dname(argv[2]);
|
|
|
|
|
-
|
|
|
|
|
- if (chan == NULL) {
|
|
|
|
|
- Tcl_AppendResult(irp, "no such channel record", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- egg_snprintf(buf2, sizeof buf2, "cpart %s", argv[2]);
|
|
|
|
|
- putallbots(buf2);
|
|
|
|
|
- remove_channel(chan);
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
- }
|
|
|
|
|
- Tcl_AppendResult(irp, "unknown channel command: should be one of: ",
|
|
|
|
|
- "add, set, get, info, remove", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
/* Parse options for a channel.
|
|
/* Parse options for a channel.
|
|
|
*/
|
|
*/
|
|
|
static int tcl_channel_modify(Tcl_Interp * irp, struct chanset_t *chan,
|
|
static int tcl_channel_modify(Tcl_Interp * irp, struct chanset_t *chan,
|
|
@@ -697,137 +381,6 @@ static int tcl_channel_modify(Tcl_Interp * irp, struct chanset_t *chan,
|
|
|
return TCL_OK;
|
|
return TCL_OK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static int tcl_do_masklist(maskrec *m, Tcl_Interp *irp)
|
|
|
|
|
-{
|
|
|
|
|
- char ts[21], ts1[21], ts2[21], *p;
|
|
|
|
|
-#if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)) || (TCL_MAJOR_VERSION > 8))
|
|
|
|
|
- CONST char *list[6];
|
|
|
|
|
-#else
|
|
|
|
|
- char *list[6];
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
- for (; m; m = m->next) {
|
|
|
|
|
- list[0] = m->mask;
|
|
|
|
|
- list[1] = m->desc;
|
|
|
|
|
- sprintf(ts, "%lu", m->expire);
|
|
|
|
|
- list[2] = ts;
|
|
|
|
|
- sprintf(ts1, "%lu", m->added);
|
|
|
|
|
- list[3] = ts1;
|
|
|
|
|
- sprintf(ts2, "%lu", m->lastactive);
|
|
|
|
|
- list[4] = ts2;
|
|
|
|
|
- list[5] = m->user;
|
|
|
|
|
- p = Tcl_Merge(6, list);
|
|
|
|
|
- Tcl_AppendElement(irp, p);
|
|
|
|
|
- Tcl_Free((char *) p);
|
|
|
|
|
- }
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_banlist STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- struct chanset_t *chan;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(1, 2, " ?channel?");
|
|
|
|
|
- if (argc == 2) {
|
|
|
|
|
- chan = findchan_by_dname(argv[1]);
|
|
|
|
|
- if (chan == NULL) {
|
|
|
|
|
- Tcl_AppendResult(irp, "invalid channel: ", argv[1], NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- return tcl_do_masklist(chan->bans, irp);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return tcl_do_masklist(global_bans, irp);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_exemptlist STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- struct chanset_t *chan;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(1, 2, " ?channel?");
|
|
|
|
|
- if (argc == 2) {
|
|
|
|
|
- chan = findchan_by_dname(argv[1]);
|
|
|
|
|
- if (chan == NULL) {
|
|
|
|
|
- Tcl_AppendResult(irp, "invalid channel: ", argv[1], NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- return tcl_do_masklist(chan->exempts, irp);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return tcl_do_masklist(global_exempts, irp);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_invitelist STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- struct chanset_t *chan;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(1, 2, " ?channel?");
|
|
|
|
|
- if (argc == 2) {
|
|
|
|
|
- chan = findchan_by_dname(argv[1]);
|
|
|
|
|
- if (chan == NULL) {
|
|
|
|
|
- Tcl_AppendResult(irp, "invalid channel: ", argv[1], NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- return tcl_do_masklist(chan->invites, irp);
|
|
|
|
|
- }
|
|
|
|
|
- return tcl_do_masklist(global_invites, irp);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_channels STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- struct chanset_t *chan;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(1, 1, "");
|
|
|
|
|
- for (chan = chanset; chan; chan = chan->next)
|
|
|
|
|
- Tcl_AppendElement(irp, chan->dname);
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_validchan STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- struct chanset_t *chan;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(2, 2, " channel");
|
|
|
|
|
- chan = findchan_by_dname(argv[1]);
|
|
|
|
|
- if (chan == NULL)
|
|
|
|
|
- Tcl_AppendResult(irp, "0", NULL);
|
|
|
|
|
- else
|
|
|
|
|
- Tcl_AppendResult(irp, "1", NULL);
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_getchaninfo STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- char s[161];
|
|
|
|
|
- struct userrec *u;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(3, 3, " handle channel");
|
|
|
|
|
- u = get_user_by_handle(userlist, argv[1]);
|
|
|
|
|
- if (!u || (u->flags & USER_BOT))
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
- get_handle_chaninfo(argv[1], argv[2], s);
|
|
|
|
|
- Tcl_AppendResult(irp, s, NULL);
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_setchaninfo STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- struct chanset_t *chan;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(4, 4, " handle channel info");
|
|
|
|
|
- chan = findchan_by_dname(argv[2]);
|
|
|
|
|
- if (chan == NULL) {
|
|
|
|
|
- Tcl_AppendResult(irp, "illegal channel: ", argv[2], NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- if (!egg_strcasecmp(argv[3], "none")) {
|
|
|
|
|
- set_handle_chaninfo(userlist, argv[1], argv[2], NULL);
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
- }
|
|
|
|
|
- set_handle_chaninfo(userlist, argv[1], argv[2], argv[3]);
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static void init_masklist(masklist *m)
|
|
static void init_masklist(masklist *m)
|
|
|
{
|
|
{
|
|
|
m->mask = (char *)malloc(1);
|
|
m->mask = (char *)malloc(1);
|
|
@@ -1010,106 +563,3 @@ static int tcl_channel_add(Tcl_Interp *irp, char *newname, char *options)
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static int tcl_setudef STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- int type;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(3, 3, " type name");
|
|
|
|
|
- if (!egg_strcasecmp(argv[1], "flag"))
|
|
|
|
|
- type = UDEF_FLAG;
|
|
|
|
|
- else if (!egg_strcasecmp(argv[1], "int"))
|
|
|
|
|
- type = UDEF_INT;
|
|
|
|
|
- else {
|
|
|
|
|
- Tcl_AppendResult(irp, "invalid type. Must be one of: flag, int", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- initudef(type, argv[2], 1);
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_renudef STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- struct udef_struct *ul;
|
|
|
|
|
- int type, found = 0;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(4, 4, " type oldname newname");
|
|
|
|
|
- if (!egg_strcasecmp(argv[1], "flag"))
|
|
|
|
|
- type = UDEF_FLAG;
|
|
|
|
|
- else if (!egg_strcasecmp(argv[1], "int"))
|
|
|
|
|
- type = UDEF_INT;
|
|
|
|
|
- else {
|
|
|
|
|
- Tcl_AppendResult(irp, "invalid type. Must be one of: flag, int", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- for (ul = udef; ul; ul = ul->next) {
|
|
|
|
|
- if (ul->type == type && !egg_strcasecmp(ul->name, argv[2])) {
|
|
|
|
|
- free(ul->name);
|
|
|
|
|
- ul->name = strdup(argv[3]);
|
|
|
|
|
- found = 1;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!found) {
|
|
|
|
|
- Tcl_AppendResult(irp, "not found", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- } else
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int tcl_deludef STDVAR
|
|
|
|
|
-{
|
|
|
|
|
- struct udef_struct *ul, *ull;
|
|
|
|
|
- int type, found = 0;
|
|
|
|
|
-
|
|
|
|
|
- BADARGS(3, 3, " type name");
|
|
|
|
|
- if (!egg_strcasecmp(argv[1], "flag"))
|
|
|
|
|
- type = UDEF_FLAG;
|
|
|
|
|
- else if (!egg_strcasecmp(argv[1], "int"))
|
|
|
|
|
- type = UDEF_INT;
|
|
|
|
|
- else {
|
|
|
|
|
- Tcl_AppendResult(irp, "invalid type. Must be one of: flag, int", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- }
|
|
|
|
|
- for (ul = udef; ul; ul = ul->next) {
|
|
|
|
|
- ull = ul->next;
|
|
|
|
|
- if (!ull)
|
|
|
|
|
- break;
|
|
|
|
|
- if (ull->type == type && !egg_strcasecmp(ull->name, argv[2])) {
|
|
|
|
|
- ul->next = ull->next;
|
|
|
|
|
- free(ull->name);
|
|
|
|
|
- free_udef_chans(ull->values);
|
|
|
|
|
- free(ull);
|
|
|
|
|
- found = 1;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (udef) {
|
|
|
|
|
- if (udef->type == type && !egg_strcasecmp(udef->name, argv[2])) {
|
|
|
|
|
- ul = udef->next;
|
|
|
|
|
- free(udef->name);
|
|
|
|
|
- free_udef_chans(udef->values);
|
|
|
|
|
- free(udef);
|
|
|
|
|
- udef = ul;
|
|
|
|
|
- found = 1;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!found) {
|
|
|
|
|
- Tcl_AppendResult(irp, "not found", NULL);
|
|
|
|
|
- return TCL_ERROR;
|
|
|
|
|
- } else
|
|
|
|
|
- return TCL_OK;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static tcl_cmds channels_cmds[] =
|
|
|
|
|
-{
|
|
|
|
|
- {"channel", tcl_channel},
|
|
|
|
|
- {"channels", tcl_channels},
|
|
|
|
|
- {"exemptlist", tcl_exemptlist},
|
|
|
|
|
- {"invitelist", tcl_invitelist},
|
|
|
|
|
- {"banlist", tcl_banlist},
|
|
|
|
|
- {"validchan", tcl_validchan},
|
|
|
|
|
- {"getchaninfo", tcl_getchaninfo},
|
|
|
|
|
- {"setchaninfo", tcl_setchaninfo},
|
|
|
|
|
- {"setudef", tcl_setudef},
|
|
|
|
|
- {"renudef", tcl_renudef},
|
|
|
|
|
- {"deludef", tcl_deludef},
|
|
|
|
|
- {NULL, NULL}
|
|
|
|
|
-};
|
|
|