2
0

cmcbxdr.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. /* $XConsortium: cmcbxdr.c /main/1 1996/04/21 19:22:05 drk $ */
  24. /*
  25. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  26. * (c) Copyright 1993, 1994 International Business Machines Corp.
  27. * (c) Copyright 1993, 1994 Novell, Inc.
  28. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  29. */
  30. /*
  31. * xdr routines for v2 callback protocol data structures
  32. */
  33. #include <EUSCompat.h>
  34. #include "cmcb.h"
  35. #include "csa.h"
  36. /*
  37. * cal_attr_data - contain names of calendar attributes updated
  38. */
  39. bool_t
  40. xdr_cmcb_cal_attr_data(XDR *xdrs, cmcb_cal_attr_data *objp)
  41. {
  42. if (!xdr_array(xdrs, (char **)&objp->names, (u_int *) &objp->num_names,
  43. ~0, sizeof (cms_name), (xdrproc_t) xdr_cms_name))
  44. return (FALSE);
  45. return (TRUE);
  46. }
  47. /*
  48. * add_entry_data - contain information of the deleted entry
  49. */
  50. bool_t
  51. xdr_cmcb_add_entry_data(XDR *xdrs, cmcb_add_entry_data *objp)
  52. {
  53. if (!xdr_string(xdrs, &objp->id, ~0))
  54. return (FALSE);
  55. return (TRUE);
  56. }
  57. /*
  58. * delete_entry_data - contain information of the deleted entry
  59. */
  60. bool_t
  61. xdr_cmcb_delete_entry_data(XDR *xdrs, cmcb_delete_entry_data *objp)
  62. {
  63. if (!xdr_string(xdrs, &objp->id, ~0))
  64. return (FALSE);
  65. if (!xdr_int(xdrs, &objp->scope))
  66. return (FALSE);
  67. if (!xdr_long(xdrs, &objp->time))
  68. return (FALSE);
  69. return (TRUE);
  70. }
  71. /*
  72. * update_entry_data - contain information of the updated entry
  73. * if new entry id is not resulted from the update, oldid will be
  74. * set to a NULL string ("").
  75. */
  76. bool_t
  77. xdr_cmcb_update_entry_data(XDR *xdrs, cmcb_update_entry_data *objp)
  78. {
  79. if (!xdr_string(xdrs, &objp->newid, ~0))
  80. return (FALSE);
  81. if (!xdr_string(xdrs, &objp->oldid, ~0))
  82. return (FALSE);
  83. if (!xdr_int(xdrs, &objp->scope))
  84. return (FALSE);
  85. if (!xdr_long(xdrs, &objp->time))
  86. return (FALSE);
  87. return (TRUE);
  88. }
  89. bool_t
  90. xdr_cmcb_update_data(XDR *xdrs, cmcb_update_data *objp)
  91. {
  92. if (!xdr_int(xdrs, &objp->reason))
  93. return (FALSE);
  94. switch (objp->reason) {
  95. case CSA_CB_CALENDAR_ATTRIBUTE_UPDATED:
  96. if (!xdr_pointer(xdrs, (char **)&objp->data.cdata,
  97. sizeof (cmcb_cal_attr_data),
  98. (xdrproc_t) xdr_cmcb_cal_attr_data))
  99. return (FALSE);
  100. break;
  101. case CSA_CB_ENTRY_ADDED:
  102. if (!xdr_pointer(xdrs, (char **)&objp->data.adata,
  103. sizeof (cmcb_add_entry_data),
  104. (xdrproc_t) xdr_cmcb_add_entry_data))
  105. return (FALSE);
  106. break;
  107. case CSA_CB_ENTRY_DELETED:
  108. if (!xdr_pointer(xdrs, (char **)&objp->data.ddata,
  109. sizeof (cmcb_delete_entry_data),
  110. (xdrproc_t) xdr_cmcb_delete_entry_data))
  111. return (FALSE);
  112. break;
  113. case CSA_CB_ENTRY_UPDATED:
  114. if (!xdr_pointer(xdrs, (char **)&objp->data.udata,
  115. sizeof (cmcb_update_entry_data),
  116. (xdrproc_t) xdr_cmcb_update_entry_data))
  117. return (FALSE);
  118. break;
  119. }
  120. return (TRUE);
  121. }
  122. bool_t
  123. xdr_cmcb_update_callback_args(XDR *xdrs, cmcb_update_callback_args *objp)
  124. {
  125. if (!xdr_string(xdrs, &objp->calendar, ~0))
  126. return (FALSE);
  127. if (!xdr_string(xdrs, &objp->user, ~0))
  128. return (FALSE);
  129. if (!xdr_cmcb_update_data(xdrs, &objp->data))
  130. return (FALSE);
  131. return (TRUE);
  132. }