コード例 #1
0
/**
 * Parse the CauchoHosts configuration in the apache config file.
 */
static const char *
cse_host_command(cmd_parms *cmd, void *mconfig, char *host_arg, char *port_arg)
{
  config_t *config = cse_get_cmd_config(cmd);
  int port = port_arg ? atoi(port_arg) : DEFAULT_PORT;
  resin_host_t *host;

  host = config->manual_host;
  if (! host) {
    host = cse_alloc(config->p, sizeof(resin_host_t));
    memset(host, 0, sizeof(resin_host_t));
    
    host->name = "manual";
    host->canonical = host;

    host->config = config;
    
    host->cluster.config = config;
    host->cluster.round_robin_index = -1;
    
    config->manual_host = host;
  }

  cse_add_host(&host->cluster, host_arg, port);

  return 0;
}
コード例 #2
0
/**
 * Parse the CauchoBackup configuration in the apache config file.
 */
static const char *
cse_backup_command(cmd_parms *cmd, void *pconfig,
		   const char *host_arg, const char *port_arg)
{
  config_t *config = pconfig; /* = cse_get_server_config(cmd->server); */
  int port = port_arg ? atoi(port_arg) : DEFAULT_PORT;
  resin_host_t *host;

  if (! config)
    return 0;

  config->has_config = 1;
  
  host = config->manual_host;
  if (! host) {
    host = cse_alloc(config->p, sizeof(resin_host_t));
    memset(host, 0, sizeof(resin_host_t));
    
    host->name = "manual";
    host->canonical = host;

    host->cluster.config = config;
    host->cluster.round_robin_index = -1;
    
    config->manual_host = host;
  }

  cse_add_backup(config->p, &host->cluster, host_arg, port);

  return 0;
}
コード例 #3
0
ファイル: memory.c プロジェクト: BruceZhou2012/baratine
char *
cse_strdup(mem_pool_t *pool, const char *str)
{
  int len = strlen(str);
  char *buf = cse_alloc(pool, len + 1);

  strcpy(buf, str);

  return buf;
}