5 #define _RPMIOB_INTERNAL
20 iob->b =
_free(iob->b);
34 if (_rpmiobPool == NULL) {
49 iob->b =
xcalloc(iob->allocated+1,
sizeof(*iob->b));
65 while (iob->blen > 0 &&
xisspace((
int)iob->b[iob->blen-1]))
72 size_t ns = strlen(s);
78 if ((iob->blen + ns) > iob->allocated) {
80 iob->b =
xrealloc(iob->b, iob->allocated+1);
83 tail = iob->b + iob->blen;
105 return (
char *) iob->b;
111 return (iob != NULL ? iob->blen : 0);
116 static size_t blenmax = (32 * BUFSIZ);
124 fd =
Fopen(fn,
"r%{?_rpmgio}");
125 if (fd == NULL ||
Ferror(fd)) {
130 if ((xx =
Fstat(fd, &sb)) < 0 || sb.st_size == 0)
131 sb.st_size = blenmax;
132 #if defined(__linux__)
135 if (sb.st_size == 0 && !strncmp(fn,
"/proc/",
sizeof(
"/proc/")-1)) {
140 xx = read(
Fileno(fd), b, blen);
141 blen = (size_t) (xx >= 0 ? xx : 0);
149 blen =
Fread(b,
sizeof(*b), blen, fd);
155 if (blen < (
size_t)sb.st_size)
160 if (fd != NULL) (void)
Fclose(fd);
168 iob->allocated = blen;