shithub: masto9

ref: 416e913d695eea696560b129c98cd3038efa103a
dir: /masto9.h/

View raw version
#define Contenttype	"contenttype application/json"

typedef struct Attachment {
	char *type;
	char *url;
} Attachment;

typedef struct Notification {
  char *id;
  char *type;
  char *username;
  char *content;
} Notification;

typedef struct Toot {
	char *id;
	char *content;
	char *username;
	char *display_name;
	char *avatar_url;
	char *in_reply_to_account_id;
	int reblogged;
	char *reblogged_username;
	Attachment media_attachments[10];
	int attachments_count;
} Toot;

enum {
	TOOTBUFSIZE = 8192,
	TLBUFSIZE = 512000,
	MAX_URL = 1024,
	TOOTS_COUNT = 20,
	NOTIFS_COUNT = 15
};

Toot toots[TOOTS_COUNT];
Notification notifs[TOOTS_COUNT];

/* http */
char *httpget(char *token, char *url);
char *httppost(char *token, char *url, char *text);

/* utils */
char *concat(char *s1, char *s2);
void *emalloc(ulong);
void *erealloc(void*, ulong);
char *estrdup(char*);
char *estrjoin(char **strings, char *sep);
char *esmprint(char*, ...);
char *fslurp(int, int*);
u32int strhash(char*);