]> andersk Git - moira.git/blobdiff - server/qsubs.c
Command line printer manipulation client, and build goo.
[moira.git] / server / qsubs.c
index af6c80aef08ce7815bb3e462e707e7a7ed90797e..62869c0103abaabfb8dd9814ab1eb40906b4b737 100644 (file)
@@ -49,28 +49,29 @@ struct query *get_query_by_name(char *name, int version)
 void list_queries(client *cl, int (*action)(int, char *[], void *),
                  void *actarg)
 {
-  static struct query **squeries = NULL;
-  static int qcount;
+  struct query **squeries = NULL;
+  int qcount;
   struct query *q, **sq;
   char qnames[80];
   char *qnp;
   int i;
 
-  if (!squeries)
+  squeries = sq = xmalloc(QueryCount * sizeof(struct query *));
+  q = Queries;
+  for (i = 0; i < QueryCount; i++)
     {
-      squeries = sq = xmalloc(QueryCount * sizeof(struct query *));
-      q = Queries;
-      for (i = 0; i < QueryCount; i++)
+      if (q->version > cl->version)
        {
-         if (q->version > cl->version)
-           continue;
-         if (i > 0 && strcmp((*sq)->name, q->name))
-           sq++;
-         *sq = q++;
+         q++;
+         continue;
        }
-      qcount = (sq - squeries) + 1;
-      qsort(squeries, qcount, sizeof(struct query *), qcmp);
+      if (i > 0 && strcmp((*sq)->name, q->name))
+       sq++;
+      *sq = q++;
     }
+  qcount = (sq - squeries) + 1;
+  qsort(squeries, qcount, sizeof(struct query *), qcmp);
+
   sq = squeries;
 
   qnp = qnames;
@@ -85,6 +86,8 @@ void list_queries(client *cl, int (*action)(int, char *[], void *),
   (*action)(1, &qnp, actarg);
   strcpy(qnames, "_list_users");
   (*action)(1, &qnp, actarg);
+
+  free(squeries);
 }
 
 void help_query(struct query *q, int (*action)(int, char *[], void *),
@@ -98,7 +101,7 @@ void help_query(struct query *q, int (*action)(int, char *[], void *),
   char *argv[32];
 
   argcount = q->argc;
-  if (q->type == UPDATE || q->type == APPEND)
+  if (q->type == MR_Q_UPDATE || q->type == MR_Q_APPEND)
     argcount += q->vcnt;
 
   switch (argcount)
@@ -133,7 +136,7 @@ void help_query(struct query *q, int (*action)(int, char *[], void *),
       break;
     }
 
-  if (q->type == RETRIEVE)
+  if (q->type == MR_Q_RETRIEVE)
     {
       sprintf(argr, "%s => %s", argv[--argcount], q->fields[q->argc]);
       argv[argcount++] = argr;
This page took 0.040034 seconds and 4 git commands to generate.