#include <sys/stat.h>
#include <fcntl.h>
+#define DOOR_UNLOCKED_DELAY 10 // 10 seconds before it re-locks
+
// === IMPORTS ===
// === PROTOTYPES ===
// == CODE ===
int Door_InitHandler(void)
-{
-// printf("connecting to door...\n");
-// giDoor_SerialFD = open(gsDoor_SerialPort, O_RDWR);
-// if( giDoor_SerialFD == -1 ) {
-// fprintf(stderr, "ERROR: Unable to open coke serial port ('%s')\n", gsDoor_SerialPort);
-// }
+{
+ gsDoor_Command = malloc(sizeof("llogin door -w ")+strlen(gsDoor_Password));
+ sprintf(gsDoor_Command, "llogin door -w %s", gsDoor_Password);
+
return 0;
}
if( !(Bank_GetFlags(User) & USER_FLAG_DOORGROUP) )
return 1;
-
- gsDoor_Command = malloc(sizeof("llogin door -w ")+strlen(gsDoor_Password));
- sprintf(gsDoor_Command, "llogin door -w %s", gsDoor_Password);
return 0;
}
return 1;
// llogin or other
- pipe = popen(gsDoor_Command, "w");
+ //pipe = popen(gsDoor_Command, "w");
+ pipe = popen("llogin door -w -", "w");
if( !pipe || pipe == (void*)-1 )
return -1;
- fputs("ATH1F", pipe);
- sleep(1);
- fputs("ATH10", pipe);
+ fputs(gsDoor_Password, pipe); fputs("\n", pipe);
+ fputs("ATH1\n", pipe);
+ sleep(DOOR_UNLOCKED_DELAY);
+ fputs("ATH0\n", pipe);
pclose(pipe);