// sgmlid.cxx // Report PUBLIC and SYSTEM Identifiers of SGML Documents // // Author: // Sean B. Palmer, inamidst.com // Based heavily on an example by James Clark // Derived from: // http://www.jclark.com/sp/generic.htm // Requires: SP source // The next two lines ensure bool gets defined appropriately. #include "config.h" #include "Boolean.h" #include "ParserEventGeneratorKit.h" #include ostream &operator<<(ostream &os, SGMLApplication::CharString s) { for (size_t i = 0; i < s.len; i++) os << char(s.ptr[i]); return os; } class SGMLIdentifier : public SGMLApplication { public: SGMLIdentifier() { } void startDtd(const StartDtdEvent &event) { if (event.haveExternalId) { if (event.externalId.havePublicId) cout << "PUBLIC: " << event.externalId.publicId << '\n'; if (event.externalId.haveSystemId) cout << "SYSTEM: " << event.externalId.systemId << '\n'; } } }; int main(int argc, char **argv) { ParserEventGeneratorKit parserKit; // Use all the arguments after argv[0] as filenames. EventGenerator *egp = parserKit.makeEventGenerator(argc-1, argv+1); SGMLIdentifier app; unsigned nErrors = egp->run(app); delete egp; return nErrors > 0; }