Skip to content

Commit

Permalink
updated pistop
Browse files Browse the repository at this point in the history
1. pistopclient.c: use timeoutwrite from libqmail
2. pistopclient.c: removed unused function timeoutread
3. Fixed configure.ac for OSX
  • Loading branch information
mbhangui committed Jul 29, 2024
1 parent 43ad5ba commit 74bb186
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ client.in
pistopserver.1
conf-release
host_status
config.guess
config.sub
41 changes: 40 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,53 @@

AC_PREREQ([2.69])
AC_INIT([pistop],m4_normalize(m4_include([conf-version])),m4_normalize(m4_include([conf-email])),pistop,[https://github.com/mbhangui/pistop])
AC_CANONICAL_HOST
AC_CONFIG_SRCDIR([pistopserver.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.
case "$host" in
*-*-sunos4.1.1*)
CPPFLAGS="$CPPFLAGS -DSUNOS4"
CFLAGS="$CFLAGS -O4 -Wall -fPIC"
CXXFLAGS="$CXXFLAGS -O4 -Wall -fPIC"
;;
*-*-solaris*)
CPPFLAGS="$CPPFLAGS -DSOLARIS"
CFLAGS="$CFLAGS -O4 -Wall -fPIC"
CXXFLAGS="$CXXFLAGS -O4 -Wall -fPIC"
;;
*-*-linux*)
CPPFLAGS="$CPPFLAGS -DLINUX"
CFLAGS="$CFLAGS -O4 -Wall -fPIC"
CXXFLAGS="$CXXFLAGS -DLINUX -O4 -Wno-delete-non-virtual-dtor -Wno-reorder -Wall -fPIC"
LDFLAGS="$LDFLAGS -pie"
;;
*-*-freebsd*)
CPPFLAGS="$CPPFLAGS -DFREEBSD -I/usr/local/include"
CFLAGS="$CFLAGS -I/usr/local/include -I/usr/local/include/qmail -Wall"
CXXFLAGS="$CXXFLAGS -DFREEBSD -I/usr/local/include -Wall -fPIC"
CXXFLAGS="$CXXFLAGS -Wno-delete-non-virtual-dtor -Wno-deprecated-register -Wno-reorder"
CXXFLAGS="$CXXFLAGS -Wno-delete-non-abstract-non-virtual-dtor"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
;;
*-*-darwin*)
CPPFLAGS="$CPPFLAGS -DDARWIN -I/opt/local/include"
CFLAGS="$CFLAGS -I/opt/local/include -I/usr/local/include -I/opt/local/include/qmail -Wall"
CXXFLAGS="$CXXFLAGS -DDARWIN -Wall -fPIC"
CXXFLAGS="$CXXFLAGS -DBIND_8_COMPAT -I/opt/local/include -Wno-c++11-extensions"
CXXFLAGS="$CXXFLAGS -Wno-delete-non-virtual-dtor -Wno-reorder-ctor -Wno-reorder"
LDFLAGS="$LDFLAGS -L/opt/local/lib -L/usr/local/lib"
;;
*)
CFLAGS="$CFLAGS -O4 -Wall -fPIC"
CXXFLAGS="$CXXFLAGS -O4 -Wall -fPIC"
;;
esac

# Checks for libraries.
AC_CHECK_LIB(qmail, substdio_fdbuf, [AC_SUBST([LIB_QMAIL], ["-lqmail"]) AC_DEFINE([HAVE_QMAIL], [1],[qmail Library])],noqmail=t,)
if test " $noqmail" = " t"
Expand Down
3 changes: 3 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ Release 1.1 Start 30/06/2022 End --/--/----
- 29/07/2024
43. pistopstart.in: get MDRIVE from /etc/auto.master.d/mpd.autofs and
/etc/autofs.mounts
44. pistopclient.c: use timeoutwrite from libqmail
45. pistopclient.c: removed unused function timeoutread
46. Fixed configure.ac for OSX

* Thu Jun 30 2022 18:10:06 IST Manvendra Bhangui <[email protected]> 1.0-1.1%{?dist}
Release 1.0 Start 28/08/2020 End 30/06/2022
Expand Down
55 changes: 5 additions & 50 deletions pistopclient.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/*
* $Log: pistopclient.c,v $
* Revision 1.4 2024-07-29 22:05:23+05:30 Cprogrammer
* removed unused function timeoutread
* use timeoutwrite from libqmail
*
* Revision 1.3 2024-01-29 09:51:15+05:30 Cprogrammer
* remove double newline
*
Expand Down Expand Up @@ -29,6 +33,7 @@
#include <sig.h>
#include <fmt.h>
#include <sgetopt.h>
#include <timeoutwrite.h>

#define FATAL "pistopclient: fatal: "
#define SELECTTIMEOUT 5
Expand Down Expand Up @@ -111,56 +116,6 @@ sigterm()
_exit(1);
}

int
timeoutread(t, fd, buf, len)
int t;
int fd;
char *buf;
int len;
{
fd_set rfds;
struct timeval tv;

tv.tv_sec = t;
tv.tv_usec = 0;

FD_ZERO(&rfds);
FD_SET(fd, &rfds);

if (select(fd + 1, &rfds, (fd_set *) 0, (fd_set *) 0, &tv) == -1)
return -1;
if (FD_ISSET(fd, &rfds))
return read(fd, buf, len);

errno = error_timeout;
return -1;
}

int
timeoutwrite(t, fd, buf, len)
int t;
int fd;
char *buf;
int len;
{
fd_set wfds;
struct timeval tv;

tv.tv_sec = t;
tv.tv_usec = 0;

FD_ZERO(&wfds);
FD_SET(fd, &wfds);

if (select(fd + 1, (fd_set *) 0, &wfds, (fd_set *) 0, &tv) == -1)
return -1;
if (FD_ISSET(fd, &wfds))
return write(fd, buf, len);

errno = error_timeout;
return -1;
}

void
do_start(char *pistopstart)
{
Expand Down

0 comments on commit 74bb186

Please sign in to comment.