ReactOS 0.4.15-dev-7788-g1ad9096
fgetline.c File Reference
#include "schilyio.h"
Include dependency graph for fgetline.c:

Go to the source code of this file.

Macros

#define fgetline   __no__fgetline__
 
#define getline   __no__getline__
 
#define FAST_GETC_PUTC   /* Will be reset if not possible */
 

Functions

EXPORT int fgetline __PR ((FILE *, char *, int))
 
EXPORT int getline __PR ((char *, int))
 
EXPORT int fgetline (FILE *f, char *buf, int len)
 
EXPORT int getline (char *buf, int len)
 
EXPORT int js_fgetline (register FILE *f, char *buf, register int len)
 
EXPORT int js_getline (char *buf, int len)
 

Macro Definition Documentation

◆ FAST_GETC_PUTC

#define FAST_GETC_PUTC   /* Will be reset if not possible */

Definition at line 27 of file fgetline.c.

◆ fgetline

#define fgetline   __no__fgetline__

Definition at line 24 of file fgetline.c.

◆ getline

#define getline   __no__getline__

Definition at line 25 of file fgetline.c.

Function Documentation

◆ __PR() [1/2]

EXPORT int getline __PR ( (char *, int )

◆ __PR() [2/2]

EXPORT int fgetline __PR ( (FILE *, char *, int )

◆ fgetline()

EXPORT int fgetline ( FILE f,
char buf,
int  len 
)

Definition at line 47 of file fgetline.c.

51{
52 return (js_fgetline(f, buf, len));
53}
EXPORT int js_fgetline(register FILE *f, char *buf, register int len)
Definition: fgetline.c:94
GLfloat f
Definition: glext.h:7540
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722

◆ getline()

EXPORT int getline ( char buf,
int  len 
)

Definition at line 56 of file fgetline.c.

59{
60 return (js_fgetline(stdin, buf, len));
61}
#define stdin
Definition: stdio.h:98

◆ js_fgetline()

EXPORT int js_fgetline ( register FILE f,
char buf,
register int  len 
)

Definition at line 94 of file fgetline.c.

98{
99 register char *bp = buf;
100#if defined(HAVE_USG_STDIO) || defined(FAST_GETC_PUTC)
101 register char *p;
102#else
103 register int nl = '\n';
104 register int c = '\0';
105#endif
106
107 down2(f, _IOREAD, _IORW);
108
109 if (len <= 0)
110 return (0);
111
112 *bp = '\0';
113 for (;;) {
114#if defined(HAVE_USG_STDIO) || defined(FAST_GETC_PUTC)
115 size_t n;
116
117 if ((__c f)->_cnt <= 0) {
118 if (usg_filbuf(f) == EOF) {
119 /*
120 * If buffer is empty and we hit EOF, return EOF
121 */
122 if (bp == buf)
123 return (EOF);
124 break;
125 }
126 (__c f)->_cnt++;
127 (__c f)->_ptr--;
128 }
129
130 n = len;
131 if (n > (__c f)->_cnt)
132 n = (__c f)->_cnt;
133 p = movecbytes((__c f)->_ptr, bp, '\n', n);
134 if (p) {
135 n = p - bp;
136 }
137 (__c f)->_ptr += n;
138 (__c f)->_cnt -= n;
139 bp += n;
140 len -= n;
141 if (p != NULL) {
142 bp--; /* Remove '\n' */
143 break;
144 }
145#else
146 if ((c = getc(f)) < 0) {
147 /*
148 * If buffer is empty and we hit EOF, return EOF
149 */
150 if (bp == buf)
151 return (c);
152 break;
153 }
154 if (c == nl)
155 break;
156 if (--len > 0) {
157 *bp++ = (char)c;
158 } else {
159#ifdef __never__
160 /*
161 * Read up to end of line
162 */
163 while ((c = getc(f)) >= 0 && c != nl)
164 /* LINTED */
165 ;
166#endif
167 break;
168 }
169#endif
170 }
171 *bp = '\0';
172
173 return (bp - buf);
174}
#define NULL
Definition: types.h:112
unsigned char
Definition: typeof.h:29
GLdouble n
Definition: glext.h:7729
const GLubyte * c
Definition: glext.h:8905
GLfloat GLfloat p
Definition: glext.h:8902
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
#define EOF
Definition: stdio.h:24
#define _IOREAD
Definition: stdio.h:124
#define _IORW
Definition: stdio.h:135
#define f
Definition: ke_i.h:83
#define __c
Definition: schilyio.h:209
#define down2(f, fl1, fl2)
Definition: schilyio.h:218

Referenced by fgetline(), getline(), and js_getline().

◆ js_getline()

EXPORT int js_getline ( char buf,
int  len 
)

Definition at line 178 of file fgetline.c.

181{
182 return (js_fgetline(stdin, buf, len));
183}