This is HTML_Stuff.m in view mode; [Download] [Up]
// Copyright H. Giesen, University of Koblenz-Landau 1996 #import "HTML_Stuff.h" #import "BibliographicFile.h" #import "BibTeXObject.h" #import "Preferences.h" static id htmlObject = nil; static char * html_HDR1= "<html><head><title>BibTeX - Frontend</title></head>\n" "<body><pre><h2>----- %s -----</h2></pre>\n"; static char *tableHdr = "<DL><DT><H3>all entries of file %s</H3></DT>\n" "<DD> <select NAME=\"X\" size=\"10\" multiple=\"multiple\" >"; static char *eoTable = "</select></DD></DL>"; static char *entryTableHdr = "\n<FORM> <TABLE BORDER=3>\n"; static char *eoEntryTable = "\n</TABLE> </FORM>\n"; static char * html_EOF1= "</body></html>\n"; @implementation HTML_Stuff + new { if( htmlObject==nil ){ htmlObject = [[super alloc] init]; } return htmlObject; } - (BOOL) writeHeaderFor:(BibliographicFile *)file { char fileNameBuf[1024]; if( htmlFp ){ fclose( htmlFp ); } sprintf( fileNameBuf, "%s/htmlTest.html", [[Preferences new] tempDirectory] ); htmlFp = fopen( fileNameBuf, "w+" ); if( htmlFp==NULL ){ fprintf( stderr, "cannot open %s\n", fileNameBuf ); return NO; } fprintf( htmlFp, html_HDR1, [file fullPath] ); return YES; } - writeTailFor:(BibliographicFile *)file { fprintf( htmlFp, html_EOF1 ); fclose( htmlFp ); return self; } - writeTableHeaderFor:(BibliographicFile *)file { //fprintf( htmlFp, tableHdr ); fprintf( htmlFp, tableHdr, [file fullPath] ); return self; } - writeEndOfTable { fprintf( htmlFp, eoTable ); return self; } - writeEntryTableFor:(BibliographicFile *)file { int i; configListType *item; preferences = [Preferences new]; configList = [preferences configList]; fprintf( htmlFp, entryTableHdr ); for( i=0; i<[configList count]; i++ ){ item = ((configListType*)[configList elementAt:i]); fprintf( htmlFp, "<TR> <TD>%s</TD>" "<TD> <TEXTAREA NAME=\"f%d\" ROWS=1 COLS=32>" "this is the text </TEXTAREA> </TD></TR>\n", item->fieldName, i ); } fprintf( htmlFp, eoEntryTable ); return self; } - writeEntryTableFor:(BibliographicFile *)file entry:(BibTeXObject *)obj { int i; configListType *item; locType location; char aTextBuffer[1024]; preferences = [Preferences new]; configList = [preferences configList]; [obj parseSelf]; fprintf( htmlFp, entryTableHdr ); for( i=0; i<[configList count]; i++ ){ item = ((configListType*)[configList elementAt:i]); location.start = item->start; // set by the parser location.length = item->length; [obj convertRawField:location to:aTextBuffer]; if( SHOW & item->mode[[obj entryType]] ){ fprintf( htmlFp, "<TR> <TD>%s</TD>" "<TD> <TEXTAREA NAME=\"f%d\" ROWS=1 COLS=32>" "%s</TEXTAREA> </TD></TR>\n", item->fieldName, i, aTextBuffer ); } } fprintf( htmlFp, eoEntryTable ); return self; } - writeHTMLfor:(BibliographicFile *)file { int i; char locBuffer[1024]; if( file==nil ){ NXBeep(); return self; } if( [self writeHeaderFor:file]==NO ) return self; [self writeTableHeaderFor:file]; for( i=0; i<[file entries]; i++ ){ id obj = [file objectAt:i]; [obj copyRange:[obj key] toBuffer:locBuffer]; fprintf( htmlFp, "\t<option> %s\n", locBuffer ); } [self writeEndOfTable]; [self writeEntryTableFor:file entry:[file objectAt:2]]; [self writeTailFor:file]; return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.