2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1996-10-11 10:57:28 adam
8 * New module recctrl. Used to manage records (extract/retrieval).
10 * Revision 1.7 1996/01/17 14:57:55 adam
11 * Prototype changed for reader functions in extract/retrieve. File
12 * is identified by 'void *' instead of 'int.
14 * Revision 1.6 1995/10/10 13:59:24 adam
15 * Function rset_open changed its wflag parameter to general flags.
17 * Revision 1.5 1995/10/02 16:24:39 adam
18 * Use attribute actually used in search requests.
20 * Revision 1.4 1995/10/02 15:42:55 adam
21 * Extract uses file descriptors instead of FILE pointers.
23 * Revision 1.3 1995/09/28 09:19:45 adam
24 * xfree/xmalloc used everywhere.
25 * Extract/retrieve method seems to work for text records.
27 * Revision 1.2 1995/09/15 14:45:21 adam
31 * Revision 1.1 1995/09/14 07:48:25 adam
32 * Record control management.
42 static void text_init (void)
46 static int text_extract (struct recExtractCtrl *p)
53 recWord.which = Word_String;
58 r = (*p->readf)(p->fh, w, 1);
59 while (r > 0 && i < 255 && isalnum(w[i]))
62 r = (*p->readf) (p->fh, w + i, 1);
67 recWord.seqno = seqno++;
75 static int text_retrieve (struct recRetrieveCtrl *p)
78 static char *text_buf = NULL;
79 static int text_size = 0;
84 if (text_ptr + 4096 >= text_size)
88 text_size = 2*text_size + 8192;
89 nb = xmalloc (text_size);
92 memcpy (nb, text_buf, text_ptr);
102 sprintf (text_buf, "Rank: %d\n", p->score);
103 text_ptr = strlen(text_buf);
105 sprintf (text_buf + text_ptr, "Local Number: %d\n", p->localno);
106 text_ptr = strlen(text_buf);
108 r = (*p->readf)(p->fh, text_buf + text_ptr, 4096);
113 p->output_format = VAL_SUTRS;
114 p->rec_buf = text_buf;
115 p->rec_len = text_ptr;
119 static struct recType text_type = {
126 RecType recTypeText = &text_type;