A tool for adding anime to your anidb list.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

94 lines
2.2KB

  1. #ifndef _API_H
  2. #define _API_H
  3. #include <stdint.h>
  4. #include <time.h>
  5. #include "error.h"
  6. #define API_VERSION "3"
  7. /* Maximum length of one response/request */
  8. #define API_BUFSIZE 1400
  9. /* Session key maximum size, including '\0' */
  10. #define API_SMAXSIZE 16
  11. /* The session timeout in miliseconds */
  12. #define API_TIMEOUT 30 * 60 * 1000
  13. /* How many miliseconds to wait between sends */
  14. #define API_SENDWAIT 2 * 1000
  15. /* The number of packets that are exccempt from the ratelimit */
  16. #define API_FREESEND 5
  17. /* Long term wait between sends */
  18. #define API_SENDWAIT_LONG 4 * 1000
  19. /* After this many packets has been sent, use the longterm ratelimit */
  20. #define API_LONGTERM_PACKETS 100
  21. enum mylist_state {
  22. MYLIST_STATE_UNKNOWN = 0,
  23. MYLIST_STATE_INTERNAL,
  24. MYLIST_STATE_EXTERNAL,
  25. MYLIST_STATE_DELETED,
  26. MYLIST_STATE_REMOTE,
  27. };
  28. enum file_state {
  29. FILE_STATE_NORMAL = 0,
  30. FILE_STATE_CORRUPT,
  31. FILE_STATE_SELF_EDIT,
  32. FILE_STATE_SELF_RIP = 10,
  33. FILE_STATE_ON_DVD,
  34. FILE_STATE_ON_VHS,
  35. FILE_STATE_ON_TV,
  36. FILE_STATE_IN_THEATERS,
  37. FILE_STATE_STREAMED,
  38. FILE_STATE_OTHER = 100,
  39. };
  40. struct api_version_result {
  41. char version_str[40];
  42. };
  43. struct api_auth_result {
  44. union {
  45. char session_key[API_SMAXSIZE];
  46. /* free() */
  47. char *banned_reason;
  48. };
  49. };
  50. struct api_uptime_result {
  51. int32_t ms;
  52. };
  53. struct api_mylistadd_result {
  54. union {
  55. uint64_t new_id;
  56. struct {
  57. uint64_t lid, fid, eid, aid, gid, date, viewdate;
  58. /* free() if != NULL ofc */
  59. char *storage, *source, *other;
  60. enum mylist_state state;
  61. enum file_state filestate;
  62. };
  63. };
  64. };
  65. #define e(n) struct api_##n##_result n
  66. struct api_result {
  67. uint16_t code;
  68. union {
  69. struct api_version_result version;
  70. struct api_auth_result auth;
  71. struct api_uptime_result uptime;
  72. e(mylistadd);
  73. };
  74. };
  75. #undef e
  76. enum error api_init(bool auth);
  77. void api_free();
  78. enum error api_cmd_version(struct api_result *res);
  79. enum error api_cmd_uptime(struct api_result *res);
  80. enum error api_cmd_mylistadd(int64_t size, const uint8_t *hash,
  81. enum mylist_state fstate, bool watched, struct api_result *res);
  82. #endif /* _API_H */