blob: a7337b68727d1c785cbdc25c1dcb928e3ff51596 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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);
}
|