@@ -22,6 +22,13 @@ See also:
2222#include < stdlib.h>
2323#include < string.h>
2424
25+ unsigned fourCC (const char a, const char b, const char c, const char d) {
26+ return (a << 0 ) | (b << 8 ) | (c << 16 ) | (d << 24 );
27+ };
28+ const unsigned CRILAYLA_LO = fourCC(' C' , ' R' , ' I' , ' L' );
29+ const unsigned CRILAYLA_HI = fourCC(' A' , ' Y' , ' L' , ' A' );
30+ const unsigned long long CRILAYLA_MAGIC = CRILAYLA_LO | (unsigned long long )CRILAYLA_HI << 32uLL;
31+
2532struct crilayla_header {
2633 unsigned long long crilayla;
2734 unsigned int decompress_size;
@@ -186,7 +193,7 @@ unsigned int layla_comp(unsigned char *dest, int *destLen, unsigned char *src, i
186193 return 0 ; // Underflow
187194 *destLen = *destLen - m; dest += m;
188195 // CRIL AYLA srcLen-0x100 destLen
189- int l[] = { 0x4c495243 , 0x414c5941 ,srcLen - 0x100 ,*destLen };
196+ int l[] = { CRILAYLA_LO,CRILAYLA_HI ,srcLen - 0x100 ,*destLen };
190197 for (j = 0 ; j<4 ; j++)
191198 {
192199 for (i = 0 ; i<4 ; i++)
@@ -210,7 +217,7 @@ PyObject* CriLaylaDecompress(PyObject* self, PyObject* d){
210217 unsigned char *data = (unsigned char *)PyBytes_AsString (d);
211218 crilayla_header header = *(crilayla_header*)data;
212219
213- if (header.crilayla != 0x414c59434152494cULL ) {
220+ if (header.crilayla != CRILAYLA_MAGIC ) {
214221 PyErr_SetString (PyExc_ValueError, " Invalid CRILAYLA header." );
215222 return NULL ;
216223 }
0 commit comments