Subversion Repositories Kolibri OS

Rev

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

  1. #include <menuet/os.h>
  2. #include <menuet/net.h>
  3.  
  4.  
  5. #define NULL 0
  6. #define __stdcall __attribute__((stdcall))
  7.  
  8. extern int dll_load();
  9. extern int mem_Free();
  10. extern int mem_Alloc();
  11. extern int mem_ReAlloc();
  12.  
  13. int kol_exit(){
  14.   __menuet__sys_exit();
  15. }
  16.  
  17. int (* __stdcall network_init)();
  18. void (* __stdcall freeaddrinfo)(struct addrinfo* ai);
  19. int (* __stdcall getaddrinfo)( const char* hostname, const char* servname, const struct addrinfo* hints, struct addrinfo **res);
  20. char * (* __stdcall inet_ntoa)(struct in_addr in);
  21. unsigned long (* __stdcall inet_addr)( const char* hostname);
  22.  
  23.  
  24. int NETWORK_YAY(){
  25. asm volatile ("pusha\n\
  26. movl $mem_Alloc, %eax\n\
  27. movl $mem_Free, %ebx\n\
  28. movl $mem_ReAlloc, %ecx\n\
  29. movl $dll_load, %edx\n\
  30. movl network_init, %esi\n\
  31. call *%esi\n\
  32. popa\n");
  33. }
  34.  
  35.  
  36. void NETWORK_INIT()
  37. {
  38. IMP_ENTRY *imp;
  39.  
  40. imp = __kolibri__cofflib_load("/sys/lib/network.obj");
  41. if (imp == NULL)
  42.   kol_exit();
  43.  
  44. network_init = ( __stdcall int(*)())
  45. __kolibri__cofflib_getproc (imp, "lib_init");
  46. if (network_init == NULL)
  47.   kol_exit();
  48.  
  49. freeaddrinfo = ( __stdcall void (*)(struct addrinfo*))
  50. __kolibri__cofflib_getproc (imp, "freeaddrinfo");
  51. if (freeaddrinfo == NULL)
  52.   kol_exit();
  53.  
  54. getaddrinfo = ( __stdcall int (*)(const char*, const char*, const struct addrinfo*, struct addrinfo **))
  55. __kolibri__cofflib_getproc (imp, "getaddrinfo");
  56. if (getaddrinfo == NULL)
  57.   kol_exit();
  58.  
  59. inet_ntoa = ( __stdcall char * (*)(struct in_addr))
  60. __kolibri__cofflib_getproc (imp, "inet_ntoa");
  61. if (inet_ntoa == NULL)
  62.   kol_exit();
  63.  
  64. inet_addr = ( __stdcall unsigned long (*)(const char *))
  65. __kolibri__cofflib_getproc (imp, "inet_addr");
  66. if (inet_addr == NULL)
  67.   kol_exit();
  68.  
  69. __menuet__debug_out("NETWORK init...\n");
  70.  
  71. NETWORK_YAY();
  72.  
  73. __menuet__debug_out("ok...\n");
  74.  
  75. }