diff --git a/samples/dclient.d b/samples/dclient.d index cddc04e647e7..6b779da83803 100644 --- a/samples/dclient.d +++ b/samples/dclient.d @@ -111,7 +111,7 @@ int dll_regserver(const (char) *dllname, int flag) if (hMod) { printf("LoadLibraryA() %s\n", (flag ? "registered".ptr : "unregistered".ptr)); - pfn = GetProcAddress(hMod, fn); + pfn = cast(pfn_t) GetProcAddress(hMod, fn); printf("pfn = %p, fn = '%s'\n", pfn, fn); if (pfn && SUCCEEDED((*pfn)())) diff --git a/samples/dhry.d b/samples/dhry.d index f3fda20e916e..2a2ba41d384c 100644 --- a/samples/dhry.d +++ b/samples/dhry.d @@ -892,7 +892,7 @@ Boolean Func_3(Enumeration Enum_Par_Val) return (false); } /* Func_3 */ -version (Win32) +version (Windows) { import core.sys.windows.windows; diff --git a/samples/dserver.d b/samples/dserver.d index 77b7b05ccd07..854328896a7a 100644 --- a/samples/dserver.d +++ b/samples/dserver.d @@ -358,7 +358,7 @@ BOOL SetKeyAndValue(LPCSTR pszKey, LPCSTR pszSubkey, LPCSTR pszValue) if (null != pszValue) { if (RegSetValueExA(hKey, null, 0, REG_SZ, cast(BYTE *) pszValue, - (strlen(pszValue) + 1) * char.sizeof) != ERROR_SUCCESS) + cast(int)((strlen(pszValue) + 1) * char.sizeof)) != ERROR_SUCCESS) result = false; } diff --git a/samples/dserver64.def b/samples/dserver64.def new file mode 100644 index 000000000000..011040452dd4 --- /dev/null +++ b/samples/dserver64.def @@ -0,0 +1,6 @@ +EXPORTS + DllGetClassObject + DllCanUnloadNow + DllRegisterServer + DllUnregisterServer + diff --git a/samples/htmlget.d b/samples/htmlget.d index 3e30aded9aba..8b15ed600a17 100644 --- a/samples/htmlget.d +++ b/samples/htmlget.d @@ -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; } diff --git a/samples/win32.mak b/samples/win32.mak new file mode 100644 index 000000000000..31de69fbf53c --- /dev/null +++ b/samples/win32.mak @@ -0,0 +1,69 @@ +MODEL=32 +DMD=..\..\windows\bin\dmd +DFLAGS=-m$(MODEL) + +EXAMPLES = hello d2html dhry pi sieve wc wc2 \ + winsamp dserver$(MODEL) mydll htmlget listener + +all: $(EXAMPLES) + echo done + +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 +# dclient will fail unless run with administrator rights +dserver32: + $(DMD) dserver.d chello.d $(DFLAGS) dserver.def advapi32.lib ole32.lib user32.lib + $(DMD) dclient $(DFLAGS) ole32.lib uuid.lib + .\dclient.exe + +dserver64: + $(DMD) dserver.d chello.d $(DFLAGS) -L/DLL dserver64.def advapi32.lib ole32.lib user32.lib + $(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 diff --git a/win32.mak b/win32.mak index 3c6054f9ad1b..dfda4fe75fa9 100644 --- a/win32.mak +++ b/win32.mak @@ -9,4 +9,8 @@ auto-tester-test: cd test $(MAKE) cd .. + cd samples + gmake -f win32.mak DMD=..\src\dmd.exe MODEL=$(MODEL) "LIB=..\..\phobos;$(LIB)" \ + "DFLAGS=-I..\..\druntime\import -I..\..\phobos -m$(MODEL)" + cd ..