/*============================================================================ | Copyright (C) 2001-2002 Jonathan Harm | | | This program is free software; you can redistribute it and/or | modify it under the terms of the GNU General Public License | as published by the Free Software Foundation; either version 2 | of the License, or (at your option) any later version. | This program is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY; without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | GNU General Public License for more details. | You should have received a copy of the GNU General Public License | along with this program; if not, write to the Free Software | | Foundation, Inc., | 59 Temple Place - Suite 330 | Boston, MA 02111-1307, USA. | | | | This program is under the GPL see http://www.gnu.org for more info | | | http://change.to/opensource | 110983@lycos.com | \============================================================================*/ // html2html ver1.1 by Jonathan Harm (110983@lycos.com) // http://change.to/opensource #include #include int main(int argc, char *argv[]) { int ch; FILE *input, *output; //if user did not enter to arguments //then show them what to do. if( argc != 3 ) { printf("\n\nusage:\n$%s [input file name] [output file name]\n\n", argv[0]); exit(1); } else if( argc == 3 ) { if ( ( input = fopen( argv[1], "r")) == NULL) { fprintf(stderr, "error opening file"); } if ( ( output = fopen( argv[2], "a+")) == NULL) { fprintf(stderr, "error opening file"); } while ( (ch = fgetc(input)) != EOF) { if (ch == '<' ) //check for opening of tag { fprintf(output, "<"); //print the less than sign to output file } else if (ch == '>' ) //check for closing of tag { fprintf(output, ">"); //print the greater than sign to output file } else if (ch == 32) //32 is space character { fprintf(output, " "); } else if( ch == '\t' ) { //literal tab char is but most browsers ignore it, so use 8 spaces instead fprintf(output, "        "); } else if (ch == '\n' || ch == '\r') { fprintf(output, "
\n"); //if the end of the line has been reached, print the line break } else { fprintf(output, "%c", ch); //if it isn't < or > then dont change it } } //end of while loop } return 0; }