src/treesutil.c
/**
 * opens a trees file
 * checks for a valid trees header
 * returns file with position after the header
 */
opens a trees file
checks for a valid trees header
returns file with position after the header
opens a trees file checks for a valid trees header returns file with position after the header
FILE *
open_trees_file(const char *path)
{
    FILE *file;
    size_t ret;
    unsigned char buffer[sizeof TREES_MAGIC];
    file = fopen(path, "r");
    if(file == NULL) {
        die(true, "error opening file: %s", strerror(errno));
    }
    ret = fread(buffer, 1, sizeof TREES_MAGIC, file);
    if(ret != sizeof TREES_MAGIC) {
        die(false, "invalid header");
    }
    if(memcmp(buffer, TREES_MAGIC, sizeof TREES_MAGIC) != 0) {
        die(false, "header does not match expected");
    }
    return file;
}
FILE * open_trees_file ( const char * path ) { FILE * file ; size_t ret ; unsigned char buffer [ sizeof TREES_MAGIC ] ; file = fopen ( path , " " ) ; if ( file == NULL ) { die ( true , " " , strerror ( errno ) ) ; } ret = fread ( buffer , 1 , sizeof TREES_MAGIC , file ) ; if ( ret != sizeof TREES_MAGIC ) { die ( false , " " ) ; } if ( memcmp ( buffer , TREES_MAGIC , sizeof TREES_MAGIC ) != 0 ) { die ( false , " " ) ; } return file ; }
opens a trees file
 checks for a valid trees header
 returns file with position after the header
opens a trees file checks for a valid trees header returns file with position after the header