Lines Matching refs:pwp

137 PWClose(PWDICT *pwp)
139 if (pwp->header.pih_magic != PIH_MAGIC) {
143 if (pwp->flags & PFOR_WRITE) {
144 pwp->flags |= PFOR_FLUSH;
145 (void) PutPW(pwp, (char *)0); /* flush last index if necess */
147 if (fseek(pwp->ifp, 0L, 0)) {
151 if (!fwrite((char *)&pwp->header, sizeof (pwp->header),
152 1, pwp->ifp)) {
156 if (pwp->flags & PFOR_USEHWMS) {
159 if (!pwp->hwms[i]) {
160 pwp->hwms[i] = pwp->hwms[i-1];
163 (void) fwrite(pwp->hwms, 1, sizeof (pwp->hwms),
164 pwp->wfp);
168 (void) fclose(pwp->ifp);
169 (void) fclose(pwp->dfp);
170 (void) fclose(pwp->wfp);
172 pwp->header.pih_magic = 0;
174 free(pwp);
180 PutPW(PWDICT *pwp, char *string)
182 if (!(pwp->flags & PFOR_WRITE)) {
187 (void) strncpy(pwp->data[pwp->count], string, MAXWORDLEN);
188 pwp->data[pwp->count][MAXWORDLEN - 1] = '\0';
190 pwp->hwms[string[0] & 0xff] = pwp->header.pih_numwords;
192 ++(pwp->count);
193 ++(pwp->header.pih_numwords);
195 } else if (!(pwp->flags & PFOR_FLUSH)) {
199 if ((pwp->flags & PFOR_FLUSH) || !(pwp->count % NUMWORDS)) {
204 datum = (uint32_t)ftell(pwp->dfp);
206 (void) fwrite((char *)&datum, sizeof (datum), 1, pwp->ifp);
208 (void) fputs(pwp->data[0], pwp->dfp);
209 (void) putc(0, pwp->dfp);
211 ostr = pwp->data[0];
217 nstr = pwp->data[i];
223 (void) putc(j & 0xff, pwp->dfp);
224 (void) fputs(nstr + j, pwp->dfp);
226 (void) putc(0, pwp->dfp);
231 (void) memset(pwp->data, '\0', sizeof (pwp->data));
232 pwp->count = 0;
238 GetPW(PWDICT *pwp, uint32_t number)
256 if (fseek(pwp->ifp, sizeof (struct pi_header) +
261 if (!fread((char *)&datum, sizeof (datum), 1, pwp->ifp)) {
265 if (fseek(pwp->dfp, datum, 0)) {
269 if (!fread(buffer, 1, sizeof (buffer), pwp->dfp)) {
296 FindPW(PWDICT *pwp, char *string)
303 return (PW_WORDS(pwp));
305 if (pwp->flags & PFOR_USEHWMS) {
307 lwm = idx ? pwp->hwms[idx - 1] : 0;
308 hwm = pwp->hwms[idx];
311 hwm = PW_WORDS(pwp) - 1;
321 if (feof(pwp->ifp) && feof(pwp->dfp) && feof(pwp->wfp))
324 if ((this = GetPW(pwp, pivot)) == NULL)
341 return (PW_WORDS(pwp));