$! /* acf4:vmsnet.sources / gjc@mitech.com / 10:55 am Dec 18, 1990 */ $! Allows you to take the file produced by extracting items $! from VAXNOTES and convert it to a format that you can $! feed to ANU NEWS (or any other news software for that matter $! which uses the standard usenet "#! rnews ..." format). $! $! This is not very sophisticated in the processing of $! the subject line, and doesn't do anything with references $! for followups. But it does take care of some tricky $! file manipulation and formatting issues so it should be $! easy to extend. $! $! $! ...................... Cut between dotted lines and save. ..................... $!............................................................................. $! VAX/VMS archive file created by VMS_SHARE V06.03 20-Oct-1988. $! $! 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 GJC $! on 18-DEC-1990 15:49:56.06. $! $! It contains the following 1 file: $! CONVERT.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.03 20-Oct-1988 requires VMS V4.4 or higher." $ EXIT 44 $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"; pat_trail := " " & LINE_END;POSITION( BEGINNING_OF( b_part ) ); LOOP b := SEARCH( pat_trail, FORWARD); EXITIF b=0; POSITION( END_OF( b ) ) ; LOOP MOVE_HORIZONTAL( -1 ); EXITIF CURRENT_CHARACTER <> ' '; ERASE_CHARACTER ( 1 ); EXITIF CURRENT_OFFSET=0; ENDLOOP; 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 ); IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII ( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; 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 = "CONVERT.C" $ CHECKSUM_IS = 712298935 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X/*`032 X * COPYRIGHT (c) 1990 BY * X * MITECH CORPORATION, CONCORD, MASSACHUSETTS. * X *`009`009`009 ALL RIGHTS RESERVED * X XPermission to use, copy, modify, distribute and sell this software and Xits documentation for any purpose and without fee is hereby granted, Xprovided that the above copyright notice appear in all copies and that Xboth that copyright notice and this permission notice appear in Xsupporting documentation, and that the name of Mitech Corporation not Xbe used in advertising or publicity pertaining to distribution of the Xsoftware without specific, written prior permission. X XMITECH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL XMITECH BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS XSOFTWARE. X XProgram: Notesconvert XPurpose: Convert a file generated by VAX NOTES using a command X such as EXTRACT/ALL/UNSEEN XYZ.NOTES-DATA X into a file suitable for usenet format news processing. X e.g. by ANU-NEWS using a command such as X $ NEWS/NOSCREEN ADD FILE/NETFEED XYZ.NEWS-DATA XCreated: 18-DEC-1990 XAuthor: George Carrette, GJC@MITECH.COM X XTO DO: Generate a Message-ID field, and use the References field so that X read/follow works for subnotes. X X*/ X X#include X#include X Xchar *newsgroup_name; Xchar *newsgroup_prefix = "isvnet."; X Xchar *art_header; Xchar *art_sep; X Xlong header_size = 80; Xlong buffn = 1024; X Xchar *inbuff; Xchar *msg_subj; Xchar *outbuff; X Xlong msg_nlines; Xchar *msg_from; Xchar *msg_date; X Xchar *output_buffer = NULL; Xlong output_buffn = 0; Xlong output_nchars = 0; X Xchar *output_pointer; X Xoutput_flush(to) X FILE *to; X`123fwrite(output_buffer,output_nchars,1,to); X output_pointer = output_buffer; X output_nchars = 0;`125 X Xoutput(line) X char *line; X`123long n; X n = strlen(line); X if ((n + output_nchars) >= output_buffn) X `123output_buffn *= 2; X output_buffn += buffn; X if (n > output_buffn) output_buffn = n; X if (output_buffer == NULL) X output_buffer = (char *) malloc(output_buffn); X else X output_buffer = (char *) realloc(output_buffer,output_buffn); X output_pointer = output_buffer + output_nchars;`125 X memcpy(output_pointer,line,n); X output_nchars += n; X output_pointer += n;`125 X Xchar *make_header(x) X int x; X`123char *p; X p = (char *) malloc(header_size + 2); X p[header_size] = '\n'; X p[header_size+1] = 0; X memset(p,x,header_size); X return(p);`125 X Xmain(argc,argv) X int argc; X char **argv; X`123FILE *in,*out; X char *p,*p1,*p2; X long j; X if (argc != 3) X `123fprintf(stderr,"%%NOTESCONVERT-F-ARGS wrong number of arguments\n"); X p = strrchr(argv[0],']'); X fprintf(stderr,"%s \n", X`009 (p) ? p+1 : "notesconvert"); X exit(44);`125 X if (!(in = fopen(argv[1],"r"))) X `123perror(argv[1]); X exit(vaxc$errno);`125 X if (!(out = fopen(argv[2],"w"))) X `123perror(argv[2]); X exit(vaxc$errno);`125 X inbuff = (char *) malloc(buffn); X outbuff = (char *) malloc(buffn); X msg_subj = (char *) malloc(buffn); X msg_from = (char *) malloc(buffn); X msg_date = (char *) malloc(buffn); X art_header = make_header('='); X art_sep = make_header('-'); X fgets(inbuff,buffn,in); X p1 = strrchr(inbuff,']'); X if (!p1) X `123fprintf(stderr,"%%NOTESCONVERT-F-BAD no header line\n"); X exit(44);`125 X ++p1; X p2 = strchr(p1,'.'); X if (!p2) X `123fprintf(stderr,"%%NOTESCONVERT-F-BAD bad header line\n"); X exit(44);`125 X *p2 = 0; X newsgroup_name = (char *) malloc(strlen(newsgroup_prefix) + X`009`009`009`009 strlen(p1) + 1); X strcpy(newsgroup_name,newsgroup_prefix); X strcat(newsgroup_name,p1); X fprintf(stderr,"Newsgroups: %s\n",newsgroup_name); X fgets(inbuff,buffn,in); X while(1) X `123p = fgets(inbuff,buffn,in); X if ((!p) `124`124 (*p == 0)) X `123fprintf(stderr,"%%NOTESCONVERT-I-END end of file\n"); X fclose(out); X exit(1);`125 X if ((inbuff[0] == '\f') && (inbuff[1] == '\n') && X`009(inbuff[2] == 0)) X continue; X if (strcmp(inbuff,art_header) != 0) X `123fprintf(stderr,"%%NOTESCONVERT-F-BAD item header not found\n"); X fclose(out); X exit(44);`125 X extract_msg_subject(fgets(inbuff,buffn,in)); X extract_msg_info(fgets(inbuff,buffn,in)); X while(fgets(inbuff,buffn,in)) X if (strcmp(inbuff,art_sep) == 0) break; X sprintf(outbuff,"From: %s\n",msg_from); X output(outbuff); X sprintf(outbuff,"Newsgroups: %s\n",newsgroup_name); X output(outbuff); X sprintf(outbuff,"Subject: %s\n",msg_subj); X output(outbuff); X sprintf(outbuff,"Date: %s\n",msg_date); X output(outbuff); X sprintf(outbuff,"Lines: %d\n",msg_nlines+1); X output(outbuff); X output("\n"); X for(j=0;j '9')) --p1; X msg_nlines = 0; X factor = 1; X while((*p1 >= '0') && (*p1 <= '9')) X `123msg_nlines = msg_nlines + (factor * (*p1 - '0')); X factor *= 10; X --p1;`125 X while(*p1 == ' ') --p1; X *(p1+1) = 0; X strcpy(msg_from,line);`125 $ GOSUB UNPACK_FILE $ EXIT