Rev 4821 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4821 | Rev 5043 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
- | 2 | #include "http_msg.h" |
|
- | 3 | //#include "http.h" |
|
- | 4 | ||
2 | #define NULL 0 |
5 | #define NULL 0 |
- | 6 | ||
3 | #define __stdcall __attribute__((stdcall)) |
7 | #define __stdcall __attribute__((stdcall)) |
Line 4... | Line 8... | ||
4 | 8 | ||
5 | extern int dll_load(); |
9 | extern int dll_load(); |
6 | extern int mem_Free(); |
10 | extern int mem_Free(); |
7 | extern int mem_Alloc(); |
11 | extern int mem_Alloc(); |
Line 8... | Line -... | ||
8 | extern int mem_ReAlloc(); |
- | |
9 | - | ||
10 | - | ||
11 | - | ||
12 | int kol_exit(){ |
- | |
13 | __menuet__sys_exit(); |
- | |
14 | } |
- | |
15 | - | ||
16 | - | ||
17 | - | ||
18 | struct http_msg { |
- | |
19 | // internal used by library, dont mess with these. |
- | |
20 | unsigned int socket; |
- | |
21 | unsigned int flags; |
- | |
22 | unsigned int write_ptr; |
- | |
23 | unsigned int buffer_length; |
- | |
24 | unsigned int chunk_ptr; |
- | |
25 | unsigned int timestamp; |
- | |
26 | - | ||
27 | // available for use. |
- | |
28 | unsigned int status; |
- | |
29 | unsigned int header_length; |
- | |
30 | char *content_ptr; |
- | |
31 | unsigned int content_length; |
- | |
32 | unsigned int content_received; |
- | |
33 | char header; //unknown size (actually, it's size is defined in header_length) |
- | |
34 | }; |
- | |
35 | 12 | extern int mem_ReAlloc(); |
|
36 | 13 | ||
37 | int (* __stdcall http_init)(); |
14 | int (* __stdcall http_init)(void); |
38 | // On the next line, we should tell the C compiler that this procedure actually returns a pointer. (to the http_msg struct) |
15 | // On the next line, we should tell the C compiler that this procedure actually returns a pointer. (to the http_msg struct) |
39 | unsigned int (* __stdcall http_get) (char * url, char * add_head); //yay, it's NOT uint, but hey, C is stubborn, and I'm dumb |
16 | unsigned int (* __stdcall http_get) (char * url, char * add_head); //yay, it's NOT uint, but hey, C is stubborn, and I'm dumb |
40 | int (* __stdcall http_process) (unsigned int identifier); |
- | |
- | 17 | int (* __stdcall http_receive) (unsigned int identifier); |
|
- | 18 | void (* __stdcall http_free) (unsigned int identifier); |
|
- | 19 | char * (* __stdcall http_find_header_field) (struct http_msg *http_ahoy, char *field_name); //This is crazzzzzzyyyyyy |
|
- | 20 | char * (* __stdcall http_unescape_url) (char * url_asciiz); |
|
- | 21 | char * (* __stdcall http_post) (char *url, char *headers, char *content_type, int content_length); |
|
Line 41... | Line 22... | ||
41 | void (* __stdcall http_free) (unsigned int identifier); |
22 | int (* __stdcall http_send) (struct http_msg *handle, char *data, unsigned int length); |
42 | 23 | void (* __stdcall http_disconnect) (struct http_msg *handle); |
|
43 | 24 | ||
44 | int HTTP_YAY(){ |
25 | int HTTP_YAY(){ |
Line 50... | Line 31... | ||
50 | movl http_init, %esi\n\ |
31 | movl http_init, %esi\n\ |
51 | call *%esi\n\ |
32 | call *%esi\n\ |
52 | popa"); |
33 | popa"); |
53 | } |
34 | } |
Line -... | Line 35... | ||
- | 35 | ||
- | 36 | int kol_exit(){ |
|
54 | 37 | __menuet__debug_out("kol_exit()..Exiting..\n"); |
|
- | 38 | __menuet__sys_exit(); |
|
Line 55... | Line 39... | ||
55 | ///=========================== |
39 | } |
56 | 40 | ||
57 | void HTTP_INIT() |
41 | void HTTP_INIT() |
Line 58... | Line 42... | ||
58 | { |
42 | { |
59 | IMP_ENTRY *imp; |
43 | const IMP_ENTRY *imp; |
60 | 44 | ||
Line 61... | Line 45... | ||
61 | imp = __kolibri__cofflib_load("/sys/lib/http.obj"); |
45 | imp = __kolibri__cofflib_load("/sys/lib/http.obj"); |
62 | if (imp == NULL) |
46 | if (imp == NULL) |
63 | kol_exit(); |
47 | kol_exit(); |
- | 48 | ||
- | 49 | http_init = ( __stdcall int(*)()) |
|
64 | 50 | __kolibri__cofflib_getproc (imp, "lib_init"); |
|
- | 51 | if (http_init == NULL) |
|
- | 52 | { |
|
- | 53 | __menuet__debug_out("http_init() is NULL. Exiting.\n"); |
|
Line -... | Line 54... | ||
- | 54 | kol_exit(); |
|
65 | http_init = ( __stdcall int(*)()) |
55 | } |
66 | __kolibri__cofflib_getproc (imp, "lib_init"); |
56 | else |
67 | if (http_init == NULL) |
57 | __menuet__debug_out("\nhttp_init() initialised properly.\n"); |
- | 58 | ||
- | 59 | ||
68 | kol_exit(); |
60 | http_get = ( __stdcall unsigned int (*)(char*, char*)) |
69 | 61 | __kolibri__cofflib_getproc (imp, "get"); |
|
70 | http_get = ( __stdcall unsigned int (*)(char*)) |
62 | if (http_get == NULL) |
71 | __kolibri__cofflib_getproc (imp, "get"); |
63 | { |
72 | if (http_get == NULL) |
64 | __menuet__debug_out("http_get() is NULL. Exiting.\n"); |
- | 65 | kol_exit(); |
|
- | 66 | } |
|
- | 67 | http_free = ( __stdcall void (*)(unsigned int)) |
|
- | 68 | __kolibri__cofflib_getproc (imp, "free"); |
|
- | 69 | if (http_free == NULL) |
|
- | 70 | { |
|
- | 71 | __menuet__debug_out("http_free() is NULL. Exiting.\n"); |
|
- | 72 | kol_exit(); |
|
- | 73 | } |
|
- | 74 | http_receive = ( __stdcall int (*)(unsigned int)) |
|
73 | kol_exit(); |
75 | __kolibri__cofflib_getproc (imp, "receive"); |
- | 76 | ||
- | 77 | if (http_receive == NULL) |
|
- | 78 | { |
|
- | 79 | __menuet__debug_out("http_receive() is NULL. Exiting.\n"); |
|
- | 80 | kol_exit(); |
|
- | 81 | } |
|
- | 82 | ||
- | 83 | http_find_header_field = ( __stdcall char *(*)(struct http_msg*, char *)) |
|
- | 84 | __kolibri__cofflib_getproc (imp, "find_header_field"); |
|
- | 85 | if (http_find_header_field == NULL) |
|
- | 86 | { |
|
- | 87 | __menuet__debug_out("http_find_header_field() is NULL. Exiting.\n"); |
|
- | 88 | kol_exit(); |
|
- | 89 | } |
|
- | 90 | ||
- | 91 | http_unescape_url = ( __stdcall char *(*)(char *)) |
|
- | 92 | __kolibri__cofflib_getproc (imp, "unescape"); |
|
- | 93 | ||
Line -... | Line 94... | ||
- | 94 | if(http_unescape_url == NULL) |
|
- | 95 | { |
|
Line 74... | Line -... | ||
74 | - | ||
75 | http_free = ( __stdcall void (*)(unsigned int)) |
- | |
76 | __kolibri__cofflib_getproc (imp, "free"); |
96 | __menuet__debug_out("http_unescape_url() is NULL. Exiting.\n"); |
- | 97 | kol_exit(); |
|
- | 98 | } |
|
77 | if (http_free == NULL) |
99 | |
- | 100 | http_post = ( __stdcall char *(*)(char *, char *, char *, int)) |
|
- | 101 | __kolibri__cofflib_getproc (imp, "post"); |
|
- | 102 | ||
- | 103 | if(http_post == NULL) |
|
- | 104 | { |
|
- | 105 | __menuet__debug_out("http_post() is NULL. Exiting.\n"); |
|
- | 106 | kol_exit(); |
|
- | 107 | } |
|
- | 108 | ||
- | 109 | ||
- | 110 | http_send = ( __stdcall int (*)(struct http_msg *, char *, unsigned int)) |
|
- | 111 | __kolibri__cofflib_getproc (imp, "send"); |
|
- | 112 | ||
- | 113 | if(http_send == NULL) |
|
- | 114 | { |
|
- | 115 | __menuet__debug_out("http_send() is NULL. Exiting.\n"); |
|
- | 116 | kol_exit(); |
|
- | 117 | } |
|
- | 118 | ||
- | 119 | ||
- | 120 | http_disconnect = ( __stdcall void (*)(struct http_msg *)) |
|
- | 121 | __kolibri__cofflib_getproc (imp, "disconnect"); |
|
- | 122 | ||
Line 78... | Line 123... | ||
78 | kol_exit(); |
123 | if(http_disconnect == NULL) |
79 | 124 | { |
|
Line 80... | Line 125... | ||
80 | 125 | __menuet__debug_out("http_disconnect() is NULL. Exiting.\n"); |
|
81 | http_process = ( __stdcall int (*)(unsigned int)) |
- | |
82 | __kolibri__cofflib_getproc (imp, "process"); |
126 | kol_exit(); |