--- /dev/null
+
+CFLAGS := -Wall -Werror -g
+LDFLAGS := -g
+
+BIN := ../../dispense
+OBJ := main.o
+
+DEPFILES := $(OBJ:%.o=%.d)
+
+.PHONY: all clean
+
+all: $(BIN)
+
+clean:
+ $(RM) $(BIN) $(OBJ)
+
+%.o: %.c
+ $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
+ $(CC) -M -MT $@ -o $*.d $< $(CPPFLAGS)
+
+-include $(DEPFILES)
--- /dev/null
+/*
+ * OpenDispense 2
+ * UCC (University [of WA] Computer Club) Electronic Accounting System
+ * - Dispense Client
+ *
+ * main.c - Core and Initialisation
+ *
+ * This file is licenced under the 3-clause BSD Licence. See the file
+ * COPYING for full details.
+ */
+#include <stdio.h>
+
+// === GLOBALS ===
+char *gsDispenseServer = "martello";
+ int giDispensePort = 11020;
+
+// === CODE ===
+int main(int argc, char *argv[])
+{
+ // Connect to server
+
+
+ // Determine what to do
+ if( argc > 1 )
+ {
+ if( strcmp(argv[1], "acct") == 0 )
+ {
+ return 0;
+ }
+ }
+
+ // Ask server for stock list
+
+ // Display the list for the user
+ // and choose what to dispense
+
+ return 0;
+}
}
}
+char *Server_Cmd_GIVE(tClient *Client, char *Args)
+{
+ char *recipient, *ammount, *reason;
+ int uid, iAmmount;
+
+ if( !Client->bIsAuthed ) return strdup("401 Not Authenticated\n");
+
+ recipient = Args;
+
+ ammount = strchr(Args, ' ');
+ if( !ammount ) return strdup("407 Invalid Argument, expected 3 parameters, 1 encountered\n");
+ *ammount = '\0';
+ ammount ++;
+
+ reason = strchr(ammount, ' ');
+ if( !reason ) return strdup("407 Invalid Argument, expected 3 parameters, 2 encountered\n");
+ *reason = '\0';
+ reason ++;
+
+ // Get recipient
+ uid = GetUserID(recipient);
+ if( uid == -1 ) return strdup("404 Invalid target user");
+
+ // Parse ammount
+ iAmmount = atoi(ammount);
+ if( iAmmount <= 0 ) return strdup("407 Invalid Argument, ammount must be > zero\n");
+
+ // Do give
+ switch( Transfer(Client->UID, uid, iAmmount, reason) )
+ {
+ case 0:
+ return strdup("200 Give OK\n");
+ default:
+ return strdup("402 Poor You\n");
+ }
+}
+
// --- INTERNAL HELPERS ---
// TODO: Move to another file
void HexBin(uint8_t *Dest, char *Src, int BufSize)