Subversion Repositories Kolibri OS

Rev

Rev 5598 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef INCLUDE_SOCKET_H
  2. #define INCLUDE_SOCKET_H
  3. #print "[include <socket.h>]\n"
  4.  
  5. #ifndef INCLUDE_KOLIBRI_H
  6. #include "../lib/kolibri.h"
  7. #endif
  8.  
  9. #define SOCK_STREAM 1
  10. #define SOCK_DGRAM 2
  11.  
  12. #define AF_INET4 2
  13.  
  14. #define MSG_PEEK 0x02
  15. #define MSG_DONTWAIT 0x40
  16.  
  17. dword errorcode;
  18.  
  19. struct  sockaddr_in
  20. {
  21.         word    sin_family;
  22.         word    sin_port;
  23.         dword   sin_addr;
  24.         char    padding[8];
  25. };  
  26.  
  27. inline fastcall dword Socket(ECX, EDX, ESI)
  28. {
  29.         $push   ebx
  30.         $mov    eax, 75
  31.         $mov    ebx, 0
  32.         $int    0x40
  33.         errorcode = EBX;
  34.         $pop    ebx
  35. }
  36.  
  37. inline fastcall dword Close(ECX)
  38. {
  39.         $push   ebx
  40.         $mov    eax, 75
  41.         $mov    ebx, 1
  42.         $int    0x40
  43.         errorcode = EBX;
  44.         $pop    ebx    
  45. }
  46.  
  47. inline fastcall dword Bind(ECX, EDX, ESI)
  48. {
  49.         $push   ebx
  50.         $mov    eax, 75
  51.         $mov    ebx, 2
  52.         $int    0x40
  53.         errorcode = EBX;
  54.         $pop    ebx
  55. }
  56.  
  57. inline fastcall dword Listen(ECX, EDX)
  58. {
  59.         $push   ebx
  60.         $mov    eax, 75
  61.         $mov    ebx, 3
  62.         $int    0x40
  63.         errorcode = EBX;
  64.         $pop    ebx
  65. }
  66.  
  67. inline fastcall dword Connect(ECX, EDX, ESI)
  68. {
  69.         $push   ebx
  70.         $mov    eax, 75
  71.         $mov    ebx, 4
  72.         $int    0x40
  73.         errorcode = EBX;
  74.         $pop    ebx
  75. }
  76.  
  77. inline fastcall dword Accept(ECX, EDX, ESI)
  78. {
  79.         $push   ebx
  80.         $mov    eax, 75
  81.         $mov    ebx, 5
  82.         $int    0x40
  83.         errorcode = EBX;
  84.         $pop    ebx
  85. }
  86.  
  87. inline fastcall dword Send(ECX, EDX, ESI, EDI)
  88. {
  89.         $push   ebx
  90.         $mov    eax, 75
  91.         $mov    ebx, 6
  92.         $int    0x40
  93.         errorcode = EBX;
  94.         $pop    ebx
  95. }
  96.  
  97. inline fastcall dword Receive(ECX, EDX, ESI, EDI)
  98. {
  99.         $push   ebx
  100.         $mov    eax, 75
  101.         $mov    ebx, 7
  102.         $int    0x40
  103.         errorcode = EBX;
  104.         $pop    ebx
  105. }
  106.  
  107. #endif