summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
cf1d197)
- This in preparation for adapting the client to categorise the items
in the ncurses GUI.
// === TYPES ===
typedef struct sItem {
// === TYPES ===
typedef struct sItem {
char *Desc;
int Price;
} tItem;
char *Desc;
int Price;
} tItem;
// > Code Type Count ...
CompileRegex(&gArrayRegex, "^([0-9]{3})\\s+([A-Za-z]+)\\s+([0-9]+)", REG_EXTENDED); //
// > Code Type Ident Price Desc
// > Code Type Count ...
CompileRegex(&gArrayRegex, "^([0-9]{3})\\s+([A-Za-z]+)\\s+([0-9]+)", REG_EXTENDED); //
// > Code Type Ident Price Desc
- CompileRegex(&gItemRegex, "^([0-9]{3})\\s+([A-Za-z]+)\\s+([A-Za-z0-9:]+?)\\s+([0-9]+)\\s+(.+)$", REG_EXTENDED);
+ CompileRegex(&gItemRegex, "^([0-9]{3})\\s+([A-Za-z]+)\\s+([A-Za-z]+):([0-9]+)\\s+([0-9]+)\\s+(.+)$", REG_EXTENDED);
// > Code 'SALT' salt
CompileRegex(&gSaltRegex, "^([0-9]{3})\\s+([A-Za-z]+)\\s+(.+)$", REG_EXTENDED);
// > Code 'User' Username Balance Flags
// > Code 'SALT' salt
CompileRegex(&gSaltRegex, "^([0-9]{3})\\s+([A-Za-z]+)\\s+(.+)$", REG_EXTENDED);
// > Code 'User' Username Balance Flags
else
{
for( i = 0; i < giNumItems; i ++ ) {
else
{
for( i = 0; i < giNumItems; i ++ ) {
- printf("%2i %s\t%3i %s\n", i, gaItems[i].Ident, gaItems[i].Price, gaItems[i].Desc);
+ printf("%2i %s:%i\t%3i %s\n", i, gaItems[i].Type, gaItems[i].ID,
+ gaItems[i].Price, gaItems[i].Desc);
}
printf(" q Quit\n");
for(;;)
}
printf(" q Quit\n");
for(;;)
responseCode = atoi(buf);
switch( responseCode )
{
responseCode = atoi(buf);
switch( responseCode )
{
-
- case 200: // Authenticated, return :)
+ case 200: // Autoauth succeeded, return
// Fetch item information
for( i = 0; i < giNumItems; i ++ )
{
// Fetch item information
for( i = 0; i < giNumItems; i ++ )
{
// Get item info
buf = ReadLine(Socket);
// Get item info
buf = ReadLine(Socket);
- RunRegex(&gItemRegex, buf, 6, matches, "Malformed server response");
+ RunRegex(&gItemRegex, buf, 7, matches, "Malformed server response");
buf[ matches[3].rm_eo ] = '\0';
buf[ matches[3].rm_eo ] = '\0';
- gaItems[i].Ident = strdup( buf + matches[3].rm_so );
- gaItems[i].Price = atoi( buf + matches[4].rm_so );
- gaItems[i].Desc = strdup( buf + matches[5].rm_so );
+ gaItems[i].Type = strdup( buf + matches[3].rm_so );
+ gaItems[i].ID = atoi( buf + matches[4].rm_so );
+ gaItems[i].Price = atoi( buf + matches[5].rm_so );
+ gaItems[i].Desc = strdup( buf + matches[6].rm_so );
if( ItemID < 0 || ItemID > giNumItems ) return -1;
// Dispense!
if( ItemID < 0 || ItemID > giNumItems ) return -1;
// Dispense!
- sendf(Socket, "DISPENSE %s\n", gaItems[ItemID].Ident);
+ sendf(Socket, "DISPENSE %s:%i\n", gaItems[ItemID].Type, gaItems[ItemID].ID);
buf = ReadLine(Socket);
responseCode = atoi(buf);
buf = ReadLine(Socket);
responseCode = atoi(buf);
#if USE_LDAP
char *ReadLDAPValue(const char *Filter, char *Value);
#endif
#if USE_LDAP
char *ReadLDAPValue(const char *Filter, char *Value);
#endif
-void HexBin(uint8_t *Dest, int BufSize, char *Src);
+void HexBin(uint8_t *Dest, int BufSize, const char *Src);
// === GLOBALS ===
FILE *gBank_LogFile;
#if USE_LDAP
// === GLOBALS ===
FILE *gBank_LogFile;
#if USE_LDAP
-char *gsLDAPServer = "mussel";
- int giLDAPPort = 389;
+char *gsLDAPPath = "ldapi:///";
fprintf(stderr, "ldap_create: %s\n", ldap_err2string(rv));
exit(1);
}
fprintf(stderr, "ldap_create: %s\n", ldap_err2string(rv));
exit(1);
}
- rv = ldap_initialize(&gpLDAP, "ldap://mussel:389");
+ rv = ldap_initialize(&gpLDAP, gsLDAPPath);
if(rv) {
fprintf(stderr, "ldap_initialize: %s\n", ldap_err2string(rv));
exit(1);
if(rv) {
fprintf(stderr, "ldap_initialize: %s\n", ldap_err2string(rv));
exit(1);
cred.bv_val = "secret";
cred.bv_len = 6;
rv = ldap_sasl_bind_s(gpLDAP, "cn=root,dc=ucc,dc=gu,dc=uwa,dc=edu,dc=au",
cred.bv_val = "secret";
cred.bv_len = 6;
rv = ldap_sasl_bind_s(gpLDAP, "cn=root,dc=ucc,dc=gu,dc=uwa,dc=edu,dc=au",
- "", &cred, NULL, NULL, NULL);
+ "", &cred, NULL, NULL, &servcred);
if(rv) {
fprintf(stderr, "ldap_start_tls_s: %s\n", ldap_err2string(rv));
exit(1);
if(rv) {
fprintf(stderr, "ldap_start_tls_s: %s\n", ldap_err2string(rv));
exit(1);
// Then create the hash from the provided salt
// Compare that with the provided hash
// Then create the hash from the provided salt
// Compare that with the provided hash
- printf("Client %i: Password hash ", Client->ID);
- for(i=0;i<HASH_LENGTH;i++)
+ printf("Password hash ");
+ for(i=0;i<20;i++)
printf("%02x", hash[i]&0xFF);
printf("\n");
}
printf("%02x", hash[i]&0xFF);
printf("\n");
}
#endif
// TODO: Move to another file
#endif
// TODO: Move to another file
-void HexBin(uint8_t *Dest, int BufSize, char *Src)
+void HexBin(uint8_t *Dest, int BufSize, const char *Src)
{
int i;
for( i = 0; i < BufSize; i ++ )
{
int i;
for( i = 0; i < BufSize; i ++ )