home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osr1.exe / src / CMVHOps.c < prev    next >
C/C++ Source or Header  |  1997-03-21  |  7KB  |  201 lines

  1. /* @(#)Z 1.4 com/src/cm/CMVHOps.c, odstorage, od96os2, odos29712d 97/03/21 17:19:34 (96/10/29 09:17:23) */
  2. /*====START_GENERATED_PROLOG======================================
  3.  */
  4. /*
  5.  *   COMPONENT_NAME: odstorage
  6.  *
  7.  *   CLASSES: none
  8.  *
  9.  *   ORIGINS: 82,27
  10.  *
  11.  *
  12.  *   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  13.  *   All Rights Reserved
  14.  *   Licensed Materials - Property of IBM
  15.  *   US Government Users Restricted Rights - Use, duplication or
  16.  *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  17.  *       
  18.  *   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  19.  *   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20.  *   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21.  *   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22.  *   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23.  *   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24.  *   OR PERFORMANCE OF THIS SOFTWARE.
  25.  */
  26. /*====END_GENERATED_PROLOG========================================
  27.  */
  28.  
  29. /*
  30.     File:        CMVHOps.c
  31.  
  32.     Contains:    Container Manager (Dynamic) Value Handler Operations
  33.  
  34.     Written by:    Ira L. Ruben
  35.  
  36.     Owned by:    Ed Lai
  37.  
  38.     Copyright:    ⌐ 1992-1994 by Apple Computer, Inc., all rights reserved.
  39.  
  40.     Change History (most recent first):
  41.  
  42.          <2>     8/26/94    EL        #1181622 Ownership update.
  43.          <1>      2/3/94    EL        first checked in
  44.  
  45.     To Do:
  46. */
  47.  
  48. /*---------------------------------------------------------------------------*
  49.  |                                                                           |
  50.  |                        <<<      CMVHOps.c      >>>                        |
  51.  |                                                                           |
  52.  |            Container Manager (Dynamic) Value Handler Operations           |
  53.  |                                                                           |
  54.  |                               Ira L. Ruben                                |
  55.  |                                  7/27/92                                  |
  56.  |                                                                           |
  57.  |                    Copyright Apple Computer, Inc. 1992-1994               |
  58.  |                           All rights reserved.                            |
  59.  |                                                                           |
  60.  *---------------------------------------------------------------------------*
  61.  
  62.  This routines in this file are used for dynamic values.  Currently one one special 
  63.  routines is defined to aid a dynamic value's "new value" handler in getting its
  64.  "constructor" (initialization) parameters from CMNewValue().  See CMScanDataPacket()
  65.  for further details.
  66. */
  67.  
  68.  
  69. #include <stddef.h>
  70. #include <stdio.h>
  71.  
  72. #ifndef __CMTYPES__
  73. #include "CMTypes.h"
  74. #endif
  75. #ifndef __CM_API__
  76. #include "CMAPI.h"
  77. #endif
  78. #ifndef __LISTMGR__
  79. #include "ListMgr.h"
  80. #endif
  81. #ifndef __TOCENTRIES__
  82. #include "TOCEnts.h"   
  83. #endif
  84. #ifndef __TOCOBJECTS__
  85. #include "TOCObjs.h"   
  86. #endif
  87. #ifndef __HANDLERS__
  88. #include "Handlers.h"
  89. #endif
  90. #ifndef __CONTAINEROPS__
  91. #include "Containr.h"  
  92. #endif
  93. #ifndef __SESSIONDATA__
  94. #include "Session.h"          
  95. #endif
  96. #ifndef __ERRORRPT__
  97. #include "ErrorRpt.h"      
  98. #endif
  99.                                                                     
  100.                                                                     CM_CFUNCTIONS
  101.  
  102. /* The following generates a segment directive for Mac only due to 32K Jump Table             */
  103. /* Limitations.  If you don't know what I'm talking about don't worry about it.  The        */
  104. /* default is not to generate the pragma.  Theoritically unknown pragmas in ANSI won't    */
  105. /* choke compilers that don't recognize them.  Besides why would they be looked at if        */
  106. /* it's being conditionally skipped over anyway?  I know, famous last words!                        */
  107.  
  108. #if CM_MPW
  109. #pragma segment CMHandlerOps
  110. #endif
  111.                                                                     
  112.  
  113. /*--------------------------------------------------------*
  114.  | CMScanDataPacket - extract the data from a data packet |
  115.  *--------------------------------------------------------*
  116.  
  117.  This routine is used by a dynamic value's "new value" handler to extract the fields of
  118.  a data packet passed to it by the Container Manager.  The data packet represents all
  119.  the CMNewValue() "..." parameters for the type also passed to the "new value hander".
  120.  
  121.  Only that portion of the CMNewValue() "..." parameters associated with the type are passed
  122.  in the data packet.  The Container Manager determines the parameters by the placement
  123.  of the type within its heirarchy (types may have base types) and the metadata.
  124.  
  125.  The Container Manager accesses the metadata through a "metadata" handler for the type to
  126.  build the data packet.  CMScanDataPacket() inverts the the operation and allows the "new
  127.  value" handler to extract the data back into distinct variables.  The "new value" handler
  128.  can use its own "metadata" handler to pass to the CMScanDataPacket() routine to extract
  129.  the data.  Each CMScanDataPacket() "..." parameter must be a pointer; extracted data read
  130.  from the data packet are stored into the locations pointed to by the pointers.
  131.  
  132.  The function returns the number of data items extracted and assigned to the parameters.
  133.  This could be 0 if metadata is passed as NULL, or if an error is reported and the error
  134.  reporter returns.
  135.   
  136.  See DynamicValues.[hc] for a full description of the "metadata" handler and metadata
  137.  format specifications.
  138. */
  139.  
  140. CMCount CM_VARARGS CMScanDataPacket(CMType type, CMMetaData metaData,
  141.                                                                         CMDataPacket dataPacket, ...)
  142. {
  143.     va_list             dataInitParams;
  144.     CM_ULONG            nbrAssigned;
  145.     
  146.     ExitIfBadType(type, 0);                                                        /* validate type                                        */
  147.         
  148.     va_start(dataInitParams, dataPacket);                            /* extract data into "..." variables*/
  149.     nbrAssigned = cmVScanDataPacketGuts((TOCObjectPtr)type, (CM_CHAR *)metaData,
  150.                                                                             (CM_UCHAR *)dataPacket, dataInitParams);
  151.     va_end(dataInitParams);
  152.     
  153.     return ((CMCount)nbrAssigned);                                        /* return nbr of values assigned        */
  154. }
  155.  
  156.  
  157. /*--------------------------------------------------------*
  158.  | CMVScanDataPacket - extract the data from a data packet |
  159.  *--------------------------------------------------------*
  160.  
  161.  This routine is the same as CMScanDataPacket() above, except that the CMNewValue()
  162.  "..." parameters are given as a variable argument list as defined by the "stdarg"
  163.  facility.
  164.  
  165.  This routine assumes the caller sets up and terminates the variable arg list using the
  166.  "stdarg.h" calls as follows:
  167.  
  168.              #include <stdarg.h>
  169.             
  170.              callersRoutine(args, ...)
  171.             {
  172.                 va_list dataInitParams;
  173.                 
  174.                 - - -
  175.                 
  176.                 va_start(dataInitParams, args);
  177.                 n = CMScanDataPacket(type, metaData, dataPacket, dataInitParams);
  178.                 va_end(dataInitParams);
  179.                 
  180.                 - - -
  181.             }
  182.             
  183.  See CMScanDataPacket() for further details.
  184. */
  185.  
  186. CMCount CM_FIXEDARGS CMVScanDataPacket(CMType type, CMMetaData metaData,
  187.                                                                              CMDataPacket dataPacket,
  188.                                                                               va_list dataInitParams)
  189. {
  190.     CM_ULONG    nbrAssigned;
  191.     
  192.     ExitIfBadType(type, 0);                                                        /* validate type                                        */
  193.         
  194.     nbrAssigned = cmVScanDataPacketGuts((TOCObjectPtr)type, (CM_CHAR *)metaData,
  195.                                                                             (CM_UCHAR *)dataPacket, dataInitParams);
  196.     
  197.     return ((CMCount)nbrAssigned);                                        /* return nbr of values assigned        */
  198. }
  199.                                                           
  200.                                                             CM_END_CFUNCTIONS
  201.