2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * COMPONENT_NAME: austext
26 * FUNCTIONS: fillnew_wordrec
34 * (C) COPYRIGHT International Business Machines Corp. 1993,1995
36 * Licensed Materials - Property of IBM
37 * US Government Users Restricted Rights - Use, duplication or
38 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
40 /********************* VSTFUNCT.C **********************************
41 * $XConsortium: vstfunct.c /main/6 1996/08/12 13:20:01 cde-ibm $
42 * Performs vista KEYFIND, RECREAD, RECWRITE, and FILLNEW functions
43 * on word database files without caller having to know
44 * whether word is short, long, or huge.
45 * Remember: all word lengths are 1 byte shorter than the field size,
46 * plus 1 byte for the terminating \0.
49 * Revision 2.2 1995/10/26 14:12:32 miker
52 * Revision 2.1 1995/09/22 22:23:13 miker
53 * Freeze DtSearch 0.1, AusText 2.1.8
55 * Revision 1.3 1995/09/05 19:34:07 miker
56 * Minor name changes for DtSearch.
61 #define PROGNAME "VSTFUNCT"
63 static struct or_swordrec Swordbuf;
64 static struct or_lwordrec Lwordbuf;
67 /************************/
71 /************************/
72 /* Sets vista "curr record" to correct word record.
73 * Usually performed prior to vista read or write function.
74 * CALLER MUST CHECK DB_STATUS.
76 void find_keyword (char *cur_word, int vista_num)
81 len = strlen (cur_word);
82 if (len < sizeof (Swordbuf.or_swordkey))
83 keyfield = OR_SWORDKEY;
84 else if (len < sizeof (Lwordbuf.or_lwordkey))
85 keyfield = OR_LWORDKEY;
87 keyfield = OR_HWORDKEY;
88 KEYFIND (PROGNAME "24", keyfield, cur_word, vista_num);
90 } /* find_keyword() */
94 /********************************/
98 /********************************/
99 /* Performs vista RECREAD on curr word record.
100 * CALLER SHOULD CHECK DB_STATUS.
102 void read_wordstr (struct or_hwordrec * glob_word, int vista_num)
106 len = strlen (glob_word->or_hwordkey);
107 if (len < sizeof (Swordbuf.or_swordkey)) {
108 RECREAD (PROGNAME "61", &Swordbuf, vista_num);
109 if (db_status != S_OKAY)
111 strncpy (glob_word->or_hwordkey, Swordbuf.or_swordkey,
113 glob_word->or_hwordkey[DtSrMAXWIDTH_HWORD - 1] = 0;
114 glob_word->or_hwoffset = ntohl (Swordbuf.or_swoffset);
115 glob_word->or_hwfree = ntohl (Swordbuf.or_swfree);
116 glob_word->or_hwaddrs = ntohl (Swordbuf.or_swaddrs);
118 else if (len < sizeof (Lwordbuf.or_lwordkey)) {
119 RECREAD (PROGNAME "69", &Lwordbuf, vista_num);
120 if (db_status != S_OKAY)
122 strncpy (glob_word->or_hwordkey, Lwordbuf.or_lwordkey,
124 glob_word->or_hwordkey[DtSrMAXWIDTH_HWORD - 1] = 0;
125 glob_word->or_hwoffset = ntohl (Lwordbuf.or_lwoffset);
126 glob_word->or_hwfree = ntohl (Lwordbuf.or_lwfree);
127 glob_word->or_hwaddrs = ntohl (Lwordbuf.or_lwaddrs);
130 RECREAD (PROGNAME "78", glob_word, vista_num);
131 glob_word->or_hwordkey[DtSrMAXWIDTH_HWORD - 1] = 0;
132 NTOHL (glob_word->or_hwoffset);
133 NTOHL (glob_word->or_hwfree);
134 NTOHL (glob_word->or_hwaddrs);
137 } /* read_wordstr() */
140 /********************************/
144 /********************************/
145 /* performs vista RECWRITE on curr word record.
146 * CALLER MUST CHECK DB_STATUS.
148 void write_wordstr (struct or_hwordrec * glob_word, int vista_num)
152 len = strlen (glob_word->or_hwordkey);
154 if (len < sizeof (Swordbuf.or_swordkey)) {
155 strcpy (Swordbuf.or_swordkey, glob_word->or_hwordkey);
156 Swordbuf.or_swoffset = htonl (glob_word->or_hwoffset);
157 Swordbuf.or_swfree = htonl (glob_word->or_hwfree);
158 Swordbuf.or_swaddrs = htonl (glob_word->or_hwaddrs);
159 RECWRITE (PROGNAME "102", &Swordbuf, vista_num);
161 else if (len < sizeof (Lwordbuf.or_lwordkey)) {
162 strcpy (Lwordbuf.or_lwordkey, glob_word->or_hwordkey);
163 Lwordbuf.or_lwoffset = htonl (glob_word->or_hwoffset);
164 Lwordbuf.or_lwfree = htonl (glob_word->or_hwfree);
165 Lwordbuf.or_lwaddrs = htonl (glob_word->or_hwaddrs);
166 RECWRITE (PROGNAME "111", &Lwordbuf,
170 if (len >= DtSrMAXWIDTH_HWORD) {
171 printf ("\n" PROGNAME "124 Program Error Abort, "
172 "word too long:\n '%s'\n",
173 glob_word->or_hwordkey);
176 HTONL (glob_word->or_hwoffset);
177 HTONL (glob_word->or_hwfree);
178 HTONL (glob_word->or_hwaddrs);
179 RECWRITE (PROGNAME "115", glob_word, vista_num);
180 NTOHL (glob_word->or_hwoffset);
181 NTOHL (glob_word->or_hwfree);
182 NTOHL (glob_word->or_hwaddrs);
185 } /* write_wordstr() */
188 /****************************************/
190 /* fillnew_wordrec */
192 /****************************************/
193 /* The input record is always a word in a 'huge' structure.
194 * This function performs vista FILLNEW on that word,
195 * but into correct sized word rec.
196 * Formerly this function was called put_new_word().
197 * CALLER MUST CHECK DB_STATUS.
199 void fillnew_wordrec (struct or_hwordrec * glob_word, int vista_num)
203 len = strlen (glob_word->or_hwordkey);
204 if (len < sizeof (Swordbuf.or_swordkey)) {
205 strcpy (Swordbuf.or_swordkey, glob_word->or_hwordkey);
206 Swordbuf.or_swoffset = htonl (glob_word->or_hwoffset);
207 Swordbuf.or_swfree = htonl (glob_word->or_hwfree);
208 Swordbuf.or_swaddrs = htonl (glob_word->or_hwaddrs);
209 FILLNEW (PROGNAME "137", OR_SWORDREC, &Swordbuf, vista_num);
211 else if (len < sizeof (Lwordbuf.or_lwordkey)) {
212 strcpy (Lwordbuf.or_lwordkey, glob_word->or_hwordkey);
213 Lwordbuf.or_lwoffset = htonl (glob_word->or_hwoffset);
214 Lwordbuf.or_lwfree = htonl (glob_word->or_hwfree);
215 Lwordbuf.or_lwaddrs = htonl (glob_word->or_hwaddrs);
216 FILLNEW (PROGNAME "147", OR_LWORDREC, &Lwordbuf, vista_num);
219 if (len >= DtSrMAXWIDTH_HWORD) {
220 printf ("\n" PROGNAME "168 Program Error Abort, "
221 "word too long:\n '%s'\n",
222 glob_word->or_hwordkey);
225 HTONL (glob_word->or_hwoffset);
226 HTONL (glob_word->or_hwfree);
227 HTONL (glob_word->or_hwaddrs);
228 FILLNEW (PROGNAME "151", OR_HWORDREC, glob_word, vista_num);
229 NTOHL (glob_word->or_hwoffset);
230 NTOHL (glob_word->or_hwfree);
231 NTOHL (glob_word->or_hwaddrs);
234 } /* fillnew_wordrec() */
236 /********************* VSTFUNCT.C **********************************/