2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
24 /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
25 /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
26 /*%% (c) Copyright 1993, 1994 Novell, Inc. */
27 /*%% $XConsortium: isapplmr.c /main/3 1995/10/23 11:35:25 rswiston $ */
29 * Copyright (c) 1988 by Sun Microsystems, Inc.
36 * Read Application magic string
40 #include "isam_impl.h"
44 #include "isam_impl.h"
47 * string = isapplmr(isfd)
49 * Isapplmr() returns the aplication magic string written to the ISAM file
50 * by isapplmw() function. No magic string is returned as "". The value
51 * of -1 returned indicates an error (iserrno is set).
56 _isapplmr(int isfd, char *buffer)
60 char cntl_page[CP_NKEYS_OFF];
63 * Get File Access Block.
65 if ((fab = _isfd_find(isfd)) == NULL) {
66 _setiserrno2(ENOTOPEN, '9', '0');
71 * Check that the open mode was ISINPUT, or ISINOUT.
73 if (fab->openmode != OM_INPUT && fab->openmode != OM_INOUT) {
74 _setiserrno2(ENOTOPEN, '9', '0');
81 * Get FCB corresponding to the isfhandle handle.
83 if ((fcb = _openfcb(&fab->isfhandle, &fab->errcode)) == NULL) {
88 _isseekpg(fcb->datfd, ISCNTLPGOFF);
89 (void)read(fcb->datfd, cntl_page, sizeof(cntl_page));
90 strncpy(buffer, cntl_page + CP_APPLMAGIC_OFF, CP_APPLMAGIC_LEN);
92 _amseterrcode(&fab->errcode, ISOK);
95 _seterr_errcode(&fab->errcode);
97 return (ISOK); /* Successful write */