");
else
{ LATEX_CLOSES_T(T_DESC)
LATEX_OPEN(tagnr)
}
else if (CLOSE_TAG(T_DD))
LATEX_CLOSES(tagnr)
else if (OPEN_TAG(T_A))
{ int j;
for (j = stack_depth - 1;
j >= 0 && stack[j].closing == C_OPT; j--)
if (stack[j].tagkind == T_A)
{ LATEX_CLOSES(H_A);
break;
}
if (a_href && href_okay)
{ if (active_href)
ERROR(html_fn, ln, "nested href")
active_href = TRUE;
}
LATEX_OPEN_C(tagnr, a_href ? C_YES : C_OPT);
}
else if (CLOSE_TAG(T_A))
{
LATEX_CLOSES(tagnr)
}
else if (OPEN_TAG(T_VERB))
LATEX_OPEN(tagnr)
else if (CLOSE_TAG(T_VERB))
LATEX_CLOSES_K()
else if (OPEN_TAG(T_P))
{ if (stack[stack_depth-1].tagkind == T_P)
LATEX_CLOSES(H_P);
if (in_header && option_info)
ERROR(html_fn, ln, " ignored in header")
LATEX_OPEN(tagnr)
}
else if (CLOSE_TAG(T_P))
LATEX_CLOSES(tagnr)
else if (OPEN_TAG(T_CHAR))
{ int j;
bool found = FALSE;
for (j = stack_depth - 1; j >= 0; j--)
if (stack[j].tagnr == tagnr)
{ found = TRUE;
break;
}
if (found && j == stack_depth - 1)
{ REPLACE_TAG();
LATEX_CLOSES(tagnr)
}
else
{ if (found)
ERROR1(html_fn, ln, "nested <%s>", html_com)
LATEX_OPEN(tagnr)
}
}
else if (CLOSE_TAG(T_CHAR))
LATEX_CLOSES(tagnr)
else if (OPEN_TAG(T_IMG))
;
else
ERROR1(html_fn, ln, "tag %s not processed", tags[tagnr].name)
}
}
/* read > and skip till first non-space */
if (ch != '\0' && ch == '>')
{
if ((ch = *s++) == '\n') ln++;
}
}
else
{
int ch_val = (ch + 256)%256;
bool skip = FALSE;
if (!isspace(ch) && !in_header && !in_head)
{
if (cur_names != 0)
{ /* Introduce fake section for text before first section */
add_section(in_file, ln, 10);
cur_section->title = "";
cur_section->names = cur_names;
cur_names = 0;
}
cur_section->has_text = TRUE;
}
if (in_header && ch != '\n' && i_st < 999)
section_title[i_st++] = ch;
/* Now analyze character */
if (ch == '\n')
skip = TRUE;
else if (ch_val >= 160 && ch_val <= 255 &&
ch_table[ch-160] != 0)
{
ERROR2(html_fn, ln, "Replace character %d by '&%s;'.",
ch_val, ch_table[ch_val-160])
skip = TRUE;
}
else if (ch == '&')
{ int i = 0;
bool correct = FALSE;
char html_ch[10];
int v;
if (in_header && i_st < 999) section_title[i_st++] = ch;
if ((ch = *s++) == '\n') ln++;
if (isalpha(ch))
{
while (isalpha(ch)||isdigit(ch))
{
if (i < 9)
html_ch[i++] = ch;
if (in_header && i_st < 999) section_title[i_st++] = ch;
if ((ch = *s++) == '\n') ln++;
}
html_ch[i] = '\0';
for (v = 0; v < NR_CH_TABLE; v++)
if ( ch_table[v] != 0
&& !strcmp(html_ch, ch_table[v]))
{ correct = TRUE;
break;
}
if (ch == ';')
{
if (i < 9)
html_ch[i++] = ch;
html_ch[i] = '\0';
if (in_header && i_st < 999) section_title[i_st++] = ch;
if ((ch = *s++) == '\n') ln++;
}
else
ERROR1(html_fn, ln,
"Place ';' after sequence '&%s'.", html_ch)
if (!correct)
ERROR1(html_fn, ln,
"Unknown sequence '&%s'.", html_ch)
}
else if (ch == '#')
{ int code = 0;
if (in_header && i_st < 999) section_title[i_st++] = ch;
if ((ch = *s++) == '\n') ln++;
html_ch[i++] = '#';
while (isdigit(ch))
{
if (i < 9)
html_ch[i++] = ch;
code = code * 10 + ch - '0';
if (in_header && i_st < 999) section_title[i_st++] = ch;
if ((ch = *s++) == '\n') ln++;
}
html_ch[i] = '\0';
if (ch == ';')
{
if (i < 9)
html_ch[i++] = ch;
html_ch[i] = '\0';
if (in_header && i_st < 999) section_title[i_st++] = ch;
if ((ch = *s++) == '\n') ln++;
}
else
ERROR1(html_fn, ln, "Place ';' after sequence '&%s'", html_ch)
if ((code >= ' ' && code < 127))
ERROR2(html_fn, ln,
"Replace sequence '&%s' by '%c'", html_ch, code)
else if (code == 132)
; // Okay
else if (code >= 160 && code <= 255
&& ch_table[code-160] != 0)
ERROR2(html_fn, ln,
"Replace sequence '&%s' by '&%s;'",
html_ch, ch_table[code-160])
else
ERROR1(html_fn, ln, "Unknown sequence '&%s'", html_ch)
}
else
ERROR(html_fn, ln - (ch == '\n'), "Replace '&' by '&'")
}
else if (ch == '>')
{ ERROR(html_fn, ln, "Replace '>' by '>'")
skip = TRUE;
}
else if ((ch >= ' ' && ch_val < 127) || ch == '\t')
skip = TRUE;
else
{ ERROR1(html_fn, ln, "Unknown character %d (decimal)", ch_val)
skip = TRUE;
}
if (skip)
if ((ch = *s++) == '\n') ln++;
}
}
/* In case no header occured, dump label */
while (stack_depth > 0)
{ if (!option_pedantic || stack[stack_depth-1].tagnr != T_HTML)
ERROR1(html_fn, ln, "add %s>", tags[stack[stack_depth-1].tagnr].name)
latex_close(ln, html_fn);
}
}
#define NO_EXPLAIN_REASON
int debug_refby = 0;
void check_exists_file(char *html_fn)
{
file_p in_file = find_file(html_fn);
//if (in_file->exists)
// in_file->exists = file_exists(html_fn);
if (!in_file->exists)
ERROR(html_fn, 0, "does not exist\n")
in_file->read |= R_READ;
in_file->read |= R_INCLUDED;
}
void scan_a_js_file(char *js_fn)
{
file_p in_file = find_file(js_fn);
char *s = 0, ch;
int ln = 1;
/*printf("Include JS file %s\n", js_fn);*/
s = get_contents(in_file);
if (s == 0)
return;
in_file->read |= R_READ;
in_file->read |= R_INCLUDED;
if ((ch = *s++) == '\n') ln++;
while(ch != '\0')
{
if (ch == '/' && *s == '/')
{
do
{ if ((ch = *s++) == '\n') ln++;
}
while (ch != '\0' && ch != '\n');
}
else if (ch == '"' || ch == '\'')
{ char fn[101];
int i = 0;
char quote = ch;
if ((ch = *s++) == '\n') ln++;
while (ch != quote && ch != '\0' && ch != '\n')
{ if (ch == '\\')
{ if ((ch = *s++) == '\n') ln++;
if (ch != '\0' && ch != '\n')
{ if (i < 100)
fn[i++] = ch;
if ((ch = *s++) == '\n') ln++;
}
}
else
{ if (i < 100)
fn[i++] = ch;
if ((ch = *s++) == '\n') ln++;
}
}
if (ch == quote)
if ((ch = *s++) == '\n') ln++;
fn[i] = '\0';
/*printf("Found string |%s|\n", fn);*/
if ( !strcmp(fn + strlen(fn) - 4, ".jpg")
|| !strcmp(fn + strlen(fn) - 4, ".gif")
|| !strcmp(fn + strlen(fn) - 4, ".png"))
{ file_p img_file = find_file(fn);
if (img_file->read & R_INDIR)
img_file->read |= R_INCLUDED;
else if (!img_file->exists)
ERROR1(js_fn, ln, "file '%s' does not exist", fn)
}
}
else
{ if ((ch = *s++) == '\n') ln++;
}
}
}
void accept_root_URL(char *URL)
{ int strlen_URL = strlen(URL);
document_URL = NALLOC(char, strlen_URL + 2);
strcpy(document_URL, URL);
if (document_URL[strlen_URL - 1] != '/')
{ document_URL[strlen_URL] = '/';
document_URL[strlen_URL + 1] = '\0';
}
server_URL = 0;
{ int i;
for (i = 0; URL[i] != '\0' && URL[i] != ':'; i++);
if (URL[i] != '\0' && URL[i+1] == '/' && URL[i+2] == '/')
{ i += 3;
while (URL[i] != '\0' && URL[i] != '/')
i++;
if (URL[i] == '/')
file_URL = document_URL + i;
else
file_URL = "/";
URL[i] = '\0';
server_URL = SALLOC(URL);
strcpy(server_URL, URL);
}
}
if (server_URL == 0)
{ printf("illegal URL '%s'\n", document_URL);
document_URL = 0;
}
}
void scan_not_included_files(bool included)
{
bool found = TRUE;
while (found)
{ file_p file = the_files;
found = FALSE;
while (file != 0 && !found)
{ DEBUG_P4("%s %d %d %d ",
file->name, file->exists, !(file->read & R_READ),
!is_URL(file->name));
DEBUG_P3("%d %d %d\n",
is_html(file->name),
file->name[0] != '.', file->name[1] != '.');
if ( file->exists && !(file->read & R_READ)
&& (file->read & R_DOREAD)
&& !is_URL(file->name)
&& (file->name[0] != '.' || file->name[1] != '.'))
found = TRUE;
else
file = file->next;
}
if (found)
{
if (is_html(file->name) && !streq(file->name, "brexrefs.html"))
scan_a_file(file->name, 0, 1, included);
else if ((file->read & R_INCLUDED) && is_js(file->name))
scan_a_js_file(file->name);
else if (!is_URL(file->name))
check_exists_file(file->name);
}
}
}
void dump_site_map(file_p file, int depth)
{ int i;
file_p child;
for (i = 0; i < depth; i++)
printf("\t");
printf("%s", file->name);
if (file->parent) printf(" p:%s", file->parent->name);
if (file->sibling) printf(" s:%s", file->sibling->name);
if (file->next_sibling) printf(" ns:%s", file->next_sibling->name);
if (file->prev_sibling) printf(" ps:%s", file->prev_sibling->name);
printf("\n");
for (child = file->children; child != 0; child = child->sibling)
dump_site_map(child, depth+1);
}
file_p root_files[10];
int nr_root_files = 0;
void read_site_map(void)
{
FILE *f = fopen("sitemap.txt", "rt");
file_p nested[20];
int cur_depth = 0;
char fn[400];
bool empty_line = FALSE;
int i;
for (i = 0; i < 20; i++) nested[i] = 0;
if (f==0)
return;
while (fgets(fn, 399, f))
{
char *s = fn;
int depth = 0;
bool special_child = FALSE;
if (fn[strlen(fn)-1] == '\n')
fn[strlen(fn)-1] = '\0';
while (*s == '\t')
{ depth++;
s++;
}
if (s[0] == '*' && s[1] == ' ')
{ s += 2;
special_child = TRUE;
}
if (*s == '\0')
empty_line = TRUE;
else
{ file_p file = 0;
file_p prev_sibling = 0;
while (depth < cur_depth)
nested[cur_depth--] = 0;
prev_sibling = nested[cur_depth];
if (empty_line)
{ nested[cur_depth] = 0;
empty_line = FALSE;
}
cur_depth = depth;
file = find_file(s);
file->special_child = special_child;
if (file->read & R_SITEMAP)
printf("site_map.txt : '%s' repeated\n", s);
file->read |= R_SITEMAP;
if (cur_depth == 0)
root_files[nr_root_files++] = file;
else
{ file_p parent = nested[cur_depth-1];
if (parent)
{
file->parent = parent;
if (parent->children == 0)
parent->children = file;
else if (prev_sibling != 0)
prev_sibling->sibling = file;
}
if (nested[cur_depth] != 0)
{ nested[cur_depth]->next_sibling = file;
file->prev_sibling = nested[cur_depth];
}
}
nested[cur_depth] = file;
}
}
/*
printf("***\n");
{
int i;
for (i = 0; i < nr_root_files; i++)
dump_site_map(root_files[i], 0);
}
printf("***\n");
*/
fclose(f);
}
void read_dir(void)
{
FILE *f;
char fn[400];
/*fprintf(stderr, "Scan directory\n");
system("dir \\www >\\www\\compare\\dir.txt");
fprintf(stderr, "Ready\n");*/
bool daylightsaving = FALSE;
{
time_t rawtime = time(0);
struct tm * timeinfo = localtime( &rawtime );
daylightsaving = timeinfo != 0 && timeinfo->tm_isdst;
}
f = fopen("compare\\dir.txt", "rt");
if (f==0)
return;
while (fgets(fn, 399, f))
{
file_p file;
int len = strlen(fn);
while (len > 0 && fn[len-1] < ' ')
fn[--len] = '\0';
if (len > 15 && fn[14] == ':' && fn[36] != '.')
{
char size[30];
file = find_file(fn+36);
file->read |= R_INDIR;
file->exists = TRUE;
strncpy(size, fn+28, 3);
strncpy(size+3, fn+32, 3);
size[6] = '\0';
sscanf(size, "%ld", &file->size_local);
{
long int year, mon, day, hour, min;
year = (fn[6] - '0')*1000 + (fn[7] - '0')*100 + (fn[8] - '0')*10 + (fn[9] - '0');
mon = (fn[3] - '0')*10 + (fn[4] - '0');
day = (fn[0] - '0')*10 + (fn[1] - '0');
hour = (fn[12] - '0')*10 + (fn[13] - '0');
min = (fn[15] - '0')*10 + (fn[16] - '0');
file->date_days = year * 10000 + mon * 100 + day;
file->date_mins = hour * 60 + min;
if (daylightsaving)
{
// Windows has incremented all the date/times with one hour for files created before day light saving period
if (file->date_days < 20100328)
{
file->date_mins -= 60;
if (file->date_mins < 0)
{
file->date_mins += 24*60;
file->date_days--;
}
}
}
}
}
#ifdef WIN_95_DIR_FORMAT
if (fn[16] == ' ' && strlen(fn) >= 45)
{
char size[30];
file = find_file(fn+44);
file->read |= R_INDIR;
strncpy(size, fn+16, 6);
strncpy(size+6, fn+23, 3);
size[9] = '\0';
sscanf(size, "%ld", &file->size_local);
{
long int year, mon, day, hour, min;
char *d = fn+28;
char *t = strstr(d, ":") - 2;
year = (d[6] - '0')*10 + d[7] - '0';
year += (year < 50) ? 2000 : 1900;
if (t[5] == 'p' || t[5] == 'm')
{ mon = (d[0] - '0')*10 + d[1] - '0';
day = (d[3] - '0')*10 + d[4] - '0';
}
else
{ day = (d[0] - '0')*10 + d[1] - '0';
mon = (d[3] - '0')*10 + d[4] - '0';
}
hour = t[1] - '0';
if (t[0] != ' ') hour += (t[0] - '0')*10;
min = (t[3] - '0')*10 + t[4] - '0';
if (hour == 12 && t[5] == 'a') hour -= 12;
if (t[5] == 'p') hour += 12;
file->date_days = year * 10000 + mon * 100 + day;
file->date_mins = hour * 60 + min;
}
}
#endif
}
fclose(f);
}
int month_of(char *s)
{
static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
int i;
for (i = 0; i < 12; i++)
if (strncmp(s, months[i], 3) == 0)
return i+1;
return 0;
}
void add_size(long size, char *fn)
{
int l = strlen(fn);
if ( (l > 6 && !strcmp(fn + l - 6, "_c.txt"))
|| (l > 8 && !strcmp(fn + l - 8, "_cpp.txt")))
{
add_other_ext("C",size);
}
else if (l > 8 && !strcmp(fn + l - 8, "_pas.txt"))
{
add_other_ext("Pascal",size);
}
else
{
char *ext = fn + l;
while (ext > fn && *(ext-1) != '.') ext--;
add_other_ext(ext, size);
}
}
void copy_file(FILE *fout, file_p file)
{
if (file->contents != 0 && is_html(file->name))
{ char ofn[200];
FILE *of;
sprintf(ofn, "ftp\\%s", file->name);
of = fopen(ofn, "wt");
if (of)
{ char *head = strstr(file->contents, "");
char *r = file->contents;
if (head)
{ char *s;
for (s = file->contents; s < head; s++)
fprintf(of, "%c", *s);
fprintf(of, "\n",
file->name);
r = head + 17;
}
else if ( (head = strstr(file->contents, "")) != 0
|| (head = strstr(file->contents, "")) != 0)
{ char *s;
for (s = file->contents; s < head; s++)
fprintf(of, "%c", *s);
fprintf(of, "\n",
file->name);
r = head + 6;
}
else
{ printf("Error: Did not find in %s\n", file->name);
}
while (*r != '\0')
{
char *s = r, *e;
for (e = s; *e != '\n' && *e != '\0'; e++)
;
r = (*e == '\n') ? e+1 : e;
for (; s < e && *(e-1) == ' '; e--)
;
for (; s < e; s++)
fputc(*s, of);
fputc('\n', of);
}
fclose(of);
}
}
else
fprintf(fout, "copy \"%s\" \"ftp\\%s\"\n", file->name, file->name);
}
void compare(bool execute)
{
FILE *fls = fopen("compare\\ls.txt", "rt");
FILE *fout = fopen("cp2ftp.bat", "wt");
char buffer[500];
time_t timeinsec;
struct tm timem;
file_p a_file;
long oldsize = 0L;
long sizecopied = 0L;
long newsize = 0L;
long removesize = 0L;
int i;
time(&timeinsec);
memcpy(&timem, localtime(&timeinsec), sizeof(struct tm));
while (fgets(buffer,499, fls))
{
if (buffer[0] == '-')
{
file_p file;
long size_ftp;
bool notincluded;
char *s;
if (buffer[strlen(buffer)-1] == '\n')
buffer[strlen(buffer)-1] = '\0';
s = buffer;
if (!isdigit(buffer[24]))
s += 10;
sscanf(s+23, "%ld", &size_ftp);
file = find_file(s+46);
file->on_ftp = TRUE;
notincluded = !(file->read & R_INCLUDED) && (file->read & R_INDIR)
&& file->exists;
if (file->size_local == -1 || notincluded)
{
printf("Could remove %s (%ld byte)\n", file->name, size_ftp);
file->removed = TRUE;
removesize += size_ftp;
/*add_size(-size_ftp, file->name);*/
}
else if ( !notincluded )
{
long int fyear, fmon, fday, fhour = 23, fmin = 59, fd=0, fm=0;
long int ld = file->date_days,
lm = file->date_mins;
char *d;
int newer = 0;
/*int diffsize = 0;
int picture = 0;*/
d = s + 33;
fmon = month_of(d);
fday = d[5] - '0';
if (d[4] != ' ') fday += (d[4] - '0')*10;
if ( d[9] == ':' )
{
fhour = d[8] - '0';
if (d[7] != ' ') fhour += (d[7] - '0')*10;
fmin = (d[10] - '0')*10 + d[11] - '0';
fyear = timem.tm_year;
if (fmon * 100 + fday > (timem.tm_mon+1) * 100 + timem.tm_mday)
fyear = fyear - 1;
fyear += 1900;
if (fyear < 1980)
fyear += 100;
}
else
{
sscanf(d+7, "%ld", &fyear);
}
fd = fyear * 10000 + fmon * 100 + fday;
fm = fhour * 60 + fmin;
/*printf("%s\n %ld %ld %ld %ld %ld %ld\n",
buffer, size_ftp, fyear, fmon, fday, fhour, fmin);
printf("%-15.15s %8ld %8ld %ld %ld\n",
file->name, ld, fd, lm, fm);*/
/*printf("%-30.30s", file->name);*/
oldsize += size_ftp > 0 ? size_ftp : 0;
file->ftp_size = size_ftp;
file->newer = ld > fd || (ld == fd && lm > (fm + 60));
/*diffsize = size_ftp != file->size_local;
/*printf(" %s %s", newer ? "newer" : " ",
diffsize ? "diffsize" : " ");*/
/*picture = strcmp(file->name + strlen(file->name)-4, ".jpg") == 0;*/
/* if (!strcmp(file->name, "index.html"))
newer = TRUE;
/ *
if (!picture && newer)
{
/ *
printf("copy %s", file->name);
if (diffsize) printf(" diffsize");
if (!picture && newer) printf(" newer");
printf("\n");
* /
if (execute)
copy_file(fout, file);
sizecopied += file->size_local;
newsize += file->size_local;
add_size(file->size_local, file->name);
}
else
{
newsize += size_ftp > 0 ? size_ftp : 0;
add_size(size_ftp > 0 ? size_ftp : 0, file->name);
}
*/
/*printf("\n");*/
}
}
}
fclose(fls);
fls = fopen("ftp\\WS_FTP.LOG", "r");
while (fgets(buffer,499, fls))
{
file_p file;
char *s, *sfn;
bool notincluded;
sfn = strstr(buffer, "\\ftp\\");
if (sfn != 0)
{
sfn += 5;
s = sfn;
while (*s != '\0' && !(s[0] == ' ' && s[1] == '-' && s[2] == '-' && s[3] == '>'))
s++;
*s = '\0';
file = find_file(sfn);
file->on_ftp = TRUE;
notincluded = !(file->read & R_INCLUDED) && (file->read & R_INDIR)
&& file->exists;
if (file->size_local == -1 || notincluded)
{
if (!file->removed)
{
printf("Could remove %s\n", file->name);
file->removed = TRUE;
}
}
else if ( !notincluded )
{
long int fyear, fmon, fday, fhour = 23, fmin = 59, fd=0, fm=0;
long int ld = file->date_days,
lm = file->date_mins;
fyear = 2000 + (buffer[1] - '0')*10 + buffer[2] - '0';
fmon = (buffer[4] - '0')*10 + buffer[5] - '0';
fday = (buffer[7] - '0')*10 + buffer[8] - '0';
fhour = (buffer[10] - '0')*10 + buffer[11] - '0';
fmin = (buffer[13] - '0')*10 + buffer[14] - '0';
fd = fyear * 10000 + fmon * 100 + fday;
fm = fhour * 60 + fmin;
//printf("%d %d:%d %s %d.%d %d.%d\n", fd, fhour, fmin, file->name, ld,lm, fd,fm);
file->ftp_size = -1;
file->newer = ld > fd || (ld == fd && lm > fm);
}
}
}
fclose(fls);
for (a_file = the_files; a_file != 0 ; a_file = a_file->next)
{
if (a_file->read & R_INCLUDED && a_file->size_local >= 0)
{
add_size(a_file->size_local, a_file->name);
newsize += a_file->size_local;
if (!a_file->on_ftp || a_file->newer || strcmp(a_file->name, "index.html") == 0)
{
if (execute)
{
printf("Copy %s (%s)\n", a_file->name, !a_file->on_ftp ? "new file" : "updated");
copy_file(fout, a_file);
}
sizecopied += a_file->size_local;
}
/*printf("New? %s %ld %d %d %d\n",
a_file->name, a_file->size_local,
a_file->on_ftp, a_file->read, a_file->exists);
if ( a_file->size_local >= 0 && ())
{
bool notincluded = !(a_file->read & R_INCLUDED) && (a_file->read & R_INDIR)
&& a_file->exists;
if (!notincluded)
{
/* printf("copy %s new\n", a_file->name); * /
} */
}
}
printf("\n\nOld size %ld bytes, New size is %ld bytes\n",
oldsize, newsize);
printf("Have to copy %ld bytes\n", sizecopied);
printf("Could remove %ld bytes\n", removesize);
printf("Netto new size: %ld bytes\n", newsize - removesize);
printf("\n");
#define GENERATE_STATISTICS 1
#if GENERATE_STATISTICS
{
FILE *f = fopen("index.html", "wt");
file_p fhome_file = find_file("index.html");
char *cont = fhome_file->contents;
char linebuf[1000];
char *start_stat = "";
char *end_stat = "";
if (f != 0 && cont != 0 && *cont != '\0')
{
int found_start_stat = 0;
linebuf[0] = '\0';
for(;*cont != '\0';)
{
int i;
for (i = 0; *cont != '\0' && *cont != '\n'; i++, cont++)
linebuf[i] = *cont;
linebuf[i] = '\0';
cont++;
if (!strcmp(linebuf, start_stat))
{
found_start_stat = 1;
break;
}
fprintf(f, "%s\n", linebuf);
}
if (found_start_stat)
{
fprintf(f, "%s\n", linebuf);
fprintf(f, "consists of %d HTML-files", nr_ext_files("html"));
fprintf(f, " with a total size of %s characters,\n", with_commas(size_ext_files("html")));
fprintf(f, "having %ld internal links and %ld external links.\n",
nr_int_links, nr_ext_links + nr_broken_ext_links);
if (nr_broken_ext_links != 0)
fprintf(f, "(About %ld of the external links are broken.)\n",
nr_broken_ext_links);
fprintf(f, "Furthermore, it contains %d C/C++ program files ", nr_ext_files("C"));
fprintf(f, "with a total size of %s characters,\n", with_commas(size_ext_files("C")));
fprintf(f, "and %d PASCAL program files ", nr_ext_files("Pascal"));
fprintf(f, "with a total size of %s characters.\n", with_commas(size_ext_files("Pascal")));
fprintf(f, "There are %d text files with a total size of %s characters.\n",
nr_ext_files("txt"), with_commas(size_ext_files("txt")));
fprintf(f, "With respect to images, this site containts %d JPEG images\n"
"(total size %s bytes), \n",
nr_ext_files("jpg"), with_commas(size_ext_files("jpg")));
fprintf(f, "%d GIF images (total size %s bytes), \n",
nr_ext_files("gif"), with_commas(size_ext_files("gif")));
fprintf(f, "%d PNG images (total size %s bytes), and\n",
nr_ext_files("png"), with_commas(size_ext_files("png")));
fprintf(f, "%d BMP images (total size %s bytes).\n",
nr_ext_files("bmp"), with_commas(size_ext_files("bmp")));
fprintf(f, "With respect to sounds, it contains %d WAV files\n"
"with a total size of %s bytes and\n",
nr_ext_files("wav"), with_commas(size_ext_files("wav")));
fprintf(f, "%d MP3 files with a total size of %s bytes.\n",
nr_ext_files("mp3"), with_commas(size_ext_files("mp3")));
fprintf(f, "It also contains %d PostScript files (total size %s bytes),\n",
nr_ext_files("ps") + nr_ext_files("eps"),
with_commas(size_ext_files("ps") + size_ext_files("eps")));
fprintf(f, "%d LaTeX files (total size %s characters),\n",
nr_ext_files("tex"), with_commas(size_ext_files("tex")));
fprintf(f, "%d PDF files (total size %s characters),\n",
nr_ext_files("pdf"), with_commas(size_ext_files("pdf")));
fprintf(f, "%d zip files (total size %s bytes),\n",
nr_ext_files("zip"), with_commas(size_ext_files("zip")));
fprintf(f, "%d gzipped tar files (total size %s bytes),\n",
nr_ext_files("tgz"), with_commas(size_ext_files("tgz")));
fprintf(f, "%d SGF files with\n"
"a total size of %s bytes,\n",
nr_ext_files("sgf"), with_commas(size_ext_files("sgf")));
fprintf(f, "%d KML files with\n"
"a total size of %s bytes,\n",
nr_ext_files("kml") + nr_ext_files("kmz"),
with_commas(size_ext_files("kml") + size_ext_files("kmz")));
fprintf(f, "and %d EXE files with a total size of %s bytes.\n",
nr_ext_files("exe"), with_commas(size_ext_files("exe")));
fprintf(f, "It also uses %d JavaScript files with\n"
"a total size of %s bytes,\n",
nr_ext_files("js"), with_commas(size_ext_files("js")));
for(;*cont != '\0';)
{
int i;
for (i = 0; *cont != '\0' && *cont != '\n'; i++, cont++)
linebuf[i] = *cont;
linebuf[i] = '\0';
if (!strcmp(linebuf, end_stat))
break;
if (*cont == '\n')
cont++;
}
fprintf(f, "%s", linebuf);
for (; *cont != '\0'; cont++)
fprintf(f, "%c", *cont);
}
fclose(f);
}
}
#endif
for (i = 0; i < nr_other_ext; i++)
if (other_ext_nr[i] > 1)
printf("%ld bytes in %d \"%s\"-files.\n",
other_ext_size[i], other_ext_nr[i], other_ext_name[i]);
else
printf("%ld bytes in one \"%s\"-file.\n",
other_ext_size[i], other_ext_name[i]);
printf("\n\n");
fclose(fout);
}
void unused()
{
FILE *funused = fopen("unused.bat", "wt");
file_p file;
for (file = the_files; file != 0; file = file->next)
{
if ( (file->read & R_INCLUDED) == 0
&& (file->read & R_INDIR) != 0)
fprintf(funused, "move \"%s\" \"unused\\%s\"\n", file->name, file->name);
}
}
bool is_oneway(section_p sect)
{
for (; sect; sect = sect->parent)
if (sect->oneway)
return TRUE;
return FALSE;
}
#define NO_SHOWREF
void print_file_section(file_p file, section_p section)
{
if (section->file)
printf("%s", section->file->name);
if (section->names)
printf(" (%ld) ", section->names->line);
printf(" : ");
/*
static section_p cur_section = 0;
if (section != cur_section)
{
if (cur_section != 0 && cur_section->file != file)
printf("\n");
printf("In file %s", file->name);
if (section->names)
printf(", at line %ld", section->names->line);
if (section->title[0] != '\0')
printf(", in section '%s'", section->title);
printf(":\n");
cur_section = section;
}
*/
}
void print_section(section_p section)
{
if (section == 0)
printf("[NULL]");
else
printf("[%ld %s'%s']", (long)section,
section->file && section->file->name ? section->file->name : "",
section->title);
}
char return_path[3000];
char found_path[3000];
int cur_level;
void set_level_found(int level)
{
if (debug_refby > 0)
printf("%*.*s #set\n", level*2, level*2, "");
if (level < cur_level)
{
strcpy(found_path, return_path);
cur_level = level;
}
}
void check_section_or_parent(section_p from, section_p to, int level, bool include_parent_files, char *s, int d)
{
if (debug_refby > 0)
{
printf("%*.*ss_o_p(%d,%d) ", d*2, d*2, "", level, cur_level);
print_section(from);
printf("\n");
}
if (from == to)
{ strcpy(s, " = section");
set_level_found(level);
return;
}
if (from->file == to->file)
{
for (to = to->parent; to; to = to->parent)
{ strcpy(s, " p");
s += 2;
if (++level >= cur_level)
return;
if (debug_refby > 0)
{
printf("%*.*s = parent ", d*2, d*2, "");
print_section(to);
printf("\n");
}
if (from == to)
{ strcpy(s, " = section");
set_level_found(level);
return;
}
}
}
else
{
/* if "from" section is top section of the file, check if the
"to" section is a child according to the site map. */
if (include_parent_files && from->level == 0)
{ file_p to_parent = to->file;
while (to_parent->special_child)
{
to_parent = to_parent->parent;
if (to_parent == 0)
break;
strcpy(s, " C");
s += 2;
if (++level >= cur_level)
return;
if (debug_refby > 0)
{
printf("%*.*s = parent file ", d*2, d*2, "");
print_section(to_parent->sections);
printf("\n");
}
if (from->file == to_parent)
{ strcpy(s, " = file");
set_level_found(level);
return;
}
}
}
}
}
void search_href_in_subsections(section_p from, section_p to, int level, char *s, int d)
{
if (debug_refby > 0)
{ printf("%*.*sh_i_s(%d,%d) ", d*2, d*2, "", level, cur_level);
print_section(from);
printf("\n");
}
if (level >= cur_level)
return;
{ href_p href;
for (href = from->hrefs; href; href = href->next)
if (href->section != 0 && href->type == ' ')
{ sprintf(s, " %s#%s", href->section->file->name, href->name ? href->name : "");
check_section_or_parent(href->section, to, level, TRUE, s + strlen(s), d+1);
}
}
/* check all sub section for the same: */
{ section_p nested;
sprintf(s, " c");
s += 2;
for (nested = from->nested; nested; nested = nested->next)
search_href_in_subsections(nested, to, level+1, s, d+1);
}
}
void search_href_in_children(file_p file, section_p to, int level, char *s, int d)
{
file_p child;
if (debug_refby > 0)
printf("%*.*sh_i_c(%d,%d) %s\n", d*2, d*2, "", level, cur_level, file->name);
strcpy(s, " C");
s += 2;
for (child = file->children; child != 0; child = child->sibling)
if (child->special_child)
search_href_in_subsections(child->sections, to, level+3, s, d+1);
}
#if 0
void search_parents(section_p from, section_p to, int level, int d)
{
if (debug_refby > 0)
{ printf("%*.*sp(%d,%d) ", d*2, d*2, "", level, cur_level);
print_section(from);
printf("\n");
}
for (; from; from = from->parent)
{ if (++level >= cur_level)
return;
{ href_p href;
for (href = from->hrefs; href; href = href->next)
{
if (level >= cur_level)
return;
if (href->section != 0 && href->type == ' ')
check_section_or_parent(href->section, to, level, FALSE);
}
}
}
}
#endif
void search_chain(section_p from, section_p to, int level, char *s, int d)
{
if (debug_refby > 0)
{ printf("%*.*sc(%d,%d) ", d*2, d*2, "", level, cur_level);
print_section(from);
printf("\n");
}
if (level >= cur_level)
return;
if (from->level != 0)
{ href_p href;
for (href = from->hrefs; href; href = href->next)
if (href->section != 0 && href->type == ' ')
{
char *r;
sprintf(s, " %s#%s", href->section->file->name, href->name ? href->name : "");
r = s + strlen(s);
check_section_or_parent(href->section, to, level, FALSE, r, d+1);
search_chain(href->section, to, level+2, r, d+1);
}
}
{ section_p nested;
strcpy(s, " c");
for (nested = from->nested; nested != 0; nested = nested->next)
search_chain(nested, to, level+2, s+2, d+1);
}
if (from->level == 0)
{
file_p child;
strcpy(s, " C");
s += 2;
for (child = from->file->children; child != 0; child = child->sibling)
if (child->special_child)
search_chain(child->sections, to, level+2, s, d+1);
}
}
void set_href_type(href_p href, section_p in_section, file_p in_file)
{
section_p refered_section = 0;
section_p psect;
/* Determine the section being linked to: */
if (href->file != 0)
{ if (href->name != 0)
refered_section = section_with_name(href->file->sections,
href->name);
else
refered_section = href->file->sections;
}
if (refered_section == 0)
return; /* -- nothing to analyze */
/* Make a direct reference in the link to the section: */
href->section = refered_section;
/* Determine the type of the reference: */
if (refered_section == in_section)
{ href->type = '=';
return;
}
if (href->title == title_up)
{ href->type = 'U';
return;
}
if (href->title == title_next)
{ href->type = 'R';
return;
}
if (href->title == title_prev)
{ href->type = 'L';
return;
}
for (psect = refered_section->parent; psect != 0; psect = psect->parent)
if (psect == in_section)
{ href->type = 'c';
return;
}
for (psect = in_section->parent; psect != 0; psect = psect->parent)
if (psect == refered_section)
{ href->type = 'p';
return;
}
if (in_file != refered_section->file)
{ file_p p_file;
for (p_file = refered_section->file->parent; p_file != 0; p_file = p_file->parent)
if (p_file == in_file)
{ href->type = 'C';
return;
}
for (p_file = in_file->parent; p_file != 0; p_file = p_file->parent)
if (p_file == refered_section->file)
{ href->type = 'P';
return;
}
}
/* What is this ???? */
if (href->name == 0)
{
file_p parent;
for (parent = in_file->parent; parent != 0; parent = parent->parent)
if (parent == href->file)
return;
}
}
void check_for_oneway(href_p href, section_p in_section, file_p in_file)
{
if (debug_refby > 0)
debug_refby--;
cur_level = 10;
strcpy(found_path, "NOT FOUND");
search_href_in_subsections(href->section, in_section, 1, return_path, 0);
if (href->section->level == 0)
search_href_in_children(href->section->file, in_section, 1, return_path, 0);
//search_parents(href->section, in_section, 1);
search_chain(href->section, in_section, 1, return_path, 0);
if (href->oneway)
{
if (cur_level < 6)
ERROR3(in_file->name, href->line,
"can remove --1-- from '%s%s%s'",
href->file->name,
href->name ? "#" : "",
href->name ? href->name : "")
}
else
{
if (cur_level == 10)
{ ERROR3(in_file->name, href->line,
"could add --1-- to '%s%s%s'",
href->file->name,
href->name ? "#" : "",
href->name ? href->name : "");
if (in_section->parent && !in_section->parent->has_text)
{
section_p name_sect = in_section->names ? in_section : in_section->parent;
if (name_sect->names)
ERROR4(href->file->name, href->section->line,
"could add: - %s: %s",
in_file->name, name_sect->names->name,
in_section->parent->title, in_section->title)
else
ERROR3(href->file->name, href->section->line,
"could add:
- %s: %s",
in_file->name,
in_section->parent->title, in_section->title)
}
else
{ section_p name_sect = in_section;
while ( name_sect->names == 0 && name_sect->parent != 0)
name_sect = name_sect->parent;
if (name_sect->names)
ERROR3(href->file->name, href->section->line,
"could add:
- %s",
in_file->name, name_sect->names->name,
in_section->title)
else
ERROR2(href->file->name, href->section->line,
"could add:
- %s",
in_file->name,
in_section->title)
}
}
}
}
bool link_to_next(file_p n, file_p p, file_p* cn)
{
while (p != 0 && p->next_sibling == 0)
p = p->parent;
if (p == 0 || p->next_sibling == 0)
return FALSE;
p = p->next_sibling;
*cn = p;
while (p != 0)
{ if (n == p)
return TRUE;
p = p->children;
}
return FALSE;
}
bool link_to_prev(file_p n, file_p p, file_p* cn)
{
while (p != 0 && p->prev_sibling == 0)
p = p->parent;
if (p == 0 || p->prev_sibling == 0)
return FALSE;
p = p->prev_sibling;
*cn = p;
while (p != 0)
{ if (n == p)
return TRUE;
p = p->children;
while (p != 0 && p->next_sibling != 0)
p = p->next_sibling;
}
return FALSE;
}
bool is_diary_file(file_p file)
{
char* name = file->name;
return name[0] == 'D' /*|| name[0] == 'N')*/
&& isdigit(name[1])
&& isdigit(name[2])
&& isdigit(name[3])
&& isdigit(name[4])
&& strcmp(name+5, ".html") == 0;
}
void analyze_all_sections()
{ file_p file;
section_p section;
href_p href;
name_p name;
tag_p tag;
#ifdef SHOWREF
printf("analyze_all_sections\n");
#endif
/* Set the link type */
for (file = the_files; file; file = file->next)
for (section = file->sections; section; next_section(§ion, 0))
for (href = section->hrefs; href; href = href->next)
set_href_type(href, section, file);
/* Analyze names and links */
for (file = the_files; file; file = file->next)
{
#ifdef SHOWREF
printf("File: %s\n", file->name);
#endif
for (section = file->sections; section; next_section(§ion, 0))
{
bool is_oneway_section = is_oneway(section);
#ifdef SHOWREF
printf(" %*.*ssection: %s\n", section->level, section->level, "", section->title);
#endif
/* For all names */
for (name = section->names; name; name = name->next)
{
if (name_repeated(file->sections, name->name))
ERROR1(file->name, name->line, " not unique.", name->name)
if ( strstr(name->name, "#") || strstr(name->name, ".html")
|| strstr(name->name, ".jpg"))
ERROR1(file->name, name->line, " looks like link.\n", name->name)
}
/* For all links */
for (href = section->hrefs; href; href = href->next)
{
if (href->file == 0)
; /* skip */
else if (!href->file->exists)
; // ERROR1(file->name, href->line, "file '%s' does not exist", href->file->name)
else if (href->section == 0)
ERROR2(file->name, href->line, "no in file '%s'.", href->name, href->file->name)
else if (href->type == 'U')
{
if (file->parent == 0)
ERROR(file->name, href->line, "href not pointing to parent. File does not have parent")
else if (href->file != file->parent)
ERROR1(file->name, href->line, "href not pointing to parent %s", file->parent->name)
}
else if (href->type == 'R')
{
file_p next_file = 0;
if (!link_to_next(href->file, file, &next_file))
{ if (next_file == 0)
ERROR(file->name, href->line, "href not pointing to next. File has no next.")
else
ERROR1(file->name, href->line, "href not pointing to next %s", next_file->name)
}
}
else if (href->type == 'L')
{
file_p prev_file;
if (!link_to_prev(href->file, file, &prev_file))
{ if (prev_file == 0)
ERROR(file->name, href->line, "href not pointing to previous. File has no previous.")
else
ERROR1(file->name, href->line, "href not pointing to previous %s", prev_file->name)
}
}
else if (href->type == ' ' && href->section != 0)
{
if (!is_oneway_section)
check_for_oneway(href, section, file);
if (is_diary_file(href->section->file))
{
tag_types_p tag_type;
for (tag_type = href->tag_types; tag_type != 0; tag_type = tag_type->next)
add_tag_from_index(href->section, tag_type->type);
}
#ifdef SHOWREF
printf(" %*.*s- '%s' |%c| %s %s.%s\n",
section->level, section->level, "",
href->title, href->type,
href->error == '1' ? "NOTONEWAY" :
href->error == '2' ? "ONEWAY" : "",
href->section->file->name,
href->section->names ? href->section->names->name : "");
fflush(stdout);
#endif
}
}
}
}
#ifdef DUMP
for (file = the_files; file; file = file->next)
{
printf("File: %s\n", file->name);
for (section = file->sections; section; next_section(§ion, 0))
{
bool is_oneway_section = is_oneway(section);
printf(" %*.*s%d: section: %s\n", section->level, section->level, "",
section->line, section->title);
/* For all names */
for (name = section->names; name; name = name->next)
{
printf(" %*.*s- %d: name: %s\n", section->level, section->level, "",
name->line, name->name);
}
/* For all links
for (href = section->hrefs; href; href = href->next)
{
//printf(" %*.*s- %d: href: '%s' |%c| %s#%s\n",
// section->level, section->level,
// href->line, href->title, href->type,
// href->section && href->section->file ? href->section->file->name : "???",
// href->section && href->section->names ? href->section->names->name : "");
}
*/
}
}
#endif
}
void fill_tag_label(char* buf, tag_p tag)
{
section_p section;
//fprintf(stderr, "(\n");
if (tag == 0)
{
buf[0] = '\0';
return;
}
section = tag->section;
if (section == 0)
buf[0] = '\0';
else if (section->file == 0)
strcpy(buf, "err1");
else if (section->file->name == 0)
strcpy(buf, "err2");
else if (is_diary_file(section->file))
{
char *name = section->file->name;
sprintf(buf, "%c%c%c%c%s", name[1], name[2], name[3], name[4],
section->names ? section->names->name : "");
}
else
sprintf(buf, "%s#%s", section->file->name,
section->names ? section->names->name : "");
}
void connect_tags_in_file(file_p file)
{
section_p section;
file_p child;
for (section = file->sections; section != 0; next_section(§ion, 0))
{
tag_p tag;
for (tag = section->tags; tag != 0; tag = tag->next)
{
if (tag->type->last_seen)
{
tag->prev_tag = tag->type->last_seen;
tag->prev_tag->next_tag = tag;
}
tag->type->last_seen = tag;
}
}
for (child = file->children; child != 0; child = child->sibling)
connect_tags_in_file(child);
}
void connect_tags()
{
int i;
for (i = 0; i < nr_root_files; i++)
connect_tags_in_file(root_files[i]);
}
void print_tags_script(FILE* f, section_p section)
{
tag_p tag;
fprintf(f, "\n");
}
void print_tags_in_file(FILE* f, file_p file)
{
section_p section;
file_p child;
for (section = file->sections; section != 0; next_section(§ion, 0))
{
if (section->tags != 0)
{
tag_p tag;
bool something_in_script = FALSE;
for (tag = section->tags; tag != 0; tag = tag->next)
{
if (tag->prev_text != empty_tag || tag->next_text != empty_tag)
{
something_in_script = TRUE;
break;
}
}
if (something_in_script)
{
bool is_correct = TRUE;
for (tag = section->tags; tag != 0; tag = tag->next)
{
char prev[100];
char next[100];
tag_p prev_tag;
tag_p next_tag;
for (prev_tag = tag->prev_tag; prev_tag != 0 && !prev_tag->in_index; prev_tag = prev_tag->prev_tag)
;
for (next_tag = tag->next_tag; next_tag != 0 && !next_tag->in_index; next_tag = next_tag->next_tag)
;
fill_tag_label(prev, prev_tag);
fill_tag_label(next, next_tag);
if (!tag->in_index)
{ if (is_correct)
fprintf(stdout, "\nFile: %s %s\n", file->name, section->names != 0 ? section->names->name : "");
is_correct = FALSE;
fprintf(stdout, "ERROR: %s not in index\n", tag->type->name);
}
if (tag->prev_text == empty_tag && tag->next_text == empty_tag)
{ if (is_correct)
fprintf(stdout, "\nFile: %s %s\n", file->name, section->names != 0 ? section->names->name : "");
is_correct = FALSE;
fprintf(stdout, "ERROR: %s not in script\n", tag->type->name);
}
else if (tag->in_index)
{
if (!streq(tag->prev_text, prev))
{ if (is_correct)
fprintf(stdout, "\nFile: %s %s\n", file->name, section->names != 0 ? section->names->name : "");
is_correct = FALSE;
fprintf(stdout, "ERROR: %s prev '%s' -> '%s'\n", tag->type->name, tag->prev_text, prev);
}
if (!streq(tag->next_text, next))
{ if (is_correct)
fprintf(stdout, "\nFile: %s %s\n", file->name, section->names != 0 ? section->names->name : "");
is_correct = FALSE;
fprintf(stdout, "ERROR: %s next '%s' -> '%s'\n", tag->type->name, tag->next_text, next);
}
}
}
if (!is_correct)
print_tags_script(stdout, section);
}
else
{
fprintf(stdout, "\nFile: %s %s\n", file->name, section->names != 0 ? section->names->name : "");
print_tags_script(stdout, section);
}
}
}
for (child = file->children; child != 0; child = child->sibling)
print_tags_in_file(f, child);
}
void print_tags(FILE* f)
{
int i;
for (i = 0; i < nr_root_files; i++)
print_tags_in_file(f, root_files[i]);
printf("\n\n");
}
int main(argc, argv)
int argc;
char **argv;
{ FILE *fin;
char *fn = 0,
*html_fn,
*outfn = 0,
*reffn;
bool option_scan_not_inc = FALSE,
option_cross_ref = FALSE,
option_compare = FALSE,
option_compare_copy = FALSE;
/* global options */
option_info = FALSE;
option_warn = FALSE;
option_pedantic = FALSE;
option_bibliography = FALSE;
printf("%s: Version %s\nWritten by %s\n\n",
"chkhtml", VERSION, WRITTEN_BY);
{ int i;
bool error = FALSE;
for (i = 1; i < argc; i++)
{ if (argv[i][0] == '-')
{ if (argv[i][1] == 'o')
{ if (argv[i][2] != '\0')
outfn = argv[i] + 2;
else if (i + 1 < argc)
outfn = argv[++i];
else
printf("Argument of -o option missing\n");
}
else if (argv[i][1] == 'i' && argv[i][2] == '\0')
{ option_warn = TRUE;
option_info = TRUE;
}
else if (argv[i][1] == 'w' && argv[i][2] == '\0')
option_warn = TRUE;
else if (argv[i][1] == 'p' && argv[i][2] == '\0')
option_pedantic = TRUE;
else if (argv[i][1] == 's' && argv[i][2] == '\0')
{
option_scan_not_inc = TRUE;
option_compare = TRUE;
option_compare_copy = TRUE;
}
else if (argv[i][1] == 'r')
{ if (argv[i][2] != '\0')
accept_root_URL(argv[i] + 2);
else if (i + 1 < argc)
accept_root_URL(argv[++i]);
else
printf("Argument of -r option missing\n");
}
else if (argv[i][1] == 'b' && argv[i][2] == '\0')
option_bibliography = TRUE;
#ifdef DYN_DEBUG
else if (argv[i][1] == 'd')
option_debug = TRUE;
#endif
else if (streq(argv[i], "-cr"))
option_cross_ref = TRUE;
else
{ printf("Unknown option %s\n", argv[i]);
error = TRUE;
}
}
else if (fn == 0)
fn = argv[i];
else
{ printf("Too many input filenames\n");
error = TRUE;
}
}
if (fn == 0)
{ printf("No input filename given\n");
error = TRUE;
}
else
{ fin = fopen(fn, "rt");
if (fin == 0)
{ printf("Error: Cannot open file: '%s'.\n", fn);
error = TRUE;
}
}
if (error)
{ printf("Usages: html2tex [options] \n");
printf("\nOptions:\n");
printf(" -o : specify output file\n");
printf(" -i : print info\n");
printf(" -w : print warnings (and info)\n");
printf(" -r : root URL of document\n");
printf(" -b : make bibliography\n");
printf(" -cr : generate cross-reference\n");
printf(" -c : check html file\n");
printf(" -s : scan not included files\n");
#ifdef DYN_DEBUG
printf(" -d : print (a lot of) debugging information\n");
#endif
return 1;
}
if (streq(fn + strlen(fn) - 5, ".html"))
{ is_html_fn = TRUE;
html_fn = SALLOC(fn);
strcpy(html_fn, fn);
fn[strlen(fn) - 5] = '\0';
}
}
reffn = NALLOC(char, strlen(fn) + 5);
strcpy(reffn, fn);
strcat(reffn, ".ref");
read_site_map();
read_dir();
f_ext_dest = fopen("compare\\ext_dest.txt", "wt");
f_broken_ext_dest = fopen("compare\\broken_ext_dest.txt", "wt");
nr_other_ext = 0;
nr_int_links = 0;
nr_ext_links = 0;
nr_broken_ext_links = 0;
scan_a_file(html_fn, 0, TRUE);
if (option_scan_not_inc)
scan_not_included_files(is_html_fn);
{ file_p file;
for (file = the_files; file != 0; file = file->next)
file->read &= ~R_READ;
}
fclose(f_ext_dest);
fclose(f_broken_ext_dest);
analyze_all_sections();
{ file_p file;
for (file = the_files; file != 0; file = file->next)
{
if ((file->read & R_SITEMAP) && !(file->read & R_INCLUDED))
ERROR(file->name, 0, "not included file in site map")
if (!(file->read & R_SITEMAP) && (file->read & R_INCLUDED) && is_html(file->name))
ERROR(file->name, 0, "included HTML file not in site map")
}
}
print_errors(stdout);
{
FILE *g = fopen("compare/tags.txt","wt");
connect_tags();
print_tags(g);
}
DEBUG_PRINT(("ready reading\n"));
DEBUG_PRINT(("\n\n\n"));
if (option_compare)
compare(option_compare_copy);
unused();
return 0;
}