Open xlar54 opened 5 years ago
The main issue is how to manage a "huge" mass of data, related to a Commodore 64. It's possible to paginate by number of bytes, but not by lines. Maybe we can read chunks of byte 'till is reached a given number of "CR" occurrences.
Tried with this trivial code to make a "GET HTTP/1.1", but I got no result (just "-1" as data count): what do I do wrong?
void main(void)
{
char buff[400];
int i;
uii_identify();
uii_getipaddress();
uii_settarget(TARGET_NETWORK);
uii_tcpconnect("cbbsoutpost.servebbs.com", 80);
socketnr = uii_data[0];
printf("FASE 1-----------------\n");
strcpy(buff,"GET /api/exportbbslist/service.php?f=csv HTTP/1.1\n\n");
uii_tcpsocketwrite(socketnr, buff);
printf("FASE 2-----------------\n");
for (i=0; i<50; ++i) {
uii_tcpsocketread(socketnr, 892);
datacount = uii_data[0] | (uii_data[1]<<8);
printf("%d ",datacount);
if(datacount > 0)
printf("%s",uii_data+2);
}
}
Tried also:
strcpy(buff,"get /API/EXPORTBBSLIST/SERVICE.PHP?F=CSV http/1.1\n\n");
...but I get the same result (=no result)
Try changing to 1.0:
GET /api/exportbbslist/service.php?f=csv HTTP/1.0\n\n
works via telnet client for me. I think something about 1.1 has an additional requirement.
just tried this, I added an "experiment" folder: https://github.com/xlar54/ultimateii-dos-lib/tree/download_with_punter_protocol/experiments try compiling it with:
cl65 -O ultimate_ii.c net.c -o net.prg
and launch net.prg on the C64/1541u2+ It do not print anything: why?
fixed in recent check in
I have extended Ultimate_II APIs with a BufferedReader of the TCP Socket, with this extension I implemented a POC of this issue's subject with a few, clean code: https://github.com/xlar54/ultimateii-dos-lib/blob/download_with_punter_protocol/sandbox/net.c
uii_tcpsocketwrite_ascii(socket, "GET /api/exportbbslist/service.php?f=csv HTTP/1.0\n\n");
// Skip HTTP header
while (uii_tcp_nextline_ascii(socket, buff) && *buff);
//Skip first line (header)
uii_tcp_nextline_ascii(socket, buff);
// Read single lines
while (uii_tcp_nextline_ascii(socket, buff) && *buff) {
p1 = strchr(buff+1, ',');
p2 = strchr(p1+1, ',');
p3 = strchr(p2+1, ',');
strncpy(name, buff+1, (p1-buff));
name[p1-buff-2]=0;
strncpy(host, p1+2, (p2-p1)-2);
host[p2-p1-3]=0;
strncpy(port, p2+2, (p3-p2)-2);
port[p3-p2-3]=0;
printf("%s:%s\n", host, port);
}
uii_tcpclose(socket);
You can run "net.prg" on the C64 and have listed all BBSes registered on the site. The main problem I see is the slowness, despite the reading is actually buffered, 892 bytes at a time.
This could be either implemented in the terminal, or as an external program. Would automatically download the active BBS list from commodore bbs output api:
(main site): http://cbbsoutpost.servebbs.com/
http://cbbsoutpost.servebbs.com/api/exportbbslist/
CSV file format would be easiest