httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@hyperreal.org
Subject cvs commit: apache-2.0/mpm/src/modules/standard mod_echo.c
Date Fri, 23 Jul 1999 18:52:29 GMT
ben         99/07/23 11:52:29

  Modified:    mpm/src  Configuration.tmpl
  Added:       mpm/src/modules/standard mod_echo.c
  Log:
  Support for echo protocol, to show how multiprotocol support works.
  
  Revision  Changes    Path
  1.5       +4 -0      apache-2.0/mpm/src/Configuration.tmpl
  
  Index: Configuration.tmpl
  ===================================================================
  RCS file: /export/home/cvs/apache-2.0/mpm/src/Configuration.tmpl,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Configuration.tmpl	1999/07/10 18:20:16	1.4
  +++ Configuration.tmpl	1999/07/23 18:52:28	1.5
  @@ -414,3 +414,7 @@
   
   AddModule modules/standard/mod_setenvif.o
   
  +## Demonstration module for the TCP echo protocol, just to show how
  +## multiprotocol support works.
  +
  +AddModule modules/standard/mod_echo.o
  
  
  
  1.1                  apache-2.0/mpm/src/modules/standard/mod_echo.c
  
  Index: mod_echo.c
  ===================================================================
  #include "httpd.h"
  #include "http_config.h"
  #include "http_connection.h"
  
  API_VAR_EXPORT module echo_module;
  
  typedef struct
      {
      int bEnabled;
      } EchoConfig;
  
  static void *create_echo_server_config(pool *p,server_rec *s)
      {
      EchoConfig *pConfig=ap_pcalloc(p,sizeof *pConfig);
  
      pConfig->bEnabled=0;
  
      return pConfig;
      }
  
  static const char *echo_on(cmd_parms *cmd, void *dummy, char *arg)
      {
      EchoConfig *pConfig=ap_get_module_config(cmd->server->module_config,
  					     &echo_module);
      pConfig->bEnabled=1;
  
      return NULL;
      }
  
  static int process_echo_connection(conn_rec *c)
      {
      char buf[1024];
      EchoConfig *pConfig=ap_get_module_config(c->base_server->module_config,
  					     &echo_module);
  
      if(!pConfig->bEnabled)
  	return DECLINED;
  
      for( ; ; )
  	{
  	int w;
  	int r=ap_bread(c->client,buf,sizeof buf);
  	if(r <= 0)
  	    break;
  	w=ap_bwrite(c->client,buf,r);
  	if(w != r)
  	    break;
  	ap_bflush(c->client);
  	}
      return OK;
      }
  
  static const command_rec echo_cmds[] = {
  { "ProtocolEcho", echo_on, NULL, RSRC_CONF, RAW_ARGS,
    "Run an echo server on this host" },
  { NULL }
  };
  
  static void register_hooks()
      {
      ap_hook_process_connection(process_echo_connection,NULL,NULL,HOOK_MIDDLE);
      }
  
  API_VAR_EXPORT module echo_module = {
      STANDARD20_MODULE_STUFF,
      NULL,			/* pre_command_line */
      NULL,			/* pre_config */
      NULL,			/* post_config */
      NULL,			/* open_logs */
      NULL, 			/* child_init */
      NULL,			/* create per-directory config structure */
      NULL,			/* merge per-directory config structures */
      create_echo_server_config,	/* create per-server config structure */
      NULL,			/* merge per-server config structures */
      echo_cmds,			/* command table */
      NULL,			/* handlers */
      NULL,			/* check auth */
      NULL,			/* check access */
      NULL,			/* type_checker */
      NULL,			/* pre-run fixups */
      register_hooks		/* register hooks */
  };
  
  
  

Mime
View raw message