--- /dev/null
+// Copyright (C) 2021-2023 Harry Godden (hgn) - All Rights Reserved
+
+#define VG_TOOLS
+#include "vg/vg.h"
+#include "vg/vg_msg.h"
+
+#define CHUNK_SIZE 4096
+
+int main( int argc, char *argv[] ){
+ assert(argc);
+
+ if( argc < 2 ){
+ vg_error( "Usage: %s <file>\n", argv[0] );
+ return 0;
+ }
+
+ FILE *f = fopen( argv[1], "rb" );
+ if( !f ){
+ vg_error( "vg_disk_open_read: %s\n", strerror(errno) );
+ }
+
+ void *buffer = NULL;
+ u64 current = 0;
+
+ /* read in chunks */
+ for( u32 i=0; 1; i++ ){
+ buffer = realloc( buffer, current + CHUNK_SIZE );
+ u64 l = fread( buffer + current, 1, CHUNK_SIZE, f );
+ current += l;
+
+ if( l != CHUNK_SIZE ){
+ if( feof( f ) ){
+ break;
+ }
+ else{
+ if( ferror( f ) ){
+ fclose(f);
+ vg_fatal_error( "read error" );
+ }
+ else{
+ fclose(f);
+ vg_fatal_error( "unknown error codition" );
+ }
+ }
+ }
+ }
+
+ fclose( f );
+
+ vg_msg msg;
+ vg_msg_init( &msg, buffer, current );
+ vg_msg_print( &msg, current );
+
+ free( buffer );
+}
SDL_SemWait( vg.sem_loader );
vg.thread_data = data;
- SDL_CreateThread( _vg_loader_thread, "Loader thread", pfn );
+ SDL_CreateThread( _vg_loader_thread, "vg: loader", pfn );
}
/*
printf( "'%s': ", cmd.key );
- if( count > 1 ) printf( "'{' " );
+ if( count > 1 ) printf( "{ " );
for( u32 i=0; i<count; i++ ){
const void *p = cmd.value + size*i;
if( i+1<count ) printf(", ");
}
- if( count > 1 ) printf( "'}'" );
+ if( count > 1 ) printf( " }" );
printf( "\n" );
}
}