/* * [FindMissingRFCs.java] * * Summary: Find which RFCs do not exist on Randy's site. * * Copyright: (c) 2013-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2013-04-06 initial release */ package com.mindprod.repair; import com.mindprod.common18.EIO; import com.mindprod.csv.CSVWriter; import com.mindprod.hunkio.HunkIO; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.BitSet; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Find which RFCs do not exist on Randy's site. *

* generates E:\mindprod\embellishment\missingrfcs.csv * * @author Roedy Green, Canadian Mind Products * @version 1.0 2013-04-06 initial release * @since 2013-04-06 */ public class FindMissingRFCs { private static final int MAX_RFC = com.mindprod.htmlmacros.macro.RFC.MAX_RFC; private static final Pattern pattern = Pattern.compile( ">RFC (\\d+):<", Pattern.CASE_INSENSITIVE ); /** * We screen scrape the website to get a list of RFC numbers supported. * Then we emit just a list of missing RFCs. * * @param args not used * * @throws java.io.IOException */ public static void main( final String[] args ) throws IOException { // rem we have download http://openrfc.org/rfc-index.pl C:\temp\rfcindex.html final String contents = HunkIO.readEntireFile( new File( "C:/temp/rfcindex.html" ) ); BitSet present = new BitSet( MAX_RFC + 1 ); final Matcher m = pattern.matcher( contents ); // Matchers are used both for matching and finding. while ( m.find() ) { present.set( Integer.parseInt( m.group( 1 ) ) ); } // find all present. Presume everything else is missing. final File outFile = new File( "E:/com/mindprod/repair/missingrfcs.csv" ); final PrintWriter prw = EIO.getPrintWriter( outFile, 24 * 1024, EIO.UTF8 ); final CSVWriter w = new CSVWriter( prw, -1 /* quote level */, ',', '\"', '#', true ); for ( int i = 0; i < MAX_RFC + 1; i++ ) { if ( !present.get( i ) ) { w.put( i ); w.nl(); } } w.close(); } }