forked from bakagirl/Arachne-WWW-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FINGOPHR.C
136 lines (112 loc) · 3.16 KB
/
FINGOPHR.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// ========================================================================
// Arachne WWW browser FTP functions
// (c)1997-1999 xChaos software
// ========================================================================
/******************************************************************************
FINGER - display user/system information
Copyright (C) 1991, University of Waterloo
******************************************************************************/
#include <stdio.h>
#include <io.h>
#include <string.h>
#include <fcntl.h>
#include <sys\stat.h>
#include "arachne.h"
#include "internet.h"
void xChLogoTICK(char Style); // animation of logo
void xChLogo(char n); // draw empty logo
int GUITICK(void); // redraw mouse, keyboard input, etc.
void memerr(void);
extern struct GLOBAL_FLAG GLOBAL;
extern char tcpip;
extern char closing[2];
extern char *msg_con;
extern char *msg_errcon;
extern char *msg_askdns;
int xfinger(struct Url *url, struct HTTPrecord *cache,char *selector)
//void finger(char *userid, longword host, char *hoststring)
{
// tcp_Socket fingersock;
int status;
int len=0;
longword host;
char str[256];
char smallbuf[512];
char *ptr;
char ext[4];
long total=0;
if(!tcpip)return 0;
free_socket();
sprintf(str,msg_askdns,url->host);
outs(str);
GlobalLogoStyle=0; //SDL set resolve animation
host = resolve_fn(url->host, (sockfunct_t) TcpIdleFunc); //SDL
// host = resolve(url->host);
if(!host)
{
DNSerr(url->host);
return 0;
}
GlobalLogoStyle=2; //SDL set connect animation
if (!tcp_open( socket, locport(), host, url->port, NULL ))
{
sprintf(str,msg_errcon,url->host);
outs(str);
return 0;
}
sprintf(str,msg_con,url->host,url->port);
outs(str);
sock_wait_established(socket, sock_delay, (sockfunct_t) TcpIdleFunc,
&status); //SDL
GlobalLogoStyle=1; //SDL set data animation
if(selector[0])
{
sprintf(str,MSG_ASKING,selector);
outs(str);
}
else
outs(MSG_WTRPL);
sprintf(str,"%s\r\n",selector);
sock_puts( socket, (unsigned char *)str);
ptr=strrchr(cache->locname,'.');
if(ptr)
{
get_extension(cache->mime,ext);
strcpy(&ptr[1],ext);
strcpy(cache->rawname,cache->locname);
}
// cache->httpresponse[0]='\0';
cache->handle=a_open(cache->locname,O_BINARY|O_WRONLY|O_CREAT|O_TRUNC,S_IREAD|S_IWRITE);
while ( 1 )
{
xChLogoTICK(1);
if(GUITICK())
if(GLOBAL.gotolocation || GLOBAL.abort)
goto abort;
if (sock_dataready( socket ))
{
len = sock_fastread( socket, (unsigned char*)smallbuf, 512 );
if(cache->handle>=0)
write(cache->handle,smallbuf,len);
total+=len;
sprintf(str,MSG_RDRPL,total);
}
sock_tick( socket, &status ); //I shift TCP/IP
}
abort:
sock_close( socket );
closing[socknum]=1;
sock_keepalive[socknum][0]='\0';
goto closed;
// sock_wait_closed( socket, sock_delay, NULL, &status );
sock_err:
sockmsg(status,socknum);
closed:
cache->size=a_filelength(cache->handle);
cache->knowsize=1;
if(cache->handle>=0)
a_close(cache->handle);
if(user_interface.logoiddle)
xChLogo('0');
return 1;
}