2 * Copyright (c) 2000-2001 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_getall_disp(). The
29 getall_disp [-b buflen] sid
31 where buflen is the size of the buffer to use, and sid is the session ID
32 whose dispositions you you are interested in.
34 ----------------------------------------------------------------------------*/
37 extern char *sys_errlist[];
48 fprintf(stderr, "usage:\t%s [-b buflen] sid\n",
62 size_t buflen = 10000;
65 char hans1[HANDLE_STR];
70 Progname = strrchr(argv[0], '/');
77 /* Crack and validate the command line options. */
79 while ((opt = getopt(argc, argv, "b:")) != EOF) {
82 buflen = atol(optarg);
88 if (optind + 1 != argc)
90 sid = atol(argv[optind]);
92 if (dm_init_service(&name) == -1) {
93 fprintf(stderr, "Can't initialize the DMAPI\n");
98 if ((bufp = malloc(buflen)) == NULL) {
99 fprintf(stderr, "malloc failed, %s\n", strerror(errno));
104 if (dm_getall_disp(sid, buflen, bufp, &rlenp)) {
105 if (errno == E2BIG) {
106 fprintf(stderr, "dm_getall_disp buffer too small, "
107 "should be %zd bytes\n", rlenp);
109 fprintf(stderr, "dm_getall_disp failed, %s\n",
114 fprintf(stdout, "rlenp is %zd\n", rlenp);
119 while (disp != NULL) {
120 hanp = DM_GET_VALUE(disp, di_fshandle, void *);
121 hlen = DM_GET_LEN(disp, di_fshandle);
123 hantoa(hanp, hlen, hans1);
125 sprintf(hans1, "<BAD HANDLE, hlen %zd>", hlen);
127 printf("%-15s %s dm_eventset_t 0%llo\n",
129 (unsigned long long) disp->di_eventset);
131 disp = DM_STEP_TO_NEXT(disp, dm_dispinfo_t *);