xmlsecurityengine/xmlsec/inc/xmlsec_buffer.h
changeset 0 e35f40988205
child 20 889504eac4fb
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 /** 
       
     2  * XML Security Library (http://www.aleksey.com/xmlsec).
       
     3  *
       
     4  * Memory buffer.
       
     5  *
       
     6  * This is free software; see Copyright file in the source
       
     7  * distribution for preciese wording.
       
     8  * 
       
     9  * Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com>
       
    10  * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
       
    11  */
       
    12 #ifndef __XMLSEC_BUFFER_H__
       
    13 #define __XMLSEC_BUFFER_H__    
       
    14 
       
    15 #ifdef __cplusplus
       
    16 extern "C" {
       
    17 #endif /* __cplusplus */ 
       
    18 
       
    19 #include <libxml2_tree.h>
       
    20 #include "xmlsec_config.h"
       
    21 #include "xmlsec_xmlsec.h"
       
    22 
       
    23 typedef struct _xmlSecBuffer					xmlSecBuffer, 
       
    24 								*xmlSecBufferPtr;
       
    25 
       
    26 
       
    27 /** 
       
    28  * xmlSecAllocMode:
       
    29  * @xmlSecAllocModeExact: 	the memory allocation mode that minimizes total 
       
    30  *				allocated memory size.
       
    31  * @xmlSecAllocModeDouble:	the memory allocation mode that tries to minimize
       
    32  *				the number of malloc calls.
       
    33  *
       
    34  * The memory allocation mode (used by @xmlSecBuffer and @xmlSecList).
       
    35  */
       
    36 typedef enum {
       
    37     xmlSecAllocModeExact = 0,
       
    38     xmlSecAllocModeDouble
       
    39 } xmlSecAllocMode;
       
    40 
       
    41 /*****************************************************************************
       
    42  *
       
    43  * xmlSecBuffer
       
    44  *
       
    45  ****************************************************************************/
       
    46 
       
    47 /** 
       
    48  * xmlSecBuffer:
       
    49  * @data: the pointer to buffer data.
       
    50  * @size: the current data size.
       
    51  * @maxSize: the max data size (allocated buffer size).
       
    52  * @allocMode: the buffer memory allocation mode.
       
    53  *
       
    54  * Binary data buffer.
       
    55  */
       
    56 struct _xmlSecBuffer {
       
    57     xmlSecByte* 	data;
       
    58     xmlSecSize 		size;
       
    59     xmlSecSize		maxSize;
       
    60     xmlSecAllocMode 	allocMode;
       
    61 };
       
    62 
       
    63 XMLSEC_EXPORT void		xmlSecBufferSetDefaultAllocMode	(xmlSecAllocMode defAllocMode,
       
    64 								 xmlSecSize defInitialSize);
       
    65 
       
    66 XMLSEC_EXPORT xmlSecBufferPtr	xmlSecBufferCreate		(xmlSecSize size);
       
    67 XMLSEC_EXPORT void		xmlSecBufferDestroy		(xmlSecBufferPtr buf);
       
    68 XMLSEC_EXPORT int		xmlSecBufferInitialize		(xmlSecBufferPtr buf,
       
    69 								 xmlSecSize size);
       
    70 XMLSEC_EXPORT void		xmlSecBufferFinalize		(xmlSecBufferPtr buf);
       
    71 XMLSEC_EXPORT xmlSecByte*	xmlSecBufferGetData		(xmlSecBufferPtr buf);
       
    72 XMLSEC_EXPORT int		xmlSecBufferSetData		(xmlSecBufferPtr buf,
       
    73 								 const xmlSecByte* data,
       
    74 								 xmlSecSize size);
       
    75 XMLSEC_EXPORT xmlSecSize	xmlSecBufferGetSize		(xmlSecBufferPtr buf);
       
    76 XMLSEC_EXPORT int		xmlSecBufferSetSize		(xmlSecBufferPtr buf,
       
    77 								 xmlSecSize size);
       
    78 XMLSEC_EXPORT xmlSecSize	xmlSecBufferGetMaxSize		(xmlSecBufferPtr buf);
       
    79 XMLSEC_EXPORT int		xmlSecBufferSetMaxSize		(xmlSecBufferPtr buf,
       
    80 								 xmlSecSize size);
       
    81 XMLSEC_EXPORT void		xmlSecBufferEmpty		(xmlSecBufferPtr buf);
       
    82 XMLSEC_EXPORT int		xmlSecBufferAppend		(xmlSecBufferPtr buf,
       
    83 								 const xmlSecByte* data,
       
    84 								 xmlSecSize size);
       
    85 XMLSEC_EXPORT int		xmlSecBufferPrepend		(xmlSecBufferPtr buf,
       
    86 								 const xmlSecByte* data,
       
    87 								 xmlSecSize size);
       
    88 XMLSEC_EXPORT int		xmlSecBufferRemoveHead		(xmlSecBufferPtr buf,
       
    89 								 xmlSecSize size);
       
    90 XMLSEC_EXPORT int		xmlSecBufferRemoveTail		(xmlSecBufferPtr buf,
       
    91 								 xmlSecSize size);
       
    92 
       
    93 XMLSEC_EXPORT int		xmlSecBufferReadFile		(xmlSecBufferPtr buf,
       
    94 								 const char* filename);
       
    95 
       
    96 XMLSEC_EXPORT int		xmlSecBufferBase64NodeContentRead(xmlSecBufferPtr buf,
       
    97 								 xmlNodePtr node);
       
    98 XMLSEC_EXPORT int		xmlSecBufferBase64NodeContentWrite(xmlSecBufferPtr buf,
       
    99 								 xmlNodePtr node,
       
   100 								 int columns);
       
   101 
       
   102 XMLSEC_EXPORT xmlOutputBufferPtr xmlSecBufferCreateOutputBuffer	(xmlSecBufferPtr buf);
       
   103 
       
   104 
       
   105 #ifdef __cplusplus
       
   106 }
       
   107 #endif /* __cplusplus */
       
   108 
       
   109 #endif /* __XMLSEC_BUFFER_H__ */
       
   110