6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
7 * For copying and distribution information, please see the file
13 static char *rcsid_test_c = "$Header$";
16 #include <mit-copyright.h>
18 #include <sys/types.h>
26 extern ss_request_table moira_test;
27 extern int sending_version_no;
40 initialize_sms_error_table();
41 initialize_krb_error_table();
43 ss = ss_create_invocation("moira", "2.0", (char *)NULL,
44 &moira_test, &status);
46 com_err(whoami, status, "Unable to create invocation");
51 ss_execute_command(ss, argv);
53 ss_listen(ss, &status);
55 com_err(whoami, status, 0);
63 int status = mr_noop();
64 if (status) ss_perror(ss, status, "");
69 sending_version_no = MR_VERSION_2;
74 sending_version_no = MR_VERSION_1;
77 test_connect(argc, argv)
81 char *server = "", *index();
87 status = mr_connect(server);
88 if (status) ss_perror(ss, status, "");
93 int status = mr_disconnect();
94 if (status) ss_perror(ss, status, "");
102 bzero(host, sizeof(host));
104 if (status = mr_host(host, sizeof(host) - 1))
105 ss_perror(ss, status, "");
107 printf("You are connected to host %s\n", host);
114 status = mr_auth("mrtest");
115 if (status) ss_perror(ss, status, "");
118 test_script(argc, argv)
123 char input[BUFSIZ], *cp, *index();
124 int status, oldstdout, oldstderr;
127 ss_perror(ss, 0, "too many levels deep in script files\n");
132 ss_perror(ss, 0, "Usage: script input_file [ output_file ]");
136 inp = fopen(argv[1], "r");
138 sprintf(input, "Cannot open input file %s", argv[1]);
139 ss_perror(ss, 0, input);
144 printf("Redirecting output to %s\n", argv[2]);
148 status = open(argv[2], O_CREAT|O_WRONLY|O_APPEND, 0664);
153 sprintf(input, "Unable to redirect output to %s\n", argv[2]);
154 ss_perror(ss, errno, input);
166 if (fgets(input, BUFSIZ, inp) == NULL)
168 if ((cp = index(input, '\n')) != (char *)NULL)
174 if (input[0] == '%') {
175 for (cp = &input[1]; *cp && isspace(*cp); cp++);
176 printf("Comment: %s\n", cp);
179 printf("Executing: %s\n", input);
180 ss_execute_line(ss, input, &status);
181 if (status == SS_ET_COMMAND_NOT_FOUND) {
182 printf("Bad command: %s\n", input);
201 char *concat(str1, str2)
205 extern char *malloc();
208 int len = strlen(str2) + 1 ;
210 bcopy(str2, rtn, len);
212 int len1 = strlen(str1);
213 int len2 = strlen(str2) + 1;
214 rtn = malloc(len1+len2);
215 bcopy(str1, rtn, len1);
216 bcopy(str2, rtn+len1, len2);
223 print_reply(argc, argv)
228 for (i = 0; i < argc; i++) {
229 if (i != 0) printf(", ");
230 printf("%s", argv[i]);
237 test_query(argc, argv)
243 ss_perror(ss, 0, "Usage: query handle [ args ... ]");
248 status = mr_query(argv[1], argc-2, argv+2, print_reply, (char *)NULL);
249 printf("%d tuple%s\n", count, ((count == 1) ? "" : "s"));
250 if (status) ss_perror(ss, status, "");
253 test_access(argc, argv)
259 ss_perror(ss, 0, "Usage: access handle [ args ... ]");
262 status = mr_access(argv[1], argc-2, argv+2);
263 if (status) ss_perror(ss, status, "");
273 if (status = mr_do_update())
274 ss_perror(ss, status, " while triggering dcm");
278 test_motd(argc, argv)
285 if (status = mr_motd(&motd))
286 ss_perror(ss, status, " while getting motd");
288 printf("%s\n", motd);
290 printf("No message of the day.\n");