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
25 /*---------------------------------------------------------------------------
27 Test program used to test the DMAPI function dm_set_dmattr(). The
30 set_dmattr [-b buflen] [-s sid] [-u] {pathname|handle} attr value
32 where pathname is the name of a file, buflen is the size of the buffer to use
33 in the call, attr is the name of the DMAPI attribute, -u is selected if
34 setdtime should be updated, and sid is the session ID whose attributes you
37 ----------------------------------------------------------------------------*/
40 extern char *sys_errlist[];
51 fprintf(stderr, "usage:\t%s [-b buflen] [-s sid] [-u] "
52 "{pathname|handle} attr value\n", Progname);
62 dm_sessid_t sid = DM_NO_SESSION;
64 dm_attrname_t *attrnamep;
74 Progname = strrchr(argv[0], '/');
81 /* Crack and validate the command line options. */
83 while ((opt = getopt(argc, argv, "b:s:u")) != EOF) {
87 buflen = atol(optarg);
99 if (optind + 3 != argc)
101 object = argv[optind++];
102 attrnamep = (dm_attrname_t *)argv[optind++];
105 buflen = strlen(bufp) + 1;
107 if (dm_init_service(&name) == -1) {
108 fprintf(stderr, "Can't initialize the DMAPI\n");
111 if (sid == DM_NO_SESSION)
112 find_test_session(&sid);
114 /* Get the file's handle. */
116 if (opaque_to_handle(object, &hanp, &hlen)) {
117 fprintf(stderr, "can't get handle for %s\n", object);
121 if (dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, attrnamep, setdtime,
123 fprintf(stderr, "dm_set_dmattr failed, %s\n",
128 dm_handle_free(hanp, hlen);