build samples when testing

fix htmlget.d
This commit is contained in:
Rainer Schuetze 2017-04-18 22:12:39 +02:00
parent 630831faa5
commit 19de4a365a
3 changed files with 86 additions and 14 deletions

View file

@ -6,10 +6,10 @@
This code has no warranties and is provided 'as-is'.
*/
// debug = HTMLGET;
debug = HTMLGET;
import std.string, std.conv, std.stream, std.stdio;
import std.socket, std.socketstream;
import std.string, std.conv, std.stdio;
import std.socket;
int main(string[] args)
{
@ -67,7 +67,6 @@ int main(string[] args)
Socket sock = new TcpSocket(new InternetAddress(domain, port));
scope(exit) sock.close();
Stream ss = new SocketStream(sock);
debug (HTMLGET)
writefln("Connected! Requesting URL \"%s\"...", url);
@ -75,18 +74,27 @@ int main(string[] args)
if (port != 80)
domain = domain ~ ":" ~ to!string(port);
ss.writeString("GET " ~ url ~ " HTTP/1.0\r\n"
"Host: " ~ domain ~ "\r\n"
sock.send("GET " ~ url ~ " HTTP/1.0\r\n" ~
"Host: " ~ domain ~ "\r\n" ~
"\r\n");
// Skip HTTP header.
while (true)
{
auto line = ss.readLine();
char[] line;
char[1] buf;
while(sock.receive(buf))
{
line ~= buf;
if (buf[0] == '\n')
break;
}
if (!line.length)
break;
write(line);
enum CONTENT_TYPE_NAME = "Content-Type: ";
if (line.length > CONTENT_TYPE_NAME.length &&
@ -99,11 +107,5 @@ int main(string[] args)
}
}
while (!ss.eof())
{
auto line = ss.readLine();
writeln(line);
}
return 0;
}

63
samples/win32.mak Normal file
View file

@ -0,0 +1,63 @@
DMD=..\..\windows\bin\dmd
DFLAGS=
EXAMPLES = hello d2html dhry pi sieve wc wc2 \
winsamp dserver mydll htmlget listener
all: $(EXAMPLES)
d2html:
$(DMD) d2html $(DFLAGS)
.\d2html.exe d2html.d
dhry:
$(DMD) dhry $(DFLAGS)
.\dhry.exe
hello:
$(DMD) hello $(DFLAGS)
.\hello.exe
htmlget:
$(DMD) htmlget $(DFLAGS)
.\htmlget.exe www.dlang.org/index.html
listener:
$(DMD) listener $(DFLAGS)
# .\listener.exe
pi:
$(DMD) pi $(DFLAGS)
.\pi.exe 1000
sieve:
$(DMD) sieve $(DFLAGS)
.\sieve.exe
wc:
$(DMD) wc $(DFLAGS)
.\wc.exe wc.d
wc2:
$(DMD) wc2 $(DFLAGS)
.\wc2.exe wc2.d
winsamp:
$(DMD) winsamp $(DFLAGS) gdi32.lib user32.lib winsamp.def
# .\winsamp.exe
# COM client/server example
dserver:
$(DMD) dserver.d chello.d $(DFLAGS) dserver.def advapi32.lib ole32.lib user32.lib
# dclient will fail unless run with administrator rights
$(DMD) dclient $(DFLAGS) ole32.lib uuid.lib
.\dclient.exe
mydll:
$(DMD) $(DFLAGS) -ofmydll.dll -L/IMPLIB mydll\mydll.d mydll\dll.d mydll\mydll.def
$(DMD) $(DFLAGS) -ofdlltest.exe -Imydll mydll\test.d mydll.lib
.\dlltest.exe
clean:
clean.bat

View file

@ -5,8 +5,15 @@ auto-tester-build:
$(MAKE) -f win32.mak auto-tester-build
cd ..
auto-tester-test:
auto-tester-test: auto-tester-samples
cd test
$(MAKE)
cd ..
# hard coding gmake here as the auto-tester does
# some patches only to the lines with $(MAKE) above
auto-tester-samples:
cd samples
gmake -f win32.mak DMD=..\src\dmd.exe "DFLAGS=-I..\..\druntime\import -I..\..\phobos" LIB=..\..\phobos
cd ..