bool read_wri_struct (wri_struct *w, GsfInput *f)
{
	int i, size;
	unsigned char *blob;
	bool result;

	// first we need to calculate the size
	i = size = 0;

	while (w[i].name) size += w[i++].size;

	// got the size, read the blob
	blob = static_cast<unsigned char *>(malloc(size));

	if (!blob)
	{
		UT_WARNINGMSG(("read_wri_struct: Out of memory!\n"));
		return false;
	}

	if (!gsf_input_read(f, size, blob))
	{
		UT_WARNINGMSG(("read_wri_struct: File not big enough!\n"));
		return false;
	}

	result = read_wri_struct_mem(w, blob);
	free(blob);

	return result;
}
Пример #2
0
int wri_ole_read (unsigned char */*data*/, int /*size*/, GsfOutput */*fout*/) {
#if 0
   FILE *f; 

    read_wri_struct_mem (write_ole, data);
    dump_wri_struct (write_ole);

    f = fopen ("ole.dump", "wb");
    fwrite (data + 40, 1, wri_struct_value (write_ole, "dwDataSize"), f);
    fclose (f);
#endif
    
    return 0;
}
Пример #3
0
int read_wri_struct (struct wri_struct *cfg, GsfInput *f) {
    int size, i;
    unsigned char *blob;

    /* first we need to calculate the size */
    i = size = 0;
    while (cfg[i].name) size += cfg[i++].size;

    /* got the size, read the blob */
    blob = static_cast<unsigned char*>(malloc (size));
    if (!blob) {
	fprintf (stderr, "Out of memory!\n");
	return 1;
    }
    if (!gsf_input_read(f, size, blob)) {
	fprintf (stderr, "File not big enough!\n");
	return 1;
    }
    
    size = read_wri_struct_mem (cfg, blob);
    free (blob);

    return size;
}