[comp.sys.hp] NNTP 1.5.11 under hp-ux...?

mahesh@cs.fau.edu (Mahesh Neelakanta) (03/06/91)

Anyone out there in netland got nntp 1.5.11 running under hpux 7.0? I
already have 1.5.10 working but need to run the latest to get that select
bug fix. Anyway, I get the following errors:

in server/misc.c : fsp->fs_spec is undefined.  I looked in fstab.h but it
                   has a #ifdef __hp9000s800 around the fstab structure 
                   decl and I am on a s300 :-(. Is there a way around this?

in server/timer.c : line 123: "timeoutp" is undefined. The code has a variable
                    called "timeout" under SYSV and "timeoutp" is under bsd.
                    This is part of the select() call.

in xmit/nntpxmit.c: getrusage() is missing from the libs. resource.h has the
                    rusage structure defined but where is getrusage? 

Any help in getting this working would be greatly appreciated!  

mahesh

hull@ibmb0.cs.uiuc.edu (David Hull) (03/08/91)

mahesh@cs.fau.edu (Mahesh Neelakanta) writes:

>in server/timer.c : line 123: "timeoutp" is undefined. The code has a variable
>                    called "timeout" under SYSV and "timeoutp" is under bsd.
>                    This is part of the select() call.

It appears that whoever hacked in the EXCELAN support broke timer.c
for USG systems.  Appended are my diffs to timer.c for NNTP 1.5.10 
that attempt to make it work for all systems.  My assumptions are:

    EXCELAN's select is severly nonstandard, and uses an integer timeout
    in microseconds.

    USG doesn't have fdset, but otherwise select is like Berkeley's.

-David Hull


*** timer.c-	Sat Feb 16 12:06:07 1991
--- timer.c	Sun Feb 17 07:00:36 1991
***************
*** 26,32 ****
  #define FD_ISSET(n, p)  ((p)->fds_bits[0] & (1<<(n)))
  #define FD_ZERO(p)      ((p)->fds_bits[0] = 0)
  #endif
! #endif
  /* non-portable */
  #define BUFFERED_DATA(f) ((f)->_cnt > 0)
  
--- 26,32 ----
  #define FD_ISSET(n, p)  ((p)->fds_bits[0] & (1<<(n)))
  #define FD_ZERO(p)      ((p)->fds_bits[0] = 0)
  #endif
! #endif 
  /* non-portable */
  #define BUFFERED_DATA(f) ((f)->_cnt > 0)
  
***************
*** 69,82 ****
  	register int i, n;
  	register struct timer *tp;
  	register long secs;
- #ifdef USG
  	long timeout;
  	long readfds;
  #else
- 	register struct timeval *timeoutp;
- 	struct timeval timeout;
  	fd_set readfds;
  #endif
  
  	/* No need to do the select if there are characters in the buffer */
  	if (BUFFERED_DATA(stdin))
--- 69,83 ----
  	register int i, n;
  	register struct timer *tp;
  	register long secs;
  	long timeout;
+ #ifdef USG
  	long readfds;
  #else
  	fd_set readfds;
  #endif
+ #ifndef EXCELAN
+ 	struct timeval to;
+ #endif
  
  	/* No need to do the select if there are characters in the buffer */
  	if (BUFFERED_DATA(stdin))
***************
*** 83,89 ****
  		return(1);
  
  	/* Length of next timeout is minimum of all "timers" */
- #ifdef USG
  	timeout = -1;
  	for (i = ntimer, tp = timers; i > 0; --i, ++tp)
  		if (tp->left >= 0 &&
--- 84,89 ----
***************
*** 93,126 ****
  	/* If active timeouts (this can easily happen), block until input */
  	if (timeout < 0)
  		timeout = 0;
! #ifdef EXCELAN
  	readfds = 1<<(fileno(stdin));
- 	timeout = timeout * 1000;     /* timeout needs to be in milliseconds */
- #endif /* EXCELAN */
  #else
- 	timeout.tv_sec = -1;
- 	timeout.tv_usec = 0;
- 	for (i = ntimer, tp = timers; i > 0; --i, ++tp)
- 		if (tp->left >= 0 &&
- 		    (tp->left < timeout.tv_sec || timeout.tv_sec < 0))
- 			timeout.tv_sec = tp->left;
- 
- 	/* If active timeouts (this can easily happen), block until input */
- 	if (timeout.tv_sec < 0)
- 		timeoutp = 0;
- 	else
- 		timeoutp = &timeout;
- 
- 	/* Do select */
  	FD_ZERO(&readfds);
  	FD_SET(fileno(stdin), &readfds);
! #endif /* !USG */
  	errno = 0;
  #ifdef EXCELAN
  	n = select(fileno(stdin) + 1, &readfds, (long*)0, timeout);
  #else
  	n = select(fileno(stdin) + 1,
! 	    &readfds, (fd_set*)0, (fd_set*)0, timeoutp);
  #endif
  	/* "Interrupted system call" isn't a real error */
  	if (n < 0 && errno != EINTR) {
--- 93,122 ----
  	/* If active timeouts (this can easily happen), block until input */
  	if (timeout < 0)
  		timeout = 0;
! 
! #ifdef USG
  	readfds = 1<<(fileno(stdin));
  #else
  	FD_ZERO(&readfds);
  	FD_SET(fileno(stdin), &readfds);
! #endif
  	errno = 0;
+ 	/* Do select */
  #ifdef EXCELAN
+ 	timeout *= 1000;     /* timeout needs to be in milliseconds */
  	n = select(fileno(stdin) + 1, &readfds, (long*)0, timeout);
  #else
+ 	to.tv_usec = 0;
+ 	to.tv_sec = timeout;
+ #ifdef USG
  	n = select(fileno(stdin) + 1,
! 	    &readfds, (long*)0, (long*)0,
! 	    (to.tv_sec < 0 ? (struct timeval *)0 : &to));
! #else
! 	n = select(fileno(stdin) + 1,
! 	    &readfds, (fd_set*)0, (fd_set*)0,
! 	    (to.tv_sec < 0 ? 0 : &to));
! #endif
  #endif
  	/* "Interrupted system call" isn't a real error */
  	if (n < 0 && errno != EINTR) {

mahesh@cs.fau.edu (Mahesh Neelakanta) (03/09/91)

In article <1991Mar05.235630.25240@cs.fau.edu> mahesh@cs.fau.edu (Mahesh Neelakanta) writes:
>in server/misc.c : fsp->fs_spec is undefined.  I looked in fstab.h but it
>                   has a #ifdef __hp9000s800 around the fstab structure 
>                   decl and I am on a s300 :-(. Is there a way around this?
>
 hpux uses checklist.h instead of fstab.h for the s300's. The getfsent(3X) is
also replaced by getmtent(3X). Many thanks to hakanson@cse.ogi.edu [Marion
Hakanson] for helping me find this. Also, I had BSD_43 defined in conf.h
(I'm still confused about hpux being more bsd or sysv, sometimes :-) which 
made the code in misc.c and nntpxmit.c go the wrong way during cpp.
 
>in server/timer.c : line 123: "timeoutp" is undefined. The code has a variable
>                    called "timeout" under SYSV and "timeoutp" is under bsd.
>                    This is part of the select() call.
>
 hull@ibmb0.cs.uiuc.edu [David Hull] posted a fix for this a few messages back.
I applied the patches and the code compiled fine.  Something to point out
here is that hpux has fd_set (in sys/types.h) so I had modified the original
timer.c to work with it (as well as using "struct timeval timeout" instead of
"long timeout"). Seems like wherever I saw a "#ifdef USG" in timer.c, I had
to replace it with "#if defined(USG) && !defined(hpux)" kinda deal :-). This
fix seemed to work too and is smaller (but will not work for other USG systems).

>in xmit/nntpxmit.c: getrusage() is missing from the libs. resource.h has the
>                    rusage structure defined but where is getrusage? 
>
 My error...I had defined BSD_43 (in common/conf.h)...dumb, dumb, dumb.

ld gave a warning that bcopy was defined more than once. Hopefully, this can be
ignored. 

Thanks again for all who helped out!

mahesh