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

  1. /* @(#)Z 1.4 com/src/bento/BentoHdr.cpp, odstorage, od96os2, odos29712d 97/03/21 17:19:01 (96/10/29 09:10:42) */
  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:        BentoHdr.cpp
  31.  
  32.     Contains:    Bento Handlers
  33.  
  34.     Owned by:    Vincent Lo
  35.  
  36.     Copyright:    ⌐ 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  37.  
  38.     Change History (most recent first):
  39.  
  40.          <2>     5/26/95    VL        1251403: Multithreading naming support.
  41.          <1>     5/27/94    VL        first checked in
  42.  
  43.     To Do:
  44. */
  45.  
  46. #ifndef _BENTOHDR_
  47. #include "BentoHdr.h"
  48. #endif
  49.  
  50. #ifndef __CM_API__
  51. #include "CMAPI.h"
  52. #endif
  53.  
  54. #ifndef __CM_API_STDOBJIDS_
  55. #include "CMAPIIDs.h"
  56. #endif
  57.  
  58. #ifndef __STRING__
  59. #include "string.h"                // for strcmp
  60. #endif
  61.  
  62. #pragma segment BentoHdr
  63.  
  64. //==============================================================================
  65. // Function Prototype
  66. //==============================================================================
  67.  
  68.      CM_CFUNCTIONS
  69.  
  70. CMHandlerAddr CM_FIXEDARGS containerMetahandler(CMType targetType, CMconst_CMGlobalName operationType);
  71.                                                                 
  72. static CMRefCon open_Handler(CMRefCon attributes, CMOpenMode mode);
  73. static void close_Handler(CMRefCon refCon);
  74. static CMSize flush_Handler(CMRefCon refCon);
  75. static CMSize seek_Handler(CMRefCon refCon, CM_LONG posOff, CMSeekMode mode);
  76. static CMSize tell_Handler(CMRefCon refCon);
  77. static CMSize read_Handler(CMRefCon refCon, CMPtr buffer, CMSize elementSize, CMCount theCount);
  78. static CMSize write_Handler(CMRefCon refCon, CMPtr buffer, CMSize elementSize, CMCount theCount);
  79. static CMEofStatus eof_Handler(CMRefCon refCon);
  80. static CMBoolean trunc_Handler(CMRefCon refCon, CMSize containerSize);
  81. static CMSize containerSize_Handler(CMRefCon refCon);
  82. static void readLabel_Handler(CMRefCon refCon, CMMagicBytes magicByteSequence,
  83.                             CMContainerFlags *flags, CM_USHORT *bufSize,
  84.                             CM_USHORT *majorVersion, CM_USHORT *minorVersion,
  85.                             CMSize *tocOffset, CMSize *tocSize);
  86. static void writeLabel_Handler(CMRefCon refCon, CMMagicBytes magicByteSequence,
  87.                             CMContainerFlags flags, CM_USHORT bufSize,
  88.                             CM_USHORT majorVersion, CM_USHORT minorVersion,
  89.                             CMSize tocOffset, CMSize tocSize);    
  90. static CMValue returnParentValue_Handler(CMRefCon refCon);
  91. static CM_UCHAR *returnContainerName_Handler(CMRefCon refCon);
  92. static CMType returnTargetType_Handler(CMRefCon refCon, CMContainer container);    
  93. static void extractData_Handler(CMRefCon refCon, CMDataBuffer buffer,
  94.                                  CMSize size, CMPrivateData data);
  95. static void formatData_Handler(CMRefCon refCon, CMDataBuffer buffer,
  96.                                 CMSize size, CMPrivateData data);
  97.                                                                  
  98.     CM_END_CFUNCTIONS
  99.  
  100. //------------------------------------------------------------------------------
  101. // containerMetahandler
  102. //------------------------------------------------------------------------------
  103. CMHandlerAddr CM_FIXEDARGS containerMetahandler(CMType targetType, CMconst_CMGlobalName operationType)
  104. {
  105.     static char *operationTypes[] = {CMOpenOpType,                        /*  0 */
  106.                                      CMCloseOpType,                        /*  1 */
  107.                                      CMFlushOpType,                        /*  2 */
  108.                                      CMSeekOpType,                        /*  3 */
  109.                                      CMTellOpType,                        /*  4 */
  110.                                      CMReadOpType,                        /*  5 */
  111.                                      CMWriteOpType,                        /*  6 */
  112.                                      CMEofOpType,                        /*  7 */
  113.                                      CMTruncOpType,                        /*  8 */
  114.                                      CMSizeOpType,                        /*  9 */
  115.                                      CMReadLblOpType,                    /* 10 */
  116.                                      CMWriteLblOpType,                    /* 11 */
  117.                                      CMParentOpType,                    /* 12 */
  118.                                      CMContainerOpName,                    /* 13 */
  119.                                      CMTargetTypeOpType,                /* 14 */
  120.                                      CMExtractDataOpType,                /* 15 */
  121.                                      CMFormatDataOpType,                /* 16 */
  122.                                      NULL};
  123.     char      **t;
  124.     CMType ignored = targetType;
  125.         
  126.     t = operationTypes - 1;
  127.     while (*++t) if (strcmp((char *)operationType, *t) == 0) break;
  128.     
  129.     switch (t - operationTypes) {
  130.         case  0:    return ((CMHandlerAddr)open_Handler);                /*CMOpenOpType             */
  131.         case  1:    return ((CMHandlerAddr)close_Handler);                /*CMCloseOpType         */
  132.         case  2:    return ((CMHandlerAddr)flush_Handler);                /*CMFlushOpType         */
  133.         case  3:    return ((CMHandlerAddr)seek_Handler);                /*CMSeekOpType             */
  134.         case  4:    return ((CMHandlerAddr)tell_Handler);                /*CMTellOpType             */
  135.         case  5:    return ((CMHandlerAddr)read_Handler);                /*CMReadOpType             */
  136.         case  6:    return ((CMHandlerAddr)write_Handler);                /*CMWriteOpType         */
  137.         case  7:    return ((CMHandlerAddr)eof_Handler);                /*CMEofOpType             */
  138.         case  8:    return ((CMHandlerAddr)trunc_Handler);                /*CMTruncOpType            */
  139.         case  9:    return ((CMHandlerAddr)containerSize_Handler);        /*CMSizeOpType             */
  140.         case 10:    return ((CMHandlerAddr)readLabel_Handler);            /*CMReadLblOpType         */
  141.         case 11:    return ((CMHandlerAddr)writeLabel_Handler);            /*CMWriteLblOpType         */
  142.         case 12:    return ((CMHandlerAddr)returnParentValue_Handler);    /*CMParentOpType        */
  143.         case 13:    return ((CMHandlerAddr)returnContainerName_Handler);/*CMContainerOpName        */
  144.         case 14:    return ((CMHandlerAddr)returnTargetType_Handler);    /*CMTargetTypeOpType    */
  145.         case 15:    return ((CMHandlerAddr)extractData_Handler);        /*CMExtractDataOpType    */
  146.         case 16:    return ((CMHandlerAddr)formatData_Handler);         /*CMFormatDataOpType    */
  147.         
  148.         default:    return (NULL);
  149.     }
  150. }
  151.  
  152. //------------------------------------------------------------------------------
  153. // open_Handler
  154. //------------------------------------------------------------------------------
  155. static CMRefCon open_Handler(CMRefCon refCon, CMOpenMode mode)
  156. {
  157.     return ((ODBentoHandlers*) refCon)->OpenHandler(mode);
  158. }
  159.  
  160. //------------------------------------------------------------------------------
  161. // close_Handler
  162. //------------------------------------------------------------------------------
  163. static void close_Handler(CMRefCon refCon)
  164. {
  165.     ((ODBentoHandlers*) refCon)->CloseHandler();
  166. }
  167.  
  168. //------------------------------------------------------------------------------
  169. // flush_Handler
  170. //------------------------------------------------------------------------------
  171. static CMSize flush_Handler(CMRefCon refCon)
  172. {
  173.     return ((ODBentoHandlers*) refCon)->FlushHandler();
  174. }
  175.  
  176. //------------------------------------------------------------------------------
  177. // seek_Handler
  178. //------------------------------------------------------------------------------
  179. static CMSize seek_Handler(CMRefCon refCon, CM_LONG posOff, CMSeekMode mode)
  180. {
  181.     return ((ODBentoHandlers*) refCon)->SeekHandler(posOff, mode);
  182.  
  183. }
  184.  
  185. //------------------------------------------------------------------------------
  186. // tell_Handler
  187. //------------------------------------------------------------------------------
  188. static CMSize tell_Handler(CMRefCon refCon)
  189. {
  190.     return     ((ODBentoHandlers*) refCon)->TellHandler();
  191. }
  192.  
  193. //------------------------------------------------------------------------------
  194. // read_Handler
  195. //------------------------------------------------------------------------------
  196. static CMSize read_Handler(CMRefCon refCon,
  197.                             CMPtr buffer,
  198.                             CMSize elementSize,
  199.                             CMCount theCount)
  200. {
  201.     return ((ODBentoHandlers*) refCon)->ReadHandler(buffer, elementSize, theCount);
  202. }
  203.  
  204. //------------------------------------------------------------------------------
  205. // write_Handler
  206. //------------------------------------------------------------------------------
  207. static CMSize write_Handler(CMRefCon refCon,
  208.                             CMPtr buffer,
  209.                             CMSize elementSize,
  210.                             CMCount theCount)
  211. {
  212.     return     ((ODBentoHandlers*) refCon)->WriteHandler(buffer, elementSize, theCount);
  213. }
  214.  
  215. //------------------------------------------------------------------------------
  216. // eof_Handler
  217. //------------------------------------------------------------------------------
  218. static CMEofStatus eof_Handler(CMRefCon refCon)
  219. {
  220.     return     ((ODBentoHandlers*) refCon)->EOFHandler();
  221.  
  222. }
  223.  
  224. //------------------------------------------------------------------------------
  225. // trunc_Handler
  226. //------------------------------------------------------------------------------
  227. static CMBoolean trunc_Handler(CMRefCon refCon, CMSize containerSize)
  228. {
  229.     return ((ODBentoHandlers*) refCon)->TruncHandler(containerSize);
  230. }
  231.  
  232. //------------------------------------------------------------------------------
  233. // containerSize_Handler
  234. //------------------------------------------------------------------------------
  235. static CMSize containerSize_Handler(CMRefCon refCon)
  236. {
  237.     return ((ODBentoHandlers*) refCon)->ContainerSizeHandler();
  238.  
  239. }
  240.  
  241. //------------------------------------------------------------------------------
  242. // readLabel_Handler
  243. //------------------------------------------------------------------------------
  244. static void readLabel_Handler(CMRefCon refCon,
  245.                                 CMMagicBytes magicByteSequence,
  246.                                 CMContainerFlags *flags,
  247.                                 CM_USHORT *bufSize,
  248.                                 CM_USHORT *majorVersion,
  249.                                 CM_USHORT *minorVersion,
  250.                                 CMSize *tocOffset,
  251.                                 CMSize *tocSize)
  252. {
  253.     ((ODBentoHandlers*) refCon)->ReadLabelHandler(magicByteSequence, flags, bufSize,
  254.                                             majorVersion, minorVersion,
  255.                                             tocOffset, tocSize);
  256. }
  257.  
  258. //------------------------------------------------------------------------------
  259. // writeLabel_Handler
  260. //------------------------------------------------------------------------------
  261. static void writeLabel_Handler(CMRefCon refCon,
  262.                                 CMMagicBytes magicByteSequence,
  263.                                 CMContainerFlags flags,
  264.                                 CM_USHORT bufSize,
  265.                                 CM_USHORT majorVersion,
  266.                                 CM_USHORT minorVersion,
  267.                                 CMSize tocOffset,
  268.                                 CMSize tocSize)
  269. {
  270.     ((ODBentoHandlers*) refCon)->WriteLabelHandler(magicByteSequence,
  271.                                             flags, bufSize,
  272.                                             majorVersion, minorVersion,
  273.                                             tocOffset, tocSize);
  274. }
  275.  
  276. //------------------------------------------------------------------------------
  277. // returnParentValue_Handler
  278. //------------------------------------------------------------------------------
  279. static CMValue returnParentValue_Handler(CMRefCon refCon)
  280. {
  281.     return ((ODBentoHandlers*) refCon)->ReturnParentValueHandler();
  282. }
  283.  
  284. //------------------------------------------------------------------------------
  285. // returnContainerName_Handler
  286. //------------------------------------------------------------------------------
  287. static CM_UCHAR *returnContainerName_Handler(CMRefCon refCon)
  288. {
  289.     return ((ODBentoHandlers*) refCon)->ReturnContainerNameHandler();
  290. }
  291.  
  292. //------------------------------------------------------------------------------
  293. // returnTargetType_Handler
  294. //------------------------------------------------------------------------------
  295. static CMType returnTargetType_Handler(CMRefCon refCon, CMContainer container)
  296. {
  297.     return ((ODBentoHandlers*) refCon)->ReturnTargetTypeHandler(container);
  298. }
  299.  
  300. //------------------------------------------------------------------------------
  301. // extractData_Handler
  302. //------------------------------------------------------------------------------
  303. static void extractData_Handler(CMRefCon refCon,
  304.                                 CMDataBuffer buffer,
  305.                                 CMSize size,
  306.                                 CMPrivateData data)
  307. {
  308.     ((ODBentoHandlers*) refCon)->ExtractDataHandler(buffer, size, data);
  309. }
  310.  
  311. //------------------------------------------------------------------------------
  312. // formatData_Handler
  313. //------------------------------------------------------------------------------
  314. static void formatData_Handler(CMRefCon refCon,
  315.                                 CMDataBuffer buffer,
  316.                                 CMSize size,
  317.                                 CMPrivateData data)
  318. {
  319.     ((ODBentoHandlers*) refCon)->FormatDataHandler(buffer, size, data);
  320. }
  321.  
  322. //------------------------------------------------------------------------------
  323. // ODBentoHandlers::ODBentoHandlers
  324. //------------------------------------------------------------------------------
  325. ODBentoHandlers::ODBentoHandlers()
  326. {
  327. }
  328.  
  329. //------------------------------------------------------------------------------
  330. // ODBentoHandlers::~ODBentoHandlers
  331. //------------------------------------------------------------------------------
  332. ODBentoHandlers::~ODBentoHandlers()
  333. {
  334. }
  335.  
  336.