]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - docs/man/man3/userrec.3
Added docs for new smaller memory footprint classes
[user/henk/code/inspircd.git] / docs / man / man3 / userrec.3
index 7e5c3ea11cfa4fc50cdf97538d0a0eacbac186b3..c5564873a0ede70147abf3912d5aa0da7b5a87d7 100644 (file)
@@ -1,4 +1,4 @@
-.TH "userrec" 3 "7 May 2005" "InspIRCd" \" -*- nroff -*-
+.TH "userrec" 3 "12 May 2005" "InspIRCd" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
@@ -61,6 +61,22 @@ Inherits \fBconnection\fP.
 .RI "std::string \fBGetBuffer\fP ()"
 .br
 .RI "\fIThis method returns the first available string at the tail end of the buffer and advances the tail end of the buffer past the string. \fP"
+.ti -1c
+.RI "void \fBSetWriteError\fP (std::string error)"
+.br
+.RI "\fISets the write error for a connection. \fP"
+.ti -1c
+.RI "std::string \fBGetWriteError\fP ()"
+.br
+.RI "\fIReturns the write error which last occured on this connection or an empty string if none occured. \fP"
+.ti -1c
+.RI "void \fBAddWriteBuf\fP (std::string data)"
+.br
+.RI "\fIAdds to the user's write buffer. \fP"
+.ti -1c
+.RI "void \fBFlushWriteBuf\fP ()"
+.br
+.RI "\fIFlushes as much of the user's buffer to the file descriptor as possible. \fP"
 .in -1c
 .SS "Public Attributes"
 
@@ -70,11 +86,11 @@ Inherits \fBconnection\fP.
 .br
 .RI "\fIThe users nickname. \fP"
 .ti -1c
-.RI "char \fBident\fP [64]"
+.RI "char \fBident\fP [16]"
 .br
 .RI "\fIThe users ident reply. \fP"
 .ti -1c
-.RI "char \fBdhost\fP [256]"
+.RI "char \fBdhost\fP [160]"
 .br
 .RI "\fIThe host displayed to non-opers (used for cloaking etc). \fP"
 .ti -1c
@@ -105,7 +121,7 @@ Inherits \fBconnection\fP.
 .br
 .RI "\fINumber of lines the user can place into the buffer (up to the global NetBufferSize bytes) before they are disconnected for excess flood. \fP"
 .ti -1c
-.RI "unsigned long \fBtimeout\fP"
+.RI "unsigned int \fBtimeout\fP"
 .br
 .RI "\fINumber of seconds this user is given to send USER/NICK If they do not send their details in this time limit they will be disconnected. \fP"
 .ti -1c
@@ -117,7 +133,7 @@ Inherits \fBconnection\fP.
 .br
 .RI "\fITrue when \fBDNS\fP lookups are completed. \fP"
 .ti -1c
-.RI "unsigned long \fBpingmax\fP"
+.RI "unsigned int \fBpingmax\fP"
 .br
 .RI "\fINumber of seconds between PINGs for this user (set from <connect:allow> tag. \fP"
 .ti -1c
@@ -129,7 +145,11 @@ Inherits \fBconnection\fP.
 .br
 .RI "\fIUser's receive queue. \fP"
 .ti -1c
-.RI "long \fBlines_in\fP"
+.RI "std::string \fBsendq\fP"
+.br
+.RI "\fIUser's send queue. \fP"
+.ti -1c
+.RI "int \fBlines_in\fP"
 .br
 .RI "\fIFlood counters. \fP"
 .ti -1c
@@ -138,6 +158,17 @@ Inherits \fBconnection\fP.
 .ti -1c
 .RI "long \fBthreshold\fP"
 .br
+.ti -1c
+.RI "std::string \fBWriteError\fP"
+.br
+.ti -1c
+.RI "long \fBsendqmax\fP"
+.br
+.RI "\fIMaximum size this user's sendq can become. \fP"
+.ti -1c
+.RI "long \fBrecvqmax\fP"
+.br
+.RI "\fIMaximum size this user's recvq can become. \fP"
 .in -1c
 .SS "Private Attributes"
 
@@ -153,14 +184,14 @@ Holds all information about a user This class stores all information about a use
 
 Everything about a connection is stored here primarily, from the user's socket ID (file descriptor) through to the user's nickname and hostname. Use the Find method of the server class to locate a specific user by nickname. 
 .PP
-Definition at line 98 of file users.h.
+Definition at line 108 of file users.h.
 .SH "Constructor & Destructor Documentation"
 .PP 
 .SS "userrec::userrec ()"
 .PP
 Definition at line 28 of file users.cpp.
 .PP
-References awaymsg, connection::bytes_in, connection::bytes_out, ucrec::channel, chans, connection::cmds_in, connection::cmds_out, dhost, dns_done, connection::fd, flood, fullname, connection::haspassed, connection::host, ident, connection::idle_lastmsg, connection::inbuf, invites, connection::ip, connection::lastping, lines_in, modes, nick, connection::nping, oper, connection::port, recvq, connection::registered, reset_due, result, server, connection::signon, TIME, timeout, and ucrec::uc_modes.
+References awaymsg, connection::bytes_in, connection::bytes_out, ucrec::channel, chans, connection::cmds_in, connection::cmds_out, dhost, dns_done, connection::fd, flood, fullname, connection::haspassed, connection::host, ident, connection::idle_lastmsg, invites, connection::ip, connection::lastping, lines_in, modes, nick, connection::nping, oper, connection::port, recvq, connection::registered, reset_due, result, sendq, server, connection::signon, TIME, timeout, and ucrec::uc_modes.
 .PP
 .nf
 29 {
@@ -173,17 +204,17 @@ References awaymsg, connection::bytes_in, connection::bytes_out, ucrec::channel,
 36         strcpy(dhost,'');
 37         strcpy(fullname,'');
 38         strcpy(modes,'');
-39         strcpy(inbuf,'');
-40         strcpy(server,'');
-41         strcpy(awaymsg,'');
-42         strcpy(oper,'');
-43         reset_due = TIME;
-44         lines_in = 0;
-45         fd = lastping = signon = idle_lastmsg = nping = registered = 0;
-46         flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
-47         haspassed = false;
-48         dns_done = false;
-49         recvq = '';
+39         strcpy(server,'');
+40         strcpy(awaymsg,'');
+41         strcpy(oper,'');
+42         reset_due = TIME;
+43         lines_in = 0;
+44         fd = lastping = signon = idle_lastmsg = nping = registered = 0;
+45         flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
+46         haspassed = false;
+47         dns_done = false;
+48         recvq = '';
+49         sendq = '';
 50         strcpy(result,'');
 51         for (int i = 0; i < MAXCHANS; i++)
 52         {
@@ -195,10 +226,10 @@ References awaymsg, connection::bytes_in, connection::bytes_out, ucrec::channel,
 .fi
 .SS "virtual userrec::~\fBuserrec\fP ()\fC [inline, virtual]\fP"
 .PP
-Definition at line 195 of file users.h.
+Definition at line 222 of file users.h.
 .PP
 .nf
-195 {  }
+222 {  }
 .fi
 .SH "Member Function Documentation"
 .PP 
@@ -206,7 +237,7 @@ Definition at line 195 of file users.h.
 .PP
 This method adds data to the buffer of the user. The buffer can grow to any size within limits of the available memory, managed by the size of a std::string, however if any individual line in the buffer grows over 600 bytes in length (which is 88 chars over the RFC-specified limit per line) then the method will return false and the text will not be inserted.Definition at line 169 of file users.cpp.
 .PP
-References recvq.
+References recvq, recvqmax, and SetWriteError().
 .PP
 .nf
 170 {
@@ -224,60 +255,114 @@ References recvq.
 182                 if (recvq[i++] == '\n')
 183                         break;
 184         }
-185         // return false if we've had more than 600 characters WITHOUT
-186         // a carriage return (this is BAD, drop the socket)
-187         return (i < 600);
-188 }
+185         if (recvq.length() > this->recvqmax)
+186         {
+187                 this->SetWriteError('RecvQ exceeded');
+188                 WriteOpers('*** User %s RecvQ of %d exceeds connect class maximum of %d',this->nick,recvq.length(),this->recvqmax);
+189         }
+190         // return false if we've had more than 600 characters WITHOUT
+191         // a carriage return (this is BAD, drop the socket)
+192         return (i < 600);
+193 }
+.fi
+.SS "void userrec::AddWriteBuf (std::string data)"
+.PP
+Adds to the user's write buffer. You may add any amount of text up to this users sendq value, if you exceed the sendq value, \fBSetWriteError()\fP will be called to set the users error string to 'SendQ exceeded', and further buffer adds will be dropped.Definition at line 225 of file users.cpp.
+.PP
+References GetWriteError(), sendq, sendqmax, and SetWriteError().
+.PP
+.nf
+226 {
+227         if (this->GetWriteError() != '')
+228                 return;
+229         if (sendq.length() + data.length() > this->sendqmax)
+230         {
+231                 WriteOpers('*** User %s SendQ of %d exceeds connect class maximum of %d',this->nick,sendq.length() + data.length(),this->sendqmax);
+232                 this->SetWriteError('SendQ exceeded');
+233                 return;
+234         }
+235         std::stringstream stream;
+236         stream << sendq << data;
+237         sendq = stream.str();
+238 }
 .fi
 .SS "bool userrec::BufferIsReady ()"
 .PP
-This method returns true if the buffer contains at least one carriage return character (e.g. one complete line may be read)Definition at line 190 of file users.cpp.
+This method returns true if the buffer contains at least one carriage return character (e.g. one complete line may be read)Definition at line 195 of file users.cpp.
 .PP
 References recvq.
 .PP
 .nf
-191 {
-192         for (int i = 0; i < recvq.length(); i++)
-193                 if (recvq[i] == '\n')
-194                         return true;
-195         return false;
-196 }
+196 {
+197         for (int i = 0; i < recvq.length(); i++)
+198                 if (recvq[i] == '\n')
+199                         return true;
+200         return false;
+201 }
 .fi
 .SS "void userrec::ClearBuffer ()"
 .PP
-This function clears the entire buffer by setting it to an empty string. Definition at line 198 of file users.cpp.
+This function clears the entire buffer by setting it to an empty string. Definition at line 203 of file users.cpp.
 .PP
 References recvq.
 .PP
 Referenced by Server::PseudoToUser(), and Server::UserToPseudo().
 .PP
 .nf
-199 {
-200         recvq = '';
-201 }
+204 {
+205         recvq = '';
+206 }
+.fi
+.SS "void userrec::FlushWriteBuf ()"
+.PP
+Flushes as much of the user's buffer to the file descriptor as possible. This function may not always flush the entire buffer, rather instead as much of it as it possibly can. If the send() call fails to send the entire buffer, the buffer position is advanced forwards and the rest of the data sent at the next call to this method.Definition at line 241 of file users.cpp.
+.PP
+References connection::bytes_out, connection::cmds_out, sendq, and SetWriteError().
+.PP
+.nf
+242 {
+243         if (sendq.length())
+244         {
+245                 char* tb = (char*)this->sendq.c_str();
+246                 int n_sent = write(this->fd,tb,this->sendq.length());
+247                 if (n_sent == -1)
+248                 {
+249                         this->SetWriteError(strerror(errno));
+250                 }
+251                 else
+252                 {
+253                         // advance the queue
+254                         tb += n_sent;
+255                         this->sendq = tb;
+256                         // update the user's stats counters
+257                         this->bytes_out += n_sent;
+258                         this->cmds_out++;
+259                 }
+260         }
+261 }
 .fi
 .SS "std::string userrec::GetBuffer ()"
 .PP
-This method returns the first available string at the tail end of the buffer and advances the tail end of the buffer past the string. This means it is a one way operation in a similar way to strtok(), and multiple calls return multiple lines if they are available. The results of this function if there are no lines to be read are unknown, always use \fBBufferIsReady()\fP to check if it is ok to read the buffer before calling \fBGetBuffer()\fP.Definition at line 203 of file users.cpp.
+This method returns the first available string at the tail end of the buffer and advances the tail end of the buffer past the string. This means it is a one way operation in a similar way to strtok(), and multiple calls return multiple lines if they are available. The results of this function if there are no lines to be read are unknown, always use \fBBufferIsReady()\fP to check if it is ok to read the buffer before calling \fBGetBuffer()\fP.Definition at line 208 of file users.cpp.
 .PP
 References recvq.
 .PP
 .nf
-204 {
-205         if (recvq == '')
-206                 return '';
-207         char* line = (char*)recvq.c_str();
-208         std::string ret = '';
-209         while ((*line != '\n') && (strlen(line)))
-210         {
-211                 ret = ret + *line;
-212                 line++;
-213         }
-214         if ((*line == '\n') || (*line == '\r'))
-215                 line++;
-216         recvq = line;
-217         return ret;
-218 }
+209 {
+210         if (recvq == '')
+211                 return '';
+212         char* line = (char*)recvq.c_str();
+213         std::string ret = '';
+214         while ((*line != '\n') && (strlen(line)))
+215         {
+216                 ret = ret + *line;
+217                 line++;
+218         }
+219         if ((*line == '\n') || (*line == '\r'))
+220                 line++;
+221         recvq = line;
+222         return ret;
+223 }
 .fi
 .SS "char * userrec::GetFullHost ()\fC [virtual]\fP"
 .PP
@@ -303,6 +388,19 @@ References connection::host, ident, nick, and result.
 71         return result;
 72 }
 .fi
+.SS "std::string userrec::GetWriteError ()"
+.PP
+Returns the write error which last occured on this connection or an empty string if none occured. Definition at line 271 of file users.cpp.
+.PP
+References WriteError.
+.PP
+Referenced by AddWriteBuf().
+.PP
+.nf
+272 {
+273         return this->WriteError;
+274 }
+.fi
 .SS "bool userrec::HasPermission (char * command)"
 .PP
 Returns true or false for if a user can execute a privilaged oper command. This is done by looking up their oper type from \fBuserrec::oper\fP, then referencing this to their oper classes and checking the commands they can execute.Definition at line 117 of file users.cpp.
@@ -421,102 +519,138 @@ References DEBUG, and invites.
 114         }
 115 }
 .fi
+.SS "void userrec::SetWriteError (std::string error)"
+.PP
+Sets the write error for a connection. This is done because the actual disconnect of a client may occur at an inopportune time such as half way through /LIST output. The WriteErrors of clients are checked at a more ideal time (in the mainloop) and errored clients purged.Definition at line 263 of file users.cpp.
+.PP
+References DEBUG, and WriteError.
+.PP
+Referenced by AddBuffer(), AddWriteBuf(), and FlushWriteBuf().
+.PP
+.nf
+264 {
+265         log(DEBUG,'Setting error string for %s to '%s'',this->nick,error.c_str());
+266         // don't try to set the error twice, its already set take the first string.
+267         if (this->WriteError == '')
+268                 this->WriteError = error;
+269 }
+.fi
 .SH "Member Data Documentation"
 .PP 
 .SS "char \fBuserrec::awaymsg\fP[512]"
 .PP
-The user's away message. If this string is empty, the user is not marked as away.Definition at line 141 of file users.h.
+The user's away message. If this string is empty, the user is not marked as away.Definition at line 151 of file users.h.
 .PP
 Referenced by userrec().
 .SS "\fBucrec\fP \fBuserrec::chans\fP[MAXCHANS]"
 .PP
-Definition at line 132 of file users.h.
+Definition at line 142 of file users.h.
 .PP
 Referenced by Server::PseudoToUser(), and userrec().
-.SS "char \fBuserrec::dhost\fP[256]"
+.SS "char \fBuserrec::dhost\fP[160]"
 .PP
-The host displayed to non-opers (used for cloaking etc). This usually matches the value of \fBuserrec::host\fP.Definition at line 120 of file users.h.
+The host displayed to non-opers (used for cloaking etc). This usually matches the value of \fBuserrec::host\fP.Definition at line 130 of file users.h.
 .PP
 Referenced by GetFullHost(), and userrec().
 .SS "bool \fBuserrec::dns_done\fP"
 .PP
-True when \fBDNS\fP lookups are completed. Definition at line 169 of file users.h.
+True when \fBDNS\fP lookups are completed. Definition at line 179 of file users.h.
 .PP
 Referenced by userrec().
 .SS "int \fBuserrec::flood\fP"
 .PP
-Number of lines the user can place into the buffer (up to the global NetBufferSize bytes) before they are disconnected for excess flood. Definition at line 152 of file users.h.
+Number of lines the user can place into the buffer (up to the global NetBufferSize bytes) before they are disconnected for excess flood. Definition at line 162 of file users.h.
 .PP
 Referenced by userrec().
 .SS "char \fBuserrec::fullname\fP[128]"
 .PP
-The users full name. Definition at line 124 of file users.h.
+The users full name. Definition at line 134 of file users.h.
 .PP
 Referenced by userrec().
-.SS "char \fBuserrec::ident\fP[64]"
+.SS "char \fBuserrec::ident\fP[16]"
 .PP
-The users ident reply. Definition at line 115 of file users.h.
+The users ident reply. Definition at line 125 of file users.h.
 .PP
 Referenced by GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), userrec(), and Server::UserToPseudo().
 .SS "\fBInvitedList\fP \fBuserrec::invites\fP\fC [private]\fP"
 .PP
-A list of channels the user has a pending invite to. Definition at line 104 of file users.h.
+A list of channels the user has a pending invite to. Definition at line 114 of file users.h.
 .PP
 Referenced by InviteTo(), IsInvited(), RemoveInvite(), and userrec().
-.SS "long \fBuserrec::lines_in\fP"
+.SS "int \fBuserrec::lines_in\fP"
 .PP
-Flood counters. Definition at line 189 of file users.h.
+Flood counters. Definition at line 204 of file users.h.
 .PP
 Referenced by userrec().
 .SS "char \fBuserrec::modes\fP[MAXBUF]"
 .PP
-The user's mode string. This may contain any of the following RFC characters: o, w, s, i Your module may define other mode characters as it sees fit.Definition at line 130 of file users.h.
+The user's mode string. This may contain any of the following RFC characters: o, w, s, i Your module may define other mode characters as it sees fit.Definition at line 140 of file users.h.
 .PP
 Referenced by userrec().
 .SS "char \fBuserrec::nick\fP[NICKMAX]"
 .PP
-The users nickname. An invalid nickname indicates an unregistered connection prior to the NICK command.Definition at line 111 of file users.h.
+The users nickname. An invalid nickname indicates an unregistered connection prior to the NICK command.Definition at line 121 of file users.h.
 .PP
 Referenced by ConfigReader::DumpErrors(), GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), and userrec().
 .SS "char \fBuserrec::oper\fP[NICKMAX]"
 .PP
-The oper type they logged in as, if they are an oper. This is used to check permissions in operclasses, so that we can say 'yay' or 'nay' to any commands they issue. The value of this is the value of a valid 'type name=' tag.Definition at line 165 of file users.h.
+The oper type they logged in as, if they are an oper. This is used to check permissions in operclasses, so that we can say 'yay' or 'nay' to any commands they issue. The value of this is the value of a valid 'type name=' tag.Definition at line 175 of file users.h.
 .PP
 Referenced by userrec().
 .SS "char \fBuserrec::password\fP[MAXBUF]"
 .PP
-Password specified by the user when they registered. This is stored even if the  block doesnt need a password, so that modules may check it.Definition at line 179 of file users.h.
-.SS "unsigned long \fBuserrec::pingmax\fP"
+Password specified by the user when they registered. This is stored even if the  block doesnt need a password, so that modules may check it.Definition at line 189 of file users.h.
+.SS "unsigned int \fBuserrec::pingmax\fP"
 .PP
-Number of seconds between PINGs for this user (set from <connect:allow> tag. Definition at line 173 of file users.h.
+Number of seconds between PINGs for this user (set from <connect:allow> tag. Definition at line 183 of file users.h.
 .SS "std::string \fBuserrec::recvq\fP"
 .PP
-User's receive queue. Lines from the IRCd awaiting processing are stored here. Upgraded april 2005, old system a bit hairy.Definition at line 185 of file users.h.
+User's receive queue. Lines from the IRCd awaiting processing are stored here. Upgraded april 2005, old system a bit hairy.Definition at line 195 of file users.h.
 .PP
 Referenced by AddBuffer(), BufferIsReady(), ClearBuffer(), GetBuffer(), and userrec().
+.SS "long \fBuserrec::recvqmax\fP"
+.PP
+Maximum size this user's recvq can become. Definition at line 218 of file users.h.
+.PP
+Referenced by AddBuffer().
 .SS "time_t \fBuserrec::reset_due\fP"
 .PP
-Definition at line 190 of file users.h.
+Definition at line 205 of file users.h.
 .PP
 Referenced by userrec().
 .SS "char \fBuserrec::result\fP[256]"
 .PP
-Stores the result of the last GetFullHost or GetRealHost call. You may use this to increase the speed of use of this class.Definition at line 146 of file users.h.
+Stores the result of the last GetFullHost or GetRealHost call. You may use this to increase the speed of use of this class.Definition at line 156 of file users.h.
 .PP
 Referenced by GetFullHost(), GetFullRealHost(), and userrec().
+.SS "std::string \fBuserrec::sendq\fP"
+.PP
+User's send queue. Lines waiting to be sent are stored here until their buffer is flushed.Definition at line 200 of file users.h.
+.PP
+Referenced by AddWriteBuf(), FlushWriteBuf(), and userrec().
+.SS "long \fBuserrec::sendqmax\fP"
+.PP
+Maximum size this user's sendq can become. Definition at line 214 of file users.h.
+.PP
+Referenced by AddWriteBuf().
 .SS "char \fBuserrec::server\fP[256]"
 .PP
-The server the user is connected to. Definition at line 136 of file users.h.
+The server the user is connected to. Definition at line 146 of file users.h.
 .PP
 Referenced by userrec().
 .SS "long \fBuserrec::threshold\fP"
 .PP
-Definition at line 191 of file users.h.
-.SS "unsigned long \fBuserrec::timeout\fP"
+Definition at line 206 of file users.h.
+.SS "unsigned int \fBuserrec::timeout\fP"
 .PP
-Number of seconds this user is given to send USER/NICK If they do not send their details in this time limit they will be disconnected. Definition at line 158 of file users.h.
+Number of seconds this user is given to send USER/NICK If they do not send their details in this time limit they will be disconnected. Definition at line 168 of file users.h.
 .PP
 Referenced by userrec().
+.SS "std::string \fBuserrec::WriteError\fP"
+.PP
+Definition at line 210 of file users.h.
+.PP
+Referenced by GetWriteError(), and SetWriteError().
 
 .SH "Author"
 .PP