+ reply("OSMSG_NO_SUCH_ALERT", argv[i]);
+ }
+ return 1;
+}
+
+static MODCMD_FUNC(cmd_listdevnull)
+{
+ struct helpfile_table tbl;
+ unsigned int count = 0, ii = 0;
+ char *on,*off,*half;
+ on = "X";
+ off = "-";
+ half = "1/2";
+
+ dict_iterator_t it;
+ for (it = dict_first(opserv_devnull_classes); it; it = iter_next(it)) {
+ count++;
+ }
+ tbl.length = count+1;
+ tbl.width = 15;
+ tbl.flags = 0;
+ tbl.flags = TABLE_NO_FREE;
+ tbl.contents = malloc(tbl.length * sizeof(tbl.contents[0]));
+ tbl.contents[0] = malloc(tbl.width * sizeof(tbl.contents[0][0]));
+ tbl.contents[0][0] = "Name";
+ tbl.contents[0][1] = "MC";
+ tbl.contents[0][2] = "UT";
+ tbl.contents[0][3] = "FL";
+ tbl.contents[0][4] = "CH";
+ tbl.contents[0][5] = "IH";
+ tbl.contents[0][6] = "SI";
+ tbl.contents[0][7] = "IH²";
+ tbl.contents[0][8] = "oC";
+ tbl.contents[0][9] = "oM";
+ tbl.contents[0][10] = "+k";
+ tbl.contents[0][11] = "+S";
+ tbl.contents[0][12] = "+X";
+ tbl.contents[0][13] = "MaxQ";
+ tbl.contents[0][14] = "OpMe";
+ if(!count) {
+ table_send(cmd->parent->bot, user->nick, 0, NULL, tbl);
+ reply("MSG_NONE");
+ free(tbl.contents[0]);
+ free(tbl.contents);
+ return 0;
+ }
+ for (it = dict_first(opserv_devnull_classes); it; it = iter_next(it)) {
+ struct devnull_class *th = iter_data(it);
+ tbl.contents[++ii] = malloc(tbl.width * sizeof(tbl.contents[0][0]));
+ tbl.contents[ii][0] = th->name;
+ if(DEVNULL_HAS_PRIV(th, CHANLIMIT)) {
+ tbl.contents[ii][1] = strtab(th->maxchan);
+ } else {
+ tbl.contents[ii][1] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, UNLIMITTARGET)) {
+ tbl.contents[ii][2] = on;
+ } else {
+ tbl.contents[ii][2] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, NOFLOOD)) {
+ tbl.contents[ii][3] = on;
+ } else if(DEVNULL_HAS_PRIV(th, HALFFLOOD)) {
+ tbl.contents[ii][3] = half;
+ } else {
+ tbl.contents[ii][3] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, CHANHIDE)) {
+ tbl.contents[ii][4] = on;
+ } else {
+ tbl.contents[ii][4] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, IDLEHIDE)) {
+ tbl.contents[ii][5] = on;
+ } else {
+ tbl.contents[ii][5] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, CHSERVMODE)) {
+ tbl.contents[ii][6] = on;
+ } else {
+ tbl.contents[ii][6] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, XTRAOPMODE)) {
+ tbl.contents[ii][7] = on;
+ } else {
+ tbl.contents[ii][7] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, NETSERVMODE)) {
+ tbl.contents[ii][8] = on;
+ } else {
+ tbl.contents[ii][8] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, SEEIDLE)) {
+ tbl.contents[ii][9] = on;
+ } else {
+ tbl.contents[ii][9] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, FORCEIDLEHIDE)) {
+ tbl.contents[ii][10] = on;
+ } else {
+ tbl.contents[ii][10] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, OVERRIDECC)) {
+ tbl.contents[ii][11] = on;
+ } else {
+ tbl.contents[ii][11] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, OVERRIDENOAMSG)) {
+ tbl.contents[ii][12] = on;
+ } else {
+ tbl.contents[ii][12] = off;
+ }
+ if(DEVNULL_HAS_PRIV(th, MAXSENDQ)) {
+ char maxsenqbuf[MAXLEN];
+ sprintf(maxsenqbuf, "%lu", th->maxsendq);
+ tbl.contents[ii][13] = strdup(maxsenqbuf);
+ } else {
+ tbl.contents[ii][13] = strdup(off);
+ }
+ if(DEVNULL_HAS_PRIV(th, OPME)) {
+ tbl.contents[ii][14] = on;
+ } else {
+ tbl.contents[ii][14] = off;
+ }
+ }
+ table_send(cmd->parent->bot, user->nick, 0, NULL, tbl);
+ for(ii = 1; ii < tbl.length; ++ii) {
+ free(tbl.contents[ii][13]);
+ free(tbl.contents[ii]);
+ }
+ free(tbl.contents[0]);
+ free(tbl.contents);
+ send_message_type(4, user, opserv,"-");
+ /*
+ tbl.contents[0][1] = "MC";
+ tbl.contents[0][2] = "UT";
+ tbl.contents[0][3] = "FL";
+ tbl.contents[0][4] = "CH";
+ tbl.contents[0][5] = "IH";
+ tbl.contents[0][6] = "SI";
+ tbl.contents[0][7] = "IH²";
+ tbl.contents[0][8] = "oC";
+ tbl.contents[0][9] = "oM";
+ tbl.contents[0][10] = "+k";
+ tbl.contents[0][11] = "+S";
+ tbl.contents[0][12] = "+X";
+ tbl.contents[0][13] = "MaxQ";
+ */
+ send_message_type(4, user, opserv,"MC = MaxChan");
+ send_message_type(4, user, opserv,"UT = UnlimitTargets");
+ send_message_type(4, user, opserv,"FL = Flood (1 = 1/2 flood, X = unlimited)");
+ send_message_type(4, user, opserv,"CH = Channel Hide (mode +n)");
+ send_message_type(4, user, opserv,"IH = Idle Hide (mode +I)");
+ send_message_type(4, user, opserv,"SI = See Idle");
+ send_message_type(4, user, opserv,"IH² = Idle Hide (override SI)");
+ send_message_type(4, user, opserv,"oC = Color override (mode +c)");
+ send_message_type(4, user, opserv,"oM = AMsg override");
+ send_message_type(4, user, opserv,"+k = ChanServ Mode (mode +k)");
+ send_message_type(4, user, opserv,"+S = NetServ Mode (mode +S)");
+ send_message_type(4, user, opserv,"+X = XtraOp Mode (mode +X)");
+ send_message_type(4, user, opserv,"OpMe = ChanServ opme command");
+ return 1;
+}
+
+static MODCMD_FUNC(cmd_adddevnull)
+{
+
+ if (dict_find(opserv_devnull_classes, argv[1], NULL)) {
+ reply("OSMSG_DEVNULL_FOUND", argv[1]);
+ return 0;
+ }
+
+ opserv_add_devnull_class(argv[1], 0, 0, 0, 0);
+ reply("OSMSG_DEVNULL_ADDED",argv[1]);
+ return 1;
+}
+
+
+static MODCMD_FUNC(cmd_deldevnull)
+{
+ unsigned int n;
+
+ for (n=1; n<argc; n++) {
+ struct devnull_class *th = dict_find(opserv_devnull_classes, argv[n], NULL);
+ if (!th)
+ continue;
+ nickserv_devnull_delete(th->id);
+ dict_remove(opserv_devnull_classes, argv[n]);
+ reply("OSMSG_DEVNULL_REMOVED",argv[n]);
+ }
+ return 1;
+}
+
+static MODCMD_FUNC(cmd_renamedevnull)
+{
+ struct devnull_class *th;
+ if (dict_find(opserv_devnull_classes, argv[2], NULL)) {
+ reply("OSMSG_DEVNULL_FOUND", argv[2]);
+ return 0;
+ }
+ if ((th = dict_find(opserv_devnull_classes, argv[1], NULL))) {
+ opserv_add_devnull_class(argv[2], th->id, th->modes, th->maxchan, th->maxsendq);
+ dict_remove(opserv_devnull_classes, argv[1]);
+ reply("OSMSG_DEVNULL_RENAMED",argv[1],argv[2]);
+ } else {
+ reply("OSMSG_DEVNULL_NOTFOUND", argv[1]);
+ return 0;
+ }
+ return 1;
+}
+
+static MODCMD_FUNC(cmd_setdevnull)
+{
+ struct devnull_class *th;
+ unsigned int offset=0;
+ if ((th = dict_find(opserv_devnull_classes, argv[offset+1], NULL))) {
+ if (argc > 3) {
+ unsigned int ii;
+ for( ii = 0; argv[offset+2][ ii ]; ii++)
+ argv[offset+2][ ii ] = toupper( argv[offset+2][ ii ] );
+ for( ii = 0; argv[offset+3][ ii ]; ii++)
+ argv[offset+3][ ii ] = toupper( argv[offset+3][ ii ] );
+
+ if(!strcmp("CHANLIMIT",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, CHANLIMIT);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ DEVNULL_SET_PRIV(th, CHANLIMIT);
+ th->maxchan = strtoul(argv[offset+3], NULL, 0);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ }
+ } else if(!strcmp("UNLIMITTARGET",argv[offset+2]) || !strcmp("UNLIMITEDTARGET",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, UNLIMITTARGET);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, UNLIMITTARGET);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("FLOOD",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, HALFFLOOD);
+ DEVNULL_CLEAR_PRIV(th, NOFLOOD);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, NOFLOOD);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("HALF",argv[offset+3]) || !strcmp("2",argv[offset+3]) || !strcmp("1/2",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, HALFFLOOD);
+ DEVNULL_CLEAR_PRIV(th, NOFLOOD);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("CHANHIDE",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, CHANHIDE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, CHANHIDE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("IDLEHIDE",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, IDLEHIDE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, IDLEHIDE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("CHSERVMODE",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, CHSERVMODE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, CHSERVMODE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("XTRAOPMODE",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, XTRAOPMODE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, XTRAOPMODE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("NETSERVMODE",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, NETSERVMODE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, NETSERVMODE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("SEEIDLE",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, SEEIDLE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, SEEIDLE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("FORCEIDLEHIDE",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, FORCEIDLEHIDE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, FORCEIDLEHIDE);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("OVERRIDECC",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, OVERRIDECC);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, OVERRIDECC);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("OVERRIDENOAMSG",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, OVERRIDENOAMSG);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, OVERRIDENOAMSG);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else if(!strcmp("MAXSENDQ",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, MAXSENDQ);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ DEVNULL_SET_PRIV(th, MAXSENDQ);
+ th->maxsendq = strtoul(argv[offset+3], NULL, 0);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ }
+ }
+ else if(!strcmp("OPME",argv[offset+2])) {
+ if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) {
+ DEVNULL_CLEAR_PRIV(th, OPME);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) {
+ DEVNULL_SET_PRIV(th, OPME);
+ reply("OSMSG_DEVNULL_SET_DONE");
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]);
+ }
+ } else {
+ reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+2]);
+ }
+
+ } else {
+ reply("OSMSG_DEVNULL_SET", th->name);
+ if(DEVNULL_HAS_PRIV(th, CHANLIMIT)) {
+ reply("OSMSG_DEVNULL_SET_A_i", th->maxchan);
+ } else {
+ reply("OSMSG_DEVNULL_SET_A", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, UNLIMITTARGET)) {
+ reply("OSMSG_DEVNULL_SET_B", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_B", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, NOFLOOD)) {
+ reply("OSMSG_DEVNULL_SET_C", "on");
+ } else if(DEVNULL_HAS_PRIV(th, HALFFLOOD)) {
+ reply("OSMSG_DEVNULL_SET_C", "half");
+ } else {
+ reply("OSMSG_DEVNULL_SET_C", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, CHANHIDE)) {
+ reply("OSMSG_DEVNULL_SET_E", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_E", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, IDLEHIDE)) {
+ reply("OSMSG_DEVNULL_SET_F", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_F", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, CHSERVMODE)) {
+ reply("OSMSG_DEVNULL_SET_G", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_G", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, XTRAOPMODE)) {
+ reply("OSMSG_DEVNULL_SET_H", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_H", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, NETSERVMODE)) {
+ reply("OSMSG_DEVNULL_SET_I", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_I", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, SEEIDLE)) {
+ reply("OSMSG_DEVNULL_SET_J", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_J", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, FORCEIDLEHIDE)) {
+ reply("OSMSG_DEVNULL_SET_K", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_K", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, OVERRIDECC)) {
+ reply("OSMSG_DEVNULL_SET_L", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_L", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, OVERRIDENOAMSG)) {
+ reply("OSMSG_DEVNULL_SET_M", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_M", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, MAXSENDQ)) {
+ reply("OSMSG_DEVNULL_SET_N_i", th->maxsendq);
+ } else {
+ reply("OSMSG_DEVNULL_SET_N", "off");
+ }
+ if(DEVNULL_HAS_PRIV(th, OPME)) {
+ reply("OSMSG_DEVNULL_SET_OPME", "on");
+ } else {
+ reply("OSMSG_DEVNULL_SET_OPME", "off");
+ }
+ }
+ } else {
+ reply("OSMSG_DEVNULL_NOTFOUND", argv[offset+1]);
+ return 0;
+ }
+ return 1;
+}
+
+struct devnull_class *devnull_find_id(unsigned int id) {
+ dict_iterator_t it;
+ for (it = dict_first(opserv_devnull_classes); it; it = iter_next(it)) {
+ struct devnull_class *th = iter_data(it);
+ if(th->id == id)
+ return th;
+ }
+ return NULL;
+}
+
+struct devnull_class *devnull_find_name(const char *name) {
+ struct devnull_class *th;
+ if ((th = dict_find(opserv_devnull_classes, name, NULL))) {
+ return th;
+ }
+ return NULL;
+}
+
+int devnull_user_has_priv(struct handle_info *hi, int devnull_priv) {
+ if(devnull_check_priv_func) {
+ struct devnull_class ext_class = ((struct devnull_class (*)(struct handle_info *))devnull_check_priv_func)(hi);
+ if((ext_class.modes & devnull_priv))
+ return (ext_class.modes & devnull_priv);