1 /* cvm/cvm-benchclient.c - CVM benchmark client
2 * Copyright (C) 2010 Bruce Guenter <bruce@untroubled.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 #include <stdlib.h>
19 #include "v2client.h"
20
21 #include <bglibs/fmt.h>
22 #include <bglibs/msg.h>
23
24 const char program[] = "cvm-benchclient";
25 const int msg_show_pid = 0;
26 const char usage[] = "\n"
27 "usage: cvm-benchclient count cvmodule account domain\n"
28 " or: cvm-benchclient count cvmodule account domain password\n";
29
main(int argc,char ** argv)30 int main(int argc, char** argv)
31 {
32 int a;
33 unsigned long count;
34 unsigned long i;
35 char* ptr;
36 char num[FMT_ULONG_LEN];
37
38 if (argc < 5)
39 die2(1, "Too few command-line arguments", usage);
40 if (argc > 6)
41 die2(1, "Too many command-line arguments", usage);
42
43 if ((count = strtoul(argv[1], &ptr, 10)) == 0 || *ptr)
44 die2(1, "Invalid number for count: ", argv[1]);
45
46 for (i = 0; i < count; i++) {
47 if ((a = cvm_client_authenticate_password(argv[2],
48 argv[3], argv[4], argv[5], 0)) != 0) {
49 num[fmt_udec(num, a)] = 0;
50 die5(a, "Authentication failed, error #", num, " (",
51 (a < cvm_nerr) ? cvm_errlist[i] : "Unknown error code", ")");
52 }
53 }
54 return 0;
55 }
56