A tool for adding anime to your anidb list.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

92 lignes
2.2KB

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