]> andersk Git - moira.git/blobdiff - server/qsupport.qc
Used /bin/sh format instead of /bin/csh format, by accident.
[moira.git] / server / qsupport.qc
index 80a9b84c36d7263a70a5ff8e213b6bc6ddbe681f..5e3638346f3508628b5d3798a85acfc5228157f6 100644 (file)
@@ -15,12 +15,12 @@ static char *rcsid_qsupport_qc = "$Header$";
 
 #include <mit-copyright.h>
 #include "query.h"
-#include "sms_server.h"
+#include "mr_server.h"
 #include <ctype.h>
 
 
 extern char *whoami, *strsave();
-extern int ingres_errno, sms_errcode;
+extern int ingres_errno, mr_errcode;
 
 
 /* Specialized Access Routines */
@@ -37,9 +37,9 @@ access_user(q, argv, cl)
     client *cl;
 {
     if (cl->users_id != *(int *)argv[0])
-       return(SMS_PERM);
+       return(MR_PERM);
     else
-       return(SMS_SUCCESS);
+       return(MR_SUCCESS);
 }
 
     
@@ -62,9 +62,9 @@ access_login(q, argv, cl)
 ##  retrieve (id = u.users_id) where qual
 ##  inquire_equel(rowcount = "rowcount")
     if (rowcount != 1 || id != cl->users_id)
-       return(SMS_PERM);
+       return(MR_PERM);
     else
-       return(SMS_SUCCESS);
+       return(MR_SUCCESS);
 ##}
 
     
@@ -98,29 +98,29 @@ access_list(q, argv, cl)
 ##        where list.#list_id = @list_id
 ##  inquire_equel(rowcount = "rowcount")
     if (rowcount != 1)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
 
     /* parse client structure */
-    if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+    if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
        return(status);
 
     /* if amtl or dmfl and list is public allow client to add or delete self */
     if (((!strcmp("amtl", q->shortname) && flags) ||
         (!strcmp("dmfl", q->shortname))) &&
        (!strcmp("USER", argv[1]))) {
-       if (*(int *)argv[2] == client_id) return(SMS_SUCCESS);
+       if (*(int *)argv[2] == client_id) return(MR_SUCCESS);
     /* if update_list, don't allow them to change the GID */
     } else if (!strcmp("ulis", q->shortname)) {
        if ((!strcmp(argv[7], UNIQUE_GID) && (gid != -1)) ||
            (strcmp(argv[7], UNIQUE_GID) && (gid != atoi(argv[7]))))
-         return(SMS_PERM);
+         return(MR_PERM);
     }
 
     /* check for client in access control list */
     status = find_member(acl_type, acl_id, client_type, client_id, 0);
-    if (!status) return(SMS_PERM);
+    if (!status) return(MR_PERM);
 
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -146,21 +146,21 @@ access_visible_list(q, argv, cl)
 ##     acl_type = list.#acl_type) where list.#list_id = @list_id
 ##  inquire_equel(rowcount = "rowcount")
     if (rowcount != 1)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
     if (!flags)
-       return(SMS_SUCCESS);
+       return(MR_SUCCESS);
 
 
     /* parse client structure */
-    if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+    if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
        return(status);
 
     /* check for client in access control list */
     status = find_member(acl_type, acl_id, client_type, client_id, 0);
     if (!status)
-       return(SMS_PERM);
+       return(MR_PERM);
 
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -186,22 +186,22 @@ access_vis_list_by_name(q, argv, cl)
 ##     acl_type = list.#acl_type) where list.#name = @listname
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount > 1)
-      return(SMS_WILDCARD);
+      return(MR_WILDCARD);
     if (rowcount == 0)
-      return(SMS_NO_MATCH);
+      return(MR_NO_MATCH);
     if (!flags)
-       return(SMS_SUCCESS);
+       return(MR_SUCCESS);
 
     /* parse client structure */
-    if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+    if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
        return(status);
 
     /* check for client in access control list */
     status = find_member(acl_type, acl_id, client_type, client_id, 0);
     if (!status)
-       return(SMS_PERM);
+       return(MR_PERM);
 
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -220,10 +220,10 @@ access_member(q, argv, cl)
 
     if (!strcmp(argv[0], "USER") || !strcmp(argv[0], "RUSER")) {
        if (cl->users_id == *(int *)argv[1])
-         return(SMS_SUCCESS);
+         return(MR_SUCCESS);
     }
 
-    return(SMS_PERM);
+    return(MR_PERM);
 }
 
 
@@ -237,8 +237,8 @@ access_qgli(q, argv, cl)
     client *cl;
 {
     if (!strcmp(argv[0], "TRUE") && !strcmp(argv[2], "FALSE"))
-      return(SMS_SUCCESS);
-    return(SMS_PERM);
+      return(MR_SUCCESS);
+    return(MR_PERM);
 }
 
 
@@ -261,17 +261,17 @@ access_service(q, argv, cl)
 ##     where servers.#name = uppercase(@name)
 ##  inquire_equel(rowcount = "rowcount")
     if (rowcount > 1)
-      return(SMS_PERM);
+      return(MR_PERM);
 
     /* parse client structure */
-    if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+    if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
        return(status);
 
     /* check for client in access control list */
     status = find_member(acl_type, acl_id, client_type, client_id, 0);
-    if (!status) return(SMS_PERM);
+    if (!status) return(MR_PERM);
 
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -296,16 +296,16 @@ access_filesys(q, argv, cl)
 ##  inquire_equel(rowcount = "rowcount")
 
     if (rowcount != 1)
-      return(SMS_PERM);
+      return(MR_PERM);
     if (users_id == cl->users_id)
-      return(SMS_SUCCESS);
-    if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+      return(MR_SUCCESS);
+    if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
       return(status);
     status = find_member("LIST", list_id, client_type, client_id, 0);
     if (status)
-      return(SMS_SUCCESS);
+      return(MR_SUCCESS);
     else
-      return(SMS_PERM);
+      return(MR_PERM);
 ##}
 
     
@@ -329,14 +329,25 @@ setup_ausr(q, argv, cl)
     client *cl;
 ##{
 ##  int nuid, rowcount;
+##  char *mit_id;
+
+#ifdef notdef
+    /* this is currently disabled because we need an index on ID's
+     * before it can run in finite time.
+     */
+    mit_id = argv[U_MITID];
+##  retrieve (rowcount = any(u.#mit_id where u.#mit_id = mit_id))
+    if (ingres_errno) return(mr_errcode);
+    if (rowcount) return(MR_EXISTS);
+#endif notdef
 
     if (!strcmp(argv[1], UNIQUE_UID) || atoi(argv[1]) == -1) {
        if (set_next_object_id("uid", "users"))
-         return(SMS_INGRES_ERR);
+         return(MR_INGRES_ERR);
 ##      repeat retrieve (nuid = values.value) where values.name = "uid"
 ##     inquire_equel(rowcount = "rowcount")
        if (rowcount != 1)
-         return(SMS_INTERNAL);
+         return(MR_INTERNAL);
        sprintf(argv[1], "%d", nuid);
     }
 
@@ -344,7 +355,7 @@ setup_ausr(q, argv, cl)
        sprintf(argv[0], "#%s", argv[1]);
     }
 
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -363,32 +374,32 @@ int setup_dusr(q, argv)
     /* For now, only allow users to be deleted if their status is 0 */
 ##  repeat retrieve (flag = u.status) where u.users_id = @id
     if (flag != 0 && flag != 4)
-      return(SMS_IN_USE);
+      return(MR_IN_USE);
 
-##  repeat delete nfsquota where nfsquota.users_id = @id
+##  repeat delete quota where quota.entity_id = @id and quota.type = "USER"
 ##  repeat delete krbmap where krbmap.users_id = @id
 ##  repeat retrieve (flag = any(imembers.member_id where imembers.member_id=@id
 ##                      and imembers.member_type = "USER"))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(filesys.label where filesys.owner=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(list.name where list.acl_id=@id and
 ##                     list.acl_type = "USER"))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(servers.name where servers.acl_id=@id and
 ##                     servers.acl_type = "USER"))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag=any(hostaccess.acl_id where hostaccess.acl_id=@id and
 ##                     hostaccess.acl_type = "USER"))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
     if (ingres_errno)
-       return(sms_errcode);
-    return(SMS_SUCCESS);
+       return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -408,10 +419,10 @@ char **argv;
 ##                                  and u.pop_id != 0 and u.users_id = @id))
 ##     where u.users_id = @id
     if (!flag)
-      return(SMS_MACHINE);
+      return(MR_MACHINE);
     if (strcmp(strtrim(type), "POP"))
       set_pop_usage(mid, 1);
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -427,11 +438,11 @@ char **argv;
     user = *(int *)argv[0];
 ##  repeat retrieve (type = u.potype, id = u.pop_id)
 ##             where u.users_id = @user
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 
     if (!strcmp(strtrim(type), "POP"))
       set_pop_usage(id, -1);
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -449,27 +460,30 @@ int setup_dmac(q, argv)
 ##  repeat retrieve (flag = any(users.login where users.potype = "POP" 
 ##                                               and users.pop_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(serverhosts.mach_id
 ##                              where serverhosts.mach_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(nfsphys.mach_id where nfsphys.mach_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(hostaccess.mach_id where hostaccess.mach_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(printcap.mach_id where printcap.mach_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
+##  repeat retrieve (flag = any(printcap.quotaserver where printcap.quotaserver=@id))
+    if (flag)
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(palladium.mach_id where palladium.mach_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 
 ##  repeat delete mcmap where mcmap.mach_id = @id
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -486,13 +500,13 @@ int setup_dclu(q, argv)
     id = *(int *)argv[0];
 ##  repeat retrieve (flag = any(mcmap.mach_id where mcmap.clu_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(svc.clu_id where svc.clu_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
     if (ingres_errno)
-       return(sms_errcode);
-    return(SMS_SUCCESS);
+       return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -519,16 +533,16 @@ char **argv;
     if (!strcmp(argv[idx], UNIQUE_GID) || atoi(argv[idx]) == -1) {
        if (atoi(argv[idx - 1])) {
            if (set_next_object_id("gid", "list"))
-             return(SMS_INGRES_ERR);
+             return(MR_INGRES_ERR);
 ##         repeat retrieve (ngid = values.value) where values.name = "gid"
-           if (ingres_errno) return(sms_errcode);
+           if (ingres_errno) return(mr_errcode);
            sprintf(argv[idx], "%d", ngid);
        } else {
            strcpy(argv[idx], "-1");
        }
     }
 
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -546,38 +560,42 @@ int setup_dlis(q, argv)
 ##  repeat retrieve (flag = any(imembers.member_id where imembers.member_id=@id
 ##                      and imembers.member_type = "LIST"))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(imembers.member_id where imembers.list_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(filesys.label where filesys.owners=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(capacls.tag where capacls.list_id=@id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(list.name where list.acl_id=@id and
 ##                     list.acl_type = "LIST" and list.list_id != @id))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(servers.name where servers.acl_id=@id and
 ##                     servers.acl_type = "LIST"))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
+##  repeat retrieve (flag = any(quota.entity_id where quota.entity_id=@id and
+##                     quota.type = "GROUP"))
+    if (flag)
+       return(MR_IN_USE);
 ##  repeat retrieve (flag=any(hostaccess.acl_id where hostaccess.acl_id=@id and
 ##                     hostaccess.acl_type = "LIST"))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = any(zephyr.class
 ##             where zephyr.xmt_type = "LIST" and zephyr.xmt_id = @id or
 ##                   zephyr.sub_type = "LIST" and zephyr.sub_id = @id or
 ##                   zephyr.iws_type = "LIST" and zephyr.iws_id = @id or
 ##                   zephyr.iui_type = "LIST" and zephyr.iui_id = @id))
     if (flag)
-        return(SMS_IN_USE);
+        return(MR_IN_USE);
     if (ingres_errno)
-       return(sms_errcode);
-    return(SMS_SUCCESS);
+       return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -596,13 +614,13 @@ int setup_dsin(q, argv)
 ##  repeat retrieve (flag = any(serverhosts.service 
 ##                             where serverhosts.service=uppercase(@name)))
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
 ##  repeat retrieve (flag = servers.inprogress) where servers.#name = @name
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
     if (ingres_errno)
-       return(sms_errcode);
-    return(SMS_SUCCESS);
+       return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -622,10 +640,10 @@ int setup_dshi(q, argv)
 ##  repeat retrieve (flag=serverhosts.inprogress) 
 ##     where serverhosts.service=uppercase(@name) and serverhosts.mach_id=@id
     if (flag)
-       return(SMS_IN_USE);
+       return(MR_IN_USE);
     if (ingres_errno)
-       return(sms_errcode);
-    return(SMS_SUCCESS);
+       return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -650,8 +668,8 @@ int setup_dshi(q, argv)
  **    filesystem (nfsphys_id for NFS, 0 for RVD)
  **
  ** Errors:
- **   SMS_NFS - specified directory not exported
- **   SMS_FILESYS_ACCESS - invalid filesys access
+ **   MR_NFS - specified directory not exported
+ **   MR_FILESYS_ACCESS - invalid filesys access
  **
  **/
 
@@ -660,11 +678,11 @@ int setup_dshi(q, argv)
 setup_afil(q, argv)
     struct query *q;
     char *argv[];
-{
-    char *type;
+##{
+    char *type, *name;
     int mach_id;
-    char *name;
-    char *access;  
+##  int ok;
+##  char ftype[32], *access;
 
     type = argv[1];
     mach_id = *(int *)argv[2];
@@ -672,11 +690,17 @@ setup_afil(q, argv)
     access = argv[5];
     var_phys_id = 0;
 
+    sprintf(ftype, "fs_access_%s", type);
+##  retrieve (ok = any(alias.trans where alias.name = ftype and
+##                          alias.type = "TYPE" and alias.trans = access))
+    if (ingres_errno) return(mr_errcode);
+    if (ok == 0) return(MR_FILESYS_ACCESS);
+
     if (!strcmp(type, "NFS"))
        return (check_nfs(mach_id, name, access));
     else
-       return(SMS_SUCCESS);
-}
+       return(MR_SUCCESS);
+##}
 
 
 /* Verify the arguments, depending on the FStype.  Also, if this is an
@@ -684,13 +708,15 @@ setup_afil(q, argv)
  * the new phys_id.
  */
 
-setup_ufil(q, argv)
+setup_ufil(q, argv, cl)
     struct query *q;
     char *argv[];
+    client *cl;
 ##{
     int mach_id, status;
-    char *type, *name, *access;  
-##  int fid, total;
+    char *type, *name;  
+##  int fid, total, who;
+##  char *entity, ftype[32], *access;
 
     type = argv[2];
     mach_id = *(int *)argv[3];
@@ -698,28 +724,36 @@ setup_ufil(q, argv)
     access = argv[6];
     var_phys_id = 0;
     fid = *(int *)argv[0];
+    who = cl->client_id;
+    entity = cl->entity;
+
+    sprintf(ftype, "fs_access_%s", type);
+##  retrieve (total = any(alias.trans where alias.name = ftype and
+##                          alias.type = "TYPE" and alias.trans = access))
+    if (ingres_errno) return(mr_errcode);
+    if (total == 0) return(MR_FILESYS_ACCESS);
 
     if (!strcmp(type, "NFS")) {
        status = check_nfs(mach_id, name, access);
-##     replace nfsquota (phys_id = var_phys_id) where nfsquota.filsys_id = fid
-       if (ingres_errno) return(sms_errcode);
+##     replace quota (phys_id = var_phys_id) where quota.filsys_id = fid
+       if (ingres_errno) return(mr_errcode);
        return(status);
     } else if (!strcmp(type, "AFS")) {
        total = 0;
-##     retrieve (total = sum(nfsquota.quota where nfsquota.filsys_id = fid))
-       if (ingres_errno) return(sms_errcode);
+##     retrieve (total = sum(quota.quota where quota.filsys_id = fid
+##                           and quota.phys_id != 0))
+       if (ingres_errno) return(mr_errcode);
        if (total != 0) {
-##         delete nfsquota where nfsquota.filsys_id = fid
-           if (ingres_errno) return(sms_errcode);
-##         append nfsquota (quota = total, filsys_id = fid,
-##                          phys_id = 0, users_id = 0)
-           if (ingres_errno) return(sms_errcode);
+##         append quota (quota = total, filsys_id = fid,
+##                          phys_id = 0, entity_id = 0, type = "ANY",
+##                          modtime = "now", modby = who, modwith = entity)
+           if (ingres_errno) return(mr_errcode);
        }
     } else {
-##     replace nfsquota (phys_id = 0) where nfsquota.filsys_id = fid
-       if (ingres_errno) return(sms_errcode);
+##     replace quota (phys_id = 0) where quota.filsys_id = fid
+       if (ingres_errno) return(mr_errcode);
     }
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -740,11 +774,7 @@ setup_ufil(q, argv)
     register char *cp1;
     register char *cp2;
 
-    caccess = (isupper(*access)) ? tolower(*access) : *access;
-    if (caccess != 'r' && caccess != 'w' && caccess != 'n')
-      return(SMS_FILESYS_ACCESS);
-
-    status = SMS_NFS;
+    status = MR_NFS;
 ##  range of np is nfsphys
 ##  repeat retrieve (var_phys_id = np.#nfsphys_id, dir = trim(np.#dir))
 ##     where np.#mach_id = @mach_id sort by #dir:d {
@@ -755,12 +785,12 @@ setup_ufil(q, argv)
             cp2++;
         }
         if (*cp2 == 0) {
-            status = SMS_SUCCESS;
+            status = MR_SUCCESS;
 ##           endretrieve
         }
 ##  }
     if (ingres_errno)
-       return(sms_errcode);
+       return(mr_errcode);
     return(status);
 ##}
 
@@ -777,7 +807,7 @@ setup_dfil(q, argv, cl)
 ##  int id;
 
     id = *(int *)argv[0];
-##  range of q is nfsquota
+##  range of q is quota
 ##  range of n is nfsphys
 ##  repeat replace n (allocated=n.allocated-sum(q.quota where q.filsys_id=@id))
 ##     where n.nfsphys_id = filesys.phys_id and filesys.filsys_id = @id
@@ -785,8 +815,8 @@ setup_dfil(q, argv, cl)
 ##  repeat delete q where q.filsys_id = @id
 ##  repeat delete fsgroup where fsgroup.filsys_id = @id
 ##  repeat delete fsgroup where fsgroup.group_id = @id
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -804,35 +834,43 @@ setup_dnfp(q, argv, cl)
     id = *(int *)argv[0];
 ##  repeat retrieve (exists = any(filesys.label where filesys.phys_id = @id))
     if (exists)
-      return(SMS_IN_USE);
+      return(MR_IN_USE);
     if (ingres_errno)
-      return(sms_errcode);
-    return(SMS_SUCCESS);
+      return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
-/* setup_dnfq: Remove allocation from nfsphys before deleting quota.
+/* setup_dqot: Remove allocation from nfsphys before deleting quota.
  *   argv[0] = filsys_id
- *   argv[1] = users_id
+ *   argv[1] = type if "update_quota" or "delete_quota"
+ *   argv[2 or 1] = users_id or list_id
  */
 
-setup_dnfq(q, argv, cl)
+setup_dqot(q, argv, cl)
     struct query  *q;
     char **argv;
     client *cl;
 ##{
-##  int quota, fs, user;
+##  int quota, fs, id;
+##  char *qtype;
 
     fs = *(int *)argv[0];
-    user = *(int *)argv[1];
+    if (!strcmp(q->name, "update_quota") || !strcmp(q->name, "delete_quota")) {
+       qtype = argv[1];
+       id = *(int *)argv[2];
+    } else {
+       qtype = "USER";
+       id = *(int *)argv[1];
+    }
 
-##  range of q is nfsquota
-##  repeat retrieve (quota = q.#quota) where q.users_id = @user and
-##     q.filsys_id = @fs
+##  range of q is #quota
+##  repeat retrieve (quota = q.#quota) where q.type = @qtype and
+##     q.entity_id = @id and q.filsys_id = @fs
 ##  repeat replace nfsphys (allocated = nfsphys.allocated - @quota)
 ##     where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -862,8 +900,8 @@ client *cl;
 ##  char *name;
 
     name = argv[1];
-    if (name_to_id(name, "STRING", &id) != SMS_SUCCESS) {
-       if (q->type != APPEND) return(SMS_STRING);
+    if (name_to_id(name, "STRING", &id) != MR_SUCCESS) {
+       if (q->type != APPEND) return(MR_STRING);
 ##     range of v is values
 ##     retrieve (id = v.value) where v.#name = "strings_id"
        id++;
@@ -871,9 +909,9 @@ client *cl;
 ##     append to strings (string_id = id, string = name)
        cache_entry(name, "STRING", id);
     }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
     *(int *)argv[1] = id;
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -900,7 +938,7 @@ set_modtime(q, argv, cl)
 
 ##  replace table (modtime = "now", modby = who, modwith = entity)
 ##      where table.#name = name
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 /* generic set_modtime_by_id routine.  This takes the table name from
@@ -925,7 +963,7 @@ set_modtime_by_id(q, argv, cl)
     id = *(int *)argv[0];
 ##  replace table (modtime = "now", modby = who, modwith = entity)
 ##      where table.id_name = id
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -946,7 +984,7 @@ set_finger_modtime(q, argv, cl)
 
 ##  repeat replace u (fmodtime = "now", fmodby = @who, fmodwith = @entity)
 ##      where u.#users_id = @users_id
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -967,7 +1005,7 @@ set_pobox_modtime(q, argv, cl)
 
 ##  repeat replace users (pmodtime = "now", pmodby = @who, pmodwith = @entity)
 ##      where users.#users_id = @users_id
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -989,7 +1027,7 @@ set_uppercase_modtime(q, argv, cl)
 
 ##  replace table (modtime = "now", modby = who, modwith = entity)
 ##      where table.#name = uppercase(name)
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1012,7 +1050,7 @@ set_mach_modtime_by_id(q, argv, cl)
     id = *(int *)argv[0];
 ##  repeat replace machine (modtime = "now", modby = @who, modwith = @entity)
 ##      where machine.mach_id = @id
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1035,7 +1073,7 @@ set_cluster_modtime_by_id(q, argv, cl)
     id = *(int *)argv[0];
 ##  repeat replace cluster (modtime = "now", modby = @who, modwith = @entity)
 ##      where cluster.clu_id = @id
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1058,7 +1096,7 @@ set_serverhost_modtime(q, argv, cl)
     id = *(int *)argv[1];
 ##  repeat replace sh (modtime = "now", modby = @who, modwith = @entity)
 ##      where sh.service = uppercase(@serv) and sh.mach_id = @id
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1081,7 +1119,7 @@ set_nfsphys_modtime(q, argv, cl)
     dir = argv[1];
 ##  repeat replace np (modtime = "now", modby = @who, modwith = @entity)
 ##      where np.#dir = @dir and np.mach_id = @id
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1106,7 +1144,7 @@ set_filesys_modtime(q, argv, cl)
 
 ##  repeat replace fs (modtime = "now", modby = @who, modwith = @entity,
 ##                    #phys_id = @var_phys_id)  where fs.#label = @label
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1129,7 +1167,7 @@ set_zephyr_modtime(q, argv, cl)
 
 ##  repeat replace z (modtime = "now", modby = @who, modwith = @entity)
 ##                    where z.#class = @class
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1157,7 +1195,7 @@ followup_fix_modby(q, sq, v, action, actarg, cl)
          status = id_to_name(id, "USER", &argv[i]);
        else
          status = id_to_name(-id, "STRING", &argv[i]);
-       if (status && status != SMS_NO_MATCH)
+       if (status && status != MR_NO_MATCH)
          return(status);
        (*action)(q->vcnt, argv, actarg);
        for (j = 0; j < q->vcnt; j++)
@@ -1165,7 +1203,7 @@ followup_fix_modby(q, sq, v, action, actarg, cl)
        free(argv);
     }
     sq_destroy(sq);
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 }
 
 
@@ -1208,7 +1246,7 @@ followup_ausr(q, argv, cl)
 ##          potype="NONE", pmodtime="now", pmodby=@who, pmodwith=@entity)
 ##     where u.#login = @login
 
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1235,7 +1273,7 @@ followup_gpob(q, sq, v, action, actarg, cl)
 
     /* for each row */
     while (sq_get_data(sq, &argv)) {
-       sms_trim_args(2, argv);
+       mr_trim_args(2, argv);
        ptype = argv[1];
        p = index(argv[2], ':');
        *p++ = 0;
@@ -1244,12 +1282,12 @@ followup_gpob(q, sq, v, action, actarg, cl)
 
        if (!strcmp(ptype, "POP")) {
            status = id_to_name(mid, "MACHINE", &argv[2]);
-           if (status == SMS_NO_MATCH)
-             return(SMS_MACHINE);
+           if (status == MR_NO_MATCH)
+             return(MR_MACHINE);
        } else if (!strcmp(ptype, "SMTP")) {
            status = id_to_name(sid, "STRING", &argv[2]);
-           if (status == SMS_NO_MATCH)
-             return(SMS_STRING);
+           if (status == MR_NO_MATCH)
+             return(MR_STRING);
        } else /* ptype == "NONE" */ {
            goto skip;
        }
@@ -1262,7 +1300,7 @@ followup_gpob(q, sq, v, action, actarg, cl)
            else
              status = id_to_name(-sid, "STRING", &argv[4]);
        }
-       if (status && status != SMS_NO_MATCH) return(status);
+       if (status && status != MR_NO_MATCH) return(status);
 
        (*action)(q->vcnt, argv, actarg);
     skip:
@@ -1274,7 +1312,7 @@ followup_gpob(q, sq, v, action, actarg, cl)
     }
 
     sq_destroy(sq);
-    return (SMS_SUCCESS);
+    return (MR_SUCCESS);
 }
 
 
@@ -1300,14 +1338,14 @@ followup_glin(q, sq, v, action, actarg, cl)
       idx = 12;
 
     while (sq_get_data(sq, &argv)) {
-       sms_trim_args(q->vcnt, argv);
+       mr_trim_args(q->vcnt, argv);
 
        id = atoi(argv[i = q->vcnt - 2]);
        if (id > 0)
          status = id_to_name(id, "USER", &argv[i]);
        else
          status = id_to_name(-id, "STRING", &argv[i]);
-       if (status && status != SMS_NO_MATCH)
+       if (status && status != MR_NO_MATCH)
          return(status);
 
        id = atoi(argv[idx]);
@@ -1328,7 +1366,7 @@ followup_glin(q, sq, v, action, actarg, cl)
            free(argv[idx]);
            argv[idx] = strsave("???");
        }
-       if (status && status != SMS_NO_MATCH)
+       if (status && status != MR_NO_MATCH)
          return(status);
 
        if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1) {
@@ -1346,16 +1384,18 @@ followup_glin(q, sq, v, action, actarg, cl)
     }
 
     sq_destroy(sq);
-    return (SMS_SUCCESS);
+    return (MR_SUCCESS);
 }
 
 
-/* followup_gnfq: Fix the directory name & modby fields
+/* followup_gqot: Fix the entity name, directory name & modby fields
  *   argv[0] = filsys_id
- *   argv[2] = ascii(quota)
+ *   argv[1] = type
+ *   argv[2] = entity_id
+ *   argv[3] = ascii(quota)
  */
 
-followup_gnfq(q, sq, v, action, actarg, cl)
+followup_gqot(q, sq, v, action, actarg, cl)
     struct query *q;
     register struct save_queue *sq;
     struct validate *v;
@@ -1367,13 +1407,37 @@ followup_gnfq(q, sq, v, action, actarg, cl)
     char **argv, *malloc();
 ##  int id, rowcount;
 ##  char *name, *label;
-    int status;
+    int status, idx;
 
+    if (!strcmp(q->name, "get_quota") ||
+       !strcmp(q->name, "get_quota_by_filesys"))
+      idx = 4;
+    else
+      idx = 3;
     while (sq_get_data(sq, &argv)) {
-       id = atoi(argv[3]);
-       free(argv[3]);
-       argv[3] = malloc(256);
-       name = argv[3];
+       if (idx == 4) {
+           switch (argv[1][0]) {
+           case 'U':
+               status = id_to_name(atoi(argv[2]), "USER", &argv[2]);
+               break;
+           case 'G':
+           case 'L':
+               status = id_to_name(atoi(argv[2]), "LIST", &argv[2]);
+               break;
+           case 'A':
+               free(argv[2]);
+               argv[2] = strsave("system:anyuser");
+               break;
+           default:
+               id = atoi(argv[2]);
+               argv[2] = malloc(8);
+               sprintf(argv[2], "%d", id);
+           }
+       }
+       id = atoi(argv[idx]);
+       free(argv[idx]);
+       argv[idx] = malloc(256);
+       name = argv[idx];
        if (id == 0) {
            label = argv[0];
 ##         repeat retrieve (name = filesys.#name) where filesys.#label = @label
@@ -1382,15 +1446,15 @@ followup_gnfq(q, sq, v, action, actarg, cl)
        }
 ##     inquire_equel(rowcount = "rowcount")
        if (rowcount != 1) {
-           sprintf(argv[3], "#%d", id);
+           sprintf(argv[idx], "#%d", id);
        }
 
-       id = atoi(argv[6]);
+       id = atoi(argv[idx+3]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[6]);
+         status = id_to_name(id, "USER", &argv[idx+3]);
        else
-         status = id_to_name(-id, "STRING", &argv[6]);
-       if (status && status != SMS_NO_MATCH)
+         status = id_to_name(-id, "STRING", &argv[idx+3]);
+       if (status && status != MR_NO_MATCH)
          return(status);
        (*action)(q->vcnt, argv, actarg);
        for (j = 0; j < q->vcnt; j++)
@@ -1398,38 +1462,81 @@ followup_gnfq(q, sq, v, action, actarg, cl)
        free(argv);
     }
     sq_destroy(sq);
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
-/* followup_anfq: Add allocation to nfsphys after creating quota.
+/* followup_aqot: Add allocation to nfsphys after creating quota.
  *   argv[0] = filsys_id
- *   argv[2] = ascii(quota)
+ *   argv[1] = type if "add_quota" or "update_quota"
+ *   argv[2 or 1] = id
+ *   argv[3 or 2] = ascii(quota)
  */
 
-followup_anfq(q, argv, cl)
+followup_aqot(q, argv, cl)
     struct query  *q;
     char **argv;
     client *cl;
 ##{
-##  int quota, user, fs, who;
-##  char *entity;
+##  int quota, id, fs, who;
+##  char *entity, *qtype;
 
     fs = *(int *)argv[0];
-    user = *(int *)argv[1];
-    quota = atoi(argv[2]);
+    if (!strcmp(q->name, "add_quota") || !strcmp(q->name, "update_quota")) {
+       qtype = argv[1];
+       id = *(int *)argv[2];
+       quota = atoi(argv[3]);
+    } else {
+       qtype = "USER";
+       id = *(int *)argv[1];
+       quota = atoi(argv[2]);
+    }
     who = cl->client_id;
     entity = cl->entity;
 
-##  repeat replace nq (modtime = "now", modby = @who, modwith = @entity)
-##     where nq.filsys_id = @fs and nq.users_id = @user
+##  repeat replace q (modtime = "now", modby = @who, modwith = @entity)
+##     where q.filsys_id = @fs and q.type = @qtype and q.entity_id = @id
 ##  repeat replace nfsphys (allocated = nfsphys.allocated + @quota)
 ##     where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
+followup_gpce(q, sq, v, action, actarg, cl)
+    struct query *q;
+    register struct save_queue *sq;
+    struct validate *v;
+    register int (*action)();
+    register int actarg;
+    client *cl;
+{
+    register int i, j;
+    char **argv, *malloc();
+    int id, status;
+
+    i = q->vcnt - 2;
+    while (sq_get_data(sq, &argv)) {
+       id = atoi(argv[PCAP_QSERVER]);
+       status = id_to_name(id, "MACHINE", &argv[PCAP_QSERVER]);
+       if (status) return (status);
+       id = atoi(argv[i]);
+       if (id > 0)
+         status = id_to_name(id, "USER", &argv[i]);
+       else
+         status = id_to_name(-id, "STRING", &argv[i]);
+       if (status && status != MR_NO_MATCH)
+         return(status);
+       (*action)(q->vcnt, argv, actarg);
+       for (j = 0; j < q->vcnt; j++)
+         free(argv[j]);
+       free(argv);
+    }
+    sq_destroy(sq);
+    return(MR_SUCCESS);
+}
+
+
 /* followup_gzcl:
  */
 
@@ -1445,14 +1552,14 @@ followup_gzcl(q, sq, v, action, actarg, cl)
     char **argv;
 
     while (sq_get_data(sq, &argv)) {
-       sms_trim_args(q->vcnt, argv);
+       mr_trim_args(q->vcnt, argv);
 
        id = atoi(argv[i = q->vcnt - 2]);
        if (id > 0)
          status = id_to_name(id, "USER", &argv[i]);
        else
          status = id_to_name(-id, "STRING", &argv[i]);
-       if (status && status != SMS_NO_MATCH)
+       if (status && status != MR_NO_MATCH)
          return(status);
 
        for (i = 1; i < 8; i+=2) {
@@ -1472,7 +1579,7 @@ followup_gzcl(q, sq, v, action, actarg, cl)
                free(argv[i+1]);
                argv[i+1] = strsave("???");
            }
-           if (status && status != SMS_NO_MATCH)
+           if (status && status != MR_NO_MATCH)
              return(status);
        }
 
@@ -1485,7 +1592,7 @@ followup_gzcl(q, sq, v, action, actarg, cl)
        free(argv);
     }
     sq_destroy(sq);
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 }
 
 
@@ -1504,14 +1611,14 @@ followup_gsha(q, sq, v, action, actarg, cl)
     int i, id, status;
 
     while (sq_get_data(sq, &argv)) {
-       sms_trim_args(q->vcnt, argv);
+       mr_trim_args(q->vcnt, argv);
 
        id = atoi(argv[4]);
        if (id > 0)
          status = id_to_name(id, "USER", &argv[4]);
        else
          status = id_to_name(-id, "STRING", &argv[4]);
-       if (status && status != SMS_NO_MATCH)
+       if (status && status != MR_NO_MATCH)
          return(status);
 
        id = atoi(argv[2]);
@@ -1530,7 +1637,7 @@ followup_gsha(q, sq, v, action, actarg, cl)
            free(argv[2]);
            argv[2] = strsave("???");
        }
-       if (status && status != SMS_NO_MATCH)
+       if (status && status != MR_NO_MATCH)
          return(status);
 
        /* send the data */
@@ -1542,7 +1649,7 @@ followup_gsha(q, sq, v, action, actarg, cl)
        free(argv);
     }
     sq_destroy(sq);
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 }
 
 
@@ -1570,14 +1677,14 @@ int set_pobox(q, argv, cl)
 
 ##  repeat retrieve (id = users.pop_id, potype = users.#potype)
 ##             where users.users_id = @user
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
     if (!strcmp(strtrim(potype), "POP"))
       set_pop_usage(id, -1);
 
     if (!strcmp(argv[1], "POP")) {
        status = name_to_id(box, "MACHINE", &id);
-       if (status == SMS_NO_MATCH)
-         return(SMS_MACHINE);
+       if (status == MR_NO_MATCH)
+         return(MR_MACHINE);
        else if (status)
          return(status);
 ##     repeat replace users (#potype = "POP", pop_id = @id)
@@ -1585,9 +1692,9 @@ int set_pobox(q, argv, cl)
        set_pop_usage(id, 1);
     } else if (!strcmp(argv[1], "SMTP")) {
        if (index(box, '/') || index(box, '|'))
-         return(SMS_BAD_CHAR);
+         return(MR_BAD_CHAR);
        status = name_to_id(box, "STRING", &id);
-       if (status == SMS_NO_MATCH) {
+       if (status == MR_NO_MATCH) {
 ##          repeat retrieve (id = values.value) where values.name = "strings_id"
            id++;
 ##          repeat replace values (value = @id) where values.name = "strings_id"
@@ -1603,8 +1710,8 @@ int set_pobox(q, argv, cl)
     set_pobox_modtime(q, argv, cl);
 ##  repeat replace tblstats (updates = tblstats.updates + 1, modtime = "now")
 ##     where tblstats.#table = "users"
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1637,9 +1744,9 @@ get_list_info(q, aargv, cl, action, actarg)
        sq_save_data(sq, id);
        rowcount++;
 ##  }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
     if (rowcount == 0)
-      return(SMS_NO_MATCH);
+      return(MR_NO_MATCH);
 
     argv[0] = listname; argv[1] = active; argv[2] = public; argv[3] = hidden;
     argv[4] = maillist; argv[5] = group; argv[6] = gid; argv[7] = acl_type;
@@ -1657,7 +1764,7 @@ get_list_info(q, aargv, cl, action, actarg)
 ##             desc = l.#desc, modtime = l.#modtime, modby_id = l.#modby,
 ##             modwith =l.#modwith)
 ##         where l.list_id = @id
-       if (ingres_errno) return(sms_errcode);
+       if (ingres_errno) return(mr_errcode);
 
        if (atoi(gid) == -1)
            argv[6] = UNIQUE_GID;
@@ -1678,16 +1785,16 @@ get_list_info(q, aargv, cl, action, actarg)
            free(argv[8]);
            argv[8] = strsave("???");
        }
-       if (status && status != SMS_NO_MATCH) return(status);
+       if (status && status != MR_NO_MATCH) return(status);
 
        argv[11] = malloc(0);
        if (modby_id > 0)
          status = id_to_name(modby_id, "USER", &argv[11]);
        else
          status = id_to_name(-modby_id, "STRING", &argv[11]);
-       if (status && status != SMS_NO_MATCH) return(status);
+       if (status && status != MR_NO_MATCH) return(status);
 
-       sms_trim_args(q->vcnt, argv);
+       mr_trim_args(q->vcnt, argv);
        returned++;
        (*action)(q->vcnt, argv, actarg);
        free(argv[8]);
@@ -1695,8 +1802,8 @@ get_list_info(q, aargv, cl, action, actarg)
     }
 
     sq_destroy(sq);
-    if (ingres_errno) return(sms_errcode);
-    return (SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return (MR_SUCCESS);
 ##}
 
 
@@ -1704,7 +1811,7 @@ get_list_info(q, aargv, cl, action, actarg)
  * how many different ancestors a member is allowed to have.
  */
 
-#define MAXLISTDEPTH   100
+#define MAXLISTDEPTH   1024
 
 int add_member_to_list(q, argv, cl)
     struct query *q;
@@ -1728,14 +1835,14 @@ int add_member_to_list(q, argv, cl)
 ##                        m.member_id = @mid and m.member_type = @mtype
 ##                        and m.direct = 1))
     if (exists)
-      return(SMS_EXISTS);
+      return(MR_EXISTS);
     if (!strcasecmp(mtype, "STRING")) {
        buf = malloc(0);
        status = id_to_name(mid, "STRING", &buf);
        if (status) return(status);
        if (index(buf, '/') || index(buf, '|')) {
            free(buf);
-           return(SMS_BAD_CHAR);
+           return(MR_BAD_CHAR);
        }
        free(buf);
     }
@@ -1751,9 +1858,9 @@ int add_member_to_list(q, argv, cl)
 ##         endretrieve
        }
 ##  }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
     if (acount >= MAXLISTDEPTH) {
-       return(SMS_INTERNAL);
+       return(MR_INTERNAL);
     }
     descendants[0] = mid;
     dtypes[0] = mtype;
@@ -1788,9 +1895,9 @@ int add_member_to_list(q, argv, cl)
 ##             endretrieve
            }
 ##     }
-       if (ingres_errno) return(sms_errcode);
+       if (ingres_errno) return(mr_errcode);
        if (error)
-         return(SMS_INTERNAL);
+         return(MR_INTERNAL);
     }
     for (a = 0; a < acount; a++) {
        lid = ancestors[a];
@@ -1798,7 +1905,7 @@ int add_member_to_list(q, argv, cl)
            mid = descendants[d];
            mtype = dtypes[d];
            if (mid == lid && !strcmp(mtype, "LIST")) {
-               return(SMS_LISTLOOP);
+               return(MR_LISTLOOP);
            }
 ##         repeat retrieve (exists = any(m.ref_count where m.list_id = @lid
 ##                                      and m.member_id = @mid
@@ -1833,8 +1940,8 @@ int add_member_to_list(q, argv, cl)
     who = cl->client_id;
 ##  repeat replace list (modtime = "now", modby = @who, modwith = @entity)
 ##      where list.#list_id = @lid
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1861,9 +1968,9 @@ int delete_member_from_list(q, argv, cl)
 ##  repeat retrieve (exists = any(m.list_id where m.list_id=@lid and 
 ##                        m.member_id = @mid and m.member_type = @mtype
 ##                        and m.direct = 1))
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
     if (!exists)
-      return(SMS_NO_MATCH);
+      return(MR_NO_MATCH);
     ancestors[0] = lid;
     aref[0] = 1;
     acount = 1;
@@ -1874,9 +1981,9 @@ int delete_member_from_list(q, argv, cl)
        if (acount >= MAXLISTDEPTH)
 ##       endretrieve
 ##  }
-         if (ingres_errno) return(sms_errcode);
+         if (ingres_errno) return(mr_errcode);
     if (acount >= MAXLISTDEPTH)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
     descendants[0] = mid;
     dtypes[0] = mtype;
     dref[0] = 1;
@@ -1908,9 +2015,9 @@ int delete_member_from_list(q, argv, cl)
            if (dcount >= MAXLISTDEPTH)
 ##           endretrieve
 ##     }
-             if (ingres_errno) return(sms_errcode);
+             if (ingres_errno) return(mr_errcode);
        if (error)
-         return(SMS_INTERNAL);
+         return(MR_INTERNAL);
     }
     for (a = 0; a < acount; a++) {
        lid = ancestors[a];
@@ -1918,7 +2025,7 @@ int delete_member_from_list(q, argv, cl)
            mid = descendants[d];
            mtype = dtypes[d];
            if (mid == lid && !strcmp(mtype, "LIST")) {
-               return(SMS_LISTLOOP);
+               return(MR_LISTLOOP);
            }
 ##         repeat retrieve (cnt = m.ref_count)
 ##             where m.list_id = @lid and m.member_id = @mid
@@ -1948,8 +2055,8 @@ int delete_member_from_list(q, argv, cl)
     who = cl->client_id;
 ##  repeat replace list (modtime = "now", modby = @who, modwith = @entity)
 ##      where list.#list_id = @lid
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -1991,7 +2098,7 @@ int get_ace_use(q, argv, cl, action, actarg)
 ##     }
        /* now process each one */
        while (sq_get_data(sq, &id)) {
-           if (get_ace_internal("LIST", id, action, actarg) == SMS_SUCCESS)
+           if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
              found++;
        }
     }
@@ -2003,10 +2110,10 @@ int get_ace_use(q, argv, cl, action, actarg)
 ##     }
        /* now process each one */
        while (sq_get_data(sq, &id)) {
-           if (get_ace_internal("LIST", id, action, actarg) == SMS_SUCCESS)
+           if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
              found++;
        }
-       if (get_ace_internal("USER", aid, action, actarg) == SMS_SUCCESS)
+       if (get_ace_internal("USER", aid, action, actarg) == MR_SUCCESS)
          found++;
     }
 
@@ -2017,17 +2124,17 @@ int get_ace_use(q, argv, cl, action, actarg)
 ##     }
        /* now process each one */
        while (sq_get_data(sq, &id)) {
-           if (get_ace_internal("LIST", id, action, actarg) == SMS_SUCCESS)
+           if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
              found++;
        }
-       if (get_ace_internal("KERBEROS", aid, action, actarg) == SMS_SUCCESS)
+       if (get_ace_internal("KERBEROS", aid, action, actarg) == MR_SUCCESS)
          found++;
     }
 
     sq_destroy(sq);    
-    if (ingres_errno) return(sms_errcode);
-    if (!found) return(SMS_NO_MATCH);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    if (!found) return(MR_NO_MATCH);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -2101,8 +2208,8 @@ int get_ace_use(q, argv, cl, action, actarg)
         found++;
 ##  }
 
-    if (!found) return(SMS_NO_MATCH);
-    return(SMS_SUCCESS);
+    if (!found) return(MR_NO_MATCH);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -2173,9 +2280,9 @@ int get_lists_of_member(q, argv, cl, action, actarg)
 ##    }
     }
 
-    if (ingres_errno) return(sms_errcode);
-    if (!found) return(SMS_NO_MATCH);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    if (!found) return(MR_NO_MATCH);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -2215,55 +2322,101 @@ get_members_of_list(q, argv, cl, action, actarg)
     int (*action)();
     int actarg;
 ##{
-##  int list_id;
-##  char member_name[129];
+##  int list_id, member_id;
+##  char member_name[129], member_type[9];
     char *targv[2];
+    int members;
+    struct save_queue *sq;
 
     list_id = *(int *)argv[0];
-    targv[0] = "USER";
-    targv[1] = member_name;
+    members = 0;
+    sq = sq_create();
 
+##  repeat retrieve (member_type = imembers.#member_type,
+##                  member_id = imembers.#member_id)
+##     where imembers.#list_id = @list_id and imembers.direct = 1 {
+      if (members++ > 49)
+##     endretrieve
+      sq_save_data(sq, (member_type[0] << 24) | (member_id & 0xffffff));
+##  }
+    if (members <= 49) {
+       targv[1] = malloc(0);
+       while (sq_remove_data(sq, &member_id)) {
+           switch (member_id >> 24) {
+           case 'U':
+               targv[0] = "USER";
+               id_to_name(member_id & 0xffffff, "USER", &targv[1]);
+               (*action)(2, targv, actarg);
+               break;
+           case 'L':
+               targv[0] = "LIST";
+               id_to_name(member_id & 0xffffff, "LIST", &targv[1]);
+               (*action)(2, targv, actarg);
+               break;
+           case 'S':
+               targv[0] = "STRING";
+               id_to_name(member_id & 0xffffff, "STRING", &targv[1]);
+               (*action)(2, targv, actarg);
+               break;
+           case 'K':
+               targv[0] = "KERBEROS";
+               id_to_name(member_id & 0xffffff, "STRING", &targv[1]);
+               (*action)(2, targv, actarg);
+               break;
+           default:
+               sq_destroy(sq);
+               return(MR_INTERNAL);
+           }
+       }
+       free(targv[1]);
+       sq_destroy(sq);
+       return(MR_SUCCESS);
+    }
+    sq_destroy(sq);
+
+    targv[1] = member_name;
+    targv[0] = "USER";
 ##  range of m is imembers
 ##  repeat retrieve (member_name = users.login)
-##             where m.#list_id = @list_id and m.member_type = "USER"
-##                   and m.member_id = users.users_id and m.direct = 1
+##             where m.#list_id = @list_id and m.#member_type = "USER"
+##                   and m.#member_id = users.users_id and m.direct = 1
 ##             sort by #member_name
 ##  {
         (*action)(2, targv, actarg);
 ##  }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 
     targv[0] = "LIST";
 ##  repeat retrieve (member_name = list.name)
-##             where m.#list_id = @list_id and m.member_type = "LIST"
-##                   and m.member_id = list.#list_id and m.direct = 1
+##             where m.#list_id = @list_id and m.#member_type = "LIST"
+##                   and m.#member_id = list.#list_id and m.direct = 1
 ##             sort by #member_name
 ##  {
         (*action)(2, targv, actarg);
 ##  }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 
     targv[0] = "STRING";
 ##  repeat retrieve (member_name = strings.string)
-##             where m.#list_id = @list_id and m.member_type = "STRING"
-##                   and m.member_id = strings.string_id and m.direct = 1
+##             where m.#list_id = @list_id and m.#member_type = "STRING"
+##                   and m.#member_id = strings.string_id and m.direct = 1
 ##             sort by #member_name
 ##  {
         (*action)(2, targv, actarg);
 ##  }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 
     targv[0] = "KERBEROS";
 ##  repeat retrieve (member_name = strings.string)
-##             where m.#list_id = @list_id and m.member_type = "KERBEROS"
-##                   and m.member_id = strings.string_id and m.direct = 1
+##             where m.#list_id = @list_id and m.#member_type = "KERBEROS"
+##                   and m.#member_id = strings.string_id and m.direct = 1
 ##             sort by #member_name
 ##  {
         (*action)(2, targv, actarg);
 ##  }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -2286,10 +2439,10 @@ int count_members_of_list(q, argv, cl, action, actarg)
 ##  repeat retrieve (ct = count(imembers.list_id
 ##                             where imembers.list_id = @list and
 ##                                   imembers.direct = 1))
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
     sprintf(countbuf, "%d", ct);
     (*action)(1, rargv, actarg);
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -2355,11 +2508,11 @@ int qualified_get(q, argv, action, actarg, start, range, field, flags)
 ##  retrieve (name = rvar.rfield) where qual {
        (*action)(1, rargv, actarg);
 ##  }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount")
     if (rowcount == 0)
-      return(SMS_NO_MATCH);
-    return(SMS_SUCCESS);
+      return(MR_NO_MATCH);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -2401,19 +2554,19 @@ int qualified_get_serverhost(q, argv, cl, action, actarg)
 ##  retrieve (sname = sh.service, mname = machine.name) where qual {
        (*action)(2, rargv, actarg);
 ##  }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount")
     if (rowcount == 0)
-      return(SMS_NO_MATCH);
-    return(SMS_SUCCESS);
+      return(MR_NO_MATCH);
+    return(MR_SUCCESS);
 ##}
 
 
 /* register_user - change user's login name and allocate a pobox, group,
  * filesystem, and quota for them.  The user's status must start out as 0,
  * and is left as 2.  Arguments are: user's UID, new login name, and user's
- * type for filesystem allocation (SMS_FS_STUDENT, SMS_FS_FACULTY, 
- * SMS_FS_STAFF, SMS_FS_MISC).
+ * type for filesystem allocation (MR_FS_STUDENT, MR_FS_FACULTY, 
+ * MR_FS_STAFF, MR_FS_MISC).
  */
 
 register_user(q, argv, cl)
@@ -2442,34 +2595,34 @@ register_user(q, argv, cl)
 
     /* find user */
 ##  repeat retrieve (users_id = u.#users_id)
-##     where u.#uid = @uid and (u.status = 0 or u.status = 5)
+##     where u.#uid = @uid and (u.status = 0 or u.status = 5 or u.status = 6)
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount == 0)
-      return(SMS_NO_MATCH);
+      return(MR_NO_MATCH);
     if (rowcount > 1)
-      return(SMS_NOT_UNIQUE);
+      return(MR_NOT_UNIQUE);
 
     /* check new login name */
 ##  repeat retrieve (flag = any(u.#login where u.#login = @login and
 ##                             u.#users_id != users_id))
-    if (ingres_errno) return(sms_errcode);
-    if (flag) return(SMS_IN_USE);
+    if (ingres_errno) return(mr_errcode);
+    if (flag) return(MR_IN_USE);
 ##  repeat retrieve (flag = any(l.#name where l.#name = @login))
-    if (ingres_errno) return(sms_errcode);
-    if (flag) return(SMS_IN_USE);
+    if (ingres_errno) return(mr_errcode);
+    if (flag) return(MR_IN_USE);
 ##  repeat retrieve (flag = any(filesys.#label where filesys.#label = @login))
-    if (ingres_errno) return(sms_errcode);
-    if (flag) return(SMS_IN_USE);
+    if (ingres_errno) return(mr_errcode);
+    if (flag) return(MR_IN_USE);
     com_err(whoami, 0, "new login name OK");
 
     /* choose place for pobox, put in mid */
 ##  repeat retrieve (mid = sh.mach_id, machname = m.name)
 ##    where sh.service = "POP" and m.mach_id = sh.mach_id and
 ##     sh.value2 - sh.value1 = max(sh.value2-sh.value1 where sh.service="POP")
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount == 0)
-      return(SMS_NO_POBOX);
+      return(MR_NO_POBOX);
 
     /* change login name, set pobox */
     sprintf(buffer, "u.users_id = %d", users_id);
@@ -2480,9 +2633,9 @@ register_user(q, argv, cl)
 ##                   pmodwith=@entity)
 ##     where u.#users_id = @users_id
 ##  inquire_equel(rowcount = "rowcount");
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
     if (rowcount != 1)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
     set_pop_usage(mid, 1);
     com_err(whoami, 0, "set login name to %s and pobox to %s", login,
            strtrim(machname));
@@ -2490,14 +2643,14 @@ register_user(q, argv, cl)
 
     /* create group list */
     if (set_next_object_id("gid", "list"))
-      return(SMS_NO_ID);
+      return(MR_NO_ID);
     if (set_next_object_id("list_id", "list"))
-      return(SMS_NO_ID);
+      return(MR_NO_ID);
 ##  repeat retrieve (list_id = values.value) where values.name = "list_id"
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
     incremental_clear_before();
 ##  repeat append list (name = @login, #list_id = @list_id, active = 1,
 ##                     public = 0, hidden = 0, maillist = 0, group = 1,
@@ -2505,10 +2658,10 @@ register_user(q, argv, cl)
 ##                     acl_type = "USER", acl_id = @users_id, modtime = "now",
 ##                     modby = @who, modwith = @entity)
 ##     where values.name = "gid"
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
     sprintf(buffer, "l.list_id = %d", list_id);
     incremental_after("list", buffer, 0);
     aargv[0] = (char *) list_id;
@@ -2517,10 +2670,10 @@ register_user(q, argv, cl)
     incremental_clear_before();
 ##  repeat append imembers (#list_id = @list_id, member_type = "USER",
 ##                        member_id = @users_id, ref_count = 1, direct = 1)
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
     incremental_after("members", 0, aargv);
     com_err(whoami, 0, "group list created");
 
@@ -2538,13 +2691,13 @@ register_user(q, argv, cl)
            m_id = mid;
        }
 ##  }
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
     if (maxsize == 0)
-      return(SMS_NO_FILESYS);
+      return(MR_NO_FILESYS);
 
     /* create filesystem */
     if (set_next_object_id("filsys_id", "filesys"))
-      return(SMS_NO_ID);
+      return(MR_NO_ID);
     incremental_clear_before();        
 ##  repeat append filesys (filsys_id = values.value, phys_id = @pid,
 ##                        label = @login, type = "NFS", mach_id = @m_id,
@@ -2555,10 +2708,10 @@ register_user(q, argv, cl)
 ##                        lockertype = "HOMEDIR", modtime = "now",
 ##                        modby = @who, modwith = @entity)
 ##     where values.name = "filsys_id"
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
     incremental_after("filesys", 
          "fs.filsys_id = values.value and values.name = \"filsys_id\"",
                      0);
@@ -2567,32 +2720,34 @@ register_user(q, argv, cl)
 
     /* set quota */
 ##  repeat retrieve (quota = values.value) where values.name = "def_quota"
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
-      return(SMS_NO_QUOTA);
+      return(MR_NO_QUOTA);
     incremental_clear_before();
-##  repeat append nfsquota (#users_id = @users_id, filsys_id = values.value,
-##                         #quota = @quota, phys_id = @pid, modtime = "now",
-##                         modby = @who, modwith = @entity)
+##  repeat append #quota (entity_id = @users_id, filsys_id = values.value,
+##                       type = "USER",
+##                       #quota = @quota, phys_id = @pid, modtime = "now",
+##                       modby = @who, modwith = @entity)
 ##     where values.name = "filsys_id"
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
 ##  repeat replace nfsphys (allocated = nfsphys.allocated + @quota)
 ##     where nfsphys.nfsphys_id = filesys.#phys_id and
 ##           filesys.filsys_id = values.value and values.name = "filsys_id"
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
-      return(SMS_INTERNAL);
+      return(MR_INTERNAL);
     aargv[0] = login;
-    aargv[1] = login;
-    sprintf(buffer, "nq.users_id = %d and nq.filsys_id = values.value and values.name = \"filsys_id\"", users_id);
-    incremental_after("nfsquota", buffer, aargv);
+    aargv[1] = "USER";
+    aargv[2] = login;
+    sprintf(buffer, "q.entity_id = %d and q.filsys_id = values.value and q.type = \"USER\" and values.name = \"filsys_id\"", users_id);
+    incremental_after("quota", buffer, aargv);
     com_err(whoami, 0, "quota of %d assigned", quota);
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 
     cache_entry(login, "USER", users_id);
 
@@ -2600,9 +2755,9 @@ register_user(q, argv, cl)
 ##     where tblstats.table = "users"
 ##  repeat replace tblstats (appends = tblstats.appends + 1, modtime = "now")
 ##     where tblstats.table = "list" or tblstats.table = "filesys" or
-##           tblstats.table = "nfsquota"
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+##           tblstats.table = "quota"
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -2628,8 +2783,8 @@ int count;
 ##  repeat replace serverhosts (value1 = serverhosts.value1 + @n)
 ##         where serverhosts.service = "POP" and serverhosts.#mach_id = @mach_id
 
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 ##}
 
 
@@ -2662,10 +2817,10 @@ validate_row(q, argv, v)
     /* look for the record */
 ##  range of rvar is table
 ##  retrieve (rowcount = count(rvar.name where qual))
-    if (ingres_errno) return(sms_errcode);
-    if (rowcount == 0) return(SMS_NO_MATCH);
-    if (rowcount > 1) return(SMS_NOT_UNIQUE);
-    return(SMS_EXISTS);
+    if (ingres_errno) return(mr_errcode);
+    if (rowcount == 0) return(MR_NO_MATCH);
+    if (rowcount > 1) return(MR_NOT_UNIQUE);
+    return(MR_EXISTS);
 ##}
 
 validate_fields(q, argv, vo, n)
@@ -2726,7 +2881,7 @@ validate_fields(q, argv, vo, n)
            break;
 
        case V_SORT:
-           status = SMS_EXISTS;
+           status = MR_EXISTS;
            break;
 
        case V_LOCK:
@@ -2734,12 +2889,12 @@ validate_fields(q, argv, vo, n)
            break;
        }
 
-       if (status != SMS_EXISTS) return(status);
+       if (status != MR_EXISTS) return(status);
        vo++;
     }
 
-    if (ingres_errno) return(sms_errcode);
-    return(SMS_SUCCESS);
+    if (ingres_errno) return(mr_errcode);
+    return(MR_SUCCESS);
 }
 
 
@@ -2771,8 +2926,8 @@ register char *s;
 {
     while (*s)
       if (illegalchars[*s++])
-       return(SMS_BAD_CHAR);
-    return(SMS_EXISTS);
+       return(MR_BAD_CHAR);
+    return(MR_EXISTS);
 }
 
 
@@ -2805,8 +2960,8 @@ validate_id(argv, vo)
        status = name_to_id(name, table, &id);
        if (status == 0) {
            *(int *)argv[vo->index] = id;
-           return(SMS_EXISTS);
-       } else if (status == SMS_NO_MATCH || status == SMS_NOT_UNIQUE)
+           return(MR_EXISTS);
+       } else if (status == MR_NO_MATCH || status == MR_NOT_UNIQUE)
          return(vo->error);
        else
          return(status);
@@ -2814,16 +2969,16 @@ validate_id(argv, vo)
 
     if (!strcmp(namefield, "uid")) {
 ##    retrieve (id = table.idfield) where table.namefield = int4(name)
-      if (ingres_errno) return(sms_errcode);
+      if (ingres_errno) return(mr_errcode);
 ##    inquire_equel (rowcount = "rowcount")
     } else {
 ##    retrieve (id = table.idfield) where table.namefield = name
-      if (ingres_errno) return(sms_errcode);
+      if (ingres_errno) return(mr_errcode);
 ##    inquire_equel (rowcount = "rowcount")
     }
     if (rowcount != 1) return(vo->error);
     *(int *)argv[vo->index] = id;
-    return(SMS_EXISTS);
+    return(MR_EXISTS);
 ##}
 
 validate_name(argv, vo)
@@ -2846,8 +3001,8 @@ validate_name(argv, vo)
     }
 ##  retrieve (rowcount = countu(table.namefield 
 ##            where table.namefield = name))
-    if (ingres_errno) return(sms_errcode);
-    return ((rowcount == 1) ? SMS_EXISTS : vo->error);
+    if (ingres_errno) return(mr_errcode);
+    return ((rowcount == 1) ? MR_EXISTS : vo->error);
 ##}
 
 validate_date(argv, vo)
@@ -2862,8 +3017,8 @@ validate_date(argv, vo)
 
 ##  retrieve (dd = interval("years", date(idate) - date("today")))
 ##  inquire_equel (errorno = "errorno")
-    if (errorno != 0 || dd > 5.0) return(SMS_DATE);
-    return(SMS_EXISTS);
+    if (errorno != 0 || dd > 5.0) return(MR_DATE);
+    return(MR_EXISTS);
 ##}
 
 
@@ -2879,7 +3034,7 @@ struct valobj *vo;
     c = name = argv[vo->index];
     while (*c)
       if (illegalchars[*c++])
-       return(SMS_BAD_CHAR);
+       return(MR_BAD_CHAR);
     table = vo->table;
     /* minor kludge to upcasify machine names */
     if (!strcmp(table, "machine"))
@@ -2889,17 +3044,17 @@ struct valobj *vo;
     id = -1;
     if (idfield == 0) {
        if (!strcmp(argv[vo->index], argv[vo->index - 1]))
-         return(SMS_EXISTS);
+         return(MR_EXISTS);
 ##     retrieve (id = any(table.namefield where table.namefield = name))
-       if (ingres_errno) return(sms_errcode);
+       if (ingres_errno) return(mr_errcode);
        if (id)
          return(vo->error);
        else
-         return(SMS_EXISTS);
+         return(MR_EXISTS);
     }
     status = name_to_id(name, table, &id);
-    if (status == SMS_NO_MATCH || id == *(int *)argv[vo->index - 1])
-      return(SMS_EXISTS);
+    if (status == MR_NO_MATCH || id == *(int *)argv[vo->index - 1])
+      return(MR_EXISTS);
     else
       return(vo->error);
 ##}
@@ -2918,15 +3073,15 @@ validate_type(argv, vo)
     c = value = argv[vo->index];
     while (*c)
       if (illegalchars[*c++])
-       return(SMS_BAD_CHAR);
+       return(MR_BAD_CHAR);
 
     /* uppercase type fields */
     for (c = value; *c; c++) if (islower(*c)) *c = toupper(*c);
 
 ##  repeat retrieve (exists = any(alias.trans where alias.name = @typename and
 ##                               alias.type = "TYPE" and alias.trans = @value))
-    if (ingres_errno) return(sms_errcode);
-    return (exists ? SMS_EXISTS : vo->error);
+    if (ingres_errno) return(mr_errcode);
+    return (exists ? MR_EXISTS : vo->error);
 ##}
 
 /* validate member or type-specific data field */
@@ -2953,9 +3108,9 @@ validate_typedata(q, argv, vo)
     /* get corresponding data type associated with field type name */
 ##  repeat retrieve (data_type = alias.trans) 
 ##         where alias.#name = @field_type and alias.type = "TYPEDATA"
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel (rowcount = "rowcount")
-    if (rowcount != 1) return(SMS_TYPE);
+    if (rowcount != 1) return(MR_TYPE);
 
     /* now retrieve the record id corresponding to the named object */
     if (index(data_type, ' '))
@@ -2963,15 +3118,15 @@ validate_typedata(q, argv, vo)
     if (!strcmp(data_type, "user")) {
        /* USER */
        status = name_to_id(name, data_type, &id);
-       if (status && (status == SMS_NO_MATCH || status == SMS_NOT_UNIQUE))
-         return(SMS_USER);
+       if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
+         return(MR_USER);
        if (status) return(status);
     } else if (!strcmp(data_type, "list")) {
        /* LIST */
        status = name_to_id(name, data_type, &id);
-       if (status && status == SMS_NOT_UNIQUE)
-         return(SMS_LIST);
-       if (status == SMS_NO_MATCH) {
+       if (status && status == MR_NOT_UNIQUE)
+         return(MR_LIST);
+       if (status == MR_NO_MATCH) {
            /* if idfield is non-zero, then if argv[0] matches the string
             * that we're trying to resolve, we should get the value of
             * values.[idfield] for the id.
@@ -2981,24 +3136,24 @@ validate_typedata(q, argv, vo)
                name = vo->idfield;
 ##             repeat retrieve (id = values.value) where values.#name = @name
 ##             inquire_equel(rowcount = "rowcount")
-               if (rowcount != 1) return(SMS_LIST);
+               if (rowcount != 1) return(MR_LIST);
            } else
-             return(SMS_LIST);
+             return(MR_LIST);
        } else if (status) return(status);
     } else if (!strcmp(data_type, "machine")) {
        /* MACHINE */
        for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
        status = name_to_id(name, data_type, &id);
-       if (status && (status == SMS_NO_MATCH || status == SMS_NOT_UNIQUE))
-         return(SMS_MACHINE);
+       if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
+         return(MR_MACHINE);
        if (status) return(status);
     } else if (!strcmp(data_type, "string")) {
        /* STRING */
        status = name_to_id(name, data_type, &id);
-       if (status && status == SMS_NOT_UNIQUE)
-         return(SMS_STRING);
-       if (status == SMS_NO_MATCH) {
-           if (q->type != APPEND && q->type != UPDATE) return(SMS_STRING);
+       if (status && status == MR_NOT_UNIQUE)
+         return(MR_STRING);
+       if (status == MR_NO_MATCH) {
+           if (q->type != APPEND && q->type != UPDATE) return(MR_STRING);
 ##          retrieve (id = values.value) where values.#name = "strings_id"
            id++;
 ##          replace values (value = id) where values.#name = "strings_id"
@@ -3007,13 +3162,13 @@ validate_typedata(q, argv, vo)
     } else if (!strcmp(data_type, "none")) {
        id = 0;
     } else {
-       return(SMS_TYPE);
+       return(MR_TYPE);
     }
 
     /* now set value in argv */
     *(int *)argv[vo->index] = id;
     
-    return (SMS_EXISTS);
+    return (MR_EXISTS);
 ##}
 
 
@@ -3028,12 +3183,12 @@ struct valobj *vo;
     table = vo->table;
     idfield = vo->idfield;
 ##  replace table (modtime = "now") where table.idfield = 0
-    if (ingres_errno) return(sms_errcode);
+    if (ingres_errno) return(mr_errcode);
 ##  inquire_equel (rowcount = "rowcount")
     if (rowcount != 1)
       return(vo->error);
     else
-      return(SMS_EXISTS);
+      return(MR_EXISTS);
 ##}
 
 
This page took 0.152325 seconds and 4 git commands to generate.