1 /* Copyright (C) 1996-2001, 2002, 2003, 2005 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper, <drepper@gnu.org>.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; version 2 of the License, or
8 (at your option) any later version.
10 This program 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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #define _LINEREADER_H 1
29 #include "locfile-token.h"
30 #include "repertoire.h"
33 typedef const struct keyword_t
*(*kw_hash_fct_t
) (const char *, unsigned int);
49 unsigned long int num
;
52 /* This element is sized on the safe expectation that no single
53 character in any character set uses more then 16 bytes. */
54 unsigned char bytes
[16];
78 int translate_strings
;
81 kw_hash_fct_t hash_fct
;
85 /* Functions defined in linereader.c. */
86 extern struct linereader
*lr_open (const char *fname
, kw_hash_fct_t hf
);
87 extern struct linereader
*lr_create (FILE *fp
, const char *fname
,
89 extern int lr_eof (struct linereader
*lr
);
90 extern void lr_close (struct linereader
*lr
);
91 extern int lr_next (struct linereader
*lr
);
92 extern struct token
*lr_token (struct linereader
*lr
,
93 const struct charmap_t
*charmap
,
94 struct localedef_t
*locale
,
95 const struct repertoire_t
*repertoire
,
97 extern void lr_ignore_rest (struct linereader
*lr
, int verbose
);
100 #define lr_error(lr, fmt, args...) \
101 WITH_CUR_LOCALE (error_at_line (0, 0, lr->fname, lr->lineno, fmt, ## args))
106 __attribute ((always_inline
))
107 lr_getc (struct linereader
*lr
)
109 if (lr
->idx
== lr
->bufact
)
112 if (lr_next (lr
) < 0)
119 return lr
->buf
[lr
->idx
] == '\32' ? EOF
: lr
->buf
[lr
->idx
++];
124 __attribute ((always_inline
))
125 lr_ungetc (struct linereader
*lr
, int ch
)
131 lr
->buf
[--lr
->idx
] = ch
;
137 lr_ungetn (struct linereader
*lr
, size_t n
)
147 #endif /* linereader.h */