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
18 #include <afs/afs_Admin.h>
19 #include <afs/afs_clientAdmin.h>
20 #include <afs/afs_utilAdmin.h>
25 "Usage: cm_list_cells <host> <port>\n");
39 *srvrName = *(argp++);
42 *srvrPort = strtol(*(argp++), NULL, 0);
43 if (*srvrPort <= 0 || *srvrPort >= 65536)
49 int main(int argc, char *argv[])
53 struct rx_connection *conn;
57 afs_CMListCell_t cellInfo;
62 ParseArgs(argc, argv, &srvrName, &srvrPort);
64 rc = afsclient_Init(&st);
66 fprintf(stderr, "afsclient_Init, status %d\n", st);
70 rc = afsclient_NullCellOpen(&cellHandle, &st);
72 fprintf(stderr, "afsclient_NullCellsOpen, status %d\n", st);
76 rc = afsclient_CMStatOpenPort(cellHandle, srvrName, srvrPort, &conn, &st);
78 fprintf(stderr, "afsclient_CMStatOpenPort, status %d\n", st);
82 rc = util_CMListCellsBegin(conn, &iterator, &st);
84 fprintf(stderr, "util_CMListCellsBegin, status %d\n", st);
89 while (util_CMListCellsNext(iterator, &cellInfo, &st)) {
90 printf("Cell %s on hosts", cellInfo.cellname);
91 for (i=0 ; i < UTIL_MAX_CELL_HOSTS && cellInfo.serverAddr[i] ; i++) {
92 taddr = cellInfo.serverAddr[i];
93 printf(" %d.%d.%d.%d",
94 (taddr >> 24) & 0xff, (taddr >> 16) & 0xff,
95 (taddr >> 8) & 0xff, taddr & 0xff);
99 if (st != ADMITERATORDONE) {
100 fprintf(stderr, "util_CMListCellsNext, status %d\n", st);
105 rc = util_CMListCellsDone(iterator, &st);
107 fprintf(stderr, "util_CMListCellsDone, status %d\n", st);
111 rc = afsclient_CMStatClose(conn, &st);
113 fprintf(stderr, "afsclient_CMStatClose, status %d\n", st);
117 rc = afsclient_CellClose(cellHandle, &st);
119 fprintf(stderr, "afsclient_CellClose, status %d\n", st);