1 /*
2 * Copyright (c) 2005-2007 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 *
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 */
9
10 #pragma ident "%Z%%M% %I% %E% SMI"
11
12 #include <sm/gen.h>
13 SM_IDSTR(id, "@(#)$Id: t-memstat.c,v 1.9 2007/03/14 21:41:09 ca Exp $")
14
15 #include <sm/misc.h>
16
17 /*
18 ** Simple test program for memstat
19 */
20
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <stdio.h>
24 #include <strings.h>
25 #include <string.h>
26
27 extern char *optarg;
28 extern int optind;
29
30 void
31 usage(prg)
32 char *prg;
33 {
48 long v;
49 char *resource;
50
51 l = 1;
52 sz = slp = 0;
53 resource = NULL;
54 while ((r = getopt(argc, argv, "l:m:r:s:")) != -1)
55 {
56 switch ((char) r)
57 {
58 case 'l':
59 l = strtol(optarg, NULL, 0);
60 break;
61
62 case 'm':
63 sz = strtol(optarg, NULL, 0);
64 break;
65
66 case 'r':
67 resource = strdup(optarg);
68 break;
69
70 case 's':
71 slp = strtol(optarg, NULL, 0);
72 break;
73
74 default:
75 usage(argv[0]);
76 exit(1);
77 }
78 }
79
80 r = sm_memstat_open();
81 r2 = -1;
82 for (i = 0; i < l; i++)
83 {
84 char *mem;
85
86 r2 = sm_memstat_get(resource, &v);
87 if (slp > 0 && i + 1 < l && 0 == r)
|
1 /*
2 * Copyright (c) 2005-2007 Proofpoint, Inc. and its suppliers.
3 * All rights reserved.
4 *
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 */
9
10 #include <sm/gen.h>
11 SM_IDSTR(id, "@(#)$Id: t-memstat.c,v 1.11 2013-11-22 20:51:43 ca Exp $")
12
13 #include <sm/misc.h>
14
15 /*
16 ** Simple test program for memstat
17 */
18
19 #include <stdlib.h>
20 #include <unistd.h>
21 #include <stdio.h>
22 #include <strings.h>
23 #include <string.h>
24
25 extern char *optarg;
26 extern int optind;
27
28 void
29 usage(prg)
30 char *prg;
31 {
46 long v;
47 char *resource;
48
49 l = 1;
50 sz = slp = 0;
51 resource = NULL;
52 while ((r = getopt(argc, argv, "l:m:r:s:")) != -1)
53 {
54 switch ((char) r)
55 {
56 case 'l':
57 l = strtol(optarg, NULL, 0);
58 break;
59
60 case 'm':
61 sz = strtol(optarg, NULL, 0);
62 break;
63
64 case 'r':
65 resource = strdup(optarg);
66 if (resource == NULL)
67 {
68 fprintf(stderr, "strdup(%s) failed\n",
69 optarg);
70 exit(1);
71 }
72 break;
73
74 case 's':
75 slp = strtol(optarg, NULL, 0);
76 break;
77
78 default:
79 usage(argv[0]);
80 exit(1);
81 }
82 }
83
84 r = sm_memstat_open();
85 r2 = -1;
86 for (i = 0; i < l; i++)
87 {
88 char *mem;
89
90 r2 = sm_memstat_get(resource, &v);
91 if (slp > 0 && i + 1 < l && 0 == r)
|