isamerror.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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: isamerror.c /main/3 1995/10/23 11:34:39 rswiston $ */
  28. /*
  29. * Copyright (c) 1988 by Sun Microsystems, Inc.
  30. */
  31. /*
  32. * isamerror.c
  33. *
  34. * Description:
  35. * Error handling functions for the Access Method layer.
  36. *
  37. *
  38. */
  39. #include "isam_impl.h"
  40. #define ESENTINEL -100 /* Must not be a valid errno */
  41. static struct errstattab {
  42. int iserrno;
  43. char isstat1;
  44. char isstat2;
  45. } errstattab[] = {
  46. { ISOK, '0', '0'},
  47. { ENOREC, '2', '3'},
  48. { ENOCURR, '2', '1'},
  49. { EENDFILE, '1', '0'},
  50. { EDUPL, '2', '2'},
  51. { ENOTOPEN, '9', '0'},
  52. { EBADARG, '9', '0'},
  53. { EBADKEY, '9', '0'},
  54. { ETOOMANY, '9', '0'},
  55. { EBADFILE, '9', '0'},
  56. { ENOTEXCL, '9', '0'},
  57. { ELOCKED, '9', '0'},
  58. { EKEXISTS, '9', '0'},
  59. { EPRIMKEY, '9', '0'},
  60. { EFLOCKED, '9', '0'},
  61. { EFNAME, '9', '0'},
  62. { EFATAL, '9', '0'},
  63. /* Unix errors */
  64. { ENOENT, '9', '0'},
  65. { EACCES, '9', '0'},
  66. { EEXIST, '9', '0'},
  67. { ENOSPC, '9', '0'},
  68. /* search sentinel */
  69. { ESENTINEL, '9', '0'}
  70. };
  71. /*
  72. * _amseterrcode(errcode, is_errno, is_stat1, is_stat2, is_stat3, is_stat4)
  73. *
  74. * Set errcode block with ISAM error codes.
  75. */
  76. void
  77. _amseterrcode(struct errcode *errcode, int is_errno)
  78. {
  79. struct errstattab *p;
  80. errcode->iserrno = is_errno;
  81. /*
  82. * Search errstattab to get appropriate isstat[12] values.
  83. */
  84. for (p = errstattab; p->iserrno != ESENTINEL; p++) {
  85. if (p->iserrno == is_errno) {
  86. errcode->isstat[0] = p->isstat1;
  87. errcode->isstat[1] = p->isstat2;
  88. break;
  89. }
  90. }
  91. if (is_errno == 0 && isdupl == 1)
  92. errcode->isstat[1] = '2'; /* Indicate allowed duplicates */
  93. }