1 /* This is the file misc.c for the MOIRA Client, which allows a naieve
2 * user to quickly and easily maintain most parts of the MOIRA database.
8 * Created: 5 October 1988
9 * By: Mark A. Rosenstein
15 * Copyright 1988 by the Massachusetts Institute of Technology.
17 * For further information on copyright and distribution
18 * see the file mit-copyright.h
24 #include <moira_site.h>
26 #include <sys/types.h>
28 #include <sys/socket.h>
29 #include <netinet/in.h>
31 #include "mit-copyright.h"
37 /* Function Name: PrintStats
38 * Description: print statistics from argv
39 * Arguments: info: statistics tuple
48 sprintf(buf, "Table: %-30s Modified: %s", info[0], info[5]);
50 sprintf(buf, " %s appends, %s updates, %s deletes",
51 info[2], info[3], info[4]);
56 /* Function Name: TableStats
57 * Description: display the MOIRA table statistics
65 struct qelem *elem = NULL;
67 if (status = do_mr_query("get_all_table_stats", 0, NULL,
68 StoreInfo, (char *)&elem)) {
69 com_err(program_name, status, " in TableStats");
72 Loop(QueueTop(elem), PrintStats);
78 /* Function Name: PrintClients
79 * Description: print info from client tuple
87 unsigned long host_address;
88 struct hostent *host_entry;
90 host_address = inet_addr(info[1]);
91 if (host_address != NULL) {
92 host_entry = gethostbyaddr((char *) &host_address, 4, AF_INET);
93 if (host_entry != NULL) {
95 info[1] = Strsave(host_entry->h_name);
98 sprintf(buf, "Principal %s on %s (%s)", info[0], info[1], info[2]);
100 sprintf(buf, " Connected at %s, client %s", info[3], info[4]);
105 /* Function Name: ShowClients
106 * Description: show clients actively using MR
114 struct qelem *elem = NULL;
116 if (status = do_mr_query("_list_users", 0, NULL,
117 StoreInfo, (char *) &elem)) {
118 com_err(program_name, status, " in ShowClients");
121 Loop(QueueTop(elem), PrintClients);
127 /* Function Name: PrintValue
128 * Description: displays variable values
137 sprintf(buf, "Value: %s", info[0]);
142 /* Function Name: ShowValue
143 * Description: get a variable value from MR
144 * Arguments: variable name
148 int ShowValue(argc, argv)
153 struct qelem *elem = NULL;
155 if (status = do_mr_query("get_value", 1, &argv[1],
156 StoreInfo, (char *) &elem)) {
157 com_err(program_name, status, " in ShowValue");
160 Loop(elem, PrintValue);
166 /* Function Name: PrintAlias
167 * Description: print an alias relation
176 sprintf(buf, "Name: %-20s Type: %-12s Value: %s",
177 info[0], info[1], info[2]);
182 /* Function Name: ShowAlias
183 * Description: display an alias relation
184 * Arguments: name & type of alias
188 int ShowAlias(argc, argv)
194 struct qelem *elem = NULL;
199 if (status = do_mr_query("get_alias", 3, info,
200 StoreInfo, (char *) &elem)) {
201 com_err(program_name, status, " in ShowAlias");
204 Loop(QueueTop(elem), PrintAlias);