]> jfr.im git - solanum.git/blobdiff - modules/m_services.c
gcc7 fixes: NICKLEN -> NAMELEN
[solanum.git] / modules / m_services.c
index 24878ad1f040c2ffb6c9d1f1f018a1e5de4cd3e4..6633319d950468449a522829ee59605292bbe0ed 100644 (file)
@@ -25,8 +25,6 @@
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id: m_services.c 1907 2006-08-29 19:18:15Z jilles $
  */
 
 #include "stdinc.h"
@@ -34,8 +32,7 @@
 #include "send.h"
 #include "channel.h"
 #include "client.h"
-#include "common.h"
-#include "config.h"
+#include "defaults.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "s_conf.h"
@@ -47,6 +44,9 @@
 #include "modules.h"
 #include "whowas.h"
 #include "monitor.h"
+#include "supported.h"
+
+static const char services_desc[] = "Provides support for running a services daemon";
 
 static int _modinit(void);
 static void _moddeinit(void);
@@ -54,10 +54,10 @@ static void _moddeinit(void);
 static void mark_services(void);
 static void unmark_services(void);
 
-static int me_su(struct Client *, struct Client *, int, const char **);
-static int me_login(struct Client *, struct Client *, int, const char **);
-static int me_rsfnc(struct Client *, struct Client *, int, const char **);
-static int me_nickdelay(struct Client *, struct Client *, int, const char **);
+static void me_su(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void me_login(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void me_rsfnc(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void me_nickdelay(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 static void h_svc_server_introduced(hook_data_client *);
 static void h_svc_whois(hook_data_client *);
@@ -66,19 +66,19 @@ static void h_svc_conf_read_start(void *);
 static void h_svc_conf_read_end(void *);
 
 struct Message su_msgtab = {
-       "SU", 0, 0, 0, MFLG_SLOW,
+       "SU", 0, 0, 0, 0,
        {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_su, 2}, mg_ignore}
 };
 struct Message login_msgtab = {
-       "LOGIN", 0, 0, 0, MFLG_SLOW,
+       "LOGIN", 0, 0, 0, 0,
        {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_login, 2}, mg_ignore}
 };
 struct Message rsfnc_msgtab = {
-       "RSFNC", 0, 0, 0, MFLG_SLOW,
+       "RSFNC", 0, 0, 0, 0,
        {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_rsfnc, 4}, mg_ignore}
 };
 struct Message nickdelay_msgtab = {
-       "NICKDELAY", 0, 0, 0, MFLG_SLOW,
+       "NICKDELAY", 0, 0, 0, 0,
        {mg_unreg, mg_ignore, mg_ignore, mg_ignore, {me_nickdelay, 3}, mg_ignore}
 };
 
@@ -95,23 +95,25 @@ mapi_hfn_list_av1 services_hfnlist[] = {
        { NULL, NULL }
 };
 
-DECLARE_MODULE_AV1(services, _modinit, _moddeinit, services_clist, NULL, services_hfnlist, "$Revision: 1907 $");
+DECLARE_MODULE_AV2(services, _modinit, _moddeinit, services_clist, NULL, services_hfnlist, NULL, NULL, services_desc);
 
 static int
 _modinit(void)
 {
        mark_services();
+       add_isupport("FNC", isupport_string, "");
        return 0;
 }
 
 static void
 _moddeinit(void)
 {
+       delete_isupport("FNC");
        unmark_services();
 }
 
-static int
-me_su(struct Client *client_p, struct Client *source_p,
+static void
+me_su(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
        struct Client *target_p;
@@ -120,85 +122,61 @@ me_su(struct Client *client_p, struct Client *source_p,
        {
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                        "Non-service server %s attempting to execute services-only command SU", source_p->name);
-               return 0;
+               return;
        }
 
        if((target_p = find_client(parv[1])) == NULL)
-               return 0;
+               return;
 
        if(!target_p->user)
-               return 0;
+               return;
 
        if(EmptyString(parv[2]))
                target_p->user->suser[0] = '\0';
        else
                rb_strlcpy(target_p->user->suser, parv[2], sizeof(target_p->user->suser));
 
-       sendto_common_channels_local_butone(target_p, CLICAP_ACCOUNT_NOTIFY, ":%s!%s@%s ACCOUNT %s",
+       sendto_common_channels_local_butone(target_p, CLICAP_ACCOUNT_NOTIFY, NOCAPS, ":%s!%s@%s ACCOUNT %s",
                                            target_p->name, target_p->username, target_p->host,
                                            EmptyString(target_p->user->suser) ? "*" : target_p->user->suser);
 
        invalidate_bancache_user(target_p);
-
-       return 0;
 }
 
-static int
-me_login(struct Client *client_p, struct Client *source_p,
+static void
+me_login(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
        if(!IsPerson(source_p))
-               return 0;
+               return;
 
        rb_strlcpy(source_p->user->suser, parv[1], sizeof(source_p->user->suser));
-       return 0;
-}
-
-static int
-clean_nick(const char *nick)
-{
-       int len = 0;
-
-       if(EmptyString(nick) || *nick == '-' || IsDigit(*nick))
-               return 0;
-
-       for(; *nick; nick++)
-       {
-               len++;
-               if(!IsNickChar(*nick))
-                       return 0;
-       }
-
-       if(len >= NICKLEN)
-               return 0;
-
-       return 1;
 }
 
-static int
-me_rsfnc(struct Client *client_p, struct Client *source_p,
+static void
+me_rsfnc(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
        struct Client *target_p;
        struct Client *exist_p;
        time_t newts, curts;
-       char note[NICKLEN + 10];
+       char note[NAMELEN + 10];
 
        if(!(source_p->flags & FLAGS_SERVICE))
        {
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                        "Non-service server %s attempting to execute services-only command RSFNC", source_p->name);
-               return 0;
+               return;
        }
 
        if((target_p = find_person(parv[1])) == NULL)
-               return 0;
+               return;
 
        if(!MyClient(target_p))
-               return 0;
+               return;
 
-       if(!clean_nick(parv[2]))
-               return 0;
+       if(!clean_nick(parv[2], 0) || IsDigit(parv[2][0]))
+               return;
 
        curts = atol(parv[4]);
 
@@ -207,7 +185,7 @@ me_rsfnc(struct Client *client_p, struct Client *source_p,
         * nicknames before the RSFNC arrives.. --anfl
         */
        if(target_p->tsinfo != curts)
-               return 0;
+               return;
 
        if((exist_p = find_named_client(parv[2])))
        {
@@ -235,7 +213,7 @@ me_rsfnc(struct Client *client_p, struct Client *source_p,
                                        parv[2]);
                }
 
-               rb_snprintf(buf, sizeof(buf), "Killed (%s (Nickname regained by services))",
+               snprintf(buf, sizeof(buf), "Killed (%s (Nickname regained by services))",
                        me.name);
                exit_client(NULL, exist_p, &me, buf);
        }
@@ -258,11 +236,11 @@ doit:
                        target_p->name, parv[2], target_p->username,
                        target_p->host);
 
-       sendto_common_channels_local(target_p, NOCAPS, ":%s!%s@%s NICK :%s",
+       sendto_common_channels_local(target_p, NOCAPS, NOCAPS, ":%s!%s@%s NICK :%s",
                                target_p->name, target_p->username,
                                target_p->host, parv[2]);
 
-       add_history(target_p, 1);
+       whowas_add_history(target_p, 1);
        sendto_server(NULL, NULL, CAP_TS6, NOCAPS, ":%s NICK %s :%ld",
                        use_id(target_p), parv[2], (long) target_p->tsinfo);
 
@@ -274,9 +252,8 @@ doit:
 
        del_all_accepts(target_p);
 
-       rb_snprintf(note, NICKLEN + 10, "Nick: %s", target_p->name);
+       snprintf(note, sizeof(note), "Nick: %s", target_p->name);
        rb_note(target_p->localClient->F, note);
-       return 0;
 }
 
 /*
@@ -284,8 +261,8 @@ doit:
 **      parv[1] = duration in seconds (0 to remove)
 **      parv[2] = nick
 */
-static int
-me_nickdelay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+static void
+me_nickdelay(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        int duration;
        struct nd_entry *nd;
@@ -294,13 +271,13 @@ me_nickdelay(struct Client *client_p, struct Client *source_p, int parc, const c
        {
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                        "Non-service server %s attempting to execute services-only command NICKDELAY", source_p->name);
-               return 0;
+               return;
        }
 
        duration = atoi(parv[1]);
        if (duration <= 0)
        {
-               nd = irc_dictionary_retrieve(nd_dict, parv[2]);
+               nd = rb_dictionary_retrieve(nd_dict, parv[2]);
                if (nd != NULL)
                        free_nd_entry(nd);
        }
@@ -309,12 +286,10 @@ me_nickdelay(struct Client *client_p, struct Client *source_p, int parc, const c
                if (duration > 86400)
                        duration = 86400;
                add_nd_entry(parv[2]);
-               nd = irc_dictionary_retrieve(nd_dict, parv[2]);
+               nd = rb_dictionary_retrieve(nd_dict, parv[2]);
                if (nd != NULL)
                        nd->expire = rb_current_time() + duration;
        }
-
-       return 0;
 }
 
 static void