]> andersk Git - moira.git/commitdiff
Cleanup (these changes were by Mike).
authorwesommer <wesommer>
Sat, 22 Aug 1987 17:47:38 +0000 (17:47 +0000)
committerwesommer <wesommer>
Sat, 22 Aug 1987 17:47:38 +0000 (17:47 +0000)
server/qrtn.qc

index 8868ce1a6950525e3071d07c67f69a0c3095e579..2e4c8d34a1aaef9c13f154379d665dae983cf542 100644 (file)
@@ -6,9 +6,12 @@
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
  *
  *     $Log$
- *     Revision 1.8  1987-08-10 16:22:26  mike
- *     wesommer modified error reporting.
+ *     Revision 1.9  1987-08-22 17:47:38  wesommer
+ *     Cleanup (these changes were by Mike).
  *
+ * Revision 1.8  87/08/10  16:22:26  mike
+ * wesommer modified error reporting.
+ * 
  * Revision 1.7  87/08/04  01:49:20  wesommer
  * Rearranged messages.
  * 
@@ -89,6 +92,7 @@ sms_check_access(cl, name, argc, argv_ro)
     struct query *get_query_by_name();
     int access_user();
     int access_pop();
+    int access_list();
 
     q = get_query_by_name(name);
     if (q == (struct query *)0) return(SMS_NO_HANDLE);
@@ -102,7 +106,8 @@ sms_check_access(cl, name, argc, argv_ro)
     status = check_query_access(q, Argv, cl);
     privileged = (status == SMS_SUCCESS) ? 1 : 0;
     if (status != SMS_SUCCESS && !(v && (v->pre_rtn == access_user ||
-                                        v->pre_rtn == access_pop))) 
+                                        v->pre_rtn == access_pop ||
+                                        v->pre_rtn == access_list))) 
        return(status);
 
     /* check argument count */
@@ -141,13 +146,18 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
     register struct validate *v;
     int privileged;
     char qual[256];
+    char sort[32];
     char *pqual;
+    char *psort;
 ##  char *table;
     struct save_queue *sq;
     struct query *get_query_by_name();
     int sq_save_args();
     struct save_queue *sq_create();
+    char *build_sort();
     int access_user();
+    int access_pop();
+    int access_list();
 
     /* copy the arguments into a local argv that we can modify */
     for (i = 0; i < argc; i++)
@@ -175,7 +185,10 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
     /* check query access */
     status = check_query_access(q, Argv, cl);
     privileged = (status == SMS_SUCCESS) ? 1 : 0;
-    if (status != SMS_SUCCESS && !(v && (v->pre_rtn == access_user)))
+    if (!privileged && !(status == SMS_PERM &&
+                        (v && (v->pre_rtn == access_user ||
+                               v->pre_rtn == access_pop ||
+                               v->pre_rtn == access_list))))
        return(status);
 
     /* check argument count */
@@ -215,13 +228,20 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
            pqual = 0;
        }
 
+       /* build "sort" clause if needed */
+       if (v && v->valobj) {
+           psort = build_sort(v, sort);
+       } else {
+           psort = 0;
+       }
+
        /* if there is a followup routine, then we must save the results */
        /* of the first query for use by the followup routine */
-       /* if q->rtable = NULL, perform post_rtn only */
-       if (table = q->rtable) {
+       /* if q->rvar = NULL, perform post_rtn only */
+       if (q->rvar) {
            if (v && v->post_rtn) {
                sq = sq_create();
-               status = do_retrieve(q, pqual, sq_save_args, sq);
+               status = do_retrieve(q, pqual, psort, sq_save_args, sq);
                if (status != SMS_SUCCESS) {
                    sq_destroy(sq);
                    break;
@@ -229,9 +249,10 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
                status = (*v->post_rtn)(q, sq, v, action, actarg);
            } else {
                /* normal retrieve */
-               status = do_retrieve(q, pqual, action, actarg);
+               status = do_retrieve(q, pqual, psort, action, actarg);
            }
            if (status != SMS_SUCCESS) break;
+           table = q->rtable;
 ##          repeat replace tblstats (retrieves = tblstats.retrieves + 1)
 ##                 where tblstats.#table = @table
        } else {
@@ -248,11 +269,12 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
        }
 
        /* build "where" clause and perform update */
-       /* if q->rtable = NULL, perform post_rtn only */
-       if (table = q->rtable) {
+       /* if q->rvar = NULL, perform post_rtn only */
+       if (q->rvar) {
            build_qual(q->qual, q->argc, Argv, qual);
            status = do_update(q, &Argv[q->argc], qual, action, actarg);
            if (status != SMS_SUCCESS) break;
+           table = q->rtable;
 ##         repeat replace tblstats (updates = tblstats.updates + 1,
 ##                                  modtime = "now")
 ##             where tblstats.#table = @table
@@ -273,11 +295,20 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
        /* increment id number if necessary */
        if (v->object_id) set_next_object_id(v->object_id);
 
+       /* build "where" clause if needed */
+       if (q->qual) {
+           build_qual(q->qual, q->argc, Argv, qual);
+           pqual = qual;
+       } else {
+           pqual = 0;
+       }
+
        /* perform the append */
-       /* if q->rtable = NULL, perform post_rtn only */
-       if (table = q->rtable) {
-           status = do_append(q, &Argv[q->argc], action, actarg);
+       /* if q->rvar = NULL, perform post_rtn only */
+       if (q->rvar) {
+           status = do_append(q, &Argv[q->argc], pqual, action, actarg);
            if (status != SMS_SUCCESS) break;
+           table = q->rtable;
 ##         repeat replace tblstats (appends = tblstats.appends + 1,
 ##                                  modtime = "now")
 ##             where tblstats.#table = @table
@@ -295,11 +326,12 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
        }
 
        /* build "where" clause and perform delete */
-       /* if q->rtable = NULL, perform post_rtn only */
-       if (table = q->rtable) {
+       /* if q->rvar = NULL, perform post_rtn only */
+       if (q->rvar) {
            build_qual(q->qual, q->argc, Argv, qual);
            status = do_delete(q, qual, action, actarg);
            if (status != SMS_SUCCESS) break;
+           table = q->rtable;
 ##         repeat replace tblstats (deletes = tblstats.deletes + 1,
 ##                                  modtime = "now")
 ##             where tblstats.#table = @table
@@ -366,6 +398,31 @@ build_qual(fmt, argc, argv, qual)
     }
 }
 
+char *
+build_sort(v, sort)
+    register struct validate *v;
+    char *sort;
+{
+    register struct valobj *vo;
+    register int n;
+    char elem[16];
+
+    n = v->objcnt;
+    vo = v->valobj;
+    *sort = 0;
+
+    while (--n >= 0) {
+       if (vo->type == V_SORT) {
+           sprintf(elem, "RET_VAR%d", vo->index + 1);
+           if (*sort) strcat(sort, ", ");
+           strcat(sort, elem);
+       }
+       vo++;
+    }
+
+    return ((*sort) ? sort : 0);
+}
+
 check_query_access(q, argv, cl)
     struct query *q;
     char *argv[];
@@ -375,6 +432,7 @@ check_query_access(q, argv, cl)
 ##  int acl_id;
 ##  int exists;
 ##  int rowcount;
+##  int errorno;
 ##  static int def_uid;
     int status;
     int client_id;
@@ -383,7 +441,8 @@ check_query_access(q, argv, cl)
     /* get query access control list */
     name = q->shortname;
 ##  repeat retrieve (acl_id = capacls.list_id) where capacls.tag = @name
-##  inquire_equel (rowcount = "rowcount")
+##  inquire_equel (rowcount = "rowcount", errorno = "errorno")
+    if (errorno != 0) return(SMS_INGRES_ERR);
     if (rowcount == 0) return(SMS_PERM);
 
     /* initialize default uid */
@@ -494,16 +553,19 @@ get_client(cl, client_type, client_id)
     }
 ##}
 
-do_retrieve(q, qual, action, actarg)
+do_retrieve(q, pqual, psort, action, actarg)
     register struct query *q;
-    char *qual;
+    char *pqual;
+    char *psort;
     int (*action)();
     char *actarg;
 ##{
 ##  char *rvar;
 ##  char *rtable;
 ##  char *cqual;
+##  char *csort;
 ##  int rowcount;
+##  int errorno;
 
     if (q->rvar) {
        rvar = q->rvar;
@@ -511,21 +573,40 @@ do_retrieve(q, qual, action, actarg)
 ##             range of rvar is rtable
     }
 
-    if (qual) {
-       cqual = qual;
-##      retrieve unique (param (q->tlist, q->vaddr)) where cqual
-##      {
-            (*action)(q->vcnt, q->vaddr, actarg);
-##      }
+    if (psort) {
+       csort = psort;
+       if (pqual) {
+           cqual = pqual;
+##          retrieve unique (param (q->tlist, q->vaddr)) where cqual
+##                   sort by csort
+##          {
+                (*action)(q->vcnt, q->vaddr, actarg);
+##          }
+       } else {
+##          retrieve unique (param (q->tlist, q->vaddr))
+##                   sort by csort
+##          {
+                (*action)(q->vcnt, q->vaddr, actarg);
+##          }
+       }
+
     } else {
-##      retrieve unique (param (q->tlist, q->vaddr))
-##      {
-            (*action)(q->vcnt, q->vaddr, actarg);
-##      }
+       if (pqual) {
+           cqual = pqual;
+##          retrieve unique (param (q->tlist, q->vaddr)) where cqual
+##          {
+                (*action)(q->vcnt, q->vaddr, actarg);
+##          }
+       } else {
+##          retrieve unique (param (q->tlist, q->vaddr))
+##          {
+                (*action)(q->vcnt, q->vaddr, actarg);
+##          }
+       }
     }
 
-##  inquire_equel (rowcount = "rowcount")
-
+##  inquire_equel (rowcount = "rowcount", errorno = "errorno")
+    if (errorno != 0) return(SMS_INGRES_ERR);
     return ((rowcount == 0) ? SMS_NO_MATCH : SMS_SUCCESS);
 ##}
 
@@ -540,6 +621,7 @@ do_update(q, argv, qual, action, actarg)
 ##  char *rtable;
 ##  char *cqual;
 ##  int rowcount;
+##  int errorno;
       
     rvar = q->rvar;
     rtable = q->rtable;
@@ -549,30 +631,36 @@ do_update(q, argv, qual, action, actarg)
 ##  replace rvar (param (q->tlist, argv))
 ##  where cqual
 
+##  inquire_equel (errorno = "errorno")
+    if (errorno != 0) return(SMS_INGRES_ERR);
     return(SMS_SUCCESS);
 ##}
 
-do_append(q, argv, action, actarg)
+do_append(q, argv, pqual, action, actarg)
     register struct query *q;
     char *argv[];
+    char *pqual;
     int (*action)();
     char *actarg;
 ##{
 ##  char *rvar;
 ##  char *rtable;
 ##  char *cqual;
+##  int errorno;
 
     rvar = q->rvar;
     rtable = q->rtable;
 ##  range of rvar is rtable
 
-    if (q->qual) {
-       cqual = q->qual;
+    if (pqual) {
+       cqual = pqual;
 ##      append to rtable (param (q->tlist, argv)) where cqual
     } else {
 ##      append to rtable (param (q->tlist, argv))
     }
 
+##  inquire_equel (errorno = "errorno")
+    if (errorno != 0) return(SMS_INGRES_ERR);
     return(SMS_SUCCESS);
 ##}
 
@@ -585,6 +673,7 @@ do_delete(q, qual, action, actarg)
 ##  char *rvar;
 ##  char *rtable;
 ##  char *cqual;
+##  int errorno;
 
     rvar = q->rvar;
     rtable = q->rtable;
@@ -593,6 +682,8 @@ do_delete(q, qual, action, actarg)
     cqual = qual;
 ##  delete rvar where cqual
 
+##  inquire_equel (errorno = "errorno")
+    if (errorno != 0) return(SMS_INGRES_ERR);
     return(SMS_SUCCESS);
 ##}
 
This page took 0.065207 seconds and 5 git commands to generate.