- strlcpy(cmd,tmp.c_str(),MAXBUF);
- strlcpy(temp,cmd,MAXBUF);
-
- if (!strchr(cmd,' '))
- {
- /*
- * no parameters, lets skip the formalities and not chop up
- * the string
- */
- log(DEBUG,"About to preprocess command with no params");
- items = 0;
- command_p[0] = NULL;
- parameters = NULL;
- unsigned int tl = strlen(cmd);
- for (unsigned int i = 0; i <= tl; i++)
- {
- cmd[i] = toupper(cmd[i]);
- }
- command = cmd;
- }
- else
- {
- *cmd = 0;
- j = 0;
-
- unsigned int vl = strlen(temp);
- /* strip out extraneous linefeeds through mirc's crappy pasting (thanks Craig) */
- for (unsigned int i = 0; i < vl; i++)
- {
- if ((temp[i] != 10) && (temp[i] != 13) && (temp[i] != 0) && (temp[i] != 7))
- {
- cmd[j++] = temp[i];
- cmd[j] = 0;
- }
- }
-
- /* split the full string into a command plus parameters */
- parameters = p;
- p[0] = ' ';
- p[1] = 0;
-
- command = cmd;
-
- if (strchr(cmd,' '))
- {
- unsigned int cl = strlen(cmd);
-
- for (unsigned int i = 0; i <= cl; i++)
- {
- /* capitalise the command ONLY, leave params intact */
- cmd[i] = toupper(cmd[i]);
- /* are we nearly there yet?! :P */
- if (cmd[i] == ' ')
- {
- command = cmd;
- parameters = cmd+i+1;
- cmd[i] = '\0';
- break;
- }
- }
- }
- else
- {
- for (char* i = cmd; *i; i++)
- {
- *i = toupper(*i);
- }
- }
- }
-
- if (strlen(command)>MAXCOMMAND)
- {
- WriteServ(user->fd,"421 %s %s :Command too long",user->nick,command);
- return;
- }
-
- for (char* x = command; *x; x++)
- {
- if (((*x < 'A') || (*x > 'Z')) && (*x != '.'))
- {
- if (((*x < '0') || (*x> '9')) && (*x != '-'))
- {
- if (strchr("@!\"$%^&*(){}[]_=+;:'#~,<>/?\\|`",*x))
- {
- ServerInstance->stats->statsUnknown++;
- WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
- return;
- }
- }
- }
- }
-
- std::string xcommand = command;
- if ((user->registered != 7) && (xcommand == "SERVER"))
- {
- kill_link(user,"Server connection to non-server port");
- return;
- }
-
- /* Tweak by brain - why was this INSIDE the mainloop? */
- if (parameters)
- {
- if (parameters[0])
- {
- items = this->ProcessParameters(command_p,parameters);
- }
- else
- {
- items = 0;
- command_p[0] = NULL;
- }
- }
- else
- {
- items = 0;
- command_p[0] = NULL;
- }