Skip to content
Snippets Groups Projects
  1. Jan 04, 2023
    • 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
  2. Nov 24, 2022
  3. Nov 23, 2022
    • Jonathan Schöbel's avatar
      Validator: added copy method · 0aca3965
      Jonathan Schöbel authored
      Copying a Validator could be useful if multiple html versions are to be
      supported. Another use case is a blacklist XSS-Scanner.
      0aca3965
    • Jonathan Schöbel's avatar
      Validator: deregister tag · 95ba8a94
      Jonathan Schöbel authored
      A registered tag can be deregistered by calling SH_Validator_deregister.
      The data is removed, but the space is not deallocated, if it is not at
      the end. This prevents copying data on removal and saves expensive calls
      to realloc. Instead the empty space is added to the list of free blocks,
      which allows to refill these spaces, if a new tag is being registered.
      The space is finally deallocated, if the validator is being deallocated
      or the tag written in the last block is removed. In this case, heavy
      iteration is performed, as the list of free blocks is not ordered. The
      next last tag at that time is determined by iterating over the list of
      free blocks until some it is not found.
      Note that even if there can be a lot of gaps in between, the Validator
      will not allocate more space until all these gaps are refilled when a
      new tag is registered, thus new space is only being allocated, if there
      is really not enough space left.
      Due to the 4 nested loops, there was an issue related to the
      72(80)-column rule. It can't be abided without severely impacting the
      readability of the code.
      95ba8a94
  4. Nov 17, 2022
  5. Nov 16, 2022
    • Jonathan Schöbel's avatar
      Validator: restructured internal data · a0c9bb25
      Jonathan Schöbel authored
      The Validator saves the tags as an array. Now also another information
      is added, which slots aren't used currently to spare expensive calls to
      realloc. This led to a mere reimplementation of the functions. Tags
      can't be deleted by now, but the adding function supports reusing empty
      slots. Also the reading functions have to determine, whether a slot can
      be read or is empty.
      The tests were adjusted, but are buggy, so they should be rewritten in
      the future.
      
      Additionaly some annotations for splint were added.
      a0c9bb25
  6. 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
  7. Oct 17, 2022
    • Jonathan Schöbel's avatar
      setup library (make & API) · f86bd5cf
      Jonathan Schöbel authored
      The make process was restructured to create a library. For this libtool
      is used to provide both static and dynamic linking. Also header
      inclusion guards were introduced, to prevent clients of the library to
      include some single file without including others. The types were
      exported with forward declarations for better abstraction. When
      compiling the library, the macro LIB_SEFHT_COMPILATION is defined and
      symbol declarations are exported fully. For compiling the tests this
      macro is also defined, as the tests not only tests the API, but also the
      internal state, because a lot of errors couldn't be detected otherwise.
      f86bd5cf
    • Jonathan Schöbel's avatar
      65bfbab2
    • Jonathan Schöbel's avatar
      Merge branch 'feature/text' · 548398ff
      Jonathan Schöbel authored
      548398ff
  8. Oct 16, 2022
    • Jonathan Schöbel's avatar
      Text: trivial print · ee0a2189
      Jonathan Schöbel authored
      The method SH_Text_print just prints the whole string to stdout.
      ee0a2189
    • Jonathan Schöbel's avatar
      Text: get length · eca6e0ab
      Jonathan Schöbel authored
      The function SH_Text_get_length returns the length of the text. As the
      text also supports being longer than SIZE_MAX, this method can fail on
      runtime. If the text is longer then SIZE_MAX, the Text returns SIZE_MAX
      and sets error to DOMAIN_ERROR. Note, that due to the implementation,
      this is a non trivial function, so don't use it to exhaustively.
      eca6e0ab
  9. Oct 15, 2022
    • Jonathan Schöbel's avatar
      Text: fetch range · bacd41a4
      Jonathan Schöbel authored
      The function SH_Text_get_range returns a string begining at start and
      ending at end. Note that end specifies the char, that is not returned
      anymore. Thus the function implements something similar, as the pythonic
      slice syntax (text[start:end]). In opposition to the behaviour there,
      calling SH_Text_get_range with start > end is undefined behaviour. If
      start == end, the empty string is returned.
      If start is out of bounds, NULL is returned and an error is set. If end
      is out of bounds, the existent part is returned. Also the length of the
      returned string can be set (optionally) to the out parameter length.
      bacd41a4
    • Jonathan Schöbel's avatar
      Text: fetch a substring · 9c9590e1
      Jonathan Schöbel authored
      The function SH_Text_get_string returns a substring of text beginning at
      index and of length offset. If index is out of bounds, NULL is returned
      and an error is set. If offset is out of bounds, the existent part is
      returned. Also the length of the returned string can be set (optionally)
      to the out parameter length.
      If the original behaviour of SH_Text_get_string is achieved,
      SH_Text_get_string (text, length, error) has to be changed to
      SH_Text_get_string (text, 0, SIZE_MAX, length, error). The only
      difference will be that the function won't fail, when the text is longer
      than SIZE_MAX, because it is told to stop there. A text that is longer
      than SIZE_MAX is not possible to be returned, but that wasn't possible
      at anytime. Also I don't think handling char[] longer than SIZE_MAX is
      possible with the standard C library. Those in this case the text can
      only be returned in parts (By now only possible till 2*SIZE_MAX-1 with
      calling SH_Text_get_string (text, SIZE_MAX, SIZE_MAX, length, error))
      or has to be manipulated using the appropiate SH_Text methods, which are
      not implemented yet.
      9c9590e1
    • Jonathan Schöbel's avatar
      Text: fetch a single char · 0cf7d0b6
      Jonathan Schöbel authored
      The method SH_Text_get_char returns a single character by a given index.
      If the index is out of range, NULL is returned and error->type is set to
      VALUE_ERROR.
      0cf7d0b6
    • Jonathan Schöbel's avatar
      reimplemented SH_Text as single linked list of strings · 0a62ebe6
      Jonathan Schöbel authored
      The (intern) implementation of SH_Text was changed from an array of
      char, to a single linked list of arrays of char. This allows an easier
      implementation of (further) text manipulation.
      The API hasn't changed much, but SH_Text_join can't yield an error
      anymore, so it now doesn't support passing an error and returns nothing.
      
      The source has been adapted to splint, which still tells about some
      errors, but they are all checked to be false-positives.
      0a62ebe6
    • Jonathan Schöbel's avatar
      return char * · 51de2c6f
      Jonathan Schöbel authored
      A method was added, that returns the generated text.
      51de2c6f
    • Jonathan Schöbel's avatar
      Text: added constructor with initialization · aeca7dd7
      Jonathan Schöbel authored
      The constructor SH_Text_new_from_string accepts a string, with that the
      text is initialized. This can replace the so far needed two calls
      SH_Text_new and SH_Text_append_string.
      
      When writing the test, it was neccessary to simulate an overflow.
      Thereby a bug was detected regarding another overflow test. The bug was,
      that when SIZE_MAX % CHUNK_SIZE == 0 (which is normally true, if 2^n is
      taken as the value for CHUNK_SIZE) there can't be an overflow, so the
      test for an overflow fails. Actually there wasn't a neccesity to check
      for an overflow, as this could easily be bypassed by just allocating the
      requested size instead of the next chunk size, if this would be greater
      then SIZE_MAX.
      aeca7dd7
  10. Sep 21, 2022
  11. Sep 20, 2022
  12. Sep 18, 2022
  13. Sep 11, 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
    • Jonathan Schöbel's avatar
      append/join Text · 0378698a
      Jonathan Schöbel authored
      SH_Text_append_string can be used to append a string to the text,
      SH_Text_append_text can be used to append another text to the text.
      SH_Text_join is a wrapper for SH_Text_append_text, but also frees the
      second text, thus joining the texts to a single one.
      0378698a
    • Jonathan Schöbel's avatar
      to_html for Fragment · 08dc6d5f
      Jonathan Schöbel authored
      A Fragment can output it's html. If there is an error the method aborts
      and returns NULL.
      08dc6d5f
    • Jonathan Schöbel's avatar
      improve Validator test (memory leaks) · 12400d8f
      Jonathan Schöbel authored
      Changing sefht_validator_test so that no memory leaks occur.
      12400d8f
  18. Jun 23, 2022
    • Jonathan Schöbel's avatar
      enlarge Text · 537069d3
      Jonathan Schöbel authored
      The space a Text has for saving the string is allocated in chunks. To
      request additional space SH_Text_enlarge is called. If the requestad
      size fits inside the already allocated space or is even smaller than the
      current size, nothing is done. Otherwise a multiple of chunk size is
      allocated beeing equal or greater than the requested size. The chunk
      size can be changed by changing the macro CHUNK_SIZE in src/text.h. The
      default is 64.
      This adjustment is done automatically when a string is added.
      537069d3
    • Jonathan Schöbel's avatar
      mapped Log::error to printf · 252f968f
      Jonathan Schöbel authored
      It is useful for debugging to actually see the error messages.
      252f968f
  19. Jun 22, 2022
  20. Jun 21, 2022
    • Jonathan Schöbel's avatar
      added Text · a71ce13c
      Jonathan Schöbel authored
      This is a data type to deal with frequently appending to a string.
      a71ce13c
    • Jonathan Schöbel's avatar
      look for duplicate tags in Validator · 47407f2d
      Jonathan Schöbel authored
      When a tag is made known to the Validator, which it already knows, the
      old id is returned and nothing is added.
      As this has to be checked by iterating over all known tags, a new helper
      function is written for both SH_Validator_check_tag and
      SH_Validator_register_tag: SH_Validator_get_tag.
      
      Because we want also to test this function, we have to include
      validator.c in the test file and override the static keyword by an empty
      macro. It isn't possible any more to check for correct overflowdetection
      by setting the index to UINT_MAX, because it will be iterated over all
      data, thus raising an SIGSEGV when doing so. This is solved by filling
      garbage unil UINT_MAX is really reached. As there would be an timeout
      and it would fill RAM with around 40 GB of garbage, UINT_MAX is
      overriden prior to inclusion of validator.c .
      47407f2d
  21. Aug 31, 2022
  22. Jun 21, 2022
Loading