2014-06-10 12:46:18 +02:00
|
|
|
#include <string.h>
|
2014-06-07 18:21:13 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2014-06-10 22:22:10 +02:00
|
|
|
#include <errno.h>
|
2014-06-07 18:21:13 +02:00
|
|
|
|
2014-06-10 22:22:10 +02:00
|
|
|
const char *password = "23door42\n";
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
size_t input_size = 0;
|
|
|
|
char *input_line = NULL;
|
2014-06-07 18:21:13 +02:00
|
|
|
|
2014-06-10 15:36:45 +02:00
|
|
|
printf("Please enter Password: ");
|
2014-06-07 18:21:13 +02:00
|
|
|
|
2014-06-10 22:56:01 +02:00
|
|
|
/* read in password from standard input, exit on error. */
|
2014-06-10 22:22:10 +02:00
|
|
|
if (getline(&input_line, &input_size, stdin) == -1) {
|
|
|
|
perror("Error");
|
2014-06-10 23:14:29 +02:00
|
|
|
free(input_line);
|
2014-06-10 22:22:10 +02:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2014-06-10 22:56:01 +02:00
|
|
|
/* compare password, print info, exit appropriately */
|
2014-06-10 22:22:10 +02:00
|
|
|
if (strcmp(input_line, password) == 0) {
|
|
|
|
puts("Success!");
|
2014-06-10 23:14:29 +02:00
|
|
|
free(input_line);
|
2014-06-10 22:22:10 +02:00
|
|
|
exit(EXIT_SUCCESS);
|
2014-06-07 18:21:13 +02:00
|
|
|
} else {
|
2014-06-10 13:01:34 +02:00
|
|
|
puts("How about no?!");
|
2014-06-10 23:14:29 +02:00
|
|
|
free(input_line);
|
2014-06-10 22:22:10 +02:00
|
|
|
exit(EXIT_FAILURE);
|
2014-06-07 18:21:13 +02:00
|
|
|
}
|
|
|
|
}
|