+char cflagsbuf[256];
+char cflagsmyinfo[256];
+
+int chmode_flags[256];
+
+/* OPTIMIZE ME! -- dwr */
+void
+construct_noparam_modes(void)
+{
+ int i;
+ char *ptr = cflagsbuf;
+ char *ptr2 = cflagsmyinfo;
+ static int prev_chmode_flags[256];
+
+ *ptr = '\0';
+ *ptr2 = '\0';
+
+ for(i = 0; i < 256; i++)
+ {
+ if( !(chmode_table[i].set_func == chm_ban) &&
+ !(chmode_table[i].set_func == chm_forward) &&
+ !(chmode_table[i].set_func == chm_throttle) &&
+ !(chmode_table[i].set_func == chm_key) &&
+ !(chmode_table[i].set_func == chm_limit) &&
+ !(chmode_table[i].set_func == chm_op) &&
+ !(chmode_table[i].set_func == chm_voice))
+ {
+ chmode_flags[i] = chmode_table[i].mode_type;
+ }
+ else
+ {
+ chmode_flags[i] = 0;
+ }
+
+ if (prev_chmode_flags[i] != 0 && prev_chmode_flags[i] != chmode_flags[i])
+ {
+ if (chmode_flags[i] == 0)
+ {
+ chmode_table[i].set_func = chm_orphaned;
+ sendto_realops_snomask(SNO_DEBUG, L_ALL, "Cmode +%c is now orphaned", i);
+ }
+ else
+ {
+ sendto_realops_snomask(SNO_DEBUG, L_ALL, "Orphaned cmode +%c is picked up by module", i);
+ }
+ chmode_flags[i] = prev_chmode_flags[i];
+ }
+ else
+ prev_chmode_flags[i] = chmode_flags[i];
+
+ switch (chmode_flags[i])
+ {
+ case MODE_EXLIMIT:
+ case MODE_DISFORWARD:
+ if(ConfigChannel.use_forward)
+ {
+ *ptr++ = (char) i;
+ }
+
+ break;
+ case MODE_REGONLY:
+ if(rb_dlink_list_length(&service_list))
+ {
+ *ptr++ = (char) i;
+ }
+
+ break;
+ default:
+ if(chmode_flags[i] != 0)
+ {
+ *ptr++ = (char) i;
+ }
+ }
+
+ /* Should we leave orphaned check here? -- dwr */
+ if(!(chmode_table[i].set_func == chm_nosuch) && !(chmode_table[i].set_func == chm_orphaned))
+ {
+ *ptr2++ = (char) i;
+ }
+ }
+
+ *ptr++ = '\0';
+ *ptr2++ = '\0';
+}
+
+/*
+ * find_umode_slot
+ *
+ * inputs - NONE
+ * outputs - an available cflag bitmask or
+ * 0 if no cflags are available
+ * side effects - NONE
+ */
+unsigned int
+find_cflag_slot(void)
+{
+ unsigned int all_cflags = 0, my_cflag = 0, i;
+
+ for (i = 0; i < 256; i++)
+ all_cflags |= chmode_flags[i];
+
+ for (my_cflag = 1; my_cflag && (all_cflags & my_cflag);
+ my_cflag <<= 1);
+
+ return my_cflag;
+}
+
+static int