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