WEBBY - the embedded web server with many faces / objects in plain C Snapshot
Classes | Typedefs | Functions
WEBBYCFG

embedded web server configuration More...

Classes

struct  tagWEBBY_CONFIG

Typedefs

typedef struct tagWEBBY_CONFIG WEBBY_CONFIG

Functions

int WEBBY_CONFIG_load (WEBBY_CONFIG *cfg, const char *file)

Detailed Description

embedded web server configuration


Typedef Documentation

typedef struct tagWEBBY_CONFIG WEBBY_CONFIG

Function Documentation

int WEBBY_CONFIG_load ( WEBBY_CONFIG cfg,
const char *  file 
)

Definition at line 570 of file webby.c.

{
  PROPERTIES props;
  const char *tmp;
  IPADDRESS addr;
  uint16_t port;

  if (PROPERTIES_init( &props, 30 )) {
    return -1;
  }
  if (PROPERTIES_load( &props, file )) {
    return -1;
  }

  tmp = PROPERTIES_get( &props, "host" );
  if (!tmp) {
    MLOG_ERROR( "Missing configuration parameter: host" );
    return -1;
  }

  if ( IPADDRESS_parse_string( &addr, tmp ) ) {
     MLOG_ERROR( "invalid configuration parameter: host" );
     return -1;
  }

  if (PROPERTIES_dec_uint16_t( &props, "port", &port)) {
     MLOG_ERROR( "Missing/Invalid configuration parameter: port" );
     return -1;
  }

  if (SOCKADDR_init( &cfg->listening_address, &addr, (uint16_t) port ) ) {
     MLOG_ERROR( "Missing/Invalid host/port configuration" );
     return -1;
  }

  if (PROPERTIES_dec_int32_t( &props, "listen_backlog", &cfg->listen_backlog)) {
     MLOG_ERROR( "Missing/Invalid configuration parameter: listen_backlog" );
     return -1;
  }

  if (PROPERTIES_dec_int32_t( &props, "socket_buffer_size", &cfg->socket_buffer_size)) {
     MLOG_ERROR( "Missing/Invalid configuration parameter: listen_backlog" );
     return -1;
  }

  if (PROPERTIES_dec_int32_t( &props, "max_connections", &cfg->max_connections)) {
     MLOG_ERROR( "Missing/Invalid configuration parameter: max_connections" );
     return -1;
  }

  if (PROPERTIES_dec_int32_t( &props, "io_timeout", &cfg->io_timeout)) {
     MLOG_ERROR( "Missing/Invalid configuration parameter: io_timeout" );
     return -1;
  }

  if (PROPERTIES_dec_int32_t( &props, "idle_timeout", &cfg->idle_timeout)) {
     MLOG_ERROR( "Missing/Invalid configuration parameter: idle_timeout" );
     return -1;
  }

  if (PROPERTIES_dec_int32_t( &props, "stack_pages_per_thread", &cfg->stack_pages_per_thread)) {
     MLOG_ERROR( "Missing/Invalid configuration parameter: stack_pages_per_thread");
     return -1;
  }
  PROPERTIES_free( &props );
  return 0;
}