if( Server_int_ParseArgs(1, CommandString, &command, &args, NULL) )
{
- printf("command=%s, args=%s\n", command, args);
+// printf("command=%s, args=%s\n", command, args);
// Is this an error? (just ignore for now)
//args = "";
}
sendf(Client->Socket, "200 User set\n");
}
+/**
+ * \brief Send an item status to the client
+ * \param Client Who to?
+ * \param Item Item to send
+ */
+void Server_int_SendItem(tClient *Client, tItem *Item)
+{
+ char *status = "avail";
+
+ if( Item->Handler->CanDispense )
+ {
+ switch(Item->Handler->CanDispense(Client->UID, Item->ID))
+ {
+ case 0: status = "avail"; break;
+ case 1: status = "sold"; break;
+ default:
+ case -1: status = "error"; break;
+ }
+ }
+
+ sendf(Client->Socket,
+ "202 Item %s:%i %s %i %s\n",
+ Item->Handler->Name, Item->ID, status, Item->Price, Item->Name
+ );
+}
+
/**
* \brief Enumerate the items that the server knows about
*/
for( i = 0; i < giNumItems; i ++ ) {
if( gaItems[i].bHidden ) continue;
- sendf(Client->Socket,
- "202 Item %s:%i %i %s\n",
- gaItems[i].Handler->Name, gaItems[i].ID, gaItems[i].Price, gaItems[i].Name
- );
+ Server_int_SendItem( Client, &gaItems[i] );
}
sendf(Client->Socket, "200 List end\n");
return ;
}
- sendf(Client->Socket,
- "202 Item %s:%i %i %s\n",
- item->Handler->Name, item->ID, item->Price, item->Name
- );
+ Server_int_SendItem( Client, item );
}
void Server_Cmd_DISPENSE(tClient *Client, char *Args)
while( (dest = va_arg(args, char **)) )
{
- printf(" dest = %p\n", dest);
// Trim leading spaces
while( *ArgStr == ' ' || *ArgStr == '\t' )
ArgStr ++;