6 * Copyright (C) 1991 by the Massachusetts Institute of Technology
7 * For copying and distribution information, please see the file
18 extern char *ErrorBuf;
21 CompData (argc, argv, CompStr)
22 int argc; /* # of fields outputted by Moira */
23 char **argv; /* Array of strings outputted by Moira */
24 char **CompStr; /* Pointer to Comparison String -- Data section only */
25 /* CompData uses the global variables: */
30 int Field = 0; /* Field number being compared */
31 int Len, Len2; /* Length of a comparison field */
32 int i; /* index for printing */
34 if (*ErrorBuf == '\0') { /* Don't process if there's a data error already */
36 for (;(**CompStr) && isspace(**CompStr); (*CompStr)++); /*whitespace*/
37 if ((**CompStr != '{') && (**CompStr != '\0'))
38 strcpy (ErrorBuf, "Malformed Comparison String");
39 else if (**CompStr != '\0') {
40 for ((*CompStr)++; ((**CompStr != '}') && (**CompStr != '\0')
41 && (Field < argc));) {
42 for (;**CompStr && isspace(**CompStr); (*CompStr)++); /* Whitespace */
43 if (**CompStr == '*') { /* Wildcard -- field automatically checks */
45 else if (**CompStr == '"') { /* Compare a field */
47 Len = (int)(strchr(*CompStr, '"')) - (int)(*CompStr);
49 strcpy (ErrorBuf, "Malformed Comparison String");
51 else if ((strncmp (*CompStr, argv[Field], Len)) ||
52 (strlen(argv[Field]) != Len)) { /* Data Error */
53 strcpy (ErrorBuf, "Data Error");
55 *CompStr = (char *)strchr(*CompStr, '"');
58 Len = (int)(strchr(*CompStr, ' ')) - (int)(*CompStr);
59 Len2 = (int)(strchr(*CompStr, '}')) - (int)(*CompStr);
60 if ((Len < 0) || ((Len2 >= 0) && (Len2 < Len)))
63 strcpy (ErrorBuf, "Malformed Comparison String");
65 if ((strncmp (*CompStr, argv[Field], Len)) ||
66 (strlen(argv[Field]) != Len)) { /* Data Error */
67 strcpy (ErrorBuf, "Data Error");
69 *CompStr = (char *)(Len + (int)(*CompStr));}}
71 for (;**CompStr && isspace(**CompStr); (*CompStr)++); /* Whitespace */
72 if (*ErrorBuf == '\0') {
73 if (**CompStr == '\0')
74 strcpy (ErrorBuf, "Malformed Comparison String");
75 else if ((**CompStr != '}') || (Field < argc))
76 strcpy (ErrorBuf, "Data Error");}
79 if (!strcmp(ErrorBuf, "Data Error")) strcat (DataBuf, "*****");
82 strcat (DataBuf, " ");}
84 if (strcmp(ErrorBuf, "Data Error")) strcat (DataBuf, " ");
86 /* Write Query output to data buffer */
87 for (i = 0; i < argc; i++) {
88 if (i != 0) strcat (DataBuf, ", ");
89 strcat (DataBuf, argv[i]);
91 strcat (DataBuf, "\n");