Compare commits

...

18 Commits

13 changed files with 78 additions and 390 deletions

6
.gitignore vendored
View File

@ -12,3 +12,9 @@ activate
test/report.txt
test/TestSuite.info
src/report.txt
src/BSDSocket_Labels.s
src/BSDSocket_Size.s
src/bsdsocket_lib.fd
src/bsdsocket_lvo.i
src/*.Lib
libs/

Binary file not shown.

8
API.md
View File

@ -338,8 +338,6 @@ out. There's no way to set this timeout, or cancel or override it via AMOS.
String with IP address, or blank string on error.
---
## Low Level
#### RESULT=Socket Setsockopt Int(Socket, Option, Value)
@ -386,8 +384,6 @@ Set or clear a socket bit in an fd_set.
* Address to that particular fd_set
* -1 if fd_set is out of range or socket is out of range.
---
#### RESULT=Socket Fdset Is Set(fd_set, Socket)
See if the particular socket remained after a Socket Select call.
@ -396,8 +392,6 @@ See if the particular socket remained after a Socket Select call.
* True or False if the socket is set or not
---
#### RESULT=Socket Select(Max Socket, Read fd_set, Write fd_set, Error fd_set, TimeoutMS)
Wait for the specified number of milliseconds. If any of the sockets
@ -409,4 +403,4 @@ how many sockets were left.
* 0 on timeout
* -1 on error
* Count of interesting sockets on success
* # of interesting sockets on success

View File

@ -153,6 +153,16 @@ Doing something cool with the extension?
timeouts using `Socket Async Wait Writing` to determine if the Internet
is available.
## Slot 18 taken already?
I'm also building releases for slots 9, 11, and 17. They're available for
separate download from each Release version 1.1.4 and on.
Note that you won't be able to load the test AMOS programs, or any other
progaam using the Slot 18 version, because AMOS uses the extension's slot
number in the saved tile. You'll have to export and import ASCII versions
of programs.
## Versioning
This project uses semantic versioning.

View File

@ -24,6 +24,22 @@ source.lines.each do |line|
end
end
FileUtils.cp 'src/AMOSPro_BSDSocket.Lib', 'AMOSPro_BSDSocket.Lib'
strings = []
Open3.popen2e('strings', 'AMOSPro_BSDSocket.Lib') do |stdin, stdout_and_stderr, wait_thr|
stdin.close
stdout_and_stderr.each { |l| strings << l }
wait_thr.join
end
unless strings.any? { |s| s[version] }
puts "Extension build doesn't match source version! Did you rebuild it yet on the Amiga?"
exit 1
end
FileUtils.mkdir_p 'dist'
build_base = 'build'
@ -31,11 +47,10 @@ project_name = 'BSDSocket-Extension'
build_dir = File.join(build_base, project_name)
FileUtils.rm_rf build_dir
FileUtils.rm_rf 'aminet'
FileUtils.mkdir_p build_dir
FileUtils.mkdir_p 'aminet'
FileUtils.cp 'src/AMOSPro_BSDSocket.Lib', 'AMOSPro_BSDSocket.Lib'
hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha")
[
@ -49,11 +64,18 @@ hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha")
FileUtils.cp file, target
end
gitignores = File.readlines('.gitignore').map(&:strip)
%w[
src
examples
].each do |dir|
FileUtils.cp_r dir, "#{build_dir}/#{dir}"
Dir["#{build_dir}/#{dir}/**/*"].each do |file|
FileUtils.rm file if gitignores.any? { |gi| File.fnmatch(gi, file) }
FileUtils.rm file if [/\.fd$/, /\.i$/].any? { |p| file[p] }
end
end
Dir['icons/**/*.info'].each do |info|
@ -62,23 +84,6 @@ Dir['icons/**/*.info'].each do |info|
FileUtils.cp info, target
end
Dir[File.join(build_base, '**', '*.uaem')].each do |file|
FileUtils.rm file
end
Dir[File.join(build_base, '**', '*.bak')].each do |file|
FileUtils.rm file
end
Dir[File.join(build_base, 'src', '*.Lib')].each do |file|
pp file
FileUtils.rm file
end
Dir[File.join(build_base, 'src', 'bsdsocket_l*')].each do |file|
FileUtils.rm file
end
Dir.chdir build_base do
Open3.popen2e(
'jlha', 'c', hackerbun_target,

24
bin/setup Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
mkdir -p stuff
if [ ! -d stuff/AMOS-Professional-Official ]; then
cd stuff
git clone https://code.hackerbun.dev/TheIndustriousRabbit/amos-professional.git
cd ..
fi
if [ ! -f src/bsdsocket_lib.fd ]; then
cd src
wget https://raw.githubusercontent.com/cnvogelg/amitools/master/amitools/data/fd/bsdsocket_lib.fd
cd ..
fi
echo "On the emulated Amiga, mount this folder at amos-pro-bsdsocket-extension: and run"
echo
echo "cd amos-pro-bsdsocket-extension:"
echo "cd src"
echo 'fd2pragma bsdsocket_lib.fd to "" special 20'
echo
echo "Then, to build the software, run:"
echo
echo "execute absdsocket"

Binary file not shown.

View File

@ -1,13 +1,14 @@
; BSDSocket Extension for AMOS Professional
; Copyright 2023 John Bintz
; Copyright 2023-2024 John Bintz
; Licensed under the MIT License
;
; Writing this code the right way, 25 years later.
; extension number 18
ExtNb equ 18-1
; this now comes from GenAm command line option
;ExtNb equ 18-1
Version MACRO
dc.b "1.1.4-20240426"
dc.b "1.1.4-20240502"
ENDM
VerNumber equ $1

View File

@ -1,40 +0,0 @@
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; BSDSocket.s, list of the library functions on the 02-05-2024 14:22:07
;
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L_Cold: set 0
L_SocketLibraryOpen: set 2
L_SocketLibraryClose: set 3
L_DoSocketSockaddrFree: set 4
L_SocketIPAddressPortToSockaddr:set 5
L_SocketCreateInetSocket:set 6
L_SocketConnect: set 7
L_SocketSendString: set 8
L_SocketSendData: set 9
L_SocketBind: set 10
L_SocketErrno: set 11
L_SocketListen: set 12
L_SocketAccept: set 13
L_SocketSetNonblocking: set 14
L_SocketSetsockoptInt: set 15
L_SocketGetsockoptInt: set 16
L_SocketFdsetZero: set 17
L_SocketFdsetSet: set 18
L_SocketFdsetIsSet: set 19
L_SocketSelect: set 20
L_SocketGetDebugArea: set 21
L_SocketGetHost: set 22
L_SocketGetPort: set 23
L_SocketInetNtoA: set 24
L_SocketRecvString: set 25
L_SocketRecvData: set 26
L_DoSocketLibraryClose: set 27
L_SocketWaitAsyncWriting:set 28
L_SocketWaitAsyncReading:set 29
L_SocketReuseAddr: set 30
L_MicrosecondsToTimeval:set 31
L_SetSockoptInt: set 32
L_DnsGetHostAddressByName:set 33
L_SocketSetTimeout: set 34
L_SocketCloseSocket: set 35
L_SocketHerrno: set 36

View File

@ -1,5 +0,0 @@
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; BSDSocket.s, library size on the 02-05-2024 14:22:07
;
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lib_Size equ 39

View File

@ -2,7 +2,7 @@ echo "***Assembling AMOSPro_BSDSocket.Lib"
assign AMOSPro_System: SYS:Development/AMOS_Pro
assign AMOSPro_Sources: amos-pro-bsdsocket-extension:stuff/AMOS-Professional-Official
AMOSPro_Sources:c/Library_Digest BSDSocket.s
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket.Lib
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket.Lib -e ExtNb=18-1
;delete >NIL: BSDSocket_Labels.s
;delete >NIL: BSDSocket_Size.s
FAILAT 21
@ -10,3 +10,11 @@ copy AMOSPro_System:APSystem/AMOSPro_BSDSocket.lib AMOSPro_System:APSystem/AMOSP
FAILAT 10
copy AMOSPro_BSDSocket.Lib AMOSPro_System:APSystem/
apcmp "/test/TestSuite.amos" inclib
echo "Build for slot 9"
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket_Slot9.Lib -e ExtNb=9-1
echo "Build for slot 11"
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket_Slot11.Lib -e ExtNb=11-1
echo "Build for slot 17"
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket_Slot17.Lib -e ExtNb=17-1

View File

@ -1,107 +0,0 @@
##base _SocketBase
##public
##bias 30
socket(domain,type,protocol)(d0/d1/d2)
bind(sock,name,namelen)(d0/a0/d1)
listen(sock,backlog)(d0/d1)
accept(sock,addr,addrlen)(d0/a0/a1)
connect(sock,name,namelen)(d0/a0/d1)
sendto(sock,buf,len,flags,to,tolen)(d0/a0/d1/d2/a1/d3)
send(sock,buf,len,flags)(d0/a0/d1/d2)
recvfrom(sock,buf,len,flags,addr,addrlen)(d0/a0/d1/d2/a1/a2)
recv(sock,buf,len,flags)(d0/a0/d1/d2)
shutdown(sock,how)(d0/d1)
setsockopt(sock,level,optname,optval,optlen)(d0/d1/d2/a0/d3)
getsockopt(sock,level,optname,optval,optlen)(d0/d1/d2/a0/a1)
getsockname(sock,name,namelen)(d0/a0/a1)
getpeername(sock,name,namelen)(d0/a0/a1)
IoctlSocket(sock,req,argp)(d0/d1/a0)
CloseSocket(sock)(d0)
WaitSelect(nfds,read_fds,write_fds,except_fds,timeout,signals)(d0/a0/a1/a2/a3/d1)
SetSocketSignals(int_mask,io_mask,urgent_mask)(d0/d1/d2)
getdtablesize()()
ObtainSocket(id,domain,type,protocol)(d0/d1/d2/d3)
ReleaseSocket(sock,id)(d0/d1)
ReleaseCopyOfSocket(sock,id)(d0/d1)
Errno()()
SetErrnoPtr(errno_ptr,size)(a0/d0)
Inet_NtoA(ip)(d0)
inet_addr(cp)(a0)
Inet_LnaOf(in)(d0)
Inet_NetOf(in)(d0)
Inet_MakeAddr(net,host)(d0/d1)
inet_network(cp)(a0)
gethostbyname(name)(a0)
gethostbyaddr(addr,len,type)(a0/d0/d1)
getnetbyname(name)(a0)
getnetbyaddr(net,type)(d0/d1)
getservbyname(name,proto)(a0/a1)
getservbyport(port,proto)(d0/a0)
getprotobyname(name)(a0)
getprotobynumber(proto)(d0)
vsyslog(pri,msg,args)(d0/a0/a1)
Dup2Socket(old_socket,new_socket)(d0/d1)
sendmsg(sock,msg,flags)(d0/a0/d1)
recvmsg(sock,msg,flags)(d0/a0/d1)
gethostname(name,namelen)(a0/d0)
gethostid()()
SocketBaseTagList(tags)(a0)
GetSocketEvents(event_ptr)(a0)
##bias 366
bpf_open(channel)(d0)
bpf_close(channel)(d0)
bpf_read(channel,buffer,len)(d0/a0/d1)
bpf_write(channel,buffer,len)(d0/a0/d1)
bpf_set_notify_mask(channel,signal_mask)(d1/d0)
bpf_set_interrupt_mask(channel,signal_mask)(d0/d1)
bpf_ioctl(channel,command,buffer)(d0/d1/a0)
bpf_data_waiting(channel)(d0)
AddRouteTagList(tags)(a0)
DeleteRouteTagList(tags)(a0)
##bias 432
FreeRouteInfo(buf)(a0)
GetRouteInfo(address_family,flags)(d0/d1)
AddInterfaceTagList(interface_name,device_name,unit,tags)(a0/a1/d0/a2)
ConfigureInterfaceTagList(interface_name,tags)(a0/a1)
ReleaseInterfaceList(list)(a0)
ObtainInterfaceList()()
QueryInterfaceTagList(interface_name,tags)(a0/a1)
CreateAddrAllocMessageA(version,protocol,interface_name,result_ptr,tags)(d0/d1/a0/a1/a2)
DeleteAddrAllocMessage(aam)(a0)
BeginInterfaceConfig(message)(a0)
AbortInterfaceConfig(message)(a0)
AddNetMonitorHookTagList(type,hook,tags)(d0/a0/a1)
RemoveNetMonitorHook(hook)(a0)
GetNetworkStatistics(type,version,destination,size)(d0/d1/a0/d2)
AddDomainNameServer(address)(a0)
RemoveDomainNameServer(address)(a0)
ReleaseDomainNameServerList(list)(a0)
ObtainDomainNameServerList()()
setnetent(stay_open)(d0)
endnetent()()
getnetent()()
setprotoent(stay_open)(d0)
endprotoent()()
getprotoent()()
setservent(stay_open)(d0)
endservent()()
getservent()()
inet_aton(cp,addr)(a0/a1)
inet_ntop(af,src,dst,size)(d0/a0/a1/d1)
inet_pton(af,src,dst)(d0/a0/a1)
In_LocalAddr(address)(d0)
In_CanForward(address)(d0)
mbuf_copym(m,off,len)(a0/d0/d1)
mbuf_copyback(m,off,len,cp)(a0/d0/d1/a1)
mbuf_copydata(m,off,len,cp)(a0/d0/d1/a1)
mbuf_free(m)(a0)
mbuf_freem(m)(a0)
mbuf_get()()
mbuf_gethdr()()
mbuf_prepend(m,len)(a0/d0)
mbuf_cat(m,n)(a0/a1)
mbuf_adj(mp,req_len)(a0/d0)
mbuf_pullup(m,len)(a0/d0)
ProcessIsServer(pr)(a0)
ObtainServerSocket()()
##end

View File

@ -1,208 +0,0 @@
IFND LIBRARIES_BSDSOCKET_LVO_I
LIBRARIES_BSDSOCKET_LVO_I SET 1
XDEF _LVOsocket
XDEF _LVObind
XDEF _LVOlisten
XDEF _LVOaccept
XDEF _LVOconnect
XDEF _LVOsendto
XDEF _LVOsend
XDEF _LVOrecvfrom
XDEF _LVOrecv
XDEF _LVOshutdown
XDEF _LVOsetsockopt
XDEF _LVOgetsockopt
XDEF _LVOgetsockname
XDEF _LVOgetpeername
XDEF _LVOIoctlSocket
XDEF _LVOCloseSocket
XDEF _LVOWaitSelect
XDEF _LVOSetSocketSignals
XDEF _LVOgetdtablesize
XDEF _LVOObtainSocket
XDEF _LVOReleaseSocket
XDEF _LVOReleaseCopyOfSocket
XDEF _LVOErrno
XDEF _LVOSetErrnoPtr
XDEF _LVOInet_NtoA
XDEF _LVOinet_addr
XDEF _LVOInet_LnaOf
XDEF _LVOInet_NetOf
XDEF _LVOInet_MakeAddr
XDEF _LVOinet_network
XDEF _LVOgethostbyname
XDEF _LVOgethostbyaddr
XDEF _LVOgetnetbyname
XDEF _LVOgetnetbyaddr
XDEF _LVOgetservbyname
XDEF _LVOgetservbyport
XDEF _LVOgetprotobyname
XDEF _LVOgetprotobynumber
XDEF _LVOvsyslog
XDEF _LVODup2Socket
XDEF _LVOsendmsg
XDEF _LVOrecvmsg
XDEF _LVOgethostname
XDEF _LVOgethostid
XDEF _LVOSocketBaseTagList
XDEF _LVOGetSocketEvents
XDEF _LVObpf_open
XDEF _LVObpf_close
XDEF _LVObpf_read
XDEF _LVObpf_write
XDEF _LVObpf_set_notify_mask
XDEF _LVObpf_set_interrupt_mask
XDEF _LVObpf_ioctl
XDEF _LVObpf_data_waiting
XDEF _LVOAddRouteTagList
XDEF _LVODeleteRouteTagList
XDEF _LVOFreeRouteInfo
XDEF _LVOGetRouteInfo
XDEF _LVOAddInterfaceTagList
XDEF _LVOConfigureInterfaceTagList
XDEF _LVOReleaseInterfaceList
XDEF _LVOObtainInterfaceList
XDEF _LVOQueryInterfaceTagList
XDEF _LVOCreateAddrAllocMessageA
XDEF _LVODeleteAddrAllocMessage
XDEF _LVOBeginInterfaceConfig
XDEF _LVOAbortInterfaceConfig
XDEF _LVOAddNetMonitorHookTagList
XDEF _LVORemoveNetMonitorHook
XDEF _LVOGetNetworkStatistics
XDEF _LVOAddDomainNameServer
XDEF _LVORemoveDomainNameServer
XDEF _LVOReleaseDomainNameServerList
XDEF _LVOObtainDomainNameServerList
XDEF _LVOsetnetent
XDEF _LVOendnetent
XDEF _LVOgetnetent
XDEF _LVOsetprotoent
XDEF _LVOendprotoent
XDEF _LVOgetprotoent
XDEF _LVOsetservent
XDEF _LVOendservent
XDEF _LVOgetservent
XDEF _LVOinet_aton
XDEF _LVOinet_ntop
XDEF _LVOinet_pton
XDEF _LVOIn_LocalAddr
XDEF _LVOIn_CanForward
XDEF _LVOmbuf_copym
XDEF _LVOmbuf_copyback
XDEF _LVOmbuf_copydata
XDEF _LVOmbuf_free
XDEF _LVOmbuf_freem
XDEF _LVOmbuf_get
XDEF _LVOmbuf_gethdr
XDEF _LVOmbuf_prepend
XDEF _LVOmbuf_cat
XDEF _LVOmbuf_adj
XDEF _LVOmbuf_pullup
XDEF _LVOProcessIsServer
XDEF _LVOObtainServerSocket
_LVOsocket EQU -30
_LVObind EQU -36
_LVOlisten EQU -42
_LVOaccept EQU -48
_LVOconnect EQU -54
_LVOsendto EQU -60
_LVOsend EQU -66
_LVOrecvfrom EQU -72
_LVOrecv EQU -78
_LVOshutdown EQU -84
_LVOsetsockopt EQU -90
_LVOgetsockopt EQU -96
_LVOgetsockname EQU -102
_LVOgetpeername EQU -108
_LVOIoctlSocket EQU -114
_LVOCloseSocket EQU -120
_LVOWaitSelect EQU -126
_LVOSetSocketSignals EQU -132
_LVOgetdtablesize EQU -138
_LVOObtainSocket EQU -144
_LVOReleaseSocket EQU -150
_LVOReleaseCopyOfSocket EQU -156
_LVOErrno EQU -162
_LVOSetErrnoPtr EQU -168
_LVOInet_NtoA EQU -174
_LVOinet_addr EQU -180
_LVOInet_LnaOf EQU -186
_LVOInet_NetOf EQU -192
_LVOInet_MakeAddr EQU -198
_LVOinet_network EQU -204
_LVOgethostbyname EQU -210
_LVOgethostbyaddr EQU -216
_LVOgetnetbyname EQU -222
_LVOgetnetbyaddr EQU -228
_LVOgetservbyname EQU -234
_LVOgetservbyport EQU -240
_LVOgetprotobyname EQU -246
_LVOgetprotobynumber EQU -252
_LVOvsyslog EQU -258
_LVODup2Socket EQU -264
_LVOsendmsg EQU -270
_LVOrecvmsg EQU -276
_LVOgethostname EQU -282
_LVOgethostid EQU -288
_LVOSocketBaseTagList EQU -294
_LVOGetSocketEvents EQU -300
_LVObpf_open EQU -366
_LVObpf_close EQU -372
_LVObpf_read EQU -378
_LVObpf_write EQU -384
_LVObpf_set_notify_mask EQU -390
_LVObpf_set_interrupt_mask EQU -396
_LVObpf_ioctl EQU -402
_LVObpf_data_waiting EQU -408
_LVOAddRouteTagList EQU -414
_LVODeleteRouteTagList EQU -420
_LVOFreeRouteInfo EQU -432
_LVOGetRouteInfo EQU -438
_LVOAddInterfaceTagList EQU -444
_LVOConfigureInterfaceTagList EQU -450
_LVOReleaseInterfaceList EQU -456
_LVOObtainInterfaceList EQU -462
_LVOQueryInterfaceTagList EQU -468
_LVOCreateAddrAllocMessageA EQU -474
_LVODeleteAddrAllocMessage EQU -480
_LVOBeginInterfaceConfig EQU -486
_LVOAbortInterfaceConfig EQU -492
_LVOAddNetMonitorHookTagList EQU -498
_LVORemoveNetMonitorHook EQU -504
_LVOGetNetworkStatistics EQU -510
_LVOAddDomainNameServer EQU -516
_LVORemoveDomainNameServer EQU -522
_LVOReleaseDomainNameServerList EQU -528
_LVOObtainDomainNameServerList EQU -534
_LVOsetnetent EQU -540
_LVOendnetent EQU -546
_LVOgetnetent EQU -552
_LVOsetprotoent EQU -558
_LVOendprotoent EQU -564
_LVOgetprotoent EQU -570
_LVOsetservent EQU -576
_LVOendservent EQU -582
_LVOgetservent EQU -588
_LVOinet_aton EQU -594
_LVOinet_ntop EQU -600
_LVOinet_pton EQU -606
_LVOIn_LocalAddr EQU -612
_LVOIn_CanForward EQU -618
_LVOmbuf_copym EQU -624
_LVOmbuf_copyback EQU -630
_LVOmbuf_copydata EQU -636
_LVOmbuf_free EQU -642
_LVOmbuf_freem EQU -648
_LVOmbuf_get EQU -654
_LVOmbuf_gethdr EQU -660
_LVOmbuf_prepend EQU -666
_LVOmbuf_cat EQU -672
_LVOmbuf_adj EQU -678
_LVOmbuf_pullup EQU -684
_LVOProcessIsServer EQU -690
_LVOObtainServerSocket EQU -696
ENDC