Search
lxdream.org :: lxdream/src/util.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/util.c
changeset 17:944f75eea496
next31:495e480360d7
author nkeynes
date Tue Dec 13 14:47:59 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change More work on load/save state - save state a little more structured now
Memory save now in
view annotate diff log raw
     1 #include "dream.h"
     2 #include "modules.h"
     4 void fwrite_string( char *s, FILE *f )
     5 {
     6     uint32_t len = 0;
     7     if( s == NULL ) {
     8 	fwrite( &len, sizeof(len), 1, f );
     9     } else {
    10 	len = strlen(s)+1;
    11 	fwrite( &len, sizeof(len), 1, f );
    12 	fwrite( s, len, 1, f );
    13     }
    14 }
    16 int fread_string( char *s, int maxlen, FILE *f ) 
    17 {
    18     uint32_t len;
    19     fread( &len, sizeof(len), 1, f );
    20     if( len != 0 ) {
    21 	fread( s, len > maxlen ? maxlen : len, 1, f );
    22     }
    23     return len;
    24 }
.