Re: [AD] errno killer patch (NICE!) |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Eric Botcazou wrote:
The attached patch removes all occurences of errno in the datedit/plugins
code. It changes the prototype of the 'save' method of plugins to make it
return a value.
--
Eric Botcazou
Outstanding!!!
I was just incountering this problem while porting the allegro packfile
to filters. (as discussed on alleg5 list)
I am at present creating a patch that makes the datafile routines
unaware of the underlying packfile structure ( lot of f->todo references
). This will enable the packfile routines to be ported over to filters
without too much work! Look how tidy pack_fopen becomes with filters
underlying it. (actual working code) I'm hopeing pack_fopen_chunk will
be as nice! I think so but I'm writing that tomorrow.
Garth
/* packfile emulation - How tidy is it with filters!?! :-) */
PACKFILE * pack_fopen (char *filename, const char *mode)
{
struct filter *f;
struct filter *parent;
allegro check to see if file is ok
if( !_al_file_isok(filename))
return NULL;
/* Sort out the parameters */
if( strpbrk( mode, "wW" ) )
{
f = al_filter_file(filename,"w");
if( f == NULL )
{
fprintf(stderr,"filename open(w)
failed:%s",filename);
return NULL;
}
}
else
{
/* Read mode then */
f = al_filter_file(filename,"r");
if( f == NULL )
{
fprintf(stderr,"filename open(r)
failed:%s",filename);
return NULL;
}
}
parent = al_filter_buffer( f, 4096 );
if( parent == NULL )
{
al_filter_close( f );
return NULL;
}
/* doesn't matter if we lose refernce 'cause
* filter_close will close all layers */
f = parent;
#ifdef FILTER_PASSWORD
if( password[0] )
{
/* How cool! Filters Rock */
parent = filter_encrypt(f, ENCRYPT_METHOD_ALLEGV4_NEW,
"password");
if( parent == NULL )
{
filter_close( f );
return NULL;
}
f = parent;
}
#endif/*FILTER_PASSWORD*/
/* Packfile ? */
if( strpbrk(mode, "pP") )
{
/* Read file.c:pack_fopen fo figure out what to write in
* The compression filter
*/
struct filter *parent = al_filter_alcompress( f, 1 );
if( parent == NULL )
{
al_filter_close( f );
return NULL;
}
}
/* compression support (not) */
if( strpbrk(mode, "!") )
{
parent = al_filter_alcompress( f, 0 );
if( parent == NULL )
{
al_filter_close( f );
return NULL;
}
f = parent;
}
return f;
}