* Sebastian Hammer, Adam Dickmeiss
*
* $Log: bfile.c,v $
- * Revision 1.23 1997-09-17 12:19:06 adam
+ * Revision 1.24 1997-09-18 08:59:16 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.23 1997/09/17 12:19:06 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
void bfs_destroy (BFiles bfs)
{
+ mf_destroy (bfs->commit_area);
+ mf_destroy (bfs->register_area);
xfree (bfs);
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: mfile.c,v $
- * Revision 1.24 1997-09-17 12:19:06 adam
+ * Revision 1.25 1997-09-18 08:59:16 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.24 1997/09/17 12:19:06 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
*/
MFile_area mf_init(const char *name, const char *spec)
{
- MFile_area ma = xmalloc(sizeof(MFile_area_struct));
+ MFile_area ma = xmalloc(sizeof(*ma));
mf_dir *dirp;
meta_file *meta_f;
part_file *part_f = 0;
struct dirent *dent;
int fd, number;
char metaname[FILENAME_MAX+1], tmpnam[FILENAME_MAX+1];
-
+
logf (LOG_DEBUG, "mf_init(%s)", name);
- ma = xmalloc(sizeof(MFile_area_struct));
strcpy(ma->name, name);
ma->mfiles = 0;
ma->dirs = 0;
return ma;
}
+void mf_destroy(MFile_area ma)
+{
+ mf_dir *dp;
+ meta_file *meta_f;
+
+ if (!ma)
+ return;
+ dp = ma->dirs;
+ while (dp)
+ {
+ mf_dir *d = dp;
+ dp = dp->next;
+ xfree (d);
+ }
+ meta_f = ma->mfiles;
+ while (meta_f)
+ {
+ meta_file *m = meta_f;
+ meta_f = meta_f->next;
+ xfree (m);
+ }
+ xfree (ma);
+}
+
/*
* Open a metafile.
* If !ma, Use MF_DEFAULT_AREA.
*/
MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag)
{
- struct meta_file *new;
+ struct meta_file *mnew;
int i;
char tmp[FILENAME_MAX+1];
mf_dir *dp;
logf(LOG_DEBUG, "mf_open(%s bs=%d, %s)", name, block_size,
wflag ? "RW" : "RDONLY");
assert (ma);
- for (new = ma->mfiles; new; new = new->next)
- if (!strcmp(name, new->name))
- if (new->open)
+ for (mnew = ma->mfiles; mnew; mnew = mnew->next)
+ if (!strcmp(name, mnew->name))
+ if (mnew->open)
abort();
else
break;
- if (!new)
+ if (!mnew)
{
- new = xmalloc(sizeof(*new));
- strcpy(new->name, name);
+ mnew = xmalloc(sizeof(*mnew));
+ strcpy(mnew->name, name);
/* allocate one, empty file */
- new->no_files = 1;
- new->files[0].bytes = new->files[0].blocks = 0;
- new->files[0].top = -1;
- new->files[0].number = 0;
- new->files[0].fd = -1;
- new->min_bytes_creat = MF_MIN_BLOCKS_CREAT * block_size;
+ mnew->no_files = 1;
+ mnew->files[0].bytes = mnew->files[0].blocks = 0;
+ mnew->files[0].top = -1;
+ mnew->files[0].number = 0;
+ mnew->files[0].fd = -1;
+ mnew->min_bytes_creat = MF_MIN_BLOCKS_CREAT * block_size;
for (dp = ma->dirs; dp && dp->max_bytes >= 0 && dp->avail_bytes <
- new->min_bytes_creat; dp = dp->next);
+ mnew->min_bytes_creat; dp = dp->next);
if (!dp)
{
logf (LOG_FATAL, "Insufficient space for new mfile.");
return 0;
}
- new->files[0].dir = dp;
- sprintf(tmp, "%s/%s.mf.%d", dp->name, new->name, 0);
- new->files[0].path = xstrdup(tmp);
- new->ma = ma;
+ mnew->files[0].dir = dp;
+ sprintf(tmp, "%s/%s.mf.%d", dp->name, mnew->name, 0);
+ mnew->files[0].path = xstrdup(tmp);
+ mnew->ma = ma;
}
else
{
- for (i = 0; i < new->no_files; i++)
+ for (i = 0; i < mnew->no_files; i++)
{
- if (new->files[i].bytes % block_size)
- new->files[i].bytes += block_size - new->files[i].bytes %
+ if (mnew->files[i].bytes % block_size)
+ mnew->files[i].bytes += block_size - mnew->files[i].bytes %
block_size;
- new->files[i].blocks = new->files[i].bytes / block_size;
+ mnew->files[i].blocks = mnew->files[i].bytes / block_size;
}
- assert(!new->open);
+ assert(!mnew->open);
}
- new->blocksize = block_size;
- new->min_bytes_creat = MF_MIN_BLOCKS_CREAT * block_size;
- new->wr=wflag;
- new->cur_file = 0;
- new->open = 1;
+ mnew->blocksize = block_size;
+ mnew->min_bytes_creat = MF_MIN_BLOCKS_CREAT * block_size;
+ mnew->wr=wflag;
+ mnew->cur_file = 0;
+ mnew->open = 1;
- for (i = 0; i < new->no_files; i++)
+ for (i = 0; i < mnew->no_files; i++)
{
- new->files[i].blocks = new->files[i].bytes / new->blocksize;
- if (i == new->no_files - 1)
- new->files[i].top = -1;
+ mnew->files[i].blocks = mnew->files[i].bytes / mnew->blocksize;
+ if (i == mnew->no_files - 1)
+ mnew->files[i].top = -1;
else
- new->files[i].top = i ? (new->files[i-1].top + new->files[i].blocks)
- : (new->files[i].blocks - 1);
+ mnew->files[i].top =
+ i ? (mnew->files[i-1].top + mnew->files[i].blocks)
+ : (mnew->files[i].blocks - 1);
}
- return new;
+ return mnew;
}
/*
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dfa.c,v $
- * Revision 1.16 1997-09-05 15:29:57 adam
+ * Revision 1.17 1997-09-18 08:59:17 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.16 1997/09/05 15:29:57 adam
* Changed prototype for chr_map_input - added const.
* Added support for C++, headers uses extern "C" for public definitions.
*
char mapfrom[2];
const char *mcp = mapfrom;
mapfrom[0] = ch0;
- mapto = (*parse_info->cmap)(&mcp, 1);
+ mapto = (*parse_info->cmap)(parse_info->cmap_data, &mcp, 1);
assert (mapto);
ch0 = mapto[0][0];
}
char mapfrom[2];
const char *mcp = mapfrom;
mapfrom[0] = ch1;
- mapto = (*parse_info->cmap) (&mcp, 1);
+ mapto = (*parse_info->cmap) (parse_info->cmap_data, &mcp, 1);
assert (mapto);
ch1 = mapto[0][0];
}
if (!parse_info->cmap)
return L_CHAR;
- mapto = (*parse_info->cmap) (&cp0, len);
+ mapto = (*parse_info->cmap) (parse_info->cmap_data, &cp0, len);
assert (mapto);
expr_ptr = (const unsigned char *) cp0;
return dfa;
}
-void dfa_set_cmap (struct DFA *dfa,
- const char **(*cmap)(const char **from, int len))
+void dfa_set_cmap (struct DFA *dfa, void *vp,
+ const char **(*cmap)(void *vp, const char **from, int len))
{
dfa->parse_info->cmap = cmap;
+ dfa->parse_info->cmap_data = vp;
}
int dfa_parse (struct DFA *dfa, const char **pattern)
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dfap.h,v $
- * Revision 1.5 1997-09-05 15:29:58 adam
+ * Revision 1.6 1997-09-18 08:59:17 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.5 1997/09/05 15:29:58 adam
* Changed prototype for chr_map_input - added const.
* Added support for C++, headers uses extern "C" for public definitions.
*
struct Tblock *end; /* end block of Tnodes */
int *charMap;
int charMapSize;
- const char **(*cmap)(const char **from, int len);
+ void *cmap_data;
+ const char **(*cmap)(void *vp, const char **from, int len);
};
typedef struct DFA_stateb_ {
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: lookgrep.c,v $
- * Revision 1.18 1997-09-05 15:29:58 adam
+ * Revision 1.19 1997-09-18 08:59:18 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.18 1997/09/05 15:29:58 adam
* Changed prototype for chr_map_input - added const.
* Added support for C++, headers uses extern "C" for public definitions.
*
logf (LOG_DEBUG, "dict_lookup_grep '%s' range=%d", pattern, range);
- dfa_set_cmap (dfa, dict->grep_cmap);
+ dfa_set_cmap (dfa, dict->grep_cmap_data, dict->grep_cmap);
i = dfa_parse (dfa, &this_pattern);
if (i || *this_pattern)
return i;
}
-void dict_grep_cmap (Dict dict,
- const char **(*cmap)(const char **from, int len))
+void dict_grep_cmap (Dict dict, void *vp,
+ const char **(*cmap)(void *vp, const char **from, int len))
{
dict->grep_cmap = cmap;
+ dict->grep_cmap_data = vp;
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dfa.h,v $
- * Revision 1.7 1997-09-05 15:29:59 adam
+ * Revision 1.8 1997-09-18 08:59:18 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.7 1997/09/05 15:29:59 adam
* Changed prototype for chr_map_input - added const.
* Added support for C++, headers uses extern "C" for public definitions.
*
};
struct DFA *dfa_init (void);
-void dfa_set_cmap (struct DFA *dfa,
- const char **(*cmap)(const char **from, int len));
+void dfa_set_cmap (struct DFA *dfa, void *vp,
+ const char **(*cmap)(void *vp, const char **from, int len));
int dfa_parse (struct DFA *, const char **);
void dfa_mkstate (struct DFA *);
void dfa_delete (struct DFA **);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dict.h,v $
- * Revision 1.25 1997-09-17 12:19:09 adam
+ * Revision 1.26 1997-09-18 08:59:18 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.25 1997/09/17 12:19:09 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
typedef struct Dict_struct {
int rw;
Dict_BFile dbf;
- const char **(*grep_cmap)(const char **from, int len);
+ const char **(*grep_cmap)(void *vp, const char **from, int len);
+ void *grep_cmap_data;
struct Dict_head head;
} *Dict;
int (*f)(char *name, const char *info, int pos,
void *client));
-void dict_grep_cmap (Dict dict,
- const char **(*cmap)(const char **from, int len));
+void dict_grep_cmap (Dict dict, void *vp,
+ const char **(*cmap)(void *vp,
+ const char **from, int len));
#define DICT_EOS 0
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: mfile.h,v $
- * Revision 1.8 1997-09-17 12:19:10 adam
+ * Revision 1.9 1997-09-18 08:59:19 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.8 1997/09/17 12:19:10 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
/*
* Release an area.
*/
-int mf_dispose(MFile_area ma);
+void mf_destroy(MFile_area ma);
/*
* Open a metafile.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recctrl.h,v $
- * Revision 1.20 1997-09-17 12:19:10 adam
+ * Revision 1.21 1997-09-18 08:59:19 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.20 1997/09/17 12:19:10 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
char *subType;
void (*init)(RecWord *p);
void (*add)(const RecWord *p);
- const char **(*map_chrs_input)(const char **from, int len);
+ const char **(*map_chrs_input)(void *vp, const char **from, int len);
int flagShowRecords;
data1_handle dh;
};
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: index.h,v $
- * Revision 1.50 1997-09-17 12:19:13 adam
+ * Revision 1.51 1997-09-18 08:59:19 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.50 1997/09/17 12:19:13 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
int zebraUnlock (int fd);
void init_charmap(Res res);
-const char **map_chrs_input(const char **from, int len);
+const char **map_chrs_input(void *vp, const char **from, int len);
const char *map_chrs_output(const char **from);
extern Res common_resource;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.63 1997-09-17 12:19:18 adam
+ * Revision 1.64 1997-09-18 08:59:20 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.63 1997/09/17 12:19:18 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
if (ct2 && strchr (ct2, *s0))
break;
s1 = s0;
- map = map_chrs_input (&s1, strlen(s1));
+ map = map_chrs_input (0, &s1, strlen(s1));
if (**map != *CHR_SPACE)
break;
s0 = s1;
while (*s0)
{
s1 = s0;
- map = map_chrs_input (&s0, strlen(s0));
+ map = map_chrs_input (0, &s0, strlen(s0));
if (space_split && **map == *CHR_SPACE)
break;
while (s1 < s0)
else
{
s1 = s0;
- map = map_chrs_input (&s0, strlen(s0));
+ map = map_chrs_input (0, &s0, strlen(s0));
if (space_split && **map == *CHR_SPACE)
break;
while (s1 < s0)
else
{
s1 = s0;
- map = map_chrs_input (&s0, strlen(s0));
+ map = map_chrs_input (0, &s0, strlen(s0));
if (**map == *CHR_SPACE)
break;
while (s1 < s0)
while ((len = (cp_end - cp)) > 0)
{
- map = map_chrs_input (&cp, len);
+ map = map_chrs_input (0, &cp, len);
if (**map == *CHR_SPACE)
space_map = *map;
else
oident *attrset;
oid_value attributeSet;
- dict_grep_cmap (zi->dict, map_chrs_input);
+ dict_grep_cmap (zi->dict, 0, map_chrs_input);
zlog_rpn (rpn);
zi->errCode = 0;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recgrs.c,v $
- * Revision 1.9 1997-09-17 12:19:21 adam
+ * Revision 1.10 1997-09-18 08:59:21 adam
+ * Extra generic handle for the character mapping routines.
+ *
+ * Revision 1.9 1997/09/17 12:19:21 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
remain = n->u.data.len - (b - n->u.data.data);
if (remain > 0)
- map = (*p->map_chrs_input)(&b, remain);
+ map = (*p->map_chrs_input)(0, &b, remain);
while (map)
{
{
remain = n->u.data.len - (b - n->u.data.data);
if (remain > 0)
- map = (*p->map_chrs_input)(&b, remain);
+ map = (*p->map_chrs_input)(0, &b, remain);
else
map = 0;
}
buf[i++] = *(cp++);
remain = n->u.data.len - (b - n->u.data.data);
if (remain > 0)
- map = (*p->map_chrs_input)(&b, remain);
+ map = (*p->map_chrs_input)(0, &b, remain);
else
map = 0;
}
remain = n->u.data.len - (b - n->u.data.data);
if (remain > 0)
- map = (*p->map_chrs_input)(&b, remain);
+ map = (*p->map_chrs_input)(0, &b, remain);
while (remain > 0 && i < GRS_MAX_WORD)
{
{
remain = n->u.data.len - (b - n->u.data.data);
if (remain > 0)
- map = (*p->map_chrs_input)(&b, remain);
+ map = (*p->map_chrs_input)(0, &b, remain);
else
map = 0;
}
buf[i++] = *(cp++);
remain = n->u.data.len - (b - n->u.data.data);
if (remain > 0)
- map = (*p->map_chrs_input)(&b, remain);
+ map = (*p->map_chrs_input)(0, &b, remain);
else
map = 0;
}