Input from unstructured files 3 GSF Library Input from unstructured files Synopsis GsfInput; guint8const * gsf_input_read (GsfInput *input, size_t num_bytes, guint8 *optional_buffer); gsf_off_t gsf_input_tell (GsfInput *input); gboolean gsf_input_seek (GsfInput *input, gsf_off_t offset, GSeekType whence); GsfInfile* gsf_input_container (GsfInput *input); GsfInput* gsf_input_dup (GsfInput *input, GError **err); gsf_off_t gsf_input_size (GsfInput *input); gboolean gsf_input_eof (GsfInput *input); gsf_off_t gsf_input_remaining (GsfInput *input); GQuark gsf_input_error_id (void); GsfInput* gsf_input_sibling (GsfInput const *input, char const *name, GError **err); GQuark gsf_input_error (void); charconst * gsf_input_name (GsfInput *input); gboolean gsf_input_set_name_from_filename (GsfInput *input, char const *filename); GsfInputProxy; GsfInput* gsf_input_proxy_new (GsfInput *source); GsfInput* gsf_input_proxy_new_section (GsfInput *source, gsf_off_t offset, gsf_off_t size); gboolean gsf_input_copy (GsfInput *input, GsfOutput *output); GsfInput* gsf_input_uncompress (GsfInput *src); gboolean gsf_input_set_name (GsfInput *input, char const *name); gboolean gsf_input_set_container (GsfInput *input, GsfInfile *container); gboolean gsf_input_set_size (GsfInput *input, gsf_off_t size); gboolean gsf_input_seek_emulate (GsfInput *input, gsf_off_t pos); Object Hierarchy GObject +----GsfInput +----GsfInfile +----GsfInputGZip +----GsfInputMemory +----GsfInputStdio +----GsfInputTextline Properties "eof" gboolean : Read "name" gchararray : Read "position" gint64 : Read "remaining" gint64 : Read "size" gint64 : Read Description Details <anchor id="GsfInput-struct"/>GsfInput GsfInputtypedef struct _GsfInput GsfInput; <anchor id="gsf-input-read"/>gsf_input_read () gsf_input_readguint8const * gsf_input_read (GsfInput *input, size_t num_bytes, guint8 *optional_buffer); Read at least num_bytes. Does not change the current position if there is an error. Will only read if the entire amount can be read. Invalidates the buffer associated with previous calls to gsf_input_read. input : the input stream num_bytes : number of bytes to read optional_buffer : NULL, or pointer to destination memory area Returns :: pointer to the buffer or NULL if there is an error or 0 bytes are requested. <anchor id="gsf-input-tell"/>gsf_input_tell () gsf_input_tellgsf_off_t gsf_input_tell (GsfInput *input); input : the input stream Returns :the current offset in the file. <anchor id="gsf-input-seek"/>gsf_input_seek () gsf_input_seekgboolean gsf_input_seek (GsfInput *input, gsf_off_t offset, GSeekType whence); input : the input stream offset : target offset whence : determines whether the offset is relative to the beginning or the end of the stream, or to the current location. Returns :TRUE on error. <anchor id="gsf-input-container"/>gsf_input_container () gsf_input_containerGsfInfile* gsf_input_container (GsfInput *input); input : the input stream Returns :, but does not add a reference to input's container. Potentially NULL <anchor id="gsf-input-dup"/>gsf_input_dup () gsf_input_dupGsfInput* gsf_input_dup (GsfInput *input, GError **err); Duplicates input src leaving the new one at the same offset. input : The input to duplicate err : optionally NULL Returns :: the duplicate, or NULL on error <anchor id="gsf-input-size"/>gsf_input_size () gsf_input_sizegsf_off_t gsf_input_size (GsfInput *input); Looks up and caches the number of bytes in the input input : The input Returns :: the size or -1 on error <anchor id="gsf-input-eof"/>gsf_input_eof () gsf_input_eofgboolean gsf_input_eof (GsfInput *input); Are we at the end of the file ? input : the input Returns :: TRUE if the input is at the eof. <anchor id="gsf-input-remaining"/>gsf_input_remaining () gsf_input_remaininggsf_off_t gsf_input_remaining (GsfInput *input); input : the input stream Returns :the number of bytes left in the file. <anchor id="gsf-input-error-id"/>gsf_input_error_id () gsf_input_error_idGQuark gsf_input_error_id (void); Returns :: A utility quark to flag a GError as being an input problem. <anchor id="gsf-input-sibling"/>gsf_input_sibling () gsf_input_siblingGsfInput* gsf_input_sibling (GsfInput const *input, char const *name, GError **err); input : name : err : Returns : <anchor id="gsf-input-error"/>gsf_input_error () gsf_input_errorGQuark gsf_input_error (void); Deprecated in 1.12.0 Returns :: A utility quark to flag a GError as being an input problem. <anchor id="gsf-input-name"/>gsf_input_name () gsf_input_namecharconst * gsf_input_name (GsfInput *input); input : the input stream Returns :input's name in utf8 form, or NULL if it has no name. <anchor id="gsf-input-set-name-from-filename"/>gsf_input_set_name_from_filename () gsf_input_set_name_from_filenamegboolean gsf_input_set_name_from_filename (GsfInput *input, char const *filename); protected. input : the input stream filename : the (fs-sys encoded) filename Returns :: TRUE if the assignment was ok. <anchor id="GsfInputProxy"/>GsfInputProxy GsfInputProxytypedef struct _GsfInputProxy GsfInputProxy; <anchor id="gsf-input-proxy-new"/>gsf_input_proxy_new () gsf_input_proxy_newGsfInput* gsf_input_proxy_new (GsfInput *source); This creates a new proxy to the entire, given input source. See gsf_input_proxy_new_section for details. source : The underlying data source. Returns :a new input object. <anchor id="gsf-input-proxy-new-section"/>gsf_input_proxy_new_section () gsf_input_proxy_new_sectionGsfInput* gsf_input_proxy_new_section (GsfInput *source, gsf_off_t offset, gsf_off_t size); This creates a new proxy to a section of the given source. The new object will have its own current position, but any operation on it can change the source's position. If a proxy to a proxy is created, the intermediate proxy is short- circuited. This function will ref the source. source : The underlying data source. offset : Offset into source for start of section. size : Length of section. Returns :a new input object. <anchor id="gsf-input-copy"/>gsf_input_copy () gsf_input_copygboolean gsf_input_copy (GsfInput *input, GsfOutput *output); Copy the contents from input to output from their respective current positions. So if you want to be sure to copy *everything*, make sure to call gsf_input_seek (input, 0, G_SEEK_SET) and gsf_output_seek (output, 0, G_SEEK_SET) first, if applicable. input : a non-null GsfInput output : a non-null GsfOutput Returns :: TRUE on Success <anchor id="gsf-input-uncompress"/>gsf_input_uncompress () gsf_input_uncompressGsfInput* gsf_input_uncompress (GsfInput *src); src : stream to be uncompressed. Returns : A stream equivalent to the source stream, but uncompressed if the source was compressed. This functions takes ownership of the incoming reference and yields a new one as its output. <anchor id="gsf-input-set-name"/>gsf_input_set_name () gsf_input_set_namegboolean gsf_input_set_name (GsfInput *input, char const *name); protected. input : the input stream name : the new name of the stream, or NULL. Returns :: TRUE if the assignment was ok. <anchor id="gsf-input-set-container"/>gsf_input_set_container () gsf_input_set_containergboolean gsf_input_set_container (GsfInput *input, GsfInfile *container); input : the input stream container : Returns :: TRUE if the assignment was ok. <anchor id="gsf-input-set-size"/>gsf_input_set_size () gsf_input_set_sizegboolean gsf_input_set_size (GsfInput *input, gsf_off_t size); input : the input stream size : the size of the stream Returns :: TRUE if the assignment was ok. <anchor id="gsf-input-seek-emulate"/>gsf_input_seek_emulate () gsf_input_seek_emulategboolean gsf_input_seek_emulate (GsfInput *input, gsf_off_t pos); input : stream to emulate seek for pos : absolute position to seek to Returns :: TRUE if the emulation failed. Properties <anchor id="GsfInput--eof"/>The "<literal>eof</literal>" property "eof" gboolean : Read End Of File.Default value: FALSE <anchor id="GsfInput--name"/>The "<literal>name</literal>" property "name" gchararray : Read The Input's Name.Default value: NULL <anchor id="GsfInput--position"/>The "<literal>position</literal>" property "position" gint64 : Read The Output's Current Position.Allowed values: >= 0 Default value: 0 <anchor id="GsfInput--remaining"/>The "<literal>remaining</literal>" property "remaining" gint64 : Read Amount of Data Remaining.Allowed values: >= 0 Default value: 0 <anchor id="GsfInput--size"/>The "<literal>size</literal>" property "size" gint64 : Read The Input's Size.Allowed values: >= 0 Default value: 0