fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
at master 83 lines 2.8 kB view raw
1/***************************************************************************** 2 * libini * 3 *****************************************************************************/ 4 5/***************************************************************************** 6 * File name: src/libini/scanner.h * 7 * Created: 2001-03-05 by Hampa Hug <hampa@hampa.ch> * 8 * Copyright: (C) 2001-2020 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 LIBINI_SCANNER_H 24#define LIBINI_SCANNER_H 1 25 26 27#include <stdio.h> 28 29 30#define SCN_BUF_MAX 256 31 32 33typedef struct scn_file_t { 34 struct scn_file_t *next; 35 char *name; 36 FILE *fp; 37 int del; 38 39 unsigned long line; 40 unsigned long offset; 41} scn_file_t; 42 43 44/*!*************************************************************************** 45 * @short The scanner type 46 *****************************************************************************/ 47typedef struct { 48 unsigned cnt; 49 unsigned buf[SCN_BUF_MAX]; 50 51 unsigned long line; 52 unsigned long offset; 53 54 int nl; 55 56 scn_file_t *file; 57 58 const char *str; 59} scanner_t; 60 61 62void scn_init (scanner_t *scn); 63void scn_free (scanner_t *scn); 64 65void scn_set_str (scanner_t *scn, const char *str); 66 67int scn_add_file (scanner_t *scn, const char *fname, FILE *fp, int del, int rel); 68 69char scn_get_chr (scanner_t *scn, unsigned idx); 70void scn_rmv_chr (scanner_t *scn, unsigned cnt); 71 72unsigned long scn_get_line (const scanner_t *scn); 73unsigned long scn_get_offset (const scanner_t *scn); 74 75int scn_match_space (scanner_t *scn); 76int scn_match_name (scanner_t *scn, char *str, unsigned max); 77int scn_match_string (scanner_t *scn, char *str, unsigned max); 78int scn_peek (scanner_t *scn, const char *str); 79int scn_match_ident (scanner_t *scn, const char *str); 80int scn_match (scanner_t *scn, const char *str); 81 82 83#endif