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 Progname = strrchr(argv[0], '/');
77 /* Crack and validate the command line options. */
79 while ((opt = getopt(argc, argv, "b:m:f")) != EOF) {
82 buflen = atol(optarg);
85 maxmsgs = atol(optarg);
94 if (optind + 1 != argc)
96 sid = atol(argv[optind]);
98 if (dm_init_service(&name) == -1) {
99 fprintf(stderr, "Can't initialize the DMAPI\n");
104 if ((bufp = malloc(buflen)) == NULL) {
105 fprintf(stderr, "malloc failed, %s\n", strerror(errno));
110 if (dm_get_events(sid, maxmsgs, flags, buflen, bufp, &rlenp)) {
111 if (errno == E2BIG) {
112 fprintf(stderr, "dm_get_events buffer too small, "
113 "should be %zd bytes\n", rlenp);
115 fprintf(stderr, "dm_get_events failed, (%d)%s\n",
116 errno, strerror(errno));
120 fprintf(stdout, "rlenp=%zd\n", rlenp);
126 while (msg != NULL) {
127 print_one_message(msg);
128 msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *);