Subversion Repositories Kolibri OS

Rev

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

  1. #include "kosnet/network.h"
  2. #include "kosnet/dlfcn.h"
  3.  
  4. int (*inet_addr)(const char* hostname) __attribute__ ((stdcall));
  5. char* (*inet_ntoa)(int ip_addr) __attribute__ ((stdcall));
  6. int (*getaddrinfo)(const char* hostname, const char* servname, const struct addrinfo* hints, struct addrinfo** res) __attribute__ ((stdcall));
  7. void (*freeaddrinfo)(struct addrinfo* ai) __attribute__ ((stdcall));
  8.  
  9. int load_network_obj() {
  10.     void *network_lib = dlopen("/sys/lib/network.obj", RTLD_GLOBAL);
  11.     if (network_lib == NULL) {
  12.         return -1;
  13.     }
  14.     inet_addr = dlsym(network_lib, "inet_addr");
  15.     inet_ntoa = dlsym(network_lib, "inet_ntoa");
  16.     getaddrinfo = dlsym(network_lib, "getaddrinfo");
  17.     freeaddrinfo = dlsym(network_lib, "freeaddrinfo");
  18.     dlclose(network_lib);
  19.     return 0;
  20. }
  21.