consdiff.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Copyright (c) 2014, Daniel Martí
  2. * Copyright (c) 2014, The Tor Project, Inc. */
  3. /* See LICENSE for licensing information */
  4. #ifndef TOR_CONSDIFF_H
  5. #define TOR_CONSDIFF_H
  6. #include "or.h"
  7. smartlist_t *consdiff_gen_diff(smartlist_t *cons1, smartlist_t *cons2,
  8. common_digests_t *digests1, common_digests_t *digests2);
  9. char *consdiff_apply_diff(smartlist_t *cons1, smartlist_t *diff,
  10. common_digests_t *digests1);
  11. int consdiff_get_digests(smartlist_t *diff,
  12. char *digest1, char *digest1_hex,
  13. char *digest2, char *digest2_hex);
  14. #ifdef CONSDIFF_PRIVATE
  15. /** Data structure to define a slice of a smarltist. */
  16. typedef struct smartlist_slice_t {
  17. /**
  18. * Smartlist that this slice is made from.
  19. * References the whole original smartlist that the slice was made out of.
  20. * */
  21. smartlist_t *list;
  22. /** Starting position of the slice in the smartlist. */
  23. int offset;
  24. /** Length of the slice, i.e. the number of elements it holds. */
  25. int len;
  26. } smartlist_slice_t;
  27. STATIC smartlist_t *gen_ed_diff(smartlist_t *cons1, smartlist_t *cons2);
  28. STATIC smartlist_t *apply_ed_diff(smartlist_t *cons1, smartlist_t *diff);
  29. STATIC void calc_changes(smartlist_slice_t *slice1, smartlist_slice_t *slice2,
  30. bitarray_t *changed1, bitarray_t *changed2);
  31. STATIC smartlist_slice_t *smartlist_slice(smartlist_t *list,
  32. int start, int end);
  33. STATIC int next_router(smartlist_t *cons, int cur);
  34. STATIC int *lcs_lengths(smartlist_slice_t *slice1, smartlist_slice_t *slice2,
  35. int direction);
  36. STATIC void trim_slices(smartlist_slice_t *slice1, smartlist_slice_t *slice2);
  37. STATIC int base64cmp(const char *hash1, const char *hash2);
  38. STATIC const char *get_id_hash(const char *r_line);
  39. STATIC int is_valid_router_entry(const char *line);
  40. STATIC int smartlist_slice_string_pos(smartlist_slice_t *slice,
  41. const char *string);
  42. STATIC void set_changed(bitarray_t *changed1, bitarray_t *changed2,
  43. smartlist_slice_t *slice1, smartlist_slice_t *slice2);
  44. #endif
  45. #endif