[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Hence my new proposal:
+ Note #1: when reading a packfile (or a sub-chunk of a packfile), you must
+ make sure you set the right password (including none) before opening it;
+ you can change the password to whatever you want afterwards without
+ affecting the read operation. On the contrary, when writing a packfile (or
+ a sub-chunk of a packfile), you must make sure that the password that was
+ active at the time the packfile (or the sub-chunk respectively) was opened
+ is still active before closing the packfile (or the sub-chunk respectively).
+ This is guaranteed to be true if you didn't call the packfile_password()
+ routine in the meantime.
+ Note #2: as explained above, the password is used for all read/write
+ operations on files, including for several functions of the library that
+ operate on files without explicitly using packfiles, e.g load_bitmap().
+ The unencrypted mode is mandatory in order for those functions to work.
+ Therefore remember to call packfile_password(NULL) before using them
+ if you previously changed the password. As a rule of thumb, always call
+ packfile_password(NULL) when you are done with operations on packfiles.
--
Eric Botcazou
ebotcazou@xxxxxxxxxx
------=_NextPart_000_0271_01C22150.D0160700
Content-Type: application/octet-stream;
name="passwd.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="passwd.c"
#include <allegro.h>
void qwrite(void)
{
PACKFILE *f;
f = pack_fopen("testing","w");
packfile_password("mypassword");
pack_fputs("(this is a string)", f);
packfile_password(NULL); /* *** */
pack_fclose(f);
}
void qread(void)
{
PACKFILE *f;
char buf[128];
f = pack_fopen("testing","r");
packfile_password("mypassword");
pack_fgets(buf, 128, f);
pack_fclose(f);
printf("%s\n",buf);
}
int main(void)
{
allegro_init();
qwrite();
qread();
return 0;
}
END_OF_MAIN()
------=_NextPart_000_0271_01C22150.D0160700--