Lines Matching defs:fnp

77  *	struct fn *fnp = fn_new("this is a string");
82 struct fn *fnp = MALLOC(sizeof (struct fn));
84 fnp->fn_n = -1;
85 bzero(&fnp->fn_stbuf, sizeof (fnp->fn_stbuf));
86 fnp->fn_next = NULL;
94 fnp->fn_buf = MALLOC(buflen);
95 fnp->fn_buflast = &fnp->fn_buf[buflen - 1];
96 (void) strlcpy(fnp->fn_buf, s, buflen);
97 fnp->fn_rptr = fnp->fn_buf;
98 fnp->fn_wptr = &fnp->fn_buf[len];
101 fnp->fn_buf = MALLOC(FN_MIN);
102 fnp->fn_buflast = &fnp->fn_buf[FN_MIN - 1];
103 *fnp->fn_buf = '\0';
104 fnp->fn_rptr = fnp->fn_buf;
105 fnp->fn_wptr = fnp->fn_buf;
108 return (fnp);
115 fn_dup(struct fn *fnp)
117 struct fn *ret = fn_new(fn_s(fnp));
119 ret->fn_n = fnp->fn_n;
120 ret->fn_stbuf = fnp->fn_stbuf;
129 fn_dirname(struct fn *fnp)
135 buf = fn_s(fnp);
158 fn_setn(struct fn *fnp, int n)
160 fnp->fn_n = n;
172 fn_setstat(struct fn *fnp, struct stat *stp)
174 fnp->fn_stbuf = *stp;
181 fn_getstat(struct fn *fnp)
183 return (&fnp->fn_stbuf);
190 fn_free(struct fn *fnp)
192 if (fnp) {
193 if (fnp->fn_buf)
194 FREE(fnp->fn_buf);
195 FREE(fnp);
202 * calling fn_renew(fnp, s) is the same as calling:
203 * fn_free(fnp);
207 fn_renew(struct fn *fnp, const char *s)
209 fnp->fn_rptr = fnp->fn_wptr = fnp->fn_buf;
210 fn_puts(fnp, s);
220 fn_putc(struct fn *fnp, int c)
222 if (fnp->fn_wptr >= fnp->fn_buflast) {
223 int buflen = fnp->fn_buflast + 1 - fnp->fn_buf;
235 src = fnp->fn_buf;
239 while (src < fnp->fn_wptr)
241 fnp->fn_rptr = &newbuf[fnp->fn_rptr - fnp->fn_buf];
242 FREE(fnp->fn_buf);
243 fnp->fn_buf = newbuf;
244 fnp->fn_buflast = &fnp->fn_buf[buflen - 1];
245 fnp->fn_wptr = dst;
247 *fnp->fn_wptr++ = c;
248 *fnp->fn_wptr = '\0';
255 fn_puts(struct fn *fnp, const char *s)
259 fn_putc(fnp, *s++);
266 fn_putfn(struct fn *fnp, struct fn *srcfnp)
272 fn_putc(fnp, c);
279 fn_rewind(struct fn *fnp)
281 fnp->fn_rptr = fnp->fn_buf;
288 fn_getc(struct fn *fnp)
290 if (fnp->fn_rptr > fnp->fn_buflast || *fnp->fn_rptr == '\0')
293 return (*fnp->fn_rptr++);
300 fn_peekc(struct fn *fnp)
302 if (fnp->fn_rptr > fnp->fn_buflast || *fnp->fn_rptr == '\0')
305 return (*fnp->fn_rptr);
312 fn_s(struct fn *fnp)
314 return (fnp->fn_buf);
321 fn_isgz(struct fn *fnp)
326 name = fnp->fn_buf;
367 struct fn *fnp;
370 while ((fnp = fn_list_next(fnlp)) != NULL)
371 fn_list_addfn(ret, fn_dup(fnp));
382 struct fn *fnp;
385 while ((fnp = fn_list_next(fnlp)) != NULL)
386 fn_free(fnp);
403 fn_list_addfn(struct fn_list *fnlp, struct fn *fnp)
405 fnp->fn_next = NULL;
407 fnlp->fnl_first = fnlp->fnl_last = fnlp->fnl_rptr = fnp;
409 fnlp->fnl_last->fn_next = fnp;
410 fnlp->fnl_last = fnp;
478 struct fn *fnp = fnlp->fnl_first;
483 while (fnp != NULL) {
484 if (fnp == fnlp->fnl_last)
487 nextfnp = fnp->fn_next;
491 fn_putc(fnp, *ptr);
493 fnp = nextfnp;
503 struct fn *fnp;
507 while ((fnp = fn_list_next(fnlp)) != NULL)
508 ret += fnp->fn_stbuf.st_size;
523 struct fn *fnp;
527 while ((fnp = fn_list_next(fnlp)) != NULL)
529 ret = fnp;
530 else if (fnp->fn_n > ret->fn_n ||
531 (fnp->fn_n == ret->fn_n &&
532 (fnp->fn_stbuf.st_mtime < ret->fn_stbuf.st_mtime ||
533 ((fnp->fn_stbuf.st_mtime == ret->fn_stbuf.st_mtime &&
534 strcmp(fnp->fn_buf, ret->fn_buf) > 0)))))
535 ret = fnp;
545 while ((fnp = fn_list_next(fnlp)) != NULL) {
546 if (fnp->fn_next == ret) {
547 fnp->fn_next = ret->fn_next;
549 fnlp->fnl_last = fnp;