checksum_plugin.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //checksum_plugin.h
  2. // checksum plugin type
  3. /*
  4. The MIT License (MIT)
  5. Copyright (c) 2018-2019 HouSisong
  6. Permission is hereby granted, free of charge, to any person
  7. obtaining a copy of this software and associated documentation
  8. files (the "Software"), to deal in the Software without
  9. restriction, including without limitation the rights to use,
  10. copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the
  12. Software is furnished to do so, subject to the following
  13. conditions:
  14. The above copyright notice and this permission notice shall be
  15. included in all copies of the Software.
  16. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  18. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  20. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  21. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23. OTHER DEALINGS IN THE SOFTWARE.
  24. */
  25. #ifndef HPatch_checksum_plugin_h
  26. #define HPatch_checksum_plugin_h
  27. #include "patch_types.h"
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. typedef void* hpatch_checksumHandle;
  32. typedef struct hpatch_TChecksum{
  33. //return type tag; strlen(result)<=hpatch_kMaxPluginTypeLength; (Note:result lifetime)
  34. const char* (*checksumType)(void); //ascii cstring,cannot contain '&'
  35. hpatch_size_t (*checksumByteSize)(void); //result<=hpatch_kStreamCacheSize
  36. hpatch_checksumHandle (*open)(struct hpatch_TChecksum* plugin);
  37. void (*close)(struct hpatch_TChecksum* plugin,hpatch_checksumHandle handle);
  38. void (*begin)(hpatch_checksumHandle handle);
  39. void (*append)(hpatch_checksumHandle handle,
  40. const unsigned char* part_data,const unsigned char* part_data_end);
  41. void (*end)(hpatch_checksumHandle handle,
  42. unsigned char* checksum,unsigned char* checksum_end);
  43. } hpatch_TChecksum;
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif