]> andersk Git - moira.git/blame - clients/mrtest/comp.c
reorder fields in filsys forms; don't try to remove window in tty mode
[moira.git] / clients / mrtest / comp.c
CommitLineData
92e88c2c 1/*
2 * $Source$
3 * $Author$
4 * $Header$
5 *
6 * Copyright (C) 1991 by the Massachusetts Institute of Technology
7 * For copying and distribution information, please see the file
8 * <mit-copyright.h>.
9 *
10 */
11
12#include <ctype.h>
13#include <stdio.h>
14#include <moira.h>
15
16extern char *DataBuf;
17extern char *ErrorBuf;
18extern int count;
19
20CompData (argc, argv, CompStr)
21int argc; /* # of fields outputted by Moira */
22char **argv; /* Array of strings outputted by Moira */
23char **CompStr; /* Pointer to Comparison String -- Data section only */
24/* CompData uses the global variables: */
25/* char *DataBuf; */
26/* char *ErrorBuf; */
27/* int count; */
28{
29int Field = 0; /* Field number being compared */
30int Len, Len2; /* Length of a comparison field */
31int i; /* index for printing */
32
33if (*ErrorBuf == '\0') { /* Don't process if there's a data error already */
34
35 for (;(**CompStr) && isspace(**CompStr); (*CompStr)++); /*whitespace*/
36 if ((**CompStr != '{') && (**CompStr != '\0'))
37 strcpy (ErrorBuf, "Malformed Comparison String");
38 else if (**CompStr != '\0') {
39 for ((*CompStr)++; ((**CompStr != '}') && (**CompStr != '\0')
40 && (Field < argc));) {
41 for (;**CompStr && isspace(**CompStr); (*CompStr)++); /* Whitespace */
42 if (**CompStr == '*') { /* Wildcard -- field automatically checks */
43 (*CompStr)++;}
44 else if (**CompStr == '"') { /* Compare a field */
45 (*CompStr)++;
46 Len = (int)(index(*CompStr, '"')) - (int)(*CompStr);
47 if (Len < 0) {
48 strcpy (ErrorBuf, "Malformed Comparison String");
49 break;}
50 else if ((strncmp (*CompStr, argv[Field], Len)) ||
51 (strlen(argv[Field]) != Len)) { /* Data Error */
52 strcpy (ErrorBuf, "Data Error");
53 break;}
54 *CompStr = (char *)index(*CompStr, '"');
55 (*CompStr)++;}
56 else {
57 Len = (int)(index(*CompStr, ' ')) - (int)(*CompStr);
58 Len2 = (int)(index(*CompStr, '}')) - (int)(*CompStr);
59 if ((Len < 0) || ((Len2 >= 0) && (Len2 < Len)))
60 Len = Len2;
61 if (Len < 0)
62 strcpy (ErrorBuf, "Malformed Comparison String");
63 else {
64 if ((strncmp (*CompStr, argv[Field], Len)) ||
65 (strlen(argv[Field]) != Len)) { /* Data Error */
66 strcpy (ErrorBuf, "Data Error");
67 break;}
68 *CompStr = (char *)(Len + (int)(*CompStr));}}
69 Field++;}
70 for (;**CompStr && isspace(**CompStr); (*CompStr)++); /* Whitespace */
71 if (*ErrorBuf == '\0') {
72 if (**CompStr == '\0')
73 strcpy (ErrorBuf, "Malformed Comparison String");
74 else if ((**CompStr != '}') || (Field < argc))
75 strcpy (ErrorBuf, "Data Error");}
76 (*CompStr)++;
77 }
78 if (!strcmp(ErrorBuf, "Data Error")) strcat (DataBuf, "*****");
79}
80else {
81 strcat (DataBuf, " ");}
82
83if (strcmp(ErrorBuf, "Data Error")) strcat (DataBuf, " ");
84
85/* Write Query output to data buffer */
86for (i = 0; i < argc; i++) {
87 if (i != 0) strcat (DataBuf, ", ");
88 strcat (DataBuf, argv[i]);
89}
90strcat (DataBuf, "\n");
91count++;
92return(MR_CONT);
93}
94
95
96
97
This page took 0.168381 seconds and 5 git commands to generate.