Import Amiga applications and desktop tools

This commit is contained in:
Alberto committed 2026-11-11 16:21:50 +01:00
commit 1c144c9a3c
347 files changed
+423483

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
#include <exec/types.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/socket.h>
#include <sys/ioctl.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include "tls.h"
struct Library*SocketBase;
static int probe(FILE*f,const char*host,const char*name,int expected){struct hostent*he;struct sockaddr_in a;int fd,n=-1,i,ok=0;LONG nb=1;he=gethostbyname((UBYTE*)host);if(!he){fprintf(f,"FAIL DNS %s\n",host);return 0;}memset(&a,0,sizeof(a));a.sin_len=sizeof(a);a.sin_family=AF_INET;a.sin_port=htons(6697);memcpy(&a.sin_addr,he->h_addr,4);fd=socket(AF_INET,SOCK_STREAM,0);if(fd<0)return 0;/* TCP establishment is bounded by stack timeout; TLS itself remains nonblocking. */if(connect(fd,(struct sockaddr*)&a,sizeof(a))<0){fprintf(f,"FAIL TCP %s\n",host);CloseSocket(fd);return 0;}IoctlSocket(fd,FIONBIO,(char*)&nb);if(tls_start(fd,name)){for(i=0;i<750;i++){n=tls_step();if(n)break;Delay(1);}if(expected&&n==1){fprintf(f,"PASS %s\n",tls_info);ok=1;}else if(!expected&&n<0){fprintf(f,"PASS wrong hostname rejected: %s\n",tls_error);ok=1;}else fprintf(f,"FAIL result=%d %s\n",n,tls_error);}else fprintf(f,"FAIL setup %s\n",tls_error);tls_close();CloseSocket(fd);return ok;}
int main(void){FILE*f=fopen("PROGDIR:tls-test.log","w");int a,b;if(!f)return 1;SocketBase=OpenLibrary("bsdsocket.library",4);if(!SocketBase){fclose(f);return 1;}a=probe(f,"irc.tilaro.net","irc.tilaro.net",1);b=probe(f,"irc.tilaro.net","invalid.example",0);fprintf(f,"%d/2 TLS tests passed\n",a+b);fclose(f);CloseLibrary(SocketBase);return a&&b?0:1;}