2
0

isindexconv.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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: isindexconv.c /main/3 1995/10/23 11:40:48 rswiston $ */
  28. /*
  29. * Copyright (c) 1988 by Sun Microsystems, Inc.
  30. */
  31. /*
  32. * isindexconv.c
  33. *
  34. * Description:
  35. * Encode/decode key descriptor
  36. */
  37. #include "isam_impl.h"
  38. void
  39. stkey(Keydesc2 *pkeydesc2, char *p)
  40. {
  41. int i;
  42. struct keypart2 *ppart;
  43. char *pp;
  44. int nparts;
  45. stshort(pkeydesc2->k2_flags, p + K2_FLAGS_OFF);
  46. stshort(pkeydesc2->k2_nparts, p + K2_NPARTS_OFF);
  47. stshort(pkeydesc2->k2_len, p + K2_LEN_OFF);
  48. stblkno(pkeydesc2->k2_rootnode, p + K2_ROOT_OFF);
  49. stlong((long)pkeydesc2->k2_keyid, p + K2_KEYID_OFF);
  50. ppart = pkeydesc2->k2_part;
  51. pp = p + K2_KEYPART_OFF;
  52. nparts = pkeydesc2->k2_nparts + 1; /* +1 for recno part */
  53. if (ALLOWS_DUPS2(pkeydesc2)) /* +1 for dups serial number*/
  54. nparts++;
  55. for (i = 0; i < nparts;i++) {
  56. stshort(ppart->kp2_start, pp);
  57. pp += SHORTSIZE;
  58. stshort(ppart->kp2_leng, pp);
  59. pp += SHORTSIZE;
  60. stshort(ppart->kp2_type, pp);
  61. pp += SHORTSIZE;
  62. stshort(ppart->kp2_offset, pp);
  63. pp += SHORTSIZE;
  64. ppart++;
  65. }
  66. }
  67. void
  68. ldkey(struct keydesc2 *pkeydesc2, char *p)
  69. {
  70. int i;
  71. struct keypart2 *ppart;
  72. char *pp;
  73. int nparts;
  74. memset ((char *) pkeydesc2, 0, sizeof (*pkeydesc2));
  75. pkeydesc2->k2_flags = ldshort(p + K2_FLAGS_OFF);
  76. pkeydesc2->k2_nparts = ldshort(p + K2_NPARTS_OFF);
  77. pkeydesc2->k2_len = ldshort(p + K2_LEN_OFF);
  78. pkeydesc2->k2_rootnode = ldblkno(p + K2_ROOT_OFF);
  79. pkeydesc2->k2_keyid = ldlong(p + K2_KEYID_OFF);
  80. ppart = pkeydesc2->k2_part;
  81. pp = p + K2_KEYPART_OFF;
  82. nparts = pkeydesc2->k2_nparts + 1; /* +1 for recno part */
  83. if (ALLOWS_DUPS2(pkeydesc2)) /* +1 for dups serial number*/
  84. nparts++;
  85. for (i = 0; i < nparts;i++) {
  86. ppart->kp2_start = ldunshort(pp);
  87. pp += SHORTSIZE;
  88. ppart->kp2_leng = ldshort(pp);
  89. pp += SHORTSIZE;
  90. ppart->kp2_type = ldshort(pp);
  91. pp += SHORTSIZE;
  92. ppart->kp2_offset = ldunshort(pp);
  93. pp += SHORTSIZE;
  94. ppart++;
  95. }
  96. }