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/
39 /*---------------------------------------------------------------------------
41 Test program used to test the DMAPI function dm_set_eventlist(). The
44 set_eventlist [-F] [-m max] [-s sid] [-t token] {pathname|handle} event [...]
48 is either the pathname of a file or a handle.
50 is the value to use for the maxevent parameter of dm_set_eventlist().
52 is the dm_sessid_t value to use.
54 is the dm_token_t value to use (DM_NO_TOKEN is the default).
56 is one or more events to set.
58 ----------------------------------------------------------------------------*/
61 extern char *sys_errlist[];
75 fprintf(stderr, "usage:\t%s [-F] [-m max] [-s sid] "
76 "{pathname|handle} event [...]\n", Progname);
77 fprintf(stderr, "possible events are:\n");
78 for (i = 0; i < ev_namecnt; i++) {
79 fprintf(stderr, "%s (%d)\n", ev_names[i].name,
91 dm_sessid_t sid = DM_NO_SESSION;
92 dm_token_t token = DM_NO_TOKEN;
94 dm_eventset_t eventset;
98 u_int maxevent = DM_EVENT_MAX;
102 if (Progname = strrchr(argv[0], '/')) {
108 /* Crack and validate the command line options. */
110 while ((opt = getopt(argc, argv, "Fm:s:t:")) != EOF) {
116 maxevent = atol(optarg);
122 token = atol(optarg);
128 if (optind + 1 > argc)
130 object = argv[optind++];
132 if (dm_init_service(&name) == -1) {
133 fprintf(stderr, "Can't inititalize the DMAPI\n");
136 if (sid == DM_NO_SESSION)
137 find_test_session(&sid);
141 /* Get the file's handle or convert the external handle. */
143 if (opaque_to_handle(object, &hanp, &hlen)) {
144 fprintf(stderr, "can't get handle for %s\n", object);
152 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
153 fprintf(stderr, "can't get filesystem handle from %s\n",
157 dm_handle_free(hanp, hlen);
162 for (; optind < argc; optind++) {
163 dm_eventtype_t event;
165 event = ev_name_to_value(argv[optind]);
166 if (event == DM_EVENT_INVALID) {
167 fprintf(stderr, "invalid event %s\n", argv[optind]);
170 DMEV_SET(event, eventset);
173 if (dm_set_eventlist(sid, hanp, hlen, token, &eventset, maxevent)) {
174 fprintf(stderr, "dm_set_eventlist failed, %s\n",
179 dm_handle_free(hanp, hlen);