Door controller code (well, the start of it)
[tpg/opendispense2.git] / src / server / handler_door.c
1 /*
2  * OpenDispense 2 
3  * UCC (University [of WA] Computer Club) Electronic Accounting System
4  *
5  * handler_doror.c - Door Relay code
6  *
7  * This file is licenced under the 3-clause BSD Licence. See the file
8  * COPYING for full details.
9  */
10 #include "common.h"
11 #include <stdio.h>
12 #include <string.h>
13 #include <unistd.h>
14 #include <sys/stat.h>
15 #include <fcntl.h>
16
17 // === IMPORTS ===
18
19 // === PROTOTYPES ===
20  int    Door_InitHandler();
21  int    Door_CanDispense(int User, int Item);
22  int    Door_DoDispense(int User, int Item);
23
24 // === GLOBALS ===
25 tHandler        gDoor_Handler = {
26         "door",
27         Door_InitHandler,
28         Door_CanDispense,
29         Door_DoDispense
30 };
31 //char  *gsDoor_SerialPort = "/dev/ttyS0";
32 // int  giDoor_SerialFD;
33
34 // == CODE ===
35 int Door_InitHandler()
36 {
37 //      printf("connecting to door...\n");
38 //      giDoor_SerialFD = open(gsDoor_SerialPort, O_RDWR);
39 //      if( giDoor_SerialFD == -1 ) {
40 //              fprintf(stderr, "ERROR: Unable to open coke serial port ('%s')\n", gsDoor_SerialPort);
41 //      }
42         return 0;
43 }
44
45 /**
46  */
47 int Door_CanDispense(int User, int Item)
48 {
49         // Sanity please
50         if( Item == 0 ) return -1;
51         
52         return 0;
53 }
54
55 /**
56  * \brief Actually do a dispense from the coke machine
57  */
58 int Door_DoDispense(int User, int Item)
59 {
60         char    tmp[32], *status;
61         regmatch_t      matches[4];
62
63         // Sanity please
64         if( Item != 0 ) return -1;
65         
66         // llogin or other
67
68         return 0;
69 }
70
71

UCC git Repository :: git.ucc.asn.au