Annotation of mstools/ole20/h/ole2sp.h, revision 1.1.1.1

1.1       root        1: /* ole2sp.h - semi-private info; only for test apps within the development group
                      2: */
                      3: 
                      4: #if !defined( _OLE2SP_H_ )
                      5: #define _OLE2SP_H_
                      6: 
                      7: #include <shellapi.h>
                      8: 
                      9: // For MAC, M_PROLOG and M_EPILOG are macros which assist us in setting up the A5
                     10: // world for a DLL when a method in the DLL is called from outside the DLL.
                     11: 
                     12: #ifdef _MAC
                     13: 
                     14: #define _MAX_PATH 260
                     15: 
                     16: #ifdef __cplusplus
                     17: 
                     18: class  CSetA5
                     19: {
                     20: public:
                     21:     CSetA5 (ULONG savedA5){ A5save = SetA5(savedA5);}
                     22:     ~CSetA5 (){ SetA5(A5save);}
                     23: 
                     24: private:
                     25:     ULONG A5save;
                     26: };
                     27: 
                     28: pascal long     GetA5(void) = 0x2E8D;
                     29: 
                     30: #define M_PROLOG(where) CSetA5 Dummy((where)->savedA5) 
                     31: #define SET_A5          ULONG savedA5
                     32: #define GET_A5()        savedA5 = GetA5()
                     33: 
                     34: // These macros assist Mac in manually saving/setting/restoring A5 in routines that contain
                     35: // goto's.
                     36: 
                     37: #define A5_PROLOG(where) ULONG A5save = SetA5(where->savedA5)
                     38: #define RESTORE_A5()     SetA5(A5save)
                     39: 
                     40: // Lets MAC name our segments without ifdef's.
                     41: 
                     42: #define NAME_SEG(x)
                     43: 
                     44: #endif // ccplus
                     45: 
                     46: #else
                     47: 
                     48: #define M_PROLOG(where)
                     49: #define SET_A5
                     50: #define GET_A5()
                     51: #define A5_PROLOG(where)
                     52: #define RESTORE_A5()
                     53: #define NAME_SEG(x)
                     54: 
                     55: 
                     56: #define IGetProcAddress(a,b) GetProcAddress((a),(b))
                     57: 
                     58: #endif
                     59: 
                     60: 
                     61: #define ReportResult(a,b,c,d) ResultFromScode(b)
                     62: 
                     63: #ifdef OLE2SHIP
                     64: #ifdef WIN32
                     65: #define MAP16(v16)
                     66: #define MAP32(v32) v32
                     67: #define MAP1632(v16,v32)   v32
                     68: #else
                     69: #define MAP16(v16) v16
                     70: #define MAP32(v32)
                     71: #define MAP1632(v16,v32)   v16
                     72: #endif
                     73: #endif
                     74: 
                     75: /****** Misc defintions ***************************************************/
                     76: 
                     77: #ifdef __TURBOC__
                     78: #define implement struct huge
                     79: #else
                     80: #define implement struct 
                     81: #endif
                     82: #define ctor_dtor private
                     83: #define implementations private
                     84: #define shared_state private
                     85: 
                     86: // helpers for internal methods and functions which follow the same convention
                     87: // as the external ones
                     88: 
                     89: #ifdef __cplusplus
                     90: #define INTERNALAPI_(type) extern "C" type 
                     91: #else 
                     92: #define INTERNALAPI_(type) type 
                     93: #endif 
                     94: 
                     95: #define INTERNAL HRESULT 
                     96: #define INTERNAL_(type) type
                     97: #define FARINTERNAL HRESULT FAR
                     98: #define FARINTERNAL_(type) type FAR
                     99: #define NEARINTERNAL HRESULT NEAR
                    100: #define NEARINTERNAL_(type) type NEAR
                    101: 
                    102: 
                    103: 
                    104: //BEGIN REVIEW: We may not need all the following ones
                    105: 
                    106: #define OT_LINK     1L
                    107: #define OT_EMBEDDED 2L
                    108: #define OT_STATIC   3L
                    109: 
                    110: 
                    111: //END REVIEW .....
                    112: 
                    113: 
                    114: /****** Old Error Codes    ************************************************/
                    115: 
                    116: #define S_OOM               E_OUTOFMEMORY
                    117: #define S_BADARG            E_INVALIDARG
                    118: #define S_BLANK             E_BLANK
                    119: #define S_FORMAT            E_FORMAT
                    120: #define S_NOT_RUNNING       E_NOTRUNNING
                    121: #define E_UNSPEC            E_FAIL
                    122: 
                    123: 
                    124: /****** Macros for nested clases ******************************************/
                    125: 
                    126: /* To overcome problems with nested classes on MAC
                    127:  *
                    128:  * NC(a,b) is used to define a member function of a nested class:
                    129:  *
                    130:  * STDMETHODIMP_(type) NC(ClassName,NestedClassName)::MemberFunction(...)
                    131:  *
                    132:  * DECLARE_NC(a,b) is used within a class declaration to let a nested class
                    133:  * access it container class:
                    134:  *
                    135:  * class ClassName {
                    136:  *     ..............
                    137:  *
                    138:  *     class NestedClassName {
                    139:  *         .............
                    140:  *     };
                    141:  *     DECLARE_NC(ClassName,NestedClassName)
                    142:  *     ..............
                    143:  * };
                    144:  */
                    145: 
                    146: #ifdef _MAC
                    147: 
                    148: #define NESTED_CLASS(a,b) struct a##_##b 
                    149: #define NC(a,b) a##__##b
                    150: #define NC1(a,b) a##_##b
                    151: #define DECLARE_NC(a,b) typedef a##::##b a##__##b; friend a##__##b;
                    152: #define DECLARE_NC2(a,b) typedef a##::a##_##b a##__##b; friend a##__##b;
                    153: 
                    154: #else
                    155: 
                    156: #define NC(a,b) a##::##b
                    157: #define DECLARE_NC(a,b) friend b;
                    158: 
                    159: #endif  
                    160: 
                    161: 
                    162: /****** More Misc defintions **********************************************/
                    163: 
                    164: 
                    165: // LPLPVOID should not be made a typedef.  typedef won't compile; worse
                    166: // within complicated macros the compiler generates unclear error messages
                    167: //
                    168: #define LPLPVOID void FAR * FAR *
                    169: 
                    170: #define UNREFERENCED(a) ((void)(a))
                    171: 
                    172: #ifndef BASED_CODE
                    173: #ifdef WIN32
                    174: #define BASED_CODE
                    175: #else
                    176: #define BASED_CODE __based(__segname("_CODE"))
                    177: #endif
                    178: #endif
                    179: 
                    180: 
                    181: /****** Standard IUnknown Implementation **********************************/
                    182: 
                    183: /*
                    184:  *      The following macro declares a nested class CUnknownImpl,
                    185:  *      creates an object of that class in the outer class, and
                    186:  *      declares CUnknownImpl to be a friend of the outer class.  After
                    187:  *      writing about 20 class headers, it became evident that the
                    188:  *      implementation of CUnknownImpl was very similar in all cases,
                    189:  *      and this macro captures the similarity.  The classname
                    190:  *      parameter is the name of the outer class WITHOUT the leading
                    191:  *      "C"; i.e., for CFileMoniker, classname is FileMoniker.
                    192:  */
                    193: 
                    194: #define noError return NOERROR
                    195: 
                    196: #ifdef _MAC
                    197: 
                    198: #define STDUNKDECL(cclassname,classname) NESTED_CLASS(cclassname, CUnknownImpl):IUnknown { public: \
                    199:     NC1(cclassname,CUnknownImpl)( cclassname FAR * p##classname ) { m_p##classname = p##classname;} \
                    200:     STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPLPVOID ppvObj); \
                    201:     STDMETHOD_(ULONG,AddRef)(THIS); \
                    202:     STDMETHOD_(ULONG,Release)(THIS); \
                    203:     private: cclassname FAR* m_p##classname; }; \
                    204:     DECLARE_NC2(cclassname, CUnknownImpl) \
                    205:     NC(cclassname, CUnknownImpl) m_Unknown;
                    206: 
                    207: #else  // _MAC
                    208: 
                    209: #define STDUNKDECL( ignore, classname ) implement CUnknownImpl:IUnknown { public: \
                    210:     CUnknownImpl( C##classname FAR * p##classname ) { m_p##classname = p##classname;} \
                    211:     STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPLPVOID ppvObj); \
                    212:     STDMETHOD_(ULONG,AddRef)(THIS); \
                    213:     STDMETHOD_(ULONG,Release)(THIS); \
                    214:     private: C##classname FAR* m_p##classname; }; \
                    215:     DECLARE_NC(C##classname, CUnknownImpl) \
                    216:     CUnknownImpl m_Unknown;
                    217: #endif
                    218: 
                    219: /*
                    220:  *      The following macro implements all the methods of a nested
                    221:  *      CUnknownImpl class EXCEPT FOR QUERYINTERFACE.  This macro was
                    222:  *      written after about 20 classes were written in which the
                    223:  *      implementations of CUnknownImpl were all the same.
                    224:  */
                    225: 
                    226: #define STDUNKIMPL(classname) \
                    227: STDMETHODIMP_(ULONG) NC(C##classname,CUnknownImpl)::AddRef( void ){ \
                    228:     return ++m_p##classname->m_refs; } \
                    229: STDMETHODIMP_(ULONG) NC(C##classname,CUnknownImpl)::Release( void ){ \
                    230:     if (--m_p##classname->m_refs == 0) { delete m_p##classname; return 0; } \
                    231:     return m_p##classname->m_refs;}
                    232: 
                    233: 
                    234: /*
                    235:  *      The following macro implements class::CUnknownImpl::QueryInterface IN
                    236:  *      THE SPECIAL CASE IN WHICH THE OUTER CLASS PRESENTS ONLY ONE INTERFACE
                    237:  *      OTHER THAN IUNKNOWN AND IDEBUG.  This is not universally the case,
                    238:  *      but it is common enough that this macro will save time and space.
                    239:  */
                    240: 
                    241: #ifdef _DEBUG
                    242: #define STDDEB_QI(classname) \
                    243:     if (iidInterface == IID_IDebug) {*ppv = (void FAR *)&(m_p##classname->m_Debug); return 0;} else
                    244: #else
                    245: #define STDDEB_QI(classname)
                    246: #endif
                    247: 
                    248: #define STDUNK_QI_IMPL(classname, interfacename) \
                    249: STDMETHODIMP NC(C##classname,CUnknownImpl)::QueryInterface \
                    250:     (REFIID iidInterface, void FAR * FAR * ppv) { \
                    251:     if (iidInterface == IID_IUnknown) {\
                    252:         *ppv = (void FAR *)&m_p##classname->m_Unknown;\
                    253:         AddRef(); noError;\
                    254:     } else if (iidInterface == IID_I##interfacename) { \
                    255:         *ppv = (void FAR *) &(m_p##classname->m_##classname); \
                    256:         m_p##classname->m_pUnkOuter->AddRef(); return NOERROR; \
                    257:     } else \
                    258:         STDDEB_QI(classname) \
                    259:         {*ppv = NULL; return ResultFromScode(E_NOINTERFACE);} \
                    260: }
                    261: 
                    262: 
                    263: /*
                    264:  *      The following macro implements the IUnknown methods inherited
                    265:  *      by the implementation of another interface.  The implementation
                    266:  *      is simply to delegate all calls to m_pUnkOuter.  Parameters:
                    267:  *      ocname is the outer class name, icname is the implementation
                    268:  *      class name.
                    269:  *      
                    270:  */
                    271: 
                    272: #define STDUNKIMPL_FORDERIVED(ocname, icname) \
                    273: STDMETHODIMP NC(C##ocname,C##icname)::QueryInterface \
                    274: (REFIID iidInterface, LPLPVOID ppvObj) { \
                    275:     return m_p##ocname->m_pUnkOuter->QueryInterface(iidInterface, ppvObj);} \
                    276: STDMETHODIMP_(ULONG) NC(C##ocname,C##icname)::AddRef(void) { \
                    277:     return m_p##ocname->m_pUnkOuter->AddRef(); } \
                    278: STDMETHODIMP_(ULONG) NC(C##ocname,C##icname)::Release(void) { \
                    279:     return m_p##ocname->m_pUnkOuter->Release(); }
                    280: 
                    281: 
                    282: /****** Debug defintions **************************************************/
                    283: 
                    284: #include <debug.h>
                    285: 
                    286: 
                    287: /****** Other API defintions **********************************************/
                    288: 
                    289: //  Utility function not in the spec; in ole2.dll.
                    290: //  Read and write length-prefixed strings.  Open/Create stream.
                    291: //  ReadStringStream does allocation, returns length of
                    292: //  required buffer (strlen + 1 for terminating null)
                    293: 
                    294: STDAPI  ReadStringStream( LPSTREAM pstm, LPSTR FAR * ppsz );
                    295: STDAPI  WriteStringStream( LPSTREAM pstm, LPCSTR psz );
                    296: STDAPI  OpenOrCreateStream( IStorage FAR * pstg, const char FAR * pwcsName,
                    297:                                                       IStream FAR* FAR* ppstm);
                    298: 
                    299: 
                    300: // read and write ole control stream (in ole2.dll)
                    301: STDAPI  WriteOleStg (LPSTORAGE pstg, IOleObject FAR* pOleObj, 
                    302:             CLIPFORMAT cfFormat, LPSTREAM FAR* ppstmOut);
                    303: STDAPI  ReadOleStg (LPSTORAGE pstg, DWORD FAR* pdwFlags, 
                    304:                 DWORD FAR* pdwOptUpdate, CLIPFORMAT FAR* pcfFormat, 
                    305:                 LPMONIKER FAR* ppmk, LPSTREAM FAR* pstmOut);
                    306: STDAPI ReadM1ClassStm(LPSTREAM pStm, CLSID FAR* pclsid);
                    307: STDAPI WriteM1ClassStm(LPSTREAM pStm, REFCLSID rclsid);
                    308: 
                    309: 
                    310: // low level reg.dat access (in compobj.dll)
                    311: STDAPI CoGetInProcDll(REFCLSID rclsid, BOOL fServer, LPSTR lpszDll, int cbMax);
                    312: STDAPI CoGetLocalExe(REFCLSID rclsid, LPSTR lpszExe, int cbMax);
                    313: STDAPI CoGetClassExt(LPCSTR lpszExt, LPCLSID pclsid);
                    314: STDAPI CoGetPSClsid(REFIID iid, LPCLSID lpclsid);
                    315: 
                    316: 
                    317: // simpler alternatives to public apis
                    318: STDAPI_(int) StringFromGUID2(REFGUID rguid, LPSTR lpsz, int cbMax);
                    319: #define StringFromCLSID2(rclsid, lpsz, cbMax) \
                    320:     StringFromGUID2(rclsid, lpsz, cbMax)
                    321: 
                    322: #define StringFromIID2(riid, lpsz, cbMax) \
                    323:     StringFromGUID2(riid, lpsz, cbMax)
                    324: 
                    325: STDAPI_(int) Ole1ClassFromCLSID2(REFCLSID rclsid, LPSTR lpsz, int cbMax);
                    326: STDAPI_(BOOL) GUIDFromString(LPCSTR lpsz, LPGUID pguid);
                    327: STDAPI CLSIDFromOle1Class(LPCSTR lpsz, LPCLSID lpclsid);
                    328: STDAPI       CoOpenClassKey(REFCLSID clsid, HKEY FAR* lphkeyClsid);
                    329: 
                    330: INTERNAL CreateStandardMalloc(DWORD memctx, IMalloc FAR* FAR* ppMalloc);
                    331: // were public; now not
                    332: STDAPI  SetDocumentBitStg(LPSTORAGE pStg, BOOL fDocument);
                    333: STDAPI  GetDocumentBitStg(LPSTORAGE pStg);
                    334: 
                    335: 
                    336: //***************************************************************************
                    337: //* Object synchronization stuff
                    338: //***************************************************************************
                    339: 
                    340: typedef DWORD COCS[4];
                    341: typedef COCS FAR* LPCOCS;
                    342: 
                    343: typedef struct _TABLELOCK {
                    344:     COCS cocs;
                    345:     DWORD dwCount;
                    346: } TABLELOCK, FAR* LPTABLELOCK;
                    347: 
                    348: #ifdef WIN32
                    349: 
                    350: EXTERN_C void WINAPI CoInitializeCriticalSection(LPCOCS pcs);
                    351: EXTERN_C void WINAPI CoEnterCriticalSection(LPCOCS pcs);
                    352: EXTERN_C void WINAPI CoLeaveCriticalSection(LPCOCS pcs);
                    353: EXTERN_C void WINAPI CoDeleteCriticalSection(LPCOCS pcs);
                    354: 
                    355: EXTERN_C void WINAPI _LockTable( LPTABLELOCK ptl, BOOL fWrite, DWORD * pdw );
                    356: EXTERN_C BOOL WINAPI _UnlockTable( LPTABLELOCK ptl, BOOL fWrite, DWORD * pdw );
                    357: 
                    358: #define LockTable(pTableLock,fWrite)  \
                    359:   TableLockRetry:\
                    360:   DWORD dwTableLockRetry;\
                    361:   _LockTable(pTableLock,fWrite,&dwTableLockRetry);
                    362: 
                    363: 
                    364: #define UnlockTable(pTableLock,fWrite) \
                    365:   if ( _UnlockTable(pTableLock, fWrite, &dwTableLockRetry) ) \
                    366:       goto TableLockRetry;
                    367: 
                    368: #define InitializeTableLock(pTableLock) \
                    369:          (CoInitializeCriticalSection(&pTableLock->cocs),pTableLock->dwCount=0)
                    370: 
                    371: #define DeleteTableLock(pTableLock) \
                    372:          (CoDeleteCriticalSection(&pTableLock->cocs),pTableLock->dwCount=0)
                    373: 
                    374: 
                    375: EXTERN_C DWORD GetSyncTimeout(void);
                    376: 
                    377: #else
                    378: 
                    379: #define CoInitializeCriticalSection(pcs)
                    380: #define CoEnterCriticalSection(pcs)
                    381: #define CoLeaveCriticalSection(pcs)
                    382: #define CoDeleteCriticalSection(pcs)
                    383: 
                    384: #define LockTable(pTableLock,fWrite)
                    385: #define UnlockTable(pTableLock,fWrite)
                    386: #define InitializeTableLock(pTableLock)
                    387: #define DeleteTableLock(pTableLock)
                    388: 
                    389: #define GetSyncTimeout() ((DWORD) 60000L)
                    390: 
                    391: #endif
                    392: 
                    393: /*
                    394:  * Shared memory allocation routines
                    395:  */
                    396: STDAPI_(void FAR*) SharedMemAlloc(ULONG size, DWORD id);
                    397: STDAPI_(void FAR*) SharedMemReAlloc(void FAR* pmem, ULONG newsize, DWORD id);
                    398: STDAPI_(void) SharedMemFree(void FAR* pmem, DWORD id);
                    399: STDAPI_(DWORD) SharedMemSize(void FAR* pmem, DWORD id);
                    400: STDAPI_(int) MemType(void FAR* pv);
                    401: 
                    402: #ifdef WIN32 
                    403: EXTERN_C DWORD GetCallTimeout(void);
                    404: #else
                    405: #define GetCallTimeout() ((DWORD) 5000L)
                    406: #endif
                    407: 
                    408: 
                    409: /*
                    410:  * Some docfiles stuff
                    411:  */
                    412: 
                    413: #define STGM_DFRALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_DENY_WRITE)
                    414: #define STGM_DFALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE)
                    415: #define STGM_SALL (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)
                    416: 
                    417: 
                    418: #endif // _OLE2SP_H_

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.