[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Fedora-directory-commits] adminserver/admserv/cgi-src40 download.c, 1.7, 1.8



Author: rmeggins

Update of /cvs/dirsec/adminserver/admserv/cgi-src40
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv27530/adminserver/admserv/cgi-src40

Modified Files:
	download.c 
Log Message:
Resolves: bug 383301
Bug Description: Admin Server main html page refers to dsgw, org
Reviewed by: nhosoi (Thanks!)
Fix Description: Introduce a new directive - INCLUDEIFEXISTS.  This will include the html file specified if it exists, or just skip it if not found.  When dsgw, org, etc. are ready, we can just plug in the appropriate html file.
I added the html excerpts to the data directory so we can have them in case we want to use them - just copy them to the html directory and reload the main admin server page.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none



Index: download.c
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/download.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- download.c	9 May 2007 00:26:30 -0000	1.7
+++ download.c	15 Nov 2007 17:02:02 -0000	1.8
@@ -71,9 +71,6 @@
 
 #define MYHTMLFILE      "admserv.html"
 
-#define DSGW_BLOCK		"<dsgw_menu_block>"
-#define DSGW_BLOCK_CLOSE	"</dsgw_menu_block>"
-
 static int
 safe_snprintf(char *buf, size_t size, const char *fmt, ...)
 {
@@ -99,11 +96,9 @@
 {
    char  line[PATH_LENGTH];
    FILE *html;
-   int   i, dsgwblock, has_dsgw;
+   int   i;
    char          *acceptLanguage = NULL;
    char          *loc;
-   
-   has_dsgw = 1; /* hardcoded for now until we can figure out a better mechanism */
 
    acceptLanguage = getenv("HTTP_ACCEPT_LANGUAGE");
    if (acceptLanguage == NULL)
@@ -121,6 +116,7 @@
                     HTMLDIR, FILE_SEP, loc[0],loc[1], FILE_SEP, MYHTMLFILE);
       if ((html = fopen(line, "r")) != NULL)
       {
+         loc[2] = '\0';
          break;
       }
       else
@@ -134,6 +130,7 @@
             {
               error_exit(MYHTMLFILE " not found");
             }
+            loc = "";
             break;
          }
       }
@@ -141,30 +138,32 @@
 
    printf("Content-type: text/html\n\n");
 
-   dsgwblock = 0;
-
    while (fgets(line, PATH_LENGTH, html))
    {
-      if (!STRNCASECMP(line, DSGW_BLOCK, strlen(DSGW_BLOCK)))
-      {
-         dsgwblock = 1;
-         continue;
-      }
-
-      if (!STRNCASECMP(line, DSGW_BLOCK_CLOSE, strlen(DSGW_BLOCK_CLOSE)))
-      {
-         dsgwblock =0;
+#define INCLUDEIFEXISTS "<!-- INCLUDEIFEXISTS "
+      if (!strncmp(line, INCLUDEIFEXISTS, strlen(INCLUDEIFEXISTS))) {
+         char *p = line + strlen(INCLUDEIFEXISTS);
+         char *end = strstr(line, " -->");
+         if (p && *p && end) {
+            char includefile[PATH_LENGTH];
+            FILE *includedhtml = NULL;
+            *end = '\0';
+            safe_snprintf(includefile, sizeof(includefile),
+                          "%s%c%s%s%s",
+                          HTMLDIR, FILE_SEP, loc ? loc : "",
+                          loc ? "/" : "", p);
+            includedhtml = fopen(includefile, "r");
+            while (includedhtml && fgets(line, PATH_LENGTH, includedhtml)) {
+               printf("%s", line);
+            }
+            if (includedhtml) {
+               fclose(includedhtml);
+               includedhtml = NULL;
+            }
+         }
          continue;
       }
-
-      if (!dsgwblock)
-      {
-         printf("%s", line);
-	 continue;
-      }
-
-      if (dsgwblock && has_dsgw)
-            printf("%s", line);
+      printf("%s", line);
    }
    
    fflush(stdout);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]