Merge pull request #618 from smuehlst/opj_malloc_casts
[openjpeg.git] / src / lib / openjp2 / cio.h
index ca218cefe1e0b2ae892dda789e5a6ad4f3a61024..1b684ef881356f64de55b2c9e5cc971d943db766 100644 (file)
@@ -1,10 +1,18 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -41,7 +49,7 @@ The functions in CIO.C have for goal to realize a byte input / output process.
 /** @defgroup CIO CIO - byte input-output stream */
 /*@{*/
 
-#include "opj_config.h"
+#include "opj_config_private.h"
 
 /* ----------------------------------------------------------------------- */
 
@@ -83,6 +91,13 @@ typedef struct opj_stream_private
         */
        void *                                  m_user_data;
 
+       /**
+        * Pointer to function to free m_user_data (NULL at initialization)
+        * when destroying the stream. If pointer is NULL the function is not
+        * called and the m_user_data is not freed (even if non-NULL).
+        */
+       opj_stream_free_user_data_fn            m_free_user_data_fn;
+
        /**
         * User data length
         */
@@ -128,7 +143,7 @@ typedef struct opj_stream_private
     /**
     * FIXME DOC.
     */
-       opj_bool (* m_opj_seek) (struct opj_stream_private * , OPJ_OFF_T , struct opj_event_mgr *);
+       OPJ_BOOL (* m_opj_seek) (struct opj_stream_private * , OPJ_OFF_T , struct opj_event_mgr *);
 
        /**
         * number of bytes containing in the buffer.
@@ -169,7 +184,7 @@ void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n
  * @param p_buffer             pointer the data buffer to read data from.
  * @param p_value              pointer to the value that will store the data.
  * @param p_nb_bytes   the nb bytes to read.
- * @return                             the number of bytes read or -1 if an error occured.
+ * @return                             the number of bytes read or -1 if an error occurred.
  */
 void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
 
@@ -178,7 +193,7 @@ void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT
  * @param p_buffer             pointer the data buffer to write data to.
  * @param p_value              the value to write
  * @param p_nb_bytes   the number of bytes to write
- * @return                             the number of bytes written or -1 if an error occured
+ * @return                             the number of bytes written or -1 if an error occurred
 */
 void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
 
@@ -187,7 +202,7 @@ void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n
  * @param p_buffer             pointer the data buffer to read data from.
  * @param p_value              pointer to the value that will store the data.
  * @param p_nb_bytes   the nb bytes to read.
- * @return                             the number of bytes read or -1 if an error occured.
+ * @return                             the number of bytes read or -1 if an error occurred.
  */
 void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
 
@@ -254,7 +269,7 @@ void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
  * @param              p_buffer        pointer to the data buffer that will receive the data.
  * @param              p_size          number of bytes to read.
  * @param              p_event_mgr     the user event manager to be notified of special events.
- * @return             the number of bytes read, or -1 if an error occured or if the stream is at the end.
+ * @return             the number of bytes read, or -1 if an error occurred or if the stream is at the end.
  */
 OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
 
@@ -264,7 +279,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
  * @param              p_buffer        pointer to the data buffer holds the data to be writtent.
  * @param              p_size          number of bytes to write.
  * @param              p_event_mgr     the user event manager to be notified of special events.
- * @return             the number of bytes writtent, or -1 if an error occured.
+ * @return             the number of bytes writtent, or -1 if an error occurred.
  */
 OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
 
@@ -274,14 +289,14 @@ OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE
  * @param              p_event_mgr     the user event manager to be notified of special events.
  * @return             true if the data could be flushed, false else.
  */
-opj_bool opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr);
+OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr);
 
 /**
  * Skips a number of bytes from the stream.
  * @param              p_stream        the stream to skip data from.
  * @param              p_size          the number of bytes to skip.
  * @param              p_event_mgr     the user event manager to be notified of special events.
- * @return             the number of bytes skipped, or -1 if an error occured.
+ * @return             the number of bytes skipped, or -1 if an error occurred.
  */
 OPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
 
@@ -309,7 +324,7 @@ OPJ_OFF_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream
  * @param              p_stream        the stream to skip data from.
  * @param              p_size          the number of bytes to skip.
  * @param              p_event_mgr     the user event manager to be notified of special events.
- * @return             the number of bytes skipped, or -1 if an error occured.
+ * @return             the number of bytes skipped, or -1 if an error occurred.
  */
 OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
 
@@ -318,7 +333,7 @@ OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_si
  * @param              p_stream        the stream to skip data from.
  * @param              p_size          the number of bytes to skip.
  * @param              p_event_mgr     the user event manager to be notified of special events.
- * @return             the number of bytes skipped, or -1 if an error occured.
+ * @return             the number of bytes skipped, or -1 if an error occurred.
  */
 OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
 
@@ -327,18 +342,18 @@ OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz
  * @param              p_stream        the stream to skip data from.
  * @param              p_size          the number of bytes to skip.
  * @param              p_event_mgr     the user event manager to be notified of special events.
- * @return             OPJ_TRUE if success, or OPJ_FALSE if an error occured.
+ * @return             OPJ_TRUE if success, or OPJ_FALSE if an error occurred.
  */
-opj_bool opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
+OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
 
 /**
  * Skips a number of bytes from the stream.
  * @param              p_stream        the stream to skip data from.
  * @param              p_size          the number of bytes to skip.
  * @param              p_event_mgr     the user event manager to be notified of special events.
- * @return             the number of bytes skipped, or -1 if an error occured.
+ * @return             the number of bytes skipped, or -1 if an error occurred.
  */
-opj_bool opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
+OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
 
 /**
  * Seeks a number of bytes from the stream.
@@ -347,12 +362,12 @@ opj_bool opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz
  * @param              p_event_mgr     the user event manager to be notified of special events.
  * @return             true if the stream is seekable.
  */
-opj_bool opj_stream_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
+OPJ_BOOL opj_stream_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
 
 /**
  * Tells if the given stream is seekable.
  */
-opj_bool opj_stream_has_seek (const opj_stream_private_t * p_stream);
+OPJ_BOOL opj_stream_has_seek (const opj_stream_private_t * p_stream);
 
 /**
  * FIXME DOC.
@@ -372,7 +387,7 @@ OPJ_OFF_T opj_stream_default_skip (OPJ_OFF_T p_nb_bytes, void * p_user_data);
 /**
  * FIXME DOC.
  */
-opj_bool opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data);
+OPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data);
 
 /* ----------------------------------------------------------------------- */
 /*@}*/