diff --git a/include/curl_utils.h b/include/curl_utils.h index 38fab8d..e70b789 100644 --- a/include/curl_utils.h +++ b/include/curl_utils.h @@ -1,3 +1,6 @@ +#ifndef CURL_UTILS_H +#define CURL_UtILS_H + #include "e621.h" typedef struct { @@ -6,4 +9,6 @@ typedef struct { int count; } curl_url_peram_t; -char *CurlGet(char *path, curl_url_peram_t *perams, int peram_count, e6_auth_t auth); \ No newline at end of file +char *CurlGet(char *path, curl_url_peram_t *perams, int peram_count, e6_auth_t auth); + +#endif \ No newline at end of file diff --git a/include/e621.h b/include/e621.h index 8b8f172..1222e3b 100644 --- a/include/e621.h +++ b/include/e621.h @@ -1,11 +1,12 @@ -#ifndef E621_HPP -#define E621_HPP +#ifndef E621_H +#define E621_H + // Includes #include -// Defines +// Defines #ifndef E621_HOST #define E621_HOST "https://e621.net" #endif @@ -14,6 +15,7 @@ #define E621_URL_BUF_SIZE 2048 #endif + // Structs typedef struct { unsigned int width; @@ -44,24 +46,8 @@ typedef struct { } e6_score_t; typedef struct { - char **general; - int general_count; - char **artist; - int artist_count; - char **contributor; - int contributor_count; - char **copyright; - int copyright_count; - char **character; - int character_count; - char **species; - int species_count; - char **invalid; - int invalid_count; - char **meta; - int meta_count; - char **lore; - int lore_count; + char **tags; + int tags_count; } e6_tags_t; typedef struct flags_t { @@ -78,6 +64,7 @@ typedef struct { bool has_children; bool has_active_children; int *children; + int children_count; } e6_relationships_t; typedef struct { @@ -88,9 +75,16 @@ typedef struct { e6_preview_t preview; e6_sample_t sample; e6_score_t score; - e6_tags_t tags; - char **locked_tags; - int locked_tags_count; + e6_tags_t general_tags; + e6_tags_t artist_tags; + e6_tags_t character_tags; + e6_tags_t species_tags; + e6_tags_t copyright_tags; + e6_tags_t contributor_tags; + e6_tags_t invalid_tags; + e6_tags_t meta_tags; + e6_tags_t lore_tags; + e6_tags_t locked_tags; unsigned int change_seq; e6_flags_t flags; char *rating; @@ -111,7 +105,9 @@ typedef struct { float project_ver; } e6_auth_t; + // Functions -e6_post_t *E6List(e6_auth_t auth, char **tags, int tags_count, unsigned int page, unsigned int limit); +e6_post_t *E6List(e6_auth_t auth, e6_tags_t tags, unsigned int page, unsigned int limit); + #endif \ No newline at end of file diff --git a/src/curl_utils.c b/src/curl_utils.c index f641c53..3c350d4 100644 --- a/src/curl_utils.c +++ b/src/curl_utils.c @@ -100,5 +100,8 @@ char *CurlGet(char *path, curl_url_peram_t *perams, int peram_count, e6_auth_t a return NULL; } + free(headers); + free(url); + curl_easy_cleanup(curl); return buffer.data; } \ No newline at end of file diff --git a/src/e621.c b/src/e621.c index ce4f5d3..7599425 100644 --- a/src/e621.c +++ b/src/e621.c @@ -8,7 +8,7 @@ #include "curl_utils.h" -e6_post_t *E6List(e6_auth_t auth, char **tags, int tags_count, unsigned int page, unsigned int limit) { +e6_post_t *E6List(e6_auth_t auth, e6_tags_t tags, unsigned int page, unsigned int limit) { char *path = "/posts.json"; curl_url_peram_t perams[3]; @@ -23,8 +23,8 @@ e6_post_t *E6List(e6_auth_t auth, char **tags, int tags_count, unsigned int page perams[1].count = 1; perams[2].key = "tags"; - perams[2].value = tags; - perams[2].count = tags_count; + perams[2].value = tags.tags; + perams[2].count = tags.tags_count; char *data = CurlGet(path, perams, 3, auth); printf("%s\n", data); diff --git a/src/main.c b/src/main.c index e41c705..c38bfa7 100644 --- a/src/main.c +++ b/src/main.c @@ -1,9 +1,11 @@ #include "e621.h" #include "creds.h" // provides the API key and username + int main(int argc, char *argv[]) { e6_auth_t auth = { USERNAME, API_KEY, "c621", 0.1 }; + e6_tags_t tags = {(char* []){ "rating:safe", "cat" }, 2}; - E6List(auth, (char* []){ "order:score", "cat" }, 2, 1, 3); + E6List(auth, tags, 1, 1); return 0; }