diff options
Diffstat (limited to 'zwgc/subscriptions.c')
-rw-r--r-- | zwgc/subscriptions.c | 61 |
1 files changed, 17 insertions, 44 deletions
diff --git a/zwgc/subscriptions.c b/zwgc/subscriptions.c index 8327279..b7f6c40 100644 --- a/zwgc/subscriptions.c +++ b/zwgc/subscriptions.c @@ -79,70 +79,45 @@ static string address_to_string(class, instance, recipient) return(result); } -/* hack. enumerate should allow client_data to be passed. If this - * were C++ I could be amazingly more elegant. - */ - -static int in_punt_list; -static char *ctest,*itest,*utest; - -static void punt_dict_test(binding) - int_dictionary_binding *binding; -{ - char *inst,*user; - static char wild[] = "*"; /* len = 2 */ - char *key = binding->key; - - if (in_punt_list) return; - - inst = index(key,'\001')+1; - user = index(inst,'\001')+1; - - if (((*key == '*') || (bcmp(key,ctest,inst-key) == 0)) && - ((*inst == '*') || (bcmp(inst,itest,user-inst) == 0)) && - ((*user == '*') || (strcmp(user,utest) == 0))) - in_punt_list = 1; - return; -} - -int puntable_address_p(class, instance, sender) +int puntable_address_p(class, instance, recipient) string class; string instance; - string sender; + string recipient; { + string temp; + if (!puntable_addresses_dict) init_puntable_dict(); - in_punt_list = 0; - ctest = address_to_string(class, instance, sender); - itest = index(ctest,'\001')+1; - utest = index(itest,'\001')+1; - - int_dictionary_Enumerate(puntable_addresses_dict,punt_dict_test); + temp = address_to_string(class, instance, recipient); + if (int_dictionary_Lookup(puntable_addresses_dict, temp)) { + free(temp); + return(1); + } - free(ctest); - return(in_punt_list); + free(temp); + return(0); } -void punt(class, instance, sender) +void punt(class, instance, recipient) string class; string instance; - string sender; + string recipient; { string temp; if (!puntable_addresses_dict) init_puntable_dict(); - temp = address_to_string(class, instance, sender); + temp = address_to_string(class, instance, recipient); (void)int_dictionary_Define(puntable_addresses_dict, temp, 0); free(temp); } -void unpunt(class, instance, sender) +void unpunt(class, instance, recipient) string class; string instance; - string sender; + string recipient; { string temp; int_dictionary_binding *binding; @@ -150,7 +125,7 @@ void unpunt(class, instance, sender) if (!puntable_addresses_dict) init_puntable_dict(); - temp = address_to_string(class, instance, sender); + temp = address_to_string(class, instance, recipient); binding = int_dictionary_Define(puntable_addresses_dict, temp, 0); free(temp); if (binding) @@ -323,8 +298,6 @@ static void load_subscriptions_from_file(file) unsubscribe(class, instance, recipient); break; case PUNT_CHARACTER: - /* well, if it's a punt, it's not a recip, but we'll - let that go */ punt(class, instance, recipient); break; default: |