Commit Graph

44 Commits

Author SHA1 Message Date
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
Benjamin Dauvergne 152ec6d42e Many fix to compile with --enable-wsf and --enable-debugging and also to
remove valgrind errors through python tests.

1. Rename lasso_wsf_profile_new_full for java bindings (cannot subclass
   in overrides of static methods).
2. Add const modifiers to many functon signatures in
   bindings/python/wrapper_top.c.
3. add initialisation of private_data->encryption_sym_key_type (to
   please valgrind) in instance_init of LassoProvider.
4. Add new macro to assign xmlNode, we consider xmlNode to be an
   immutable value, and always use xmlCopyNode for assignment. The
   macros is called named lasso_assign_node.
5. Fix segfault, when using xmlSec to encrypt the newly created
   encrypted node replace the original node inside the xmlDoc structure,
   and the original node is freed automatically. So you cannot borrow
   the encrypted if you do not remove it from xmlDoc first.
2008-09-23 09:13:09 +00:00
Benjamin Dauvergne 9ed0670e48 * Remove ending blanks 2008-09-12 15:06:58 +00:00
Benjamin Dauvergne 5a3ae3cd28 new empty macro OFTYPE(x) to specify type of GList containers 2008-08-05 14:53:18 +00:00
Benjamin Dauvergne 6c65ad341b * add missing lasso_release_list, add lasso_release_list_of_full, reimplement lasso_release_list_of_* using _full 2008-08-05 14:52:48 +00:00
Benjamin Dauvergne 87146dc9ec add macros to release xmlSec context objects 2008-08-05 14:52:32 +00:00
Benjamin Dauvergne 838a3c4a2d add lasso_release_full to construct other lasso_release_ functions, use it in old definitions 2008-08-05 14:52:31 +00:00
Benjamin Dauvergne 2828676eeb rename g_unlink_and_release_node to lasso_unlink_and_release_node 2008-08-05 14:52:29 +00:00
Benjamin Dauvergne 36ca34b166 Add a macro to emit a «Function is deprecated» warning 2008-08-05 14:52:28 +00:00
Benjamin Dauvergne d012fcfd52 change last g_* macros to lasso_ prefix 2008-08-05 14:52:26 +00:00
Benjamin Dauvergne b9b65ed9fc * change g_list_add* to lasso_list_add* 2008-08-05 14:52:23 +00:00
Benjamin Dauvergne fd1294504f change g_assign_* to lasso_assgin_* and g_release_* to lasso_release_* 2008-08-05 14:52:20 +00:00
Benjamin Dauvergne 60579adcae add macro to assign gobject field, first a simple version 2008-08-01 14:12:03 +00:00
Benjamin Dauvergne 89485bc912 beginning of a pool of macros for mem handling, affectation to fields, etc.. 2008-08-01 14:12:01 +00:00
Benjamin Dauvergne 60ce087798 * lasso/utils.h: add utility macros to releases libxml objects, to check null
parameters or badly typed parameters. add a macro that go to an "exit" label
  and set the return code variable named "rc".
2008-08-01 14:10:34 +00:00
Benjamin Dauvergne 68b6e578e4 fix forgottent arg to g_list_foreach 2008-08-01 14:10:11 +00:00
Benjamin Dauvergne 6be4b416ce added functions to release [list]string/gobject/any 2008-08-01 14:09:15 +00:00
Benjamin Dauvergne 9314cecc4f add methods to manipulate list of gobjects, and dissociate affectation of fresh object from older objects 2008-08-01 14:09:13 +00:00
Benjamin Dauvergne 7556ea6c2e add macro to assign gobject field, first a simple version 2008-08-01 14:09:11 +00:00
Benjamin Dauvergne ada94eb956 beginning of a pool of macros for mem handling, affectation to fields, etc.. 2008-08-01 14:09:04 +00:00
Benjamin Dauvergne 934228a3c7 added functions to release [list]string/gobject/any 2008-08-01 14:07:13 +00:00
Benjamin Dauvergne 9d9fe50f2e add methods to manipulate list of gobjects, and dissociate affectation of fresh object from older objects 2008-08-01 14:07:11 +00:00
Benjamin Dauvergne c405836d22 add macro to assign gobject field, first a simple version 2008-08-01 14:06:51 +00:00
Benjamin Dauvergne 13cfa070a9 beginning of a pool of macros for mem handling, affectation to fields, etc.. 2008-08-01 14:06:41 +00:00
Benjamin Dauvergne e72184c8ef reformat utils.h 2008-05-30 12:41:11 +00:00
Damien Laniel 14f7d3fc2a fixed too long lines and remove some blank lines 2008-05-30 12:08:24 +00:00
Benjamin Dauvergne c56b308388 add a new headers <lasso/utils.h> with macros to handle memory like assigning a
gobject field (work flow, is you augment ref of the new value, decrease the one
from the old, and then assign), assigning strings, releasing lists of strings, of
gobjects,etc..
the free macros are all called g_release_somehting and they set the released
variable to NULL.
add a macro to validate GObject parameter types

This header is intended to concentre every bit of wisdom for handling pointers
and memory, try to use thoses macros in your code.
They are not intended to work with weak references (references you do not own),
so always g_object_ref in this case (or use g_assign_gobject that does it,
when your variable is not needed anymore to g_assign_gobject(var, NULL));
2008-05-22 14:54:13 +00:00