From 4d5a17380bc71cabe544b41c7c8a26a292384f3d Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 15 May 2005 17:05:15 +0000 Subject: Added docs for hashcomp git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1396 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/module-doc/users_8cpp-source.html | 510 +++++++++++++++++---------------- 1 file changed, 258 insertions(+), 252 deletions(-) (limited to 'docs/module-doc/users_8cpp-source.html') diff --git a/docs/module-doc/users_8cpp-source.html b/docs/module-doc/users_8cpp-source.html index b1258eb0a..4e2e35443 100644 --- a/docs/module-doc/users_8cpp-source.html +++ b/docs/module-doc/users_8cpp-source.html @@ -4,7 +4,7 @@ -
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members
+
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

users.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
 00002  *       | Inspire Internet Relay Chat Daemon |
 00003  *       +------------------------------------+
@@ -27,259 +27,265 @@
 00020 #include "inspircd.h"
 00021 #include <stdio.h>
 00022 #include "inspstring.h"
-00023 
-00024 extern std::stringstream config_f;
-00025 
-00026 extern time_t TIME;
-00027 
-00028 userrec::userrec()
-00029 {
-00030         // the PROPER way to do it, AVOID bzero at *ALL* costs
-00031         strcpy(nick,"");
-00032         strcpy(ip,"127.0.0.1");
-00033         timeout = 0;
-00034         strcpy(ident,"");
-00035         strcpy(host,"");
-00036         strcpy(dhost,"");
-00037         strcpy(fullname,"");
-00038         strcpy(modes,"");
-00039         strcpy(server,"");
-00040         strcpy(awaymsg,"");
-00041         strcpy(oper,"");
-00042         reset_due = TIME;
-00043         lines_in = 0;
-00044         fd = lastping = signon = idle_lastmsg = nping = registered = 0;
-00045         flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
-00046         haspassed = false;
-00047         dns_done = false;
-00048         recvq = "";
-00049         sendq = "";
-00050         strcpy(result,"");
-00051         for (int i = 0; i < MAXCHANS; i++)
-00052         {
-00053                 this->chans[i].channel = NULL;
-00054                 this->chans[i].uc_modes = 0;
-00055         }
-00056         invites.clear();
-00057 }
-00058 
+00023 #include "helperfuncs.h"
+00024 
+00025 extern std::stringstream config_f;
+00026 
+00027 extern time_t TIME;
+00028 
+00029 userrec::userrec()
+00030 {
+00031         // the PROPER way to do it, AVOID bzero at *ALL* costs
+00032         strcpy(nick,"");
+00033         strcpy(ip,"127.0.0.1");
+00034         timeout = 0;
+00035         strcpy(ident,"");
+00036         strcpy(host,"");
+00037         strcpy(dhost,"");
+00038         strcpy(fullname,"");
+00039         strcpy(modes,"");
+00040         strcpy(server,"");
+00041         strcpy(awaymsg,"");
+00042         strcpy(oper,"");
+00043         reset_due = TIME;
+00044         lines_in = 0;
+00045         fd = lastping = signon = idle_lastmsg = nping = registered = 0;
+00046         flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
+00047         haspassed = false;
+00048         dns_done = false;
+00049         recvq = "";
+00050         sendq = "";
+00051         strcpy(result,"");
+00052         for (int i = 0; i < MAXCHANS; i++)
+00053         {
+00054                 this->chans[i].channel = NULL;
+00055                 this->chans[i].uc_modes = 0;
+00056         }
+00057         invites.clear();
+00058 }
 00059 
-00060  
-00061 char* userrec::GetFullHost()
-00062 {
-00063         snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost);
-00064         return result;
-00065 }
-00066 
+00060 
+00061  
+00062 char* userrec::GetFullHost()
+00063 {
+00064         snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost);
+00065         return result;
+00066 }
 00067 
-00068 char* userrec::GetFullRealHost()
-00069 {
-00070         snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,host);
-00071         return result;
-00072 }
-00073 
-00074 bool userrec::IsInvited(char* channel)
-00075 {
-00076         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
-00077         {
-00078                 if (i->channel) {
-00079                         if (!strcasecmp(i->channel,channel))
-00080                         {
-00081                                 return true;
-00082                         }
-00083                 }
-00084         }
-00085         return false;
-00086 }
-00087 
-00088 void userrec::InviteTo(char* channel)
-00089 {
-00090         Invited i;
-00091         strlcpy(i.channel,channel,CHANMAX);
-00092         invites.push_back(i);
-00093 }
-00094 
-00095 void userrec::RemoveInvite(char* channel)
-00096 {
-00097         log(DEBUG,"Removing invites");
-00098         if (channel)
-00099         {
-00100                 if (invites.size())
-00101                 {
-00102                         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
-00103                         {
-00104                                 if (i->channel)
-00105                                 {
-00106                                         if (!strcasecmp(i->channel,channel))
-00107                                         {
-00108                                                 invites.erase(i);
-00109                                                 return;
-00110                                         }
-00111                                 }
-00112                         }
-00113                 }
-00114         }
-00115 }
-00116 
-00117 bool userrec::HasPermission(char* command)
-00118 {
-00119         char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
-00120         char* mycmd;
-00121         char* savept;
-00122         char* savept2;
-00123         
-00124         // are they even an oper at all?
-00125         if (strchr(this->modes,'o'))
-00126         {
-00127                 log(DEBUG,"*** HasPermission: %s is an oper",this->nick);
-00128                 for (int j =0; j < ConfValueEnum("type",&config_f); j++)
-00129                 {
-00130                         ConfValue("type","name",j,TypeName,&config_f);
-00131                         if (!strcmp(TypeName,this->oper))
-00132                         {
-00133                                 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper);
-00134                                 ConfValue("type","classes",j,Classes,&config_f);
-00135                                 char* myclass = strtok_r(Classes," ",&savept);
-00136                                 while (myclass)
-00137                                 {
-00138                                         log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass);
-00139                                         for (int k =0; k < ConfValueEnum("class",&config_f); k++)
-00140                                         {
-00141                                                 ConfValue("class","name",k,ClassName,&config_f);
-00142                                                 if (!strcmp(ClassName,myclass))
-00143                                                 {
-00144                                                         ConfValue("class","commands",k,CommandList,&config_f);
-00145                                                         log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList);
-00146                                                         
-00147                                                         
-00148                                                         mycmd = strtok_r(CommandList," ",&savept2);
-00149                                                         while (mycmd)
-00150                                                         {
-00151                                                                 if (!strcasecmp(mycmd,command))
-00152                                                                 {
-00153                                                                         log(DEBUG,"*** Command %s found, returning true",command);
-00154                                                                         return true;
-00155                                                                 }
-00156                                                                 mycmd = strtok_r(NULL," ",&savept2);
-00157                                                         }
-00158                                                 }
-00159                                         }
-00160                                         myclass = strtok_r(NULL," ",&savept);
-00161                                 }
-00162                         }
-00163                 }
-00164         }
-00165         return false;
-00166 }
-00167 
-00168 
-00169 bool userrec::AddBuffer(std::string a)
-00170 {
-00171         std::string b = "";
-00172         for (int i = 0; i < a.length(); i++)
-00173                 if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7))
-00174                         b = b + a[i];
-00175         std::stringstream stream(recvq);
-00176         stream << b;
-00177         recvq = stream.str();
-00178         int i = 0;
-00179         // count the size of the first line in the buffer.
-00180         while (i < recvq.length())
-00181         {
-00182                 if (recvq[i++] == '\n')
-00183                         break;
-00184         }
-00185         if (recvq.length() > this->recvqmax)
-00186         {
-00187                 this->SetWriteError("RecvQ exceeded");
-00188                 WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
-00189         }
-00190         // return false if we've had more than 600 characters WITHOUT
-00191         // a carriage return (this is BAD, drop the socket)
-00192         return (i < 600);
-00193 }
-00194 
-00195 bool userrec::BufferIsReady()
-00196 {
-00197         for (int i = 0; i < recvq.length(); i++)
-00198                 if (recvq[i] == '\n')
-00199                         return true;
-00200         return false;
-00201 }
-00202 
-00203 void userrec::ClearBuffer()
-00204 {
-00205         recvq = "";
-00206 }
-00207 
-00208 std::string userrec::GetBuffer()
-00209 {
-00210         if (recvq == "")
-00211                 return "";
-00212         char* line = (char*)recvq.c_str();
-00213         std::string ret = "";
-00214         while ((*line != '\n') && (strlen(line)))
-00215         {
-00216                 ret = ret + *line;
-00217                 line++;
-00218         }
-00219         if ((*line == '\n') || (*line == '\r'))
-00220                 line++;
-00221         recvq = line;
-00222         return ret;
-00223 }
-00224 
-00225 void userrec::AddWriteBuf(std::string data)
-00226 {
-00227         if (this->GetWriteError() != "")
-00228                 return;
-00229         if (sendq.length() + data.length() > this->sendqmax)
-00230         {
-00231                 WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
-00232                 this->SetWriteError("SendQ exceeded");
-00233                 return;
-00234         }
-00235         std::stringstream stream;
-00236         stream << sendq << data;
-00237         sendq = stream.str();
-00238 }
-00239 
-00240 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)
-00241 void userrec::FlushWriteBuf()
-00242 {
-00243         if (sendq.length())
-00244         {
-00245                 char* tb = (char*)this->sendq.c_str();
-00246                 int n_sent = write(this->fd,tb,this->sendq.length());
-00247                 if (n_sent == -1)
-00248                 {
-00249                         this->SetWriteError(strerror(errno));
-00250                 }
-00251                 else
-00252                 {
-00253                         // advance the queue
-00254                         tb += n_sent;
-00255                         this->sendq = tb;
-00256                         // update the user's stats counters
-00257                         this->bytes_out += n_sent;
-00258                         this->cmds_out++;
-00259                 }
-00260         }
-00261 }
-00262 
-00263 void userrec::SetWriteError(std::string error)
-00264 {
-00265         log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str());
-00266         // don't try to set the error twice, its already set take the first string.
-00267         if (this->WriteError == "")
-00268                 this->WriteError = error;
-00269 }
-00270 
-00271 std::string userrec::GetWriteError()
-00272 {
-00273         return this->WriteError;
-00274 }
-

Generated on Fri May 13 15:48:42 2005 for InspIRCd by +00068 +00069 char* userrec::GetFullRealHost() +00070 { +00071 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,host); +00072 return result; +00073 } +00074 +00075 bool userrec::IsInvited(char* channel) +00076 { +00077 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) +00078 { +00079 if (i->channel) { +00080 if (!strcasecmp(i->channel,channel)) +00081 { +00082 return true; +00083 } +00084 } +00085 } +00086 return false; +00087 } +00088 +00089 InvitedList* userrec::GetInviteList() +00090 { +00091 return &invites; +00092 } +00093 +00094 void userrec::InviteTo(char* channel) +00095 { +00096 Invited i; +00097 strlcpy(i.channel,channel,CHANMAX); +00098 invites.push_back(i); +00099 } +00100 +00101 void userrec::RemoveInvite(char* channel) +00102 { +00103 log(DEBUG,"Removing invites"); +00104 if (channel) +00105 { +00106 if (invites.size()) +00107 { +00108 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) +00109 { +00110 if (i->channel) +00111 { +00112 if (!strcasecmp(i->channel,channel)) +00113 { +00114 invites.erase(i); +00115 return; +00116 } +00117 } +00118 } +00119 } +00120 } +00121 } +00122 +00123 bool userrec::HasPermission(char* command) +00124 { +00125 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF]; +00126 char* mycmd; +00127 char* savept; +00128 char* savept2; +00129 +00130 // are they even an oper at all? +00131 if (strchr(this->modes,'o')) +00132 { +00133 log(DEBUG,"*** HasPermission: %s is an oper",this->nick); +00134 for (int j =0; j < ConfValueEnum("type",&config_f); j++) +00135 { +00136 ConfValue("type","name",j,TypeName,&config_f); +00137 if (!strcmp(TypeName,this->oper)) +00138 { +00139 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper); +00140 ConfValue("type","classes",j,Classes,&config_f); +00141 char* myclass = strtok_r(Classes," ",&savept); +00142 while (myclass) +00143 { +00144 log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass); +00145 for (int k =0; k < ConfValueEnum("class",&config_f); k++) +00146 { +00147 ConfValue("class","name",k,ClassName,&config_f); +00148 if (!strcmp(ClassName,myclass)) +00149 { +00150 ConfValue("class","commands",k,CommandList,&config_f); +00151 log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList); +00152 +00153 +00154 mycmd = strtok_r(CommandList," ",&savept2); +00155 while (mycmd) +00156 { +00157 if (!strcasecmp(mycmd,command)) +00158 { +00159 log(DEBUG,"*** Command %s found, returning true",command); +00160 return true; +00161 } +00162 mycmd = strtok_r(NULL," ",&savept2); +00163 } +00164 } +00165 } +00166 myclass = strtok_r(NULL," ",&savept); +00167 } +00168 } +00169 } +00170 } +00171 return false; +00172 } +00173 +00174 +00175 bool userrec::AddBuffer(std::string a) +00176 { +00177 std::string b = ""; +00178 for (int i = 0; i < a.length(); i++) +00179 if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7)) +00180 b = b + a[i]; +00181 std::stringstream stream(recvq); +00182 stream << b; +00183 recvq = stream.str(); +00184 int i = 0; +00185 // count the size of the first line in the buffer. +00186 while (i < recvq.length()) +00187 { +00188 if (recvq[i++] == '\n') +00189 break; +00190 } +00191 if (recvq.length() > this->recvqmax) +00192 { +00193 this->SetWriteError("RecvQ exceeded"); +00194 WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax); +00195 } +00196 // return false if we've had more than 600 characters WITHOUT +00197 // a carriage return (this is BAD, drop the socket) +00198 return (i < 600); +00199 } +00200 +00201 bool userrec::BufferIsReady() +00202 { +00203 for (int i = 0; i < recvq.length(); i++) +00204 if (recvq[i] == '\n') +00205 return true; +00206 return false; +00207 } +00208 +00209 void userrec::ClearBuffer() +00210 { +00211 recvq = ""; +00212 } +00213 +00214 std::string userrec::GetBuffer() +00215 { +00216 if (recvq == "") +00217 return ""; +00218 char* line = (char*)recvq.c_str(); +00219 std::string ret = ""; +00220 while ((*line != '\n') && (strlen(line))) +00221 { +00222 ret = ret + *line; +00223 line++; +00224 } +00225 if ((*line == '\n') || (*line == '\r')) +00226 line++; +00227 recvq = line; +00228 return ret; +00229 } +00230 +00231 void userrec::AddWriteBuf(std::string data) +00232 { +00233 if (this->GetWriteError() != "") +00234 return; +00235 if (sendq.length() + data.length() > this->sendqmax) +00236 { +00237 WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax); +00238 this->SetWriteError("SendQ exceeded"); +00239 return; +00240 } +00241 std::stringstream stream; +00242 stream << sendq << data; +00243 sendq = stream.str(); +00244 } +00245 +00246 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it) +00247 void userrec::FlushWriteBuf() +00248 { +00249 if (sendq.length()) +00250 { +00251 char* tb = (char*)this->sendq.c_str(); +00252 int n_sent = write(this->fd,tb,this->sendq.length()); +00253 if (n_sent == -1) +00254 { +00255 this->SetWriteError(strerror(errno)); +00256 } +00257 else +00258 { +00259 // advance the queue +00260 tb += n_sent; +00261 this->sendq = tb; +00262 // update the user's stats counters +00263 this->bytes_out += n_sent; +00264 this->cmds_out++; +00265 } +00266 } +00267 } +00268 +00269 void userrec::SetWriteError(std::string error) +00270 { +00271 log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str()); +00272 // don't try to set the error twice, its already set take the first string. +00273 if (this->WriteError == "") +00274 this->WriteError = error; +00275 } +00276 +00277 std::string userrec::GetWriteError() +00278 { +00279 return this->WriteError; +00280 } +
Generated on Sun May 15 17:02:06 2005 for InspIRCd by doxygen 1.3.3
-- cgit v1.2.3