1 /* Copyright (C) 1996-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published
6 by the Free Software Foundation; version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <https://www.gnu.org/licenses/>. */
18 #define _LINEREADER_H 1
27 #include "locfile-token.h"
28 #include "repertoire.h"
29 #include "record-status.h"
31 typedef const struct keyword_t
*(*kw_hash_fct_t
) (const char *, size_t);
47 unsigned long int num
;
50 /* This element is sized on the safe expectation that no single
51 character in any character set uses more than 16 bytes. */
52 unsigned char bytes
[16];
76 int translate_strings
;
79 kw_hash_fct_t hash_fct
;
83 /* Functions defined in linereader.c. */
84 extern struct linereader
*lr_open (const char *fname
, kw_hash_fct_t hf
);
85 extern struct linereader
*lr_create (FILE *fp
, const char *fname
,
87 extern int lr_eof (struct linereader
*lr
);
88 extern void lr_close (struct linereader
*lr
);
89 extern int lr_next (struct linereader
*lr
);
90 extern struct token
*lr_token (struct linereader
*lr
,
91 const struct charmap_t
*charmap
,
92 struct localedef_t
*locale
,
93 const struct repertoire_t
*repertoire
,
95 extern void lr_ignore_rest (struct linereader
*lr
, int verbose
);
99 __attribute__ ((__format__ (__printf__
, 2, 3), nonnull (1, 2)))
100 lr_error (struct linereader
*lr
, const char *fmt
, ...)
104 struct locale_state ls
;
110 ret
= vasprintf (&str
, fmt
, arg
);
117 error_at_line (0, 0, lr
->fname
, lr
->lineno
, "%s", str
);
124 __attribute ((always_inline
))
125 lr_getc (struct linereader
*lr
)
127 if (lr
->idx
== lr
->bufact
)
130 if (lr_next (lr
) < 0)
137 return lr
->buf
[lr
->idx
++] & 0xff;
142 __attribute ((always_inline
))
143 lr_ungetc (struct linereader
*lr
, int ch
)
149 lr
->buf
[--lr
->idx
] = ch
;
155 lr_ungetn (struct linereader
*lr
, size_t n
)
165 #endif /* linereader.h */