0

i trying to compile the latest ver of Delegate on my rpi3 with this tuto (i use raspbian): https://its-more.jp/delegate/ftp/pub/DeleGate/INSTALL.htm

but i have this error:

In file included from readycc.c:2:
readycc.c: In function ‘int ready_cc(FILE*)’:
../include/fpoll.h:15:30: error: ‘FILE’ {aka ‘struct _IO_FILE’} has no member named ‘_egptr’
 #define READYCC(fp)     (fp->_egptr - fp->_gptr)
                              ^~~~~~
readycc.c:8:14: note: in expansion of macro ‘READYCC’
  else return READYCC(fp);
              ^~~~~~~
../include/fpoll.h:15:43: error: ‘FILE’ {aka ‘struct _IO_FILE’} has no member named ‘_gptr’
 #define READYCC(fp)     (fp->_egptr - fp->_gptr)
                                           ^~~~~
readycc.c:8:14: note: in expansion of macro ‘READYCC’
  else return READYCC(fp);
              ^~~~~~~
readycc.c: In function ‘int ready_CC(FILE*)’:
../include/fpoll.h:15:30: error: ‘FILE’ {aka ‘struct _IO_FILE’} has no member named ‘_egptr’
 #define READYCC(fp)     (fp->_egptr - fp->_gptr)
                              ^~~~~~
readycc.c:13:8: note: in expansion of macro ‘READYCC’
  rcc = READYCC(fp);
        ^~~~~~~
../include/fpoll.h:15:43: error: ‘FILE’ {aka ‘struct _IO_FILE’} has no member named ‘_gptr’
 #define READYCC(fp)     (fp->_egptr - fp->_gptr)
                                           ^~~~~
readycc.c:13:8: note: in expansion of macro ‘READYCC’
  rcc = READYCC(fp);
        ^~~~~~~
make[4]: *** [Makefile.go:41: readycc.o] Error 1
make[4]: Leaving directory '/home/pi/delegate/rary'
make[3]: *** [Makefile:7: libx] Error 2
make[3]: Leaving directory '/home/pi/delegate/rary'
mkmake: ERROR LOG is left at /home/pi/delegate/rary/mkmake.err
mkmake: ERROR LOG is left at /home/pi/delegate/rary/mkmake.err
make[2]: *** [Makefile.go:1067: ../lib/library.a] Error 2
make[2]: Leaving directory '/home/pi/delegate/src'
make[1]: *** [Makefile:365: start0] Error 2
make[1]: Leaving directory '/home/pi/delegate/src'
mkmake: ERROR LOG is left at /home/pi/delegate/src/mkmake.err
mkmake: ERROR LOG is left at /home/pi/delegate/src/mkmake.err
make: *** [Makefile:71: all] Error 2

In the mkmake.err:

    *** exit(2): -makeat at /home/pi/delegate/src
    [0] make
    [1] MKMAKE_SRC=
    [2] SHELL=/bin/sh
    [3] HDRDIRS=-I../gen -I../include 
    [4] LIBDIRS=-L../lib
    [5] MKMAKE=/home/pi/delegate/mkmake.exe
    [6] MKBASE=/home/pi/delegate
    [7] MKMKMK=/home/pi/delegate/mkmkmk.exe

    *** exit(2): -makeat at /home/pi/delegate/src
    [0] ./mkmake.exe
    [1] 
    [2] src
    [3] dg.exe
    [4] make
    [5] MKMAKE_SRC=
    [6] SHELL=/bin/sh
    [7] HDRDIRS=-I../gen -I../include 
    [8] LIBDIRS=-L../lib

in the readycc.c

#include <stdio.h>
#include "fpoll.h"

int ready_cc(FILE *fp)
{
    if( fp == NULL )
        return 0;
    else    return READYCC(fp);
}
int ready_CC(FILE *fp)
{   int rcc;

    rcc = READYCC(fp);
    if( 0 < rcc )
        return rcc;
    else    return 0;
}

and in the fpoll.h

/*
 *  The following code is extracted from $ONEW/sys/sys.h which was
 *  made by members of <onew@etl.go.jp> <ftp://etlport.etl.go.jp/pub/onew>
 */
/*
 *  Get the count of bufferd characters.
 */
#ifdef __linux__
#if defined(__STDIO_STREAM_BUFFER_RAVAIL)
#define READYCC(fp)      __STDIO_STREAM_BUFFER_RAVAIL(fp)
#else
#if defined(_LIBIO_H) || defined(_IO_STDIO_H)
#define READYCC(fp)     (fp->_IO_read_end - fp->_IO_read_ptr)
#else
#define READYCC(fp)     (fp->_egptr - fp->_gptr)
#endif
#endif
#else
#if defined(__bsdi__) \
 || defined(__FreeBSD__) \
 || defined(__NetBSD__) \
 || defined(__OpenBSD__) \
 || defined(__MACHTEN__) \
 || defined(__CYGWIN__) || defined(__MINGW32__) \
 || defined(__APPLE__)
#define READYCC(fp)     (fp->_r)
#else
#ifdef __GNU_LIBRARY__
#define READYCC(fp)     (fp->__get_limit - fp->__bufp)
#else
#ifdef __EMX__
#define READYCC(fp) (fp->_rcount)
#else
#if defined(sun) && defined(__x86_64__)
#define READYCC(fp) ((int*)fp)[6]
#elif defined(sun) && defined(m64) && defined(sparc)
#define READYCC(fp) ((int*)fp)[7]
#else
#if defined(_MSC_VER) && defined(UNDER_CE)
int Xready_cc(FILE *fp);
#define READYCC(fp)     Xready_cc(fp)
#else
#define READYCC(fp)     (fp->_cnt)
#endif
#endif
#endif
#endif
#endif
#endif


#if defined(HCASE)
#ifdef READYCC
#undef READYCC
#endif

#if HCASE == 1
#define READYCC(fp)     (fp->_IO_read_end - fp->_IO_read_ptr)
#endif

#if HCASE == 2
#define READYCC(fp)     (fp->_egptr - fp->_gptr)
#endif

#if HCASE == 3
#define READYCC(fp)     (fp->_r)
#endif

#if HCASE == 4
#define READYCC(fp)     (fp->__get_limit - fp->__bufp)
#endif

#if HCASE == 5
#define READYCC(fp) (fp->_rcount)
#endif

#if HCASE == 6
#define READYCC(fp)     (fp->_cnt)
#endif

#if HCASE == 7
#define READYCC(fp) READYCC_UNSUPPORTED()
#endif

#endif

typedef struct _RelayCtrl {
    int rc_ctrl;
    int rc_stat;
    int rc_max_turns;
    int rc_num_turns;
    double  rc_thru_time; /* initial period without limitation of turns */
    double  rc_max_packintvl;
    double  rc_packintvl;
    int rc_min_packz; /* minimum packet size for a side in a turn */
    int rc_packz;
    int rc_concat;    /* waiting for concat in milli-seconds */
    int rc_max_paras; /* for exemption of pipelined request */
    int rc_num_paras;
    int   (*rc_idle_cb)(struct _RelayCtrl*,double,int);
    int rc_exitfd; /* exit when this fd become ready */
} RelayCtrl;
typedef int (*relayCB)(RelayCtrl*,double,int);

#define RELAY_HALFDUP       1
#define RELAY_NOTHALFDUP    1
#define RELAY_SSL_ONLY      2
#define RELAY_NOTSSL        2
#define RELAY_BOTH_DATA     4
#define RELAY_EXITFD        8
#define RELAY_SSL_PEEK      0x0010
extern RelayCtrl *relayCtrlG;

#define RELAY_ctrl  relayCtrl->rc_ctrl
#define RELAY_stat  relayCtrl->rc_stat
#define RELAY_max_turns relayCtrl->rc_max_turns
#define RELAY_num_turns relayCtrl->rc_num_turns
#define RELAY_thru_time relayCtrl->rc_thru_time
#define RELAY_max_packintvl relayCtrl->rc_max_packintvl
#define RELAY_packintvl relayCtrl->rc_packintvl
#define RELAY_half_dup  (relayCtrl->rc_ctrl & RELAY_HALFDUP)
#define RELAY_ssl_only  (relayCtrl->rc_ctrl & RELAY_SSL_ONLY)
#define RELAY_ssl_peek  (relayCtrl->rc_ctrl & RELAY_SSL_PEEK)
#define RELAY_min_packz relayCtrl->rc_min_packz
#define RELAY_packz relayCtrl->rc_packz
#define RELAY_concat    relayCtrl->rc_concat
#define RELAY_num_paras relayCtrl->rc_num_paras
#define RELAY_max_paras relayCtrl->rc_max_paras
#define RELAY_idle_cb   relayCtrl->rc_idle_cb
#define RELAY_exitfd    relayCtrl->rc_exitfd
#define RELAY_getxfd()  ((RELAY_ctrl&RELAY_EXITFD)?RELAY_exitfd:-1)
#define RELAY_setxfd(f) (RELAY_ctrl|=RELAY_EXITFD),(RELAY_exitfd=f)

#ifndef _MSC_VER
#include <unistd.h>
#endif

int top_fd(int fd,int rw);
int file_issock(int fd);
int file_isreg(int fd);
int file_isselectable(int fd);
int isUDPsock(int sock);

#ifndef FL_PAR
#define FL_PAR const char *FL_F,int FL_L
#endif
int ready_cc(FILE *fp);
int fPollIn_FL(FL_PAR,FILE *fp,int msec);
#define fPollIn(fp,ms) fPollIn_FL(FL_ARG,fp,ms)
int PollIn1(int fd,int msec);
int PollIn_FL(FL_PAR,int fd,int msec);
#define PollIn(fd,ms) PollIn_FL(FL_ARG,fd,ms)
int PollIn_HUP(int on);
int _PollIn(int fd,int msec);
int poll_error(int fd);
int pollPipe(int pfd,int slpmsec);
int PollIns(int timeout,int size,int *mask,int *rmask);
int fPollIns(int timeout,int fpc,FILE *fps[],int rdv[]);
int PollOut(int fd,int timeout);
int gotOOB(int fd);
int withOOB(int fd);

int waitShutdownSocket(FL_PAR,int fd,int ms);
int exceptionReady(int sock);
int pollIX(const char *wh,double timeout,int in,int ex);
int watchBothside(int in,int out);
int receiverReset(const char *wh,double timeout,int in,int out);
int inputReady(int sock,int *rd);
int finputReady(FILE *fs,FILE *ts);
int fpop_fd(FILE *fp);

int connHUP();
int connRESETbypeer();
int readyAlways(int fd);
int PollInsOuts(int timeout,int nfds,int fdv[],int ev[],int rev[]);

int simple_relayf(FILE *src,FILE *dst);
int simple_relay(int src,int dst);
void frelay(int timeout,int s1,int d1,int s2,int d2,int (*relayfunc)(FILE*,FILE*));
void usleep_bypoll(int usec);
void relay2_cntl(int timeout,int s1,int d1,int s2,int d2,int s3,int d3,int (*cntlfunc)(void*,...),void *arg);

#ifndef NO_INC_IO
#if defined(_MSC_VER) && defined(UNDER_CE)
#include <io.h>
#endif
#endif

#if defined(FMT_CHECK)
#define daemonlog(flags,fmt,...) fprintf(stderr,fmt,##__VA_ARGS__)
#define syslog_ERROR(fmt,...)    fprintf(stderr,fmt,##__VA_ARGS__)
#else
#define FMT_daemonlog    daemonlog
#define FMT_syslog_ERROR syslog_ERROR
int FMT_daemonlog(const char *flags,const char *fmt,...);
int FMT_syslog_ERROR(const char *fmt, ...);
#endif

I'm not very good with this and i need your help for compiling that. Thanks you

SkyNe0Niak
  • 11
  • 1

1 Answers1

2

Here is a patch for you.

diff -r -c1 orig/delegate9.9.13/include/fpoll.h delegate9.9.13/include/fpoll.h
*** orig/delegate9.9.13/include/fpoll.h Sun May 18 05:11:20 2014
--- delegate9.9.13/include/fpoll.h      Fri Jun 19 12:16:16 2020
***************
*** 7,8 ****
--- 7,9 ----
   */
+ #define _LIBIO_H // @2020-0619, @SatoxITS @ITS-more
  #ifdef __linux__
diff -r -c1 orig/delegate9.9.13/include/ystring.h delegate9.9.13/include/ystring.h
*** orig/delegate9.9.13/include/ystring.h       Sun Aug 10 17:29:50 2014
--- delegate9.9.13/include/ystring.h    Fri Jun 19 12:15:15 2020
***************
*** 1502,1503 ****
--- 1502,1514 ----

+ // the shortest patch for comilation of delegate9.9.13 on recent Linuxes
+ // @2020-0619, @SatoxITS, @ITS-more
+ #pragma GCC diagnostic ignored "-Wparentheses"
+ #pragma GCC diagnostic ignored "-Wcomment"
+ #pragma GCC diagnostic ignored "-Wunused-result"
+ #pragma GCC diagnostic ignored "-Wunused-value"
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ #pragma GCC diagnostic ignored "-Wformat-extra-args"
+ #pragma GCC diagnostic ignored "-Wnarrowing"
+ #pragma GCC diagnostic ignored "-Wstringop-overflow=" // for Pi
+ 
  #endif /* _YSTRING_H */

@SatoxITS

SatoxITS
  • 21
  • 3
  • Can you offer an explanation of how this works and why it solves the issue? – Jeremy Caney Jun 18 '20 at 20:08
  • 1
    DeleGate tries to detect the amount of buffered data in FILE stream to apply fpoll() for the stream. The problematic READY_CC() in this issue is a macro for it. Since the implementation of FILE structure is so platform dependent historically, automatically detecting the relevant members in the structure was problem. In typical Linux, the member is like "_IO_read_ptr" and such Linux could be detected by existence of predefined macro "_LIBIO_H" until ten years ago, but macro seems gone in recent Linux. But today's Linux seem to have member, so defining the macro solves the compilation. – SatoxITS Jun 18 '20 at 21:49
  • And as the author of entire code of DeleGate, I still remember most of them I wrote until ten years ago. One month ago, I had 3 days of an intensional camp to make review of the errors and warnings put by Linux Gcc, Apple CC and Windows VC. Most of them are warnings for codes before testing or porting, or for coders who is not familiar with parenthesis of C. Especially on Linux, there was no effective problem to make DeleGate 9.9.13 work in the kernel 4 or 5. The patched DeleGate has been running as the HTTP server on http://www.delegate.org on Ubuntu18, without problems for about 45 days. – SatoxITS Jun 18 '20 at 21:55
  • Just wow. Thank you for saving my ass, really. Today I had to compile DeleGate on new Rocky Linux 8.4. I'm still using DeleGate extensively, it's very, very useful! Too bad that there is no new release 9.9.14 with all these fixes, along with "make CFLAGS="-O2 -std=c++0x -Wno-narrowing" :( Every year it takes more and more time to find out what's wrong with DeleGate compilation... – Grrruk Sep 03 '21 at 15:25
  • Do I need to `make clean` after applying the patch, to have the CFLAGS applied to the rest of the build? Wha happened to delegate9.org? Will it ever be built – Nicola Nov 28 '21 at 08:13