2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 /*---------------------------------------------------------------------------
26 Test program used to test the DMAPI function dm_get_events(). The
29 get_events [-b buflen] [-m maxmsgs] [-f] sid
31 where buflen is the size of the buffer to use, maxmsgs is the number of messages
32 to read, -f, if selected, is DM_EV_WAIT, and sid is the session ID
33 whose dispositions you are interested in.
35 ----------------------------------------------------------------------------*/
38 extern char *sys_errlist[];
49 fprintf(stderr, "usage:\t%s [-b buflen] [-m maxmsgs] [-f] sid\n",
64 size_t buflen = 10000;
70 if (Progname = strrchr(argv[0], '/')) {
76 /* Crack and validate the command line options. */
78 while ((opt = getopt(argc, argv, "b:m:f")) != EOF) {
81 buflen = atol(optarg);
84 maxmsgs = atol(optarg);
93 if (optind + 1 != argc)
95 sid = atol(argv[optind]);
97 if (dm_init_service(&name) == -1) {
98 fprintf(stderr, "Can't initialize the DMAPI\n");
103 if ((bufp = malloc(buflen)) == NULL) {
104 fprintf(stderr, "malloc failed, %s\n", strerror(errno));
109 if (dm_get_events(sid, maxmsgs, flags, buflen, bufp, &rlenp)) {
110 if (errno == E2BIG) {
111 fprintf(stderr, "dm_get_events buffer too small, "
112 "should be %d bytes\n", rlenp);
114 fprintf(stderr, "dm_get_events failed, (%d)%s\n",
115 errno, strerror(errno));
119 fprintf(stdout, "rlenp=%d\n", rlenp);
125 while (msg != NULL) {
126 print_one_message(msg);
127 msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *);