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>
26 #include <rx/rxstat.h>
28 #include <afs/afs_Admin.h>
29 #include <afs/afs_clientAdmin.h>
30 #include <afs/afs_utilAdmin.h>
35 fprintf(stderr
, "Usage: cm_server_prefs <host> <port>\n");
40 ParseArgs(int argc
, char *argv
[], char **srvrName
, long *srvrPort
)
46 *srvrName
= *(argp
++);
49 *srvrPort
= strtol(*(argp
++), NULL
, 0);
50 if (*srvrPort
<= 0 || *srvrPort
>= 65536)
57 main(int argc
, char *argv
[])
61 struct rx_connection
*conn
;
65 afs_CMServerPref_t prefs
;
69 ParseArgs(argc
, argv
, &srvrName
, &srvrPort
);
71 rc
= afsclient_Init(&st
);
73 fprintf(stderr
, "afsclient_Init, status %d\n", st
);
77 rc
= afsclient_NullCellOpen(&cellHandle
, &st
);
79 fprintf(stderr
, "afsclient_NullCellOpen, status %d\n", st
);
83 rc
= afsclient_CMStatOpenPort(cellHandle
, srvrName
, srvrPort
, &conn
, &st
);
85 fprintf(stderr
, "afsclient_CMStatOpenPort, status %d\n", st
);
89 rc
= util_CMGetServerPrefsBegin(conn
, &iterator
, &st
);
91 fprintf(stderr
, "util_CMGetServerPrefsBegin, status %d\n", st
);
96 while (util_CMGetServerPrefsNext(iterator
, &prefs
, &st
)) {
98 printf("%d.%d.%d.%d\t\t\t%d\n", (taddr
>> 24) & 0xff,
99 (taddr
>> 16) & 0xff, (taddr
>> 8) & 0xff, taddr
& 0xff,
102 if (st
!= ADMITERATORDONE
) {
103 fprintf(stderr
, "util_CMGetServerPrefsNext, status %d\n", st
);
108 rc
= util_CMGetServerPrefsDone(iterator
, &st
);
110 fprintf(stderr
, "util_CMGetServerPrefsDone, 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
);