]> andersk Git - moira.git/blobdiff - server/qsupport.pc
Punt on the "NONE" stuff; the TNS folks decided they liked empty fields more.
[moira.git] / server / qsupport.pc
index aa041caec950e31ba7f853569c08420c78d9abc0..c133a0ee6a25d945a40322c7a1e71508631aaaaa 100644 (file)
@@ -272,6 +272,9 @@ int add_member_to_list(struct query *q, char **argv, client *cl)
            case 'K':
              dtypes[dcount] = "KERBEROS";
              break;
+           case 'M':
+             dtypes[dcount] = "MACHINE";
+             break;
            default:
              error++;
              break;
@@ -444,6 +447,9 @@ int delete_member_from_list(struct query *q, char **argv, client *cl)
            case 'K':
              dtypes[dcount] = "KERBEROS";
              break;
+           case 'M':
+             dtypes[dcount] = "MACHINE";
+             break;
            default:
              error++;
              break;
@@ -1036,10 +1042,11 @@ int get_host_by_owner(struct query *q, char *argv[], client *cl,
 
 /* get_lists_of_member - given a type and a name, return the name and flags
  * of all of the lists of the given member.  The member_type is one of
- * "LIST", "USER", "STRING", "RLIST", "RUSER", or "RSTRING" in argv[0],
- * and argv[1] will contain the ID of the entity in question.  The R*
- * types mean to recursively look at every containing list, not just
- * when the object in question is a direct member.
+ * "LIST", "USER", "STRING", "KERBEROS", "MACHINE", "RLIST", "RUSER", 
+ * "RSTRING", "RKERBEROS", or "RMACHINE" in argv[0], and argv[1] will contain 
+ * the ID of the entity in question.  The R* types mean to recursively look 
+ * at every containing list, not just when the object in question is a direct 
+ * member.
  */
 
 int get_lists_of_member(struct query *q, char *argv[], client *cl,
@@ -1076,6 +1083,11 @@ int get_lists_of_member(struct query *q, char *argv[], client *cl,
       atype = "KERBEROS";
       direct = 0;
     }
+  if (!strcmp(atype, "RMACHINE"))
+    {
+      atype = "MACHINE";
+      direct = 0;
+    }
 
   rargv[0] = name;
   rargv[1] = active;
@@ -1269,6 +1281,28 @@ int get_members_of_list(struct query *q, char *argv[], client *cl,
   if (dbms_errno)
     return mr_errcode;
 
+  targv[0] = "MACHINE";
+  EXEC SQL DECLARE csr123 CURSOR FOR
+    SELECT m.name, s.string FROM machine m, imembers im, strings s
+    WHERE im.list_id = :list_id AND im.member_type = 'MACHINE'
+    AND im.member_id = m.mach_id AND im.direct > :direct
+    AND s.string_id = im.tag ORDER BY 1;
+  if (dbms_errno)
+    return mr_errcode;
+  EXEC SQL OPEN csr123;
+  if (dbms_errno)
+    return mr_errcode;
+  while (1)
+    {
+      EXEC SQL FETCH csr123 INTO :member_name, :tag;
+      if (sqlca.sqlcode)
+       break;
+      (*action)(targc, targv, actarg);
+    }
+  EXEC SQL CLOSE csr123;
+  if (dbms_errno)
+    return mr_errcode;
+
   return MR_SUCCESS;
 }
 
@@ -1627,7 +1661,8 @@ int register_user(struct query *q, char **argv, client *cl)
     nstatus = 1;
   EXEC SQL UPDATE users SET login = :login, status = :nstatus,
     modtime = SYSDATE, modby = :who, modwith = :entity,
-    pmodtime = SYSDATE, pmodby = :who, pmodwith = :entity
+    pmodtime = SYSDATE, pmodby = :who, pmodwith = :entity,
+    created = SYSDATE, creator = :who
     WHERE users_id = :users_id;
 
   if (dbms_errno)
@@ -1862,6 +1897,7 @@ int update_container(struct query *q, char *argv[], client *cl)
   char* tmpchar;
   int cnt, childid;
   char childname[CONTAINERS_NAME_SIZE];
+  char *qual;
 
   cnt_id = *(int *)argv[0];
   newname = argv[1];
@@ -1882,6 +1918,10 @@ int update_container(struct query *q, char *argv[], client *cl)
   /* trim off the trailing spaces */
    strcpy(name, strtrim(name));
 
+   qual = xmalloc(MAX_FIELD_WIDTH);    
+   sprintf(qual, "name = '%s'", name);
+   incremental_before(CONTAINERS_TABLE, qual, argv);
+
   /* if we are renaming the container */
   if (strcmp(name, newname))
   {
@@ -1955,6 +1995,9 @@ int update_container(struct query *q, char *argv[], client *cl)
 
   if (dbms_errno)
     return mr_errcode;
+
+  sprintf(qual, "name = '%s'", newname);
+  incremental_after(CONTAINERS_TABLE, qual, argv);
     
   return MR_SUCCESS;
 }
@@ -1976,7 +2019,7 @@ int get_machines_of_container(struct query *q, char *argv[], client *cl,
   rargv[1] = containername;
 
   cnt_id = *(int *)argv[0];
-  isrecursive = *(int *)argv[1];
+  isrecursive = atoi(argv[1]);
 
   /* get the container name */
   
@@ -2030,14 +2073,14 @@ int get_subcontainers_of_container(struct query *q, char *argv[], client *cl,
   char *qs;
   EXEC SQL END DECLARE SECTION;
 
-  char querystring[512], tmp [256];
+  char querystring[2048], tmp [1024];
   char *rargv[1];
   int found = 0;
   
   rargv[0] = subcontainername;
 
   cnt_id = *(int *)argv[0];
-  isrecursive = *(int *)argv[1];
+  isrecursive = atoi(argv[1]);
 
   /* get the container name */
   
This page took 0.038023 seconds and 4 git commands to generate.