Re: [AD] Custom packfiles

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> file = pack_fopen_vtable(can_be_any_different_vtable, data);
> pack_fread(file, ...)
> ...
> pack_fclose(file);

Was just thinking some more about if "open" should be in the vtable or not:

If it is, some things can be easier for users:

pack_fopen_vtable(tcp_vtable, "192.168.0.1:1234");
pack_fopen_vtable(gz_vtable, "blah.txt.gz");

Obviously, these examples would pass the 2nd argument as filename to
the open function in the vtable, which then would initialize the
->userdata member of the PACKFILE with its relevant data. Everything
stays simple for the user.

OTOH, the expackf.c can't be done that way, since memory files need
more than a single string argument from the user. The best way
probably would be to modify expackf.c so it has a PACKFILE
*memread_fopen(unsigned char const *address, long length) function.
And addon authors could then provide algz_fopen(...) or
altcpfile_fopen(...) like above - but no vtable entry. I still find it
somehow asssymetric to have no fopen entry though..




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/