2 Client/Server Dispense Protocol
4 The protocol is ASCII based, similar to the FTP protocol
5 All server responses are on one line and are prefixed by a three digit response code.
9 200 Command succeeded, no extra information
10 201 Command succeeded, array follows (<length> <items> <items> ...)
11 202 Command succeeded, per-command format
13 401 Not Authenticated (or Authentication failure)
14 402 Balance insufficient
15 403 User not allowed to perform this action
16 404 Bad other username
19 500 Unknown Dispense Failure
23 <item_id> represents the item ID
24 Item IDs are allowed to contain any non-whitespace character, but in
25 general they will be limited to the standard alpha-numeric set
29 s 100 SALT <string>\n or 100 User Set\n (If no salt used)
30 c PASS <hash>\n (Hex-Encoded SHA-1 Hash of <username><salt><password>)
31 s 200 Auth OK\n or 401 Auth Failure\n
32 User is now authenticated
33 --- Alternate Method (Implicit Trust Authentication) ---
34 If the client is connecting from a trusted machine on a root port then
35 automatic authentication is allowed
36 c AUTOAUTH <username>\n
37 s 200 Auth OK\n or 404 Bad Username\n or 401 Untrusted\n
40 --- Dispense an item ---
41 c DISPENSE <item_id>\n
42 s 200 Dispense OK\n or 402 Poor You\n or 500 Dispense Error\n or 406 Bad Item\n
43 --- Give to another user ---
44 c GIVE <user> <ammount> <reason>\n
45 s 200 Give OK\n or 402 Poor You\n or 404 Bad User\n
46 --- Update balance ---
47 c ADD <user> <ammount> <reason>\n
48 s 200 Add OK\n or 403 Not Coke\n or 404 Bad User\n
52 s 201 Items <count> <item_id> <item_id> ...\n
53 --- Get Item Information ---
54 c ITEM_INFO <item_id>\n
55 s 202 Item <item_id> <price> <description>\n
57 c SET <user> <balance> <reason>\n
58 s 200 Set OK\n or 403 Not allowed\n or 404 Bad User\n
59 --- Get Users Balances ---
60 c ENUM_USERS[ <max balance>]\n
61 s 201 Users <count> <username> <username> ...\n
62 --- Get a User's Balance ---
64 s 202 User <username> <balance>\n