]> andersk Git - moira.git/blobdiff - server/qfollow.pc
Include object ids in args for incremental programs.
[moira.git] / server / qfollow.pc
index 0c3a9a68d1c69179769bd43b5915428b11f4b6df..09a9d1af4629e8f81538e8c4a2cc289bb4e63c29 100644 (file)
@@ -280,6 +280,28 @@ int set_zephyr_modtime(struct query *q, char *argv[], client *cl)
   return MR_SUCCESS;
 }
 
+/* sets the modtime on an entry in services table, where argv[0] contains
+ * the service name.
+ */
+
+int set_service_modtime(struct query *q, char *argv[], client *cl)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  char *service, *protocol, *entity;
+  int who;
+  EXEC SQL END DECLARE SECTION;
+
+  entity = cl->entity;
+  who = cl->client_id; 
+
+  service = argv[0];
+  protocol = argv[1];
+
+  EXEC SQL UPDATE services SET modtime = SYSDATE, modby = :who,
+    modwith = :entity WHERE name = :service AND protocol = :protocol;
+
+  return MR_SUCCESS;
+}
 
 /* fixes the modby field.  This will be the second to last thing in the
  * argv, the argv length is determined from the query structure.  It is
@@ -318,9 +340,9 @@ int followup_fix_modby(struct query *q, struct save_queue *sq,
  **
  ** Inputs:
  **    argv[0] - login (add_user)
- **    argv[3] - last name
- **    argv[4] - first name
- **    argv[5] - middle name
+ **    argv[U_LAST] - last name
+ **    argv[U_FIRST] - first name
+ **    argv[U_MIDDLE] - middle name
  **
  **/
 
@@ -333,12 +355,13 @@ int followup_ausr(struct query *q, char *argv[], client *cl)
   EXEC SQL END DECLARE SECTION;
 
   /* build fullname */
-  if (strlen(argv[4]) && strlen(argv[5]))
-    sprintf(fullname, "%s %s %s", argv[4], argv[5], argv[3]);
-  else if (strlen(argv[4]))
-    sprintf(fullname, "%s %s", argv[4], argv[3]);
+  if (strlen(argv[U_FIRST]) && strlen(argv[U_MIDDLE]))
+    sprintf(fullname, "%s %s %s", argv[U_FIRST], argv[U_MIDDLE], 
+           argv[U_LAST]);
+  else if (strlen(argv[U_FIRST]))
+    sprintf(fullname, "%s %s", argv[U_FIRST], argv[U_LAST]);
   else
-    sprintf(fullname, "%s", argv[3]);
+    sprintf(fullname, "%s", argv[U_LAST]);
 
   login = argv[0];
   who = cl->client_id;
@@ -371,7 +394,7 @@ int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
   char *ptype, *p;
   int mid, sid, status, i;
   EXEC SQL BEGIN DECLARE SECTION;
-  int users_id;
+  int users_id, pid, iid, bid;
   char mach[MACHINE_NAME_SIZE], fs[FILESYS_LABEL_SIZE];
   char str[STRINGS_STRING_SIZE];
   EXEC SQL END DECLARE SECTION;
@@ -383,43 +406,69 @@ int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
       ptype = argv[1];
       users_id = atoi(argv[2]);
 
-      if (!strcmp(ptype, "POP"))
+      EXEC SQL SELECT pop_id, imap_id, box_id INTO :pid, :iid, :bid
+       FROM users WHERE users_id = :users_id;
+      if (sqlca.sqlcode)
+       return MR_USER;
+
+      if (ptype[0] == 'S')
        {
+         /* SMTP or SPLIT */
+         EXEC SQL SELECT string INTO :str FROM strings
+           WHERE string_id = :bid;
+         if (sqlca.sqlcode)
+           return MR_STRING;
+
+         /* If SMTP, don't bother fetching IMAP and POP boxes. */
+         if (ptype[1] == 'M')
+           pid = iid = 0;
+       }
+      if (iid)
+       {
+         /* IMAP, or SPLIT with IMAP */
+         EXEC SQL SELECT f.label, m.name INTO :fs, :mach
+           FROM filesys f, machine m
+           WHERE f.filsys_id = :iid AND f.mach_id = m.mach_id;
+         if (sqlca.sqlcode)
+           return MR_FILESYS;
+       }
+      if (pid)
+       {
+         /* POP, or SPLIT with POP */
          EXEC SQL SELECT m.name INTO :mach FROM machine m, users u
            WHERE u.users_id = :users_id AND u.pop_id = m.mach_id;
          if (sqlca.sqlcode)
            return MR_MACHINE;
-         free(argv[2]);
+       }
+
+      free(argv[2]);
+      free(argv[3]);
+
+      /* Now assemble the right answer. */
+      if (!strcmp(ptype, "POP"))
+       {
          argv[2] = xstrdup(strtrim(mach));
-         free(argv[3]);
          argv[3] = xmalloc(strlen(argv[0]) + strlen(argv[2]) + 2);
          sprintf(argv[3], "%s@%s", argv[0], argv[2]);
        }
       else if (!strcmp(ptype, "SMTP"))
        {
-         EXEC SQL SELECT s.string INTO :str FROM strings s, users u
-           WHERE u.users_id = :users_id AND u.box_id = s.string_id;
-         if (sqlca.sqlcode)
-           return MR_STRING;
-         free(argv[2]);
-         free(argv[3]);
          argv[2] = xstrdup(strtrim(str));
          argv[3] = xstrdup(str);
        }
       else if (!strcmp(ptype, "IMAP"))
        {
-         EXEC SQL SELECT f.label, m.name INTO :fs, :mach
-           FROM filesys f, machine m, users u
-           WHERE u.users_id = :users_id AND f.filsys_id = u.imap_id
-           AND f.mach_id = m.mach_id;
-         if (sqlca.sqlcode)
-           return MR_FILESYS;
-         free(argv[2]);
          argv[2] = xstrdup(strtrim(fs));
-         free(argv[3]);
          argv[3] = xmalloc(strlen(argv[0]) + strlen(strtrim(mach)) + 2);
          sprintf(argv[3], "%s@%s", argv[0], mach);
        }
+      else if (!strcmp(ptype, "SPLIT"))
+       {
+         argv[2] = xstrdup(strtrim(str));
+         argv[3] = xmalloc(strlen(argv[0]) + strlen(strtrim(mach)) +
+                           strlen(str) + 4);
+         sprintf(argv[3], "%s@%s, %s", argv[0], mach, str);
+       }
       else /* ptype == "NONE" */
        goto skip;
 
@@ -499,29 +548,34 @@ int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
                  client *cl)
 {
   char **argv;
-  int id, status;
+  int id, status, idx;
+
+  if (q->version < 6)
+    idx = 0;
+  else
+    idx = 1;
 
   while (sq_get_data(sq, &argv))
     {
       mr_trim_args(q->vcnt, argv);
 
-      id = atoi(argv[13]);
-      status = id_to_name(id, STRINGS_TABLE, &argv[13]);
+      id = atoi(argv[13 + idx]);
+      status = id_to_name(id, STRINGS_TABLE, &argv[13 + idx]);
       if (status)
        return status;
-      id = atoi(argv[14]);
-      status = id_to_name(id, STRINGS_TABLE, &argv[14]);
+      id = atoi(argv[14 + idx]);
+      status = id_to_name(id, STRINGS_TABLE, &argv[14 + idx]);
       if (status)
        return status;
-      id = atoi(argv[16]);
+      id = atoi(argv[16 + idx]);
       if (id < 0)
-       status = id_to_name(-id, STRINGS_TABLE, &argv[16]);
+       status = id_to_name(-id, STRINGS_TABLE, &argv[16 + idx]);
       else
-       status = id_to_name(id, USERS_TABLE, &argv[16]);
+       status = id_to_name(id, USERS_TABLE, &argv[16 + idx]);
       if (status && status != MR_NO_MATCH)
        return status;
 
-      status = fix_ace(argv[11], &argv[12]);
+      status = fix_ace(argv[11 + idx], &argv[12 + idx]);
       if (status && status != MR_NO_MATCH)
        return status;
     }
@@ -537,21 +591,26 @@ int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
                  client *cl)
 {
   char **argv;
-  int id, i, idx, status;
-
-  idx = 7;
-  if (!strcmp(q->shortname, "gsin"))
-    idx = 11;
+  int status;
 
   while (sq_get_data(sq, &argv))
     {
       mr_trim_args(q->vcnt, argv);
 
-      status = fix_ace(argv[idx], &argv[idx + 1]);
+      if (q->version == 2)
+       status = fix_ace(argv[7], &argv[8]);
+      else 
+       status = fix_ace(argv[8], &argv[9]);
       if (status && status != MR_NO_MATCH)
        return status;
+      if (q->version > 3)
+       {
+         status = fix_ace(argv[10], &argv[11]);
+         if (status && status != MR_NO_MATCH)
+           return status;
+       }
 
-      if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1)
+      if (atoi(argv[6]) == -1)
        {
          argv[6] = xrealloc(argv[6], strlen(UNIQUE_GID) + 1);
          strcpy(argv[6], UNIQUE_GID);
@@ -561,6 +620,26 @@ int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
   return followup_fix_modby(q, sq, v, action, actarg, cl);
 }
 
+/* followup_gsin: fix the ace_name and modby. */
+int followup_gsin(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
+{
+  char **argv;
+  int status;
+
+  while (sq_get_data(sq, &argv))
+    {
+      mr_trim_args(q->vcnt, argv);
+
+      status = fix_ace(argv[11], &argv[12]);
+      if (status && status != MR_NO_MATCH)
+       return status;
+    }
+
+  return followup_fix_modby(q, sq, v, action, actarg, cl);
+}
+
 int followup_gpsv(struct query *q, struct save_queue *sq, struct validate *v,
                  int (*action)(int, char *[], void *), void *actarg,
                  client *cl)
@@ -733,7 +812,6 @@ int followup_aqot(struct query *q, char *argv[], client *cl)
 
   if (dbms_errno)
     return mr_errcode;
-  flush_name(argv[0], table);
   if (q->type == APPEND)
     {
       EXEC SQL UPDATE tblstats SET appends = appends + 1, modtime = SYSDATE
@@ -798,7 +876,6 @@ int followup_dqot(struct query *q, char **argv, client *cl)
 
   if (dbms_errno)
     return mr_errcode;
-  flush_name(argv[0], table);
 
   EXEC SQL UPDATE tblstats SET deletes = deletes + 1, modtime = SYSDATE
     WHERE table_name = :tname;
@@ -812,14 +889,19 @@ int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
                  int (*action)(int, char *[], void *), void *actarg,
                  client *cl)
 {
-  int i, status;
+  int i, n, status;
   char **argv;
 
+  if (q->version < 5)
+    n = 8;
+  else
+    n = 10;
+
   while (sq_get_data(sq, &argv))
     {
       mr_trim_args(q->vcnt, argv);
 
-      for (i = 1; i < 8; i += 2)
+      for (i = 1; i < n; i += 2)
        {
          status = fix_ace(argv[i], &argv[i + 1]);
          if (status && status != MR_NO_MATCH)
@@ -885,3 +967,29 @@ int trigger_dcm(struct query *q, char *argv[], client *cl)
       return MR_SUCCESS;
     }
 }
+
+/* followup_gcon: fix the ace_name, memace_name, and modby */
+
+int followup_gcon(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
+{
+  char **argv;
+  int status;
+
+  while (sq_get_data(sq, &argv))
+  {
+    mr_trim_args(q->vcnt, argv);
+
+    status = fix_ace(argv[4], &argv[5]);
+    if (status && status != MR_NO_MATCH)
+           return status;
+      
+         status = fix_ace(argv[6], &argv[7]);
+         if (status && status != MR_NO_MATCH)
+           return status;
+       }
+
+  return followup_fix_modby(q, sq, v, action, actarg, cl);
+}
+
This page took 0.047412 seconds and 4 git commands to generate.