Perhaps you could use a function that takes two keys and returns 1 or zero if the first key meets the criteria for the second key?
Code:
int isKeyMatch(const KEY * key1, const KEY * key2)
{
return (
(strcmp (key1.sender, "0") == 0 || strcmp (key1.sender, key2.sender) == 0) &&
(strcmp (key1.addressee, "0") == 0 || strcmp (key1.addressee, key2.addressee) == 0) &&
(strcmp (key1.regarding, "0") == 0 || strcmp (key1.regarding, key2.regarding) == 0) &&
(key1.date.day == 0 || key1.date.day == key2.date.day) &&
(key1.date.month == 0 || key1.date.month == key2.date.month) &&
(key1.date.year == 0 || key1.date.year == key2.date.year) &&
(key1.id == 0 || key1.id == key2.id) &&
(strcmp (key1.fname, "0") == 0 || strcmp (key1.fname, key2.fname) == 0));
}
That's a hell of a return statement, eh? I'm not sure it's all syntactically correct, but the idea is that it goes through each element of the structure, and for each element, it checks to see if the search value is 0, or if the search value is the same as the other value passed. The way I wrote it, key1 is the search value, and key2 is the value you are checking to see whether it matches key1's criteria. If I might make a suggestion though, instead of using "0", maybe you should try using something like NULL, or an empty string... it's just kinda a good C-habit to use.