1 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset:8 -*- */ 2 3 /* libcroco - Library for parsing and applying CSS 4 * Copyright (C) 2006-2019 Free Software Foundation, Inc. 5 * 6 * This file is not part of the GNU gettext program, but is used with 7 * GNU gettext. 8 * 9 * The original copyright notice is as follows: 10 */ 11 12 /* 13 * This file is part of The Croco Library 14 * 15 * Copyright (C) 2003-2004 Dodji Seketeli. All Rights Reserved. 16 * 17 * This program is free software; you can redistribute it and/or 18 * modify it under the terms of version 2.1 of the GNU Lesser General Public 19 * License as published by the Free Software Foundation. 20 * 21 * This program is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * GNU General Public License for more details. 25 * 26 * You should have received a copy of the GNU Lesser General Public License 27 * along with this program; if not, write to the Free Software 28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 29 * USA 30 * 31 * Author: Dodji Seketeli 32 */ 33 34 #ifndef __CR_INPUT_SRC_H__ 35 #define __CR_INPUT_SRC_H__ 36 37 38 #include <glib.h> 39 #include "cr-utils.h" 40 #include "cr-parsing-location.h" 41 42 G_BEGIN_DECLS 43 44 /** 45 *@file 46 *The libcroco basic input stream class 47 *declaration file. 48 */ 49 50 typedef struct _CRInput CRInput ; 51 typedef struct _CRInputPriv CRInputPriv ; 52 53 /** 54 *The #CRInput class provides the abstraction of 55 *an utf8-encoded character stream. 56 */ 57 struct _CRInput 58 { 59 CRInputPriv *priv ; 60 } ; 61 62 typedef struct _CRInputPos CRInputPos ; 63 64 struct _CRInputPos 65 { 66 glong line ; 67 glong col ; 68 gboolean end_of_file ; 69 gboolean end_of_line ; 70 glong next_byte_index ; 71 } ; 72 73 CRInput * 74 cr_input_new_from_buf (guchar *a_buf, gulong a_len, 75 enum CREncoding a_enc, gboolean a_free_buf) ; 76 CRInput * 77 cr_input_new_from_uri (const gchar *a_file_uri, 78 enum CREncoding a_enc) ; 79 80 void 81 cr_input_destroy (CRInput *a_this) ; 82 83 void 84 cr_input_ref (CRInput *a_this) ; 85 86 gboolean 87 cr_input_unref (CRInput *a_this) ; 88 89 enum CRStatus 90 cr_input_read_byte (CRInput *a_this, guchar *a_byte) ; 91 92 enum CRStatus 93 cr_input_read_char (CRInput *a_this, guint32 *a_char) ; 94 95 enum CRStatus 96 cr_input_consume_chars (CRInput *a_this, guint32 a_char, 97 gulong *a_nb_char) ; 98 99 enum CRStatus 100 cr_input_consume_char (CRInput *a_this, guint32 a_char) ; 101 102 enum CRStatus 103 cr_input_consume_white_spaces (CRInput *a_this, gulong *a_nb_chars) ; 104 105 enum CRStatus 106 cr_input_peek_byte (CRInput const *a_this, enum CRSeekPos a_origin, 107 gulong a_offset, guchar *a_byte) ; 108 109 guchar 110 cr_input_peek_byte2 (CRInput const *a_this, gulong a_offset, 111 gboolean *a_eof) ; 112 113 enum CRStatus 114 cr_input_peek_char (CRInput const *a_this, guint32 *a_char) ; 115 116 guchar * 117 cr_input_get_byte_addr (CRInput *a_this, 118 gulong a_offset) ; 119 120 enum CRStatus 121 cr_input_get_cur_byte_addr (CRInput *a_this, guchar ** a_offset) ; 122 123 enum CRStatus 124 cr_input_seek_index (CRInput *a_this, 125 enum CRSeekPos a_origin, gint a_pos) ; 126 127 enum CRStatus 128 cr_input_get_cur_index (CRInput const *a_this, glong *a_index) ; 129 130 enum CRStatus 131 cr_input_set_cur_index (CRInput *a_this, glong a_index) ; 132 133 enum CRStatus 134 cr_input_get_cur_pos (CRInput const *a_this, CRInputPos * a_pos) ; 135 136 enum CRStatus 137 cr_input_set_cur_pos (CRInput *a_this, CRInputPos const *a_pos) ; 138 139 enum CRStatus 140 cr_input_get_parsing_location (CRInput const *a_this, 141 CRParsingLocation *a_loc) ; 142 143 enum CRStatus 144 cr_input_get_end_of_line (CRInput const *a_this, gboolean *a_eol) ; 145 146 enum CRStatus 147 cr_input_set_end_of_line (CRInput *a_this, gboolean a_eol) ; 148 149 enum CRStatus 150 cr_input_get_end_of_file (CRInput const *a_this, gboolean *a_eof) ; 151 152 enum CRStatus 153 cr_input_set_end_of_file (CRInput *a_this, gboolean a_eof) ; 154 155 enum CRStatus 156 cr_input_set_line_num (CRInput *a_this, glong a_line_num) ; 157 158 enum CRStatus 159 cr_input_get_line_num (CRInput const *a_this, glong *a_line_num) ; 160 161 enum CRStatus 162 cr_input_set_column_num (CRInput *a_this, glong a_col) ; 163 164 enum CRStatus 165 cr_input_get_column_num (CRInput const *a_this, glong *a_col) ; 166 167 enum CRStatus 168 cr_input_increment_line_num (CRInput *a_this, 169 glong a_increment) ; 170 171 enum CRStatus 172 cr_input_increment_col_num (CRInput *a_this, 173 glong a_increment) ; 174 175 glong 176 cr_input_get_nb_bytes_left (CRInput const *a_this) ; 177 178 enum CRStatus 179 cr_input_end_of_input (CRInput const *a_this, gboolean *a_end_of_input) ; 180 181 G_END_DECLS 182 183 #endif /*__CR_INPUT_SRC_H__*/ 184 185