40 pos1 =
find_pos(
"<b>Drivers sections:</b>", html, 0);
46 (
"<!-- GEM Extensions StartHTML. Do not delete or change this comment! -->",
51 (
"Unknown format of index.html. Unable to register HTML man pages.\n");
56 if (
find_pos(
"<h3>Installed extensions:</h3>", html, pos1) == -1) {
58 insert_str(
"<h3>Installed extensions:</h3>\n", pos2, html);
64 start =
find_pos(
"<h3>Installed extensions:</h3>", html, pos1);
65 end =
find_pos(
"</ul>", html, start);
66 insert_here = start + 2;
69 pos3 =
find_pos(item, html, insert_here);
75 "<li><a href=\"../extensions/%s/index.html\">%s (%i.%i.%i)</a>\n",
76 ext, ext, major, minor, revision);
77 strcpy(html[pos3], item);
84 pos3 =
find_pos(
"<li><a href=", html, start);
85 while ((pos3 != -1) && (pos3 < end)) {
87 first_char = strrchr(html[pos3],
'"');
88 last_char = strrchr(html[pos3],
'<');
89 len = (last_char - first_char) /
sizeof(
char);
90 strncpy(item, first_char + 2 *
sizeof(
char), len);
92 if (strcmp(ext, item) < 0) {
98 pos3 =
find_pos(
"<li><a href=", html, start);
103 "<li><a href=\"../extensions/%s/index.html\">%s (%i.%i.%i)</a>\n",
104 ext, ext, major, minor, revision);
112 int pos1, pos2, pos3;
118 pos1 =
find_pos(
"<b>Drivers sections:</b>", html, 0);
124 (
"<!-- GEM Extensions StartHTML. Do not delete or change this comment! -->",
129 (
"Unknown format of index.html. Unable to de-register HTML man pages.\n");
134 pos2 =
find_pos(
"<hr>", html, pos1);
135 if (
find_pos(
"<h3>Installed extensions:</h3>", html, pos1) == -1) {
137 print_warning(
"no extensions section found in index.html.\n");
141 start =
find_pos(
"<h3>Installed extensions:</h3>", html, pos1);
142 end =
find_pos(
"</ul>", html, start);
149 print_warning(
"extension '%s' not listed in index.html.\n", ext);
160 pos3 =
find_pos(
"<ul>", html, start);
161 if ((pos3 != -1) && (end > pos3) && (end - pos3 < 2)) {
162 for (i = 0; i < 4; i++) {
180 sprintf(file,
"%s/docs/html/index.html", gisbase);
181 f_in = fopen(file,
"r");
183 if (
errno == ENOENT) {
191 file, strerror(
errno));
197 strcpy(
TMP_HTML,
"/tmp/grass.extensions.db.XXXXXX");
203 "could not create temp file '%s': %s\n \
204 Make sure that directory /tmp exists on your system and you have write permission.\n",
TMP_HTML, strerror(
errno));
212 "cp -vf %s %s/docs/html/index.html ; chmod -v a+r %s/docs/html/index.html ;",
217 "cp -f %s %s/docs/html/index.html &>%s ; chmod a+r %s/docs/html/index.html &>%s ;",
236 line = (
char **)calloc(n_lines + 10,
sizeof(
char *));
237 for (i = 0; i < (n_lines + 10); i++) {
242 line[i] = (
char *)
malloc((1 + strlen(str)) *
sizeof(
char));
243 strcpy(line[i], str);
249 new_ext_html(pkg_short_name, gisbase, line, major, minor, revision);
253 while (line[i] !=
NULL) {
254 fprintf(f_out, line[i]);
264 for (i = 0; i < (n_lines + 10); i++) {
281 sprintf(file,
"%s/docs/html/index.html", gisbase);
282 f_in = fopen(file,
"r");
284 if (
errno == ENOENT) {
292 file, strerror(
errno));
298 strcpy(
TMP_HTML,
"/tmp/grass.extensions.db.XXXXXX");
304 "could not create temp file '%s': %s\n \
305 Make sure that directory /tmp exists on your system and you have write permission.\n",
TMP_HTML, strerror(
errno));
313 "cp -vf %s %s/docs/html/index.html ; chmod -v a+r %s/docs/html/index.html ;",
318 "cp -f %s %s/docs/html/index.html &>%s ; chmod a+r %s/docs/html/index.html &>%s ;",
337 line = (
char **)calloc(n_lines + 1,
sizeof(
char *));
338 for (i = 0; i < (n_lines + 1); i++) {
343 line[i] = (
char *)
malloc((1 + strlen(str)) *
sizeof(
char));
344 strcpy(line[i], str);
353 while (line[i] !=
NULL) {
354 fprintf(f_out, line[i]);
364 for (i = 0; i < (n_lines + 1); i++) {
382 int n_entries, n_lines, i;
383 FILE *f_in, *f_out, *f_ext;
389 int major, minor, revision;
393 sprintf(idx,
"%s/docs/html/index.html", gisbase);
394 f_in = fopen(idx,
"r");
396 if (
errno == ENOENT) {
404 idx, strerror(
errno));
410 strcpy(
TMP_HTML,
"/tmp/grass.extensions.db.XXXXXX");
416 "could not create temp file '%s': %s\n \
417 Make sure that directory /tmp exists on your system and you have write permission.\n",
TMP_HTML, strerror(
errno));
423 "cp -vf %s %s/docs/html/index.html ; chmod -v a+r %s/docs/html/index.html ;",
428 "cp -f %s %s/docs/html/index.html &>%s ; chmod a+r %s/docs/html/index.html &>%s ;",
436 sprintf(dir,
"%s/docs/extensions", gisbase);
448 sprintf(subdir,
"%s/%s", dir, ep->d_name);
449 if ((!strcmp(ep->d_name,
".")) || (!strcmp(ep->d_name,
".."))) {
453 if (subdirp ==
NULL) {
476 line = (
char **)calloc(n_lines + n_subdirs + 10,
sizeof(
char *));
477 for (i = 0; i < (n_lines + n_subdirs + 10); i++) {
482 line[i] = (
char *)
malloc((1 + strlen(str)) *
sizeof(
char));
483 strcpy(line[i], str);
492 sprintf(subdir,
"%s/%s", dir, ep->d_name);
493 if ((!strcmp(ep->d_name,
".")) || (!strcmp(ep->d_name,
".."))) {
497 if (subdirp ==
NULL) {
503 sprintf(ext_idx,
"%s/index.html", subdir);
504 f_ext = fopen(ext_idx,
"r");
514 if (strstr(str,
"<title>") !=
NULL) {
522 sscanf(strchr(str,
'(') +
sizeof(
char),
"%i.%i.%i", &major, &minor,
524 new_ext_html(ep->d_name, gisbase, line, major, minor, revision);
532 while (line[i] !=
NULL) {
533 fprintf(f_out, line[i]);
543 for (i = 0; i < (n_lines + n_subdirs + 10); i++) {
548 return (num_restored);
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
EXTERN char TMP_NULL[MAXSTR]
void print_error(int err_code, char *msg,...)
void delete_ext_html(char *ext, char *gisbase, char **html)
EXTERN char TMP_HTML[MAXSTR]
void deregister_html(char *pkg_short_name, char *gisbase)
void new_ext_html(char *ext, char *gisbase, char **html, int major, int minor, int revision)
EXTERN char HTML_CMD[MAXSTR]
void register_html(char *pkg_short_name, char *gisbase, int major, int minor, int revision)
void print_warning(char *msg,...)
#define ERR_REGISTER_HTML
int restore_html(char *gisbase)