Commit Graph

76 Commits

Author SHA1 Message Date
Benjamin Dauvergne 462c9a1cd0 [Core] replace all use of g_strcmp0 by lasso_strisequal and lasso_strisnotequal
Too much human errors with strcmp kind of functions. Also change name os
lasso_is_empty_string to lasso_strisempty.
2010-10-01 15:29:38 +02:00
Benjamin Dauvergne b5fcbc6455 [Core] add helper API for string comparaison
It should remove most errors when comparing strings.
2010-10-01 15:13:49 +02:00
Benjamin Dauvergne 2e9e814b09 [Core] add macro to release an xmlNodeList object 2010-06-29 14:15:02 +00:00
Benjamin Dauvergne 4a36e6d065 [Core] add macro to release GList of xmlNodeList 2010-06-29 14:14:59 +00:00
Benjamin Dauvergne 0524051343 [Core] add macros to manipulate xmlNodeList and GList of xmlNodeList
The method to copy them is xmlCopyNodeList and not xmlCopyNode, so we
need another set of macros.
2010-06-29 14:14:58 +00:00
Benjamin Dauvergne a9b673cd4a Core: move logging function and macros to their own module, adapt perl binding 2010-06-12 00:43:49 +00:00
Benjamin Dauvergne d0a2135f60 Import tools in utils.h 2010-06-10 13:37:56 +00:00
Benjamin Dauvergne 2c0ea4d647 Change all logging to use message() 2010-06-09 16:54:55 +00:00
Benjamin Dauvergne 80a930cc37 Utils: add function to extract/create node in lists
* lasso_extract_gtype_from_list_or_new will help for method with create
   or extend nodes in lists.
2010-06-09 16:54:49 +00:00
Benjamin Dauvergne 0e8441afe3 Improve safety by replacing all g_hash_table_destroy use by lasso_release_ghashtable 2010-04-22 00:45:02 +00:00
Benjamin Dauvergne 34c7642226 Utils: add lasso_assign_list 2010-04-22 00:44:22 +00:00
Benjamin Dauvergne f08387c983 Add lasso_release_gstring 2010-04-22 00:44:19 +00:00
Benjamin Dauvergne 7682ce4eac Utils: add lasso_release_ghashtable 2010-04-22 00:44:15 +00:00
Benjamin Dauvergne 99454639cd Core: add macro to remove gobject from lists 2010-03-02 11:58:00 +00:00
Benjamin Dauvergne dce077bd99 Core: add do/while(0) around block of goto_cleanup_with_rc 2010-03-02 11:57:34 +00:00
Benjamin Dauvergne 3c8855eb66 Fix lasso_extract_gobject_from_list 2010-02-22 13:30:23 +00:00
Benjamin Dauvergne 6aee196410 Core: in utils.h, use a temporary to store reference to freed list 2010-02-17 10:14:31 +00:00
Benjamin Dauvergne 3433a07361 Core: add more memory tracing, add a tracing macro
* lasso/utils.h: add lasso_trace, which as a printf signature.
 * xml/xml.c: add more trace to node initialization code.
2010-02-04 00:02:16 +00:00
Benjamin Dauvergne 2a7b411ea1 Core: in utils.h, add macros to replace verbose g_return_val_if_fail 2010-02-01 19:50:04 +00:00
Benjamin Dauvergne 935c724cea Utils: lasso_unref, a safe g_object_unref, and add some document about existing family of macros 2010-02-01 19:50:00 +00:00
Benjamin Dauvergne b3b2e6f22d Core: add new macros to lasso/utils.h, fix lasso_assign_new_list_of_gobjects
* lasso/utils.h:
   add:
    - lasso_assign_new_xml_node
    - lasso_assign_new_list_of_strings
    - lasso_assign_new_list_of_xml_node
   fix lasso_assign_new_list_of_gobjects, bad naming of release macro.
2010-01-28 15:31:41 +00:00
Benjamin Dauvergne bec8672cc5 Add new macro lasso_list_add_new_xml_node
* lasso/utils.h:
   fix lasso_list_add_xml_node, it must copy the node before assigning
   it.
   add lasso_list_add_new_xml_node for keeping the old behaviour.
 * lasso/xml/xml.c:
   fix use of lasso_list_add_xml_node, because copying the node before
   assigning it is a leak now.
2010-01-25 23:47:43 +00:00
Benjamin Dauvergne 0279087029 Documentation: distribute stylesheet, fix documentation comments, compelte lasso-sections.txt 2010-01-18 10:03:54 +00:00
Benjamin Dauvergne bb2f640231 Core: in utils.h, add a macros, fix existing
* lasso/utils.h:
   - add macro lasso_ref(object), if object is not null, call
     g_object_ref on it, and return the value, otherwise do nothing and
     return NULL.
   - make a better reporting of bad object release
   - change format type for __LINE__ and dest arguments in
     lasso_release_gobject warning display.
   - add a lasso_check_non_empty_string macro
   - add new macro to extract a specific node type from a list of
     GObject objects.
   - use xmlStrdup not g_strdup for lasso_assign_xml_string
   - add lasso_list_add_gstrv and lasso_check_good_rc
   - add macro lasso_list_get_first_child
   - add inline function to test empty string
   - change macro lasso_check_non_empty_string to use the new inline
     function and go to cleanup
   - fix lasso_check_non_empty_string macro
 * lasso/utils.c:
   - add lasso_gobject_is_of_type returns 0 if first parameters is a
     gobject whose GType is equal to the second parameter, and 1
     otherwise.
2010-01-04 09:13:46 +00:00
Benjamin Dauvergne 07ccaf02ec Core: in utils.h, change __STRING(x) for #x
* lasso/utils.h:
   __STRING(x) does not seem more portable than #x so change, problem
   with AIX.
2009-12-16 09:28:04 +00:00
Benjamin Dauvergne 4074c22a13 Core: add new macros to traverse lists
* lasso/utils.h:
   lasso_foreach_full_begin(_type, _data, _iter, _list)
   traverse GList* _list, using _iter as iteration variable
   extract data field to variable _data of type _type.
2009-09-11 15:51:51 +00:00
Benjamin Dauvergne fbfbe5553d ID-FF&Core: Seal public field of LassoSession
* id-ff/session.h: seal public fields.

 * id-ff/session.c, id-ff/sessionprivate.h: add accessors for reading
   the is_dirty flag and counting store assertions.

 * id-ff/logout.c, id-ff/login.c, saml-2.0/login.c, saml-2.0/logout.c,
   saml-2.0/profile.c: use the new accessors.

 * id-ff/profile.c: include the private header file, use the new
   accessors, and remove unnecessary setting of is_dirty to FALSE (it
   should be false at instanciation).

 * utils.h: add a macro to access private content, prepare for using
   G_TYPE_INSTANCE_GET_PRIVATE and the GObject infrastructure for
   private structures eventually.
2009-08-26 15:13:55 +00:00
Benjamin Dauvergne c150172504 Core: fix bad name of lasso_unlink_and_release_node
* lasso/utils.h:
   - rename lasso_unlink_and_release_node to
     lasso_release_list_of_xml_node.
   - add a GList iteration macro: lasso_foreach.
2009-08-26 15:13:49 +00:00
Benjamin Dauvergne 8b23081b3a Fix debug echo on stdout
* lasso/utils.h:
   make lasso_mem_debug output on stderr and not stdout
2009-04-30 14:58:01 +00:00
Benjamin Dauvergne 86b97760e6 fix: handle non-LHS argument for lasso_extract_node_or_fail()
* lasso/utils.h:
   create a temporary varaible to store result of second argument
   evaluation to prevent spurious side effects.
2009-04-27 08:19:25 +00:00
Benjamin Dauvergne 52e60ecb09 Rework cleanup handling
* lasso/utils.h:
   change 'goto exit' for 'goto cleanup'. rename all goto_exit macros to
   goto_cleanup_.  rename goto_cleanup_if_fail to
   goto_cleanup_if_fail_with_rc and add a
   goto_cleanup_if_fail for function which do not return an integer
   value. add documentation for goto_cleanup macro family.
 * lasso/id-ff/login.c:
 * lasso/id-ff/provider.c:
 * lasso/id-ff/server.c:
 * lasso/id-ff/session.c:
 * lasso/id-wsf/discovery.c:
 * lasso/id-wsf/wsf_profile.c:
 * lasso/saml-2.0/profile.c:
 * lasso/utils.h:
 * lasso/xml/lib_logout_request.c:
 * lasso/xml/tools.c:
 * lasso/xml/xml.c:
   update name of goto_exit_if_fail macros. rename 'exit' labels to
   'cleanup'.
2009-04-22 23:49:29 +00:00
Benjamin Dauvergne 3cd463c4a2 Core: add an header file for backward compatibility
* lasso/backward_comp.h:
   this header will contain substitue function, defines or types for
   compatibility with older versions of dependencies.
 * lasso/utils.h:
   remove declaration of g_strcmp0
 * lasso.c:
 * tests/login_tests.c:
   use backward_comp.h
2009-04-14 07:51:22 +00:00
Benjamin Dauvergne ff18983520 Tests&Core: add g_strcmp0 if glib is old
* lasso/utils.h:
   if glib is older than 2.16, export g_strcmp0 as part of internal
   headers, in order to use it in login_tests.c
 * tests/login_tests.c:
   include utils.h
2009-04-02 17:16:05 +00:00
Benjamin Dauvergne 61b64a38c5 Core: Macros to print deallocation messages
* lasso/utils.h:
   lasso_mem_debug print deallocation message with respect to class and
   field.
2009-03-27 15:06:34 +00:00
Benjamin Dauvergne c34e67d523 Core: remove type check equality on gobject macros
* lasso/utils.h:
   assignment to the temporary variable allow to check for the typing,
   do not use lasso_check_type_equality.
2009-03-27 15:06:33 +00:00
Benjamin Dauvergne 38053d6790 Core: add macros to handle xmlSecKey
* lasso/utils.h:
   macros to assign and release xmlSecKey(s).
2009-03-27 15:06:32 +00:00
Benjamin Dauvergne d0d71abe2c Core: rename lasso_release_xmlchar to lasso_release_xml_string
* lasso/id-wsf/wsf_profile.c, lasso/utils.h, lasso/xml/xml.c: rename
   lasso_release_xmlchar to lasso_release_xml_string.
2009-03-27 15:05:37 +00:00
Benjamin Dauvergne 56160b783d Core: Fix double instantiation of macro parameters
* lasso/utils.h:
 - (lasso_assign_new_string,lasso_assign_gobject) if source parameter
   is a function call it could be called two times and have unexpected
   side effects. Copy the returned value to a temp variable and use it
   instead.
2009-03-27 15:05:35 +00:00
Benjamin Dauvergne 7696062fbd Core: Fix corner case in deallocation macros
* lasso/utils.h: When setting strings using lasso_assing_string or
   lasso_assign_new_string, verify that new string is different than the
   target value string before deallocating the target.
2009-03-27 15:05:34 +00:00
Benjamin Dauvergne a57841ce69 Core: add new internal macro lasso_extract_node_or_fail
* lasso/utils.h:
   this new macro try to extract a field from a structre (or any
   left-hand-side value), try to typecheck it using 'LASSO_IS_XXX',
   if succesfull, the value is assigned to the variable given as first
   argument or we jump to the 'cleanup' goto label, setting the 4th
   argument as the current error code (value of variable 'rc').
2009-03-27 15:05:06 +00:00
Benjamin Dauvergne 420572a397 Core: if OFTYPE is already defined, skip 2009-01-24 09:34:30 +00:00
Benjamin Dauvergne 7fc388abb3 Core: add macros to assign list of things, rename xmlNode related macros
* lasso/utils.h: added new macros, renamed others:
  - macros handling xmlNode are renamed from _node to _xml_node,
  - new macros for assign GList* of specific objects:
    - lasso_assign_list_of_gobjects,
    - lasso_assign_list_of_strings,
    - lasso_assign_new_list_of_gobjects,
  - macros for assigning xmlChar string (we need a specific macros
    because, we must use xmlFree to release the destination string),
  - macros to add string without duping: lasso_list_add_xml_string,
  - macros to add anything non-null (no type cast):
    lasso_list_add_non_null.
2009-01-24 09:33:21 +00:00
Benjamin Dauvergne cfc64aac4c Core: add references handling macros
* lasso/utils.h:
  - add macro lasso_transfer_string and lasso_transfer_gobject,
    to transfer ownership of such objects without copying or
    their changing reference count. The old containing variable is
    NULLed.
  - lasso_list_add_gobject,lasso_list_add_new_gobject: test if the added
    object is a GObject, if not do not add it and print a warning.
  - lasso_check_type_equality: this macro use special builtin functions
    only with GCC (typeof and __builtin_types_compatible_p) and do
    metaprogramming using anonymous enumeration type to make compile
    time assertions. It is used
 -  add macros to release XPathObject XPathContext, macro constructor to
    make reference transfert macros (free dest, nullify dest, copy src
    to dest without increasing refcount, nullify src), add a macro to
    transfert xpath objects.
2009-01-24 09:33:20 +00:00
Benjamin Dauvergne 03c6d3ba25 Core: new goto_exit macro which produces warnings
* lasso/utils.h:
  similar macro to goto_exit_if_fail but also produce a printed warning.
2009-01-24 09:33:18 +00:00
Benjamin Dauvergne 4b4bdbf1af Core: new macros for adding string to GList
* lasso/utils.h:
  - lasso_list_add_string, add a copy of a string to a GList
2009-01-24 09:33:17 +00:00
Benjamin Dauvergne 66633a4d95 Core: Remove unused macro lasso_warn_deprecated
* lasso/utils.h: remove macros lasso_warn_deprecated, use GCC
  attributes and gtkdoc markers instead.
2009-01-24 09:33:04 +00:00
Benjamin Dauvergne b4391766a5 Fix missing include 2008-11-05 14:38:00 +00:00
Benjamin Dauvergne f60b39eb9a Add new internal function to show safe extracts
- lasso/utils.c, lasso/utils.h:
   New internal api lasso_safe_prefix_string that can show any string
   taking care of escaping newlines,tabs and non-graphical ou non-ASCII
   characters.
2008-11-05 11:23:27 +00:00
Benjamin Dauvergne a62a31e5bc Add new utils macros
- lasso/utils.h:
   - add goto_exit_with_rc a standardized macro that suppose having an
     'int rc' variable and an exit label in the current function.
   - add lasso_release_output_buffer macro
2008-11-04 01:58:42 +00:00
Benjamin Dauvergne 4e28ae1025 Fix lasso_assign_node: wrong xmlFreeNodeList
* lasso/utils.h:
   - (lasso_assign_node) This macro wrongly assumes that the destroy
     function for xmlNode is xmlFreeNodeList but it's xmlFreeNode.
     xmlFreeNodeList is for xmlNode list of children.
2008-11-04 01:58:40 +00:00