2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1995-11-17 15:54:42 adam
8 * Started work on virtual directory structure.
10 * Revision 1.9 1995/10/30 13:42:12 adam
13 * Revision 1.8 1995/10/10 13:59:23 adam
14 * Function rset_open changed its wflag parameter to general flags.
16 * Revision 1.7 1995/09/28 09:19:40 adam
17 * xfree/xmalloc used everywhere.
18 * Extract/retrieve method seems to work for text records.
20 * Revision 1.6 1995/09/08 14:52:26 adam
21 * Minor changes. Dictionary is lower case now.
23 * Revision 1.5 1995/09/06 16:11:16 adam
24 * Option: only one word key per file.
26 * Revision 1.4 1995/09/04 12:33:41 adam
27 * Various cleanup. YAZ util used instead.
29 * Revision 1.3 1995/09/01 14:06:35 adam
30 * Split of work into more files.
32 * Revision 1.2 1995/09/01 10:57:07 adam
35 * Revision 1.1 1995/09/01 10:34:51 adam
55 struct dirs_entry *entries;
58 struct dirs_client_info {
65 static int dirs_client_proc (Dict_char *name, const char *info, int pos,
68 struct dirs_client_info *ci = client;
70 if (memcmp (name, ci->prefix, ci->prelen))
72 if (ci->di->no == ci->no_max)
76 struct dirs_entry *arn;
79 arn = malloc (sizeof(*arn) * (ci->no_max));
82 logf (LOG_FATAL|LOG_ERRNO, "malloc");
85 memcpy (arn, ci->di->entries, ci->di->no * sizeof(*arn));
86 free (ci->di->entries);
87 ci->di->entries = arn;
90 strcpy ((ci->di->entries + ci->di->no)->path, name);
91 memcpy (&(ci->di->entries + ci->di->no)->sysno, info+1, *info);
92 assert (*info == sizeof(ci->di->entries->sysno));
97 struct dirs_info *dirs_open (Dict dict, const char *rep)
99 static char wname[200];
100 static char pname[200];
103 struct dirs_client_info dirs_client_info;
107 sprintf (wname, "d%s", rep);
108 dinfo = dict_lookup (dict, wname);
111 if (!(p = malloc (sizeof (*p))))
113 logf (LOG_FATAL|LOG_ERRNO, "malloc");
116 memcpy (&dirid, dinfo+1, sizeof(dirid));
117 sprintf (wname, "%d.", dirid);
118 strcpy (pname, wname);
121 dirs_client_info.di = p;
122 dirs_client_info.no_max = 0;
123 dirs_client_info.prefix = wname;
124 dirs_client_info.prelen = strlen(wname);
125 strcpy (pname, wname);
126 dict_scan (dict, pname, &before, &after, &dirs_client_info,
132 void dirs_free (struct dirs_info **pp)
134 struct dirs_info *p = *pp;