1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#ident "$Id$"
/* ----------------------------------------------------------------------- *
*
* Copyright 2000-2001 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, Inc.,
* 59 Temple Place Ste 330, Boston MA 02111-1307, USA, version 2.1,
* incorporated herein by reference.
*
* ----------------------------------------------------------------------- */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "lpsm.h"
int main(int argc, char *argv[])
{
void *buf;
int arena_len = 16384;
buf = lpsm_arena_init("test.dat", "test.log", &arena_len, NULL);
printf("Read from first page: %s\n", (char *)buf);
strcpy((char *)buf + 4096, "This is the second page!");
strcpy((char *)buf + 8192, "This is the third page!");
printf("Read from third page: %s\n", (char *)buf + 8192);
lpsm_checkpoint(0.5, PSMSYNC_WAIT);
strcpy((char *)buf + 8192, "This is also the third page!");
printf("Read from third page: %s\n", (char *)buf + 8192);
lpsm_checkpoint(0.0, PSMSYNC_WAIT);
lpsm_extend(65536);
strcpy((char *)buf + 32768, "This is the ninth page!");
lpsm_checkpoint(0.0, PSMSYNC_SYNC);
return 0;
}
|