diff --git a/programs/develop/ktcc/trunk/bin/lib/libck.a b/programs/develop/ktcc/trunk/bin/lib/libck.a index aa4221024e..8a4d75cdd5 100644 Binary files a/programs/develop/ktcc/trunk/bin/lib/libck.a and b/programs/develop/ktcc/trunk/bin/lib/libck.a differ diff --git a/programs/develop/ktcc/trunk/libc/include/kolibrisys.h b/programs/develop/ktcc/trunk/libc/include/kolibrisys.h index 5638b8300a..934cdda48e 100644 --- a/programs/develop/ktcc/trunk/libc/include/kolibrisys.h +++ b/programs/develop/ktcc/trunk/libc/include/kolibrisys.h @@ -171,8 +171,9 @@ extern int stdcall _ksys_pci_write_config_word(int bus,int dev,int fn,int reg,i extern int stdcall _ksys_pci_write_config_dword(int bus,int dev,int fn,int reg,int value); //-------------------------------------------------------------------------------------- -//------------------------Process information-------------------------------------- +//------------------------Working with processes-------------------------------------- extern int stdcall _ksys_get_process_table(struct process_table_entry *proctab,int pid); //if pid=-1 than get info about him. +extern int stdcall _ksys_kill_process(int pid); // if it returns -1 then an error. //--------------------------------------------------------------------------------- //-----------------Old functions for work with sound(Sound Blaster only).--------- diff --git a/programs/develop/ktcc/trunk/libc/include/net/network.h b/programs/develop/ktcc/trunk/libc/include/net/network.h new file mode 100644 index 0000000000..879548f783 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/include/net/network.h @@ -0,0 +1,54 @@ +#ifndef __NETWORK_H +#define __NETWORK_H + +#include + +#define EAI_ADDRFAMILY 1 +#define EAI_AGAIN 2 +#define EAI_BADFLAGS 3 +#define EAI_FAIL 4 +#define EAI_FAMILY 5 +#define EAI_MEMORY 6 +#define EAI_NONAME 8 +#define EAI_SERVICE 9 +#define EAI_SOCKTYPE 10 +#define EAI_BADHINTS 12 +#define EAI_PROTOCOL 13 +#define EAI_OVERFLOW 14 + +// Flags for addrinfo +#define AI_PASSIVE 1 +#define AI_CANONNAME 2 +#define AI_NUMERICHOST 4 +#define AI_NUMERICSERV 8 +#define AI_ADDRCONFIG 0x400 + +#pragma pack(push, 1) +struct ARP_entry{ +unsigned int IP; +unsigned char MAC[6]; +unsigned short status; +unsigned short TTL; +}; +#pragma pack(pop) + +#pragma pack(push, 1) +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + int ai_addrlen; + char *ai_canonname; + sockaddr *ai_addr; + struct addrinfo *ai_next; +}; +#pragma pack(pop) + +extern int networklib_init (); +extern int (*inet_addr __attribute__ ((stdcall)))(const char* hostname); +extern char* (*inet_ntoa __attribute__ ((stdcall)))(int ip_addr); +extern int (*getaddrinfo __attribute__ ((stdcall)))(char* hostname, int servname, struct addrinfo* hints, struct addrinfo** res); +extern void (*freeaddrinfo __attribute__ ((stdcall)))(struct addrinfo* ai); + +#endif diff --git a/programs/develop/ktcc/trunk/libc/include/net/socket.h b/programs/develop/ktcc/trunk/libc/include/net/socket.h index 06f57961d0..b250171449 100644 --- a/programs/develop/ktcc/trunk/libc/include/net/socket.h +++ b/programs/develop/ktcc/trunk/libc/include/net/socket.h @@ -83,7 +83,7 @@ typedef struct{ }sockaddr; #pragma pack(pop) -#pragma pack(push, 1) +#pragma pack(push,1) typedef struct{ unsigned int level; unsigned int optionname; diff --git a/programs/develop/ktcc/trunk/libc/kolibrisys/process.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/process.asm index cbff86911e..797a616ecb 100644 --- a/programs/develop/ktcc/trunk/libc/kolibrisys/process.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/process.asm @@ -2,15 +2,23 @@ format ELF ;include "public_stdcall.inc" public _ksys_get_process_table +public _ksys_kill_process section '.text' executable _ksys_get_process_table: ;arg1 - pointer to information ;arg2 - pid - mov eax,9 - mov ebx,[esp+4] - mov ecx,[esp+8] - int 0x40 + mov eax,9 + mov ebx,[esp+4] + mov ecx,[esp+8] + int 0x40 + ret 8 - ret 8 \ No newline at end of file +_ksys_kill_process: +;arg - pid + mov eax, 18 + mov ebx, 18 + mov ecx,[esp+4] + int 0x40 + ret 4 diff --git a/programs/develop/ktcc/trunk/libc/net/network.asm b/programs/develop/ktcc/trunk/libc/net/network.asm new file mode 100644 index 0000000000..5d996a5663 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/net/network.asm @@ -0,0 +1,50 @@ +format elf +use32 ; Tell compiler to use 32 bit instructions +; ELF section +section '.text' executable + + +include '../../../../../proc32.inc' +include '../../../../../macros.inc' +purge section,mov,add,sub + +include '../../../../../dll.inc' + + +public lib_init as 'networklib_init' + + +proc lib_init +local retval dd ? + mov [retval], eax + pusha + mcall 68, 11 + test eax, eax + jnz @f + mov [retval], -1 + jmp exit_init_networklib +@@: + stdcall dll.Load, @IMPORT + test eax, eax + jz exit_init_networklib + mov [retval], -1 +exit_init_networklib: + popa + mov eax, [retval] + ret +endp + +section '.data' writeable +@IMPORT: +library networklib, 'network.obj' + +import networklib, \ + inet_addr, 'inet_addr', \ + inet_ntoa, 'inet_ntoa', \ + getaddrinfo, 'getaddrinfo', \ + freeaddrinfo, 'freeaddrinfo' + +public inet_addr as 'inet_addr' +public inet_ntoa as 'inet_ntoa' +public getaddrinfo as 'getaddrinfo' +public freeaddrinfo as 'freeaddrinfo' diff --git a/programs/develop/ktcc/trunk/samples/build_all.sh b/programs/develop/ktcc/trunk/samples/build_all.sh index 7aa7919dda..fc269226fa 100644 --- a/programs/develop/ktcc/trunk/samples/build_all.sh +++ b/programs/develop/ktcc/trunk/samples/build_all.sh @@ -13,4 +13,5 @@ ../tcc console/console.c -lck -limg -o /tmp0/1/console ../tcc dir_example.c -lck -o /tmp0/1/dir_example ../tcc net/tcpsrv_demo.c -lck -o /tmp0/1/tcpsrv_demo +../tcc net/nslookup.c -lck -o /tmp0/1/nslookup exit diff --git a/programs/develop/ktcc/trunk/samples/net/nslookup.c b/programs/develop/ktcc/trunk/samples/net/nslookup.c new file mode 100644 index 0000000000..010c2b9e6e --- /dev/null +++ b/programs/develop/ktcc/trunk/samples/net/nslookup.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +struct addrinfo *res; +char host[256]; + +void main() +{ + con_init_console_dll(); + networklib_init(); + con_set_title("nslookup demo"); + printf("Host name to resolve: "); + con_gets(host, 256); + host[strlen(host)-1] = '\0'; + if(getaddrinfo(host ,0, 0, &res)!=0) + { + puts("Host not found!"); + freeaddrinfo(res); + con_exit(0); + } + else + { + printf("%s",inet_ntoa(res->ai_addr->sin_addr)); + freeaddrinfo(res); + con_exit(0); + } +}