2 * $Id: util.c,v 1.3 2005-12-26 03:54:52 nkeynes Exp $
4 * Miscellaneous utility functions.
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
21 void fwrite_string( char *s, FILE *f )
25 fwrite( &len, sizeof(len), 1, f );
28 fwrite( &len, sizeof(len), 1, f );
29 fwrite( s, len, 1, f );
33 int fread_string( char *s, int maxlen, FILE *f )
36 fread( &len, sizeof(len), 1, f );
38 fread( s, len > maxlen ? maxlen : len, 1, f );
.