summaryrefslogtreecommitdiffstats
path: root/common/test_textfile.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-02-08 05:38:38 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-02-08 05:38:38 +0000
commit85cc0c57e4fd0e44c3b270aba4f87eb28151b1a2 (patch)
tree224ae692ccbed28ac1b5657835849a5e96b267dc /common/test_textfile.c
parent9b993dda376d1c74575ed8984b0cf07d1d671f8c (diff)
Add textfile_foreach() function
Diffstat (limited to 'common/test_textfile.c')
-rw-r--r--common/test_textfile.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/common/test_textfile.c b/common/test_textfile.c
index c2b2c993..5a5b22c5 100644
--- a/common/test_textfile.c
+++ b/common/test_textfile.c
@@ -34,6 +34,11 @@
#include "textfile.h"
+static void print_entry(char *key, char *value, void *data)
+{
+ printf("%s %s\n", key, value);
+}
+
int main(int argc, char *argv[])
{
char filename[] = "/tmp/textfile";
@@ -109,15 +114,8 @@ int main(int argc, char *argv[])
printf("\n");
- for (i = 1; i < max + 1; i++) {
- sprintf(key, "00:00:00:00:00:%02X", i);
+ textfile_foreach(filename, print_entry, NULL);
- str = textfile_get(filename, key);
- if (str) {
- printf("%s %s\n", key, str);
- free(str);
- }
- }
sprintf(key, "00:00:00:00:00:%02X", 1);
@@ -136,15 +134,7 @@ int main(int argc, char *argv[])
printf("\n");
- for (i = 1; i < max + 1; i++) {
- sprintf(key, "00:00:00:00:00:%02X", i);
-
- str = textfile_get(filename, key);
- if (str) {
- printf("%s %s\n", key, str);
- free(str);
- }
- }
+ textfile_foreach(filename, print_entry, NULL);
return 0;
}