+ child_stdin = popen("llogin door -w -", "w");
+ if( !child_stdin || child_stdin == (void*)-1 ) {
+ #if DEBUG
+ printf("Door_DoDispense: llogin failure\n");
+ #endif
+ return -1;
+ }
+ #endif
+
+ if(fread(buf, 1, 512, child_stdin) == 0) {
+ #if DEBUG
+ printf("Door_DoDispense: fread fail\n");
+ #endif
+ return -1;
+ }
+
+ // Send password
+ if( fputs(gsDoor_Password, child_stdin) <= 0 ) {
+ #if DEBUG
+ printf("Door_DoDispense: fputs password\n");
+ #endif
+ return -1;
+ }
+ fputs("\n", child_stdin);
+
+
+ #if DEBUG
+ printf("Door_DoDispense: Door unlock\n");
+ #endif
+
+ // ATH1 - Unlock door
+ if( fputs("ATH1\n", child_stdin) <= 0) {
+ #if DEBUG
+ printf("Door_DoDispense: fputs unlock\n");
+ #endif
+ return -1;
+ }
+
+ // Wait before re-locking
+ sleep(DOOR_UNLOCKED_DELAY);
+
+
+ #if DEBUG
+ printf("Door_DoDispense: Door re-lock\n");
+ #endif
+
+ // Re-lock the door
+ if( fputs("ATH0\n", child_stdin) <= 0 ) {
+ #if DEBUG
+ printf("Door_DoDispense: fputs lock\n");
+ #endif
+ return -1;
+ }
+
+ #if !USE_POPEN
+ fclose(child_stdin);
+ close(stdin_pair[1]); // child stdin write
+ close(stdout_pair[0]); // child stdout read
+ #else
+ pclose(child_stdin);
+ #endif
+
+ #if DEBUG
+ printf("Door_DoDispense: User %i opened door\n", User);
+ #endif