git.ucc.asn.au
/
tpg
/
opendispense2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9c119e4
)
Fixing crappy code in coke handler, debug in others
author
root
<
[email protected]
>
Sat, 19 Feb 2011 04:16:28 +0000
(12:16 +0800)
committer
root
<
[email protected]
>
Sat, 19 Feb 2011 04:16:28 +0000
(12:16 +0800)
items.cfg
patch
|
blob
|
history
src/cokebank_sqlite/main.c
patch
|
blob
|
history
src/server/handler_coke.c
patch
|
blob
|
history
src/server/main.c
patch
|
blob
|
history
src/server/server.c
patch
|
blob
|
history
diff --git
a/items.cfg
b/items.cfg
index
c2b27e1
..
2d9df3e
100644
(file)
--- a/
items.cfg
+++ b/
items.cfg
@@
-2,8
+2,8
@@
# Type ID Price Description
# Drinks
# Type ID Price Description
# Drinks
-coke 0
75 Screaming Soda
-coke 1
75 Green Solo
+coke 0
200 Blue Powerade
+coke 1
200 Mother Energy Drink
coke 2 75 Solo
coke 3 75 Lemonade
coke 4 75 Orange Foo
coke 2 75 Solo
coke 3 75 Lemonade
coke 4 75 Orange Foo
diff --git
a/src/cokebank_sqlite/main.c
b/src/cokebank_sqlite/main.c
index
504ec4e
..
e539105
100644
(file)
--- a/
src/cokebank_sqlite/main.c
+++ b/
src/cokebank_sqlite/main.c
@@
-15,6
+15,8
@@
#include "../cokebank.h"
#include <sqlite3.h>
#include "../cokebank.h"
#include <sqlite3.h>
+#define DEBUG 1
+
const char * const csBank_DatabaseSetup =
"CREATE TABLE IF NOT EXISTS accounts ("
" acct_id INTEGER PRIMARY KEY NOT NULL,"
const char * const csBank_DatabaseSetup =
"CREATE TABLE IF NOT EXISTS accounts ("
" acct_id INTEGER PRIMARY KEY NOT NULL,"
diff --git
a/src/server/handler_coke.c
b/src/server/handler_coke.c
index
dbc2a81
..
decdf4d
100644
(file)
--- a/
src/server/handler_coke.c
+++ b/
src/server/handler_coke.c
@@
-108,7
+108,9
@@
int Coke_CanDispense(int UNUSED(User), int Item)
// Read from the machine (ignoring empty lines)
while( (ret = ReadLine(sizeof(tmp)-1, tmp)) == 0 );
printf("ret = %i, tmp = '%s'\n", ret, tmp);
// Read from the machine (ignoring empty lines)
while( (ret = ReadLine(sizeof(tmp)-1, tmp)) == 0 );
printf("ret = %i, tmp = '%s'\n", ret, tmp);
- if( tmp[0] == ':' ) {
+ // Read back-echoed lines
+ while( tmp[0] == ':' || tmp[1] != 'l' )
+ {
ret = ReadLine(sizeof(tmp)-1, tmp);
printf("ret = %i, tmp = '%s'\n", ret, tmp);
}
ret = ReadLine(sizeof(tmp)-1, tmp);
printf("ret = %i, tmp = '%s'\n", ret, tmp);
}
@@
-157,7
+159,7
@@
int Coke_CanDispense(int UNUSED(User), int Item)
int Coke_DoDispense(int UNUSED(User), int Item)
{
char tmp[32];
int Coke_DoDispense(int UNUSED(User), int Item)
{
char tmp[32];
- int
i,
ret;
+ int ret;
// Sanity please
if( Item < 0 || Item > 6 ) return -1;
// Sanity please
if( Item < 0 || Item > 6 ) return -1;
@@
-190,17
+192,14
@@
int Coke_DoDispense(int UNUSED(User), int Item)
sprintf(tmp, "d%i\r\n", Item);
write(giCoke_SerialFD, tmp, 4);
sprintf(tmp, "d%i\r\n", Item);
write(giCoke_SerialFD, tmp, 4);
- // Read empty lines
- while( (ret = ReadLine(sizeof(tmp)-1, tmp)) == -1 );
- if( ret == -1 ) return -1;
- // Read d%i
- while( tmp[0] == ':' ) {
+ // Read empty lines and echo-backs
+ do {
ret = ReadLine(sizeof(tmp)-1, tmp);
if( ret == -1 ) return -1;
ret = ReadLine(sizeof(tmp)-1, tmp);
if( ret == -1 ) return -1;
- }
- // Get status
- ret = ReadLine(sizeof(tmp)-1, tmp);
-
if( ret == -1 ) return -1
;
+ #if TRACE_COKE
+ printf("Coke_DoDispense: read %i '%s'\n", ret, tmp);
+ #endif
+
} while( ret == 0 || tmp[0] == ':' || tmp[0] == 'd' )
;
WaitForColon(); // Eat up rest of response
WaitForColon(); // Eat up rest of response
diff --git
a/src/server/main.c
b/src/server/main.c
index
714f513
..
0692d6a
100644
(file)
--- a/
src/server/main.c
+++ b/
src/server/main.c
@@
-103,6
+103,9
@@
int RunRegex(regex_t *regex, const char *string, int nMatches, regmatch_t *match
int ret;
ret = regexec(regex, string, nMatches, matches, 0);
int ret;
ret = regexec(regex, string, nMatches, matches, 0);
+ if( ret == REG_NOMATCH ) {
+ return -1;
+ }
if( ret ) {
size_t len = regerror(ret, regex, NULL, 0);
char errorStr[len];
if( ret ) {
size_t len = regerror(ret, regex, NULL, 0);
char errorStr[len];
diff --git
a/src/server/server.c
b/src/server/server.c
index
17e8549
..
315b129
100644
(file)
--- a/
src/server/server.c
+++ b/
src/server/server.c
@@
-1031,13
+1031,14
@@
void Server_Cmd_USERINFO(tClient *Client, char *Args)
space = strchr(user, ' ');
if(space) *space = '\0';
space = strchr(user, ' ');
if(space) *space = '\0';
- if( giDebugLevel )
- Debug(Client, "User Info '%s'", user);
+ if( giDebugLevel ) Debug(Client, "User Info '%s'", user);
// Get recipient
uid = Bank_GetAcctByName(user);
// Get recipient
uid = Bank_GetAcctByName(user);
+
+ if( giDebugLevel >= 2 ) Debug(Client, "uid = %i", uid);
if( uid == -1 ) {
if( uid == -1 ) {
- sendf(Client->Socket, "404 Invalid user");
+ sendf(Client->Socket, "404 Invalid user
\n
");
return ;
}
return ;
}
UCC
git Repository :: git.ucc.asn.au