diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-02 19:34:57 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-02 19:34:57 +0000 |
commit | c3b861b2507dd2ef52802c69a2d737925846e2e0 (patch) | |
tree | 0acd160336f53426b273af935f3ecb5189117cee | |
parent | d7c9583c8ec819444efdb326d15b2ff92a881089 (diff) |
Added IS_SINGLE, see comment in include/inspircd.h
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3438 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/inspircd.h | 21 | ||||
-rw-r--r-- | src/cmd_who.cpp | 4 | ||||
-rw-r--r-- | src/inspircd_io.cpp | 2 | ||||
-rw-r--r-- | src/mode.cpp | 6 | ||||
-rwxr-xr-x | src/svn-rev.sh | 2 |
5 files changed, 12 insertions, 23 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index 56fe5678b..db30ca7cb 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -57,22 +57,11 @@ // crucial defines #define ETIREDGERBILS EAGAIN -/* -flags for use with WriteMode - -#define WM_AND 1 -#define WM_OR 2 - -flags for use with OnUserPreMessage and OnUserPreNotice - -#define TYPE_USER 1 -#define TYPE_CHANNEL 2 -#define TYPE_SERVER 3 - -#define IS_LOCAL(x) (x->fd > -1) -#define IS_REMOTE(x) (x->fd < 0) -#define IS_MODULE_CREATED(x) (x->fd == FD_MAGIC_NUMBER) -*/ +// This define is used in place of strcmp when we +// want to check if a char* string contains only one +// letter. Pretty fast, its just two compares and an +// addition. +#define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) ) class serverstats { diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp index 624006758..307e86d91 100644 --- a/src/cmd_who.cpp +++ b/src/cmd_who.cpp @@ -70,7 +70,7 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user) /* theres more to do here, but for now just close the socket */ if (pcnt == 1) { - if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*"))) + if ((IS_SINGLE(parameters[0],'0)) || (IS_SINGLE(parameters[0],'*'))) { if ((user->chans.size()) && (user->chans[0].channel)) { @@ -165,7 +165,7 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user) } if (pcnt == 2) { - if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")) && (!strcmp(parameters[1],"o"))) + if ((IS_SINGLE(parameters[0],'0')) || (IS_SINGLE(parameters[0],'*')) && (IS_SINGLE(parameters[1],'o'))) { for (std::vector<userrec*>::iterator i = all_opers.begin(); i != all_opers.end(); i++) { diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp index c0cf997b0..e47cf9dda 100644 --- a/src/inspircd_io.cpp +++ b/src/inspircd_io.cpp @@ -1183,7 +1183,7 @@ int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server struct in_addr addy; inet_aton(addr,&addy); server.sin_family = AF_INET; - if (!strcmp(addr,"")) + if (!*addr) { server.sin_addr.s_addr = htonl(INADDR_ANY); } diff --git a/src/mode.cpp b/src/mode.cpp index 30000dfe2..f14c3bcb5 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -1460,10 +1460,10 @@ void cmd_mode::Handle (char **parameters, int pcnt, userrec *user) if ((b[z] == '-') || (b[z] == '+')) b[z] = '\0'; - if ((!b[0]) || (!strcmp(b,"+")) || (!strcmp(b,"-"))) + if ((!*b) || (IS_SINGLE(b,"+")) || (IS_SINGLE(b,"-"))) return; - if (strcmp(b,"")) + if (*b) { WriteTo(user, dest, "MODE %s :%s", dest->nick, b); FOREACH_MOD(I_OnMode,OnMode(user, dest, TYPE_USER, b)); @@ -1711,7 +1711,7 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user) if ((b[z] == '-') || (b[z] == '+')) b[z] = '\0'; - if ((!b[0]) || (!strcmp(b,"+")) || (!strcmp(b,"-"))) + if ((!*b) || (IS_SINGLE(b,'+')) || (IS_SINGLE(b,'-'))) return; if (*b) diff --git a/src/svn-rev.sh b/src/svn-rev.sh index 2d41e01be..9b66cc15d 100755 --- a/src/svn-rev.sh +++ b/src/svn-rev.sh @@ -1 +1 @@ -echo 3434 +echo 3437 |