calypso_util.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include <stdbool.h>
  2. #include "calypso_i.h"
  3. #ifndef CALYPSO_UTIL_H
  4. #define CALYPSO_UTIL_H
  5. typedef enum {
  6. CALYPSO_APP_CONTRACT,
  7. CALYPSO_APP_EVENT,
  8. CALYPSO_APP_ENV_HOLDER,
  9. } CalypsoAppType;
  10. typedef enum {
  11. CALYPSO_FINAL_TYPE_UNKNOWN,
  12. CALYPSO_FINAL_TYPE_NUMBER,
  13. CALYPSO_FINAL_TYPE_DATE,
  14. CALYPSO_FINAL_TYPE_TIME,
  15. CALYPSO_FINAL_TYPE_PAY_METHOD,
  16. CALYPSO_FINAL_TYPE_AMOUNT,
  17. CALYPSO_FINAL_TYPE_SERVICE_PROVIDER,
  18. CALYPSO_FINAL_TYPE_ZONES,
  19. CALYPSO_FINAL_TYPE_TARIFF,
  20. CALYPSO_FINAL_TYPE_NETWORK_ID,
  21. CALYPSO_FINAL_TYPE_TRANSPORT_TYPE,
  22. CALYPSO_FINAL_TYPE_CARD_STATUS,
  23. CALYPSO_FINAL_TYPE_STRING,
  24. } CalypsoFinalType;
  25. typedef enum {
  26. CALYPSO_ELEMENT_TYPE_CONTAINER,
  27. CALYPSO_ELEMENT_TYPE_BITMAP,
  28. CALYPSO_ELEMENT_TYPE_FINAL
  29. } CalypsoElementType;
  30. typedef struct CalypsoFinalElement_t CalypsoFinalElement;
  31. typedef struct CalypsoBitmapElement_t CalypsoBitmapElement;
  32. typedef struct CalypsoContainerElement_t CalypsoContainerElement;
  33. typedef struct {
  34. CalypsoElementType type;
  35. union {
  36. CalypsoFinalElement* final;
  37. CalypsoBitmapElement* bitmap;
  38. CalypsoContainerElement* container;
  39. };
  40. } CalypsoElement;
  41. struct CalypsoFinalElement_t {
  42. char key[36];
  43. int size;
  44. char label[64];
  45. CalypsoFinalType final_type;
  46. };
  47. struct CalypsoBitmapElement_t {
  48. char key[36];
  49. int size;
  50. CalypsoElement* elements;
  51. };
  52. struct CalypsoContainerElement_t {
  53. char key[36];
  54. int size;
  55. CalypsoElement* elements;
  56. };
  57. typedef struct {
  58. CalypsoAppType type;
  59. CalypsoContainerElement* container;
  60. } CalypsoApp;
  61. CalypsoElement make_calypso_final_element(
  62. const char* key,
  63. int size,
  64. const char* label,
  65. CalypsoFinalType final_type);
  66. CalypsoElement make_calypso_bitmap_element(const char* key, int size, CalypsoElement* elements);
  67. CalypsoElement make_calypso_container_element(const char* key, int size, CalypsoElement* elements);
  68. void free_calypso_structure(CalypsoApp* structure);
  69. int* get_bitmap_positions(const char* binary_string, int* count);
  70. int is_bit_present(int* positions, int count, int bit);
  71. bool is_calypso_node_present(const char* binary_string, const char* key, CalypsoApp* structure);
  72. int get_calypso_node_offset(const char* binary_string, const char* key, CalypsoApp* structure);
  73. int get_calypso_node_size(const char* key, CalypsoApp* structure);
  74. // Calypso known Card types
  75. CALYPSO_CARD_TYPE guess_card_type(int country_num, int network_num);
  76. const char* get_country_string(int country_num);
  77. const char* get_network_string(CALYPSO_CARD_TYPE card_type);
  78. #endif // CALYPSO_UTIL_H