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>
25 extern ss_request_table sms_test;
26 extern int sending_version_no;
49 ss = ss_create_invocation("sms", "2.0", (char *)NULL,
52 com_err(whoami, status, "Unable to create invocation");
55 ss_listen(ss, &status);
57 com_err(whoami, status, 0);
65 int status = sms_noop();
66 if (status) ss_perror(ss, status, 0);
71 sending_version_no = SMS_VERSION_2;
76 sending_version_no = SMS_VERSION_1;
79 test_connect(argc, argv)
88 status = sms_connect(server);
89 if (status) ss_perror(ss, status, 0);
94 int status = sms_disconnect();
95 if (status) ss_perror(ss, status, 0);
102 status = sms_auth("smstest");
103 if (status) ss_perror(ss, status, 0);
106 test_script(argc, argv)
111 char input[BUFSIZ], *cp, *index();
112 int status, oldstdout, oldstderr;
115 ss_perror(ss, 0, "too many levels deep in script files\n");
120 ss_perror(ss, 0, "Usage: script input_file [ output_file ]");
124 inp = fopen(argv[1], "r");
126 ss_perror(ss, 0, "Cannot open input file %s", argv[1]);
131 printf("Redirecting output to %s\n", argv[2]);
135 status = open(argv[2], O_CREAT|O_WRONLY|O_APPEND, 0664);
140 ss_perror(ss, errno, "Unable to redirect output to %s\n", argv[2]);
152 if (fgets(input, BUFSIZ, inp) == NULL)
154 if ((cp = index(input, '\n')) != (char *)NULL)
160 if (input[0] == '%') {
161 for (cp = &input[1]; *cp && isspace(*cp); cp++);
162 printf("Comment: %s\n", cp);
165 printf("Executing: %s\n", input);
166 ss_execute_line(ss, input, &status);
167 if (status == SS_ET_COMMAND_NOT_FOUND) {
168 printf("Bad command: %s\n", input);
187 char *concat(str1, str2)
191 extern char *malloc();
194 int len = strlen(str2) + 1 ;
196 bcopy(str2, rtn, len);
198 int len1 = strlen(str1);
199 int len2 = strlen(str2) + 1;
200 rtn = malloc(len1+len2);
201 bcopy(str1, rtn, len1);
202 bcopy(str2, rtn+len1, len2);
210 print_reply(argc, argv)
215 for (i = 0; i < argc; i++) {
216 if (i != 0) printf(", ");
217 printf("%s", argv[i]);
224 test_query(argc, argv)
230 ss_perror(ss, 0, "Usage: query handle [ args ... ]");
235 status = sms_query(argv[1], argc-2, argv+2, print_reply, (char *)NULL);
236 printf("%d tuple%s\n", count, ((count == 1) ? "" : "s"));
237 if (status) ss_perror(ss, status, 0);
240 test_access(argc, argv)
246 ss_perror(ss, 0, "Usage: access handle [ args ... ]");
249 status = sms_access(argv[1], argc-2, argv+2);
250 if (status) ss_perror(ss, status, 0);
260 if (status = sms_do_update())
261 ss_perror(ss, status, " while triggering dcm");