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
9 * Portions Copyright (c) 2003 Apple Computer, Inc.
13 * This file contains sample code for the client admin interface
16 #include <afsconfig.h>
17 #include <afs/param.h>
25 #include <afs/afs_Admin.h>
26 #include <afs/afs_clientAdmin.h>
27 #include <afs/afs_utilAdmin.h>
32 fprintf(stderr, "Usage: cm_list_cells <host> <port>\n");
37 ParseArgs(int argc, char *argv[], char **srvrName, long *srvrPort)
43 *srvrName = *(argp++);
46 *srvrPort = strtol(*(argp++), NULL, 0);
47 if (*srvrPort <= 0 || *srvrPort >= 65536)
54 main(int argc, char *argv[])
58 struct rx_connection *conn;
62 afs_CMListCell_t cellInfo;
67 ParseArgs(argc, argv, &srvrName, &srvrPort);
69 rc = afsclient_Init(&st);
71 fprintf(stderr, "afsclient_Init, status %d\n", st);
75 rc = afsclient_NullCellOpen(&cellHandle, &st);
77 fprintf(stderr, "afsclient_NullCellsOpen, status %d\n", st);
81 rc = afsclient_CMStatOpenPort(cellHandle, srvrName, srvrPort, &conn, &st);
83 fprintf(stderr, "afsclient_CMStatOpenPort, status %d\n", st);
87 rc = util_CMListCellsBegin(conn, &iterator, &st);
89 fprintf(stderr, "util_CMListCellsBegin, status %d\n", st);
94 while (util_CMListCellsNext(iterator, &cellInfo, &st)) {
95 printf("Cell %s on hosts", cellInfo.cellname);
96 for (i = 0; i < UTIL_MAX_CELL_HOSTS && cellInfo.serverAddr[i]; i++) {
97 taddr = cellInfo.serverAddr[i];
98 printf(" %d.%d.%d.%d", (taddr >> 24) & 0xff, (taddr >> 16) & 0xff,
99 (taddr >> 8) & 0xff, taddr & 0xff);
103 if (st != ADMITERATORDONE) {
104 fprintf(stderr, "util_CMListCellsNext, status %d\n", st);
109 rc = util_CMListCellsDone(iterator, &st);
111 fprintf(stderr, "util_CMListCellsDone, status %d\n", st);
115 rc = afsclient_CMStatClose(conn, &st);
117 fprintf(stderr, "afsclient_CMStatClose, status %d\n", st);
121 rc = afsclient_CellClose(cellHandle, &st);
123 fprintf(stderr, "afsclient_CellClose, status %d\n", st);