]> andersk Git - moira.git/blob - clients/mrtest/mrtest.c
aa29f4141524a1153483a59e196636b423dd349e
[moira.git] / clients / mrtest / mrtest.c
1 /*
2  *      $Source$
3  *      $Author$
4  *      $Header$
5  *
6  *      Copyright (C) 1987 by the Massachusetts Institute of Technology
7  *
8  *      $Log$
9  *      Revision 1.3  1988-01-07 17:42:06  mar
10  *      print "tuple" or "tuples" as is correct
11  *
12  * Revision 1.2  87/08/22  23:45:10  wesommer
13  * Removed extra RCS headers.
14  * 
15  * Revision 1.1  87/08/22  18:31:59  wesommer
16  * Initial revision
17  * 
18  */
19
20 #ifndef lint
21 static char *rcsid_test_c = "$Header$";
22 #endif lint
23
24 #include <stdio.h>
25 #include <sms.h>
26 #include <ss.h>
27
28 int ss;
29 extern ss_request_table sms_test;
30
31 #ifndef __SABER__
32 main(argc, argv)
33         int argc;
34         char **argv;
35 #else __SABER__
36 sms()
37 #endif __SABER__
38 {       
39         int status;
40         char *whoami;
41         
42 #ifndef __SABER__
43         whoami = argv[0];
44 #else
45         whoami = "sms";
46 #endif __SABER__
47         
48         init_ss_err_tbl();
49         init_sms_err_tbl();
50         init_krb_err_tbl();
51
52         ss = ss_create_invocation("sms", "0.1", (char *)NULL,
53                                   &sms_test, &status);
54         if (status != 0) {
55                 com_err(whoami, status, "Unable to create invocation");
56                 exit(1);
57         }
58         ss_listen(ss, &status);
59         if (status != 0) {
60                 com_err(whoami, status, 0);
61                 exit(1);
62         }
63 }
64
65 test_noop()
66 {
67         int status = sms_noop();
68         if (status) ss_perror(ss, status, 0);
69 }
70
71 test_connect()
72 {
73         int status = sms_connect();
74         if (status) ss_perror(ss, status, 0);
75 }
76
77 test_disconnect()
78 {
79         int status = sms_disconnect();
80         if (status) ss_perror(ss, status, 0);
81 }
82
83 test_auth()
84 {
85         int status = sms_auth();
86         if (status) ss_perror(ss, status, 0);
87 }
88
89 char *concat(str1, str2)
90         char *str1, *str2;
91 {
92         char *rtn;
93         extern char *malloc();
94         
95         if (!str1) {
96                 int len = strlen(str2) + 1 ;
97                 rtn = malloc(len);
98                 bcopy(str2, rtn, len);
99         } else {
100                 int len1 = strlen(str1);
101                 int len2 = strlen(str2) + 1;
102                 rtn = malloc(len1+len2);
103                 bcopy(str1, rtn, len1);
104                 bcopy(str2, rtn+len1, len2);
105         }
106         return rtn;
107 }
108
109 test_shutdown(argc, argv)
110         int argc;
111         char **argv;
112 {
113         char *reason = NULL;
114         int status, i;
115         
116         if (argc < 2) {
117                 ss_perror(ss, 0, "Usage: shutdown reason ...");
118                 return;
119         }
120         
121         for (i = 1 ; i < argc; i++) {
122                 if (i != 1) reason = concat(reason, " ");
123                 reason = concat(reason, argv[i]);
124         }
125         status = sms_shutdown(reason);
126         if (status) ss_perror(ss, status, 0);
127 }
128 static int count;
129
130
131 print_reply(argc, argv)
132         int argc;
133         char **argv;
134 {
135         int i;
136         for (i = 0; i < argc; i++) {
137                 if (i != 0) printf(", ");
138                 printf("%s", argv[i]);
139         }
140         printf("\n");
141         count++;
142 }
143
144 test_query(argc, argv)
145         int argc;
146         char **argv;
147 {
148         int status;
149         if (argc < 2) {
150                 ss_perror(ss, 0, "Usage: query handle [ args ... ]");
151                 return;
152         }
153         count = 0;
154         status = sms_query(argv[1], argc-2, argv+2, print_reply, (char *)NULL);
155         printf("%d tuple%s\n", count, ((count == 1) ? "" : "s"));
156         if (status) ss_perror(ss, status, 0);
157 }
158
159 test_access(argc, argv)
160         int argc;
161         char **argv;
162 {
163         int status;
164         if (argc < 2) {
165                 ss_perror(ss, 0, "Usage: access handle [ args ... ]");
166                 return;
167         }
168         status = sms_access(argv[1], argc-2, argv+2);
169         if (status) ss_perror(ss, status, 0);
170 }
171
This page took 0.065929 seconds and 3 git commands to generate.