Initial commit

This commit is contained in:
Carsten Sonne Larsen 2017-09-01 00:03:35 +02:00
commit bd6f825d46
12 changed files with 2097 additions and 0 deletions

26
Makefile Normal file
View File

@ -0,0 +1,26 @@
# Portable Makefile generated by configure
all: http_ping help
CC = m68k-amigaos-gcc
CFLAGS = -O2 -noixemul $(SSL_DEFS) $(SSL_INC) -Iinclude -Wall
LDFLAGS = -s -lm $(SSL_LIBS)
http_ping.o: http_ping.c port.h
http_ping_amiga.o: http_ping_amiga.c version.h
time_timer.o: time_timer.c
http_ping: http_ping.o http_ping_amiga.o time_timer.o
${CC} ${CFLAGS} -o http_ping http_ping.o http_ping_amiga.o time_timer.o ${LDFLAGS}
help:
nroff -man http_ping.1 > http_ping.help
clean:
rm -f http_ping.o http_ping_amiga.o time_timer.o http_ping http_ping.help
depend:
@echo Dependencies already done

22
README Normal file
View File

@ -0,0 +1,22 @@
http_ping - measure HTTP latency
http_ping runs an HTTP fetch every few seconds, timing how long it takes.
See the manual entry for more details.
Files in this distribution:
README this
Makefile guess
http_ping.c source file
http_ping.1 manual entry
port.h portability defines
To build: If you're on a SysV-like machine (which includes old Linux systems
but not new Linux systems), edit the Makefile and uncomment the SYSV_LIBS
line. If you're doing SSL, uncomment those lines too. Otherwise, just do
a make.
Feedback is welcome - send bug reports, enhancements, checks, money
orders, etc. to the addresses below.
Jef Poskanzer jef@mail.acme.com http://www.acme.com/jef/

126
configure vendored Normal file
View File

@ -0,0 +1,126 @@
#!/bin/sh
#
# Copyright (c) 2015 Carsten Larsen
# Copyright (c) 2014 Poul-Henning Kamp
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
set -e
# CONFIGURE: If you want to compile in support for https, uncomment these
# definitions. You will need to have already built OpenSSL, available at
# http://www.openssl.org/ Make sure the SSL_TREE definition points to the
# tree with your OpenSSL installation - depending on how you installed it,
# it may be in /usr/local instead of /usr/local/ssl.
#SSL_TREE = /usr/local/ssl
#SSL_DEFS = -DUSE_SSL
#SSL_INC = -I$(SSL_TREE)/include
#SSL_LIBS = -L$(SSL_TREE)/lib -lssl -lcrypto
EXEC='http_ping'
HDRS='
port.h
version.h
'
SRCS='
http_ping.c
http_ping_amiga.c
time_timer.c
'
if make -v 2>&1 | grep GNU > /dev/null 2>&1 ; then
echo "make is GNU make."
VALID=true
#else
# echo "Wrong version of make."
# VALID=false
fi
if $VALID ; then
(
echo '# Portable Makefile generated by configure'
echo ''
echo "all: $EXEC help"
echo ''
if [ -n "$1" ] && [ $1 = "AMIGA" ] ; then
echo 'CC = m68k-amigaos-gcc'
echo "CFLAGS = -O2 -noixemul \$(SSL_DEFS) \$(SSL_INC) -Iinclude -Wall"
echo "LDFLAGS = -s -lm \$(SSL_LIBS)"
elif [ -n "$1" ] && [ $1 = "AROS" ] ; then
echo 'CC = gcc'
echo "CFLAGS = -O2 -noixemul \$(SSL_DEFS) \$(SSL_INC) -Iinclude -Wall"
echo "LDFLAGS = -lm \$(SSL_LIBS)"
else
echo "CFLAGS = -O2 -Wall -Werror"
echo "LDFLAGS = -s -lm \$(SSL_LIBS)"
fi
echo ''
for f in ${HDRS}
do
b=`basename $f .h`
i=`sed -n -e '/#include.*"/{
s/"$//
s/.*"//
p
}' $f | sort -u`
if [ "x${i}" != "x" ] ; then
echo "${b}.h: " ${i}
echo " touch ${b}.h"
echo
fi
done
l=""
for f in ${SRCS}
do
b=`basename $f .c`
i=`sed -n -e '/#include.*"/{
s/"$//
s/.*"//
p
}' $f | sort -u`
echo "${b}.o: ${b}.c" ${i}
echo
l="${l} ${b}.o"
done
echo
echo "$EXEC: ${l}"
echo " \${CC} \${CFLAGS} -o $EXEC ${l} \${LDFLAGS}"
echo
echo "help:"
echo " nroff -man $EXEC.1 > $EXEC.help"
echo
echo "clean:"
echo " rm -f ${l} $EXEC $EXEC.help"
echo
echo "depend:"
echo " @echo Dependencies already done"
) > Makefile
echo "Makefile generated"
fi

75
http_ping.1 Normal file
View File

@ -0,0 +1,75 @@
.TH http_ping 1 "01 November 2015"
.SH NAME
http_ping - measure HTTP latency
.SH SYNOPSIS
.B http_ping
.RB [ -count
.IR n ]
.RB [ -interval
.IR n ]
.RB [ -quiet ]
.RB [ -proxy
.IR host:port ]
.I url
.SH DESCRIPTION
.PP
.I http_ping
runs an HTTP fetch every few seconds, timing how long it takes.
.PP
Sample run:
.nf
% http_ping http://www.example.com/
7816 bytes from http://www.example.com/: 246.602 ms (9.923c/23.074r/213.605d)
7816 bytes from http://www.example.com/: 189.997 ms (11.619c/22.971r/155.407d)
7816 bytes from http://www.example.com/: 190.463 ms (8.994c/25.091r/156.378d)
7816 bytes from http://www.example.com/: 190.07 ms (9.234c/23.9r/156.936d)
7816 bytes from http://www.example.com/: 190.706 ms (10.142c/46.579r/133.985d)
^C
--- http://www.example.com/ http_ping statistics ---
5 fetches started, 5 completed (100%), 0 failures (0%), 0 timeouts (0%)
total min/avg/max = 189.997/201.568/246.602 ms
connect min/avg/max = 8.994/9.9824/11.619 ms
response min/avg/max = 22.971/28.323/46.579 ms
data min/avg/max = 133.985/163.262/213.605 ms
.fi
.SH OPTIONS
.TP
.B -count
Stop after the specified number of fetches.
Without this option, http_ping will continue until interrupted.
.TP
.B -interval
Wait the specified number of seconds between fetches.
The default is five seconds.
.TP
.B -quiet
Only display the summary info at the end.
.TP
.B -proxy
Specifies a proxy host and port to use.
.SH "SEE ALSO"
http_load, http_get, ping
.SH AUTHOR
Copyright © 1998,1999,2001,2002 by Jef Poskanzer <jef@mail.acme.com>.
Copyright © 2015 by Carsten Larsen <carsten.larsen@mail.com>.
All rights reserved.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.

1181
http_ping.c Normal file

File diff suppressed because it is too large Load Diff

53
http_ping.guide Normal file
View File

@ -0,0 +1,53 @@
@database http_ping.guide
@author Carsten Larsen
@(c) Carsten Larsen
@$VER: http_ping.guide 1.10 (01.11.2015)
@node Main "HTTP Ping"
@title "HTTP Ping"
NAME
http_ping - measure HTTP latency
SYNOPSIS
http_ping [-count n] [-interval n] [-quiet] [-proxy host:port] url
DESCRIPTION
http_ping runs an HTTP fetch every few seconds, timing how long it
takes.
Sample run:
% http_ping http://www.example.com/
7816 bytes from http://www.example.com/: 246.602 ms (9.923c/23.074r/213.605d)
7816 bytes from http://www.example.com/: 189.997 ms (11.619c/22.971r/155.407d)
7816 bytes from http://www.example.com/: 190.463 ms (8.994c/25.091r/156.378d)
7816 bytes from http://www.example.com/: 190.07 ms (9.234c/23.9r/156.936d)
7816 bytes from http://www.example.com/: 190.706 ms (10.142c/46.579r/133.985d)
^C
--- http://www.example.com/ http_ping statistics ---
5 fetches started, 5 completed (100%), 0 failures (0%), 0 timeouts (0%)
total min/avg/max = 189.997/201.568/246.602 ms
connect min/avg/max = 8.994/9.9824/11.619 ms
response min/avg/max = 22.971/28.323/46.579 ms
data min/avg/max = 133.985/163.262/213.605 ms
OPTIONS
-count Stop after the specified number of fetches. Without this
option, http_ping will continue until interrupted.
-interval
Wait the specified number of seconds between fetches. The
default is five seconds.
-quiet Only display the summary info at the end.
-proxy Specifies a proxy host and port to use.
SEE ALSO
http_load, http_get, ping
AUTHOR
Copyright (C) 1998,1999,2001,2002 by Jef Poskanzer <jef@mail.acme.com>.
Copyright (C) 2015 by Carsten Larsen <carsten.larsen@mail.com>.
All rights reserved.
@endnode

98
http_ping_amiga.c Normal file
View File

@ -0,0 +1,98 @@
/*
* Written by Carsten Larsen.
* Public domain.
*/
#include <stdio.h>
#include <stdlib.h>
#include <clib/exec_protos.h>
#include <clib/timer_protos.h>
#include <dos/var.h>
#include <devices/timer.h>
#include <libraries/locale.h>
#include <sys/time.h>
#include "version.h"
#define OPEN_ERROR "Cannot open %s.\n"
#define OPEN_VER_ERROR "Cannot open %s (%d.0)\n"
#define DOSLIB_NAME "dos.library"
#define DOSLIB_REV 33L
#define BSDLIB_NAME "bsdsocket.library"
#define BSDLIB_REV 03L
int CreateTimer();
void DeleteTimer();
const char *vers = "\0$VER: " PACKAGE_NAME " " PACKAGE_VERSION " (" PACKAGE_DATE ")";
struct Library *DOSBase;
struct Library *SocketBase;
void amiga_open_error(char *name)
{
printf(OPEN_ERROR, name);
}
void amiga_open_lib_error(char *name, int version)
{
printf(OPEN_VER_ERROR, name, version);
}
void close_libs()
{
if (DOSBase != NULL) {
CloseLibrary(DOSBase);
DOSBase = NULL;
}
if (SocketBase != NULL) {
CloseLibrary(SocketBase);
SocketBase = NULL;
}
}
int open_libs()
{
atexit(close_libs);
if(!(DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV))) {
amiga_open_lib_error(DOSLIB_NAME, DOSLIB_REV);
return 5;
}
if(!(SocketBase = OpenLibrary((STRPTR)BSDLIB_NAME, BSDLIB_REV))) {
amiga_open_lib_error(BSDLIB_NAME, BSDLIB_REV);
return 5;
}
return 0;
}
int gettimeofday(struct timeval *tv, struct timezone* tz)
{
struct timeval tv1;
if (CreateTimer() != 0) {
tv->tv_secs = 0;
tv->tv_micro = 0;
return -1;
}
GetSysTime(&tv1);
*tv = tv1;
DeleteTimer();
return 0;
}
void srandom(unsigned int x) { }
#ifdef USE_SSL
int getuid() { return 55; }
void sigaction(int signum, void *act, void *oldact) { }
void tcgetattr(int fd, void *termios_p) { }
int tcsetattr(int fd, void *termios_p) { return 0; }
#endif

View File

@ -0,0 +1,116 @@
/*
* Copyright (c) 2015 Carsten Larsen
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef _SOCKET_AMITCP_H
#define _SOCKET_AMITCP_H
//--------------------------------------------------------------------------//
#define AMITCP_BASE_NAME SocketBase
#include "inline/amitcp.h"
//--------------------------------------------------------------------------//
#define socket Socket
#define bind Bind
#define listen Listen
#define accept Accept
#define connect Connect
#define send Send
#define sendto SendTo
#define sendmsg SendMsg
#define recv Recv
#define recvfrom RecvFrom
#define recvmsg RecvMsg
#define select Select
#define shutdown ShutDown
#define setsockopt SetSockOpt
#define getsockopt GetSockOpt
#define getsockname GetSockName
#define getpeername GetPeerName
#define inet_addr Inet_Addr
#define inet_network Inet_Network
#define inet_ntoa Inet_NtoA
#define gethostbyname GetHostByName
#define gethostbyaddr GetHostByAddr
#define getnetbyname GetNetByName
#define getnetbyaddr GetNetByAddr
#define getservbyname GetServByName
#define getservbyport GetServByPort
#define getprotobyname GetProtoByName
#define getprotobynumber GetProtoByNumber
#define getdtablesize GetDTableSize
#define gethostname GetHostName
#define gethostid GetHostId
#define vsyslog SyslogA
#define syslog Syslog
//--------------------------------------------------------------------------//
#define Accept TCP_Accept
#define Bind TCP_Bind
#define CloseSocket TCP_CloseSocket
#define Connect TCP_Connect
#define Dup2Socket TCP_Dup2Socket
#define Errno TCP_Errno
#define GetDTableSize TCP_GetDTableSize
#define GetHostByAddr TCP_GetHostByAddr
#define GetHostByName TCP_GetHostByName
#define GetHostId TCP_GetHostId
#define GetHostName TCP_GetHostName
#define GetNetByAddr TCP_GetNetByAddr
#define GetNetByName TCP_GetNetByName
#define GetPeerName TCP_GetPeerName
#define GetProtoByName TCP_GetProtoByName
#define GetProtoByNumber TCP_GetProtoByNumber
#define GetServByName TCP_GetServByName
#define GetServByPort TCP_GetServByPort
#define GetSockName TCP_GetSockName
#define GetSockOpt TCP_GetSockOpt
#define GetSocketEvents TCP_GetSocketEvents
#define Inet_Addr TCP_Inet_Addr
#define Inet_LnaOf TCP_Inet_LnaOf
#define Inet_MakeAddr TCP_Inet_MakeAddr
#define Inet_NetOf TCP_Inet_NetOf
#define Inet_Network TCP_Inet_Network
#define Inet_NtoA(x) TCP_Inet_NtoA((x).s_addr)
#define IoctlSocket TCP_IoctlSocket
#define Listen TCP_Listen
#define ObtainSocket TCP_ObtainSocket
#define Recv TCP_Recv
#define RecvFrom TCP_RecvFrom
#define RecvMsg TCP_RecvMsg
#define ReleaseCopyOfSocket TCP_ReleaseCopyOfSocket
#define ReleaseSocket TCP_ReleaseSocket
#define Send TCP_Send
#define SendMsg TCP_SendMsg
#define SendTo TCP_SendTo
#define SetErrnoPtr TCP_SetErrnoPtr
#define SetSockOpt TCP_SetSockOpt
#define SetSocketSignals TCP_SetSocketSignals
#define ShutDown TCP_ShutDown
#define Socket TCP_Socket
#define SocketBaseTagList TCP_SocketBaseTagList
#define SocketBaseTags TCP_SocketBaseTags
#define SyslogA TCP_SyslogA
#define WaitSelect TCP_WaitSelect
#define Select(n,r,w,e,t) TCP_WaitSelect(n,r,w,e,t,0)
//--------------------------------------------------------------------------//
#endif

203
include/inline/amitcp.h Normal file
View File

@ -0,0 +1,203 @@
/* Automatically generated header! Do not edit! */
#ifndef _INLINE_AMITCP_H
#define _INLINE_AMITCP_H
#ifndef __INLINE_MACROS_H
#include <inline/macros.h>
#endif /* !__INLINE_MACROS_H */
#ifndef AMITCP_BASE_NAME
#define AMITCP_BASE_NAME lss->lx_BsdSocketBase
#endif /* !AMITCP_BASE_NAME */
#define TCP_Accept(s, addr, addrlen) \
LP3(0x30, LONG, TCP_Accept, LONG, s, d0, struct sockaddr *, addr, a0, int *, addrlen, a1, \
, AMITCP_BASE_NAME)
#define TCP_Bind(s, name, namelen) \
LP3(0x24, LONG, TCP_Bind, LONG, s, d0, const struct sockaddr *, name, a0, LONG, namelen, d1, \
, AMITCP_BASE_NAME)
#define TCP_CloseSocket(d) \
LP1(0x78, LONG, TCP_CloseSocket, LONG, d, d0, \
, AMITCP_BASE_NAME)
#define TCP_Connect(s, name, namelen) \
LP3(0x36, LONG, TCP_Connect, LONG, s, d0, const struct sockaddr *, name, a0, LONG, namelen, d1, \
, AMITCP_BASE_NAME)
#define TCP_Dup2Socket(fd1, fd2) \
LP2(0x108, LONG, TCP_Dup2Socket, LONG, fd1, d0, LONG, fd2, d1, \
, AMITCP_BASE_NAME)
#define TCP_Errno() \
LP0(0xa2, LONG, TCP_Errno, \
, AMITCP_BASE_NAME)
#define TCP_GetDTableSize() \
LP0(0x8a, LONG, TCP_GetDTableSize, \
, AMITCP_BASE_NAME)
#define TCP_GetHostByAddr(addr, len, type) \
LP3(0xd8, struct hostent *, TCP_GetHostByAddr, const UBYTE *, addr, a0, LONG, len, d0, LONG, type, d1, \
, AMITCP_BASE_NAME)
#define TCP_GetHostByName(name) \
LP1(0xd2, struct hostent *, TCP_GetHostByName, const UBYTE *, name, a0, \
, AMITCP_BASE_NAME)
#define TCP_GetHostId() \
LP0(0x120, ULONG, TCP_GetHostId, \
, AMITCP_BASE_NAME)
#define TCP_GetHostName(hostname, size) \
LP2(0x11a, LONG, TCP_GetHostName, STRPTR, hostname, a0, LONG, size, d0, \
, AMITCP_BASE_NAME)
#define TCP_GetNetByAddr(net, type) \
LP2(0xe4, struct netent *, TCP_GetNetByAddr, LONG, net, d0, LONG, type, d1, \
, AMITCP_BASE_NAME)
#define TCP_GetNetByName(name) \
LP1(0xde, struct netent *, TCP_GetNetByName, const UBYTE *, name, a0, \
, AMITCP_BASE_NAME)
#define TCP_GetPeerName(s, hostname, namelen) \
LP3(0x6c, LONG, TCP_GetPeerName, LONG, s, d0, struct sockaddr *, hostname, a0, int *, namelen, a1, \
, AMITCP_BASE_NAME)
#define TCP_GetProtoByName(name) \
LP1(0xf6, struct protoent *, TCP_GetProtoByName, const UBYTE *, name, a0, \
, AMITCP_BASE_NAME)
#define TCP_GetProtoByNumber(proto) \
LP1(0xfc, struct protoent *, TCP_GetProtoByNumber, LONG, proto, d0, \
, AMITCP_BASE_NAME)
#define TCP_GetServByName(name, proto) \
LP2(0xea, struct servent *, TCP_GetServByName, const UBYTE *, name, a0, const UBYTE *, proto, a1, \
, AMITCP_BASE_NAME)
#define TCP_GetServByPort(port, proto) \
LP2(0xf0, struct servent *, TCP_GetServByPort, LONG, port, d0, const UBYTE *, proto, a0, \
, AMITCP_BASE_NAME)
#define TCP_GetSockName(s, hostname, namelen) \
LP3(0x66, LONG, TCP_GetSockName, LONG, s, d0, struct sockaddr *, hostname, a0, int *, namelen, a1, \
, AMITCP_BASE_NAME)
#define TCP_GetSockOpt(s, level, optname, optval, optlen) \
LP5(0x60, LONG, TCP_GetSockOpt, LONG, s, d0, LONG, level, d1, LONG, optname, d2, void *, optval, a0, int *, optlen, a1, \
, AMITCP_BASE_NAME)
#define TCP_GetSocketEvents(eventmaskp) \
LP1(0x12c, LONG, TCP_GetSocketEvents, ULONG *, eventmaskp, a0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_Addr(cp) \
LP1(0xb4, ULONG, TCP_Inet_Addr, const UBYTE *, cp, a0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_LnaOf(in) \
LP1(0xba, ULONG, TCP_Inet_LnaOf, LONG, in, d0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_MakeAddr(net, host) \
LP2(0xc6, ULONG, TCP_Inet_MakeAddr, ULONG, net, d0, ULONG, host, d1, \
, AMITCP_BASE_NAME)
#define TCP_Inet_NetOf(in) \
LP1(0xc0, ULONG, TCP_Inet_NetOf, LONG, in, d0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_Network(cp) \
LP1(0xcc, ULONG, TCP_Inet_Network, const UBYTE *, cp, a0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_NtoA(in) \
LP1(0xae, char *, TCP_Inet_NtoA, ULONG, in, d0, \
, AMITCP_BASE_NAME)
#define TCP_IoctlSocket(d, request, argp) \
LP3(0x72, LONG, TCP_IoctlSocket, LONG, d, d0, ULONG, request, d1, char *, argp, a0, \
, AMITCP_BASE_NAME)
#define TCP_Listen(s, backlog) \
LP2(0x2a, LONG, TCP_Listen, LONG, s, d0, LONG, backlog, d1, \
, AMITCP_BASE_NAME)
#define TCP_ObtainSocket(id, domain, type, protocol) \
LP4(0x90, LONG, TCP_ObtainSocket, LONG, id, d0, LONG, domain, d1, LONG, type, d2, LONG, protocol, d3, \
, AMITCP_BASE_NAME)
#define TCP_Recv(s, buf, len, flags) \
LP4(0x4e, LONG, TCP_Recv, LONG, s, d0, UBYTE *, buf, a0, LONG, len, d1, LONG, flags, d2, \
, AMITCP_BASE_NAME)
#define TCP_RecvFrom(s, buf, len, flags, from, fromlen) \
LP6(0x48, LONG, TCP_RecvFrom, LONG, s, d0, UBYTE *, buf, a0, LONG, len, d1, LONG, flags, d2, struct sockaddr *, from, a1, int *, fromlen, a2, \
, AMITCP_BASE_NAME)
#define TCP_RecvMsg(s, msg, flags) \
LP3(0x114, LONG, TCP_RecvMsg, LONG, s, d0, struct msghdr *, msg, a0, LONG, flags, d1, \
, AMITCP_BASE_NAME)
#define TCP_ReleaseCopyOfSocket(fd, id) \
LP2(0x9c, LONG, TCP_ReleaseCopyOfSocket, LONG, fd, d0, LONG, id, d1, \
, AMITCP_BASE_NAME)
#define TCP_ReleaseSocket(fd, id) \
LP2(0x96, LONG, TCP_ReleaseSocket, LONG, fd, d0, LONG, id, d1, \
, AMITCP_BASE_NAME)
#define TCP_Send(s, msg, len, flags) \
LP4(0x42, LONG, TCP_Send, LONG, s, d0, const UBYTE *, msg, a0, LONG, len, d1, LONG, flags, d2, \
, AMITCP_BASE_NAME)
#define TCP_SendMsg(s, msg, flags) \
LP3(0x10e, LONG, TCP_SendMsg, LONG, s, d0, const struct msghdr *, msg, a0, LONG, flags, d1, \
, AMITCP_BASE_NAME)
#define TCP_SendTo(s, msg, len, flags, to, tolen) \
LP6(0x3c, LONG, TCP_SendTo, LONG, s, d0, const UBYTE *, msg, a0, LONG, len, d1, LONG, flags, d2, const struct sockaddr *, to, a1, LONG, tolen, d3, \
, AMITCP_BASE_NAME)
#define TCP_SetErrnoPtr(errno_p, size) \
LP2(0xa8, LONG, TCP_SetErrnoPtr, void *, errno_p, a0, LONG, size, d0, \
, AMITCP_BASE_NAME)
#define TCP_SetSockOpt(s, level, optname, optval, optlen) \
LP5(0x5a, LONG, TCP_SetSockOpt, LONG, s, d0, LONG, level, d1, LONG, optname, d2, const void *, optval, a0, LONG, optlen, d3, \
, AMITCP_BASE_NAME)
#define TCP_SetSocketSignals(SIGINTR, SIGIO, SIGURG) \
LP3NR(0x84, TCP_SetSocketSignals, ULONG, SIGINTR, d0, ULONG, SIGIO, d1, ULONG, SIGURG, d2, \
, AMITCP_BASE_NAME)
#define TCP_ShutDown(s, how) \
LP2(0x54, LONG, TCP_ShutDown, LONG, s, d0, LONG, how, d1, \
, AMITCP_BASE_NAME)
#define TCP_Socket(domain, type, protocol) \
LP3(0x1e, LONG, TCP_Socket, LONG, domain, d0, LONG, type, d1, LONG, protocol, d2, \
, AMITCP_BASE_NAME)
#define TCP_SocketBaseTagList(taglist) \
LP1(0x126, LONG, TCP_SocketBaseTagList, struct TagItem *, taglist, a0, \
, AMITCP_BASE_NAME)
#ifndef NO_INLINE_STDARG
#define TCP_SocketBaseTags(tags...) \
({ULONG _tags[] = { tags }; TCP_SocketBaseTagList((struct TagItem *)_tags);})
#endif
#define TCP_SyslogA(level, format, ap) \
LP3NR(0x102, TCP_SyslogA, ULONG, level, d0, const char *, format, a0, va_list, ap, a1, \
, AMITCP_BASE_NAME)
#define TCP_WaitSelect(nfds, readfds, writefds, execptfds, timeout, maskp) \
LP6(0x7e, LONG, TCP_WaitSelect, LONG, nfds, d0, fd_set *, readfds, a0, fd_set *, writefds, a1, fd_set *, execptfds, a2, struct timeval *, timeout, a3, ULONG *, maskp, d1, \
, AMITCP_BASE_NAME)
#endif /* !_INLINE_AMITCP_H */

122
port.h Normal file
View File

@ -0,0 +1,122 @@
/* port.h - portability defines */
#if defined(__FreeBSD__)
# define OS_FreeBSD
# define ARCH "FreeBSD"
#elif defined(__OpenBSD__)
# define OS_OpenBSD
# define ARCH "OpenBSD"
#elif defined(__NetBSD__)
# define OS_NetBSD
# define ARCH "NetBSD"
#elif defined(linux)
# define OS_Linux
# define ARCH "Linux"
#elif defined(sun)
# define OS_Solaris
# define ARCH "Solaris"
#elif defined(__osf__)
# define OS_DigitalUnix
# define ARCH "DigitalUnix"
#elif defined(__svr4__)
# define OS_SysV
# define ARCH "SysV"
#else
# define OS_UNKNOWN
# define ARCH "UNKNOWN"
#endif
#ifdef OS_FreeBSD
# include <osreldate.h>
# define HAVE_DAEMON
# define HAVE_SETSID
# define HAVE_SETLOGIN
# define HAVE_WAITPID
# define HAVE_HSTRERROR
# define HAVE_TM_GMTOFF
# define HAVE_SENDFILE
# define HAVE_SCANDIR
# define HAVE_INT64T
# define HAVE_SRANDOMDEV
# ifdef SO_ACCEPTFILTER
# define HAVE_ACCEPT_FILTERS
# if ( __FreeBSD_version >= 411000 )
# define ACCEPT_FILTER_NAME "httpready"
# else
# define ACCEPT_FILTER_NAME "dataready"
# endif
# endif /* SO_ACCEPTFILTER */
#endif /* OS_FreeBSD */
#ifdef OS_OpenBSD
# define HAVE_DAEMON
# define HAVE_SETSID
# define HAVE_SETLOGIN
# define HAVE_WAITPID
# define HAVE_HSTRERROR
# define HAVE_TM_GMTOFF
# define HAVE_SCANDIR
# define HAVE_INT64T
#endif /* OS_OpenBSD */
#ifdef OS_NetBSD
# define HAVE_DAEMON
# define HAVE_SETSID
# define HAVE_SETLOGIN
# define HAVE_WAITPID
# define HAVE_HSTRERROR
# define HAVE_TM_GMTOFF
# define HAVE_SCANDIR
# define HAVE_INT64T
#endif /* OS_NetBSD */
#ifdef OS_Linux
# define HAVE_DAEMON
# define HAVE_SETSID
# define HAVE_WAITPID
# define HAVE_TM_GMTOFF
# define HAVE_SENDFILE
# define HAVE_LINUX_SENDFILE
# define HAVE_SCANDIR
# define HAVE_INT64T
#endif /* OS_Linux */
#ifdef OS_Solaris
# define HAVE_SETSID
# define HAVE_WAITPID
# define HAVE_MEMORY_H
# define HAVE_SIGSET
# define HAVE_INT64T
# define HAVE_RAND
#endif /* OS_Solaris */
#ifdef OS_DigitalUnix
# define HAVE_SETSID
# define HAVE_SETLOGIN
# define HAVE_WAITPID
# define HAVE_SCANDIR
# define HAVE_TM_GMTOFF
# define NO_SNPRINTF
/* # define HAVE_INT64T */ /* Digital Unix 4.0d doesn't have int64_t */
#endif /* OS_DigitalUnix */
#ifdef OS_SysV
# define HAVE_SETSID
# define HAVE_WAITPID
# define HAVE_MEMORY_H
# define HAVE_SIGSET
# define HAVE_RAND
#endif /* OS_Solaris */
#ifdef HAVE_RAND
# define srandom srand
# define random rand
#endif /* HAVE_RAND */
#ifdef __AMIGA__
# include <clib/exec_protos.h>
# include <clib/amitcp_protos.h>
# define alarm(x) ;
int open_libs();
extern struct Library *SocketBase;
#endif

72
time_timer.c Normal file
View File

@ -0,0 +1,72 @@
//--------------------------------------------------------------------------//
// This file is in the public domain. //
//--------------------------------------------------------------------------//
/*
* Written by Carsten Larsen.
* Public domain.
*/
#include <clib/exec_protos.h>
#include <clib/timer_protos.h>
#include <devices/timer.h>
struct Device* TimerBase;
struct MsgPort* TimerPort;
struct timerequest* TimeRequest;
int CreateTimer()
{
int error;
TimerPort = CreateMsgPort();
if (TimerPort == NULL) {
return 1;
}
TimeRequest = (struct timerequest*)CreateIORequest(
TimerPort,
sizeof(struct timerequest)
);
if (TimeRequest == NULL) {
DeleteMsgPort(TimerPort);
return 2;
}
error = OpenDevice(
(STRPTR)TIMERNAME,
UNIT_MICROHZ,
(struct IORequest*)TimeRequest,
0
);
if (error != 0)
{
DeleteIORequest((struct IORequest*)TimeRequest);
DeleteMsgPort(TimerPort);
return 3;
}
TimerBase = (struct Device*)TimeRequest->tr_node.io_Device;
return 0;
}
void DeleteTimer()
{
if (TimeRequest != NULL) {
if (!CheckIO((struct IORequest*)TimeRequest)) {
WaitIO((struct IORequest*)TimeRequest);
}
CloseDevice((struct IORequest*)TimeRequest);
DeleteIORequest((struct IORequest*)TimeRequest);
TimeRequest = NULL;
}
if (TimerPort != NULL) {
DeleteMsgPort(TimerPort);
TimerPort = NULL;
}
}

3
version.h Normal file
View File

@ -0,0 +1,3 @@
#define PACKAGE_NAME "http_ping"
#define PACKAGE_VERSION "1.10"
#define PACKAGE_DATE "01.11.2015"