Author: nkinder
Update of /cvs/dirsec/adminserver/admserv/cgi-src40
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv714
Modified Files:
help.c
Log Message:
Resolves: 251418
Summary: Added header and footer support to help.cgi.
Index: help.c
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/help.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- help.c 22 Jun 2007 01:34:19 -0000 1.9
+++ help.c 8 Aug 2007 22:23:18 -0000 1.10
@@ -74,6 +74,8 @@
#define DIR_VAR "HelpDirectory"
#define HELPWIN_VAR "HelpWindow"
#define TOKEN_FILE "index.map"
+#define HEADER_FILE "header.htm"
+#define FOOTER_FILE "footer.htm"
#define HEAD_BLOCK "<head>"
#define FRAME_BLOCK "<frame "
#define TITLE_BLOCK "<title>"
@@ -279,7 +281,6 @@
{
char path[PATH_LENGTH];
char base[PATH_LENGTH];
- char *dirp;
FILE *file = NULL;
if (debugPrintout)
@@ -287,8 +288,33 @@
printf( "New help<P>\n" );
}
- /* Open the target file and return the contents */
+ /* read and flush the header to stdout */
+ safe_snprintf(path, sizeof(path), "%s%c%s%c%s%c%s", MANUALDIR, FILE_SEP,
locale, FILE_SEP,
+ product, FILE_SEP, HEADER_FILE);
+ if (!(file = fopen(path, "r")))
+ {
+ safe_snprintf(base, sizeof(base), "unable to open file: %s", path);
+ if (debugPrintout)
+ {
+ printf("%s<P>\n", base);
+ fflush( stdout );
+ }
+ return error_exit(base);
+ }
+ if (debugPrintout)
+ {
+ printf("reading file: %s<P>\n", path);
+ }
+ if (!didContentHeader)
+ {
+ printf("Content-type: text/html\n\n");
+ }
+ while (fgets(path, PATH_LENGTH, file))
+ {
+ fputs(path, stdout);
+ }
+ /* Open the target file and return the contents */
safe_snprintf(path, sizeof(path), "%s%c%s%c%s%c%s", MANUALDIR, FILE_SEP,
locale, FILE_SEP,
product, FILE_SEP, content);
if (!(file = fopen(path, "r")))
@@ -305,22 +331,31 @@
{
printf("reading file: %s<P>\n", path);
}
+ while (fgets(path, PATH_LENGTH, file))
+ {
+ fputs(path, stdout);
+ }
- /* spit out the output, inserting a BASE tag into the HEAD block */
- if (dirp = strchr(content, FILE_SEP)) {
- safe_snprintf(base, sizeof(base), "<base
href=\"/%s/%s/%s/help/%.*s/\">", "manual", locale, product,
- (dirp-content), content);
- } else {
- safe_snprintf(base, sizeof(base), "<base
href=\"/%s/%s/%s/help/\">", "manual", locale, product);
+ /* read and flush the footer to stdout */
+ safe_snprintf(path, sizeof(path), "%s%c%s%c%s%c%s", MANUALDIR, FILE_SEP,
locale, FILE_SEP,
+ product, FILE_SEP, FOOTER_FILE);
+ if (!(file = fopen(path, "r")))
+ {
+ safe_snprintf(base, sizeof(base), "unable to open file: %s", path);
+ if (debugPrintout)
+ {
+ printf("%s<P>\n", base);
+ fflush( stdout );
+ }
+ return error_exit(base);
}
- if (!didContentHeader)
+ if (debugPrintout)
{
- printf("Content-type: text/html\n\n");
+ printf("reading file: %s<P>\n", path);
}
-
while (fgets(path, PATH_LENGTH, file))
{
- fputs(path, stdout);
+ fputs(path, stdout);
}
/* finished */