2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * This file contains sample code for the client admin interface
14 #include <afsconfig.h>
15 #include <afs/param.h>
24 #include <afs/afs_Admin.h>
25 #include <afs/afs_clientAdmin.h>
26 #include <afs/afs_utilAdmin.h>
31 fprintf(stderr, "Usage: cm_list_cells <host> <port>\n");
36 ParseArgs(int argc, char *argv[], char **srvrName, long *srvrPort)
42 *srvrName = *(argp++);
45 *srvrPort = strtol(*(argp++), NULL, 0);
46 if (*srvrPort <= 0 || *srvrPort >= 65536)
53 main(int argc, char *argv[])
57 struct rx_connection *conn;
61 afs_CMListCell_t cellInfo;
66 ParseArgs(argc, argv, &srvrName, &srvrPort);
68 rc = afsclient_Init(&st);
70 fprintf(stderr, "afsclient_Init, status %d\n", st);
74 rc = afsclient_NullCellOpen(&cellHandle, &st);
76 fprintf(stderr, "afsclient_NullCellsOpen, status %d\n", st);
80 rc = afsclient_CMStatOpenPort(cellHandle, srvrName, srvrPort, &conn, &st);
82 fprintf(stderr, "afsclient_CMStatOpenPort, status %d\n", st);
86 rc = util_CMListCellsBegin(conn, &iterator, &st);
88 fprintf(stderr, "util_CMListCellsBegin, status %d\n", st);
93 while (util_CMListCellsNext(iterator, &cellInfo, &st)) {
94 printf("Cell %s on hosts", cellInfo.cellname);
95 for (i = 0; i < UTIL_MAX_CELL_HOSTS && cellInfo.serverAddr[i]; i++) {
96 taddr = cellInfo.serverAddr[i];
97 printf(" %d.%d.%d.%d", (taddr >> 24) & 0xff, (taddr >> 16) & 0xff,
98 (taddr >> 8) & 0xff, taddr & 0xff);
102 if (st != ADMITERATORDONE) {
103 fprintf(stderr, "util_CMListCellsNext, status %d\n", st);
108 rc = util_CMListCellsDone(iterator, &st);
110 fprintf(stderr, "util_CMListCellsDone, status %d\n", st);
114 rc = afsclient_CMStatClose(conn, &st);
116 fprintf(stderr, "afsclient_CMStatClose, status %d\n", st);
120 rc = afsclient_CellClose(cellHandle, &st);
122 fprintf(stderr, "afsclient_CellClose, status %d\n", st);