Remove the RCSID macro
[openafs.git] / src / libadmin / samples / rxstat_clear_process.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  *
9  * Portions Copyright (c) 2003 Apple Computer, Inc.
10  */
11
12 /*
13  * This file contains sample code for the rxstats interface 
14  */
15
16 #include <afsconfig.h>
17 #include <afs/param.h>
18
19
20 #ifdef AFS_NT40_ENV
21 #include <winsock2.h>
22 #include <pthread.h>
23 #endif
24
25 #include <rx/rx.h>
26 #include <rx/rxstat.h>
27
28 #include <afs/afs_Admin.h>
29 #include <afs/afs_clientAdmin.h>
30 #include <afs/afs_utilAdmin.h>
31
32 #ifdef AFS_DARWIN_ENV
33 pthread_mutex_t des_init_mutex = PTHREAD_MUTEX_INITIALIZER;
34 pthread_mutex_t des_random_mutex = PTHREAD_MUTEX_INITIALIZER;
35 pthread_mutex_t rxkad_random_mutex = PTHREAD_MUTEX_INITIALIZER;
36 #endif /* AFS_DARWIN_ENV */
37
38 extern int RXSTATS_ClearProcessRPCStats();
39
40 void
41 Usage(void)
42 {
43     fprintf(stderr, "Usage: rxstat_clear_process <cell> <host> <port>\n");
44     exit(1);
45 }
46
47 void
48 ParseArgs(int argc, char *argv[], char **cellName, char **srvrName,
49           long *srvrPort)
50 {
51     char **argp = argv;
52
53     if (!*(++argp))
54         Usage();
55     *cellName = *(argp++);
56     if (!*(argp))
57         Usage();
58     *srvrName = *(argp++);
59     if (!*(argp))
60         Usage();
61     *srvrPort = strtol(*(argp++), NULL, 0);
62     if (*srvrPort <= 0 || *srvrPort >= 65536)
63         Usage();
64     if (*(argp))
65         Usage();
66 }
67
68 int
69 main(int argc, char *argv[])
70 {
71     int rc;
72     afs_status_t st = 0;
73     struct rx_connection *conn;
74     char *srvrName;
75     long srvrPort;
76     char *cellName;
77     void *tokenHandle;
78     void *cellHandle;
79
80     ParseArgs(argc, argv, &cellName, &srvrName, &srvrPort);
81
82     rc = afsclient_Init(&st);
83     if (!rc) {
84         fprintf(stderr, "afsclient_Init, status %d\n", st);
85         exit(1);
86     }
87
88     rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
89     if (!rc) {
90         fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
91         exit(1);
92     }
93
94     rc = afsclient_CellOpen(cellName, tokenHandle, &cellHandle, &st);
95     if (!rc) {
96         fprintf(stderr, "afsclient_CellOpen, status %d\n", st);
97         exit(1);
98     }
99
100     rc = afsclient_RPCStatOpenPort(cellHandle, srvrName, srvrPort, &conn,
101                                    &st);
102     if (!rc) {
103         fprintf(stderr, "afsclient_RPCStatOpenPort, status %d\n", st);
104         exit(1);
105     }
106
107     rc = util_RPCStatsClear(conn, RXSTATS_ClearProcessRPCStats,
108                             AFS_RX_STATS_CLEAR_ALL, &st);
109     if (!rc) {
110         fprintf(stderr, "util_RPCStatsClear, status %d\n", st);
111         exit(1);
112     }
113
114     rc = afsclient_RPCStatClose(conn, &st);
115     if (!rc) {
116         fprintf(stderr, "afsclient_RPCStatClose, status %d\n", st);
117         exit(1);
118     }
119
120     rc = afsclient_CellClose(cellHandle, &st);
121     if (!rc) {
122         fprintf(stderr, "afsclient_CellClose, status %d\n", st);
123         exit(1);
124     }
125
126     rc = afsclient_TokenClose(tokenHandle, &st);
127     if (!rc) {
128         fprintf(stderr, "afsclient_TokenClose, status %d\n", st);
129         exit(1);
130     }
131
132     exit(0);
133 }