general cleanup
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef CURL_UTILS_H
|
||||||
|
#define CURL_UtILS_H
|
||||||
|
|
||||||
#include "e621.h"
|
#include "e621.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -6,4 +9,6 @@ typedef struct {
|
|||||||
int count;
|
int count;
|
||||||
} curl_url_peram_t;
|
} curl_url_peram_t;
|
||||||
|
|
||||||
char *CurlGet(char *path, curl_url_peram_t *perams, int peram_count, e6_auth_t auth);
|
char *CurlGet(char *path, curl_url_peram_t *perams, int peram_count, e6_auth_t auth);
|
||||||
|
|
||||||
|
#endif
|
||||||
+21
-25
@@ -1,11 +1,12 @@
|
|||||||
#ifndef E621_HPP
|
#ifndef E621_H
|
||||||
#define E621_HPP
|
#define E621_H
|
||||||
|
|
||||||
|
|
||||||
// Includes
|
// Includes
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
// Defines
|
|
||||||
|
|
||||||
|
// Defines
|
||||||
#ifndef E621_HOST
|
#ifndef E621_HOST
|
||||||
#define E621_HOST "https://e621.net"
|
#define E621_HOST "https://e621.net"
|
||||||
#endif
|
#endif
|
||||||
@@ -14,6 +15,7 @@
|
|||||||
#define E621_URL_BUF_SIZE 2048
|
#define E621_URL_BUF_SIZE 2048
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Structs
|
// Structs
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
@@ -44,24 +46,8 @@ typedef struct {
|
|||||||
} e6_score_t;
|
} e6_score_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char **general;
|
char **tags;
|
||||||
int general_count;
|
int tags_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;
|
|
||||||
} e6_tags_t;
|
} e6_tags_t;
|
||||||
|
|
||||||
typedef struct flags_t {
|
typedef struct flags_t {
|
||||||
@@ -78,6 +64,7 @@ typedef struct {
|
|||||||
bool has_children;
|
bool has_children;
|
||||||
bool has_active_children;
|
bool has_active_children;
|
||||||
int *children;
|
int *children;
|
||||||
|
int children_count;
|
||||||
} e6_relationships_t;
|
} e6_relationships_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -88,9 +75,16 @@ typedef struct {
|
|||||||
e6_preview_t preview;
|
e6_preview_t preview;
|
||||||
e6_sample_t sample;
|
e6_sample_t sample;
|
||||||
e6_score_t score;
|
e6_score_t score;
|
||||||
e6_tags_t tags;
|
e6_tags_t general_tags;
|
||||||
char **locked_tags;
|
e6_tags_t artist_tags;
|
||||||
int locked_tags_count;
|
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;
|
unsigned int change_seq;
|
||||||
e6_flags_t flags;
|
e6_flags_t flags;
|
||||||
char *rating;
|
char *rating;
|
||||||
@@ -111,7 +105,9 @@ typedef struct {
|
|||||||
float project_ver;
|
float project_ver;
|
||||||
} e6_auth_t;
|
} e6_auth_t;
|
||||||
|
|
||||||
|
|
||||||
// Functions
|
// 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
|
#endif
|
||||||
@@ -100,5 +100,8 @@ char *CurlGet(char *path, curl_url_peram_t *perams, int peram_count, e6_auth_t a
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(headers);
|
||||||
|
free(url);
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
return buffer.data;
|
return buffer.data;
|
||||||
}
|
}
|
||||||
+3
-3
@@ -8,7 +8,7 @@
|
|||||||
#include "curl_utils.h"
|
#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";
|
char *path = "/posts.json";
|
||||||
curl_url_peram_t perams[3];
|
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[1].count = 1;
|
||||||
|
|
||||||
perams[2].key = "tags";
|
perams[2].key = "tags";
|
||||||
perams[2].value = tags;
|
perams[2].value = tags.tags;
|
||||||
perams[2].count = tags_count;
|
perams[2].count = tags.tags_count;
|
||||||
|
|
||||||
char *data = CurlGet(path, perams, 3, auth);
|
char *data = CurlGet(path, perams, 3, auth);
|
||||||
printf("%s\n", data);
|
printf("%s\n", data);
|
||||||
|
|||||||
+3
-1
@@ -1,9 +1,11 @@
|
|||||||
#include "e621.h"
|
#include "e621.h"
|
||||||
#include "creds.h" // provides the API key and username
|
#include "creds.h" // provides the API key and username
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
e6_auth_t auth = { USERNAME, API_KEY, "c621", 0.1 };
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user