fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/lib/text.h *
7 * Created: 2021-11-28 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2021-2023 Hampa Hug <hampa@hampa.ch> *
9 *****************************************************************************/
10
11/*****************************************************************************
12 * This program is free software. You can redistribute it and / or modify it *
13 * under the terms of the GNU General Public License version 2 as published *
14 * by the Free Software Foundation. *
15 * *
16 * This program is distributed in the hope that it will be useful, but *
17 * WITHOUT ANY WARRANTY, without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
19 * Public License for more details. *
20 *****************************************************************************/
21
22
23#ifndef PCE_LIB_TEXT_H
24#define PCE_LIB_TEXT_H 1
25
26
27#include <config.h>
28
29#include <stdio.h>
30
31
32typedef struct {
33 FILE *fp;
34
35 unsigned cnt;
36 char buf[256];
37 unsigned line;
38} pce_text_t;
39
40
41void txt_init (pce_text_t *ctx, FILE *fp);
42void txt_free (pce_text_t *ctx);
43
44int txt_error (pce_text_t *ctx, const char *str);
45
46int txt_putc (pce_text_t *ctx, int c);
47
48int txt_getc (pce_text_t *ctx, unsigned idx);
49
50void txt_skip (pce_text_t *ctx, unsigned cnt);
51
52int txt_match_space (pce_text_t *ctx);
53int txt_match_eol (pce_text_t *ctx);
54int txt_match (pce_text_t *ctx, const char *str, int skip);
55int txt_match_string (pce_text_t *ctx, char *str, unsigned max);
56int txt_match_hex_digit (pce_text_t *ctx, unsigned *val);
57int txt_match_uint (pce_text_t *ctx, unsigned base, unsigned long *val);
58
59
60#endif