shithub: rtmp

ref: d36842808af48e19a4335fb513801cd9c7ea6464
dir: /amf.h/

View raw version
enum {
	Tstr,
	Tnum,
	Tbool,
	Tarr,
	Tobj,
};

typedef struct Amf Amf;

struct Amf {
	int type;
	union {
		char *str;
		double num;
		u8int bool;
		struct {
			Amf **v;
			int n;
		}arr;
		struct {
			char **k;
			Amf **v;
			int n;
		}obj;
	};
};

u8int *amfi16(u8int *p, u8int *e, s16int i);
u8int *amfbool(u8int *p, u8int *e, int v);
u8int *amfbyte(u8int *p, u8int *e, u8int byte);
u8int *amfi24(u8int *p, u8int *e, s32int i);
u8int *amfi32(u8int *p, u8int *e, s32int i);
u8int *amfnum(u8int *p, u8int *e, double v);
u8int *amfstr(u8int *p, u8int *e, char *s);
u8int *amfarr(u8int *p, u8int *e);
u8int *amfobj(u8int *p, u8int *e);
u8int *amfend(u8int *p, u8int *e);
u8int *amfkvnum(u8int *p, u8int *e, char *name, double v);
u8int *amfkvstr(u8int *p, u8int *e, char *name, char *v);
u8int *amfkvbool(u8int *p, u8int *e, char *name, int v);

u8int *amfbyteget(u8int *p, u8int *e, u8int *byte);
u8int *amfi16get(u8int *p, u8int *e, s16int *i);
u8int *amfi24get(u8int *p, u8int *e, s32int *i);
u8int *amfi32get(u8int *p, u8int *e, s32int *i);

u8int *amfparse(Amf **a, u8int *p, u8int *e);
void amffree(Amf *a);

#pragma varargck type "A" Amf*
int amffmt(Fmt *f);