/*
* HelpPC Reference Library to HTML converter. Ver 1.02
*
* Copyleft (l) Stanislav Sokolov (stanisls@gmail.com)
* The source is published under GNU General Public Licence
* ver. 2 of June 1991.
*
* Visit on-line version on:
* http://heim.ifi.uio.no/~stanisls/helppc/
*
* NOTE: If you want to make HTML version using UNIX, convert first
* all TXT files so that they have UNIX-style new-line.
*/
#include
#include
#include
#include
#include
#include
#define BASE_PATH "helppc"
struct conv{
char *file;
char *orig;
struct conv *next;
};
struct conv *c_head;
void cleanLine(char *);
char *makeFile(char *);
inline void rmFirst(char *);
char *makeFName(char *);
void convError(char *);
void parseLine(char *);
int buildConv(int argc, char **argv);
void strlowr(char *x);
void freeTable(struct conv *);
void idxSortWrt(struct conv [], int, FILE*);
void _qsort(struct conv c_list[], int first, int last);
int main(int argc, char **argv){
FILE *f = NULL, *fout = NULL;
char line[1024];
char *tmp, *fName;
char foutname[100];
int i;
char first;
int pending = 0, files;
fprintf(stderr, "\nHelpPC Reference Library to HTML converter. Ver 1.02\n"
"Copyleft (l) Stanislav Sokolov\n\n");
if(argc == 1){
fprintf(stderr, "Usage:\n %s [file.txt [file2.txt [...]]]\n"
"or\n %s *.txt\n\n", argv[0], argv[0]);
return 10;
}
mkdir(BASE_PATH, 0777);
/* Build conversion table */
fprintf(stderr, "Building conversion table and index files...\n");
i = buildConv(argc, argv);
fprintf(stderr, "Found %d keywords corresponding to %d unique entries.\n",
i >> 16, i & 0xFFFF);
/* Parse the files */
for(files = 1; files < argc; files++){ //For all files given to function
if((f = fopen(argv[files], "r")) == NULL){
fprintf(stderr, "Error opening %s\n", argv[files]);
exit(100);
}
fprintf(stderr, "\nParsing %s...\n", argv[files]);
while(fgets(line, 200, f) != NULL){
cleanLine(line);
line[strlen(line) - 1] = '\0';
first = line[0];
if(first == '@'){
/* do nothing */
} else if(first == ':'){ /*Make new html file*/
if(pending){
fprintf(fout, "\n\n