aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gemini-windows.prj98
-rw-r--r--network.F90 (renamed from network.f90)18
-rw-r--r--test_ssl.f907
-rw-r--r--wsa.f9046
4 files changed, 161 insertions, 8 deletions
diff --git a/gemini-windows.prj b/gemini-windows.prj
new file mode 100644
index 0000000..44c4108
--- /dev/null
+++ b/gemini-windows.prj
@@ -0,0 +1,98 @@
+{
+ "Root":{
+ "Folders":[{
+ "Folders":[],
+ "Name":"+samples",
+ "Files":[{
+ "filename":".\\samples\\sample1.gmi",
+ "enabled":"1"
+ }]
+ },{
+ "Folders":[],
+ "Name":"+ssl",
+ "Files":[{
+ "filename":".\\jessl.f90",
+ "enabled":"1"
+ },{
+ "filename":".\\network.F90",
+ "enabled":"1"
+ },{
+ "filename":".\\test_ssl.f90",
+ "enabled":"1"
+ },{
+ "filename":".\\wsa.f90",
+ "enabled":"1"
+ }]
+ }],
+ "Name":"+gemini-windows (target.exe)",
+ "Files":[{
+ "filename":".\\dumb_render.f90",
+ "enabled":"1"
+ },{
+ "filename":".\\files.f90",
+ "enabled":"1"
+ },{
+ "filename":".\\layout.f90",
+ "enabled":"1"
+ },{
+ "filename":".\\render.f90",
+ "enabled":"1"
+ },{
+ "filename":".\\test.f90",
+ "enabled":"0"
+ }]
+ },
+ "Name":"gemini-windows (target.exe)",
+ "Options":{
+ "Compiler Options":{
+ "Fortran Flags":"",
+ "Link Flags":"-lssl -lcrypto -lws2_32 -lcrypt32",
+ "C Flags":""
+ },
+ "Architecture":1,
+ "Type":0,
+ "Revision":2,
+ "Windows GUI":0,
+ "File Options":{
+ "Library Directories":["Default Add-On Directory","../../Workspace/git/libvncserver/openssl-1.1.1f-win64-mingw/lib"],
+ "Build Directory":"build",
+ "Module Directory":"modules",
+ "Include Directories":["Default Add-On Include Directory"]
+ },
+ "Target":"target.exe",
+ "Fortran Options":{
+ "Use C Preprocessor":"false",
+ "Runtime Diagnostics":"false",
+ "Cray Pointers":"false",
+ "Enable OpenMP":"false",
+ "Enable Coarrays":"false",
+ "Default Double for Real":"false"
+ },
+ "Code Generation Options":{
+ "CPU Specific":"false",
+ "Processor":"generic",
+ "Aggressive Loops":"false",
+ "Debugging":"true",
+ "Optimization Mode":0,
+ "Profiling":"false"
+ },
+ "Build Dependencies":1,
+ "Launch Options":{
+ "Working Directory":"",
+ "Launch Using MPI":"false",
+ "Keep Console":"true",
+ "External Console":"false",
+ "Command Line Arguments":"-g samples\\sample1.gmi",
+ "Build Before Launch":"true"
+ },
+ "Build Options":{
+ "Makefile":"Makefile",
+ "Auto Makefile":"true"
+ },
+ "Linker Options":{
+ "Static Linking Mode":0,
+ "Link MPI Library":"false",
+ "Link LAPACK":0
+ }
+ }
+} \ No newline at end of file
diff --git a/network.f90 b/network.F90
index a4a3ddc..2130841 100644
--- a/network.f90
+++ b/network.F90
@@ -8,6 +8,12 @@ implicit none
integer(kind=c_int), parameter::SOCK_STREAM = 1
+#ifdef WINDOWS
+ integer, parameter::hostent_int_kind = c_short
+#else
+ integer, parameter::hostent_int_kind = c_int
+#endif
+
type, bind(c) :: in_addr
integer(kind=c_int32_t)::s_addr
end type
@@ -20,11 +26,11 @@ implicit none
end type
type, bind(c) :: hostent_c
- type(c_ptr)::h_name !official name of host */
- type(c_ptr)::h_aliases !alias list */
- integer(kind=c_int):: h_addrtype !host address type */
- integer(kind=c_int):: h_length !length of address */
- type(c_ptr)::h_addr_list !list of addresses */
+ type(c_ptr)::h_name !official name of host */
+ type(c_ptr)::h_aliases !alias list */
+ integer(kind=hostent_int_kind):: h_addrtype !host address type */
+ integer(kind=hostent_int_kind):: h_length !length of address */
+ type(c_ptr)::h_addr_list !list of addresses */
end type
! Let's keep this simple...
@@ -166,7 +172,7 @@ implicit none
do while(h_name(i) /= c_null_char)
i = i + 1
end do
- allocate(character(len=i) :: res%h_name)
+ allocate(character(len=i-1) :: res%h_name)
i = 1
do while(h_name(i) /= c_null_char)
res%h_name(i:i) = h_name(i)
diff --git a/test_ssl.f90 b/test_ssl.f90
index 0e169c1..04386d4 100644
--- a/test_ssl.f90
+++ b/test_ssl.f90
@@ -1,6 +1,7 @@
program test_ssl
use jessl
use network
+use wsa_network, only: windows_network_startup => startup
implicit none
type(sockaddr_in), target::sa
@@ -8,10 +9,12 @@ implicit none
type(simple_hostent)::hent
+ call windows_network_startup()
+
hent = gethostbyname("google.com")
if(allocated(hent%h_name)) then
- !Print *, "host: ", hent%h_name
- !Print *, "addr: ", hent%h_addr4
+ Print *, "host: ", hent%h_name
+ Print *, "addr: ", hent%h_addr4
else
Print *, "Failure"
stop
diff --git a/wsa.f90 b/wsa.f90
new file mode 100644
index 0000000..c46b097
--- /dev/null
+++ b/wsa.f90
@@ -0,0 +1,46 @@
+module wsa_network
+use iso_c_binding
+implicit none
+
+ integer, parameter::wsa_description_length_plus_1 = 256
+
+ type, bind(c) :: wsadata
+ integer(kind=c_int16_t)::wVersion
+ integer(kind=c_int16_t)::wHighVersion
+ integer(kind=c_short)::iMaxSockets
+ integer(kind=c_short)::iMaxUdpDg
+
+ type(c_ptr)::lpVendorInfo
+ character(len=1, kind=c_char), dimension(wsa_description_length_plus_1)::szDescription
+ character(len=1, kind=c_char), dimension(wsa_description_length_plus_1)::szSystemStatus
+ end type
+
+contains
+
+ subroutine startup()
+ use iso_c_binding
+ implicit none
+
+ interface
+ function wsa_startup(v, p) bind(c, name="WSAStartup")
+ use iso_c_binding
+ integer(kind=c_int16_t), value::v
+ type(c_ptr), value::p
+ integer(kind=c_int)::wsa_startup
+ end function wsa_startup
+ end interface
+
+ type(wsadata), target::startup_data
+ integer::res
+
+ ! need to use wVersionRequested = MAKEWORD(2, 2);
+
+
+ res = wsa_startup(int(z'0202', kind=c_int16_t), c_loc(startup_data))
+ if(res /= 0) then
+ Print *, "Windows Networking failed to start"
+ Print *, "Error=", res
+ stop
+ end if
+ end subroutine startup
+end module wsa_network