[news.software.anu-news] 5.9c, whereis nntp_tcpwinmultinet.c?

reggers@UWOVAX.UWO.CA (Reg Quinton) (01/18/90)

received the shar of nntp_xfer.c; now my build goes a bit farther... down
to where it complains about "nntp_tcpwinmultinet.c". Could this be sent
out too?
     
thanks a bunch

gih900@CSC.DNET (Geoff Huston) (01/22/90)

>received the shar of nntp_xfer.c; now my build goes a bit farther... down
>to where it complains about "nntp_tcpwinmultinet.c". Could this be sent
>out too?
     
my mistake:... sorry !
     
$! ................... Cut between dotted lines and save. ...................
$!...........................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.10 7-FEB-1989.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user GIH900
$! on 22-JAN-1990 08:46:24.58.
$!
$! It contains the following 1 file:
$!        NNTP_TCPWINMULTINET.C
$!
$!============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.10 7-FEB-1989 requires VMS V4.4 or higher."
$ EXIT 44 ! SS$_ABORT
$VERSION_OK:
$ GOTO START
$!
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY
b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) )
; s_file_spec := GET_INFO( COMMAND_LINE, "output_file" ); SET( OUTPUT_FILE
, b_part, s_file_spec ); b_errors := CREATE_BUFFER( "{Errors}" ); i_errors
:= 0; pat_beg_1 := ANCHOR & "-+-+-+ Beginning"; pat_beg_2 := LINE_BEGIN
& "+-+-+-+ Beginning"; pat_end := ANCHOR & "+-+-+-+-+ End"; POSITION
( BEGINNING_OF( b_part ) ); LOOP EXITIF SEARCH( SPAN( ' ' )@r_trail
& LINE_END, FORWARD) = 0; POSITION( r_trail ); ERASE( r_trail ); ENDLOOP
; POSITION( BEGINNING_OF( b_part ) ); i_append_line := 0; LOOP EXITIF MARK
( NONE ) = END_OF( b_part ); s_x := ERASE_CHARACTER( 1 )
; IF s_x = '+' THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip
<> 0 THEN s_x := ''; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF
; ENDIF; IF s_x = '-' THEN r_skip := SEARCH( pat_end, FORWARD, EXACT )
; IF r_skip <> 0 THEN s_x := ''; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip
:= MARK( NONE ); r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip
<> 0 THEN POSITION( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET )
; MOVE_VERTICAL( 1 ); MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part )
); ENDIF; ERASE( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF
; IF s_x = 'V' THEN s_x := ''; IF i_append_line <> 0 THEN APPEND_LINE
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF; i_append_line := 1
; MOVE_VERTICAL( 1 ); ENDIF; IF s_x = 'X' THEN s_x := ''; IF i_append_line
<> 0 THEN APPEND_LINE; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF
; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; IF s_x <> '' THEN i_errors
:= i_errors + 1; s_text := CURRENT_LINE; POSITION( b_errors ); COPY_TEXT
( "The following line could not be unpacked properly:" ); SPLIT_LINE
; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part ); MOVE_VERTICAL
( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP r_x := SEARCH
( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x ); ERASE_CHARACTER( 1
); COPY_TEXT( ASCII( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDLOOP
; IF i_errors = 0 THEN SET( NO_WRITE, b_errors, ON ); ELSE POSITION
( BEGINNING_OF( b_errors ) ); COPY_TEXT( FAO
( "The following !UL errors were detected while unpacking !AS", i_errors
, s_file_spec ) ); SPLIT_LINE; SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" )
; ENDIF; EXIT;
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!!,passed." )
$ RETURN
$!
$START:
$ FILE_IS = "NNTP_TCPWINMULTINET.C"
$ CHECKSUM_IS = 1234264863
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X/*
X**++
X**  FACILITY:
X**      NNTP_TCPWINMULTINET
X**
X**  ABSTRACT:
V**      This module contains the QIO interface to the WIN/MULTINET implementa
Xtion
X**      of TCP/IP, V3.0.  The module provices a single-threaded interface to
X**      the NEWSSERVER module.
X**
X**  AUTHOR:
X**      Geoff Huston
X**
X**  COPYRIGHT:
X**      Copyright `169 1988,1989
X**
X**  MODIFICATION HISTORY:
X**      V5.5     7-Oct-1988     GIH
V**          Included modifications for WIN TCP/IP V3.0 support by Jim Patters
Xon
X**          (jimp@cognos.uucp)
X**          NOTE: I have NOT tested the WIN support modifications.
X**      V5.7    21-Nov-1988     PK
X**        - Changes to support WIN TCP 3.2 - Pekka Kytolaakso
X**        - There still was an error in WIN support. READ_NET both in
X**          nntp_tcpwin.c and in nntp_tcpcmu.c had an error.
X**          change: if (!iosb[1]) return(-1);
X**          to:     if (!iosb[1]) return(cancel_net(),-1);;
X**          Also make nntp_getchar a bit faster by defining it as a macro
X**             Pekka Kytolaakso
X**      V5.9    18-Apr-1989     GIH
X**        - Changes to allow compilation by GNUCC compiler
V**        - Modified GET_REMOTE_HOST routine to get the remote host name in`0
X32
V**          order to implement logging when receiving articles in NNTP_SERVER
X.
X**              Michelle R. Thibault
X**`009  - Add code for MULTINET, Mats Sundvall
X**--
X**/
X`012
X#if vax11c
X#module NNTP_TCPWINMULTINET "V5.9"
X#endif
X
X#if vax11c
X#include descrip
X#include iodef
X#include signal
X#include stdio
X#else
X#include <descrip.h>
X#include <iodef.h>
X#include <signal.h>
X#include <stdio.h>
X#endif
X
X                                /* Include WIN internet definitions */
X#include <types.h>
X#include <socket.h>
X#include <netdb.h>
X                                /* Include files for get_remote_host() */
X#include <in.h>
X#include <nameser.h>
X#include <resolv.h>
X
X#ifdef MULTINET
Xextern int h_errno;
Xstruct hostent *dest_host;
Xstruct sockaddr_in data_socket = `1230`125;
X#endif
X
X#define TIMEOUT     600         /* read wait timeout  - 10 minutes */
X#define X_BUF_SIZE  2048        /* size of line assembly read buffer */
X
X                                /* check status bits */
X#define cks(s)      if (!((c$status = (s)) & 1)) lib$signal(c$status)
X
V#define nntp_getchar() (!nntp_size ? nntp_fillbuf() : (--nntp_size, *nntp_ptr
X++))
X
Xstatic unsigned short f_i;      /* tcp channel input */
Xstatic unsigned short f_o;      /* tcp channel output */
X
Xstatic int c$status;            /* return status */
X
Xstatic unsigned short iosb[4];  /* i/o status blocks */
Xstatic unsigned short *i_o_sts = iosb;
Xstatic char nntp_buffer[X_BUF_SIZE];
Xstatic char *nntp_ptr = nntp_buffer;
Xstatic int nntp_size = 0;
X
Xint (*next_function)();
X
Xmain()
X`123
X    if (!server_init(1)) exit(1);
X    if (!open_net()) exit(1);
X    server_init_unit(1);
X    while (next_function) (*next_function)(1);
X    server_shut();
X    close_net();
X`125
X`012
X/*
X *  cancel_net
X *
X *  If the read timer expires then cancel this server task (by exiting)
X */
X
Xcancel_net()
X`123
X#ifdef DEBUG
X    fprintf(stderr,"Cancel_net\n");
X#endif
X    sys$cancel(f_o);
X    sys$cancel(f_i);
X    log_to_file(1);
X    write_net("400 service discontinued - read timeout\r\n");
X    cks(sys$qiow(0,f_i,IO$_DELETE,iosb,0,0,0,0,0,0,0,0));
X    cks(sys$qiow(0,f_o,IO$_DELETE,iosb,0,0,0,0,0,0,0,0));
X    cks(*i_o_sts);
X    sys$dassgn(f_i);
X    sys$dassgn(f_o);
X    exit(1);
X`125
X
Xstatic int nntp_fillbuf()
X`123
X    signal(SIGALRM,cancel_net);
X    alarm(TIMEOUT);
V    cks(sys$qiow(0,f_i,IO$_READVBLK,iosb,0,0,nntp_buffer, sizeof(nntp_buffer)
X,0,0,0,0));
X    alarm(0);
X    if (!iosb[1]) return(cancel_net(),-1);
X    nntp_ptr = nntp_buffer;
X    nntp_size = iosb[1]-1;
X    return(*nntp_ptr++);
X`125
X
X/*
X *  read_net
X *
X *  Get a line of text from the server.  Strips CR's and LF's.
X *  Parameters:     string  has the buffer space for the line received.
X *                  size    is the size of the buffer.
X *  Returns:           -1 on error, 0 otherwise.
X *  Side effects:      Talks to server, changes contents of "string"
X */
X
Xread_net(string, size,unit)
X    char *string;
X    int size;
X    int unit;
X`123
X    char *cp;
X    int c = 0;
X
X    for (cp = string; size; size--) `123
X        c = nntp_getchar();
X        if (c == '\r') c = nntp_getchar(); /* skip CR */
X        *cp++ = c;
X        if (c == '\n') break;
X        `125
X    *cp = '\0';
X#ifdef DEBUG
X    fprintf(stderr,"Read_net:%s\n",string);
X#endif
X    return(0);
X`125
X
X/*
X *  write_net
X *
X *  write to the client process - catch i/o errors and abort
X */
X
Xwrite_net(s,unit)
X    char *s;
X    int unit;
X`123
X#ifdef DEBUG
X    fprintf(stderr,"Write_net:%s\n",s);
X#endif
X    cks(sys$qiow(0,f_o,IO$_WRITEVBLK,iosb,0,0,s,strlen(s),0,1,0,0));
X    cks(*i_o_sts);
X`125
X
Xnext_call(unit,func,type)
X    int unit;
X    int (*func)();
X    int type;
X`123
X    next_function = func;
X`125
X`012
X/*
X *  open_net
X *
X *  Open TCP channel
X */
X
Xopen_net()
X`123
X    $DESCRIPTOR(in,"SYS$INPUT");
X    $DESCRIPTOR(out,"SYS$OUTPUT");
X
X#ifdef DEBUG
X    fprintf(stderr,"Open_net\n");
X#endif
X    cks(sys$assign(&in,&f_i,0,0));
X    cks(sys$assign(&out,&f_o,0,0));
X    return(1);
X`125
X`012
X/*
X *  close_net
X *
X *  Close the TCP link
X */
X
Xclose_net()
X`123
X#ifdef DEBUG
X    fprintf(stderr,"Close_net\n");
X#endif
X    sys$cancel(f_i);
X    sys$cancel(f_o);
X`125
X`012
X/*
X
XWhat follows is the getremhost() function for NNTP_SERVER with
XWIN/TCP. It uses getpeername() to get the address of remote host
Xfollowed by gethostbyname() to convert address to hostname.
XAt return remhost contains the name of remote host as it is received
Xfrom nameserver (NAMED), remuser is always "nntp" because TCP/IP
Xdoesn't provide any way to obtain remote username.
X`032
X  Seppo Syrjanen                      Internet : syrjanen@cc.Helsinki.FI
X  Computing Center                    BITNET   : syrjanen@finuha.bitnet
X  University of Helsinki              Phone    : +358 0 708 4132
X  Finland       "Cyborg's gotta do what cyborg's programmed to do." -ABC
X`032
X-------------------------------------------------------------------
X*/
X`032
X/*
X * Get name of the host requesting new connection
X *
X * for NNTP_SERVER with WIN/TCP. Tested with WIN/TCP 5.0.2.
X *
X * unsigned short f_i contains socket number of the connection.
X */
X`032
Xint getremhost(remhost, remuser, unit)
X  char *remhost, *remuser;
X  int unit;
X`123
X  struct hostent *hp;
X  struct sockaddr name;
X  int namelen;
X`032
X  if (remuser) strcpy(remuser,"nntp");
X  if (remhost) `123
X    namelen=sizeof(name);
X    getpeername(f_i,&name,&namelen);
X    hp = gethostbyaddr(&name.sa_data[2],4,AF_INET);
X    if (hp == NULL) `123
X      fprintf (stderr,"gethostbyaddr: error %d \n",h_errno);
X      strcpy(remhost,"TCP");
X      `125
X    else
X      strcpy(remhost,hp->h_name);
X    `125
X`125
$ GOSUB UNPACK_FILE
$ EXIT