diff options
Diffstat (limited to 'readkey.c')
| -rw-r--r-- | readkey.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/readkey.c b/readkey.c new file mode 100644 index 0000000..a7337b6 --- /dev/null +++ b/readkey.c @@ -0,0 +1,23 @@ +#define _XOPEN_SOURCE 700 +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/shm.h> +#include "deonebook.h" + +unsigned char *readkey(const char *path) +{ + key_t key = ftok(path, 0x2a); + if (key == (key_t)(-1)) { + perror("ftok"); + return NULL; + } + + int shmid = shmget(key, 0, 0); + if (shmid == -1) { + perror("shmget"); + return NULL; + } + + return shmat(shmid, NULL, 0); +} |
