Skip to content
Snippets Groups Projects
  1. Jun 04, 2023
    • Jonathan Schöbel's avatar
      NodeFragment: added remove_attr methods · 76e06eec
      Jonathan Schöbel authored
      Two alternatives are provided: remove_attr and pop_attr. While the
      former free's the Attr's data, the latter allocates a new Attr, to store
      and return the data. Both functionality is provided by a single
      (internal) static method.
      76e06eec
  2. Jun 03, 2023
  3. Jun 02, 2023
  4. Mar 20, 2023
  5. Mar 17, 2023
  6. Mar 16, 2023
    • Jonathan Schöbel's avatar
      NodeFragment: added remove methods · 8d84e3c7
      Jonathan Schöbel authored
      Various remove methods were added, which are all implemented by an
      static method, analog to the last commit.
      8d84e3c7
    • Jonathan Schöbel's avatar
      NodeFragment: improved insert methods · 1e575a13
      Jonathan Schöbel authored
      The single method (formerly SH_NodeFragment_append_child) to add a child
      at the end of the child list was replaced, by a bunch of methods to
      insert a child at the beginning (SH_NodeFragment_prepend_child), at the
      end (SH_NodeFragment_append_child), at a specific position
      (SH_NodeFragment_insert_child) and directly before
      (SH_NodeFragment_insert_child_before) or after another child
      (SH_NodeFragment_insert_child_after). All these methods are implemented
      by a single internal one (insert_child), as there isn't really much
      difference in inserting one or the other way.
      But this internal method doesn't check whether this insertion request is
      actually doable, to save overhead as not every insertion method requires
      this check. This is done by the respective method. However if the check
      is not done correctly the internal method will attempt to write at not
      allocated space, which will hopefully result in a segfault.
      
      The child list is implemented as an array. To reduce the overhead to
      realloc calls, the array is allocated in chunks of childs. The
      calculation how many has to be allocated is done by another static
      method and determined by the macro CHILD_CHUNK. This is set to 5, which
      is just a guess. It should be somewhere around the average number of
      childs per html element, to reduce unused overhead.
      
      Also some predicates (SH_NodeFragment_is_parent,
      SH_NodeFragment_is_ancestor) were added to check whether a relationship
      exists between to nodes, thus whether they are linked through one or
      multiple levels. These functions could replace the old ones
      (SH_NodeFragment_is_child, SH_NodeFragment_is_descendant) semantically.
      Furthermore they are more efficient as this is now possible to check
      over the parent pointer. The internal insert method also uses these
      methods to check whether the child node is actually a parent of the
      parent node, which would result in errors later one.
      
      The old test is now obsolete but remained, as it is not bad to test
      more.
      1e575a13
  7. Mar 13, 2023
    • Jonathan Schöbel's avatar
      fixup! implement NodeFragment as Fragment · 95051add
      Jonathan Schöbel authored
      Removed some unnecessary type casts.
      Added some forgotten calls to free.
      95051add
    • Jonathan Schöbel's avatar
      Fragment: added parent · 92ed2019
      Jonathan Schöbel authored
      Every fragment has a parent now, this is useful for both traversing the
      tree and checking for cycles when a node is added, which would cause
      problems, like freeing things twice or similar nice bugs. Both wouldn't
      be possible otherwise. These features are not implemented yet.
      92ed2019
    • Jonathan Schöbel's avatar
      NodeFragment: added unsafe getter for tag · 0bab1f50
      Jonathan Schöbel authored
      The library provides a way to directly access the tag in a read-only
      way, which saves an call to strdup. This is useful if only reading is
      necessary , but needs special care by developers, as it is neither
      allowed to modify it nor to free it. Disregarding this will lead to a
      segfault in the best, and to silent data corruption and security bugs in
      the worst case.
      0bab1f50
  8. Jan 06, 2023
  9. Jan 05, 2023
  10. Jan 04, 2023
    • Jonathan Schöbel's avatar
      fixed type definitions · fed99df0
      Jonathan Schöbel authored
      Internal struct definitions shouldn't be exported by header files.
      fed99df0
    • Jonathan Schöbel's avatar
      disintegrated validator · 1e61c23e
      Jonathan Schöbel authored
      The validator was used to check that every created tag is validate.
      However I now think that validation should take place at a later time,
      so it is not mandatory.
      Thus developing the validator is now discontinued.
      1e61c23e
  11. Nov 15, 2022
    • Jonathan Schöbel's avatar
      API change: error -> status for exception handling · 0e0fa194
      Jonathan Schöbel authored
      Instead of the trivial structure SH_Error, SH_Status is used. The name
      was chosen, because error/status is set independently whether an error
      has occurred. Beside the error type, it also contains the associated
      errno and an error message. The error message is also printed, when it
      is set. Generating error messages with variadic arguments is now also
      supported.
      There are also macros to check for a set status.
      
      The exception handling was removed for the *_free methods, because they
      can't fail predictably during runtime.
      
      Unfortunately the compiler reports, that inside the macro set_status
      printf may be called with NULL [printf (NULL)], although, this is
      explicitly debarred.
      0e0fa194
  12. Sep 20, 2022
  13. Sep 18, 2022
  14. Sep 08, 2022
    • Jonathan Schöbel's avatar
      added "wrap mode" for html generation · f027c56d
      Jonathan Schöbel authored
      When the wrap mode is used, after each tag a newline is started. Also the
      html is indented, which can be configured by the parameters indent_base,
      indent_base, indent_char. The parameter indent_base specifies the width
      the first tag should be indented with, while indent_step specifies the
      increment of the indent when switching to a child tag. The character,
      that is used for indenting is taken from indent_char. (It could also be
      a string longer than a single character).
      This aguments can't be set by the user, but are hardcoded (by now).
      f027c56d
    • Jonathan Schöbel's avatar
      added copy methods (Fragment) · ce4fcf29
      Jonathan Schöbel authored
      Fragment can be copied, either recursive (copying also all childs) or
      nonrecursive (ignoring the childs, thus the copy has always no childs).
      Adding the same element twice in the tree (graph) isn't possible, as
      this leads to problems e.g. double free or similars.
      ce4fcf29
  15. Sep 05, 2022
  16. Sep 04, 2022
    • Jonathan Schöbel's avatar
      child for Fragment · c57027bc
      Jonathan Schöbel authored
      A Fragment can contain childs. When building the html, the childs html
      is generated where appropiate.
      c57027bc
  17. Sep 01, 2022
  18. Jun 22, 2022
  19. Aug 31, 2022
  20. Jun 20, 2022
    • Jonathan Schöbel's avatar
      added test for Fragment · 6f933e85
      Jonathan Schöbel authored
      6f933e85
    • Jonathan Schöbel's avatar
      added test for CMS · 46436e8a
      Jonathan Schöbel authored
      Tests are done using check, allowing to integrate the tests into the
      Autotools.
      Methods that are part of another unit, but are called in this unit
      aren't tested as this would interfere with the idea of unittests. This
      also applies for purely wrapper functions, where a call is passed to
      another unit.
      46436e8a
  21. Jun 21, 2022
    • Jonathan Schöbel's avatar
      error handling added · 6a592b8d
      Jonathan Schöbel authored
      Error handling is done by passing an Error structure as inout parameter
      to functions that can fail on runtime predictable. This parameter is
      always the last one. Methods, where this is not the case, doesn't have an
      error parameter.
      When an Error is detected, also an ERROR is passed to the log. Because
      this isn't implemented yet, it is replaced by a nop.
      The macro EXIT becomes now useless. It was used earlier in case of an
      error, to terminate the program in the first place. This behaviour is not
      userfriendly, but it can't be decided on the library's side, whether
      there is an option to inform the user, something must be cleaned up or
      even that recovering is possible at all.
      Often these recognized errors are a non-working malloc or an over-/underflow.
      
      Error handling can be ignored by the caller by passing NULL to the Error
      parameter. Whether an error had occured, is also always possible to be
      determined, by examining the return value. If the error occours in a
      function returning a pointer, NULL will be returned. If it returns an value,
      a special error value of that type is returned, i.e. PAGE_ERR in
      SH_Data_register_page. If the return type would be void, a boolean is returned,
      which tells, whether the method has succeeded.
      (False means, that an error has occured.)
      
      The error may have occured in an intern method and is passed upwards (the stack).
      Internally errors are handled by an enum, but this must be considered an
      implementation detail and can be changed in later versions.
      It is in the responsibility of the caller to recover gracefully. It has
      to be assumed that the requested operation have neither worked, nor
      actually took place. Those the operation can be retried (hopefully).
      6a592b8d
  22. Jun 20, 2022
Loading