Home
last modified time | relevance | path

Searched refs:fp (Results 1 – 25 of 63) sorted by relevance

123

/bionic/libc/stdio/
Drefill.c40 lflush(FILE *fp) in lflush() argument
42 if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR)) in lflush()
43 return (__sflush_locked(fp)); /* ignored... */ in lflush()
52 __srefill(FILE *fp) in __srefill() argument
59 fp->_r = 0; /* largely a convenience for callers */ in __srefill()
62 if (fp->_flags & __SEOF) in __srefill()
66 if ((fp->_flags & __SRD) == 0) { in __srefill()
67 if ((fp->_flags & __SRW) == 0) { in __srefill()
69 fp->_flags |= __SERR; in __srefill()
73 if (fp->_flags & __SWR) { in __srefill()
[all …]
Dungetc.c47 __submore(FILE *fp) in __submore() argument
52 if (_UB(fp)._base == fp->_ubuf) { in __submore()
58 _UB(fp)._base = p; in __submore()
59 _UB(fp)._size = BUFSIZ; in __submore()
60 p += BUFSIZ - sizeof(fp->_ubuf); in __submore()
61 for (i = sizeof(fp->_ubuf); --i >= 0;) in __submore()
62 p[i] = fp->_ubuf[i]; in __submore()
63 fp->_p = p; in __submore()
66 i = _UB(fp)._size; in __submore()
67 p = realloc(_UB(fp)._base, i << 1); in __submore()
[all …]
Dfreopen.c49 freopen(const char *file, const char *mode, FILE *fp) in freopen() argument
55 (void) fclose(fp); in freopen()
62 FLOCKFILE(fp); in freopen()
72 if (fp->_flags == 0) { in freopen()
73 fp->_flags = __SEOF; /* hold on to it */ in freopen()
78 if (fp->_flags & __SWR) in freopen()
79 (void) __sflush(fp); in freopen()
81 isopen = fp->_close != NULL; in freopen()
82 if ((wantfd = fp->_file) < 0 && isopen) { in freopen()
83 (void) (*fp->_close)(fp->_cookie); in freopen()
[all …]
Dfread.c40 lflush(FILE *fp) in lflush() argument
42 if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR)) in lflush()
43 return (__sflush_locked(fp)); in lflush()
48 fread(void *buf, size_t size, size_t count, FILE *fp) in fread() argument
62 FLOCKFILE(fp); in fread()
63 if (fp->_r < 0) in fread()
64 fp->_r = 0; in fread()
69 if (fp->_flags & __SNBF && fp->_ur == 0) in fread()
79 fp->_r = 0; /* largely a convenience for callers */ in fread()
82 if (fp->_flags & __SEOF) { in fread()
[all …]
Dwsetup.c44 __swsetup(FILE *fp) in __swsetup() argument
53 if ((fp->_flags & __SWR) == 0) { in __swsetup()
54 if ((fp->_flags & __SRW) == 0) in __swsetup()
56 if (fp->_flags & __SRD) { in __swsetup()
58 if (HASUB(fp)) in __swsetup()
59 FREEUB(fp); in __swsetup()
60 fp->_flags &= ~(__SRD|__SEOF); in __swsetup()
61 fp->_r = 0; in __swsetup()
62 fp->_p = fp->_bf._base; in __swsetup()
64 fp->_flags |= __SWR; in __swsetup()
[all …]
Dfclose.c40 fclose(FILE *fp) in fclose() argument
44 if (fp->_flags == 0) { /* not open! */ in fclose()
48 FLOCKFILE(fp); in fclose()
49 WCIO_FREE(fp); in fclose()
50 r = fp->_flags & __SWR ? __sflush(fp) : 0; in fclose()
51 if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0) in fclose()
53 if (fp->_flags & __SMBF) in fclose()
54 free((char *)fp->_bf._base); in fclose()
55 if (HASUB(fp)) in fclose()
56 FREEUB(fp); in fclose()
[all …]
Dfseek.c49 fseeko(FILE *fp, off_t offset, int whence) in fseeko() argument
64 if ((seekfn = fp->_seek) == NULL) { in fseeko()
73 FLOCKFILE(fp); in fseeko()
82 __sflush(fp); /* may adjust seek offset on append stream */ in fseeko()
83 if (fp->_flags & __SOFF) in fseeko()
84 curoff = fp->_offset; in fseeko()
86 curoff = (*seekfn)(fp->_cookie, (fpos_t)0, SEEK_CUR); in fseeko()
88 FUNLOCKFILE(fp); in fseeko()
92 if (fp->_flags & __SRD) { in fseeko()
93 curoff -= fp->_r; in fseeko()
[all …]
Dfpurge.c44 fpurge(FILE *fp) in fpurge() argument
46 FLOCKFILE(fp); in fpurge()
47 if (!fp->_flags) { in fpurge()
48 FUNLOCKFILE(fp); in fpurge()
53 if (HASUB(fp)) in fpurge()
54 FREEUB(fp); in fpurge()
55 WCIO_FREE(fp); in fpurge()
56 fp->_p = fp->_bf._base; in fpurge()
57 fp->_r = 0; in fpurge()
58 fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size; in fpurge()
[all …]
Dfgetln.c47 __slbexpand(FILE *fp, size_t newsize) in __slbexpand() argument
54 if ((size_t)fp->_lb._size >= newsize) in __slbexpand()
56 if ((p = realloc(fp->_lb._base, newsize)) == NULL) in __slbexpand()
58 fp->_lb._base = p; in __slbexpand()
59 fp->_lb._size = newsize; in __slbexpand()
71 fgetln(FILE *fp, size_t *lenp) in fgetln() argument
78 FLOCKFILE(fp); in fgetln()
81 if (fp->_r <= 0 && __srefill(fp)) in fgetln()
85 if ((p = memchr((void *)fp->_p, '\n', fp->_r)) != NULL) { in fgetln()
92 ret = (char *)fp->_p; in fgetln()
[all …]
Dftell.c42 ftello(FILE *fp) in ftello() argument
46 if (fp->_seek == NULL) { in ftello()
56 FLOCKFILE(fp); in ftello()
57 __sflush(fp); /* may adjust seek offset on append stream */ in ftello()
58 if (fp->_flags & __SOFF) in ftello()
59 pos = fp->_offset; in ftello()
61 pos = (*fp->_seek)(fp->_cookie, (fpos_t)0, SEEK_CUR); in ftello()
65 if (fp->_flags & __SRD) { in ftello()
71 pos -= fp->_r; in ftello()
72 if (HASUB(fp)) in ftello()
[all …]
Dfflush.c40 fflush(FILE *fp) in fflush() argument
44 if (fp == NULL) in fflush()
46 FLOCKFILE(fp); in fflush()
47 if ((fp->_flags & (__SWR | __SRW)) == 0) { in fflush()
51 r = __sflush(fp); in fflush()
52 FUNLOCKFILE(fp); in fflush()
57 __sflush(FILE *fp) in __sflush() argument
62 t = fp->_flags; in __sflush()
66 if ((p = fp->_bf._base) == NULL) in __sflush()
69 n = fp->_p - p; /* write this much */ in __sflush()
[all …]
Dwbuf.c44 __swbuf(int c, FILE *fp) in __swbuf() argument
48 _SET_ORIENTATION(fp, -1); in __swbuf()
56 fp->_w = fp->_lbfsize; in __swbuf()
57 if (cantwrite(fp)) { in __swbuf()
72 n = fp->_p - fp->_bf._base; in __swbuf()
73 if (n >= fp->_bf._size) { in __swbuf()
74 if (__sflush(fp)) in __swbuf()
78 fp->_w--; in __swbuf()
79 *fp->_p++ = c; in __swbuf()
80 if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n')) in __swbuf()
[all …]
Dmakebuf.c49 __smakebuf(FILE *fp) in __smakebuf() argument
56 if (fp->_flags & __SNBF) { in __smakebuf()
57 fp->_bf._base = fp->_p = fp->_nbuf; in __smakebuf()
58 fp->_bf._size = 1; in __smakebuf()
61 flags = __swhatbuf(fp, &size, &couldbetty); in __smakebuf()
63 fp->_flags |= __SNBF; in __smakebuf()
64 fp->_bf._base = fp->_p = fp->_nbuf; in __smakebuf()
65 fp->_bf._size = 1; in __smakebuf()
70 fp->_bf._base = fp->_p = p; in __smakebuf()
71 fp->_bf._size = size; in __smakebuf()
[all …]
Dsetvbuf.c43 setvbuf(FILE *fp, char *buf, int mode, size_t size) in setvbuf() argument
64 FLOCKFILE(fp); in setvbuf()
66 (void)__sflush(fp); in setvbuf()
67 if (HASUB(fp)) in setvbuf()
68 FREEUB(fp); in setvbuf()
69 WCIO_FREE(fp); in setvbuf()
70 fp->_r = fp->_lbfsize = 0; in setvbuf()
71 flags = fp->_flags; in setvbuf()
73 free((void *)fp->_bf._base); in setvbuf()
85 flags |= __swhatbuf(fp, &iosize, &ttyflag); in setvbuf()
[all …]
Dlocal.h71 #define cantwrite(fp) \ argument
72 ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
73 __swsetup(fp))
79 #define HASUB(fp) (_UB(fp)._base != NULL) argument
80 #define FREEUB(fp) { \ argument
81 if (_UB(fp)._base != (fp)->_ubuf) \
82 free(_UB(fp)._base); \
83 _UB(fp)._base = NULL; \
89 #define HASLB(fp) ((fp)->_lb._base != NULL) argument
90 #define FREELB(fp) { \ argument
[all …]
Dfvwrite.c48 __sfvwrite(FILE *fp, struct __suio *uio) in __sfvwrite() argument
60 if (cantwrite(fp)) { in __sfvwrite()
66 #define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n)) in __sfvwrite()
79 if (fp->_flags & __SNBF) { in __sfvwrite()
86 w = (*fp->_write)(fp->_cookie, p, len); in __sfvwrite()
88 w = (*fp->_write)(fp->_cookie, p, MIN(len, BUFSIZ2)); in __sfvwrite()
95 } else if ((fp->_flags & __SLBF) == 0) { in __sfvwrite()
109 if ((fp->_flags & (__SALC | __SSTR)) == in __sfvwrite()
110 (__SALC | __SSTR) && fp->_w < (int)len) { in __sfvwrite()
111 size_t blen = fp->_p - fp->_bf._base; in __sfvwrite()
[all …]
Dfopen.c45 FILE *fp; in fopen() local
51 if ((fp = __sfp()) == NULL) in fopen()
54 fp->_flags = 0; /* release */ in fopen()
57 fp->_file = f; in fopen()
58 fp->_flags = flags; in fopen()
59 fp->_cookie = fp; in fopen()
60 fp->_read = __sread; in fopen()
61 fp->_write = __swrite; in fopen()
62 fp->_seek = __sseek; in fopen()
63 fp->_close = __sclose; in fopen()
[all …]
Dstdio.c46 FILE *fp = cookie; in __sread() local
49 ret = read(fp->_file, buf, n); in __sread()
52 fp->_offset += ret; in __sread()
54 fp->_flags &= ~__SOFF; /* paranoia */ in __sread()
61 FILE *fp = cookie; in __swrite() local
63 if (fp->_flags & __SAPP) in __swrite()
64 (void) lseek(fp->_file, (off_t)0, SEEK_END); in __swrite()
65 fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */ in __swrite()
66 return (write(fp->_file, buf, n)); in __swrite()
72 FILE *fp = cookie; in __sseek() local
[all …]
Dfgets.c45 fgets(char *buf, int n, FILE *fp) in fgets() argument
54 FLOCKFILE(fp); in fgets()
55 _SET_ORIENTATION(fp, -1); in fgets()
62 if (fp->_r <= 0) { in fgets()
63 if (__srefill(fp)) { in fgets()
66 FUNLOCKFILE(fp); in fgets()
72 len = fp->_r; in fgets()
73 p = fp->_p; in fgets()
86 fp->_r -= len; in fgets()
87 fp->_p = t; in fgets()
[all …]
Dfdopen.c44 FILE *fp; in fdopen() local
59 if ((fp = __sfp()) == NULL) in fdopen()
61 fp->_flags = flags; in fdopen()
68 fp->_flags |= __SAPP; in fdopen()
69 fp->_file = fd; in fdopen()
70 fp->_cookie = fp; in fdopen()
71 fp->_read = __sread; in fdopen()
72 fp->_write = __swrite; in fdopen()
73 fp->_seek = __sseek; in fdopen()
74 fp->_close = __sclose; in fdopen()
[all …]
Dfunopen.c43 FILE *fp; in funopen() local
58 if ((fp = __sfp()) == NULL) in funopen()
60 fp->_flags = flags; in funopen()
61 fp->_file = -1; in funopen()
62 fp->_cookie = (void *)cookie; /* SAFE: cookie not modified */ in funopen()
63 fp->_read = readfn; in funopen()
64 fp->_write = writefn; in funopen()
65 fp->_seek = seekfn; in funopen()
66 fp->_close = closefn; in funopen()
67 return (fp); in funopen()
Dfileext.h40 #define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base)) argument
41 #define _UB(fp) _EXT(fp)->_ub argument
43 #define _FILEEXT_INIT(fp) \ argument
45 _UB(fp)._base = NULL; \
46 _UB(fp)._size = 0; \
47 WCIO_INIT(fp); \
Dputc.c44 putc_unlocked(int c, FILE *fp) in putc_unlocked() argument
46 if (cantwrite(fp)) { in putc_unlocked()
50 return (__sputc(c, fp)); in putc_unlocked()
59 putc(int c, FILE *fp) in putc() argument
63 FLOCKFILE(fp); in putc()
64 ret = putc_unlocked(c, fp); in putc()
65 FUNLOCKFILE(fp); in putc()
Dgetc.c43 getc_unlocked(FILE *fp) in getc_unlocked() argument
45 return (__sgetc(fp)); in getc_unlocked()
54 getc(FILE *fp) in getc() argument
58 FLOCKFILE(fp); in getc()
59 c = __sgetc(fp); in getc()
60 FUNLOCKFILE(fp); in getc()
Drget.c43 __srget(FILE *fp) in __srget() argument
45 _SET_ORIENTATION(fp, -1); in __srget()
46 if (__srefill(fp) == 0) { in __srget()
47 fp->_r--; in __srget()
48 return (*fp->_p++); in __srget()

123