calypso_util.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include <stdbool.h>
  2. #ifndef CALYPSO_UTIL_H
  3. #define CALYPSO_UTIL_H
  4. typedef enum {
  5. CALYPSO_APP_CONTRACT,
  6. } CalypsoAppType;
  7. typedef enum {
  8. CALYPSO_FINAL_TYPE_UNKNOWN,
  9. CALYPSO_FINAL_TYPE_NUMBER,
  10. CALYPSO_FINAL_TYPE_DATE,
  11. CALYPSO_FINAL_TYPE_TIME,
  12. CALYPSO_FINAL_TYPE_PAY_METHOD,
  13. CALYPSO_FINAL_TYPE_AMOUNT,
  14. CALYPSO_FINAL_TYPE_SERVICE_PROVIDER,
  15. CALYPSO_FINAL_TYPE_ZONES,
  16. CALYPSO_FINAL_TYPE_TARIFF,
  17. CALYPSO_FINAL_TYPE_NETWORK_ID,
  18. CALYPSO_FINAL_TYPE_TRANSPORT_TYPE,
  19. CALYPSO_FINAL_TYPE_CARD_STATUS,
  20. } CalypsoFinalType;
  21. typedef enum {
  22. CALYPSO_ELEMENT_TYPE_BITMAP,
  23. CALYPSO_ELEMENT_TYPE_FINAL
  24. } CalypsoElementType;
  25. typedef struct CalypsoFinalElement_t CalypsoFinalElement;
  26. typedef struct CalypsoBitmapElement_t CalypsoBitmapElement;
  27. typedef struct {
  28. CalypsoElementType type;
  29. union {
  30. CalypsoFinalElement* final;
  31. CalypsoBitmapElement* bitmap;
  32. };
  33. } CalypsoElement;
  34. struct CalypsoFinalElement_t {
  35. char key[36];
  36. int size;
  37. char label[64];
  38. CalypsoFinalType final_type;
  39. };
  40. struct CalypsoBitmapElement_t {
  41. char key[36];
  42. int size;
  43. CalypsoElement* elements;
  44. };
  45. typedef struct {
  46. CalypsoAppType type;
  47. CalypsoElement* elements;
  48. int elements_size;
  49. } CalypsoApp;
  50. CalypsoElement make_calypso_final_element(
  51. const char* key,
  52. int size,
  53. const char* label,
  54. CalypsoFinalType final_type);
  55. CalypsoElement make_calypso_bitmap_element(const char* key, int size, CalypsoElement* elements);
  56. void free_calypso_structure(CalypsoApp* structure);
  57. int* get_bit_positions(const char* binary_string, int* count);
  58. int is_bit_present(int* positions, int count, int bit);
  59. bool is_calypso_node_present(const char* binary_string, const char* key, CalypsoApp* structure);
  60. int get_calypso_node_offset(const char* binary_string, const char* key, CalypsoApp* structure);
  61. int get_calypso_node_size(const char* key, CalypsoApp* structure);
  62. #endif // CALYPSO_UTIL_H