]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blobdiff - zephyr/server/subscr.c
r4275@bucket (orig r265): kcr | 2008-01-21 02:57:32 -0500
[1ts-debian.git] / zephyr / server / subscr.c
index 97861e791808eeee83cbab51168b950c011d9423..c67bc8956e73a24cf7e545417f13ac930fb7cd63 100644 (file)
@@ -73,33 +73,30 @@ Sched       serv_ksched;
 #ifdef OLD_COMPAT
 #define        OLD_ZEPHYR_VERSION      "ZEPH0.0"
 #define        OLD_CLIENT_INCOMPSUBS   "INCOMP"
-static void old_compat_subscr_sendlist __P((ZNotice_t *notice, int auth,
-                                         struct sockaddr_in *who));
+static void old_compat_subscr_sendlist(ZNotice_t *notice, int auth,
+                                      struct sockaddr_in *who);
 extern int old_compat_count_subscr;    /* counter of old use */
 #endif /* OLD_COMPAT */
 #ifdef NEW_COMPAT
 #define NEW_OLD_ZEPHYR_VERSION "ZEPH0.1"
-static void new_old_compat_subscr_sendlist __P((ZNotice_t *notice, int auth,
-                                             struct sockaddr_in *who)); 
+static void new_old_compat_subscr_sendlist(ZNotice_t *notice, int auth,
+                                          struct sockaddr_in *who); 
 extern int new_compat_count_subscr;    /* counter of old use */
 #endif /* NEW_COMPAT */
 
-extern char *re_comp(), *re_conv();
-static Code_t add_subscriptions __P((Client *who, Destlist *subs_queue,
-                                  ZNotice_t *notice, Server *server));
-static Destlist *extract_subscriptions __P((ZNotice_t *notice));
-static void free_subscriptions __P((Destlist *subs));
-static void free_subscription __P((Destlist *sub));
-static char **subscr_marshal_subs __P((ZNotice_t *notice, int auth,
-                                    struct sockaddr_in *who,
-                                    int *found));
-static Destlist *subscr_copy_def_subs __P((char *person));
-static Code_t subscr_realm_sendit __P((Client *who, Destlist *subs,
-                                      ZNotice_t *notice, ZRealm *realm));
-static void subscr_unsub_realms __P((Destlist *newsubs));
-static void subscr_unsub_sendit __P((Client *who, Destlist *subs, 
-                                    ZRealm *realm));
-static int cl_match  __P((Destlist*, Client *));
+static Code_t add_subscriptions(Client *who, Destlist *subs_queue,
+                               ZNotice_t *notice, Server *server);
+static Destlist *extract_subscriptions(ZNotice_t *notice);
+static void free_subscriptions(Destlist *subs);
+static void free_subscription(Destlist *sub);
+static char **subscr_marshal_subs(ZNotice_t *notice, int auth,
+                                 struct sockaddr_in *who,
+                                 int *found);
+static Destlist *subscr_copy_def_subs(char *person);
+static Code_t subscr_realm_sendit(Client *who, Destlist *subs,
+                                 ZNotice_t *notice, ZRealm *realm);
+static void subscr_unsub_sendit(Client *who, Destlist *subs, 
+                               ZRealm *realm);
 
 static int defaults_read = 0;          /* set to 1 if the default subs
                                           are in memory */
@@ -118,10 +115,9 @@ String *empty;
  */
 
 Code_t
-subscr_subscribe(who, notice, server)
-    Client *who;
-    ZNotice_t *notice;
-    Server *server;
+subscr_subscribe(Client *who,
+                ZNotice_t *notice,
+                Server *server)
 {
     Destlist *subs;
 
@@ -130,11 +126,10 @@ subscr_subscribe(who, notice, server)
 }
 
 static Code_t
-add_subscriptions(who, subs, notice, server)
-    Client *who;
-    Destlist *subs;
-    ZNotice_t *notice;
-    Server *server;
+add_subscriptions(Client *who,
+                 Destlist *subs,
+                 ZNotice_t *notice,
+                 Server *server)
 {
     Destlist *next;
     Code_t retval;
@@ -208,7 +203,7 @@ add_subscriptions(who, subs, notice, server)
              }
          } else {
              /* If realm, let the REALM_ADD_SUBSCRIBE do insertion */
-             LIST_INSERT(&who->subs, subs);
+             Destlist_insert(&who->subs, subs);
          }
        }
     }
@@ -222,8 +217,7 @@ add_subscriptions(who, subs, notice, server)
  */
 
 Code_t
-subscr_def_subs(who)
-    Client *who;
+subscr_def_subs(Client *who)
 {
     Destlist *subs;
 
@@ -232,7 +226,7 @@ subscr_def_subs(who)
 }
 
 void
-subscr_reset()
+subscr_reset(void)
 {
 #if 0
     zdbug((LOG_DEBUG, "subscr_reset()"));
@@ -243,8 +237,7 @@ subscr_reset()
 }
 
 static Destlist *
-subscr_copy_def_subs(person)
-    char *person;
+subscr_copy_def_subs(char *person)
 {
     int retval, fd;
     struct stat statbuf;
@@ -325,16 +318,14 @@ subscr_copy_def_subs(person)
  */
 
 Code_t
-subscr_cancel(sin, notice)
-    struct sockaddr_in *sin;
-    ZNotice_t *notice;
+subscr_cancel(struct sockaddr_in *sin,
+             ZNotice_t *notice)
 {
     ZRealm *realm;
     Client *who;
     Destlist *cancel_subs, *subs, *cancel_next, *client_subs, *client_next;
     Code_t retval;
     int found = 0;
-    int relation;
 
 #if 0
     zdbug((LOG_DEBUG,"subscr_cancel"));
@@ -355,7 +346,7 @@ subscr_cancel(sin, notice)
        for (client_subs = who->subs; client_subs; client_subs = client_next) {
            client_next = client_subs->next;
            if (ZDest_eq(&client_subs->dest, &subs->dest)) {
-               LIST_DELETE(client_subs);
+               Destlist_delete(client_subs);
                retval = triplet_deregister(who, &client_subs->dest, NULL);
                if (retval == ZSRV_EMPTYCLASS &&
                    client_subs->dest.recip->string[0] == '@') {
@@ -389,12 +380,10 @@ subscr_cancel(sin, notice)
 }
 
 Code_t
-subscr_realm_cancel(sin, notice, realm)
-    struct sockaddr_in *sin;
-    ZNotice_t *notice;
-    ZRealm *realm;
+subscr_realm_cancel(struct sockaddr_in *sin,
+                   ZNotice_t *notice,
+                   ZRealm *realm)
 {
-    Client *who;
     Destlist *cancel_subs, *subs, *client_subs, *next, *next2;
     Code_t retval;
     int found = 0;
@@ -414,7 +403,7 @@ subscr_realm_cancel(sin, notice, realm)
         for (client_subs = realm->subs; client_subs; client_subs = next2) {
             next2 = client_subs->next;
             if (ZDest_eq(&client_subs->dest, &subs->dest)) {
-                LIST_DELETE(client_subs);
+                Destlist_delete(client_subs);
                 retval = triplet_deregister(realm->client, &client_subs->dest, realm);
                free_subscription(client_subs);
                 found = 1;
@@ -443,8 +432,7 @@ subscr_realm_cancel(sin, notice, realm)
  */
 
 void
-subscr_cancel_client(client)
-    Client *client;
+subscr_cancel_client(Client *client)
 {
     Destlist *subs, *next;
     Code_t retval;
@@ -481,10 +469,9 @@ subscr_cancel_client(client)
  */
 
 void
-subscr_sendlist(notice, auth, who)
-    ZNotice_t *notice;
-    int auth;
-    struct sockaddr_in *who;
+subscr_sendlist(ZNotice_t *notice,
+               int auth,
+               struct sockaddr_in *who)
 {
     char **answer;
     int found;
@@ -535,11 +522,10 @@ subscr_sendlist(notice, auth, who)
 }
 
 static char **
-subscr_marshal_subs(notice, auth, who, found)
-    ZNotice_t *notice;
-    int auth;
-    struct sockaddr_in *who;
-    int *found;
+subscr_marshal_subs(ZNotice_t *notice,
+                   int auth,
+                   struct sockaddr_in *who,
+                   int *found)
 {
     char **answer = NULL;
     unsigned short temp;
@@ -833,14 +819,13 @@ old_compat_subscr_sendlist(notice, auth, who)
 
 /*ARGSUSED*/
 Code_t
-subscr_send_subs(client)
-    Client *client;
+subscr_send_subs(Client *client)
 {
     int i = 0;
     Destlist *subs;
 #ifdef HAVE_KRB5
     char buf[512];
-    char *bufp;
+    unsigned char *bufp;
 #else
 #ifdef HAVE_KRB4
     char buf[512];
@@ -972,8 +957,7 @@ free_subscription(Destlist *sub)
 }
 
 static void
-free_subscriptions(subs)
-    Destlist *subs;
+free_subscriptions(Destlist *subs)
 {
     Destlist *next;
 
@@ -996,8 +980,7 @@ free_subscriptions(subs)
  */
 
 static Destlist *
-extract_subscriptions(notice)
-    ZNotice_t *notice;
+extract_subscriptions(ZNotice_t *notice)
 {
     Destlist *subs = NULL, *sub;
     char *recip, *class_name, *classinst;
@@ -1033,7 +1016,7 @@ extract_subscriptions(notice)
            sub->dest.recip = make_string("", 0);
        else
            sub->dest.recip = make_string(recip, 0);
-       LIST_INSERT(&subs, sub);
+       Destlist_insert(&subs, sub);
     }
     return subs;
 }
@@ -1045,12 +1028,9 @@ extract_subscriptions(notice)
  */
 
 void
-subscr_dump_subs(fp, subs)
-    FILE *fp;
-    Destlist *subs;
+subscr_dump_subs(FILE *fp,
+                Destlist *subs)
 {
-    char *p;
-
     if (!subs)                 /* no subscriptions to dump */
        return;
 
@@ -1075,16 +1055,14 @@ subscr_dump_subs(fp, subs)
 /* As it exists, this function expects to take only the first sub from the 
  * Destlist. At some point, it and the calling code should be replaced */
 static Code_t
-subscr_realm_sendit(who, subs, notice, realm)
-    Client *who;
-    Destlist *subs;
-    ZNotice_t *notice;
-    ZRealm *realm;
+subscr_realm_sendit(Client *who,
+                   Destlist *subs,
+                   ZNotice_t *notice,
+                   ZRealm *realm)
 {
   ZNotice_t snotice;
   char *pack;
   int packlen;
-  int found = 0, i;
   char **text;
   Code_t retval;
   char addr[16];          /* xxx.xxx.xxx.xxx max */
@@ -1162,12 +1140,11 @@ subscr_realm_sendit(who, subs, notice, realm)
 
 /* Called from subscr_realm and subscr_foreign_user */
 static Code_t
-subscr_add_raw(client, realm, newsubs)
-    Client *client;
-    ZRealm *realm;
-    Destlist *newsubs;
+subscr_add_raw(Client *client,
+              ZRealm *realm,
+              Destlist *newsubs)
 {
-  Destlist *subs, *subs2, *subs3, **head;
+  Destlist *subs, *subs2, **head;
   Code_t retval;
 
 #if 0
@@ -1209,21 +1186,20 @@ subscr_add_raw(client, realm, newsubs)
                    sub->dest.classname->string, sub->dest.inst->string, 
                    sub->dest.recip->string, remrealm->name));
 #endif
-           LIST_INSERT(&remrealm->remsubs, sub);
+           Destlist_insert(&remrealm->remsubs, sub);
          }
        }
       }
     }
-    LIST_INSERT(head, subs);
+    Destlist_insert(head, subs);
   }
   return ZERR_NONE;
 }
 
 /* Called from bdump_recv_loop to decapsulate realm subs */
 Code_t
-subscr_realm(realm, notice)
-    ZRealm *realm;
-    ZNotice_t *notice;
+subscr_realm(ZRealm *realm,
+            ZNotice_t *notice)
 {
         Destlist  *newsubs;
 
@@ -1239,17 +1215,15 @@ subscr_realm(realm, notice)
 
 /* Like realm_sendit, this only takes one item from subs */
 static void
-subscr_unsub_sendit(who, subs, realm)
-    Client *who;
-    Destlist *subs;
-    ZRealm *realm;
+subscr_unsub_sendit(Client *who,
+                   Destlist *subs,
+                   ZRealm *realm)
 {
   ZNotice_t unotice;
   Code_t retval;
   char **list;
   char *pack;
   int packlen;
-  int found = 0;
   Destlist *subsp, *subsn;
 
   for (subsp = realm->remsubs; subsp; subsp = subsn) {
@@ -1260,7 +1234,7 @@ subscr_unsub_sendit(who, subs, realm)
              subsp->dest.classname->string, subsp->dest.inst->string, 
              subsp->dest.recip->string, realm->name));
 #endif
-      LIST_DELETE(subsp);
+      Destlist_delete(subsp);
       free_subscription(subsp);
       break;
     }
@@ -1306,8 +1280,7 @@ subscr_unsub_sendit(who, subs, realm)
 
 /* Called from bump_send_loop by way of realm_send_realms */
 Code_t
-subscr_send_realm_subs(realm)
-    ZRealm *realm;
+subscr_send_realm_subs(ZRealm *realm)
 {
   int i = 0;
   Destlist *subs, *next;
@@ -1373,12 +1346,9 @@ subscr_send_realm_subs(realm)
 }
 
 Code_t
-subscr_realm_subs(realm)
-    ZRealm *realm;
+subscr_realm_subs(ZRealm *realm)
 {
-  int i = 0;
   Destlist *subs, *next;
-  char buf[512];
   char *text[2 + NUM_FIELDS];
   unsigned short num = 0;
   Code_t retval;
@@ -1459,14 +1429,13 @@ subscr_realm_subs(realm)
 
 /* Called from subscr_foreign_user for REALM_REQ_SUBSCRIBE */
 static Code_t
-subscr_check_foreign_subs(notice, who, server, realm, newsubs)
-    ZNotice_t *notice;
-    struct sockaddr_in *who;
-    Server *server;
-    ZRealm *realm;
-    Destlist *newsubs;
+subscr_check_foreign_subs(ZNotice_t *notice,
+                         struct sockaddr_in *who,
+                         Server *server,
+                         ZRealm *realm,
+                         Destlist *newsubs)
 {
-    Destlist *subs, *subs2, *next;
+    Destlist *subs, *next;
     Acl *acl;
     char **text;
     int found = 0;
@@ -1562,7 +1531,7 @@ subscr_check_foreign_subs(notice, who, server, realm, newsubs)
                return retval;
            }
        }
-       LIST_INSERT(&realm->subs, subs);
+       Destlist_insert(&realm->subs, subs);
     }
     /* don't send confirmation if we're not the initial server contacted */
     if (!(server_which_server(who) || found == 0)) {
@@ -1594,14 +1563,12 @@ subscr_check_foreign_subs(notice, who, server, realm, newsubs)
 }
 
 /* Called from realm_control_dispatch for REALM_REQ/ADD_SUBSCRIBE */
-Code_t subscr_foreign_user(notice, who, server, realm)
-    ZNotice_t *notice;
-    struct sockaddr_in *who;
-    Server *server;
-    ZRealm *realm;
+Code_t subscr_foreign_user(ZNotice_t *notice,
+                          struct sockaddr_in *who,
+                          Server *server,
+                          ZRealm *realm)
 {
   Destlist *newsubs, *temp;
-  Acl *acl;
   Code_t status;
   Client *client;
   ZNotice_t snotice;
@@ -1617,7 +1584,7 @@ Code_t subscr_foreign_user(notice, who, server, realm)
   
   newwho.sin_addr.s_addr = inet_addr(cp);
   if (newwho.sin_addr.s_addr == -1) {
-    syslog(LOG_ERR, "malformed addr from %s, notice->z_sender");
+    syslog(LOG_ERR, "malformed addr from %s", notice->z_sender);
     return(ZERR_NONE);
   }