diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-08-04 11:06:52 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-08-04 11:06:52 +0000 |
commit | 4371b0fcd9b50f78ca27ac48adf2f4663b2dfc9b (patch) | |
tree | 05c40696267088fa94cdb0a94b3c079b38ea8ed2 /src/peerstore/test_peerstore_api_iterate.c | |
parent | ef494e57d189e2b7c038104e44398d11026ff6a6 (diff) | |
download | gnunet-4371b0fcd9b50f78ca27ac48adf2f4663b2dfc9b.tar.gz gnunet-4371b0fcd9b50f78ca27ac48adf2f4663b2dfc9b.zip |
peerstore: indentation
Diffstat (limited to 'src/peerstore/test_peerstore_api_iterate.c')
-rw-r--r-- | src/peerstore/test_peerstore_api_iterate.c | 120 |
1 files changed, 40 insertions, 80 deletions
diff --git a/src/peerstore/test_peerstore_api_iterate.c b/src/peerstore/test_peerstore_api_iterate.c index 0b864aea5..626a020de 100644 --- a/src/peerstore/test_peerstore_api_iterate.c +++ b/src/peerstore/test_peerstore_api_iterate.c | |||
@@ -40,127 +40,87 @@ static char *val = "test_peerstore_api_iterate_val"; | |||
40 | static int count = 0; | 40 | static int count = 0; |
41 | 41 | ||
42 | static int | 42 | static int |
43 | iter3_cb(void *cls, | 43 | iter3_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) |
44 | struct GNUNET_PEERSTORE_Record *record, | ||
45 | char *emsg) | ||
46 | { | 44 | { |
47 | if(NULL != emsg) | 45 | if (NULL != emsg) |
48 | return GNUNET_NO; | 46 | return GNUNET_NO; |
49 | if(NULL != record) | 47 | if (NULL != record) |
50 | { | 48 | { |
51 | count++; | 49 | count++; |
52 | return GNUNET_YES; | 50 | return GNUNET_YES; |
53 | } | 51 | } |
54 | GNUNET_assert(count == 3); | 52 | GNUNET_assert (count == 3); |
55 | ok = 0; | 53 | ok = 0; |
56 | GNUNET_PEERSTORE_disconnect(h, GNUNET_NO); | 54 | GNUNET_PEERSTORE_disconnect (h, GNUNET_NO); |
57 | GNUNET_SCHEDULER_shutdown(); | 55 | GNUNET_SCHEDULER_shutdown (); |
58 | return GNUNET_YES; | 56 | return GNUNET_YES; |
59 | } | 57 | } |
60 | 58 | ||
59 | |||
61 | static int | 60 | static int |
62 | iter2_cb(void *cls, | 61 | iter2_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) |
63 | struct GNUNET_PEERSTORE_Record *record, | ||
64 | char *emsg) | ||
65 | { | 62 | { |
66 | if(NULL != emsg) | 63 | if (NULL != emsg) |
67 | return GNUNET_NO; | 64 | return GNUNET_NO; |
68 | if(NULL != record) | 65 | if (NULL != record) |
69 | { | 66 | { |
70 | count++; | 67 | count++; |
71 | return GNUNET_YES; | 68 | return GNUNET_YES; |
72 | } | 69 | } |
73 | GNUNET_assert(count == 2); | 70 | GNUNET_assert (count == 2); |
74 | count = 0; | 71 | count = 0; |
75 | GNUNET_PEERSTORE_iterate(h, | 72 | GNUNET_PEERSTORE_iterate (h, ss, NULL, NULL, GNUNET_TIME_UNIT_FOREVER_REL, |
76 | ss, | 73 | iter3_cb, NULL); |
77 | NULL, | ||
78 | NULL, | ||
79 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
80 | iter3_cb, | ||
81 | NULL); | ||
82 | return GNUNET_YES; | 74 | return GNUNET_YES; |
83 | } | 75 | } |
84 | 76 | ||
77 | |||
85 | static int | 78 | static int |
86 | iter1_cb(void *cls, | 79 | iter1_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) |
87 | struct GNUNET_PEERSTORE_Record *record, | ||
88 | char *emsg) | ||
89 | { | 80 | { |
90 | if(NULL != emsg) | 81 | if (NULL != emsg) |
91 | return GNUNET_NO; | 82 | return GNUNET_NO; |
92 | if(NULL != record) | 83 | if (NULL != record) |
93 | { | 84 | { |
94 | count++; | 85 | count++; |
95 | return GNUNET_YES; | 86 | return GNUNET_YES; |
96 | } | 87 | } |
97 | GNUNET_assert(count == 1); | 88 | GNUNET_assert (count == 1); |
98 | count = 0; | 89 | count = 0; |
99 | GNUNET_PEERSTORE_iterate(h, | 90 | GNUNET_PEERSTORE_iterate (h, ss, &p1, NULL, GNUNET_TIME_UNIT_FOREVER_REL, |
100 | ss, | 91 | iter2_cb, NULL); |
101 | &p1, | ||
102 | NULL, | ||
103 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
104 | iter2_cb, | ||
105 | NULL); | ||
106 | return GNUNET_YES; | 92 | return GNUNET_YES; |
107 | } | 93 | } |
108 | 94 | ||
95 | |||
109 | static void | 96 | static void |
110 | run (void *cls, | 97 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, |
111 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 98 | struct GNUNET_TESTING_Peer *peer) |
112 | struct GNUNET_TESTING_Peer *peer) | ||
113 | { | 99 | { |
114 | h = GNUNET_PEERSTORE_connect(cfg); | 100 | h = GNUNET_PEERSTORE_connect (cfg); |
115 | GNUNET_assert(NULL != h); | 101 | GNUNET_assert (NULL != h); |
116 | memset (&p1, 1, sizeof (p1)); | 102 | memset (&p1, 1, sizeof (p1)); |
117 | memset (&p2, 2, sizeof (p2)); | 103 | memset (&p2, 2, sizeof (p2)); |
118 | GNUNET_PEERSTORE_store(h, | 104 | GNUNET_PEERSTORE_store (h, ss, &p1, k1, val, strlen (val) + 1, |
119 | ss, | 105 | GNUNET_TIME_UNIT_FOREVER_ABS, |
120 | &p1, | 106 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); |
121 | k1, | 107 | GNUNET_PEERSTORE_store (h, ss, &p1, k2, val, strlen (val) + 1, |
122 | val, | 108 | GNUNET_TIME_UNIT_FOREVER_ABS, |
123 | strlen(val) + 1, | 109 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); |
124 | GNUNET_TIME_UNIT_FOREVER_ABS, | 110 | GNUNET_PEERSTORE_store (h, ss, &p2, k3, val, strlen (val) + 1, |
125 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | 111 | GNUNET_TIME_UNIT_FOREVER_ABS, |
126 | NULL, | 112 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); |
127 | NULL); | 113 | GNUNET_PEERSTORE_iterate (h, ss, &p1, k1, GNUNET_TIME_UNIT_FOREVER_REL, |
128 | GNUNET_PEERSTORE_store(h, | 114 | iter1_cb, NULL); |
129 | ss, | ||
130 | &p1, | ||
131 | k2, | ||
132 | val, | ||
133 | strlen(val) + 1, | ||
134 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
135 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | ||
136 | NULL, | ||
137 | NULL); | ||
138 | GNUNET_PEERSTORE_store(h, | ||
139 | ss, | ||
140 | &p2, | ||
141 | k3, | ||
142 | val, | ||
143 | strlen(val) + 1, | ||
144 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
145 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | ||
146 | NULL, | ||
147 | NULL); | ||
148 | GNUNET_PEERSTORE_iterate(h, | ||
149 | ss, | ||
150 | &p1, | ||
151 | k1, | ||
152 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
153 | iter1_cb, | ||
154 | NULL); | ||
155 | } | 115 | } |
156 | 116 | ||
117 | |||
157 | int | 118 | int |
158 | main (int argc, char *argv[]) | 119 | main (int argc, char *argv[]) |
159 | { | 120 | { |
160 | if (0 != GNUNET_TESTING_service_run ("test-gnunet-peerstore", | 121 | if (0 != |
161 | "peerstore", | 122 | GNUNET_TESTING_service_run ("test-gnunet-peerstore", "peerstore", |
162 | "test_peerstore_api_data.conf", | 123 | "test_peerstore_api_data.conf", &run, NULL)) |
163 | &run, NULL)) | ||
164 | return 1; | 124 | return 1; |
165 | return ok; | 125 | return ok; |
166 | } | 126 | } |