1 /* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
21 #define _LINEREADER_H 1
28 #include "locfile-token.h"
31 typedef const struct keyword_t
*(*kw_hash_fct_t
) (const char *, int);
45 unsigned long int num
;
71 int translate_strings
;
73 kw_hash_fct_t hash_fct
;
77 /* Functions defined in linereader.c. */
78 struct linereader
*lr_open (const char *fname
, kw_hash_fct_t hf
);
79 int lr_eof (struct linereader
*lr
);
80 void lr_close (struct linereader
*lr
);
81 int lr_next (struct linereader
*lr
);
82 struct token
*lr_token (struct linereader
*lr
,
83 const struct charset_t
*charset
);
86 #define lr_error(lr, fmt, args...) \
87 error_at_line (0, 0, lr->fname, lr->lineno, fmt, ## args)
92 lr_getc (struct linereader
*lr
)
94 if (lr
->idx
== lr
->bufact
)
104 return lr
->buf
[lr
->idx
] == '\32' ? EOF
: lr
->buf
[lr
->idx
++];
109 lr_ungetc (struct linereader
*lr
, int ch
)
114 lr
->buf
[--lr
->idx
] = ch
;
120 lr_ungetn (struct linereader
*lr
, size_t n
)
131 lr_ignore_rest (struct linereader
*lr
, int verbose
)
135 while (isspace (lr
->buf
[lr
->idx
]) && lr
->buf
[lr
->idx
] != '\n'
136 && lr
->buf
[lr
->idx
] != lr
->comment_char
)
137 if (lr
->buf
[lr
->idx
] == '\0')
139 if (lr_next (lr
) < 0)
145 if (lr
->buf
[lr
->idx
] != '\n' &&lr
->buf
[lr
->idx
] != lr
->comment_char
)
146 lr_error (lr
, _("trailing garbage at end of line"));
149 /* Ignore continued line. */
150 while (lr
->bufact
> 0 && lr
->buf
[lr
->bufact
- 1] != '\n')
151 if (lr_next (lr
) < 0)
154 lr
->idx
= lr
->bufact
;
158 #endif /* linereader.h */