From cd9f9a8add02597a2998ba74b803ed3fbf81314c Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 27 Nov 2005 01:44:46 +0000 Subject: Added new documentation git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1966 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/module-doc/users_8cpp-source.html | 609 +++++++++++++++++---------------- 1 file changed, 306 insertions(+), 303 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 95ca9e0b8..78de98822 100644 --- a/docs/module-doc/users_8cpp-source.html +++ b/docs/module-doc/users_8cpp-source.html @@ -1,310 +1,313 @@ - + InspIRCd: users.cpp Source File - -
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  *       +------------------------------------+
-00004  *
-00005  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
-00006  *                       E-mail:
-00007  *                <brain@chatspike.net>
-00008  *                <Craig@chatspike.net>
-00009  *     
-00010  * Written by Craig Edwards, Craig McLure, and others.
-00011  * This program is free but copyrighted software; see
-00012  *            the file COPYING for details.
-00013  *
-00014  * ---------------------------------------------------
-00015  */
-00016 
-00017 using namespace std;
-00018 
-00019 #include "inspircd_config.h" 
-00020 #include "channels.h"
-00021 #include "users.h"
-00022 #include "inspircd.h"
-00023 #include <stdio.h>
-00024 #include "inspstring.h"
-00025 #include "helperfuncs.h"
-00026 
-00027 extern std::stringstream config_f;
-00028 extern char ServerName[MAXBUF];
-00029 
-00030 extern time_t TIME;
-00031 
-00032 userrec::userrec()
-00033 {
-00034         // the PROPER way to do it, AVOID bzero at *ALL* costs
-00035         strcpy(nick,"");
-00036         strcpy(ip,"127.0.0.1");
-00037         timeout = 0;
-00038         strcpy(ident,"");
-00039         strcpy(host,"");
-00040         strcpy(dhost,"");
-00041         strcpy(fullname,"");
-00042         strcpy(modes,"");
-00043         server = (char*)FindServerNamePtr(ServerName);
-00044         strcpy(awaymsg,"");
-00045         strcpy(oper,"");
-00046         reset_due = TIME;
-00047         lines_in = 0;
-00048         fd = lastping = signon = idle_lastmsg = nping = registered = 0;
-00049         flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
-00050         haspassed = false;
-00051         dns_done = false;
-00052         recvq = "";
-00053         sendq = "";
-00054         for (int i = 0; i < MAXCHANS; i++)
-00055         {
-00056                 this->chans[i].channel = NULL;
-00057                 this->chans[i].uc_modes = 0;
-00058         }
-00059         invites.clear();
-00060 }
-00061 
-00062 void userrec::CloseSocket()
-00063 {
-00064         shutdown(this->fd,2);
-00065         close(this->fd);
-00066 }
-00067  
-00068 char* userrec::GetFullHost()
-00069 {
-00070         static char result[MAXBUF];
-00071         snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost);
-00072         return result;
-00073 }
-00074 
-00075 int userrec::ReadData(void* buffer, size_t size)
-00076 {
-00077         if (this->fd > -1)
-00078         {
-00079                 return read(this->fd, buffer, size);
-00080         }
-00081         else return 0;
-00082 }
-00083 
-00084 
-00085 char* userrec::GetFullRealHost()
-00086 {
-00087         static char fresult[MAXBUF];
-00088         snprintf(fresult,MAXBUF,"%s!%s@%s",nick,ident,host);
-00089         return fresult;
-00090 }
-00091 
-00092 bool userrec::IsInvited(char* channel)
-00093 {
-00094         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
-00095         {
-00096                 if (i->channel) {
-00097                         if (!strcasecmp(i->channel,channel))
-00098                         {
-00099                                 return true;
-00100                         }
-00101                 }
-00102         }
-00103         return false;
-00104 }
-00105 
-00106 InvitedList* userrec::GetInviteList()
-00107 {
-00108         return &invites;
-00109 }
-00110 
-00111 void userrec::InviteTo(char* channel)
-00112 {
-00113         Invited i;
-00114         strlcpy(i.channel,channel,CHANMAX);
-00115         invites.push_back(i);
-00116 }
-00117 
-00118 void userrec::RemoveInvite(char* channel)
-00119 {
-00120         log(DEBUG,"Removing invites");
-00121         if (channel)
-00122         {
-00123                 if (invites.size())
-00124                 {
-00125                         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
-00126                         {
-00127                                 if (i->channel)
-00128                                 {
-00129                                         if (!strcasecmp(i->channel,channel))
-00130                                         {
-00131                                                 invites.erase(i);
-00132                                                 return;
-00133                                         }
-00134                                 }
-00135                         }
-00136                 }
-00137         }
-00138 }
-00139 
-00140 bool userrec::HasPermission(char* command)
-00141 {
-00142         char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
-00143         char* mycmd;
-00144         char* savept;
-00145         char* savept2;
-00146         
-00147         // are they even an oper at all?
-00148         if (strchr(this->modes,'o'))
-00149         {
-00150                 log(DEBUG,"*** HasPermission: %s is an oper",this->nick);
-00151                 for (int j =0; j < ConfValueEnum("type",&config_f); j++)
-00152                 {
-00153                         ConfValue("type","name",j,TypeName,&config_f);
-00154                         if (!strcmp(TypeName,this->oper))
-00155                         {
-00156                                 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper);
-00157                                 ConfValue("type","classes",j,Classes,&config_f);
-00158                                 char* myclass = strtok_r(Classes," ",&savept);
-00159                                 while (myclass)
-00160                                 {
-00161                                         log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass);
-00162                                         for (int k =0; k < ConfValueEnum("class",&config_f); k++)
-00163                                         {
-00164                                                 ConfValue("class","name",k,ClassName,&config_f);
-00165                                                 if (!strcmp(ClassName,myclass))
-00166                                                 {
-00167                                                         ConfValue("class","commands",k,CommandList,&config_f);
-00168                                                         log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList);
-00169                                                         
-00170                                                         
-00171                                                         mycmd = strtok_r(CommandList," ",&savept2);
-00172                                                         while (mycmd)
-00173                                                         {
-00174                                                                 if (!strcasecmp(mycmd,command))
-00175                                                                 {
-00176                                                                         log(DEBUG,"*** Command %s found, returning true",command);
-00177                                                                         return true;
-00178                                                                 }
-00179                                                                 mycmd = strtok_r(NULL," ",&savept2);
-00180                                                         }
-00181                                                 }
-00182                                         }
-00183                                         myclass = strtok_r(NULL," ",&savept);
-00184                                 }
-00185                         }
-00186                 }
-00187         }
-00188         return false;
-00189 }
-00190 
-00191 
-00192 bool userrec::AddBuffer(std::string a)
-00193 {
-00194         std::string b = "";
-00195         for (int i = 0; i < a.length(); i++)
-00196                 if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7))
-00197                         b = b + a[i];
-00198         std::stringstream stream(recvq);
-00199         stream << b;
-00200         recvq = stream.str();
-00201         int i = 0;
-00202         // count the size of the first line in the buffer.
-00203         while (i < recvq.length())
-00204         {
-00205                 if (recvq[i++] == '\n')
-00206                         break;
-00207         }
-00208         if (recvq.length() > this->recvqmax)
-00209         {
-00210                 this->SetWriteError("RecvQ exceeded");
-00211                 WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
-00212         }
-00213         // return false if we've had more than 600 characters WITHOUT
-00214         // a carriage return (this is BAD, drop the socket)
-00215         return (i < 600);
-00216 }
-00217 
-00218 bool userrec::BufferIsReady()
-00219 {
-00220         for (int i = 0; i < recvq.length(); i++)
-00221                 if (recvq[i] == '\n')
-00222                         return true;
-00223         return false;
-00224 }
-00225 
-00226 void userrec::ClearBuffer()
-00227 {
-00228         recvq = "";
-00229 }
-00230 
-00231 std::string userrec::GetBuffer()
-00232 {
-00233         if (recvq == "")
-00234                 return "";
-00235         char* line = (char*)recvq.c_str();
-00236         std::string ret = "";
-00237         while ((*line != '\n') && (strlen(line)))
-00238         {
-00239                 ret = ret + *line;
-00240                 line++;
-00241         }
-00242         if ((*line == '\n') || (*line == '\r'))
-00243                 line++;
-00244         recvq = line;
-00245         return ret;
-00246 }
-00247 
-00248 void userrec::AddWriteBuf(std::string data)
-00249 {
-00250         if (this->GetWriteError() != "")
-00251                 return;
-00252         if (sendq.length() + data.length() > this->sendqmax)
-00253         {
-00254                 WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
-00255                 this->SetWriteError("SendQ exceeded");
-00256                 return;
-00257         }
-00258         std::stringstream stream;
-00259         stream << sendq << data;
-00260         sendq = stream.str();
-00261 }
-00262 
-00263 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)
-00264 void userrec::FlushWriteBuf()
-00265 {
-00266         if (sendq.length())
-00267         {
-00268                 char* tb = (char*)this->sendq.c_str();
-00269                 int n_sent = write(this->fd,tb,this->sendq.length());
-00270                 if (n_sent == -1)
-00271                 {
-00272                         this->SetWriteError(strerror(errno));
-00273                 }
-00274                 else
-00275                 {
-00276                         // advance the queue
-00277                         tb += n_sent;
-00278                         this->sendq = tb;
-00279                         // update the user's stats counters
-00280                         this->bytes_out += n_sent;
-00281                         this->cmds_out++;
-00282                 }
-00283         }
-00284 }
-00285 
-00286 void userrec::SetWriteError(std::string error)
-00287 {
-00288         log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str());
-00289         // don't try to set the error twice, its already set take the first string.
-00290         if (this->WriteError == "")
-00291                 this->WriteError = error;
-00292 }
-00293 
-00294 std::string userrec::GetWriteError()
-00295 {
-00296         return this->WriteError;
-00297 }
-

Generated on Mon May 30 05:15:21 2005 for InspIRCd by + + + +

users.cpp

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

Generated on Sun Nov 27 01:43:24 2005 for InspIRCd by  -doxygen -1.3.3
+doxygen 1.4.4-20050815
-- cgit v1.2.3