global-state.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef GLOBAL_STATE_H_GUARD_
  2. #define GLOBAL_STATE_H_GUARD_
  3. #include "stringutils.h"
  4. #include "vec.h"
  5. #include <stdbool.h>
  6. #include <stdint.h>
  7. #include <inttypes.h>
  8. #define HASH64BIT uint_fast64_t
  9. enum StagesProcessing
  10. {
  11. STAGE_PROC_NONE,
  12. STAGE_PROC_SCANNING,
  13. STAGE_PROC_VALIDATING,
  14. STAGE_PROC_HASHD64,
  15. STAGE_PROC_COMPARED64,
  16. STAGE_PROC_DECOUPLING,
  17. STAGE_PROC_HASHD256,
  18. STAGE_PROC_COMPARED256,
  19. STAGE_PROC_FINISHED
  20. };
  21. enum StagesMeta
  22. {
  23. STAGE_NONE,
  24. STAGE_READY,
  25. STAGE_PROCESSING,
  26. STAGE_SORTING
  27. };
  28. typedef struct UIState
  29. {
  30. /* Stages */
  31. int stage;
  32. int processingStage;
  33. /* Window controls */
  34. bool helpScreen;
  35. bool buttonDelLeft;
  36. bool buttonDelRight;
  37. bool buttonKeepLeft;
  38. bool buttonKeepRight;
  39. bool buttonLaunch;
  40. bool buttonReset;
  41. bool buttonDelBoth;
  42. bool buttonKeepBoth;
  43. bool buttonStopSorting;
  44. bool buttonNext;
  45. /* Options */
  46. bool recursive;
  47. bool extraPassD256;
  48. float threshSlider;
  49. bool biggerIsBetter;
  50. int screenWidth;
  51. int screenHeight;
  52. char * windowName;
  53. string * statusline;
  54. string * threshString;
  55. string * directoryPaths;
  56. string * dirPathCount;
  57. float progress;
  58. string * imgLeftPath;
  59. string * imgRightPath;
  60. string * imgLeftResolution;
  61. string * imgRightResolution;
  62. string * groupCount;
  63. string * groupSize;
  64. string * totalDupes;
  65. string * fullPaths;
  66. } UIState;
  67. typedef struct ProcessingOptions
  68. {
  69. bool recursive;
  70. bool extraPassD256;
  71. float threshold;
  72. } ProcessingOptions;
  73. typedef struct Imagefile
  74. {
  75. string * path;
  76. HASH64BIT * hash;
  77. bool hashed;
  78. bool disposed;
  79. struct ImageGroup * group;
  80. } Imagefile;
  81. typedef vec_t(Imagefile *) imagefile_vec_t;
  82. typedef struct ImageGroup
  83. {
  84. size_t hashlen;
  85. HASH64BIT * hash;
  86. imagefile_vec_t images;
  87. } ImageGroup;
  88. typedef vec_t(ImageGroup *) imagegroup_vec_t;
  89. typedef vec_t(string *) string_vec_t;
  90. typedef struct FilesState
  91. {
  92. unsigned long hashedfiles;
  93. unsigned long failedfiles;
  94. unsigned long dupenum;
  95. int compareiter;
  96. string_vec_t dirs;
  97. imagegroup_vec_t groups;
  98. imagefile_vec_t images;
  99. } FilesState;
  100. void PUGS_Init ( void );
  101. #endif