-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskList.h
More file actions
52 lines (43 loc) · 1.39 KB
/
TaskList.h
File metadata and controls
52 lines (43 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef __TaskList_H__
#define __TaskList_H__
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <emscripten.h>
#include <emscripten/fetch.h>
enum {
_NOP, // do nothing
_GET_INDEX, // retrieve all items; returns INDEX
_GET_ITEM, // retrieve 1 item (param == id); returns ITEM
_INSERT, // insert new item (id is created by server and returned in param); returns NEW_ITEM
_DELETE, // deletes item; returns DELETE
_UPDATE, // updates item; returns UPDATE
_INDEX, // samples of all items
_ITEM, // a single item
_NEW_ITEM, // a newly added item
_OK, // command successful
_ERROR, // error (param = code)
_CMD_COUNT
};
typedef struct _tFetchWorkOrder tFetchWorkOrder;
typedef struct _tHeader tHeader;
struct _tFetchWorkOrder {
void (*JSHandler)(int, int, char *, char *);
int id;
tHeader *data;
emscripten_fetch_t *fetch_struct;
tFetchWorkOrder *next;
};
struct _tHeader {
char magic1[4];
int cmd;
int param;
int name_len;
int body_len;
char magic2[4];
};
void SubmitWorkOrder(int cmd, int param, char *name, void *body, int body_len, void (*JSHandler)(int, int, char *, char *));
void RemoveWorkOrder(tFetchWorkOrder *wk);
void FetchTransferHandler(emscripten_fetch_t *fetch);
void FetchErrorHandler(emscripten_fetch_t *fetch);
#endif