Rev 4821 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4224 | sourcerer | 1 | #include |
5043 | ashmew2 | 2 | #include "http_msg.h" |
3 | //#include "http.h" |
||
4 | |||
4224 | sourcerer | 5 | #define NULL 0 |
5043 | ashmew2 | 6 | |
4224 | sourcerer | 7 | #define __stdcall __attribute__((stdcall)) |
8 | |||
9 | extern int dll_load(); |
||
10 | extern int mem_Free(); |
||
11 | extern int mem_Alloc(); |
||
12 | extern int mem_ReAlloc(); |
||
13 | |||
5043 | ashmew2 | 14 | int (* __stdcall http_init)(void); |
4821 | ashmew2 | 15 | // On the next line, we should tell the C compiler that this procedure actually returns a pointer. (to the http_msg struct) |
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 |
||
5043 | ashmew2 | 17 | int (* __stdcall http_receive) (unsigned int identifier); |
4224 | sourcerer | 18 | void (* __stdcall http_free) (unsigned int identifier); |
5043 | ashmew2 | 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); |
||
22 | int (* __stdcall http_send) (struct http_msg *handle, char *data, unsigned int length); |
||
23 | void (* __stdcall http_disconnect) (struct http_msg *handle); |
||
4224 | sourcerer | 24 | |
25 | int HTTP_YAY(){ |
||
26 | asm volatile ("pusha\n\ |
||
27 | movl $mem_Alloc, %eax\n\ |
||
28 | movl $mem_Free, %ebx\n\ |
||
29 | movl $mem_ReAlloc, %ecx\n\ |
||
30 | movl $dll_load, %edx\n\ |
||
31 | movl http_init, %esi\n\ |
||
32 | call *%esi\n\ |
||
33 | popa"); |
||
34 | } |
||
35 | |||
5043 | ashmew2 | 36 | int kol_exit(){ |
37 | __menuet__debug_out("kol_exit()..Exiting..\n"); |
||
38 | __menuet__sys_exit(); |
||
39 | } |
||
4224 | sourcerer | 40 | |
41 | void HTTP_INIT() |
||
42 | { |
||
5043 | ashmew2 | 43 | const IMP_ENTRY *imp; |
4224 | sourcerer | 44 | |
45 | imp = __kolibri__cofflib_load("/sys/lib/http.obj"); |
||
46 | if (imp == NULL) |
||
47 | kol_exit(); |
||
48 | |||
49 | http_init = ( __stdcall int(*)()) |
||
50 | __kolibri__cofflib_getproc (imp, "lib_init"); |
||
51 | if (http_init == NULL) |
||
5043 | ashmew2 | 52 | { |
53 | __menuet__debug_out("http_init() is NULL. Exiting.\n"); |
||
54 | kol_exit(); |
||
55 | } |
||
56 | else |
||
57 | __menuet__debug_out("\nhttp_init() initialised properly.\n"); |
||
4224 | sourcerer | 58 | |
5043 | ashmew2 | 59 | |
60 | http_get = ( __stdcall unsigned int (*)(char*, char*)) |
||
4224 | sourcerer | 61 | __kolibri__cofflib_getproc (imp, "get"); |
62 | if (http_get == NULL) |
||
5043 | ashmew2 | 63 | { |
64 | __menuet__debug_out("http_get() is NULL. Exiting.\n"); |
||
65 | kol_exit(); |
||
66 | } |
||
4224 | sourcerer | 67 | http_free = ( __stdcall void (*)(unsigned int)) |
68 | __kolibri__cofflib_getproc (imp, "free"); |
||
69 | if (http_free == NULL) |
||
5043 | ashmew2 | 70 | { |
71 | __menuet__debug_out("http_free() is NULL. Exiting.\n"); |
||
72 | kol_exit(); |
||
73 | } |
||
74 | http_receive = ( __stdcall int (*)(unsigned int)) |
||
75 | __kolibri__cofflib_getproc (imp, "receive"); |
||
4224 | sourcerer | 76 | |
5043 | ashmew2 | 77 | if (http_receive == NULL) |
78 | { |
||
79 | __menuet__debug_out("http_receive() is NULL. Exiting.\n"); |
||
80 | kol_exit(); |
||
81 | } |
||
4224 | sourcerer | 82 | |
5043 | ashmew2 | 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 | |||
94 | if(http_unescape_url == NULL) |
||
95 | { |
||
96 | __menuet__debug_out("http_unescape_url() is NULL. Exiting.\n"); |
||
97 | kol_exit(); |
||
98 | } |
||
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 | |||
123 | if(http_disconnect == NULL) |
||
124 | { |
||
125 | __menuet__debug_out("http_disconnect() is NULL. Exiting.\n"); |
||
126 | kol_exit(); |
||
127 | } |
||
128 | |||
129 | |||
130 | |||
4224 | sourcerer | 131 | __menuet__debug_out("HTTP init...\n"); |
132 | HTTP_YAY(); |
||
133 | |||
134 | __menuet__debug_out("ok...\n"); |
||
135 | } |