commit 4f261ec
default
·
2022-11-26 16:35:18 +0000 UTC
parent d03b988
New function index_first().
M
data.c
+19,
-0
1@@ -306,6 +306,25 @@ int index_in(const char *fn, const char *id)
2 }
3
4
5+int index_first(const char *fn, char *line, int size)
6+/* reads the first entry of an index */
7+{
8+ FILE *f;
9+ int ret = 0;
10+
11+ if ((f = fopen(fn, "r")) != NULL) {
12+ if (fgets(line, size, f) != NULL) {
13+ line[32] = '\0';
14+ ret = 1;
15+ }
16+
17+ fclose(f);
18+ }
19+
20+ return ret;
21+}
22+
23+
24 d_char *index_list(const char *fn, int max)
25 /* returns an index as a list */
26 {
M
snac.h
+1,
-0
1@@ -55,6 +55,7 @@ double mtime_nl(const char *fn, int *n_link);
2
3 int index_add(const char *fn, const char *md5);
4 int index_del(const char *fn, const char *md5);
5+int index_first(const char *fn, char *buf, int size);
6 d_char *index_list(const char *fn, int max);
7 d_char *index_list_desc(const char *fn, int max);
8