Structs for account, application, attachment, emojis, history, mention, status, tags

Some of the structs in status aren't created yet

FossilOrigin-Name: 228a50a75ffee30dc968e8e127bec7f0a0725b22c48fca3b9736f10eb5734069
This commit is contained in:
me@ow.nekobit.net 2022-01-22 04:28:17 +00:00
parent aa688d40d5
commit 27a433bc27
11 changed files with 295 additions and 6 deletions

View File

@ -0,0 +1,24 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MASTODONT_ACCOUNT
#define MASTODONT_ACCOUNT
struct mstdnt_account
{
int i;
};
#endif /* MASTODONT_ACCOUNT */

View File

@ -0,0 +1,28 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MASTODONT_APPLICATION
#define MASTODONT_APPLICATION
/* Status: Complete */
struct mstdnt_application
{
char* name;
char* website;
char* vapid_key;
};
#endif /* MASTODONT_ACCOUNT */

View File

@ -0,0 +1,42 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MASTODONT_ATTACHMENT
#define MASTODONT_ATTACHMENT
/* Status: Complete, not implemented */
enum mstdnt_attachment_type
{
MSTDNT_ATTACHMENT_UNKNOWN,
MSTDNT_ATTACHMENT_IMAGE,
MSTDNT_ATTACHMENT_GIFV,
MSTDNT_ATTACHMENT_VIDEO,
MSTDNT_ATTACHMENT_AUDIO
};
struct mstdnt_attachment
{
char* id;
enum mstdnt_attachment_type type;
char* url;
char* preview_url;
char* remote_url;
char* hash; /* <- Likely wrong */
char* description;
char* blurhash;
};
#endif /* MASTODONT_ATTACHMENT */

View File

@ -0,0 +1,33 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MASTODONT_EMOJI
#define MASTODONT_EMOJI
#include "mastodont_types.h"
struct mstdnt_emoji
{
/* Required */
char* shortcode;
char* url;
char* static_url;
mstdnt_bool visible_in_picker;
/* Optional */
char* category
};
#endif /* MASTODONT_EMOJI */

View File

@ -18,15 +18,15 @@
#include <cjson/cJSON.h>
#include <mastodont_types.h>
struct mastodont_fetch_results
struct mstdnt_fetch_results
{
char* response;
size_t size;
};
void mastodont_fetch_results_cleanup(struct mastodont_fetch_results* res);
void mastodont_fetch_results_cleanup(struct mstdnt_fetch_results* res);
int mastodont_fetch_curl(mastodont_t* mstdnt,
char* url,
struct mastodont_fetch_results* results);
struct mstdnt_fetch_results* results);
#endif /* MASTODONT_FETCH_H */

View File

@ -0,0 +1,28 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MASTODONT_HISTORY
#define MASTODONT_HISTORY
#include <time.h>
struct mstdnt_history
{
time_t day;
unsigned uses;
unsigned accounts;
};
#endif /* MASTODONT_TAG */

View File

@ -0,0 +1,27 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MASTODONT_MENTION
#define MASTODONT_MENTION
struct mstdnt_mention
{
char* id;
char* username;
char* acct;
char* url;
};
#endif /* MASTODONT_MENTION */

View File

@ -0,0 +1,76 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MASTODONT_STATUS
#define MASTODONT_STATUS
#include "mastodont_types.h"
#include "mastodont_attachment.h"
#include "mastodont_application.h"
#include "mastodont_mention.h"
/* Status: Complete, not implemented */
enum mstdnt_status_visibility
{
MSTDNT_VISIBILITY_PUBLIC,
MSTDNT_VISIBILITY_UNLISTED,
MSTDNT_VISIBILITY_PRIVATE,
MSTDNT_VISIBILITY_DIRECT,
MSTDNT_VISIBILITY_LIST,
MSTDNT_VISIBILITY_LOCAL
};
struct mstdnt_status
{
char* id;
char* uri;
char* created_at;
struct mstdnt_account account;
char* content;
enum mstdnt_status_visibility visibility;
mstdnt_bool sensitive;
char* spoiler_text;
mstdnt_attachment media_attachments[];
struct mstdnt_application application;
/* Rendering attributes */
struct mstdnt_mention mentions[];
struct mstdnt_tag tags[];
struct mstdnt_emoji emojis[];
/* Information attributes */
unsigned reblogs_count;
unsigned favourites_count;
unsigned replies_count;
/* Nullable attributes */
char* url;
char* in_reply_to_id;
char* in_reply_to_account_id;
struct mstdnt_status* status;
struct mstdnt_poll* poll;
struct mstdnt_card* card;
char* language;
char* text;
/* Authorized user attributes */
mstdnt_bool favourited;
mstdnt_bool reblogged;
mstdnt_bool muted;
mstdnt_bool bookmarked;
mstdnt_bool pinned;
};
#endif /* MASTODONT_STATUS */

27
include/mastodont_tags.h Normal file
View File

@ -0,0 +1,27 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MASTODONT_TAG
#define MASTODONT_TAG
struct mstdnt_tag
{
char* name;
char* url;
struct mstdnt_history history[];
};
#endif /* MASTODONT_TAG */

View File

@ -18,6 +18,7 @@
#include <curl/curl.h>
#define MSTDNT_URLSIZE 2048
typedef unsigned char mstdnt_bool;
typedef struct mastodont {
char* url;

View File

@ -23,7 +23,7 @@ int mastodont_timeline_public(mastodont_t* data,
struct mstdnt_response* response)
{
int res;
struct mastodont_fetch_results results = { 0 };
struct mstdnt_fetch_results results = { 0 };
/* Default args */
struct mstdnt_timeline_public_args _args;
if (args == NULL)
@ -41,8 +41,11 @@ int mastodont_timeline_public(mastodont_t* data,
res = mastodont_fetch_curl(data, "/api/v1/timelines/public", &results);
cJSON* parse = cJSON_Parse(results.response);
/* Compile pretty object and set it
if (!parse)
{
}
/* Cleanup */
free: