home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warphead.zip / H / CMCONFIG.H < prev    next >
C/C++ Source or Header  |  1997-02-28  |  16KB  |  354 lines

  1. /* @(#)Z 1.6 com/src/cm/CMConfig.h, odstorage, od96os2, odos29646d 96/11/15 15:26:45 (96/10/29 09:16:25) */
  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:        CMConfig.h
  31.  
  32.     Contains:    Container Manager Configuration Controls
  33.  
  34.     Written by:    Ira L. Ruben
  35.  
  36.     Owned by:    Ed Lai
  37.  
  38.     Copyright:    ⌐ 1994-95 by Apple Computer, Inc., all rights reserved.
  39.  
  40.     Change History (most recent first):
  41.  
  42.          <7>     10/9/95    EL        1290781: flag to allow ignoring non-fatal
  43.                                     error.
  44.          <6>     4/25/95    EL        1242376: Separate crash proof for embedded
  45.                                                     and top level container.
  46.          <5>     3/24/95    EL        1226127: add CMCRASH_PROOF.
  47.          <4>     12/9/94    EL        #1182275 Add CMKEEP_CONTINUE_FLAG
  48.          <3>     9/15/94    EL        #1182275 More comment on MinFragmentSize.
  49.          <2>     8/26/94    EL        #1181622 Ownership update.
  50.          <3>      5/9/94    MB        #1162181: Changes necessary to install MMM.
  51.          <2>      2/3/94    EL        Bento File names are now eight chars or
  52.                                     less.
  53.  
  54.     To Do:
  55. */
  56.  
  57. /*---------------------------------------------------------------------------*
  58.  |                                                                           |
  59.  |                            <<< CMConfig.h >>>                             |
  60.  |                                                                           |
  61.  |                 Container Manager Configuration Controls                  |
  62.  |                                                                           |
  63.  |                               Ira L. Ruben                                |
  64.  |                                  8/4/92                                   |
  65.  |                                                                           |
  66.  |                    Copyright Apple Computer, Inc. 1992-1995               |
  67.  |                           All rights reserved.                            |
  68.  |                                                                           |
  69.  *---------------------------------------------------------------------------*
  70.  
  71.  This header is used to defined various "configuration" attributes that control optional
  72.  or alternative versions of various aspects of the Container Manager code.  Some constants
  73.  are also defined here which may be a function of the environment in which the Container
  74.  Manager is run.  Such constants are not in CMAPIEnv.h.h because these also may
  75.  control the way code is generated and this header is not a published header as is the
  76.  case for CMAPIEnv.h.h.
  77. */
  78.  
  79.  
  80. #ifndef __CMCONFIG__
  81. #define __CMCONFIG__
  82.  
  83.  
  84. /*---------------------------------------------------------------*
  85.  | For Lotus (support for "original format 1 TOC layout)...      |
  86.  *---------------------------------------------------------------*
  87.  
  88.  The following macros are used to define call "old" code for support of format 1 TOC
  89.  manipulations.  They are sufficiently "grotesque" to make them stand out.  That is because
  90.  the support of the "old" TOC format is only there TEMPORARILY for Lotus and initial
  91.  format size comparisons with the "new" and more compact TOC format.  To make it easier to
  92.  find and remove the bracketed code, we make these macros stand out.
  93. */
  94.  
  95. #ifndef TOC1_SUPPORT
  96. #define TOC1_SUPPORT 0                    /* Must be explicitly requested as compiler option!            */
  97. #endif
  98.  
  99. #if TOC1_SUPPORT                                /* function call TOC format 1 alternative with result        */
  100. #define USE_TOC_FORMAT_1_ALTERNATIVE(format1Proc, params)    \
  101.     if (((ContainerPtr)container)->majorVersion == 1)                \
  102.         return format1Proc##params
  103. #else
  104. #define USE_TOC_FORMAT_1_ALTERNATIVE(format1Proc, params)    
  105. #endif
  106.  
  107. #if TOC1_SUPPORT                                /* function call TOC format 1 alternative with no result*/
  108. #define USE_TOC_FORMAT_1_ALTERNATIVE1(format1Proc, params)    \
  109.     if (((ContainerPtr)container)->majorVersion == 1)    {                \
  110.         format1Proc##params;                                                                        \
  111.         return;                                                                                                    \
  112.     }
  113. #else
  114. #define USE_TOC_FORMAT_1_ALTERNATIVE1(format1Proc, params)    
  115. #endif
  116.  
  117.  
  118. /*--------------------*
  119.  | Buffering Controls |
  120.  *--------------------*
  121.  
  122.  Some routines buffer their I/O.  The following define the buffer sizes used.  Where 
  123.  indicated, some sizes may be defined as 0 to disable the explicit buffering.  This would
  124.  usually be done if the the I/O is through handlers which do their own buffering so there
  125.  would be n need to do additional buffering by the handler callers.
  126.  
  127.  Unless indicated, these buffers are only allocated during the time they are used. These 
  128.  uses are generally at mutually exclusive times and thus the total space defined is not
  129.  the total space used.
  130.  
  131.  The buffers being defined here are used as the buffer size parameter to  BufferIO.c 's
  132.  cmUseIOBuffer() which allocate the buffers.  The buffering routines will take any
  133.  (reasonable) size.  It does not have to be a multiple of something.  Although that 
  134.  probably would not hurt!
  135. */
  136.  
  137.  
  138. /* The reading and writing the TOC is buffered.  The following defines the buffer size    */
  139. /* used...                                                                                                                                                            */
  140.  
  141. #if TOC1_SUPPORT
  142. #ifndef TOCInputBufSize
  143. #define TOCInputBufSize (0)                    /* This defines the size of the TOC input buffer. It*/
  144. #endif                                                            /* should be a "moderate" size (maybe about 50*24)    */
  145.                                                                         /* chosen as a comprimize to wanting to read large     */
  146.                                                                         /* chunks of TOC and not wanting to read too far         */
  147.                                                                         /* into a "split" TOC which has a public and private*/
  148.                                                                         /*  section when the TOC is used for updating a         */
  149.                                                                         /* target container.                                                                */
  150.                                                                                 
  151.                                                                         /* THIS CAN BE 0.  No explict TOC buffering will be */
  152.                                                                         /* done. It is then assumed that either no buffering*/
  153.                                                                         /* is wanted (why?), or that the handlers do the         */
  154.                                                                         /* buffering.                                                                              */
  155.                                                                         
  156.                                                                         /* If the handlers are doing standard stream I/O,     */
  157.                                                                         /* then presumably a setvbuf() can be done to allow    */
  158.                                                                         /* the stream I/O to do the buffering so none would    */
  159.                                                                         /* be needed to be defined here.                                        */
  160. #endif
  161.  
  162. #ifndef UpdateBufSize
  163. #define UpdateBufSize         512                /* Max size of the updates buffer, i.e., the buffer    */
  164. #endif                                                            /* used to write updating instructions into as value*/
  165.                                                                         /* data.  This can NEVER be 0.  Update instructions    */
  166.                                                                         /* are always buffered because the handlers are not    */
  167.                                                                         /* explicitly used as is the case for TOC I/O.            */
  168.                                                                         
  169.                                                                         /* A "moderate" size should be chosen for this since*/
  170.                                                                         /* the buffer is reused for each object that has        */
  171.                                                                         /* updates associated with it.  It come down to         */
  172.                                                                         /* guessing how much updating will be done to the        */
  173.                                                                         /* values belonging to an object.                                        */
  174.  
  175. #define DefaultTOCBufSize    1                    /* Default TOC output buffer size in units of 1024    */
  176.                                                                         /* bytes. A value of "n" means n*1024 bytes is used    */
  177.                                                                         /* as the TOC output buffer size.  The TOC is             */
  178.                                                                         /* formatted in "blocks" of n*1024 and will never     */
  179.                                                                         /* span (cross) a block boundary.  Padding is added */
  180.                                                                         /* if necessary.  The n here is placed in the             */
  181.                                                                         /* container label and is limited to a maximum value*/
  182.                                                                         /* of 65535 (0xFFFF).                                                                */
  183.                                                                         
  184.                                                                         /* For reading, whatever "n" is found in the label    */
  185.                                                                         /* is used to determine the input TOC buffer size.    */
  186.                                                                         /* Thus, there can be no default for the input             */
  187.                                                                         /* buffer size.                                                                            */
  188.  
  189. #define RefsBufSize                (64*8)        /* Size of the input buffer used to search for             */
  190.                                                                         /* a value's references. See "Reference Shadow List */
  191.                                                                         /* Controls" for a brief description of references.    */
  192.                                                                         /* The value data is formatted as 8-byte CMReference*/
  193.                                                                         /* key/object ID pairs (4 bytes each).  Almost any    */
  194.                                                                         /* reasonable size will do here depending on your        */
  195.                                                                         /* estimate on how heavily references are used.            */
  196.  
  197. /*----------------------*
  198.  | Performance Controls |
  199.  *----------------------*
  200.  
  201.     Some parameters can be used to control the trade off between performance and disk
  202.     space usage. For example if we allows a value to be separated into many value
  203.     segments to use up every possible disk space, we save disk space but the resulting
  204.     performance would suffer because of the fragmentation. So you want to adjust it
  205.     to suit your own need.
  206.  */
  207.  
  208. /* Very often, the same value is being written back. If we know it is unchanged we can    */
  209. /* avoid the write. We can do this by reading the data back and comparing with the new    */
  210. /* data. However, this reading and comparison introduces overhead. So we only want to        */
  211. /* do it if the data size is small. kSizeReadBeforeWrite is the data size limit that we    */
  212. /* would attempt a read before write.                                                                                                        */
  213.  
  214. #ifndef SizeReadBeforeWrite
  215. #define SizeReadBeforeWrite        32
  216. #endif                                                        
  217.  
  218. /* When we are getting space from the free space, we try not to break it up into very        */
  219. /* small segment. MinFragmentSize is the smallest block we try to get unless we are            */
  220. /* asking for less ourselves.                                                                                                                        */
  221. #ifndef MinFragmentSize
  222. #define MinFragmentSize                128
  223. #endif                                                        
  224.  
  225. /* For large blocks, we try not to have more than MaxFragmentCount segments.                        */
  226. /* In reality, we end up with more segments than this. The reason is that if we do not    */
  227. /* get all the space we want, we would ask again. However the second time we ask we         */
  228. /* are asking for the remainder, which is smaller. So if kMaxFragmentCount is 4 and we    */
  229. /* initially ask for 4K, we may not end up with 4 1K segment. Rather we may get back        */
  230. /* blocks of 1K, 0.75K, 0.56K, 0.42K, 0.32K etc.                                                                                */
  231.  
  232. /* We also use this constant to trigger when we need to try to consolidate segments            */
  233. /* Of course this does not means that we can cut it down to this number.                                 */
  234. #ifndef MaxFragmentCount
  235. #define MaxFragmentCount            4
  236. #endif                                                        
  237.  
  238. /*--------------------*
  239.  | Debugging Controls |
  240.  *--------------------*
  241.  
  242.  The following two switches control whether the indicated debugging code should be 
  243.  generated. The first controls the generation of CMDebugging() while the second controls
  244.  the generation of CMDumpTOCStructures() and CMDumpContainerTOC().  These two routines have
  245.  the following actions:
  246.  
  247.  CMDebugging()                    - to set some internal debugging "options"
  248.  CMDumpTOCStructures()    - to dump in-memory TOC as a tree-like format
  249.  CMDumpContainerTOC()        - to read in container TOC and display it in a table format
  250. */
  251.  
  252. #ifndef CMDEBUGGING
  253. #define CMDEBUGGING 0            /* 1 ==> define CMDebugging()                                                                    */
  254. #endif
  255.  
  256. #ifndef CMDUMPTOC
  257. #define CMDUMPTOC 0                /* 1 ==> define CMDumpTOCStructures() and CMDumpContainerTOC()*/
  258. #endif
  259.  
  260.  
  261. /*------------------------------------*
  262.  | Validation and Protection Controls |
  263.  *------------------------------------*
  264.  
  265.  The following two switches control the validation checking code in the Container Manager.
  266.  Validations include checking that CMStartSession() was called and for NULL refNums. There
  267.  is a dynamic switch controlled by CMDebugging() (the switch is in the session global data)
  268.  and a static (compile time) switch to suppress the validation checks entirely.
  269.  
  270.  Remember, suppressing the validation checks removes what little protection the Container
  271.  Manager has against careless users.
  272. */
  273.  
  274. #ifndef CMVALIDATE
  275. #define CMVALIDATE 1                        /* 1 ==> generate validation code; 0 ==> don't generate */
  276. #endif
  277.  
  278. #ifndef CMDEFAULT_VALIDATE
  279. #define CMDEFAULT_VALIDATE 1        /* default (initial) dynamic validation switch setting    */
  280. #endif
  281.  
  282.  
  283. /*--------------------------------*
  284.  | Reference Shadow List Controls |
  285.  *--------------------------------*
  286.  
  287.  Object references are "pointers" (i.e., object IDs) to other objects from a value 
  288.  (CMValue) that contains data that refers to those objects.  The data is in the form of a
  289.  CMReference "key" and associated object ID.  The routines in    CMRefOps.c    manipulate
  290.  those key/object (ID) associations.  The associations are maintained in a list as value
  291.  data for a uniquely typed value in a private object "tied" to the value through a pointer
  292.  in the value header.
  293.  
  294.  To increase efficiency, the data is read into memory the first time it's accessed.  From
  295.  that point on, all updates to the actual data are "shadowed" in the in-memory list.  The
  296.  updating can't be avoided (so updating, e.g., touches, etc. work correctly).  But at least
  297.  the searches can be made to not be I/O bound!  This shadow list support is OPTIONAL and
  298.  controlled by the macro variable defined below.  If the variable is defined as 0, no
  299.  shadow list support is provided.  All search operations for a reference will take place
  300.  directly on the value data.  This has the benefit of not requiring additional memory 
  301.  space.  It also could potentially be more efficient depending on the supporting I/O
  302.  handlers.  These are the reasons the shadow list support is optional.
  303. */
  304.  
  305. #ifndef CMSHADOW_LIST
  306. #define CMSHADOW_LIST    0                    /* 1 ==> support reference shadow list                                    */
  307. #endif
  308.  
  309. /*-----------------------*
  310.  | Miscelaneous Controls |
  311.  *-----------------------*
  312.  
  313. */
  314.  
  315. /* If there are multiple value segments, there is a continous flag in all the values
  316.     except the last one as well as value header. A lot of work is needed to maintain
  317.     the flags to make sure that they are correct as segments are being added and
  318.     deleted. The flags are used at close time when the TOC is being written out.
  319.     If we do not use the flags until close time, we may skip the maintenance of
  320.     the flags. At close time we can reconstruct the flag by looking at the value
  321.     list.
  322. */
  323.  
  324. #ifndef CMKEEP_CONTINUE_FLAG
  325. #define CMKEEP_CONTINUE_FLAG    0            /* 1 ==> maintain the continue flag in values                */
  326. #endif
  327.  
  328. /* If there are multiple value segments, there is a continous flag in all the values
  329.     except the last one as well as value header. A lot of work is needed to maintain
  330.     the flags to make sure that they are correct as segments are being added and
  331.     deleted. The flags are used at close time when the TOC is being written out.
  332.     If we do not use the flags until close time, we may skip the maintenance of
  333.     the flags. At close time we can reconstruct the flag by looking at the value
  334.     list.
  335. */
  336. #ifndef CMIGNORE_NONFATAL
  337. #define CMIGNORE_NONFATAL    1                    /* 1 ==> ignore non-fatal errors                */
  338. #endif
  339.  
  340. /* If an error is non-fatal, this flag allows the program to ignore the error and
  341.     continue instead of calling the error handling routine.
  342. */
  343.  
  344. #ifndef CMTOPLEVEL_CRASH_PROOF
  345. #define CMTOPLEVEL_CRASH_PROOF    1                /* 1 ==> make sure don't write over old content                */
  346. #endif
  347.  
  348. #ifndef CMEMBEDDED_CRASH_PROOF
  349. #define CMEMBEDDED_CRASH_PROOF    0                /* 1 ==> make sure don't write over old content                */
  350. #endif
  351.  
  352.  
  353. #endif
  354.