xmlsecurityengine/xmlsec/inc/xmlsec_list.h
changeset 0 e35f40988205
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 /** 
       
     2  * XML Security Library (http://www.aleksey.com/xmlsec).
       
     3  *
       
     4  * List of pointers.
       
     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_LIST_H__
       
    13 #define __XMLSEC_LIST_H__    
       
    14 
       
    15 #ifdef __cplusplus
       
    16 extern "C" {
       
    17 #endif /* __cplusplus */ 
       
    18 
       
    19 #include "xmlsec_config.h"
       
    20 
       
    21 #include "xmlsec_xmlsec.h"
       
    22 #include "xmlsec_buffer.h"
       
    23 
       
    24 typedef const struct _xmlSecPtrListKlass			xmlSecPtrListKlass, 
       
    25 								*xmlSecPtrListId;
       
    26 typedef struct _xmlSecPtrList 					xmlSecPtrList, 
       
    27 								*xmlSecPtrListPtr;
       
    28 
       
    29 /**
       
    30  * xmlSecPtrList:
       
    31  * @id:				the list items description.
       
    32  * @data:			the list data.
       
    33  * @use:			the current list size.
       
    34  * @max:			the max (allocated) list size.
       
    35  * @allocMode:			the memory allocation mode.
       
    36  * 
       
    37  * The pointers list.
       
    38  */
       
    39 struct _xmlSecPtrList {
       
    40     xmlSecPtrListId		id;        
       
    41 
       
    42     xmlSecPtr*			data;
       
    43     xmlSecSize			use;
       
    44     xmlSecSize			max;
       
    45     xmlSecAllocMode 		allocMode;
       
    46 };
       
    47 
       
    48 XMLSEC_EXPORT void		xmlSecPtrListSetDefaultAllocMode(xmlSecAllocMode defAllocMode,
       
    49 								 xmlSecSize defInitialSize);
       
    50 
       
    51 
       
    52 XMLSEC_EXPORT int		xmlSecPtrListInitialize		(xmlSecPtrListPtr list,
       
    53 								 xmlSecPtrListId id);
       
    54 XMLSEC_EXPORT void		xmlSecPtrListFinalize		(xmlSecPtrListPtr list);
       
    55 XMLSEC_EXPORT xmlSecPtrListPtr	xmlSecPtrListCreate		(xmlSecPtrListId id);
       
    56 XMLSEC_EXPORT void		xmlSecPtrListDestroy		(xmlSecPtrListPtr list);
       
    57 XMLSEC_EXPORT void		xmlSecPtrListEmpty		(xmlSecPtrListPtr list);
       
    58 
       
    59 XMLSEC_EXPORT int		xmlSecPtrListCopy		(xmlSecPtrListPtr dst,
       
    60 								 xmlSecPtrListPtr src);
       
    61 XMLSEC_EXPORT xmlSecPtrListPtr	xmlSecPtrListDuplicate		(xmlSecPtrListPtr list);
       
    62 
       
    63 XMLSEC_EXPORT xmlSecSize	xmlSecPtrListGetSize		(xmlSecPtrListPtr list);
       
    64 XMLSEC_EXPORT xmlSecPtr		xmlSecPtrListGetItem		(xmlSecPtrListPtr list,
       
    65 							         xmlSecSize pos);
       
    66 XMLSEC_EXPORT int		xmlSecPtrListAdd		(xmlSecPtrListPtr list,
       
    67 								 xmlSecPtr item);
       
    68 XMLSEC_EXPORT int		xmlSecPtrListSet		(xmlSecPtrListPtr list,
       
    69 								 xmlSecPtr item,
       
    70 								 xmlSecSize pos);
       
    71 XMLSEC_EXPORT int		xmlSecPtrListRemove		(xmlSecPtrListPtr list,
       
    72 							    	 xmlSecSize pos);
       
    73 XMLSEC_EXPORT void		xmlSecPtrListDebugDump		(xmlSecPtrListPtr list,
       
    74     								 FILE* output);
       
    75 XMLSEC_EXPORT void		xmlSecPtrListDebugXmlDump	(xmlSecPtrListPtr list,
       
    76  								 FILE* output);
       
    77 
       
    78 /**
       
    79  * xmlSecPtrListGetName:
       
    80  * @list: 		the ponter to list.
       
    81  * 
       
    82  * Macro. Returns lists's name.
       
    83  */
       
    84 #define xmlSecPtrListGetName(list) \
       
    85 	(((list) != NULL) ? xmlSecPtrListKlassGetName((list)->id) : NULL)
       
    86 
       
    87 /**
       
    88  * xmlSecPtrListIsValid:
       
    89  * @list: 		the pointer to list.
       
    90  *
       
    91  * Macro. Returns 1 if @list is not NULL and @list->id is not NULL
       
    92  * or 0 otherwise.
       
    93  */ 
       
    94 #define xmlSecPtrListIsValid(list) \
       
    95 	((( list ) != NULL) && ((( list )->id) != NULL))
       
    96 /**
       
    97  * xmlSecPtrListCheckId:
       
    98  * @list: 		the pointer to list.
       
    99  * @dataId: 		the list Id.
       
   100  *
       
   101  * Macro. Returns 1 if @list is valid and @list's id is equal to @dataId.
       
   102  */
       
   103 #define xmlSecPtrListCheckId(list, dataId) \
       
   104  	(xmlSecPtrListIsValid(( list )) && \
       
   105 	((( list )->id) == ( dataId )))
       
   106 
       
   107 
       
   108 /**************************************************************************
       
   109  *
       
   110  * List klass
       
   111  *
       
   112  *************************************************************************/
       
   113 /**
       
   114  * xmlSecPtrListIdUnknown:
       
   115  *
       
   116  * The "unknown" id.
       
   117  */
       
   118 #define xmlSecPtrListIdUnknown 			NULL
       
   119 
       
   120 /**
       
   121  * xmlSecPtrDuplicateItemMethod:
       
   122  * @ptr:		the poinetr to list item.
       
   123  *
       
   124  * Duplicates item @ptr.
       
   125  *
       
   126  * Returns pointer to new item copy or NULL if an error occurs.
       
   127  */
       
   128 typedef xmlSecPtr		(*xmlSecPtrDuplicateItemMethod)	(xmlSecPtr ptr);
       
   129 
       
   130 /**
       
   131  * xmlSecPtrDestroyItemMethod:
       
   132  * @ptr:		the poinetr to list item.
       
   133  *
       
   134  * Destroys list item @ptr.
       
   135  */
       
   136 typedef void			(*xmlSecPtrDestroyItemMethod)	(xmlSecPtr ptr);
       
   137 
       
   138 /**
       
   139  * xmlSecPtrDebugDumpItemMethod:
       
   140  * @ptr:		the poinetr to list item.
       
   141  * @output:		the output FILE.
       
   142  *
       
   143  * Prints debug information about @item to @output.
       
   144  */
       
   145 typedef void			(*xmlSecPtrDebugDumpItemMethod)	(xmlSecPtr ptr,
       
   146 								 FILE* output);
       
   147 
       
   148 /**
       
   149  * xmlSecPtrListKlass: 
       
   150  * @name:		the list klass name.
       
   151  * @duplicateItem:	the duplciate item method.
       
   152  * @destroyItem:	the destroy item method.
       
   153  * @debugDumpItem:	the debug dump item method.
       
   154  * @debugXmlDumpItem:	the debug dump item in xml format method.
       
   155  *
       
   156  * List klass.
       
   157  */
       
   158 struct _xmlSecPtrListKlass {
       
   159     const xmlChar*			name;
       
   160     xmlSecPtrDuplicateItemMethod	duplicateItem;
       
   161     xmlSecPtrDestroyItemMethod		destroyItem;
       
   162     xmlSecPtrDebugDumpItemMethod	debugDumpItem;
       
   163     xmlSecPtrDebugDumpItemMethod	debugXmlDumpItem;
       
   164 };
       
   165 
       
   166 /**
       
   167  * xmlSecPtrListKlassGetName: 
       
   168  * @klass:		the list klass.
       
   169  *2
       
   170  
       
   171  * Macro. Returns the list klass name.
       
   172  */
       
   173 #define xmlSecPtrListKlassGetName(klass) \
       
   174 	(((klass) != NULL) ? ((klass)->name) : NULL)
       
   175 
       
   176 /**************************************************************************
       
   177  *
       
   178  * xmlSecStringListKlass
       
   179  *
       
   180  *************************************************************************/
       
   181 /**
       
   182  * xmlSecStringListId:
       
   183  *
       
   184  * Strings list klass.
       
   185  */
       
   186 #define xmlSecStringListId \
       
   187 	xmlSecStringListGetKlass()
       
   188 XMLSEC_EXPORT xmlSecPtrListId	xmlSecStringListGetKlass	(void);
       
   189 
       
   190 #ifdef __cplusplus
       
   191 }
       
   192 #endif /* __cplusplus */
       
   193 
       
   194 #endif /* __XMLSEC_LIST_H__ */
       
   195