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 = " ", 3) == 0)
empty_line = TRUE;
if (strncmp(s, "", 7) == 0)
special_child = TRUE;
*e = '\0';
s += 9;
}
else if (strncmp(s, "";
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"CRLF, linebuf);
}
if (found_start_stat)
{
fprintf(f, "%s"CRLF, linebuf);
fprintf(f, "consists of %d HTML-files", nr_ext_files("html"));
fprintf(f, " with a total size of %s characters,"CRLF, with_commas(size_ext_files("html")));
fprintf(f, "having %s internal links ", with_commas(nr_int_links));
fprintf(f, "and %s external links ", with_commas(nr_ext_links + nr_broken_ext_links));
fprintf(f, "to (more than) %s websites."CRLF, with_commas(nr_sites));
if (nr_broken_ext_links != 0)
fprintf(f, "(At least %s of the external links are broken.)"CRLF, with_commas(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,"CRLF, with_commas(size_ext_files("C")));
fprintf(f, " %d MySample scripts ", nr_ext_files("scr"));
fprintf(f, "with a total size of %s characters,"CRLF, with_commas(size_ext_files("scr")));
fprintf(f, "%d PASCAL program files ", nr_ext_files("Pascal"));
fprintf(f, "with a total size of %s characters."CRLF, with_commas(size_ext_files("Pascal")));
fprintf(f, "and %d Python program files ", nr_ext_files("Python"));
fprintf(f, "with a total size of %s characters."CRLF, with_commas(size_ext_files("Python")));
fprintf(f, "There are %d text files with a total size of %s characters."CRLF,
nr_ext_files("txt"), with_commas(size_ext_files("txt")));
fprintf(f, "With respect to images, this site containts %d JPEG images"CRLF
"(total size %s bytes),"CRLF,
nr_ext_files("jpg"), with_commas(size_ext_files("jpg")));
fprintf(f, "%d GIF images (total size %s bytes),"CRLF,
nr_ext_files("gif"), with_commas(size_ext_files("gif")));
fprintf(f, "%d PNG images (total size %s bytes), and"CRLF,
nr_ext_files("png"), with_commas(size_ext_files("png")));
fprintf(f, "%d BMP images (total size %s bytes)."CRLF,
nr_ext_files("bmp"), with_commas(size_ext_files("bmp")));
fprintf(f, "With respect to sounds, it contains %d WAV files"CRLF
"with a total size of %s bytes and"CRLF,
nr_ext_files("wav"), with_commas(size_ext_files("wav")));
fprintf(f, "%d MP3 files with a total size of %s bytes."CRLF,
nr_ext_files("mp3"), with_commas(size_ext_files("mp3")));
fprintf(f, "It also contains %d PostScript files (total size %s bytes),"CRLF,
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),"CRLF,
nr_ext_files("tex"), with_commas(size_ext_files("tex")));
fprintf(f, "%d PDF files (total size %s characters),"CRLF,
nr_ext_files("pdf"), with_commas(size_ext_files("pdf")));
fprintf(f, "%d zip files (total size %s bytes),"CRLF,
nr_ext_files("zip"), with_commas(size_ext_files("zip")));
fprintf(f, "%d gzipped tar files (total size %s bytes),"CRLF,
nr_ext_files("tgz"), with_commas(size_ext_files("tgz")));
fprintf(f, "%d SGF files with"CRLF
"a total size of %s bytes,"CRLF,
nr_ext_files("sgf"), with_commas(size_ext_files("sgf")));
fprintf(f, "%d KML files with"CRLF
"a total size of %s bytes,"CRLF,
nr_ext_files("kml") + nr_ext_files("kmz"),
with_commas(size_ext_files("kml") + size_ext_files("kmz")));
fprintf(f, "%d bundle files with"CRLF
"a total size of %s bytes,"CRLF,
nr_ext_files("bundle"),
with_commas(size_ext_files("bundle")));
fprintf(f, "and %d EXE files with a total size of %s bytes."CRLF,
nr_ext_files("exe"), with_commas(size_ext_files("exe")));
fprintf(f, "It also uses %d JavaScript files with"CRLF
"a total size of %s bytes,"CRLF,
nr_ext_files("js"), with_commas(size_ext_files("js")));
fprintf(f, "This leads to a total size of %s bytes."CRLF, with_commas(newsize));
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++)
if (*cont == '\n')
fprintf(f, CRLF);
else
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);
fls = fopen("sd.log", "rt");
if (fls != 0)
{
while (fgets(buffer,499, fls))
{
if (strncmp(buffer, "add ", 4) != 0 && strncmp(buffer, "remove ", 7) != 0 && strlen(buffer) > 15)
{
file_p file;
char *s = buffer;
bool notincluded;
int long fd, fm;
for (fd = 0; '0' <= *s && *s <= '9'; s++)
fd = 10*fd + *s - 10;
if (*s == ' ')
s++;
for (fm = 0; '0' <= *s && *s <= '9'; s++)
fm = 10*fm + *s - 10;
if (*s == ' ')
s++;
file = find_file(s);
file->fd_sd = fd;
file->fm_sd = fm;
/*
notincluded = !(file->read & R_INCLUDED) && (file->read & R_INDIR)
&& file->exists;
if (file->size_local == -1 || notincluded)
file->remove_from_sd = TRUE;
else if ( !notincluded )
{
long int ld = file->date_days,
lm = file->date_mins;
file->upload_to_sd = ld > fd || (ld == fd && lm > fm);
}
*/
}
}
fclose(fls);
}
fls = fopen("sd.log", "wt");
if (fls == 0)
printf("Error: Cannot open sd.log for writing\n");
else
{
for (a_file = the_files; a_file != 0 ; a_file = a_file->next)
{
if (a_file->read & R_INCLUDED && a_file->size_local >= 0)
{
if ( ( a_file->date_days > a_file->fd_sd
|| (a_file->date_days == a_file->fd_sd && a_file->date_mins > a_file->fm_sd))
|| strcmp(a_file->name, "index.html") == 0)
fprintf(fls, "add %s\n", a_file->name);
else
fprintf(fls, "%ld %ld %s\n", a_file->fd_sd, a_file->fm_sd, a_file->name);
}
else if (a_file->fd_sd != 0)
fprintf(fls, "remove %s\n", a_file->name);
}
fclose(fls);
}
}
void unused()
{
FILE *funused = fopen("unused.bat", "wt");
if (funused == 0)
{
printf("Error: Cannot open unused.bat\n");
return;
}
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);
}
fclose(funused);
}
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;
}
}
int count_nr_tag_types(section_p section, tag_type_p *ref_tag_type)
{
int result = section->nr_tag_types;
if (result == 1)
*ref_tag_type = section->tag_type;
section_p nested;
for (nested = section->nested; nested != 0; nested = nested->next)
if (nested->names == 0)
result += count_nr_tag_types(nested, ref_tag_type);
return result;
}
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: Referenced external sites
\n\n\n");
for (site = all_sites; site != 0; site = site->next)
{
fprintf(fsites, "
\n\n
\n\nHome and email address\n\n\n");
fclose(fsites);
}
}
if (0)
{
FILE *fsites = fopen("ExtSites", "wt");
if (fsites != 0)
{ site_p site;
for (site = all_sites; site != 0; site = site->next)
{
if (strncmp(site->name, "http", 4) == 0)
fprintf(fsites, "%s\n", site->name);
}
fclose(fsites);
}
}
return 0;
}