Пример #1
0
static void
test_pipefrom_version(struct cfg_s *cfg0, struct cfg_s *cfg1, gint64 r)
{
	gint64 worst = 0;
	GTree *v0 = build_version(cfg0);
	GTree *v1 = build_version(cfg1);
	GError *err = version_validate_diff(v0, v1, &worst);
	g_assert_error(err, GQD("sqliterepo"), CODE_PIPEFROM);
	g_assert(r == worst);
	g_tree_destroy(v0);
	g_tree_destroy(v1);
}
Пример #2
0
static void
test_concurrent_version(struct cfg_s *cfg0, struct cfg_s *cfg1)
{
	gint64 worst = 0;
	GTree *v0 = build_version(cfg0);
	GTree *v1 = build_version(cfg1);
	GError *err = version_validate_diff(v0, v1, &worst);
	g_assert_error(err, GQD("sqliterepo"), CODE_CONCURRENT);
	g_assert(0 == worst);
	g_tree_destroy(v0);
	g_tree_destroy(v1);
}
Пример #3
0
static void
test_noerror_version(struct cfg_s *c0, struct cfg_s *c1, gint64 r)
{
	gint64 worst = 0;
	GTree *v0 = build_version(c0);
	GTree *v1 = build_version(c1);
	GError *err = version_validate_diff(v0, v1, &worst);
	g_assert_no_error(err);
	g_assert(worst == r);
	g_tree_destroy(v0);
	g_tree_destroy(v1);
}
Пример #4
0
/**
 * @brief	Display the POP3 server capabilities, in response to a POP3 CAPA command.
 * @param	con		the POP3 client connection issuing the command.
 * @return	This function returns no value.
 */
void pop_capa(connection_t *con) {

	// If the user is in authorization mode via an insecure channel and there is an SSL context, output the STLS capability.
	if (con->pop.session_state == 0 && con_secure(con) == 0) {
		con_print(con, "+OK Capabilities follow.\r\nTOP\r\nUSER\r\nUIDL\r\nSTLS\r\nPIPELINING\r\nEXPIRE NEVER\r\nLOGIN-DELAY 0\r\n"
			"RESP-CODES\r\nAUTH-RESP-CODE\r\nIMPLEMENTATION magmad %s\r\n.\r\n", build_version());
	}
	// Otherwise don't advertise STLS.
	else {
		con_print(con, "+OK Capabilities follow.\r\nTOP\r\nUSER\r\nUIDL\r\nPIPELINING\r\nEXPIRE NEVER\r\nLOGIN-DELAY 0\r\n"
			"RESP-CODES\r\nAUTH-RESP-CODE\r\nIMPLEMENTATION magmad %s\r\n.\r\n", build_version());
	}

	return;
}
Пример #5
0
/* Dispatch client write state, following socks5 RFC
 * In each state, it deal with write buf on soc and
 * change state to next
 *
 * Return:
 * 	-1, error something happen we need to disconnect the client
 * 	 0, success
 */
int dispatch_client_write(s_socket *soc, s_socks *socks,
		s_buffer *buf, s_socks_conf *conf)
{
	int k = 0;
	switch(socks->state){
		case S_W_VER:
			if ( buf_empty(buf) )
				build_version(socks, conf, buf);

			WRITE_DISP(k, soc, buf);
			socks->state = S_R_VER_ACK;
			break;

		case S_W_AUTH:
			WRITE_DISP(k, soc, buf);
			socks->state = S_R_AUTH_ACK;
			break;

		case S_W_REQ:
			WRITE_DISP(k, soc, buf);
			socks->state = S_R_REQ_ACK;
			break;

		case S_REPLY:
			k = write_socks(soc, buf);
			if (k < 0){ close_socket(soc);  break; } /* Error */
			init_buffer(buf);
			break;

		default:
			break;
	}

	return k;
}
Пример #6
0
std::string IEServer::GetStatus() {
  SYSTEM_INFO system_info;
  ::ZeroMemory(&system_info, sizeof(SYSTEM_INFO));
  ::GetNativeSystemInfo(&system_info);

  OSVERSIONINFO os_version_info;
  ::ZeroMemory(&os_version_info, sizeof(OSVERSIONINFO));
  os_version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  ::GetVersionEx(&os_version_info);

  // Allocate only 2 characters for the major and minor versions
  // and 5 characters for the build number (+1 for null char)
  vector<char> major_buffer(3);
  _itoa_s(os_version_info.dwMajorVersion, &major_buffer[0], 3, 10);
  vector<char> minor_buffer(3);
  _itoa_s(os_version_info.dwMinorVersion, &minor_buffer[0], 3, 10);
  vector<char> build_buffer(6);
  _itoa_s(os_version_info.dwBuildNumber, &build_buffer[0], 6, 10);

  std::string major_version(&major_buffer[0]);
  std::string minor_version(&minor_buffer[0]);
  std::string build_version(&build_buffer[0]);
  std::string os_version = major_version + "." + minor_version + "." + build_version;

  std::string arch = "x86";
  if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
    arch = "x64";
  }

  Json::Value build;
  build["version"] = "2.21.0";

  Json::Value os;
  os["arch"] = arch;
  os["name"] = "windows";
  os["version"] = os_version;
    
  Json::Value status;
  status["build"] = build;
  status["os"] = os;
  Response response;
  response.SetSuccessResponse(status);
  return response.Serialize();
}
Пример #7
0
int
do_parse(request_t* request)
{
    int started = 0;
    int status;
    char* buffer;
    size_t length;
    char* p;
    char* pe;
    int cs;
    int gensaved = 0;
    int urisaved = 0;
    
    do
    {
        // Get a chunk of data to parse.
        status = fill_buffer(request, &buffer, &length);
        if(status < 0 || (status == 0 && started)) return -1;
        if(status == 0) return 0;
        started = 1;

        // If we saved some state in the buffers we need
        // to reinitialize them before resuming parsing.

        if(gensaved) reinit_buffer(request->genbuf, buffer);
        gensaved = 0;
        
        if(urisaved) reinit_buffer(request->uribuf, buffer);
        urisaved = 0;

        // Setup and run the main parse loop saving the
        // parse state afterwards.

        cs = request->cs;
        p = buffer;
        pe = buffer + length;

        
#line 219 "./c_src/request.c"
	{
	if ( p == pe )
		goto _test_eof;
	switch ( cs )
	{
case 1:
	switch( (*p) ) {
		case 36: goto tr0;
		case 95: goto tr0;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto tr0;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto tr0;
	} else
		goto tr0;
	goto st0;
st0:
cs = 0;
	goto _out;
tr0:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st2;
st2:
	if ( ++p == pe )
		goto _test_eof2;
case 2:
#line 253 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st48;
		case 95: goto st48;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st48;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st48;
	} else
		goto st48;
	goto st0;
tr2:
#line 44 "./c_src/request.rl"
	{
        request->method = buffer_to_string(request->genbuf, p);
        if(request->method == NULL) {p++; cs = 3; goto _out;}
    }
	goto st3;
st3:
	if ( ++p == pe )
		goto _test_eof3;
case 3:
#line 280 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr4;
		case 32: goto tr4;
		case 35: goto tr5;
		case 42: goto tr6;
		case 43: goto tr7;
		case 47: goto tr8;
		case 63: goto tr9;
	}
	if ( (*p) < 65 ) {
		if ( 45 <= (*p) && (*p) <= 57 )
			goto tr7;
	} else if ( (*p) > 90 ) {
		if ( 97 <= (*p) && (*p) <= 122 )
			goto tr7;
	} else
		goto tr7;
	goto st0;
tr4:
#line 82 "./c_src/request.rl"
	{
        assert(request->uribuf->pos == NULL && "wont overwrite uri mark");
        request->uribuf->pos = p;
    }
#line 87 "./c_src/request.rl"
	{
        request->uri = buffer_to_string(request->uribuf, p);
        if(request->fragment == NULL) {p++; cs = 4; goto _out;}
    }
	goto st4;
st4:
	if ( ++p == pe )
		goto _test_eof4;
case 4:
#line 315 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr4;
		case 32: goto tr4;
		case 35: goto tr5;
		case 42: goto tr6;
		case 43: goto tr7;
		case 47: goto tr8;
		case 63: goto tr9;
		case 72: goto tr10;
	}
	if ( (*p) < 65 ) {
		if ( 45 <= (*p) && (*p) <= 57 )
			goto tr7;
	} else if ( (*p) > 90 ) {
		if ( 97 <= (*p) && (*p) <= 122 )
			goto tr7;
	} else
		goto tr7;
	goto st0;
tr5:
#line 82 "./c_src/request.rl"
	{
        assert(request->uribuf->pos == NULL && "wont overwrite uri mark");
        request->uribuf->pos = p;
    }
	goto st5;
tr51:
#line 54 "./c_src/request.rl"
	{
        request->host = buffer_to_string(request->genbuf, p);
        if(request->host == NULL) {p++; cs = 5; goto _out;}
    }
	goto st5;
tr57:
#line 67 "./c_src/request.rl"
	{
        request->path = buffer_to_string(request->genbuf, p);
        if(request->path == NULL) {p++; cs = 5; goto _out;}
    }
	goto st5;
tr63:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
#line 72 "./c_src/request.rl"
	{
        request->query = buffer_to_string(request->genbuf, p);
        if(request->query == NULL) {p++; cs = 5; goto _out;}
    }
	goto st5;
tr67:
#line 72 "./c_src/request.rl"
	{
        request->query = buffer_to_string(request->genbuf, p);
        if(request->query == NULL) {p++; cs = 5; goto _out;}
    }
	goto st5;
tr71:
#line 59 "./c_src/request.rl"
	{
        request->port = 0;
    }
	goto st5;
st5:
	if ( ++p == pe )
		goto _test_eof5;
case 5:
#line 385 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr11;
		case 32: goto tr11;
		case 37: goto tr13;
		case 61: goto tr12;
		case 95: goto tr12;
	}
	if ( (*p) < 44 ) {
		if ( (*p) > 34 ) {
			if ( 36 <= (*p) && (*p) <= 42 )
				goto tr12;
		} else if ( (*p) >= 33 )
			goto tr12;
	} else if ( (*p) > 59 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto tr12;
		} else if ( (*p) >= 64 )
			goto tr12;
	} else
		goto tr12;
	goto st0;
tr11:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
#line 77 "./c_src/request.rl"
	{
        request->fragment = buffer_to_string(request->genbuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
#line 87 "./c_src/request.rl"
	{
        request->uri = buffer_to_string(request->uribuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
	goto st6;
tr39:
#line 77 "./c_src/request.rl"
	{
        request->fragment = buffer_to_string(request->genbuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
#line 87 "./c_src/request.rl"
	{
        request->uri = buffer_to_string(request->uribuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
	goto st6;
tr43:
#line 87 "./c_src/request.rl"
	{
        request->uri = buffer_to_string(request->uribuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
	goto st6;
tr50:
#line 54 "./c_src/request.rl"
	{
        request->host = buffer_to_string(request->genbuf, p);
        if(request->host == NULL) {p++; cs = 6; goto _out;}
    }
#line 87 "./c_src/request.rl"
	{
        request->uri = buffer_to_string(request->uribuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
	goto st6;
tr55:
#line 67 "./c_src/request.rl"
	{
        request->path = buffer_to_string(request->genbuf, p);
        if(request->path == NULL) {p++; cs = 6; goto _out;}
    }
#line 87 "./c_src/request.rl"
	{
        request->uri = buffer_to_string(request->uribuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
	goto st6;
tr61:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
#line 72 "./c_src/request.rl"
	{
        request->query = buffer_to_string(request->genbuf, p);
        if(request->query == NULL) {p++; cs = 6; goto _out;}
    }
#line 87 "./c_src/request.rl"
	{
        request->uri = buffer_to_string(request->uribuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
	goto st6;
tr65:
#line 72 "./c_src/request.rl"
	{
        request->query = buffer_to_string(request->genbuf, p);
        if(request->query == NULL) {p++; cs = 6; goto _out;}
    }
#line 87 "./c_src/request.rl"
	{
        request->uri = buffer_to_string(request->uribuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
	goto st6;
tr70:
#line 59 "./c_src/request.rl"
	{
        request->port = 0;
    }
#line 87 "./c_src/request.rl"
	{
        request->uri = buffer_to_string(request->uribuf, p);
        if(request->fragment == NULL) {p++; cs = 6; goto _out;}
    }
	goto st6;
st6:
	if ( ++p == pe )
		goto _test_eof6;
case 6:
#line 512 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto st6;
		case 32: goto st6;
		case 72: goto st7;
	}
	goto st0;
st7:
	if ( ++p == pe )
		goto _test_eof7;
case 7:
	if ( (*p) == 84 )
		goto st8;
	goto st0;
st8:
	if ( ++p == pe )
		goto _test_eof8;
case 8:
	if ( (*p) == 84 )
		goto st9;
	goto st0;
st9:
	if ( ++p == pe )
		goto _test_eof9;
case 9:
	if ( (*p) == 80 )
		goto st10;
	goto st0;
st10:
	if ( ++p == pe )
		goto _test_eof10;
case 10:
	if ( (*p) == 47 )
		goto st11;
	goto st0;
st11:
	if ( ++p == pe )
		goto _test_eof11;
case 11:
	if ( 48 <= (*p) && (*p) <= 57 )
		goto tr20;
	goto st0;
tr20:
#line 92 "./c_src/request.rl"
	{
        request->vsn_major = 0;
    }
#line 96 "./c_src/request.rl"
	{
        request->vsn_major = request->vsn_major*10 + ((*p)-'0');
    }
	goto st12;
tr22:
#line 96 "./c_src/request.rl"
	{
        request->vsn_major = request->vsn_major*10 + ((*p)-'0');
    }
	goto st12;
st12:
	if ( ++p == pe )
		goto _test_eof12;
case 12:
#line 574 "./c_src/request.c"
	if ( (*p) == 46 )
		goto st13;
	if ( 48 <= (*p) && (*p) <= 57 )
		goto tr22;
	goto st0;
st13:
	if ( ++p == pe )
		goto _test_eof13;
case 13:
	if ( 48 <= (*p) && (*p) <= 57 )
		goto tr23;
	goto st0;
tr23:
#line 100 "./c_src/request.rl"
	{
        request->vsn_minor = 0;
    }
#line 104 "./c_src/request.rl"
	{
        request->vsn_minor = request->vsn_minor*10 + ((*p)-'0');
    }
	goto st14;
tr26:
#line 104 "./c_src/request.rl"
	{
        request->vsn_minor = request->vsn_minor*10 + ((*p)-'0');
    }
	goto st14;
st14:
	if ( ++p == pe )
		goto _test_eof14;
case 14:
#line 607 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto st15;
		case 13: goto st16;
		case 32: goto st15;
	}
	if ( 48 <= (*p) && (*p) <= 57 )
		goto tr26;
	goto st0;
st15:
	if ( ++p == pe )
		goto _test_eof15;
case 15:
	switch( (*p) ) {
		case 9: goto st15;
		case 13: goto st16;
		case 32: goto st15;
	}
	goto st0;
st16:
	if ( ++p == pe )
		goto _test_eof16;
case 16:
	if ( (*p) == 10 )
		goto st17;
	goto st0;
tr38:
#line 134 "./c_src/request.rl"
	{
        if(*p == ' ' || *p == '\t')
        {
            request->continued = 1;
            p--;
            {goto st20;}
        }
        else if(*p == '\r')
        {
            if(!append_header(request, p)) {p++; cs = 17; goto _out;}
            p--;
            {goto st68;}
        }
        else
        {
            if(!append_header(request, p)) {p++; cs = 17; goto _out;}
            p--;
            {goto st67;}
        }
    }
	goto st17;
st17:
	if ( ++p == pe )
		goto _test_eof17;
case 17:
#line 660 "./c_src/request.c"
	switch( (*p) ) {
		case 13: goto st18;
		case 33: goto tr29;
		case 124: goto tr29;
		case 126: goto tr29;
	}
	if ( (*p) < 45 ) {
		if ( (*p) > 39 ) {
			if ( 42 <= (*p) && (*p) <= 43 )
				goto tr29;
		} else if ( (*p) >= 35 )
			goto tr29;
	} else if ( (*p) > 46 ) {
		if ( (*p) < 65 ) {
			if ( 48 <= (*p) && (*p) <= 57 )
				goto tr29;
		} else if ( (*p) > 90 ) {
			if ( 94 <= (*p) && (*p) <= 122 )
				goto tr29;
		} else
			goto tr29;
	} else
		goto tr29;
	goto st0;
st18:
	if ( ++p == pe )
		goto _test_eof18;
case 18:
	if ( (*p) == 10 )
		goto tr30;
	goto st0;
tr30:
#line 155 "./c_src/request.rl"
	{
        build_version(request);
        {p++; cs = 69; goto _out;}
    }
	goto st69;
st69:
	if ( ++p == pe )
		goto _test_eof69;
case 69:
#line 703 "./c_src/request.c"
	goto st0;
tr29:
#line 108 "./c_src/request.rl"
	{
        assert(request->hdr_name == NULL && "header name already marked");        
        assert(request->genbuf->pos == NULL && "wont overwrite a mark");
        request->genbuf->pos = p;
    }
	goto st19;
st19:
	if ( ++p == pe )
		goto _test_eof19;
case 19:
#line 717 "./c_src/request.c"
	switch( (*p) ) {
		case 33: goto st19;
		case 58: goto tr32;
		case 124: goto st19;
		case 126: goto st19;
	}
	if ( (*p) < 45 ) {
		if ( (*p) > 39 ) {
			if ( 42 <= (*p) && (*p) <= 43 )
				goto st19;
		} else if ( (*p) >= 35 )
			goto st19;
	} else if ( (*p) > 46 ) {
		if ( (*p) < 65 ) {
			if ( 48 <= (*p) && (*p) <= 57 )
				goto st19;
		} else if ( (*p) > 90 ) {
			if ( 94 <= (*p) && (*p) <= 122 )
				goto st19;
		} else
			goto st19;
	} else
		goto st19;
	goto st0;
tr32:
#line 114 "./c_src/request.rl"
	{
        request->hdr_name = buffer_to_string(request->genbuf, p);
        if(request->hdr_name == NULL) {p++; cs = 20; goto _out;}
    }
	goto st20;
st20:
	if ( ++p == pe )
		goto _test_eof20;
case 20:
#line 753 "./c_src/request.c"
	if ( (*p) == 13 )
		goto tr34;
	goto tr33;
tr33:
#line 119 "./c_src/request.rl"
	{
        assert(request->hdr_name != NULL && "value must have a name");
        assert(request->continued ||
                    (request->genbuf->pos == NULL && "wont overwrite a mark"));
        
        if(request->continued)
        {
            request->continued = 1;
        }
        else
        {
            request->genbuf->pos = p;
        }
    }
	goto st21;
st21:
	if ( ++p == pe )
		goto _test_eof21;
case 21:
#line 778 "./c_src/request.c"
	if ( (*p) == 13 )
		goto st22;
	goto st21;
tr34:
#line 119 "./c_src/request.rl"
	{
        assert(request->hdr_name != NULL && "value must have a name");
        assert(request->continued ||
                    (request->genbuf->pos == NULL && "wont overwrite a mark"));
        
        if(request->continued)
        {
            request->continued = 1;
        }
        else
        {
            request->genbuf->pos = p;
        }
    }
	goto st22;
st22:
	if ( ++p == pe )
		goto _test_eof22;
case 22:
#line 803 "./c_src/request.c"
	if ( (*p) == 10 )
		goto st23;
	goto st0;
st23:
	if ( ++p == pe )
		goto _test_eof23;
case 23:
	goto tr38;
tr12:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st24;
st24:
	if ( ++p == pe )
		goto _test_eof24;
case 24:
#line 823 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr39;
		case 32: goto tr39;
		case 37: goto st25;
		case 61: goto st24;
		case 95: goto st24;
	}
	if ( (*p) < 44 ) {
		if ( (*p) > 34 ) {
			if ( 36 <= (*p) && (*p) <= 42 )
				goto st24;
		} else if ( (*p) >= 33 )
			goto st24;
	} else if ( (*p) > 59 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto st24;
		} else if ( (*p) >= 64 )
			goto st24;
	} else
		goto st24;
	goto st0;
tr13:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st25;
st25:
	if ( ++p == pe )
		goto _test_eof25;
case 25:
#line 857 "./c_src/request.c"
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto st26;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto st26;
	} else
		goto st26;
	goto st0;
st26:
	if ( ++p == pe )
		goto _test_eof26;
case 26:
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto st24;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto st24;
	} else
		goto st24;
	goto st0;
tr6:
#line 82 "./c_src/request.rl"
	{
        assert(request->uribuf->pos == NULL && "wont overwrite uri mark");
        request->uribuf->pos = p;
    }
	goto st27;
st27:
	if ( ++p == pe )
		goto _test_eof27;
case 27:
#line 891 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr43;
		case 32: goto tr43;
	}
	goto st0;
tr7:
#line 82 "./c_src/request.rl"
	{
        assert(request->uribuf->pos == NULL && "wont overwrite uri mark");
        request->uribuf->pos = p;
    }
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st28;
st28:
	if ( ++p == pe )
		goto _test_eof28;
case 28:
#line 913 "./c_src/request.c"
	switch( (*p) ) {
		case 43: goto st28;
		case 58: goto tr45;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st28;
	} else if ( (*p) > 57 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto st28;
		} else if ( (*p) >= 65 )
			goto st28;
	} else
		goto st28;
	goto st0;
tr45:
#line 49 "./c_src/request.rl"
	{
        request->scheme = buffer_to_string(request->genbuf, p);
        if(request->scheme == NULL) {p++; cs = 29; goto _out;}
    }
	goto st29;
st29:
	if ( ++p == pe )
		goto _test_eof29;
case 29:
#line 941 "./c_src/request.c"
	if ( (*p) == 47 )
		goto st30;
	goto st0;
st30:
	if ( ++p == pe )
		goto _test_eof30;
case 30:
	if ( (*p) == 47 )
		goto st31;
	goto st0;
st31:
	if ( ++p == pe )
		goto _test_eof31;
case 31:
	switch( (*p) ) {
		case 33: goto tr48;
		case 37: goto tr49;
		case 59: goto tr48;
		case 61: goto tr48;
		case 63: goto tr48;
		case 95: goto tr48;
	}
	if ( (*p) < 48 ) {
		if ( (*p) > 42 ) {
			if ( 44 <= (*p) && (*p) <= 46 )
				goto tr48;
		} else if ( (*p) >= 36 )
			goto tr48;
	} else if ( (*p) > 57 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto tr48;
		} else if ( (*p) >= 65 )
			goto tr48;
	} else
		goto tr48;
	goto st0;
tr48:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st32;
st32:
	if ( ++p == pe )
		goto _test_eof32;
case 32:
#line 990 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr50;
		case 32: goto tr50;
		case 35: goto tr51;
		case 47: goto tr52;
		case 58: goto tr53;
		case 63: goto tr54;
	}
	goto st0;
tr76:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st33;
tr8:
#line 82 "./c_src/request.rl"
	{
        assert(request->uribuf->pos == NULL && "wont overwrite uri mark");
        request->uribuf->pos = p;
    }
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st33;
tr52:
#line 54 "./c_src/request.rl"
	{
        request->host = buffer_to_string(request->genbuf, p);
        if(request->host == NULL) {p++; cs = 33; goto _out;}
    }
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st33;
tr72:
#line 59 "./c_src/request.rl"
	{
        request->port = 0;
    }
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st33;
st33:
	if ( ++p == pe )
		goto _test_eof33;
case 33:
#line 1046 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr55;
		case 32: goto tr55;
		case 35: goto tr57;
		case 37: goto st34;
		case 61: goto st33;
		case 63: goto tr59;
		case 95: goto st33;
	}
	if ( (*p) < 44 ) {
		if ( 33 <= (*p) && (*p) <= 42 )
			goto st33;
	} else if ( (*p) > 59 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto st33;
		} else if ( (*p) >= 64 )
			goto st33;
	} else
		goto st33;
	goto st0;
st34:
	if ( ++p == pe )
		goto _test_eof34;
case 34:
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto st35;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto st35;
	} else
		goto st35;
	goto st0;
st35:
	if ( ++p == pe )
		goto _test_eof35;
case 35:
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto st33;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto st33;
	} else
		goto st33;
	goto st0;
tr9:
#line 82 "./c_src/request.rl"
	{
        assert(request->uribuf->pos == NULL && "wont overwrite uri mark");
        request->uribuf->pos = p;
    }
	goto st36;
tr54:
#line 54 "./c_src/request.rl"
	{
        request->host = buffer_to_string(request->genbuf, p);
        if(request->host == NULL) {p++; cs = 36; goto _out;}
    }
	goto st36;
tr59:
#line 67 "./c_src/request.rl"
	{
        request->path = buffer_to_string(request->genbuf, p);
        if(request->path == NULL) {p++; cs = 36; goto _out;}
    }
	goto st36;
tr74:
#line 59 "./c_src/request.rl"
	{
        request->port = 0;
    }
	goto st36;
st36:
	if ( ++p == pe )
		goto _test_eof36;
case 36:
#line 1125 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr61;
		case 32: goto tr61;
		case 35: goto tr63;
		case 37: goto tr64;
		case 61: goto tr62;
		case 95: goto tr62;
	}
	if ( (*p) < 44 ) {
		if ( 33 <= (*p) && (*p) <= 42 )
			goto tr62;
	} else if ( (*p) > 59 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto tr62;
		} else if ( (*p) >= 64 )
			goto tr62;
	} else
		goto tr62;
	goto st0;
tr62:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st37;
st37:
	if ( ++p == pe )
		goto _test_eof37;
case 37:
#line 1157 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr65;
		case 32: goto tr65;
		case 35: goto tr67;
		case 37: goto st38;
		case 61: goto st37;
		case 95: goto st37;
	}
	if ( (*p) < 44 ) {
		if ( 33 <= (*p) && (*p) <= 42 )
			goto st37;
	} else if ( (*p) > 59 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto st37;
		} else if ( (*p) >= 64 )
			goto st37;
	} else
		goto st37;
	goto st0;
tr64:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st38;
st38:
	if ( ++p == pe )
		goto _test_eof38;
case 38:
#line 1189 "./c_src/request.c"
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto st39;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto st39;
	} else
		goto st39;
	goto st0;
st39:
	if ( ++p == pe )
		goto _test_eof39;
case 39:
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto st37;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto st37;
	} else
		goto st37;
	goto st0;
tr53:
#line 54 "./c_src/request.rl"
	{
        request->host = buffer_to_string(request->genbuf, p);
        if(request->host == NULL) {p++; cs = 40; goto _out;}
    }
	goto st40;
st40:
	if ( ++p == pe )
		goto _test_eof40;
case 40:
#line 1223 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr70;
		case 32: goto tr70;
		case 35: goto tr71;
		case 47: goto tr72;
		case 63: goto tr74;
	}
	if ( 48 <= (*p) && (*p) <= 57 )
		goto tr73;
	goto st0;
tr73:
#line 59 "./c_src/request.rl"
	{
        request->port = 0;
    }
#line 63 "./c_src/request.rl"
	{
        request->port = request->port*10 + ((*p)-'0');
    }
	goto st41;
tr77:
#line 63 "./c_src/request.rl"
	{
        request->port = request->port*10 + ((*p)-'0');
    }
	goto st41;
st41:
	if ( ++p == pe )
		goto _test_eof41;
case 41:
#line 1254 "./c_src/request.c"
	switch( (*p) ) {
		case 9: goto tr43;
		case 32: goto tr43;
		case 35: goto st5;
		case 47: goto tr76;
		case 63: goto st36;
	}
	if ( 48 <= (*p) && (*p) <= 57 )
		goto tr77;
	goto st0;
tr49:
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st42;
st42:
	if ( ++p == pe )
		goto _test_eof42;
case 42:
#line 1276 "./c_src/request.c"
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto st43;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto st43;
	} else
		goto st43;
	goto st0;
st43:
	if ( ++p == pe )
		goto _test_eof43;
case 43:
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto st32;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto st32;
	} else
		goto st32;
	goto st0;
tr10:
#line 82 "./c_src/request.rl"
	{
        assert(request->uribuf->pos == NULL && "wont overwrite uri mark");
        request->uribuf->pos = p;
    }
#line 39 "./c_src/request.rl"
	{
        assert(request->genbuf->pos == NULL && "won't overwrite a mark.");
        request->genbuf->pos = p;
    }
	goto st44;
st44:
	if ( ++p == pe )
		goto _test_eof44;
case 44:
#line 1315 "./c_src/request.c"
	switch( (*p) ) {
		case 43: goto st28;
		case 58: goto tr45;
		case 84: goto st45;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st28;
	} else if ( (*p) > 57 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto st28;
		} else if ( (*p) >= 65 )
			goto st28;
	} else
		goto st28;
	goto st0;
st45:
	if ( ++p == pe )
		goto _test_eof45;
case 45:
	switch( (*p) ) {
		case 43: goto st28;
		case 58: goto tr45;
		case 84: goto st46;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st28;
	} else if ( (*p) > 57 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto st28;
		} else if ( (*p) >= 65 )
			goto st28;
	} else
		goto st28;
	goto st0;
st46:
	if ( ++p == pe )
		goto _test_eof46;
case 46:
	switch( (*p) ) {
		case 43: goto st28;
		case 58: goto tr45;
		case 80: goto st47;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st28;
	} else if ( (*p) > 57 ) {
		if ( (*p) > 90 ) {
			if ( 97 <= (*p) && (*p) <= 122 )
				goto st28;
		} else if ( (*p) >= 65 )
			goto st28;
	} else
		goto st28;
	goto st0;
st47:
	if ( ++p == pe )
		goto _test_eof47;
case 47:
	switch( (*p) ) {
		case 43: goto st28;
		case 47: goto st11;
		case 58: goto tr45;
	}
	if ( (*p) < 65 ) {
		if ( 45 <= (*p) && (*p) <= 57 )
			goto st28;
	} else if ( (*p) > 90 ) {
		if ( 97 <= (*p) && (*p) <= 122 )
			goto st28;
	} else
		goto st28;
	goto st0;
st48:
	if ( ++p == pe )
		goto _test_eof48;
case 48:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st49;
		case 95: goto st49;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st49;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st49;
	} else
		goto st49;
	goto st0;
st49:
	if ( ++p == pe )
		goto _test_eof49;
case 49:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st50;
		case 95: goto st50;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st50;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st50;
	} else
		goto st50;
	goto st0;
st50:
	if ( ++p == pe )
		goto _test_eof50;
case 50:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st51;
		case 95: goto st51;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st51;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st51;
	} else
		goto st51;
	goto st0;
st51:
	if ( ++p == pe )
		goto _test_eof51;
case 51:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st52;
		case 95: goto st52;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st52;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st52;
	} else
		goto st52;
	goto st0;
st52:
	if ( ++p == pe )
		goto _test_eof52;
case 52:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st53;
		case 95: goto st53;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st53;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st53;
	} else
		goto st53;
	goto st0;
st53:
	if ( ++p == pe )
		goto _test_eof53;
case 53:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st54;
		case 95: goto st54;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st54;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st54;
	} else
		goto st54;
	goto st0;
st54:
	if ( ++p == pe )
		goto _test_eof54;
case 54:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st55;
		case 95: goto st55;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st55;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st55;
	} else
		goto st55;
	goto st0;
st55:
	if ( ++p == pe )
		goto _test_eof55;
case 55:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st56;
		case 95: goto st56;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st56;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st56;
	} else
		goto st56;
	goto st0;
st56:
	if ( ++p == pe )
		goto _test_eof56;
case 56:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st57;
		case 95: goto st57;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st57;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st57;
	} else
		goto st57;
	goto st0;
st57:
	if ( ++p == pe )
		goto _test_eof57;
case 57:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st58;
		case 95: goto st58;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st58;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st58;
	} else
		goto st58;
	goto st0;
st58:
	if ( ++p == pe )
		goto _test_eof58;
case 58:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st59;
		case 95: goto st59;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st59;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st59;
	} else
		goto st59;
	goto st0;
st59:
	if ( ++p == pe )
		goto _test_eof59;
case 59:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st60;
		case 95: goto st60;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st60;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st60;
	} else
		goto st60;
	goto st0;
st60:
	if ( ++p == pe )
		goto _test_eof60;
case 60:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st61;
		case 95: goto st61;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st61;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st61;
	} else
		goto st61;
	goto st0;
st61:
	if ( ++p == pe )
		goto _test_eof61;
case 61:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st62;
		case 95: goto st62;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st62;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st62;
	} else
		goto st62;
	goto st0;
st62:
	if ( ++p == pe )
		goto _test_eof62;
case 62:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st63;
		case 95: goto st63;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st63;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st63;
	} else
		goto st63;
	goto st0;
st63:
	if ( ++p == pe )
		goto _test_eof63;
case 63:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st64;
		case 95: goto st64;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st64;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st64;
	} else
		goto st64;
	goto st0;
st64:
	if ( ++p == pe )
		goto _test_eof64;
case 64:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st65;
		case 95: goto st65;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st65;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st65;
	} else
		goto st65;
	goto st0;
st65:
	if ( ++p == pe )
		goto _test_eof65;
case 65:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
		case 36: goto st66;
		case 95: goto st66;
	}
	if ( (*p) < 48 ) {
		if ( 45 <= (*p) && (*p) <= 46 )
			goto st66;
	} else if ( (*p) > 57 ) {
		if ( 65 <= (*p) && (*p) <= 90 )
			goto st66;
	} else
		goto st66;
	goto st0;
st66:
	if ( ++p == pe )
		goto _test_eof66;
case 66:
	switch( (*p) ) {
		case 9: goto tr2;
		case 32: goto tr2;
	}
	goto st0;
st67:
	if ( ++p == pe )
		goto _test_eof67;
case 67:
	switch( (*p) ) {
		case 33: goto tr29;
		case 124: goto tr29;
		case 126: goto tr29;
	}
	if ( (*p) < 45 ) {
		if ( (*p) > 39 ) {
			if ( 42 <= (*p) && (*p) <= 43 )
				goto tr29;
		} else if ( (*p) >= 35 )
			goto tr29;
	} else if ( (*p) > 46 ) {
		if ( (*p) < 65 ) {
			if ( 48 <= (*p) && (*p) <= 57 )
				goto tr29;
		} else if ( (*p) > 90 ) {
			if ( 94 <= (*p) && (*p) <= 122 )
				goto tr29;
		} else
			goto tr29;
	} else
		goto tr29;
	goto st0;
st68:
	if ( ++p == pe )
		goto _test_eof68;
case 68:
	if ( (*p) == 13 )
		goto st18;
	goto st0;
	}
	_test_eof2: cs = 2; goto _test_eof; 
	_test_eof3: cs = 3; goto _test_eof; 
	_test_eof4: cs = 4; goto _test_eof; 
	_test_eof5: cs = 5; goto _test_eof; 
	_test_eof6: cs = 6; goto _test_eof; 
	_test_eof7: cs = 7; goto _test_eof; 
	_test_eof8: cs = 8; goto _test_eof; 
	_test_eof9: cs = 9; goto _test_eof; 
	_test_eof10: cs = 10; goto _test_eof; 
	_test_eof11: cs = 11; goto _test_eof; 
	_test_eof12: cs = 12; goto _test_eof; 
	_test_eof13: cs = 13; goto _test_eof; 
	_test_eof14: cs = 14; goto _test_eof; 
	_test_eof15: cs = 15; goto _test_eof; 
	_test_eof16: cs = 16; goto _test_eof; 
	_test_eof17: cs = 17; goto _test_eof; 
	_test_eof18: cs = 18; goto _test_eof; 
	_test_eof69: cs = 69; goto _test_eof; 
	_test_eof19: cs = 19; goto _test_eof; 
	_test_eof20: cs = 20; goto _test_eof; 
	_test_eof21: cs = 21; goto _test_eof; 
	_test_eof22: cs = 22; goto _test_eof; 
	_test_eof23: cs = 23; goto _test_eof; 
	_test_eof24: cs = 24; goto _test_eof; 
	_test_eof25: cs = 25; goto _test_eof; 
	_test_eof26: cs = 26; goto _test_eof; 
	_test_eof27: cs = 27; goto _test_eof; 
	_test_eof28: cs = 28; goto _test_eof; 
	_test_eof29: cs = 29; goto _test_eof; 
	_test_eof30: cs = 30; goto _test_eof; 
	_test_eof31: cs = 31; goto _test_eof; 
	_test_eof32: cs = 32; goto _test_eof; 
	_test_eof33: cs = 33; goto _test_eof; 
	_test_eof34: cs = 34; goto _test_eof; 
	_test_eof35: cs = 35; goto _test_eof; 
	_test_eof36: cs = 36; goto _test_eof; 
	_test_eof37: cs = 37; goto _test_eof; 
	_test_eof38: cs = 38; goto _test_eof; 
	_test_eof39: cs = 39; goto _test_eof; 
	_test_eof40: cs = 40; goto _test_eof; 
	_test_eof41: cs = 41; goto _test_eof; 
	_test_eof42: cs = 42; goto _test_eof; 
	_test_eof43: cs = 43; goto _test_eof; 
	_test_eof44: cs = 44; goto _test_eof; 
	_test_eof45: cs = 45; goto _test_eof; 
	_test_eof46: cs = 46; goto _test_eof; 
	_test_eof47: cs = 47; goto _test_eof; 
	_test_eof48: cs = 48; goto _test_eof; 
	_test_eof49: cs = 49; goto _test_eof; 
	_test_eof50: cs = 50; goto _test_eof; 
	_test_eof51: cs = 51; goto _test_eof; 
	_test_eof52: cs = 52; goto _test_eof; 
	_test_eof53: cs = 53; goto _test_eof; 
	_test_eof54: cs = 54; goto _test_eof; 
	_test_eof55: cs = 55; goto _test_eof; 
	_test_eof56: cs = 56; goto _test_eof; 
	_test_eof57: cs = 57; goto _test_eof; 
	_test_eof58: cs = 58; goto _test_eof; 
	_test_eof59: cs = 59; goto _test_eof; 
	_test_eof60: cs = 60; goto _test_eof; 
	_test_eof61: cs = 61; goto _test_eof; 
	_test_eof62: cs = 62; goto _test_eof; 
	_test_eof63: cs = 63; goto _test_eof; 
	_test_eof64: cs = 64; goto _test_eof; 
	_test_eof65: cs = 65; goto _test_eof; 
	_test_eof66: cs = 66; goto _test_eof; 
	_test_eof67: cs = 67; goto _test_eof; 
	_test_eof68: cs = 68; goto _test_eof; 

	_test_eof: {}
	_out: {}
	}

#line 329 "./c_src/request.rl"

        if(PyErr_Occurred())
        {
            return -1;
        }

        request->cs = cs;
        request->nread += p - buffer;
        
        if(p < pe) save_chunk(request, p, pe-p);
        
        // Parsing stopped in the middle of a buffer
        // state. Save the current data and prepare
        // for reinitialization.
        
        gensaved = request->genbuf->pos ? 1 : 0;
        if(gensaved) save_buffer(request->genbuf, p);
        
        urisaved = request->uribuf->pos ? 1 : 0;
        if(urisaved) save_buffer(request->uribuf, p);

    } while(cs != http_req_parser_error && cs < http_req_parser_first_final);

    if(cs == http_req_parser_error)
    {
        if(!PyErr_Occurred())
        {
            // MAKE MOAR BUTTAH
            PyErr_SetString(PyExc_ValueError, "Failed to parse data stream.");
            return -1;
        }
    }

    return 1;
}
Пример #8
0
int main(int argc, char *argv[])
{
	slx_error_t err = SLX_OK;
    int connfd = 0;
    char recvBuff[1025];
	char sendBuff[1025];
    struct sockaddr_in serv_addr;
	unsigned char *buff_send = NULL;

    memset(recvBuff, '\0',sizeof(recvBuff));
	memset(sendBuff, '\0',sizeof(sendBuff));
    memset(&serv_addr, '0', sizeof(serv_addr));	
	strcpy(sendBuff, clientTestMessage);
	
	SLX_log_information_init();
	SLX_INFO_NOTICE("Begin - %s ver. %s", SLX_PROGNAME_CLIENT, build_version());
	
    if((connfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    {
		err = SLX_SET_ERRNO(errno);
		SLX_ERROR_DONE(err, "Unable to create client socket, socket: %d", connfd);
    } 

	SLX_INFO_NOTICE_LOG("Client socket created, socket: %d", connfd);
	 
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_port = htons(g_port); 

    if((err = inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr)) <= 0)
    {
		if (err == 0)
		{
			err = SLX_INET_PTON_ERR;
			SLX_ERROR_DONE(err, "inet_pton - src does not contain a character string representing a valid network address in the specified address family");
		}
		else
		{
			err = SLX_SET_ERRNO(errno);
			SLX_ERROR_DONE(err, "Client inet_pton error occurred, cannot convert IPv4 and IPv6 addresses");
		}
    } 
	
	SLX_INFO_NOTICE_LOG("Client inet_pton convert IPv4/IPv6");

    if(connect(connfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
    {
		err = SLX_SET_ERRNO(errno);
		SLX_ERROR_DONE(err, "Client connect failed");	   
    }
	
	SLX_INFO_NOTICE("Client connect successfully");

	//prepare data to send
	slx_req_header_t header;
	slx_req_echo_t echo;
	
	memset(&echo, '\0',sizeof(slx_req_echo_t));
	memset(&header, '\0',sizeof(slx_req_header_t));
	
	header.message_code = SLX_ECHO;
	header.status = SLX_OK;
	strcpy(echo.echo_req_text, clientTestMessage);
	
	buff_send = malloc(sizeof(slx_req_header_t) + sizeof(slx_req_echo_t));
	memcpy(buff_send, &header, sizeof(slx_req_header_t));
	memcpy(buff_send + sizeof(slx_req_header_t), &echo, sizeof(slx_req_echo_t));
	
    while(1)
    {
        //if(send(connfd, sendBuff, strlen(sendBuff), 0) < 0)
		if(send(connfd, buff_send, sizeof(slx_req_header_t) + sizeof(slx_req_echo_t), 0) < 0)
        {
			err = SLX_SET_ERRNO(errno);
			SLX_ERROR_DONE(err, "Unable to send data to server");
        }
         
		SLX_INFO_NOTICE_LOG("Data sended to server successfully");

        if( recv(connfd, recvBuff, 1025, 0) < 0)
        {
			err = SLX_SET_ERRNO(errno);
			SLX_ERROR_DONE(err, "Unable to receive respond from server");
        }
		
		//decode message
		slx_res_header_t header_res;
		
		memcpy(&header_res, &recvBuff, sizeof(slx_req_header_t));
		SLX_INFO_NOTICE("header.message_code\t%d", header_res.message_code);
		SLX_INFO_NOTICE("header.status      \t%d", header_res.status);
		
		if (header_res.message_code == SLX_ECHO)
		{
			slx_replay_echo_t echo_res;
			memset(&echo_res, '\0',sizeof(slx_req_echo_t));
			memcpy(&echo_res, *(&recvBuff) + sizeof(slx_res_header_t), sizeof(slx_replay_echo_t));
			
			SLX_INFO_NOTICE("echo_res.echo_replay_text \t\"%s\"", echo_res.echo_replay_text);
		}
		else
			SLX_ERROR_DONE(err, "Unable to determine message header");	
		
        SLX_INFO_NOTICE_LOG("Server reply : \"%s\"", sendBuff);
		break;
    }
	
done:
	close(connfd);
	if (SLX_IS_ERROR(err))
		SLX_INFO_ERROR_CODE(err, "Error occurred during connection.");
	SLX_INFO_NOTICE("End - Client BackMM", 0);
	
	return 0;
}
Пример #9
0
int
main(int argc, char *argv[])
{
   uid_t         uid, euid;
   int           portarg = 0,  fd;
#ifdef SAVE_MAXCLIENT_STATS
   FILE 	*mcsfp;
#endif

   memset(&me, 0, sizeof(aClient));
	
   if ((timeofday = time(NULL)) == -1) 
   {
      (void) fprintf(stderr, "ERROR: Clock Failure (%d)\n", errno);
      exit(errno);
   }
	
   build_version();
	
   Count.server = 1;		/* us */
   Count.oper = 0;
   Count.chan = 0;
   Count.local = 0;
   Count.total = 0;
   Count.invisi = 0;
   Count.unknown = 0;
   Count.max_loc = 0;
   Count.max_tot = 0;
   Count.today = 0;
   Count.weekly = 0;
   Count.monthly = 0;
   Count.yearly = 0;
   Count.start = NOW;
   Count.day = NOW;
   Count.week = NOW;
   Count.month = NOW;
   Count.year = NOW;

#ifdef SAVE_MAXCLIENT_STATS
	mcsfp=fopen(DPATH "/.maxclients", "r");
	if(mcsfp!=NULL) {
		fscanf(mcsfp, "%d %d %li %li %li %ld %ld %ld %ld", &Count.max_loc, 
			&Count.max_tot, &Count.weekly, &Count.monthly, &Count.yearly, 
			&Count.start, &Count.week, &Count.month, &Count.year);
		fclose(mcsfp);
	}
#endif
	

	
   /*
    * this code by [email protected] 
    * it is intended to keep the ircd from being swapped out. BSD
    * swapping criteria do not match the requirements of ircd
    */
	
#ifdef INITIAL_DBUFS
   dbuf_init();			/* set up some dbuf stuff to control paging */
#endif

   sbrk0 = (char *) sbrk((size_t) 0);
   uid = getuid();
   euid = geteuid();
#ifdef	PROFIL
   (void) monstartup(0, etext);
   (void) moncontrol(1);
   (void) signal(SIGUSR1, s_monitor);
#endif
	
   myargv = argv;
   (void) umask(077);		/* better safe than sorry --SRB  */
   memset((char *) &me, '\0', sizeof(me));
	
   setup_signals();
   /*
    * * All command line parameters have the syntax "-fstring"  or "-f
    * string" (e.g. the space is optional). String may  be empty. Flag
    * characters cannot be concatenated (like "-fxyz"), it would
    * conflict with the form "-fstring".
    */
   while (--argc > 0 && (*++argv)[0] == '-') 
   {
	char       *p = argv[0] + 1;
	int         flag = *p++;
		
        if (flag == '\0' || *p == '\0') 
	{
	   if (argc > 1 && argv[1][0] != '-') 
	   {
		p = *++argv;
		argc -= 1;
	   }
	   else
		p = "";
	   }
		
      switch (flag) 
      {
		 case 'a':
			bootopt |= BOOT_AUTODIE;
			break;
		 case 'c':
			bootopt |= BOOT_CONSOLE;
			break;
		 case 'q':
			bootopt |= BOOT_QUICK;
			break;
		 case 'd':
			(void) setuid((uid_t) uid);
			dpath = p;
			break;
		 case 'o':		/* Per user local daemon... */
			(void) setuid((uid_t) uid);
			bootopt |= BOOT_OPER;
			break;
#ifdef CMDLINE_CONFIG
		 case 'f':
			(void) setuid((uid_t) uid);
			configfile = p;
			break;
			
# ifdef KPATH
		 case 'k':
			(void) setuid((uid_t) uid);
			klinefile = p;
			break;
# endif
			
#endif
		 case 'h':
			strncpyzt(me.name, p, sizeof(me.name));
			break;
		 case 'i':
			bootopt |= BOOT_INETD | BOOT_AUTODIE;
			break;
		 case 'p':
			if ((portarg = atoi(p)) > 0)
			  portnum = portarg;
			break;
		 case 's':
			bootopt |= BOOT_STDERR;
			break;
		 case 't':
			(void) setuid((uid_t) uid);
			bootopt |= BOOT_TTY;
			break;
		 case 'v':
			(void) printf("ircd %s\n", version);
			exit(0);
		 case 'x':
#ifdef	DEBUGMODE
			(void) setuid((uid_t) uid);
			debuglevel = atoi(p);
			debugmode = *p ? p : "0";
			bootopt |= BOOT_DEBUG;
			break;
#else
			(void) fprintf(stderr,
				"%s: DEBUGMODE must be defined for -x y\n",
								myargv[0]);
			exit(0);
#endif
		 default:
			bad_command();
			break;
      }
   }
	
   if (chdir(dpath)) 
   {
      perror("chdir");
      exit(-1);
   }
   if ((uid != euid) && !euid) 
   {
      (void) fprintf(stderr,
	"ERROR: do not run ircd setuid root. Make it setuid a normal user.\n");
      exit(-1);
   }
	
   if (argc > 0)
	  return bad_command();	/* This should exit out  */
   initialize_ssl();

   motd = (aMotd *) NULL;
   helpfile = (aMotd *) NULL;
   motd_tm = NULL;
#ifdef SHORT_MOTD
   shortmotd = NULL;
#endif
	
   read_motd(MOTD);
   read_help(HELPFILE);
#ifdef SHORT_MOTD
   read_shortmotd(SHORTMOTD);
#endif
	
   clear_client_hash_table();
   clear_channel_hash_table();
   clear_scache_hash_table();	/* server cache name table */
   clear_ip_hash_table();	/* client host ip hash table */

   initlists();
   initclass();
   initwhowas();
   initstats();
   init_tree_parse(msgtab);
   init_send();
   NOW = time(NULL);
   open_debugfile();
   NOW = time(NULL);
   init_fdlist(&serv_fdlist);
   init_fdlist(&oper_fdlist);
   init_fdlist(&listen_fdlist);
	
#ifndef NO_PRIORITY
   init_fdlist(&busycli_fdlist);
#endif
	
   init_fdlist(&default_fdlist);
	  {
		  int i;
		  
		  for (i = MAXCONNECTIONS + 1; i > 0; i--) 
		  {
			  default_fdlist.entry[i] = i - 1;
		  }
	  }

   if ((timeofday = time(NULL)) == -1) 
   {
#ifdef USE_SYSLOG
      syslog(LOG_WARNING, "Clock Failure (%d), TS can be corrupted", errno);
#endif
      sendto_ops("Clock Failure (%d), TS can be corrupted", errno);
   }

#ifdef WINGATE_NOTICE
   strcpy(ProxyMonURL, "http://");
   strncpyzt((ProxyMonURL + 7), DEFAULT_PROXY_INFO_URL, (TOPICLEN + 1) - 7);
   strncpyzt(ProxyMonHost, MONITOR_HOST, (HOSTLEN + 1));
#endif
	
   if (portnum < 0)
	  portnum = PORTNUM;
   me.port = portnum;
   (void) init_sys();
   me.flags = FLAGS_LISTEN;
#ifndef _WIN32
   if (bootopt & BOOT_INETD) 
   {
      me.fd = 0;
      local[0] = &me;
      me.flags = FLAGS_LISTEN;
   }
   else
#endif
	  me.fd = -1;
	
#ifdef USE_SYSLOG
# define SYSLOG_ME     "ircd"
   openlog(SYSLOG_ME, LOG_PID | LOG_NDELAY, LOG_FACILITY);
#endif
   if ((fd = openconf(configfile)) == -1) 
   {
      Debug((DEBUG_FATAL, "Failed in reading configuration file %s",
				 configfile));
      (void) printf("Couldn't open configuration file %s\n",
						  configfile);
      exit(-1);
   }
   (void) initconf(bootopt, fd);
	
   /* comstuds SEPARATE_QUOTE_KLINES_BY_DATE code */
#ifdef SEPARATE_QUOTE_KLINES_BY_DATE
	  {
		  struct tm  *tmptr;
		  char        timebuffer[20], filename[200];
		  
		  tmptr = localtime(&NOW);
		  (void) strftime(timebuffer, 20, "%y%m%d", tmptr);
		  ircsprintf(filename, "%s.%s", klinefile, timebuffer);
		  if ((fd = openconf(filename)) == -1) 
		  {
			  Debug((DEBUG_ERROR, "Failed reading kline file %s",
						filename));
			  (void) printf("Couldn't open kline file %s\n",
								 filename);
		  }
		  else
			 (void) initconf(0, fd);
	  }
#else
# ifdef KPATH
   if ((fd = openconf(klinefile)) == -1) 
   {
      Debug((DEBUG_ERROR, "Failed reading kline file %s", klinefile));
      (void) printf("Couldn't open kline file %s\n", klinefile);
   }
   else
	  (void) initconf(0, fd);
# endif
#endif
   if (!(bootopt & BOOT_INETD)) 
   {
		static char star[] = "*";
		aConfItem  *aconf;
		u_long      vaddr;
		
      if ((aconf = find_me()) && portarg <= 0 && aconf->port > 0)
		  portnum = aconf->port;

      Debug((DEBUG_ERROR, "Port = %d", portnum));

      if ((aconf->passwd[0] != '\0') && (aconf->passwd[0] != '*'))
		  vaddr = inet_addr(aconf->passwd);
      else
		  vaddr = (u_long) NULL;
		
      if (inetport(&me, star, portnum, vaddr)) 
      {
			if (bootopt & BOOT_STDERR)
			  fprintf(stderr, "Couldn't bind to primary port %d\n", portnum);
#ifdef USE_SYSLOG
			(void) syslog(LOG_CRIT, "Couldn't bind to primary port %d\n", portnum);
#endif
			exit(1);
      }
   }
   else if (inetport(&me, "*", 0, 0)) 
   {
      if (bootopt & BOOT_STDERR)
		  fprintf(stderr, "Couldn't bind to port passed from inetd\n");
#ifdef USE_SYSLOG
      (void) syslog(LOG_CRIT, "Couldn't bind to port passed from inetd\n");
#endif
      exit(1);
   }
	
   (void) get_my_name(&me, me.sockhost, sizeof(me.sockhost) - 1);
   if (me.name[0] == '\0')
	  strncpyzt(me.name, me.sockhost, sizeof(me.name));
   me.hopcount = 0;
   me.authfd = -1;
   me.confs = NULL;
   me.next = NULL;
   me.user = NULL;
   me.from = &me;
   SetMe(&me);
   make_server(&me);
   me.serv->up = me.name;
   me.lasttime = me.since = me.firsttime = NOW;
   (void) add_to_client_hash_table(me.name, &me);
	
   /* We don't want to calculate these every time they are used :) */
	
   sprintf(REPORT_DO_DNS, REPORT_DO_DNS_, me.name);
   sprintf(REPORT_FIN_DNS, REPORT_FIN_DNS_, me.name);
   sprintf(REPORT_FIN_DNSC, REPORT_FIN_DNSC_, me.name);
   sprintf(REPORT_FAIL_DNS, REPORT_FAIL_DNS_, me.name);
   sprintf(REPORT_DO_ID, REPORT_DO_ID_, me.name);
   sprintf(REPORT_FIN_ID, REPORT_FIN_ID_, me.name);
   sprintf(REPORT_FAIL_ID, REPORT_FAIL_ID_, me.name);
   R_do_dns = strlen(REPORT_DO_DNS);
   R_fin_dns = strlen(REPORT_FIN_DNS);
   R_fin_dnsc = strlen(REPORT_FIN_DNSC);
   R_fail_dns = strlen(REPORT_FAIL_DNS);
   R_do_id = strlen(REPORT_DO_ID);
   R_fin_id = strlen(REPORT_FIN_ID);
   R_fail_id = strlen(REPORT_FAIL_ID);
	
   check_class();
   if (bootopt & BOOT_OPER) 
   {
      aClient    *tmp = add_connection(&me, 0);
		
      if (!tmp)
		  exit(1);
      SetMaster(tmp);
   }
   else
	  write_pidfile();
	
   Debug((DEBUG_NOTICE, "Server ready..."));
#ifdef USE_SYSLOG
   syslog(LOG_NOTICE, "Server Ready");
#endif
   NOW = time(NULL);
	
#ifndef NO_PRIORITY
   check_fdlists();
#endif
	
   if ((timeofday = time(NULL)) == -1) 
   {
#ifdef USE_SYSLOG
      syslog(LOG_WARNING, "Clock Failure (%d), TS can be corrupted", errno);
#endif
      sendto_ops("Clock Failure (%d), TS can be corrupted", errno);
   }

#ifdef DUMP_DEBUG
   dumpfp=fopen("dump.log", "w");
#endif

   io_loop();
   return 0;
}
Пример #10
0
int
main (int argc, char *argv[])
{
  /* Check to see if the user is running
   * us as root, which is a nono
   */
  if (geteuid () == 0)
    {
      fprintf (stderr, "Don't run ircd as root!!!\n");
      return (-1);
    }

  /* save server boot time right away, so getrusage works correctly */
  set_time ();

  /* Setup corefile size immediately after boot -kre */
  setup_corefile ();

  /* set initialVMTop before we allocate any memory */
  initialVMTop = get_vm_top ();

  ServerRunning = 0;

  /* It ain't random, but it ought to be a little harder to guess */
  srand (SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid () << 20)));
  memset (&me, 0, sizeof (me));
  memset (&meLocalUser, 0, sizeof (meLocalUser));
  me.localClient = &meLocalUser;
  dlinkAdd (&me, &me.node, &global_client_list);	/* Pointer to beginning
							   of Client list */

  memset (&ServerInfo, 0, sizeof (ServerInfo));

  /* Initialise the channel capability usage counts... */
  init_chcap_usage_counts ();

  ConfigFileEntry.dpath = DPATH;
  ConfigFileEntry.configfile = CPATH;	/* Server configuration file */
  ConfigFileEntry.klinefile = KPATH;	/* Server kline file         */
  ConfigFileEntry.xlinefile = XPATH;	/* Server xline file         */
  ConfigFileEntry.dlinefile = DLPATH;	/* dline file                */
  ConfigFileEntry.cresvfile = CRESVPATH;	/* channel resv file      */
  ConfigFileEntry.nresvfile = NRESVPATH;	/* nick resv file         */
  myargv = argv;
  umask (077);			/* better safe than sorry --SRB */

  parseargs (&argc, &argv, myopts);

  build_version ();

  if (printVersion)
    {
      printf ("ircd: version %s\n", ircd_version);
      exit (EXIT_SUCCESS);
    }

  if (chdir (ConfigFileEntry.dpath))
    {
      perror ("chdir");
      exit (EXIT_FAILURE);
    }

  if (!server_state.foreground)
    make_daemon ();
  else
    print_startup (getpid ());

#ifdef HAVE_LIBCRYPTO
  dh_init();
  fprintf(stderr, "SSL: Initialize\n");

  SSL_load_error_strings();
  SSLeay_add_ssl_algorithms();
  ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method());

  if (!ServerInfo.ctx) {
       ERR_print_errors_fp(stderr);
       return 0;
  }

  fprintf(stderr, "SSL: Client based SSL connections are enabled.\n");
#endif

  setup_signals ();
  /* We need this to initialise the fd array before anything else */
  fdlist_init ();

  if (!server_state.foreground)
    close_all_connections ();	/* this needs to be before init_netio()! */
  else
    check_can_use_v6 ();	/* Done in close_all_connections normally */

  init_log (logFileName);
  init_netio ();		/* This needs to be setup early ! -- adrian */
  /* Check if there is pidfile and daemon already running */
  check_pidfile (pidFileName);
  /* Init the event subsystem */
  eventInit ();
  init_sys ();

#ifndef NOBALLOC
  initBlockHeap ();
#endif
  init_dlink_nodes ();
  init_slink_nodes ();
  initialize_message_files ();
  dbuf_init ();
  init_hash ();
  init_ip_hash_table ();	/* client host ip hash table */
  init_host_hash ();		/* Host-hashtable. */
  clear_hash_parse ();
  init_client ();
  init_user ();
  init_channels ();
  init_class ();
  init_whowas ();
  init_stats ();
  init_hooks ();
  read_conf_files (1);		/* cold start init conf files */
  initServerMask ();
  init_uid ();
  init_auth ();			/* Initialise the auth code */
  init_resolver ();		/* Needs to be setup before the io loop */
  init_reject ();               /* Set up the reject code. */
  init_umodes ();               /* Set up the usermode system. */

  initialize_foundation_signals(); /* register things that modules need */

#ifdef HAVE_LIBCRYPTO
  bio_spare_fd = save_spare_fd ("SSL private key validation");
#endif /* HAVE_LIBCRYPTO */

  initialize_server_capabs ();	/* Set up default_server_capabs */
  initialize_global_set_options ();

  if (ServerInfo.name == NULL)
    {
      fprintf (stderr,
	       "ERROR: No server name specified in serverinfo block.\n");
      ilog (L_CRIT, "No server name specified in serverinfo block.");
      exit (EXIT_FAILURE);
    }
  strlcpy (me.name, ServerInfo.name, sizeof (me.name));

  /* serverinfo{} description must exist.  If not, error out. */
  if (ServerInfo.description == NULL)
    {
      fprintf (stderr,
	       "ERROR: No server description specified in serverinfo block.\n");
      ilog (L_CRIT,
	    "ERROR: No server description specified in serverinfo block.");
      exit (EXIT_FAILURE);
    }
  strlcpy (me.info, ServerInfo.description, sizeof (me.info));

  me.from = &me;
  me.servptr = &me;

  SetMe (&me);
  make_server (&me);

  strlcpy (me.serv->up, me.name, sizeof (me.serv->up));
  me.lasttime = me.since = me.firsttime = CurrentTime;
  hash_add_client (&me);

  /* add ourselves to global_serv_list */
  dlinkAdd (&me, make_dlink_node (), &global_serv_list);

  check_class ();

#ifndef STATIC_MODULES
  if (chdir (MODPATH))
    {
      ilog (L_CRIT, "Could not load core modules. Terminating!");
      exit (EXIT_FAILURE);
    }
  mod_set_base ();
  load_all_modules (1);
  load_core_modules (1);
  /* Go back to DPATH after checking to see if we can chdir to MODPATH */
  chdir (ConfigFileEntry.dpath);
#else
  load_all_modules (1);
#endif

  write_pidfile (pidFileName);

  ilog (L_NOTICE, "Server Ready");

  eventAddIsh ("cleanup_tklines", cleanup_tklines, NULL,
	       CLEANUP_TKLINES_TIME);

  /* We want try_connections to be called as soon as possible now! -- adrian */
  /* No, 'cause after a restart it would cause all sorts of nick collides */
  eventAddIsh ("try_connections", try_connections, NULL,
	       STARTUP_CONNECTIONS_TIME);

  eventAddIsh ("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);

  /* Setup the timeout check. I'll shift it later :)  -- adrian */
  eventAddIsh ("comm_checktimeouts", comm_checktimeouts, NULL, 1);

  if (splitmode)
    eventAddIsh ("check_splitmode", check_splitmode, NULL, 60);

  ServerRunning = 1;
  io_loop ();
  return (0);
}