From 03be04a9a2d86a4568d09d5e1689dd7ef37c863a Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 14 Dec 2005 14:52:12 +0000 Subject: Added extra docs for new config system git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2417 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/module-doc/users_8cpp-source.html | 535 ++++++++++++++++----------------- 1 file changed, 264 insertions(+), 271 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 85fe1cfcf..2ada48e14 100644 --- a/docs/module-doc/users_8cpp-source.html +++ b/docs/module-doc/users_8cpp-source.html @@ -39,285 +39,278 @@ 00030 #include "commands.h" 00031 #include "helperfuncs.h" 00032 -00033 extern std::stringstream config_f; -00034 extern char ServerName[MAXBUF]; +00033 extern ServerConfig* Config; +00034 extern time_t TIME; 00035 -00036 extern time_t TIME; -00037 -00038 userrec::userrec() -00039 { -00040 // the PROPER way to do it, AVOID bzero at *ALL* costs -00041 strcpy(nick,""); -00042 strcpy(ip,"127.0.0.1"); -00043 timeout = 0; -00044 strcpy(ident,""); -00045 strcpy(host,""); -00046 strcpy(dhost,""); -00047 strcpy(fullname,""); -00048 strcpy(modes,""); -00049 server = (char*)FindServerNamePtr(ServerName); -00050 strcpy(awaymsg,""); -00051 strcpy(oper,""); -00052 reset_due = TIME; -00053 lines_in = 0; -00054 fd = lastping = signon = idle_lastmsg = nping = registered = 0; -00055 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0; -00056 haspassed = false; -00057 dns_done = false; -00058 recvq = ""; -00059 sendq = ""; -00060 for (int i = 0; i < MAXCHANS; i++) -00061 { -00062 this->chans[i].channel = NULL; -00063 this->chans[i].uc_modes = 0; -00064 } -00065 invites.clear(); -00066 } -00067 -00068 userrec::~userrec() -00069 { +00036 userrec::userrec() +00037 { +00038 // the PROPER way to do it, AVOID bzero at *ALL* costs +00039 strcpy(nick,""); +00040 strcpy(ip,"127.0.0.1"); +00041 timeout = 0; +00042 strcpy(ident,""); +00043 strcpy(host,""); +00044 strcpy(dhost,""); +00045 strcpy(fullname,""); +00046 strcpy(modes,""); +00047 server = (char*)FindServerNamePtr(Config->ServerName); +00048 strcpy(awaymsg,""); +00049 strcpy(oper,""); +00050 reset_due = TIME; +00051 lines_in = 0; +00052 fd = lastping = signon = idle_lastmsg = nping = registered = 0; +00053 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0; +00054 haspassed = false; +00055 dns_done = false; +00056 recvq = ""; +00057 sendq = ""; +00058 chans.clear(); +00059 invites.clear(); +00060 } +00061 +00062 userrec::~userrec() +00063 { +00064 } +00065 +00066 void userrec::CloseSocket() +00067 { +00068 shutdown(this->fd,2); +00069 close(this->fd); 00070 } -00071 -00072 void userrec::CloseSocket() +00071 +00072 char* userrec::GetFullHost() 00073 { -00074 shutdown(this->fd,2); -00075 close(this->fd); -00076 } -00077 -00078 char* userrec::GetFullHost() -00079 { -00080 static char result[MAXBUF]; -00081 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost); -00082 return result; -00083 } -00084 -00085 int userrec::ReadData(void* buffer, size_t size) -00086 { -00087 if (this->fd > -1) -00088 { -00089 log(DEBUG,"userrec::ReadData on fd %d",this->fd); -00090 return read(this->fd, buffer, size); -00091 } -00092 else return 0; -00093 } -00094 +00074 static char result[MAXBUF]; +00075 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost); +00076 return result; +00077 } +00078 +00079 int userrec::ReadData(void* buffer, size_t size) +00080 { +00081 if (this->fd > -1) +00082 { +00083 return read(this->fd, buffer, size); +00084 } +00085 else return 0; +00086 } +00087 +00088 +00089 char* userrec::GetFullRealHost() +00090 { +00091 static char fresult[MAXBUF]; +00092 snprintf(fresult,MAXBUF,"%s!%s@%s",nick,ident,host); +00093 return fresult; +00094 } 00095 -00096 char* userrec::GetFullRealHost() +00096 bool userrec::IsInvited(char* channel) 00097 { -00098 static char fresult[MAXBUF]; -00099 snprintf(fresult,MAXBUF,"%s!%s@%s",nick,ident,host); -00100 return fresult; -00101 } -00102 -00103 bool userrec::IsInvited(char* channel) -00104 { -00105 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) -00106 { -00107 if (i->channel) { -00108 if (!strcasecmp(i->channel,channel)) -00109 { -00110 return true; -00111 } -00112 } -00113 } -00114 return false; -00115 } -00116 -00117 InvitedList* userrec::GetInviteList() -00118 { -00119 return &invites; +00098 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) +00099 { +00100 if (i->channel) { +00101 if (!strcasecmp(i->channel,channel)) +00102 { +00103 return true; +00104 } +00105 } +00106 } +00107 return false; +00108 } +00109 +00110 InvitedList* userrec::GetInviteList() +00111 { +00112 return &invites; +00113 } +00114 +00115 void userrec::InviteTo(char* channel) +00116 { +00117 Invited i; +00118 strlcpy(i.channel,channel,CHANMAX); +00119 invites.push_back(i); 00120 } 00121 -00122 void userrec::InviteTo(char* channel) +00122 void userrec::RemoveInvite(char* channel) 00123 { -00124 Invited i; -00125 strlcpy(i.channel,channel,CHANMAX); -00126 invites.push_back(i); -00127 } -00128 -00129 void userrec::RemoveInvite(char* channel) -00130 { -00131 log(DEBUG,"Removing invites"); -00132 if (channel) -00133 { -00134 if (invites.size()) -00135 { -00136 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) -00137 { -00138 if (i->channel) -00139 { -00140 if (!strcasecmp(i->channel,channel)) -00141 { -00142 invites.erase(i); -00143 return; -00144 } -00145 } -00146 } -00147 } -00148 } -00149 } -00150 -00151 bool userrec::HasPermission(char* command) -00152 { -00153 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF]; -00154 char* mycmd; -00155 char* savept; -00156 char* savept2; -00157 -00158 // users on u-lined servers can completely bypass -00159 // all permissions based checks. -00160 // -00161 // of course, if this is sent to a remote server and this -00162 // server is not ulined there, then that other server -00163 // silently drops the command. -00164 if (is_uline(this->server)) -00165 return true; -00166 -00167 // are they even an oper at all? -00168 if (strchr(this->modes,'o')) -00169 { -00170 for (int j =0; j < ConfValueEnum("type",&config_f); j++) -00171 { -00172 ConfValue("type","name",j,TypeName,&config_f); -00173 if (!strcmp(TypeName,this->oper)) -00174 { -00175 ConfValue("type","classes",j,Classes,&config_f); -00176 char* myclass = strtok_r(Classes," ",&savept); -00177 while (myclass) -00178 { -00179 for (int k =0; k < ConfValueEnum("class",&config_f); k++) -00180 { -00181 ConfValue("class","name",k,ClassName,&config_f); -00182 if (!strcmp(ClassName,myclass)) -00183 { -00184 ConfValue("class","commands",k,CommandList,&config_f); -00185 mycmd = strtok_r(CommandList," ",&savept2); -00186 while (mycmd) -00187 { -00188 if ((!strcasecmp(mycmd,command)) || (*mycmd == '*')) -00189 { -00190 return true; -00191 } -00192 mycmd = strtok_r(NULL," ",&savept2); -00193 } -00194 } -00195 } -00196 myclass = strtok_r(NULL," ",&savept); -00197 } -00198 } -00199 } -00200 } -00201 return false; -00202 } -00203 -00204 -00205 bool userrec::AddBuffer(std::string a) -00206 { -00207 std::string b = ""; -00208 for (unsigned int i = 0; i < a.length(); i++) -00209 if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7)) -00210 b = b + a[i]; -00211 std::stringstream stream(recvq); -00212 stream << b; -00213 recvq = stream.str(); -00214 unsigned int i = 0; -00215 // count the size of the first line in the buffer. -00216 while (i < recvq.length()) -00217 { -00218 if (recvq[i++] == '\n') -00219 break; -00220 } -00221 if (recvq.length() > (unsigned)this->recvqmax) -00222 { -00223 this->SetWriteError("RecvQ exceeded"); -00224 WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax); -00225 } -00226 // return false if we've had more than 600 characters WITHOUT -00227 // a carriage return (this is BAD, drop the socket) -00228 return (i < 600); -00229 } -00230 -00231 bool userrec::BufferIsReady() -00232 { -00233 for (unsigned int i = 0; i < recvq.length(); i++) -00234 if (recvq[i] == '\n') -00235 return true; -00236 return false; -00237 } -00238 -00239 void userrec::ClearBuffer() -00240 { -00241 recvq = ""; -00242 } -00243 -00244 std::string userrec::GetBuffer() -00245 { -00246 if (recvq == "") -00247 return ""; -00248 char* line = (char*)recvq.c_str(); -00249 std::string ret = ""; -00250 while ((*line != '\n') && (strlen(line))) -00251 { -00252 ret = ret + *line; -00253 line++; -00254 } -00255 if ((*line == '\n') || (*line == '\r')) -00256 line++; -00257 recvq = line; -00258 return ret; -00259 } -00260 -00261 void userrec::AddWriteBuf(std::string data) -00262 { -00263 if (this->GetWriteError() != "") -00264 return; -00265 if (sendq.length() + data.length() > (unsigned)this->sendqmax) -00266 { -00267 WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax); -00268 this->SetWriteError("SendQ exceeded"); -00269 return; -00270 } -00271 std::stringstream stream; -00272 stream << sendq << data; -00273 sendq = stream.str(); -00274 } -00275 -00276 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it) -00277 void userrec::FlushWriteBuf() -00278 { -00279 if (sendq.length()) -00280 { -00281 char* tb = (char*)this->sendq.c_str(); -00282 int n_sent = write(this->fd,tb,this->sendq.length()); -00283 if (n_sent == -1) -00284 { -00285 this->SetWriteError(strerror(errno)); -00286 } -00287 else -00288 { -00289 // advance the queue -00290 tb += n_sent; -00291 this->sendq = tb; -00292 // update the user's stats counters -00293 this->bytes_out += n_sent; -00294 this->cmds_out++; -00295 } -00296 } -00297 } -00298 -00299 void userrec::SetWriteError(std::string error) -00300 { -00301 log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str()); -00302 // don't try to set the error twice, its already set take the first string. -00303 if (this->WriteError == "") -00304 this->WriteError = error; -00305 } -00306 -00307 std::string userrec::GetWriteError() -00308 { -00309 return this->WriteError; -00310 } -
Generated on Mon Dec 12 18:30:58 2005 for InspIRCd by  +00124 log(DEBUG,"Removing invites"); +00125 if (channel) +00126 { +00127 if (invites.size()) +00128 { +00129 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) +00130 { +00131 if (i->channel) +00132 { +00133 if (!strcasecmp(i->channel,channel)) +00134 { +00135 invites.erase(i); +00136 return; +00137 } +00138 } +00139 } +00140 } +00141 } +00142 } +00143 +00144 bool userrec::HasPermission(char* command) +00145 { +00146 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF]; +00147 char* mycmd; +00148 char* savept; +00149 char* savept2; +00150 +00151 // users on u-lined servers can completely bypass +00152 // all permissions based checks. +00153 // +00154 // of course, if this is sent to a remote server and this +00155 // server is not ulined there, then that other server +00156 // silently drops the command. +00157 if (is_uline(this->server)) +00158 return true; +00159 +00160 // are they even an oper at all? +00161 if (strchr(this->modes,'o')) +00162 { +00163 for (int j =0; j < Config->ConfValueEnum("type",&Config->config_f); j++) +00164 { +00165 Config->ConfValue("type","name",j,TypeName,&Config->config_f); +00166 if (!strcmp(TypeName,this->oper)) +00167 { +00168 Config->ConfValue("type","classes",j,Classes,&Config->config_f); +00169 char* myclass = strtok_r(Classes," ",&savept); +00170 while (myclass) +00171 { +00172 for (int k =0; k < Config->ConfValueEnum("class",&Config->config_f); k++) +00173 { +00174 Config->ConfValue("class","name",k,ClassName,&Config->config_f); +00175 if (!strcmp(ClassName,myclass)) +00176 { +00177 Config->ConfValue("class","commands",k,CommandList,&Config->config_f); +00178 mycmd = strtok_r(CommandList," ",&savept2); +00179 while (mycmd) +00180 { +00181 if ((!strcasecmp(mycmd,command)) || (*mycmd == '*')) +00182 { +00183 return true; +00184 } +00185 mycmd = strtok_r(NULL," ",&savept2); +00186 } +00187 } +00188 } +00189 myclass = strtok_r(NULL," ",&savept); +00190 } +00191 } +00192 } +00193 } +00194 return false; +00195 } +00196 +00197 +00198 bool userrec::AddBuffer(std::string a) +00199 { +00200 std::string b = ""; +00201 for (unsigned int i = 0; i < a.length(); i++) +00202 if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7)) +00203 b = b + a[i]; +00204 std::stringstream stream(recvq); +00205 stream << b; +00206 recvq = stream.str(); +00207 unsigned int i = 0; +00208 // count the size of the first line in the buffer. +00209 while (i < recvq.length()) +00210 { +00211 if (recvq[i++] == '\n') +00212 break; +00213 } +00214 if (recvq.length() > (unsigned)this->recvqmax) +00215 { +00216 this->SetWriteError("RecvQ exceeded"); +00217 WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax); +00218 } +00219 // return false if we've had more than 600 characters WITHOUT +00220 // a carriage return (this is BAD, drop the socket) +00221 return (i < 600); +00222 } +00223 +00224 bool userrec::BufferIsReady() +00225 { +00226 for (unsigned int i = 0; i < recvq.length(); i++) +00227 if (recvq[i] == '\n') +00228 return true; +00229 return false; +00230 } +00231 +00232 void userrec::ClearBuffer() +00233 { +00234 recvq = ""; +00235 } +00236 +00237 std::string userrec::GetBuffer() +00238 { +00239 if (recvq == "") +00240 return ""; +00241 char* line = (char*)recvq.c_str(); +00242 std::string ret = ""; +00243 while ((*line != '\n') && (strlen(line))) +00244 { +00245 ret = ret + *line; +00246 line++; +00247 } +00248 if ((*line == '\n') || (*line == '\r')) +00249 line++; +00250 recvq = line; +00251 return ret; +00252 } +00253 +00254 void userrec::AddWriteBuf(std::string data) +00255 { +00256 if (this->GetWriteError() != "") +00257 return; +00258 if (sendq.length() + data.length() > (unsigned)this->sendqmax) +00259 { +00260 WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax); +00261 this->SetWriteError("SendQ exceeded"); +00262 return; +00263 } +00264 std::stringstream stream; +00265 stream << sendq << data; +00266 sendq = stream.str(); +00267 } +00268 +00269 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it) +00270 void userrec::FlushWriteBuf() +00271 { +00272 if (sendq.length()) +00273 { +00274 char* tb = (char*)this->sendq.c_str(); +00275 int n_sent = write(this->fd,tb,this->sendq.length()); +00276 if (n_sent == -1) +00277 { +00278 this->SetWriteError(strerror(errno)); +00279 } +00280 else +00281 { +00282 // advance the queue +00283 tb += n_sent; +00284 this->sendq = tb; +00285 // update the user's stats counters +00286 this->bytes_out += n_sent; +00287 this->cmds_out++; +00288 } +00289 } +00290 } +00291 +00292 void userrec::SetWriteError(std::string error) +00293 { +00294 log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str()); +00295 // don't try to set the error twice, its already set take the first string. +00296 if (this->WriteError == "") +00297 this->WriteError = error; +00298 } +00299 +00300 std::string userrec::GetWriteError() +00301 { +00302 return this->WriteError; +00303 } +
Generated on Wed Dec 14 14:49:17 2005 for InspIRCd by  doxygen 1.4.4-20050815
-- cgit v1.2.3