Exemplo n.º 1
0
static int socket_error( SGS_CTX )
{
	int astext = 0, e = 0;
	SGSFN( "socket_error" );
	if( !sgs_LoadArgs( C, "|b", &astext ) )
		return 0;
	
	if( sgs_PushGlobal( C, SCKERRVN ) == SGS_SUCCESS )
		e = (int) sgs_GetInt( C, -1 );
	else if( !astext )
		sgs_PushInt( C, 0 );
	
	if( !astext )
		return 1;
	
#ifdef _WIN32
	{
		char buf[ 1024 ];
		DWORD numwr = FormatMessageA
		(
			FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD) e,
			MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
			buf, 1024, NULL
		);
		if( !numwr )
			STDLIB_WARN( "failed to retrieve error message" )
		sgs_PushStringBuf( C, buf, (sgs_SizeVal) numwr );
	}
#else
	sgs_PushString( C, strerror( e ) );
#endif
	return 1;
}
Exemplo n.º 2
0
static int SS_EnableProfiler( SGS_CTX )
{
	SGSFN( "SS_EnableProfiler" );
	if( sgs_StackSize( C ) > 0 )
		GEnabledProfiler = sgs_GetInt( C, 0 );
	else
		GEnabledProfiler = 1;
	return 0;
}