shithub: masto9

ref: 494b0cda3dad99e3e1076acea474cf5b19b0c1d8
dir: masto9/masto9.h

View raw version
typedef struct Attachment {
	char *type;
	char *url;
} Attachment;

typedef struct FileAttachment {
	char *buf;
	int size;
} FileAttachment;

typedef struct Notification {
  char *id;
  char *type;
  char *handle;
  char *displayname;
  char *content;
  char *statusid;
} Notification;

typedef struct Toot {
	char *id;
	char *content;
	char *handle;
	char *displayname;
	char *avatarurl;
	char *inreplytoaccountid;
	int reblogged;
	char *rebloggedhandle;
	Attachment *mediaattachments[10];
	int attachmentscount;
} Toot;

enum {
	BUFSIZE = 2056,
	TOOTBUFSIZE = 8192,
	TLBUFSIZE = 512000,
	MAXURL = 1024,
	TOOTSCOUNT = 20,
	NOTIFSCOUNT = 20
};

/* display */
void displaytoots(Toot toots[], char *server);
void displaynotifications(Notification notifs[]);

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

/* utils */
void *emalloc(ulong);
char *estrdup(char*);
char *estrjoin(char **strings, char *sep);
char *esmprint(char*, ...);
char *fslurp(int, int*);
void removesubstring(char *, char *);
void removetag(char *, char *);
JSON *getjsonkey(JSON *, char *);
FileAttachment *readfile(char *filename);
char *basename(char *filepath);