Old versions of GILS tables
[yaz-moved-to-github.git] / util / tpath.c
1 /*
2  * Copyright (c) 1995, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: tpath.c,v $
7  * Revision 1.2  1996-10-29 13:36:26  adam
8  * Added header.
9  *
10  * Revision 1.1  1995/11/01 16:35:00  quinn
11  * Making data1 look for tables in data1_tabpath
12  *
13  *
14  */
15
16 #include <stdio.h>
17 #include <string.h>
18 #include <tpath.h>
19
20 FILE *yaz_path_fopen(const char *path, const char *name, const char *mode)
21 {
22     char spath[512] = "";
23
24     if (!path)
25         return fopen(name, mode);
26
27     do
28     {
29         FILE *f;
30
31         if (sscanf(path, "%511[^:]", spath) < 1)
32             return 0;
33         sprintf(spath + strlen(spath), "/%s", name);
34         if ((f = fopen(spath, mode)))
35             return f;
36         if ((path = strchr(path, ':')))
37             path++;
38     }
39     while (path);
40     return 0;
41 }