2
0

isaddindex.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  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)
  10. * any later version.
  11. *
  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
  16. * details.
  17. *
  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
  22. */
  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: isaddindex.c /main/3 1995/10/23 11:33:26 rswiston $ */
  28. /*
  29. * Copyright (c) 1988 by Sun Microsystems, Inc.
  30. */
  31. /*
  32. * isaddindex.c
  33. *
  34. * Description:
  35. * Add secondary index to ISAM file
  36. */
  37. #include "isam_impl.h"
  38. #include <sys/time.h>
  39. /*
  40. * err = isaddindex(isfd, keydesc)
  41. *
  42. * Isaddindex() is used to add an alternate index to ISAM file.
  43. *
  44. * Errors:
  45. * EBADKEY error in keydesc
  46. * EDUPL there are duplicate keys and the keydesc does not allow
  47. * duplicate keys
  48. * EKEXISTS key with the same key descriptor already exists
  49. * ENOTEXCL ISAM file is not open in exclusive mode
  50. * ENOTOPEN the ISAM file is not open in ISINOUT mode.
  51. * EACCES Cannot create index file because of UNIX error.
  52. */
  53. int
  54. isaddindex(int isfd, struct keydesc *keydesc)
  55. {
  56. int _amaddindex();
  57. Fab *fab;
  58. int ret;
  59. /*
  60. * Get File Access Block.
  61. */
  62. if ((fab = _isfd_find(isfd)) == NULL) {
  63. _setiserrno2(ENOTOPEN, '9', '0');
  64. return (ISERROR);
  65. }
  66. /*
  67. * Check that the open mode was ISOUTPUT
  68. */
  69. if (fab->openmode != OM_INOUT) {
  70. _setiserrno2(ENOTOPEN, '9', '0');
  71. return (ISERROR);
  72. }
  73. ret = _amaddindex(&fab->isfhandle, keydesc, &fab->errcode);
  74. _seterr_errcode(&fab->errcode);
  75. return (ret); /* Successful write */
  76. }