home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / mapi / flatfile.ab / abctbl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-11  |  4.8 KB  |  170 lines

  1. /***********************************************************************
  2.  *
  3.  *  ABCTBL.H
  4.  *
  5.  *  Definitions for Sample Address Book Contents Table
  6.  *
  7.  *  Copyright 1992-1995 Microsoft Corporation.  All Rights Reserved.
  8.  *
  9.  ***********************************************************************/
  10.  
  11.  
  12. /*
  13.  *  BookMark structure
  14.  */
  15.  
  16. #define MAX_BOOKMARKS   10
  17.  
  18. #define BK_PEGGEDTOEND      ((ULONG)0x00000001)
  19.  
  20. typedef struct _ABCBK
  21. {
  22.  
  23.     ULONG       ulFlags;            /*  Flags */
  24.     FILETIME    filetime;           /*  Time of file when bookmark created */
  25.     ULONG       ulPosition;         /*  Position of record in file */
  26.     ABCREC      abcrec;             /*  Record associated with this bookmark */
  27.  
  28. } ABCBK, *LPABCBK;
  29.  
  30.  
  31. /*
  32.  *  _IVTABC is the structure returned to the client when
  33.  *  the contents table is retrieved from the ab container
  34.  *  object (ABCONT.C).
  35.  *
  36.  *  The first thing in the structure must be a jump table
  37.  *  with all the IMAPITable methods in it.
  38.  *
  39.  */
  40. typedef struct _IVTABC
  41. {
  42.     const IVTABC_Vtbl FAR * lpVtbl;
  43.  
  44.     SAB_IUnkWithLogon;
  45.     
  46.     /*
  47.      *  Private data
  48.      */
  49.  
  50.     /*  The list of active columns */
  51.     LPSPropTagArray lpPTAColSet;
  52.  
  53.     /*  HANDLE of file that I'm browsing... */
  54.     HANDLE hFile;
  55.  
  56.     /*  FILETIME time the file was last changed */
  57.     FILETIME filetime;
  58.  
  59.     /*  Size of file */
  60.     ULONG ulMaxPos;
  61.  
  62.     /*  Current position in file */
  63.     ULONG ulPosition;
  64.  
  65.     /*  BookMark array... */
  66.     LPABCBK rglpABCBK[MAX_BOOKMARKS];
  67.  
  68.     /*
  69.      *  Restriction stuff
  70.      */
  71.  
  72.     ULONG ulRstrDenom;
  73.  
  74.     /*  Partial Name to match */
  75.     LPSTR lpszPartialName;
  76.  
  77.     /*  2 bit arrays of what's been checked, and what (of them) matches */
  78.     BYTE *rgChecked;
  79.     BYTE *rgMatched;
  80.  
  81.     ULONG   ulConnectMic;
  82.     UINT    cAdvise;                            /* Count of registered notifications */
  83.     LPMAPIADVISESINK * parglpAdvise;    /* Registered notifications */
  84.     FTG ftg;                                /* Idle function tag */
  85.     LPSTR   lpszFileName;
  86.  
  87.  
  88. } IVTABC, *LPIVTABC;
  89.  
  90.  
  91. /*
  92.  *  Record for PR_INSTANCE_KEY.  Need enough information to find the record quickly as
  93.  *  well as determine if the record is still valid.
  94.  */
  95. typedef struct _abcrecinstance
  96. {
  97.     ULONG ulRecordPosition;
  98.     FILETIME filetime;
  99.     char rgchzFileName[1];  /* Get's sized accordingly */
  100.  
  101. } ABCRecInstance, FAR * LPABCRecInstance;
  102.  
  103.  
  104. /*
  105.  *  Private macros
  106.  */
  107.  
  108. /* Counts the number of bits in a byte */
  109. #define CBitsB(b, cbits) {                               \
  110.                                                          \
  111.         cbits = 0;                                       \
  112.                                                          \
  113.         cbits = ((b)   & 0x55) + ((b>>1) & 0x55);        \
  114.         cbits = (cbits & 0x33) + ((cbits>>2) & 0x33);    \
  115.         cbits = (cbits & 0x0f) + (cbits>>4);             \
  116.     }
  117.  
  118.  
  119.  
  120. /*
  121.  *  Internal abctbl functions
  122.  */
  123.  
  124. HRESULT     HrOpenFile(LPIVTABC lpIVTAbc);
  125. void        FreeANRBitmaps(LPIVTABC lpIVTAbc);
  126. HRESULT     HrValidateEntry (LPIVTABC lpIVTAbc, ULONG ulNewPos);
  127. BOOL        FNameMatch (LPIVTABC lpIVTAbc, LPSTR rgchDisplayName);
  128. BOOL        FMatched (LPIVTABC lpIVTAbc, ULONG ulNewPos);
  129. BOOL        FChecked (LPIVTABC lpIVTAbc, ULONG ulNewPos);
  130.  
  131.  
  132.  
  133. /*
  134.  *  Default column set
  135.  */
  136. enum {  ivalvtPR_DISPLAY_NAME,
  137.         ivalvtPR_ENTRYID,
  138.         ivalvtPR_ADDRTYPE,
  139.         ivalvtPR_EMAIL_ADDRESS,
  140.         ivalvtPR_OBJECT_TYPE,
  141.         ivalvtPR_DISPLAY_TYPE,
  142.         ivalvtPR_INSTANCE_KEY,
  143.         cvalvtMax };
  144.  
  145.  
  146.  
  147. /*
  148.  *  Externs defined for use in the three table modules
  149.  */
  150.  
  151. extern const IVTABC_Vtbl vtblIVTABC;
  152. extern const LPSPropTagArray ptagaivtabcColSet;
  153.  
  154. /* Parameter Validation*/
  155. #define IVTABC_ValidateObject(Method, pThis)                                \
  156. {   HRESULT hr;                                                             \
  157.     if(IsBadReadPtr(pThis, sizeof(IVTABC)))                                 \
  158.     {                                                                       \
  159.         hr = ResultFromScode(E_INVALIDARG);                                 \
  160.         DebugTraceResult(IVTABC##_##Method, hr);                            \
  161.         return hr;                                                          \
  162.     }                                                                       \
  163.     if(pThis->lpVtbl != &vtblIVTABC)                                        \
  164.     {                                                                       \
  165.         hr = ResultFromScode(E_INVALIDARG);                                 \
  166.         DebugTraceResult(IVTABC##_##Method, hr);                            \
  167.         return hr;                                                          \
  168.     }                                                                       \
  169. }
  170.