summaryrefslogtreecommitdiff
path: root/legacy/eet/src/examples/eet-file.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:01 +0000
committerCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:01 +0000
commit8893a9ff35f58e012be3cc838bd94268add13e10 (patch)
treee5c560542a70ccf657e1da45fb57d8dee99d3348 /legacy/eet/src/examples/eet-file.c
parenta331fe3bca4816e3a45662afd986e364b3586eed (diff)
ran ecrustify on eet. this seems to do a good job of eet. comments?
SVN revision: 64237
Diffstat (limited to 'legacy/eet/src/examples/eet-file.c')
-rw-r--r--legacy/eet/src/examples/eet-file.c121
1 files changed, 61 insertions, 60 deletions
diff --git a/legacy/eet/src/examples/eet-file.c b/legacy/eet/src/examples/eet-file.c
index 017a6cd6bf..740c179f7b 100644
--- a/legacy/eet/src/examples/eet-file.c
+++ b/legacy/eet/src/examples/eet-file.c
@@ -12,25 +12,25 @@ create_eet_file(void)
12 char buf[1024], *ptr; 12 char buf[1024], *ptr;
13 int size, len, i; 13 int size, len, i;
14 const char *some_strings[] = { 14 const char *some_strings[] = {
15 "And some more strings", 15 "And some more strings",
16 "spread across several", 16 "spread across several",
17 "elements of an array!" 17 "elements of an array!"
18 }; 18 };
19 const char some_data[] = 19 const char some_data[] =
20 "\x1e\xe7\x0f\x42\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x35" 20 "\x1e\xe7\x0f\x42\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x35"
21 "\x00\x00\x00\xa0\x00\x00\x00\xa0\x00\x00\x00\x24\x00\x00\x00\x11" 21 "\x00\x00\x00\xa0\x00\x00\x00\xa0\x00\x00\x00\x24\x00\x00\x00\x11"
22 "\x00\x00\x00\x00\x2f\x6d\x69\x73\x74\x65\x72\x69\x6f\x75\x73\x2f" 22 "\x00\x00\x00\x00\x2f\x6d\x69\x73\x74\x65\x72\x69\x6f\x75\x73\x2f"
23 "\x64\x61\x74\x61\x00\x41\x6e\x20\x45\x45\x54\x20\x69\x6e\x73\x69" 23 "\x64\x61\x74\x61\x00\x41\x6e\x20\x45\x45\x54\x20\x69\x6e\x73\x69"
24 "\x64\x65\x20\x6f\x66\x20\x61\x6e\x20\x45\x45\x54\x21\x0a\x54\x68" 24 "\x64\x65\x20\x6f\x66\x20\x61\x6e\x20\x45\x45\x54\x21\x0a\x54\x68"
25 "\x69\x73\x20\x77\x61\x73\x6e\x27\x74\x20\x72\x65\x61\x6c\x6c\x79" 25 "\x69\x73\x20\x77\x61\x73\x6e\x27\x74\x20\x72\x65\x61\x6c\x6c\x79"
26 "\x20\x75\x73\x65\x66\x75\x6c\x20\x62\x75\x74\x20\x69\x74\x20\x68" 26 "\x20\x75\x73\x65\x66\x75\x6c\x20\x62\x75\x74\x20\x69\x74\x20\x68"
27 "\x65\x6c\x70\x65\x64\x20\x74\x6f\x20\x73\x68\x6f\x77\x20\x68\x6f" 27 "\x65\x6c\x70\x65\x64\x20\x74\x6f\x20\x73\x68\x6f\x77\x20\x68\x6f"
28 "\x77\x0a\x74\x6f\x20\x75\x73\x65\x20\x65\x65\x74\x5f\x6d\x65\x6d" 28 "\x77\x0a\x74\x6f\x20\x75\x73\x65\x20\x65\x65\x74\x5f\x6d\x65\x6d"
29 "\x6f\x70\x65\x6e\x5f\x72\x65\x61\x64\x28\x29\x20\x74\x6f\x20\x6f" 29 "\x6f\x70\x65\x6e\x5f\x72\x65\x61\x64\x28\x29\x20\x74\x6f\x20\x6f"
30 "\x70\x65\x6e\x20\x61\x6e\x20\x65\x65\x74\x20\x66\x69\x6c\x65\x20" 30 "\x70\x65\x6e\x20\x61\x6e\x20\x65\x65\x74\x20\x66\x69\x6c\x65\x20"
31 "\x66\x72\x6f\x6d\x0a\x64\x61\x74\x61\x20\x61\x6c\x72\x65\x61\x64" 31 "\x66\x72\x6f\x6d\x0a\x64\x61\x74\x61\x20\x61\x6c\x72\x65\x61\x64"
32 "\x79\x20\x6c\x6f\x61\x64\x65\x64\x20\x69\x6e\x20\x6d\x65\x6d\x6f" 32 "\x79\x20\x6c\x6f\x61\x64\x65\x64\x20\x69\x6e\x20\x6d\x65\x6d\x6f"
33 "\x72\x79\x2e\x0a\x00"; 33 "\x72\x79\x2e\x0a\x00";
34 34
35 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE); 35 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE);
36 if (!ef) return 0; 36 if (!ef) return 0;
@@ -60,67 +60,68 @@ create_eet_file(void)
60 60
61 eet_delete(ef, "/several/strings"); 61 eet_delete(ef, "/several/strings");
62 62
63 return (eet_close(ef) == EET_ERROR_NONE); 63 return eet_close(ef) == EET_ERROR_NONE;
64} 64}
65 65
66int 66int
67main(void) 67main(void)
68{ 68{
69 Eet_File *ef; 69 Eet_File *ef;
70 char *ret, **list; 70 char *ret, **list;
71 int size, num, i; 71 int size, num, i;
72 72
73 eet_init(); 73 eet_init();
74 74
75 if (!create_eet_file()) 75 if (!create_eet_file())
76 return -1; 76 return -1;
77 77
78 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ); 78 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ);
79 if (!ef) return -1; 79 if (!ef) return -1;
80 80
81 list = eet_list(ef, "*", &num); 81 list = eet_list(ef, "*", &num);
82 if (list) 82 if (list)
83 { 83 {
84 for (i = 0; i < num; i++) 84 for (i = 0; i < num; i++)
85 printf("Key stored: %s\n", list[i]); 85 printf("Key stored: %s\n", list[i]);
86 free(list); 86 free(list);
87 } 87 }
88 88
89 ret = eet_read(ef, "/key/to_store/at", &size); 89 ret = eet_read(ef, "/key/to_store/at", &size);
90 if (ret) 90 if (ret)
91 { 91 {
92 printf("Data read (%i bytes):\n%s\n", size, ret); 92 printf("Data read (%i bytes):\n%s\n", size, ret);
93 free(ret); 93 free(ret);
94 } 94 }
95 95
96 ret = eet_read(ef, "/several/strings", &size); 96 ret = eet_read(ef, "/several/strings", &size);
97 if (ret) 97 if (ret)
98 { 98 {
99 printf("More data read (%i bytes):\n%s\n", size, ret); 99 printf("More data read (%i bytes):\n%s\n", size, ret);
100 free(ret); 100 free(ret);
101 } 101 }
102 102
103 ret = eet_read(ef, "/some/mysterious/data", &size); 103 ret = eet_read(ef, "/some/mysterious/data", &size);
104 if (ret) 104 if (ret)
105 { 105 {
106 Eet_File *ef2; 106 Eet_File *ef2;
107 107
108 ef2 = eet_memopen_read(ret, size); 108 ef2 = eet_memopen_read(ret, size);
109 109
110 num = eet_num_entries(ef2); 110 num = eet_num_entries(ef2);
111 printf("Mysterious data has %d entries\n", num); 111 printf("Mysterious data has %d entries\n", num);
112 112
113 printf("Mysterious data:\n%s\n", 113 printf("Mysterious data:\n%s\n",
114 (char *)eet_read_direct(ef2, "/mysterious/data", NULL)); 114 (char *)eet_read_direct(ef2, "/mysterious/data", NULL));
115 115
116 eet_close(ef2); 116 eet_close(ef2);
117 117
118 free(ret); 118 free(ret);
119 } 119 }
120 120
121 eet_close(ef); 121 eet_close(ef);
122 122
123 eet_shutdown(); 123 eet_shutdown();
124 124
125 return 0; 125 return 0;
126} 126}
127