Re: Feeding params to cachemgr.cgi

From: Mark Treacy <mark@dont-contact.us>
Date: Fri, 30 Aug 1996 01:10:25 +1000

>> Yo,
>>
>> I'm sure there is a way to feed parameters into /cgi-bin/cachemgr.cgi;
>> I'm tired of typing my server name into the text field every time I
>> want to use the cache interface. How can I do this? I (briefly) took
>> a peek at cachemgr.c but couldn't find anything..
>> Any hints?
>>
> You could just make an HTML form which starts off setting the right
> values. Just bring up the cachemanager in Netscape, dump the HTML
> to a file, edit it to "host" to be the value of your hostname, edit
> "port" to the port.
>
> ...or, do a brutal hack to cachemgr.c
>
> printf("SIZE=30 VALUE=\"%s\">\n", CACHEMGR_HOSTNAME);
> change %s to your target proxy hostname
> printf("SIZE=30 VALUE=\"%d\">\n", CACHE_HTTP_PORT);
> change %s to your target proxy port
Or duplicate the functionality added to the commercial Harvest 2.0 code.
See
        http://www.netcache.com/DOC/manager.html
for a description of how to use this. Note I used CACHEMGR_HOSTNAME
rather than HARVEST_ for the environment variable.

 - Mark

Example patch follows:

*** /tmp/T0a0033C Fri Aug 30 01:04:28 1996
--- cachemgr.c Fri Aug 30 01:04:09 1996
***************
*** 1,6 ****
  
  /*
! * $Id: cachemgr.c,v 1.16 1996/08/26 19:57:02 wessels Exp $
   *
   * DEBUG: Section 0 CGI Cache Manager
   * AUTHOR: Harvest Derived
--- 1,6 ----
  
  /*
! * $Id: cachemgr.c,v 1.16.1.1 1996/08/29 15:03:36 mark Exp $
   *
   * DEBUG: Section 0 CGI Cache Manager
   * AUTHOR: Harvest Derived
***************
*** 267,272 ****
--- 267,274 ----
  
  char *script_name = "/cgi-bin/cachemgr.cgi";
  char *progname = NULL;
+ int portnum;
+ char hostname[256];
  
  static int client_comm_connect _PARAMS((int, char *, int));
  
***************
*** 299,307 ****
      printf("<FORM METHOD=\"POST\" ACTION=\"%s\">\n", script_name);
      printf("<PRE>\n");
      printf("<BR><STRONG>Cache Host:</STRONG><INPUT NAME=\"host\" ");
! printf("SIZE=30 VALUE=\"%s\">\n", CACHEMGR_HOSTNAME);
      printf("<BR><STRONG>Cache Port:</STRONG><INPUT NAME=\"port\" ");
! printf("SIZE=30 VALUE=\"%d\">\n", CACHE_HTTP_PORT);
      printf("<BR><STRONG>Password :</STRONG><INPUT TYPE=\"password\" ");
      printf("NAME=\"password\" SIZE=30 VALUE=\"\">\n");
      printf("<BR><STRONG>URL :</STRONG><INPUT NAME=\"url\" ");
--- 301,309 ----
      printf("<FORM METHOD=\"POST\" ACTION=\"%s\">\n", script_name);
      printf("<PRE>\n");
      printf("<BR><STRONG>Cache Host:</STRONG><INPUT NAME=\"host\" ");
! printf("SIZE=30 VALUE=\"%s\">\n", hostname);
      printf("<BR><STRONG>Cache Port:</STRONG><INPUT NAME=\"port\" ");
! printf("SIZE=30 VALUE=\"%d\">\n", portnum);
      printf("<BR><STRONG>Password :</STRONG><INPUT TYPE=\"password\" ");
      printf("NAME=\"password\" SIZE=30 VALUE=\"\">\n");
      printf("<BR><STRONG>URL :</STRONG><INPUT NAME=\"url\" ");
***************
*** 497,503 ****
  
  int main(int argc, char *argv[])
  {
- static char hostname[256];
      static char operation[256];
      static char password[256];
      static char url[4096];
--- 499,504 ----
***************
*** 515,521 ****
      int conn;
      int len;
      int bytesWritten;
- int portnum = CACHE_HTTP_PORT;
      int op = 0;
      int p_state;
      int n_loops;
--- 516,521 ----
***************
*** 544,550 ****
              hasTables = TRUE;
          }
      }
! hostname[0] = '\0';
      if ((s = getenv("CONTENT_LENGTH")) == NULL) {
          noargs_html();
          exit(0);
--- 544,557 ----
              hasTables = TRUE;
          }
      }
! if (s = getenv("CACHEMGR_HOSTNAME"))
! strncpy(hostname, s, sizeof(hostname)-1);
! else
! strncpy(hostname, CACHEMGR_HOSTNAME, sizeof(hostname)-1);
! if (s = getenv("CACHE_HTTP_PORT"))
! portnum = strtol(s, NULL, 0);
! else
! portnum = CACHE_HTTP_PORT;
      if ((s = getenv("CONTENT_LENGTH")) == NULL) {
          noargs_html();
          exit(0);
Received on Thu Aug 29 1996 - 08:12:41 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:32:53 MST