]> andersk Git - moira.git/blame - clients/mrtest/comp.c
added hosttable stuff
[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>
f071d8a7 13#include <string.h>
92e88c2c 14#include <stdio.h>
15#include <moira.h>
16
17extern char *DataBuf;
18extern char *ErrorBuf;
19extern int count;
20
21CompData (argc, argv, CompStr)
22int argc; /* # of fields outputted by Moira */
23char **argv; /* Array of strings outputted by Moira */
24char **CompStr; /* Pointer to Comparison String -- Data section only */
25/* CompData uses the global variables: */
26/* char *DataBuf; */
27/* char *ErrorBuf; */
28/* int count; */
29{
30int Field = 0; /* Field number being compared */
31int Len, Len2; /* Length of a comparison field */
32int i; /* index for printing */
33
34if (*ErrorBuf == '\0') { /* Don't process if there's a data error already */
35
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 */
44 (*CompStr)++;}
45 else if (**CompStr == '"') { /* Compare a field */
46 (*CompStr)++;
f071d8a7 47 Len = (int)(strchr(*CompStr, '"')) - (int)(*CompStr);
92e88c2c 48 if (Len < 0) {
49 strcpy (ErrorBuf, "Malformed Comparison String");
50 break;}
51 else if ((strncmp (*CompStr, argv[Field], Len)) ||
52 (strlen(argv[Field]) != Len)) { /* Data Error */
53 strcpy (ErrorBuf, "Data Error");
54 break;}
f071d8a7 55 *CompStr = (char *)strchr(*CompStr, '"');
92e88c2c 56 (*CompStr)++;}
57 else {
f071d8a7 58 Len = (int)(strchr(*CompStr, ' ')) - (int)(*CompStr);
59 Len2 = (int)(strchr(*CompStr, '}')) - (int)(*CompStr);
92e88c2c 60 if ((Len < 0) || ((Len2 >= 0) && (Len2 < Len)))
61 Len = Len2;
62 if (Len < 0)
63 strcpy (ErrorBuf, "Malformed Comparison String");
64 else {
65 if ((strncmp (*CompStr, argv[Field], Len)) ||
66 (strlen(argv[Field]) != Len)) { /* Data Error */
67 strcpy (ErrorBuf, "Data Error");
68 break;}
69 *CompStr = (char *)(Len + (int)(*CompStr));}}
70 Field++;}
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");}
77 (*CompStr)++;
78 }
79 if (!strcmp(ErrorBuf, "Data Error")) strcat (DataBuf, "*****");
80}
81else {
82 strcat (DataBuf, " ");}
83
84if (strcmp(ErrorBuf, "Data Error")) strcat (DataBuf, " ");
85
86/* Write Query output to data buffer */
87for (i = 0; i < argc; i++) {
88 if (i != 0) strcat (DataBuf, ", ");
89 strcat (DataBuf, argv[i]);
90}
91strcat (DataBuf, "\n");
92count++;
93return(MR_CONT);
94}
95
96
97
98
This page took 0.076193 seconds and 5 git commands to generate.