Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include <menuet/os.h>
  2. #define NULL 0
  3. #define __stdcall __attribute__((stdcall))
  4.  
  5. extern int dll_load();
  6. extern int mem_Free();
  7. extern int mem_Alloc();
  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. unsigned int socket;
  20. unsigned int flags;
  21. unsigned int write_ptr;
  22. unsigned int buffer_length;
  23. unsigned int chunk_ptr;
  24. unsigned int timestamp;
  25. unsigned int status;
  26. unsigned int header_length;
  27. unsigned int content_length;
  28. unsigned int content_received;
  29. char data; //unknown size
  30. };
  31.  
  32.  
  33. int (* __stdcall http_init)();
  34. unsigned int (* __stdcall http_get) (char * url); //yay, it's NOT uint, but hey, C is stubborn, and I'm dumb
  35. int (* __stdcall http_process) (unsigned int identifier);
  36. void (* __stdcall http_free) (unsigned int identifier);
  37.  
  38.  
  39. int HTTP_YAY(){
  40.         asm volatile ("pusha\n\
  41.                            movl $mem_Alloc, %eax\n\
  42.                            movl $mem_Free, %ebx\n\
  43.                            movl $mem_ReAlloc, %ecx\n\
  44.                            movl $dll_load, %edx\n\
  45.                            movl http_init, %esi\n\
  46.                            call *%esi\n\
  47.                            popa");
  48. }
  49.  
  50. ///===========================
  51.  
  52. void HTTP_INIT()
  53. {
  54. IMP_ENTRY *imp;
  55.  
  56. imp = __kolibri__cofflib_load("/sys/lib/http.obj");
  57. if (imp == NULL)
  58.         kol_exit();
  59.  
  60. http_init = ( __stdcall  int(*)())
  61.                 __kolibri__cofflib_getproc (imp, "lib_init");
  62. if (http_init == NULL)
  63.         kol_exit();
  64.  
  65. http_get = ( __stdcall  unsigned int (*)(char*))
  66.                 __kolibri__cofflib_getproc  (imp, "get");
  67. if (http_get == NULL)
  68.         kol_exit();
  69.  
  70. http_free = ( __stdcall  void (*)(unsigned int))
  71.                 __kolibri__cofflib_getproc  (imp, "free");
  72. if (http_free == NULL)
  73.         kol_exit();
  74.  
  75.        
  76. http_process = ( __stdcall  int (*)(unsigned int))
  77.                 __kolibri__cofflib_getproc  (imp, "process");
  78. if (http_process == NULL)
  79.         kol_exit();
  80.  
  81. __menuet__debug_out("HTTP init...\n");
  82. HTTP_YAY();
  83.  
  84. __menuet__debug_out("ok...\n");
  85.  
  86. }
  87.