/* ######################################################## */ /* Conversion from troff to HTML */ /* Version 2 : 6/11/95 */ /* Update 11/11/95 Standard HTML Heading Format */ /* 15/11/95 .bp to HR Size Page Break */ /* 2/7/96 Corrected .TS/.TE translation */ /* (Paul E. Dunne) */ /* Written in C Code */ /* ####################################################### */ /* Dave J. McGaw and Paul E. Dunne; */ /* Department of Computer Science. */ /* University of Liverpool */ /* Liverpool L69 3BX */ /* Great Britain e-mail : u3djm@csc.liv.ac.uk */ /* http://www.csc.liv.ac.uk/users/u3djm */ /* (e-mail : ped@csc.liv.ac.uk */ /* http://www.csc.liv.ac.uk/users/ped) */ /* ######################################################## */ /* Header-File Inclusions */ /* ---------------------- */ #include #include #include #include /* Useful Definitions */ /* ------------------ */ #define true 1 #define false 0 #define roman 'R' #define italic 'I' #define bold 'B' /* Global Variables */ /* ---------------- */ int i,j,p,q; int length; int lines = 0; int directive; int nh_level_1 = 0; int nh_level_2 = 0; int nh_level_3 = 0; int center_count = 0; int pic_count = 1; /* Point Sizes */ /* ----------- */ int dpoint = 10; int cpoint = 10; /* Boolean Variables */ /* ----------------- */ int indent_para = false; int equation = false; int complete = false; int out_error = false; int non_fill = false; int center_box = false; /* List of Directives */ /* ------------------ */ const int error = 0; const int unused = 100; const int NH = 1; const int SH = 2; const int LP = 3; const int IP = 4; const int ps = 5; const int nr = 6; const int sp = 7; const int br = 8; const int bp = 9; const int ce = 10; const int nc = 11; const int ul = 12; const int ft = 13; const int DS = 14; const int EQ = 15; const int EN = 16; const int fi = 17; const int nf = 18; const int tl = 19; const int TS = 20; const int B1 = 21; const int B2 = 22; const int PS = 23; const int so = 24; const int bm = 25; /* Table Variables */ /* --------------- */ int table_matrix[70][20]; int cols; int rows; /* File Name Input */ /* --------------- */ char in[20]; char out[20]; /* Text Line and Checking Strings */ /* ------------------------------ */ char txt[256]; char checker[50]; /* Colour Setup Variables */ /* ---------------------- */ char answer = 'n'; char col_name[10]; char col_code[7]; char def_colour[10]; char colour_type[20]; /* Text Line Pointer - Used for indexing each line */ /* ----------------------------------------------- */ char *line_pointer = &txt[0]; /* Other Global Variables */ /* ---------------------- */ char apos = 39; char tab_char = '\t'; /* Font Initialisation */ /* ------------------- */ char font = roman; char cfont = roman; /* File Pointers to Input and Output Streams */ /* ----------------------------------------- */ FILE *infile; FILE *outfile; FILE *dictionary; /* Cover of Program */ /* ================ */ void cover() { for (i=0; i < 100; i++) { printf("\n"); } printf("\a"); printf("\t##############################################################\n"); printf("\n"); printf("\t TROFF FILE TO HTML DOCUMENT CONVERTER\n"); printf("\t =====================================\n"); printf("\t Input : file1.tro\tOutput : file2.html\n"); printf("\n"); printf("\t Taken from an original idea and concept by\n"); printf("\t Dr. Paul E. Dunne\n"); printf("\t Department of Computer Science\n"); printf("\t The University of Liverpool\n"); printf("\n"); printf("\t##############################################################\n"); printf("\n"); printf("\t (Version 1.0 - 15/6/95)\n"); printf("\t ---------------------\n"); printf("\t Written in the Ada Programming Language\n"); printf("\t Dr. Paul E. Dunne\n"); printf("\n"); printf("\t (Version 2.0 - 6/11/95)\n"); printf("\t ---------------------\n"); printf("\t Written in the C Programming Language\n"); printf("\t Dave 'Mack' McGaw\n"); printf("\n"); printf("\t##############################################################\n"); printf("\n"); printf("\t Amendments and Expansions\n"); printf("\t =========================\n"); printf("\t Version 1.0 - Ada Program\n"); printf("\t ----------- -----------\n"); printf("\t Table Processing\t\t\t\t16/6/95\n"); printf("\t Amended for TEXT_IO Package\t\t\t13/7/95\n"); printf("\t Table processing using HTML table specs\t\t\t1/7/96\n"); printf("\n"); printf("\t Version 2.0 - C Program\n"); printf("\t----------- ---------\n"); printf("\t File Interface opposing Command Line\t\t11/12/96\n"); printf("\t Standard HTML Header and Closure\t\t11/12/95\n"); printf("\t .bp to
Conversion for Page Breaks\t14/12/95\n"); printf("\t Data Dictionary to Netscapisms\t\t\t19/1/96\n"); printf("\t Escape character \"s\" utilises point size\t19/2/96\n"); printf("\t Line Drawing Function Included\t\t\t22/2/96\n"); printf("\t Table Handling using HTML Tabling\t\t14/3/96\n"); printf("\t Titling Directive\t\t\t\t18/3/96\n"); printf("\t Box Handling Directives\t\t\t20/3/96\n"); printf("\t Unused Directives Accounted for\t\t28/3/96\n"); printf("\t Errors in table-handling fixed (PED)\t\t2/7/96\n"); printf("\n"); printf("\t##############################################################\n"); printf("\n\n\n\n\n"); } /* Standard Header for Html File */ /* ============================= */ void header() { fprintf(outfile,"\n"); fprintf(outfile,"\n"); fprintf(outfile,"Troff File to Html Document Conversion\n"); fprintf(outfile,"\n"); fprintf(outfile,"\n"); fprintf(outfile,"\n\n"); fprintf(outfile,"\n"); fprintf(outfile,"\n\n"); fprintf(outfile,"\n\n"); } /* Grab the Next Line from the Input File */ /* ====================================== */ void next_line() { fgets(txt,256,infile); length = strlen(txt); line_pointer = &txt[0]; lines++; } /* Find a directive */ /* ================ */ int find_directive(char data[]) { int command = error; if (!strcmp(data, ".NH")) { command = NH; } else if (!strcmp(data, ".SH")) { command = SH; } else if ( (!strcmp(data, ".LP")) || (!strcmp(data, ".PP")) ) { command = LP; } else if ( (!strcmp(data, ".IP")) || (!strcmp(data, ".in")) ) { command = IP; } else if (!strcmp(data, ".ps")) { command = ps; } else if (!strcmp(data, ".nr")) { command = nr; } else if (!strcmp(data, ".sp")) { command = sp; } else if (!strcmp(data, ".br")) { command = br; } else if (!strcmp(data, ".bp")) { command = bp; } else if ( (!strcmp(data, ".ce")) || (!strcmp(data, ".cu")) ) { command = ce; } else if (!strcmp(data, ".nc")) { command = nc; } else if (!strcmp(data, ".ul")) { command = ul; } else if (!strcmp(data, ".ft")) { command = ft; } else if (!strcmp(data, ".DS")) { command = DS; } else if (!strcmp(data, ".EQ")) { command = EQ; } else if (!strcmp(data, ".EN")) { command = EN; } else if (!strcmp(data, ".fi")) { command = fi; } else if (!strcmp(data, ".nf")) { command = nf; } else if (!strcmp(data, ".tl")) { command = tl; } else if (!strcmp(data, ".TS")) { command = TS; } else if (!strcmp(data, ".B1")) { command = B1; } else if (!strcmp(data, ".B2")) { command = B2; } else if (!strcmp(data, ".PS")) { command = PS; } else if ( (!strcmp(data, ".so")) || (!strcmp(data, ".nx")) ) { command = so; } else if (!strcmp(data, ".bm")) { command = bm; } else if ( (!strcmp(data, ".KS")) || (!strcmp(data, ".KE")) ) { command = unused; } else if ( (!strcmp(data, ".ll")) || (!strcmp(data, ".pl")) ) { command = unused; } else if ( (!strcmp(data, ".po")) || (!strcmp(data, ".pn")) ) { command = unused; } else if ( (!strcmp(data, ".bd")) || (!strcmp(data, ".ss")) ) { command = unused; } else if (!strcmp(data, ".vs")) { command = unused; } return command; } /* Process Directive : Point Sizing (.ps) */ /* ====================================== */ /* Process the Point Size and Output */ /* --------------------------------- */ void process_point(int p) { int point_size; if (p < 10) { point_size = 1; } else if (p < 13) { point_size = 2; } else if (p < 15) { point_size = 3; } else if (p < 25) { point_size = 4; } else if (p < 29) { point_size = 5; } else if (p < 37) { point_size = 6; } else { point_size = 7; } fprintf(outfile, "\n\n", point_size); } /* Process the Directive Call */ /* -------------------------- */ void process_ps() { int a,b,c; if (line_pointer[3] == '\n') { cpoint = dpoint; } else { a = line_pointer[4]; b = line_pointer[5]; if ((a == '+') || (a == '-')) { c = line_pointer[6]; if (c == '\n') { if (a == '-') { cpoint -= (b-48); } else { cpoint += (b-48); } } else { b = (b-48)*10; c -= 48; if (a == '-') { cpoint -= (b+c); } else { cpoint += (b+c); } } } else { if (b == '\n') { cpoint = a-48; } else { a = (a-48)*10; b -= 48; cpoint = a+b; } } } process_point(cpoint); } /* Process Directive : Next Register (.nr) */ /* ======================================= */ void process_nr() { int a = line_pointer[7]; int b = line_pointer[8]; int t = 0; if (b == '\n') { t = a-48; } else { a = (a-48)*10; b -= 48; t = a+b; } if (line_pointer[4] == 'P') { dpoint = t; cpoint = t; process_point(cpoint); } else if (line_pointer[4] == 'V') { fprintf(outfile, "\n"); } else if (line_pointer[4] == 'N') { fprintf(outfile, "\n"); } else { printf("Line %d : ", lines); printf("** ERROR -- "); printf("HTML Does not handle register "); printf("\"%c%c\" **\n", line_pointer[4], line_pointer[5]); } } /* Determine if character is viewable in HTML */ /* ============================================ */ int check_printable(char x) { char ch; for (ch = 'a'; ch <= 'z'; ch++) { if (x == ch) { return true; } } for (ch = 'A'; ch <= 'Z'; ch++) { if (x == ch) { return true; } } for (ch = '0'; ch <= '9'; ch++) { if (x == ch) { return true; } } if ((x == ',') || (x == ';') || (x == ':') || (x == '|')) { return true; } else if ((x == '(') || (x == ')') || (x == '{') || (x == '}')) { return true; } else if ((x == '[') || (x == ']') || (x =='<') || (x == '>')) { return true; } else if ((x == '*') || (x == '+') || (x == '-') || (x == '/')) { return true; } else if ((x == '!') || (x == '?') || (x == '=') || (x == '%')) { return true; } else if ((x == '\n') || (x == '\t') || (x == '\\') || (x == '&')) { return true; } else if ((x == '.') || (x == '"') || (x == '@') || (x == '#')) { return true; } else if ((x == ' ') || (x == '~') || (x == '`')) { return true; } else if (x == apos) { return true; } else { return false; } } /* Font Changing, Roman, Italic, Bold */ /* ================================== */ void change_font(char x) { if (x == 'B') { font = cfont; cfont = bold; fprintf(outfile, ""); } else if (x == 'I') { font = cfont; cfont = italic; fprintf(outfile, ""); } else if (x == 'R') { if (cfont != roman) { fprintf(outfile, "", cfont); cfont = font; } if (cfont != roman) { fprintf(outfile, "", cfont); cfont = roman; } } } /* Reference to the Data Dictionary */ /* ================================ */ void check_dictionary(char data[]) { int dd_length; char troval[3]; char htmlval[6]; char dd_txt[50]; char *dd_line_pointer = &dd_txt[0]; dictionary = fopen("tro2html.dd", "r"); while (!feof(dictionary)) { fscanf(dictionary, "%s",troval); fscanf(dictionary, "%s",htmlval); if (!strcmp(troval, data)) { complete = true; fprintf(outfile,"%s", htmlval); break; } } fclose(dictionary); } /* Process a Line of Text for inline characters */ /* ============================================ */ void process_inline() { int icheck; int dollar_eqn = false; int sub_on = false; int sup_on = false; for (i=0; i"); } else if (!strcmp(checker, " sub ")) { sub_on = true; fprintf(outfile, ""); } else { i -= 5; } } } else if (dollar_eqn) { for (j=0; j < 5; j++) { checker[j] = line_pointer[i]; i++; } checker[5] = NULL; if (!strcmp(checker, " sup ")) { sup_on = true; fprintf(outfile, ""); } else if (!strcmp(checker, " sub ")) { sub_on = true; fprintf(outfile, ""); } else { i -= 5; } } /* Finally, checking if the characters */ /* ----------------------------------- */ icheck = check_printable(line_pointer[i]); if (icheck) { if (line_pointer[i] == '>') { fprintf(outfile, ">"); } else if (line_pointer[i] == '<') { fprintf(outfile, "<"); } else if (line_pointer[i] == '&') { fprintf(outfile, "&"); } else if (line_pointer[i] == '"') { fprintf(outfile, """); } else if (line_pointer[i] == '\n') { if (sup_on) { fprintf(outfile, ""); } if (sub_on) { fprintf(outfile, ""); } if (non_fill) { fprintf(outfile, "
\n"); } else if ((equation) || (dollar_eqn)) { fprintf(outfile, "
\n"); } else { fprintf(outfile, " \n"); } } else { fprintf(outfile,"%c", line_pointer[i]); } } else { printf("Line %d : ", lines); printf("** ERROR -- "); printf("Unprintable Character, \"%c\" **\n", line_pointer[i]); fprintf(outfile, " "); } out_error = true; } } } /* Process Directive : Number Heading (.NH) */ /* ========================================== */ void process_NH() { fprintf(outfile,"

"); if ((line_pointer[3] == '\n') || (line_pointer[4] == '1')) { nh_level_1++; nh_level_2 = 0; nh_level_3 = 0; fprintf(outfile, "%d\t", nh_level_1); } else if (line_pointer[4] == '2') { nh_level_2++; nh_level_3 = 0; fprintf(outfile, "%d.%d\t", nh_level_1, nh_level_2); } else if (line_pointer[4] == '3') { if (nh_level_2 == 0) { printf("Line %d : ", lines); printf("## WARNING -- "); printf("Incorrect Heading Structure ##\n", lines); nh_level_2++; } nh_level_3++; fprintf(outfile, "%d.%d.%d\t", nh_level_1, nh_level_2, nh_level_3); } else { printf("Line %d : ", lines); printf("** ERROR -- "); printf("Excess Heading Level **\n"); out_error = true; } next_line(); process_inline(); fprintf(outfile,"

\n"); } /* Process Directive : Sub-Heading (.SH) */ /* ======================================= */ void process_SH() { fprintf(outfile,"

"); next_line(); process_inline(); fprintf(outfile,"

\n"); } /* Process Directive : Left Paragraph (.LP) */ /* ========================================== */ void process_LP() { if (indent_para) { fprintf(outfile,"\n\n"); indent_para = false; } else { fprintf(outfile,"\n

\n\n"); } } /* Process Directive : Indent Paragraph (.IP) */ /* ============================================ */ void process_IP() { if (indent_para) { fprintf(outfile,"

  • \n"); } else { fprintf(outfile,"
      \n"); fprintf(outfile,"
    • \n"); indent_para = true; } } /* Process Directive : Spacing (.sp) */ /* ==================================== */ void process_sp() { fprintf(outfile,"\n
      \n"); } /* Process Directive : Line Break (.br) */ /* ======================================= */ void process_br() { fprintf(outfile,"\n
      \n"); } /* Process Directive : Page Break (.bp) */ /* ======================================= */ void process_bp() { fprintf(outfile,"\n
      \n"); } /* Process Directive : Center (.ce) */ /* ================================== */ void process_ce() { fprintf(outfile,"
      \n"); center_count++; } /* Process Directive : Non-Center (.nc) */ /* ===================================== */ void process_nc() { if (center_count = 0) { printf("Line %d : ", lines); printf("** Two Non-Center Tags Encountered! **\n"); out_error = true; } else { fprintf(outfile,"
      \n"); center_count--; } } /* Process Directive : Underline (.ul) */ /* ===================================== */ void process_ul() { fprintf(outfile,""); next_line(); process_inline(); fprintf(outfile,""); } /* Process Directive : (.ft) */ /* =========================== */ void process_ft() { change_font(line_pointer[4]); } /* Process Directive : Data (Pre-formatted) Input (.DS) */ /* ========================================================== */ void process_DS() { fprintf(outfile,"\n

      \n

      \n");
      next_line();
      
      while (strcmp(checker, ".DE")) {
      
      	for (i=0; i < length; i++) {
      		fprintf(outfile, "%c", line_pointer[i]);
      	}
      
      next_line();
      
      	for (i=0; i < 3; i++) {
      		checker[i] = line_pointer[i];
      	}
      
      checker[3] = NULL;
      
      }
      
      fprintf(outfile, "\n
      \n

      \n"); } /* Process Directive : Process Equations (.EQ) */ /* ============================================== */ void process_EQ() { equation = true; } /* Process Directive : End Equation (.EN) */ /* ====================================== */ void process_EN() { equation = false; } /* Process Directive : Fill Option (.fi) */ /* ===================================== */ void process_fi() { non_fill = false; } /* Process Directive : Non-Fill Option (.nf) */ /* ========================================= */ void process_nf() { non_fill = true; fprintf(outfile, "\n
      \n"); } /* Process Directive : Titling (.tl) */ /* ==================================== */ void process_tl() { int section = 0; fprintf(outfile, "\n\n"); fprintf(outfile, "\n\n"); for (i=4; i < length; i++) { if (line_pointer[i] == apos) { section++; if (section == 1) { fprintf(outfile, ""); } } else if (line_pointer[i] == '\\') { i++; if (line_pointer[i] == 'f') { i++; if ((line_pointer[i] == 'B') || (line_pointer[i] == 'I') || (line_pointer[i] == 'R')) { change_font(line_pointer[i]); } else { fprintf(outfile, "\\f%c", line_pointer[i]); } } } else { fprintf(outfile, "%c", line_pointer[i]); } } fprintf(outfile, "\n\n"); fprintf(outfile, "
      "); } else if (section == 2) { fprintf(outfile, ""); } else if (section == 3) { fprintf(outfile, ""); } else if (section == 4) { fprintf(outfile, "
      \n"); } /* Process Directive : Tables (.ts) */ /*====================================================*/ /* WARNING: Don't try anything too clever!! */ /* Tables with l,r, and c column specs only, should */ /* process O.K; Tables with multi-column span MAY */ /* need post-translation editing. Change of font, */ /* point size, and eqn will amost certainly require */ /* some editing. */ /* Max: 20 column and 70 different row specs. */ /* (if you need more change the spec. of table_matrix */ /* above. */ /* ===================================================*/ /* Process Table Options */ /* --------------------- */ void process_table_options() { char box_type = 'e'; if (line_pointer[1] != ' ') { i=0; while (line_pointer[i] != ';') { /* Check for Centering of the Table */ /* -------------------------------- */ if (line_pointer[i] == 'c') { center_box = true; fprintf(outfile, "\n

      \n"); i+=6; } /* Check for Box Type */ /* ------------------ */ if (line_pointer[i] == 'b') { box_type = line_pointer[i]; i+=4; } else if (line_pointer[i] == 'a') { box_type = line_pointer[i]; i+=6; } /* Finally, Grab the new Tab Character (if any) */ /* -------------------------------------------- */ else if (line_pointer[i] == 't') { tab_char = line_pointer[i+4]; i+=6; } else { i+=1; } } next_line(); } fprintf(outfile, "\n"); } else if (box_type == 'a') { fprintf(outfile, " border=1>\n"); } else if (box_type == 'b') { fprintf(outfile, " border=1>\n"); } else { fprintf(outfile, ">\n"); } fprintf(outfile, "\n"); } /* Load the Table with Data Entries */ /* -------------------------------- */ void load_table() { q=0; for (i=0; i < length; i++) { if (line_pointer[i] != ' ') { table_matrix[p][q] = line_pointer[i]; q++; } } p++; } /* Data Checking of Table Cell */ /* --------------------------- */ void process_cell() { if (table_matrix[p][q] == 'l') { fprintf(outfile, ""); process_cell(); for (i=0; i < length; i++) { if (line_pointer[i] == '\n') { fprintf(outfile, "\n"); p++; q=0; if (p==(rows+1)) { p=rows; } } else if (line_pointer[i] == tab_char) { process_cell(); } else { fprintf(outfile, "%c", line_pointer[i]); } } next_line(); for (i=0; i < 3; i++) { checker[i] = line_pointer[i]; } checker[3] = NULL; } fprintf(outfile, "\n\n"); fprintf(outfile, "\n
      "); } else if (table_matrix[p][q] == 'r') { fprintf(outfile, ""); } else if (table_matrix[p][q] == 'c') { fprintf(outfile, ""); } q++; } /* Process the Directive Call */ /* -------------------------- */ void process_TS() { next_line(); process_table_options(); p=0; while (line_pointer[length-2] != '.') { load_table(); next_line(); } /*----------------------------------------*/ /* Pick up last row description (default) */ /*----------------------------------------*/ load_table(); next_line(); rows=p-1; p=0; q=0; while (strcmp(checker, ".TE")) { /*---------------------------------------*/ /* Format individual rows (ignoring tbl */ /* directives = and _) */ /*---------------------------------------*/ fprintf(outfile, "\n
      \n"); if (center_box) { fprintf(outfile, "
      \n"); } } /* Process Directive : Single Box On (.B1) */ /* ========================================== */ void process_B1() { fprintf(outfile, "\n
      \n"); fprintf(outfile, "\n\n"); fprintf(outfile, "\n"); fprintf(outfile, "
      \n"); } /* Process Directive : Single Box Off (.B2) */ /* ========================================== */ void process_B2() { fprintf(outfile, "
      "); fprintf(outfile, "\n
      \n"); } /* Process Directive : Picture Section (.PS) */ /* ========================================= */ void process_PS() { fprintf(outfile, "\n
      \n
      \n
      \n"); fprintf(outfile, "\n", pic_count); fprintf(outfile, "
      Insert Picture File p_%d.pic
      \n", pic_count); fprintf(outfile, "
      \n"); pic_count++; while (strcmp(checker, ".PE")) { for (i=0; i < 3; i++) { checker[i] = line_pointer[i]; } checker[3] = NULL; next_line(); } } /* Process Directive : Graphics Handling (.bm) */ /* ============================================== */ void process_bm() { fprintf(outfile, "\n
      \n\n
      \n"); } /* Process Directive : Stack Object / Insert File (.so) */ /* ================================================== */ void process_so() { fprintf(outfile, "\n
      \nInsert File "); for (i=4; i < length-1; i++) { fprintf(outfile, "%c", line_pointer[i]); } fprintf(outfile, "\n
      \n"); } /* Colour Setup */ /* ------------ */ void get_colour(char colour[]) { strcpy(col_code, "xxxxxx"); if (!strcmp(colour, "black")) { strcpy(col_code, "000000"); } else if (!strcmp(colour, "white")) { strcpy(col_code, "FFFFFF"); } else if (!strcmp(colour, "grey")) { strcpy(col_code, "777777"); } else if (!strcmp(colour, "red")) { strcpy(col_code, "FF0000"); } else if (!strcmp(colour, "green")) { strcpy(col_code, "00FF00"); } else if (!strcmp(colour, "blue")) { strcpy(col_code, "0000FF"); } else if (!strcmp(colour, "yellow")) { strcpy(col_code, "FFFF00"); } } void set_colour() { if (!strcmp(col_name, def_colour)) { printf("(Using default)\n"); } else { get_colour(col_name); if (col_code[0] == 'x') { printf("(Illegal Colour - Using default)\n"); } else { fprintf(outfile," %s=\"%s\"", colour_type, col_code); } } } void bkgrnd_colour() { printf("Background Colour (default : grey) : "); scanf("%s", col_name); strcpy(def_colour,"grey"); strcpy(colour_type,"bgcolor"); set_colour(); } void text_colour() { printf("Text Colour (default : black) : "); scanf("%s", col_name); strcpy(def_colour,"black"); strcpy(colour_type,"text"); set_colour(); } void link_colour() { printf("Link Colour (default : blue) : "); scanf("%s", col_name); strcpy(def_colour,"blue"); strcpy(colour_type,"link"); set_colour(); } void vlink_colour() { printf("Visited Link Colour (default : red) : "); scanf("%s", col_name); strcpy(def_colour,"red"); strcpy(colour_type,"vlink"); set_colour(); } void colour_setup() { bkgrnd_colour(); text_colour(); link_colour(); vlink_colour(); } /* Main Program */ /* ============ */ main() { cover(); printf("\nPlease Enter the name of the Input File : "); scanf("%s", in); infile = fopen(in, "r"); if (infile == NULL) { printf("\a\nErrors"); printf("\n------\n"); printf("Input Line : ** Invalid Filename **\n"); printf("\n\nTerminating Program!\n"); printf("====================\n\n"); exit(1); } else { printf("Please Enter the name of the Output File : "); scanf("%s", out); outfile = fopen(out, "w"); if (outfile == NULL) { printf("\a\nErrors"); printf("\n------\n"); printf("Output Line : ** Cannot Open Output File **\n"); printf("\n\nTerminating Program!\n"); printf("====================\n\n"); exit(1); } } header(); printf("Change Colour Setup (y/n) ? : "); scanf("%c", &answer); scanf("%c", &answer); if (answer == 'y') { colour_setup(); } else { printf("Using default colours\n"); } fprintf(outfile, ">\n\n"); printf("\nErrors\n"); printf("------\n"); do { if (line_pointer[0] == '.') { for (i=0; i<3; i++) { checker[i] = line_pointer[i]; } checker[3] = NULL; directive = find_directive(checker); if (directive == 1) { process_NH(); } else if (directive == 2) { process_SH(); } else if (directive == 3) { process_LP(); } else if (directive == 4) { process_IP(); } else if (directive == 5) { process_ps(); } else if (directive == 6) { process_nr(); } else if (directive == 7) { process_sp(); } else if (directive == 8) { process_br(); } else if (directive == 9) { process_bp(); } else if (directive == 10) { process_ce(); } else if (directive == 11) { process_nc(); } else if (directive == 12) { process_ul(); } else if (directive == 13) { process_ft(); } else if (directive == 14) { process_DS(); } else if (directive == 15) { process_EQ(); } else if (directive == 16) { process_EN(); } else if (directive == 17) { process_fi(); } else if (directive == 18) { process_nf(); } else if (directive == 19) { process_tl(); } else if (directive == 20) { process_TS(); } else if (directive == 21) { process_B1(); } else if (directive == 22) { process_B2(); } else if (directive == 23) { process_PS(); } else if (directive == 24) { process_so(); } else if (directive == 25) { process_bm(); } else if (directive == 100) { printf("Line %d : ", lines); printf("## WARNING -- "); printf("Directive \"%s\" Unused in HTML ##\n", checker); } else if (directive == 0) { printf("Line %d : ", lines); printf("** ERROR -- "); printf("Unknown Directive Found, \"%s\" **\n", checker); out_error = true; } } else { process_inline(); } next_line(); } while (!feof(infile)); if (indent_para) { fprintf(outfile, "\n
    \n"); } closure(); if (out_error == false) { printf("No Errors Found!\n"); } printf("\n\nConversion Complete!"); printf("\n====================\n\n"); fclose(infile); fclose(outfile); exit(0); }