Removed lcddriver.c (doesn't do anything, isn't in any makefiles, etc.).
Passed *every* piece of source in this project through indent. I'm setting things up with ctags soon and am actually going to *gasp* use a nice programming environment to continue development in. :)
This commit is contained in:
+46
-61
@@ -23,7 +23,8 @@
|
||||
|
||||
|
||||
|
||||
int parse_all_client_messages()
|
||||
int
|
||||
parse_all_client_messages ()
|
||||
{
|
||||
int i, j;
|
||||
int newtoken, inquote;
|
||||
@@ -33,78 +34,64 @@ int parse_all_client_messages()
|
||||
int argc;
|
||||
char *argv[256];
|
||||
char delimiters[] = " \0";
|
||||
char leftquote[] = "\0\"'`([{\0";
|
||||
char leftquote[] = "\0\"'`([{\0";
|
||||
char rightquote[] = "\0\"'`)]}\0";
|
||||
char errmsg[256];
|
||||
int invalid=0;
|
||||
|
||||
int invalid = 0;
|
||||
|
||||
//debug("parse: Rewinding list...\n");
|
||||
LL_Rewind(clients);
|
||||
LL_Rewind (clients);
|
||||
do {
|
||||
// Get the next client...
|
||||
//debug("parse: Getting client...\n");
|
||||
c = LL_Get(clients);
|
||||
if(c)
|
||||
{
|
||||
c = LL_Get (clients);
|
||||
if (c) {
|
||||
// And parse all its messages...
|
||||
//debug("parse: Getting messages...\n");
|
||||
for(str = client_get_message(c); str; str = client_get_message(c))
|
||||
{
|
||||
debug("parse: ...%s\n", str);
|
||||
for (str = client_get_message (c); str; str = client_get_message (c)) {
|
||||
debug ("parse: ...%s\n", str);
|
||||
// Now, split up the string...
|
||||
//len = strlen(str);
|
||||
argc=0;
|
||||
newtoken=1;
|
||||
inquote=0;
|
||||
for(i=0; str[i]; i++)
|
||||
{
|
||||
if(inquote) // Scan for the end of the quote
|
||||
argc = 0;
|
||||
newtoken = 1;
|
||||
inquote = 0;
|
||||
for (i = 0; str[i]; i++) {
|
||||
if (inquote) // Scan for the end of the quote
|
||||
{
|
||||
if(str[i] == rightquote[inquote])
|
||||
{ // Found the end of the quote
|
||||
inquote=0;
|
||||
if (str[i] == rightquote[inquote]) { // Found the end of the quote
|
||||
inquote = 0;
|
||||
str[i] = 0;
|
||||
newtoken=1;
|
||||
newtoken = 1;
|
||||
}
|
||||
}
|
||||
else // Normal operation; split at delimiters
|
||||
} else // Normal operation; split at delimiters
|
||||
{
|
||||
for(j=1; leftquote[j]; j++)
|
||||
{
|
||||
for (j = 1; leftquote[j]; j++) {
|
||||
// Found the beginning of a new quote...
|
||||
if(str[i] == leftquote[j])
|
||||
{
|
||||
if (str[i] == leftquote[j]) {
|
||||
inquote = j;
|
||||
str[i] = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for(j=0; delimiters[j]; j++)
|
||||
{
|
||||
for (j = 0; delimiters[j]; j++) {
|
||||
// Break into a new string...
|
||||
if(str[i] == delimiters[j])
|
||||
{
|
||||
if (str[i] == delimiters[j]) {
|
||||
str[i] = 0;
|
||||
newtoken = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(newtoken && str[i])
|
||||
{
|
||||
newtoken=0;
|
||||
if (newtoken && str[i]) {
|
||||
newtoken = 0;
|
||||
argv[argc] = str + i;
|
||||
argc++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
}
|
||||
}
|
||||
if(inquote)
|
||||
{
|
||||
sprintf(errmsg, "huh? Unterminated string: missing %c\n",
|
||||
rightquote[inquote]);
|
||||
sock_send_string(c->sock, errmsg);
|
||||
if (inquote) {
|
||||
sprintf (errmsg, "huh? Unterminated string: missing %c\n", rightquote[inquote]);
|
||||
sock_send_string (c->sock, errmsg);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
@@ -117,32 +104,30 @@ int parse_all_client_messages()
|
||||
}
|
||||
*/
|
||||
argv[argc] = NULL;
|
||||
if(argc < 1) continue;
|
||||
|
||||
if (argc < 1)
|
||||
continue;
|
||||
|
||||
// Now find and call the appropriate function...
|
||||
// debug("parse: Finding function...\n");
|
||||
// debug("parse: Finding function...\n");
|
||||
invalid = 1;
|
||||
for(i=0; commands[i].keyword; i++)
|
||||
{
|
||||
// debug("(checking %s)\n", commands[i].keyword);
|
||||
if(0 == strcmp(argv[0], commands[i].keyword))
|
||||
{
|
||||
// debug("(FOUND %s)\n", commands[i].keyword);
|
||||
invalid = commands[i].function(c, argc, argv);
|
||||
// debug("parse: Returned %i...\n", err);
|
||||
for (i = 0; commands[i].keyword; i++) {
|
||||
// debug("(checking %s)\n", commands[i].keyword);
|
||||
if (0 == strcmp (argv[0], commands[i].keyword)) {
|
||||
// debug("(FOUND %s)\n", commands[i].keyword);
|
||||
invalid = commands[i].function (c, argc, argv);
|
||||
// debug("parse: Returned %i...\n", err);
|
||||
}
|
||||
}
|
||||
if(invalid)
|
||||
{
|
||||
if (invalid) {
|
||||
// FIXME: Check for buffer overflows here...
|
||||
sprintf(errmsg, "huh? Invalid command \"%s\"\n", argv[0]);
|
||||
sock_send_string(c->sock, errmsg);
|
||||
sprintf (errmsg, "huh? Invalid command \"%s\"\n", argv[0]);
|
||||
sock_send_string (c->sock, errmsg);
|
||||
}
|
||||
|
||||
free(str); // fixed memory leak?
|
||||
} // end for(str...)
|
||||
} // end if (c)
|
||||
} while (LL_Next(clients) == 0);
|
||||
free (str); // fixed memory leak?
|
||||
} // end for(str...)
|
||||
} // end if (c)
|
||||
} while (LL_Next (clients) == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user