Skip to content

Commit

Permalink
1st commit
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Jul 24, 2021
1 parent 309a976 commit b066e50
Show file tree
Hide file tree
Showing 48 changed files with 9,325 additions and 0 deletions.
167 changes: 167 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# The GPL applies to this program.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the
# OpenSSL library under certain conditions as described in each
# individual source file, and distribute linked combinations
# including the two.
# You must obey the GNU General Public License in all respects
# for all of the code used other than OpenSSL. If you modify
# file(s) with this exception, you may extend this exception to your
# version of the file(s), but you are not obligated to do so. If you
# do not wish to do so, delete this exception statement from your
# version. If you delete this exception statement from all source
# files in the program, then also delete it here.

-include makefile.inc

# *** configure script ***
# support for tcp fast open?
#TFO=yes
# disable SSL? (no = disable so the default is use openssl)
# SSL=no
# enable NCURSES interface?
#NC=yes
# do fft in ncurses interface? (requires libfftw3)
#FW=yes

############# do not change anything below here #############

include version

TARGET=httping

LOCALEDIR=/usr/share/locale

DEBUG=yes
WFLAGS=-Wall -W -Wextra -pedantic -D_FORTIFY_SOURCE=2
OFLAGS=
CFLAGS+=$(WFLAGS) $(OFLAGS) -DVERSION=\"$(VERSION)\" -DLOCALEDIR=\"$(LOCALEDIR)\"
LDFLAGS+=-lm

PACKAGE=$(TARGET)-$(VERSION)
PREFIX?=/usr
BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man
DOCDIR=$(PREFIX)/share/doc/$(TARGET)

INSTALL=install
INSTALLDIR=$(INSTALL) -m 0755 -d
INSTALLBIN=$(INSTALL) -m 0755
INSTALLMAN=$(INSTALL) -m 0644
INSTALLDOC=$(INSTALL) -m 0644
STRIP=/usr/bin/strip
RMDIR=/bin/rm -rf
MKDIR=/bin/mkdir
ARCHIVE=/bin/tar cf -
COMPRESS=/bin/gzip -9

ifneq ($(NO_GETTEXT),yes)
TRANSLATIONS=nl.mo ru.mo
endif

OBJS=gen.o http.o io.o error.o utils.o main.o tcp.o res.o socks5.o kalman.o cookies.o help.o colors.o

MAN_EN=httping.1
MAN_NL=httping-nl.1
MAN_RU=httping-ru.1

DOCS=license.txt license.OpenSSL readme.txt

ifeq ($(SSL),no)
CFLAGS+=-DNO_SSL
else
OBJS+=mssl.o
LDFLAGS+=-lssl -lcrypto
endif

ifeq ($(TFO),yes)
CFLAGS+=-DTCP_TFO
endif

ifeq ($(NC),yes)
CFLAGS+=-DNC
OBJS+=nc.o
LDFLAGS+=-lncursesw
endif

ifeq ($(FW),yes)
CFLAGS+=-DFW
OBJS+=fft.o
LDFLAGS+=-lfftw3
endif

ifeq ($(DEBUG),yes)
CFLAGS+=-D_DEBUG -ggdb
LDFLAGS+=-g
endif

ifeq ($(ARM),yes)
CC=arm-linux-gcc
endif

all: $(TARGET) $(TRANSLATIONS)

$(TARGET): $(OBJS)
$(CC) $(WFLAGS) $(OBJS) $(LDFLAGS) -o $(TARGET)
#
# Oh, blatant plug: http://www.vanheusden.com/wishlist.php

install: $(TARGET) $(TRANSLATIONS)
$(INSTALLDIR) $(DESTDIR)/$(BINDIR)
$(INSTALLBIN) $(TARGET) $(DESTDIR)/$(BINDIR)
$(INSTALLDIR) $(DESTDIR)/$(MANDIR)/man1
$(INSTALLMAN) $(MAN_EN) $(DESTDIR)/$(MANDIR)/man1
$(INSTALLDIR) $(DESTDIR)/$(MANDIR)/nl/man1
$(INSTALLMAN) $(MAN_NL) $(DESTDIR)/$(MANDIR)/nl/man1
$(INSTALLDIR) $(DESTDIR)/$(MANDIR)/ru/man1
$(INSTALLMAN) $(MAN_RU) $(DESTDIR)/$(MANDIR)/ru/man1
$(INSTALLDIR) $(DESTDIR)/$(DOCDIR)
$(INSTALLDOC) $(DOCS) $(DESTDIR)/$(DOCDIR)
ifneq ($(DEBUG),yes)
$(STRIP) $(DESTDIR)/$(BINDIR)/$(TARGET)
endif
ifneq ($(NO_GETTEXT),yes)
mkdir -p $(DESTDIR)/$(PREFIX)/share/locale/nl/LC_MESSAGES
cp nl.mo $(DESTDIR)/$(PREFIX)/share/locale/nl/LC_MESSAGES/httping.mo
mkdir -p $(DESTDIR)/$(PREFIX)/share/locale/ru/LC_MESSAGES
cp ru.mo $(DESTDIR)/$(PREFIX)/share/locale/ru/LC_MESSAGES/httping.mo
endif


makefile.inc:
./configure

nl.mo: nl.po
msgfmt -o nl.mo nl.po
ru.mo: ru.po
msgfmt -o ru.mo ru.po


clean:
$(RMDIR) $(OBJS) $(TARGET) *~ core cov-int *.mo

distclean: clean
rm -f makefile.inc

package:
# source package
$(RMDIR) $(PACKAGE)*
$(MKDIR) $(PACKAGE)
$(INSTALLDOC) *.c *.h configure Makefile *.po version $(MAN_EN) $(MAN_NL) $(MAN_RU) $(DOCS) $(PACKAGE)
$(INSTALLBIN) configure $(PACKAGE)
$(ARCHIVE) $(PACKAGE) | $(COMPRESS) > $(PACKAGE).tgz
$(RMDIR) $(PACKAGE)

check: makefile.inc
cppcheck -v --force -j 3 --enable=all --std=c++11 --inconclusive -I. . 2> err.txt
#
make clean
scan-build make

coverity: makefile.inc
make clean
rm -rf cov-int
CC=gcc cov-build --dir cov-int make all
tar vczf ~/site/coverity/httping.tgz README cov-int/
putsite -q
/home/folkert/.coverity-hp.sh
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
httping
=======

Ping with HTTP requests, see http://www.vanheusden.com/httping/


[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=flok&url=https://github.com/flok99/httping&title=httping&language=&tags=github&category=software)

[![Support the development of this project](https://pledgie.com/campaigns/28612.png?skin_name=chrome)](https://pledgie.com/campaigns/28612)
51 changes: 51 additions & 0 deletions colors.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "colors.h"

const char *c_error = "";
const char *c_normal = "";
const char *c_very_normal = "";
const char *c_red = "";
const char *c_blue = "";
const char *c_green = "";
const char *c_yellow = "";
const char *c_magenta = "";
const char *c_cyan = "";
const char *c_white = "";
const char *c_bright = "";

void set_colors(char nc)
{
if (nc)
{
c_red = COLOR_ESCAPE "1";
c_blue = COLOR_ESCAPE "2";
c_green = COLOR_ESCAPE "3";
c_yellow = COLOR_ESCAPE "4";
c_magenta = COLOR_ESCAPE "5";
c_cyan = COLOR_ESCAPE "6";
c_white = COLOR_ESCAPE "7";

c_bright = COLOR_ESCAPE "8";
c_normal = COLOR_ESCAPE "9";

c_very_normal = COLOR_ESCAPE "7" COLOR_ESCAPE "9";

c_error = COLOR_ESCAPE "1";
}
else
{
c_red = "\033[31;40m";
c_blue = "\033[34;40m";
c_green = "\033[32;40m";
c_yellow = "\033[33;40m";
c_magenta = "\033[35;40m";
c_cyan = "\033[36;40m";
c_white = "\033[37;40m";

c_bright = "\033[1;40m";
c_normal = "\033[0;37;40m";

c_very_normal = "\033[0m";

c_error = "\033[1;4;40m";
}
}
15 changes: 15 additions & 0 deletions colors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extern const char *c_error;
extern const char *c_normal;
extern const char *c_very_normal;
extern const char *c_red;
extern const char *c_blue;
extern const char *c_green;
extern const char *c_yellow;
extern const char *c_magenta;
extern const char *c_cyan;
extern const char *c_white;
extern const char *c_bright;

#define COLOR_ESCAPE "\001"

void set_colors(char nc);
96 changes: 96 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#! /bin/sh

FILE=`mktemp`
FILE2=`mktemp`

echo \*\*\* HTTPing v`grep VERSION version | cut -d = -f 2` configure script \*\*\*
echo

if [ -z "$CC" ]
then
CC=gcc
fi

F_TFO=0
F_NC=0
F_OS=0
F_FW=0
for var in "$@"
do
case "$var" in
--with-tfo)
F_TFO=1
;;

--with-ncurses)
F_NC=1
;;

--with-openssl)
F_OS=1
;;

--with-fftw3)
F_FW=1
;;

--help)
echo "--with-tfo force enable tcp fast open"
echo "--with-ncurses force enable ncurses"
echo "--with-openssl force enable openssl"
echo "--with-fftw3 force enable fftw3"
exit 0
;;

*)
echo WARNING: Command line parameter \"$var\" is not understood.
echo Re-run this script with --help to see a list of switches.
;;
esac
done

$CC -O0 -o $FILE test_TFO.c 2> $FILE2
if [ $? -eq 0 ] || [ $F_TFO -eq 1 ] ; then
echo \+ system supports TCP fast open
TFO="TFO=yes"
else
echo \- this system does NOT support TCP fast open - this is an optional feature
TFO=""
fi

$CC -O0 -o $FILE test_ncurses.c -lncursesw 2> $FILE2
if [ $? -eq 0 ] || [ $F_NC -eq 1 ] ; then
echo \+ system has ncurses development libraries
NC="NC=yes"
else
echo \- this system does NOT have the ncurses development libraries - they are optional
NC=""
fi

$CC -O0 -o $FILE test_openssl.c -lssl -lcrypto 2> $FILE2
if [ $? -eq 0 ] || [ $F_OS -eq 1 ] ; then
echo \+ system has OpenSSL development libraries
SSL="SSL=yes"
else
echo \- this system does NOT have the OpenSSL development libraries - they are optional
SSL="SSL=no"
fi

$CC -O0 -o $FILE test_fftw3.c -lfftw3 2> $FILE2
if [ $? -eq 0 ] || [ $F_FW -eq 1 ] ; then
echo \+ system has FFTW3 development libraries
FW="FW=yes"
else
echo \- this system does NOT have the FFTW3 development libraries - they are optional and only useful when also including ncurses
FW=""
fi

> makefile.inc
echo $NC >> makefile.inc
echo $SSL >> makefile.inc
echo $TFO >> makefile.inc
echo $FW >> makefile.inc

rm -f $FILE $FILE2

echo
Loading

0 comments on commit b066e50

Please sign in to comment.