/* * to preprocess using CYGWIN tools: * cpp -E -P -C -o rgb2html.java rgb2html_in.java * * or, using BORLAND BCC55 tools: * cpp32 -Sr -Sc -otextToHtml.java rgb2html_in.java * cpp32 -Sr -Sc -otextToHtml.c txToHt.c */ #include #include "style.h" #include #define MAXLINE 2500 char getline(char line[]); char lignevide(char to[], char from[]); void makealine(char sin[], int j); void usage(void); int un_P = 0; int main(int argc, char *argv[]) { int c, i; char line[MAXLINE]; char len[MAXLINE]; char *thetitle = argv[1]; if(argc < 2 ){ usage(); return 0; } printf(HEADER); PRINT_TITLE(thetitle); printf(STYLE); printf("

%s

\n", thetitle); while(getline(line) != 0){ printf("%s", line); } printf("

"); printf(FOOTER); return 0; } char getline(char s[]){ int c; int i= 0; char d[1024]; int split = 0; int tabulations = 0; int tabon = 0; if(un_P == 0){ printf("\n

"); un_P = 1; } while((c = getchar()) != EOF) { if(c == '\t'){ tabon = 1; tabulations = tabulations + 11; continue; } if(c == ' ' && tabon == 1){ tabulations += 1; continue; } if(c == '\n'){ s[i] = '<'; ++i; s[i] = '/'; ++i; s[i] = 'p'; ++i; s[i] = '>'; ++i; s[i] = '\n'; ++i; s[i] = '\0'; un_P = 0; return lignevide(d, s); } if(32 < c <= 'z'){ if(tabulations>0){ printf("\"|\"", tabulations); tabulations = 0; tabon = 0; } s[i] = c; ++i; break; } s[i] = c; ++i; } while((c = getchar()) != EOF && c != '\n') { if(c == '\t'){ // \t = 9 tabon = 1; tabulations = tabulations + 11; continue; } if(c == ' ' && tabon == 1){ tabulations = tabulations + 1; continue; } if(32 < c <= 'z' && tabulations>0){ printf("\"|\"", tabulations); tabulations = 0; tabon = 0; } s[i++] = c; /* if (i%80 == 0 && split == 0) { while((c = getchar()) != ' ' && c != '\n' && c != EOF) s[i++] = c; if(un_P == 1){ s[i++] = '<'; s[i++] = 'b'; s[i++] = 'r'; s[i++] = '>'; split = 1; } }*/ } if(c == '\n') { if(un_P == 1){ s[i] = '<'; ++i; s[i] = '/'; ++i; s[i] = 'b'; ++i; s[i] = 'r'; ++i; s[i] = '>'; ++i; s[i] = '\n'; ++i; } s[i] = c; } s[i] = '\0'; return *s; } char lignevide(char to[], char from[]) { int i; for(i = 0; from[i] != '\0' ; i++){ if(to[i] != ' ' && to[i] != '\t') to[i] = from[i]; } //to[i+1] = '\0'; return *to; } void usage(){ printf("\nUsage: xtTohtm [ title ] [ < input file.txt ] [ > output file.html ]\n"); }