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>
28 extern ss_request_table moira_test;
29 extern int sending_version_no;
42 initialize_sms_error_table();
43 initialize_krb_error_table();
45 ss = ss_create_invocation("moira", "2.0", (char *)NULL,
46 &moira_test, &status);
48 com_err(whoami, status, "Unable to create invocation");
53 ss_execute_command(ss, argv);
55 ss_listen(ss, &status);
57 com_err(whoami, status, 0);
65 int status = mr_noop();
66 if (status) ss_perror(ss, status, "");
71 sending_version_no = MR_VERSION_2;
76 sending_version_no = MR_VERSION_1;
79 test_connect(argc, argv)
89 status = mr_connect(server);
90 if (status) ss_perror(ss, status, "");
95 int status = mr_disconnect();
96 if (status) ss_perror(ss, status, "");
104 memset(host, 0, sizeof(host));
106 if (status = mr_host(host, sizeof(host) - 1))
107 ss_perror(ss, status, "");
109 printf("You are connected to host %s\n", host);
116 status = mr_auth("mrtest");
117 if (status) ss_perror(ss, status, "");
120 test_script(argc, argv)
125 char input[BUFSIZ], *cp;
126 int status, oldstdout, oldstderr;
129 ss_perror(ss, 0, "too many levels deep in script files\n");
134 ss_perror(ss, 0, "Usage: script input_file [ output_file ]");
138 inp = fopen(argv[1], "r");
140 sprintf(input, "Cannot open input file %s", argv[1]);
141 ss_perror(ss, 0, input);
146 printf("Redirecting output to %s\n", argv[2]);
150 status = open(argv[2], O_CREAT|O_WRONLY|O_APPEND, 0664);
155 sprintf(input, "Unable to redirect output to %s\n", argv[2]);
156 ss_perror(ss, errno, input);
168 if (fgets(input, BUFSIZ, inp) == NULL)
170 if ((cp = strchr(input, '\n')) != (char *)NULL)
176 if (input[0] == '%') {
177 for (cp = &input[1]; *cp && isspace(*cp); cp++);
178 printf("Comment: %s\n", cp);
181 printf("Executing: %s\n", input);
182 ss_execute_line(ss, input, &status);
183 if (status == SS_ET_COMMAND_NOT_FOUND) {
184 printf("Bad command: %s\n", input);
203 char *concat(str1, str2)
207 extern char *malloc();
210 int len = strlen(str2) + 1 ;
212 memcpy(rtn, str2, len);
214 int len1 = strlen(str1);
215 int len2 = strlen(str2) + 1;
216 rtn = malloc(len1+len2);
217 memcpy(rtn, str1, len1);
218 memcpy(rtn+len1, str2, len2);
225 print_reply(argc, argv)
230 for (i = 0; i < argc; i++) {
231 if (i != 0) printf(", ");
232 printf("%s", argv[i]);
239 test_query(argc, argv)
245 ss_perror(ss, 0, "Usage: query handle [ args ... ]");
250 status = mr_query(argv[1], argc-2, argv+2, print_reply, (char *)NULL);
251 printf("%d tuple%s\n", count, ((count == 1) ? "" : "s"));
252 if (status) ss_perror(ss, status, "");
255 test_access(argc, argv)
261 ss_perror(ss, 0, "Usage: access handle [ args ... ]");
264 status = mr_access(argv[1], argc-2, argv+2);
265 if (status) ss_perror(ss, status, "");
275 if (status = mr_do_update())
276 ss_perror(ss, status, " while triggering dcm");
280 test_motd(argc, argv)
287 if (status = mr_motd(&motd))
288 ss_perror(ss, status, " while getting motd");
290 printf("%s\n", motd);
292 printf("No message of the day.\n");