2008-01-11 21:06:15 +03:00
|
|
|
/*
|
|
|
|
* function to compare 2 BMessages
|
|
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <Message.h>
|
|
|
|
|
|
|
|
/* returns true if == */
|
|
|
|
bool CompareMessages(BMessage &a, BMessage &b)
|
|
|
|
{
|
2008-01-12 02:49:42 +03:00
|
|
|
char *name;
|
2008-01-11 21:06:15 +03:00
|
|
|
type_code code;
|
2008-01-12 02:49:42 +03:00
|
|
|
int32 count, index, i;
|
2008-01-11 21:06:15 +03:00
|
|
|
const void *adata, *bdata;
|
|
|
|
ssize_t asize, bsize;
|
|
|
|
|
|
|
|
if (a.what != b.what)
|
|
|
|
return false;
|
2008-01-12 02:49:42 +03:00
|
|
|
for (index = 0; a.GetInfo(B_ANY_TYPE, index, &name, &code, &count) == B_OK; i++) {
|
2008-01-11 21:06:15 +03:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
if (a.FindData(name, code, i, &adata, &asize) != B_OK)
|
|
|
|
return false;
|
|
|
|
if (b.FindData(name, code, i, &bdata, &bsize) != B_OK)
|
|
|
|
return false;
|
|
|
|
if (asize != bsize)
|
|
|
|
return false;
|
|
|
|
if (memcmp(adata, bdata, asize))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* cross compare */
|
2008-01-12 02:49:42 +03:00
|
|
|
for (index = 0; b.GetInfo(B_ANY_TYPE, index, &name, &code, &count) == B_OK; i++) {
|
2008-01-11 21:06:15 +03:00
|
|
|
type_code acode;
|
|
|
|
int32 acount;
|
|
|
|
if (a.GetInfo(name, &acode, &acount) < B_OK)
|
|
|
|
return false;
|
|
|
|
if (code != acode)
|
|
|
|
return false;
|
|
|
|
if (count != acount)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|