gih900@csc.anu.oz (Geoff Huston) (12/21/89)
+-+-+-+ Beginning of part 21 +-+-+-+ X `125 X if (fpl) `123 X************** X*** 2795,2801 V if (np = getenv("NNTP_SCRATCH")) sprintf(scratchfile,"%s:NNTP_%%X_%%X.TMP X",np); V else if (!getenv("SYS$SCRATCH")) strcpy(scratchfile,"NEWS_MANAGER:NNTP_%X X_%X.TMP"); X else strcpy(scratchfile,"SYS$SCRATCH:NNTP_%X_%X.TMP"); X! if (!(np = getenv("SYS$NODE"))) *np = '\0'; X strcpy(localhost, np); X if (np = strchr(localhost,':')) *np = '\0'; X s_to_lower(localhost); X--- 2819,2825 ----- V if (np = getenv("NNTP_SCRATCH")) sprintf(scratchfile,"%s:NNTP_%%X_%%X.TMP X",np); V else if (!getenv("SYS$SCRATCH")) strcpy(scratchfile,"NEWS_MANAGER:NNTP_%X X_%X.TMP"); X else strcpy(scratchfile,"SYS$SCRATCH:NNTP_%X_%X.TMP"); X! if (!(np = getenv("SYS$NODE"))) np = ""; X strcpy(localhost, np); X if (np = strchr(localhost,':')) np = '\0'; X s_to_lower(localhost); X************** X*** 2797,2803 X else strcpy(scratchfile,"SYS$SCRATCH:NNTP_%X_%X.TMP"); X if (!(np = getenv("SYS$NODE"))) *np = '\0'; X strcpy(localhost, np); X! if (np = strchr(localhost,':')) *np = '\0'; X s_to_lower(localhost); X cxt = (struct context *) malloc((max_stms + 1) * (sizeof *cxt)); X for (i = 0; i <= max_stms; ++i) cxt[i].grpv = 0; X--- 2821,2827 ----- X else strcpy(scratchfile,"SYS$SCRATCH:NNTP_%X_%X.TMP"); X if (!(np = getenv("SYS$NODE"))) np = ""; X strcpy(localhost, np); X! if (np = strchr(localhost,':')) np = '\0'; X s_to_lower(localhost); X cxt = (struct context *) malloc((max_stms + 1) * (sizeof *cxt)); X for (i = 0; i <= max_stms; ++i) cxt[i].grpv = 0; $ GOSUB UNPACK_FILE $ FILE_IS = "NNTP_TCPCMU.DIFF" $ CHECKSUM_IS = 51369178 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X*** [.news_v59_src]nntp_tcpcmu.c X--- [.news_src]nntp_tcpcmu.c X************** X*** 64,70 X #include <stdio.h> X #endif X `032 X! #define DEBUG 1 X #define TIMEOUT 600 /* read wait timeout - 10 minutes */ X #define X_BUF_SIZE 1024 /* size of line assembly read buffer */ X `032 X--- 64,70 ----- X #include <stdio.h> X #endif X `032 X! #define DEBUG 0 X #define TIMEOUT 600 /* read wait timeout - 10 minutes */ X #define X_BUF_SIZE 1024 /* size of line assembly read buffer */ X `032 X************** X*** 71,77 X /* check status bits */ X #define cks(s) if (!((c$status = (s)) & 1)) lib$signal(c$status) X `032 V! #define nntp_getchar() (!nntp_size ? nntp_fillbuf() : (--nntp_size, *nntp_p Xtr++)) X `032 X static unsigned short f; /* tcp i/o channel */ X `032 X--- 71,77 ----- X /* check status bits */ X #define cks(s) if (!((c$status = (s)) & 1)) lib$signal(c$status) X `032 V! #define nntp_getchar() (!nntp_input_size ? nntp_fillbuf() : (--nntp_input_s Xize, *nntp_input_ptr++)) X `032 X static unsigned short f; /* tcp i/o channel */ X `032 X************** X*** 79,87 X `032 X static unsigned short iosb[4]; /* i/o status blocks */ X static unsigned short *i_o_sts = iosb; X! static char nntp_buffer[X_BUF_SIZE]; X! static char *nntp_ptr = nntp_buffer; X! static int nntp_size = 0; X `032 X int (*next_function)(); X `032 X--- 79,87 ----- X `032 X static unsigned short iosb[4]; /* i/o status blocks */ X static unsigned short *i_o_sts = iosb; X! static char nntp_input_buffer[X_BUF_SIZE]; X! static char *nntp_input_ptr = nntp_input_buffer; X! static int nntp_input_size = 0; X `032 X #define POK_OUTPUT_BUFFER X #ifdef POK_OUTPUT_BUFFER X************** X*** 83,89 X static char *nntp_ptr = nntp_buffer; X static int nntp_size = 0; X `032 X! int (*next_function)(); X `032 X #if DEBUG X FILE *flog; X--- 83,94 ----- X static char *nntp_input_ptr = nntp_input_buffer; X static int nntp_input_size = 0; X `032 X! #define POK_OUTPUT_BUFFER X! #ifdef POK_OUTPUT_BUFFER X! static char nntp_output_buffer[X_BUF_SIZE];`009/* NNTP output buffer */ X! static char *nntp_output_ptr = nntp_output_buffer; X! static int nntp_output_size = X_BUF_SIZE; X! #endif X `032 X int (*next_function)(); X `032 X************** X*** 85,90 X `032 X int (*next_function)(); X `032 X #if DEBUG X FILE *flog; X #define LOGFILE "NEWS_MANAGER:NNTP.LOG" X--- 90,97 ----- X static int nntp_output_size = X_BUF_SIZE; X #endif X `032 X+ int (*next_function)(); X+`032 X #if DEBUG X FILE *flog; X #define LOGFILE "NEWS_MANAGER:NNTP.LOG" X************** X*** 97,103 X `032 X time(&cur_time); X flog = fopen(LOGFILE,"a+"); X! fprintf(flog,"TCP CMU open NNTP Connection %s",ctime(cur_time)); X fclose(flog); X #endif X `032 X--- 104,110 ----- X `032 X time(&cur_time); X flog = fopen(LOGFILE,"a+"); X! fprintf(flog,"TCP CMU open NNTP Connection %s",ctime(&cur_time)); X fclose(flog); X #endif X `032 X************** X*** 119,125 X fprintf(flog,"server unit inited\n"); X fclose(flog); X #endif X! while (next_function) (*next_function)(1); X server_shut(); X close_net(); X #if DEBUG X--- 126,138 ----- X fprintf(flog,"server unit inited\n"); X fclose(flog); X #endif X! while (next_function) `123 X!`032 X! #ifdef POK_OUTPUT_BUFFER X! write_out(); X! #endif X! (*next_function)(1); X! `125 X server_shut(); X close_net(); X #if DEBUG X************** X*** 143,148 X sys$cancel(f); X log_to_file(1); X write_net("400 service discontinued - read timeout\r\n"); X cks(sys$qiow(0,f,IO$_DELETE,iosb,0,0,0,0,0,0,0,0)); X cks(*i_o_sts); X sys$dassgn(f); X--- 156,166 ----- X sys$cancel(f); X log_to_file(1); X write_net("400 service discontinued - read timeout\r\n"); X+`032 X+ #ifdef POK_OUTPUT_BUFFER X+ write_out(); X+ #endif X+`032 X cks(sys$qiow(0,f,IO$_DELETE,iosb,0,0,0,0,0,0,0,0)); X cks(*i_o_sts); X sys$dassgn(f); X************** X*** 153,159 X `123 X signal(SIGALRM,cancel_net); X alarm(TIMEOUT); V! cks(sys$qiow(0,f,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--- 171,178 ----- X `123 X signal(SIGALRM,cancel_net); X alarm(TIMEOUT); X! cks(sys$qiow(0,f,IO$_READVBLK,iosb,0,0,nntp_input_buffer, X! sizeof(nntp_input_buffer),0,0,0,0)); X alarm(0); X if (!iosb[1]) return(cancel_net(),-1); X nntp_input_ptr = nntp_input_buffer; X************** X*** 156,164 V cks(sys$qiow(0,f,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 `032 X /* X--- 175,183 ----- X sizeof(nntp_input_buffer),0,0,0,0)); X alarm(0); X if (!iosb[1]) return(cancel_net(),-1); X! nntp_input_ptr = nntp_input_buffer; X! nntp_input_size = iosb[1]-1; X! return(*nntp_input_ptr++); X `125 X `032 X /* X************** X*** 198,203 X * write to the client process - catch i/o errors and abort X */ X `032 X write_net(s,unit) X char *s; X int unit; X--- 217,225 ----- X * write to the client process - catch i/o errors and abort X */ X `032 X+ #ifdef POK_OUTPUT_BUFFER X+ /* this asumes that nobody ever writes more than X_BUF_SIZE bytes */ X+`032 X write_net(s,unit) X char *s; X int unit; X************** X*** 199,206 X */ X `032 X write_net(s,unit) X! char *s; X! int unit; X `123 X #if DEBUG X fprintf(stderr,"Write_net:%s\n",s); X--- 221,228 ----- X /* this asumes that nobody ever writes more than X_BUF_SIZE bytes */ X `032 X write_net(s,unit) X! char *s; X! int unit; X `123 X register int size = strlen(s); X `032 X************** X*** 202,207 X char *s; X int unit; X `123 X #if DEBUG X fprintf(stderr,"Write_net:%s\n",s); X #endif X--- 224,231 ----- X char *s; X int unit; X `123 X+ register int size = strlen(s); X+`032 X #if DEBUG X fprintf(stderr,"Write_net:%s\n",s); X #endif X************** X*** 203,209 X int unit; X `123 X #if DEBUG X! fprintf(stderr,"Write_net:%s\n",s); X #endif X cks(sys$qiow(0,f,IO$_WRITEVBLK,iosb,0,0,s,strlen(s),0,1,0,0)); X cks(*i_o_sts); X--- 227,233 ----- X register int size = strlen(s); X `032 X #if DEBUG X! fprintf(stderr,"Write_net:%s\n",s); X #endif X `032 V if (nntp_output_size < size) write_out(); /* no space in buffer - flush * X/ X************** X*** 205,213 X #if DEBUG X fprintf(stderr,"Write_net:%s\n",s); X #endif X- cks(sys$qiow(0,f,IO$_WRITEVBLK,iosb,0,0,s,strlen(s),0,1,0,0)); X- cks(*i_o_sts); X- `125 X `032 X next_call(unit,func,type) X int unit; X--- 229,234 ----- X #if DEBUG X fprintf(stderr,"Write_net:%s\n",s); X #endif X `032 V if (nntp_output_size < size) write_out(); /* no space in buffer - flush * X/ X strncpy(nntp_output_ptr,s,size); X************** X*** 209,214 X cks(*i_o_sts); X `125 X `032 X next_call(unit,func,type) X int unit; X int (*func)(); X--- 230,266 ----- X fprintf(stderr,"Write_net:%s\n",s); X #endif X `032 V+ if (nntp_output_size < size) write_out(); /* no space in buffer - flush * X/ X+ strncpy(nntp_output_ptr,s,size); X+ nntp_output_ptr += size; X+ nntp_output_size -= size; X+ `125 X+`032 X+ write_out() X+ `123 V+ if (nntp_output_ptr != nntp_output_buffer) `123 /* something in the buff Xer */ X+ cks(sys$qiow(0,f,IO$_WRITEVBLK,iosb,0,0,nntp_output_buffer, X+ nntp_output_ptr - nntp_output_buffer,0,1,0,0)); X+ cks(*i_o_sts); X+ nntp_output_ptr = nntp_output_buffer; X+ nntp_output_size = X_BUF_SIZE; X+ `125 X+ `125 X+ #else X+`032 X+ write_net(s,unit) X+ char *s; X+ int unit; X+ `123 X+ #if DEBUG X+ fprintf(stderr,"Write_net:%s\n",s); X+ #endif X+`032 X+ cks(sys$qiow(0,f,IO$_WRITEVBLK,iosb,0,0,s,strlen(s),0,1,0,0)); X+ cks(*i_o_sts); X+ `125 X+ #endif X+`032 X next_call(unit,func,type) X int unit; X int (*func)(); X************** X*** 245,251 X close_net() X `123 X #if DEBUG X! fprintf(stderr,"Close_net\n"); X #endif X sys$cancel(f); X log_to_file(1); X--- 297,303 ----- X close_net() X `123 X #if DEBUG X! fprintf(stderr,"Close_net\n"); X #endif X `032 X #ifdef POK_OUTPUT_BUFFER`032 X************** X*** 247,257 X #if DEBUG X fprintf(stderr,"Close_net\n"); X #endif X! sys$cancel(f); X! log_to_file(1); X! cks(sys$qiow(0,f,IO$_DELETE,iosb,0,0,0,0,0,0,0,0)); X! cks(*i_o_sts); X! sys$dassgn(f); X `125 X `012 X /* X--- 299,314 ----- X #if DEBUG X fprintf(stderr,"Close_net\n"); X #endif X!`032 X! #ifdef POK_OUTPUT_BUFFER`032 X! write_out(); X! #endif X!`032 X! sys$cancel(f); X! log_to_file(1); X! cks(sys$qiow(0,f,IO$_DELETE,iosb,0,0,0,0,0,0,0,0)); X! cks(*i_o_sts); X! sys$dassgn(f); X `125 X `012 X /* X************** X*** 272,278 X short fill_2; X unsigned int linet_addr; X unsigned int finet_addr; X! `125 info_buffer; X `032 X getremhost(remhost,remuser,unit) X char *remhost, *remuser; X--- 329,335 ----- X short fill_2; X unsigned int linet_addr; X unsigned int finet_addr; X! `125 _align(quadword) info_buffer; X `032 X getremhost(remhost,remuser,unit) X char *remhost, *remuser; X************** X*** 275,282 X `125 info_buffer; X `032 X getremhost(remhost,remuser,unit) X! char *remhost, *remuser; X! int unit; X `123 X if (remhost) `123 X cks(sys$qiow(0,f,IO$_MODIFY,iosb,0,0,&info_buffer,276,0,0,0,0)); X--- 332,339 ----- X `125 _align(quadword) info_buffer; X `032 X getremhost(remhost,remuser,unit) X! char *remhost, *remuser; X! int unit; X `123 X if (remhost) `123 X `032 X************** X*** 278,288 X char *remhost, *remuser; X int unit; X `123 X! if (remhost) `123 X! cks(sys$qiow(0,f,IO$_MODIFY,iosb,0,0,&info_buffer,276,0,0,0,0)); X! cks(*i_o_sts); X! strncpy(remhost,info_buffer.fhost,info_buffer.fhost_len); X! remhost[info_buffer.fhost_len] = '\0'; X! `125 X! if (remuser) strcpy(remuser,"nntp"); X `125 X--- 335,355 ----- X char *remhost, *remuser; X int unit; X `123 X! if (remhost) `123 X!`032 V! /* i have had some trouble with this call - it is reinserted - BUT take it X out X! if you cannot get it to work and replace it with the single line following! X!`032 X! strcpy(remhost,"tcp"); X! */ X!`032 V! cks(sys$qiow(0,f,IO$_MODIFY,iosb,0,0,&info_buffer,sizeof(info_buffer),0 X,0,0,0)); X! cks(*i_o_sts); X! strncpy(remhost,info_buffer.fhost,info_buffer.fhost_len); X! remhost[info_buffer.fhost_len] = '\0'; V! /* if you cannot get it to work comment out the above block and put back th Xe X! strcpy line! */ X!`032 X! `125 X! if (remuser) strcpy(remuser,"nntp"); X `125 $ GOSUB UNPACK_FILE $ FILE_IS = "NNTP_TCPWIN.DIFF" $ CHECKSUM_IS = 1985494578 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X*** [.news_v59_src]nntp_tcpwin.c X--- [.news_src]nntp_tcpwin.c $ GOSUB UNPACK_FILE $ FILE_IS = "NNTP_TTY.DIFF" $ CHECKSUM_IS = 1985494842 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X*** [.news_v59_src]nntp_tty.c X--- [.news_src]nntp_tty.c $ GOSUB UNPACK_FILE $ EXIT -+-+-+-+-+ End of part 21 +-+-+-+-+-