From 0a2550249f9523dca974a79b51b5a7358b5fb943 Mon Sep 17 00:00:00 2001 From: CNLohr Date: Tue, 14 Mar 2017 19:05:46 -0400 Subject: Almost able to build on Windows. --- src/survive.c | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 6d49d55..d786d3d 100755 --- a/src/survive.c +++ b/src/survive.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "survive_config.h" @@ -211,6 +210,40 @@ int survive_poll( struct SurviveContext * ctx ) } +struct SurviveObject * survive_get_so_by_name( struct SurviveContext * ctx, const char * name ) +{ + int i; + for( i = 0; i < ctx->objs_ct; i++ ) + { + if( strcmp( ctx->objs[i]->codename, name ) == 0 ) + return ctx->objs[i]; + } + return 0; +} + +#ifdef NOZLIB + +#include + + +int survive_simple_inflate( struct SurviveContext * ctx, const char * input, int inlen, char * output, int outlen ) +{ + unsigned long ol = outlen; + unsigned long il = inlen; + int ret = puff( output, &ol, input, &il ); + if( ret == 0 ) + return ol; + else + { + SV_INFO( "puff returned error code %d\n", ret ); + return -5; + } +} + +#else + +#include + int survive_simple_inflate( struct SurviveContext * ctx, const char * input, int inlen, char * output, int outlen ) { z_stream zs; //Zlib stream. May only be used by configuration at beginning and by USB thread periodically. @@ -233,14 +266,4 @@ int survive_simple_inflate( struct SurviveContext * ctx, const char * input, int return len; } -struct SurviveObject * survive_get_so_by_name( struct SurviveContext * ctx, const char * name ) -{ - int i; - for( i = 0; i < ctx->objs_ct; i++ ) - { - if( strcmp( ctx->objs[i]->codename, name ) == 0 ) - return ctx->objs[i]; - } - return 0; -} - +#endif \ No newline at end of file -- cgit v1.2.3 From 99b615ba75f24e48b713e9b23ae596d7ddf1c59b Mon Sep 17 00:00:00 2001 From: cnlohr Date: Tue, 14 Mar 2017 21:25:53 -0400 Subject: Handle autoregistration of startup functions. --- src/survive.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index d786d3d..0e567ad 100755 --- a/src/survive.c +++ b/src/survive.c @@ -9,6 +9,23 @@ #include "survive_config.h" +#ifdef RUNTIME_SYMNUM +#include +static int did_runtime_symnum; +int SymnumCheck( const char * path, const char * name, void * location, long size ) +{ + printf( "--->%s\n", name ); + if( strncmp( name, "REGISTER", 8 ) == 0 ) + { + typedef void (*sf)(); + sf fn = (sf)location; + fn(); + } + return 0; +} + +#endif + static void survivefault( struct SurviveContext * ctx, const char * fault ) { fprintf( stderr, "Error: %s\n", fault ); @@ -23,6 +40,10 @@ static void survivenote( struct SurviveContext * ctx, const char * fault ) SurviveContext * survive_init( int headless ) { +#ifdef RUNTIME_SYMNUM + EnumerateSymbols( SymnumCheck ); +#endif + int r = 0; int i = 0; SurviveContext * ctx = calloc( 1, sizeof( SurviveContext ) ); @@ -266,4 +287,4 @@ int survive_simple_inflate( struct SurviveContext * ctx, const char * input, int return len; } -#endif \ No newline at end of file +#endif -- cgit v1.2.3 From e15459cd9efab607e95f720bd971d0e73615f437 Mon Sep 17 00:00:00 2001 From: CNLohr Date: Wed, 15 Mar 2017 00:14:37 -0400 Subject: Getting very close to a Windows port. --- src/survive.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 0e567ad..1b5bed1 100755 --- a/src/survive.c +++ b/src/survive.c @@ -14,7 +14,6 @@ static int did_runtime_symnum; int SymnumCheck( const char * path, const char * name, void * location, long size ) { - printf( "--->%s\n", name ); if( strncmp( name, "REGISTER", 8 ) == 0 ) { typedef void (*sf)(); @@ -41,7 +40,11 @@ static void survivenote( struct SurviveContext * ctx, const char * fault ) SurviveContext * survive_init( int headless ) { #ifdef RUNTIME_SYMNUM - EnumerateSymbols( SymnumCheck ); + if( !did_runtime_symnum ) + { + EnumerateSymbols( SymnumCheck ); + did_runtime_symnum = 1; + } #endif int r = 0; -- cgit v1.2.3