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;
(*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 *),
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)
break;
}
- if (q->type == RETRIEVE)
+ if (q->type == MR_Q_RETRIEVE)
{
sprintf(argr, "%s => %s", argv[--argcount], q->fields[q->argc]);
argv[argcount++] = argr;