2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 /*---------------------------------------------------------------------------
40 Test program used to test the DMAPI function dm_get_events(). The
43 get_events [-b buflen] [-m maxmsgs] [-f] sid
45 where buflen is the size of the buffer to use, maxmsgs is the number of messages
46 to read, -f, if selected, is DM_EV_WAIT, and sid is the session ID
47 whose dispositions you are interested in.
49 ----------------------------------------------------------------------------*/
52 extern char *sys_errlist[];
63 fprintf(stderr, "usage:\t%s [-b buflen] [-m maxmsgs] [-f] sid\n",
78 size_t buflen = 10000;
84 if (Progname = strrchr(argv[0], '/')) {
90 /* Crack and validate the command line options. */
92 while ((opt = getopt(argc, argv, "b:m:f")) != EOF) {
95 buflen = atol(optarg);
98 maxmsgs = atol(optarg);
107 if (optind + 1 != argc)
109 sid = atol(argv[optind]);
111 if (dm_init_service(&name) == -1) {
112 fprintf(stderr, "Can't initialize the DMAPI\n");
117 if ((bufp = malloc(buflen)) == NULL) {
118 fprintf(stderr, "malloc failed, %s\n", strerror(errno));
123 if (dm_get_events(sid, maxmsgs, flags, buflen, bufp, &rlenp)) {
124 if (errno == E2BIG) {
125 fprintf(stderr, "dm_get_events buffer too small, "
126 "should be %d bytes\n", rlenp);
128 fprintf(stderr, "dm_get_events failed, (%d)%s\n",
129 errno, strerror(errno));
133 fprintf(stdout, "rlenp is %d\n", rlenp);
139 while (msg != NULL) {
140 print_one_message(msg);
141 msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *);