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