X-Git-Url: https://harrygodden.com/git/?p=csRadar.git;a=blobdiff_plain;f=vdf.h;h=fb242d13cd71239d34519ce583e9c2cf05cf0292;hp=892b65d5f304386a0efa532888e14c79398c20ca;hb=8382aed7f0cdc38bc5c58832d4a15277cf56d4be;hpb=1bdd02062cda9b107c4d66586d3c036ea15f6ae2 diff --git a/vdf.h b/vdf.h index 892b65d..fb242d1 100644 --- a/vdf.h +++ b/vdf.h @@ -1,3 +1,11 @@ +// This software is not affiliated with Valve Corporation +// We are not affiliated, associated, authorized, endorsed by, or in any way officially +// connected with Valve Corporation, or any of its subsidiaries or its affiliates. +// +// All trademarks are property of their respective owners + +// VDF aka Keyvalue text format parser / writer + #define vdf_foreach( NODE, STR, AS ) \ int __vdf_it_##AS = 0; \ vdf_node * AS;\ @@ -8,10 +16,6 @@ int __kv_it_##AS = 0; \ const char * AS;\ while( (AS = kv_iter( NODE, STR, &__kv_it_##AS )) ) -#include -#include -#include -#include // TYPES // ================================================================================================================== @@ -63,6 +67,7 @@ void kv_double_array( vdf_node *node, const char *key, u32 count, double *arr ); // INTERNAL API // ================================================================================================================== +#ifdef VALVE_IMPLEMENTATION // Add keyvalue pair to node void vdf_kv_append( vdf_node *p, const char *k, const char *v ); @@ -86,6 +91,8 @@ void vdf_parse_feedbuffer( vdf_ctx *ctx, char *buf ); // Formatting void vdf_out_indent( const int n, FILE *file ); +#endif + // IMPLEMENTATION // ================================================================================================================== @@ -108,6 +115,8 @@ struct vdf_node u32 user1; }; +#ifdef VALVE_IMPLEMENTATION + vdf_node *vdf_next( vdf_node *node, const char *name, int *it ) { if( !node ) @@ -420,7 +429,7 @@ void vdf_parse_string( vdf_ctx *ctx ) if( vdf_line_control( ctx ) ) { - fprintf( stderr, "Unexpected end of line character (Line: %u)\n", ctx->lines ); + log_error( "Unexpected end of line character (Line: %u)\n", ctx->lines ); return; } @@ -434,7 +443,7 @@ int vdf_parse_structure( vdf_ctx *ctx ) { if( ctx->st.tokens[0] || !ctx->st.expect_decl ) { - fprintf( stderr, "Unexpected token '{' (Line: %u)\n", ctx->lines ); + log_error( "Unexpected token '{' (Line: %u)\n", ctx->lines ); ctx->errors ++; } @@ -450,7 +459,7 @@ int vdf_parse_structure( vdf_ctx *ctx ) { if( !ctx->st.pnode->parent ) { - fprintf( stderr, "Unexpected token '}' (Line: %u)\n", ctx->lines ); + log_error( "Unexpected token '}' (Line: %u)\n", ctx->lines ); ctx->errors ++; } else @@ -471,7 +480,7 @@ void vdf_parse_begin_token( vdf_ctx *ctx, char *ptr ) if( ctx->st.expect_decl ) { - fprintf( stderr, "Unexpected token '%s' (Line: %u)\n", ctx->name, ctx->lines ); + log_error( "Unexpected token '%s' (Line: %u)\n", ctx->name, ctx->lines ); ctx->errors ++; } } @@ -543,7 +552,6 @@ int vdf_load_into( const char *fn, vdf_node *node ) if( !text_src ) { - fprintf( stderr, "vdf open failed\n" ); return 0; } @@ -617,3 +625,5 @@ void vdf_print( vdf_node *node ) { vdf_out( node, -1, 0, stdout ); } + +#endif