STDAPI DllUnregisterServer(VOID) #endif { HRESULT rslt; HINSTANCE hInst; hInst = GetModuleHandle(DBCLIENT_DLL); if (hInst) { DBIPATH pszDllPath = { 0 }; OLECHAR pszDllPathw[DBIMAXPATHLEN+1] = { 0 }; GetModuleFileName(hInst, pszDllPath, sizeof(pszDllPath)); MultiByteToWideChar(0, 0, pszDllPath, -1, pszDllPathw, sizeof(pszDllPathw)/sizeof(pszDllPathw[0])); ITypeLib *pTypeLib = 0; ; // oleauto.h rslt = LoadTypeLib(pszDllPathw, &pTypeLib); if (!rslt) { TLIBATTR *pLibAttr = 0; // oaidl.h pTypeLib->GetLibAttr(&pLibAttr); HRESULT hr = UnRegisterTypeLib(pLibAttr->guid, pLibAttr->wMajorVerNum, pLibAttr->wMinorVerNum, pLibAttr->lcid, pLibAttr->syskind); if (hr != S_OK) { regError("ERROR: UnregisterTypeLib returned %lX", hr); } pTypeLib->ReleaseTLibAttr(pLibAttr); pTypeLib->Release(); pTypeLib = 0; } else { regError("ERROR: LoadTypeLib returned %lX", rslt); } } #ifdef MIDAS_DLL // DSBASE rslt = Register_IF(NULL, PROGID_MDSBASE, NULL, PROGID_MDSBASE_1, NULL, CLSID_MDSBASE_1, FALSE); if (!rslt) rslt = Register_IF(NULL, PROGID_MDSBASE_1, NULL, NULL, NULL, CLSID_MDSBASE_1, FALSE); // DSCursor if (!rslt) rslt = Register_IF(NULL, PROGID_MDSCURSOR, NULL, PROGID_MDSCURSOR_1, NULL, CLSID_MDSCURSOR_1, FALSE); if (!rslt) rslt = Register_IF(NULL, PROGID_MDSCURSOR_1, NULL, NULL, NULL, CLSID_MDSCURSOR_1, FALSE); // DSDATAPACKET if (!rslt) rslt = Register_IF(NULL, PROGID_MDATAPACKETREAD, NULL, NULL, NULL, CLSID_MDATAPACKETREAD, FALSE); if (!rslt) rslt = Register_IF(NULL, PROGID_MDATAPACKETWRITE, NULL, NULL, NULL, CLSID_MDATAPACKETWRITE, FALSE); #else // DSBASE rslt = Register_IF(NULL, PROGID_DSBASE, NULL, PROGID_DSBASE_2, NULL, CLSID_DSBASE_2, FALSE); if (!rslt) rslt = Register_IF(NULL, PROGID_DSBASE_1, NULL, NULL, NULL, CLSID_DSBASE_1, FALSE); if (!rslt) rslt = Register_IF(NULL, PROGID_DSBASE_2, NULL, NULL, NULL, CLSID_DSBASE_2, FALSE); // DSCursor if (!rslt) rslt = Register_IF(NULL, PROGID_DSCURSOR, NULL, PROGID_DSCURSOR_2, NULL, CLSID_DSCURSOR_2, FALSE); if (!rslt) rslt = Register_IF(NULL, PROGID_DSCURSOR_1, NULL, NULL, NULL, CLSID_DSCURSOR_1, FALSE); if (!rslt) rslt = Register_IF(NULL, PROGID_DSCURSOR_2, NULL, NULL, NULL, CLSID_DSCURSOR_2, FALSE); // DSDATAPACKET if (!rslt) rslt = Register_IF(NULL, PROGID_DATAPACKETREAD, NULL, NULL, NULL, CLSID_DATAPACKETREAD, FALSE); if (!rslt) rslt = Register_IF(NULL, PROGID_DATAPACKETWRITE, NULL, NULL, NULL, CLSID_DATAPACKETWRITE, FALSE); #endif return rslt; }
/* - RegComp - compile a regular expression into internal code * * We can't allocate space until we know how big the compiled form will be, * but we can't compile it (and thus know how big it is) until we've got a * place to put the code. So we cheat: we compile it twice, once with code * generation turned off and size counting turned on, and once "for real". * This also means that we don't allocate space until we are sure that the * thing really will compile successfully, and we never have to move the * code and thus invalidate pointers into it. (Note that it has to be in * one piece because free() must be able to free it all.) * * Beware that the optimization-preparation code in here knows about some * of the structure of the compiled regexp. */ regexp *RegComp( const char *instr ) { regexp *r; char *scan; char *longest; const char *exp; char buff[MAX_STR*2]; int flags, ignmag = FALSE; unsigned j; size_t i, k, len; #ifdef WANT_EXCLAMATION if( instr[0] == '!' ) { instr++; ignmag = TRUE; } #endif /* * flip roles of magic chars */ if( !ignmag && ( !MAGICFLAG && MAGICSTR != NULL ) ) { j = 0; k = strlen( instr ); for( i = 0; i < k; i++ ) { if( instr[i] == '\\' ) { if( strchr( MAGICSTR, instr[i + 1] ) == NULL ) { buff[j++] = '\\'; } i++; } else { if( strchr( MAGICSTR, instr[i] ) != NULL ) { buff[j++] = '\\'; } } buff[j++] = instr[i]; } buff[j] = 0; exp = buff; } else { exp = instr; } regError( ERR_NO_ERR ); if( exp == NULL ) { FAIL( ERR_RE_NULL_ARGUMENT ); } /* First pass: determine size, legality. */ regparse = exp; regnpar = 1; regsize = 0L; regcode = ®dummy; regc( MAGIC ); if( reg( 0, &flags ) == NULL ) { return( NULL ); } /* Allocate space. */ r = ALLOC( sizeof( regexp ) + ( unsigned ) regsize ); /* Second pass: emit code. */ regparse = exp; regnpar = 1; regcode = r->program; regc( MAGIC ); if( reg( 0, &flags ) == NULL ) { return( NULL ); } /* Dig out information for optimizations. */ r->regstart = '\0'; /* Worst-case defaults. */ r->reganch = 0; r->regmust = NULL; r->regmlen = 0; scan = r->program + 1; /* First BRANCH. */ if( OP( regnext( scan ) ) == END ) { /* Only one top-level choice. */ scan = OPERAND( scan ); /* Starting-point info. */ if( OP( scan ) == EXACTLY ) { r->regstart = *OPERAND( scan ); } else if( OP( scan ) == BOL ) { r->reganch++; } /* * If there's something expensive in the r.e., find the * longest literal string that must appear and make it the * regmust. Resolve ties in favor of later strings, since * the regstart check works with the beginning of the r.e. * and avoiding duplication strengthens checking. Not a * strong reason, but sufficient in the absence of others. */ if( flags & SPSTART ) { longest = NULL; len = 0; for( ; scan != NULL; scan = regnext( scan ) ) { if( OP( scan ) == EXACTLY && strlen( OPERAND( scan ) ) >= len ) { longest = OPERAND( scan ); len = strlen( OPERAND( scan ) ); } } r->regmust = longest; r->regmlen = (short)len; } } return( r ); }
STDAPI DllRegisterServer(VOID) #endif { DBIPATH pszDllPath = { 0 }; OLECHAR pszDllPathw[DBIMAXPATHLEN+1] = { 0 }; HINSTANCE hInst; HRESULT rslt = SELFREG_E_CLASS; hInst = GetModuleHandle(DBCLIENT_DLL); if (hInst) { ITypeLib *pTypeLib = 0; DWORD dw = GetModuleFileName(hInst, pszDllPath, sizeof(pszDllPath)/sizeof(pszDllPath[0])); if (dw < 1) { regError("ERROR: Unable to retrieve module file name"); } MultiByteToWideChar(0, 0, pszDllPath, -1, pszDllPathw, sizeof(pszDllPathw)/sizeof(pszDllPathw[0])); rslt = LoadTypeLib(pszDllPathw, &pTypeLib); if (!rslt) { HRESULT hr = RegisterTypeLib(pTypeLib, pszDllPathw, NULL); if (hr != S_OK) { regError("ERROR: RegisterTypeLib returned %lX", hr); } pTypeLib->Release(); pTypeLib = 0; } else { regError("ERROR: LoadTypeLib returned %lX", rslt); } #ifdef MIDAS_DLL // DSBASE rslt = Register_IF(pszDllPath, PROGID_MDSBASE, PROGID_MDSBASE_DESC, PROGID_MDSBASE_1, NULL, CLSID_MDSBASE_1, TRUE); if (!rslt) rslt = Register_IF(pszDllPath, PROGID_MDSBASE_1, PROGID_MDSBASE_DESC_1, NULL, PROGID_MDSBASE, CLSID_MDSBASE_1, TRUE); // DSCursor if (!rslt) rslt = Register_IF(pszDllPath, PROGID_MDSCURSOR, PROGID_MDSCURSOR_DESC, PROGID_MDSCURSOR_1, NULL, CLSID_MDSCURSOR_1, TRUE); if (!rslt) rslt = Register_IF(pszDllPath, PROGID_MDSCURSOR_1, PROGID_MDSCURSOR_DESC_1, NULL, PROGID_MDSCURSOR, CLSID_MDSCURSOR_1, TRUE); // DSDATAPACKET if (!rslt) rslt = Register_IF(pszDllPath, PROGID_MDATAPACKETREAD, PROGID_MDATAPACKETREAD_DESC, NULL, NULL, CLSID_MDATAPACKETREAD, TRUE); if (!rslt) rslt = Register_IF(pszDllPath, PROGID_MDATAPACKETWRITE, PROGID_MDATAPACKETWRITE_DESC, NULL, NULL, CLSID_MDATAPACKETWRITE, TRUE); #else // DSBASE rslt = Register_IF(pszDllPath, PROGID_DSBASE, PROGID_DSBASE_DESC, PROGID_DSBASE_2, NULL, CLSID_DSBASE_2, TRUE); if (!rslt) rslt = Register_IF(pszDllPath, PROGID_DSBASE_1, PROGID_DSBASE_DESC_1, NULL, NULL, CLSID_DSBASE_1, TRUE); if (!rslt) rslt = Register_IF(pszDllPath, PROGID_DSBASE_2, PROGID_DSBASE_DESC_2, NULL, PROGID_DSBASE, CLSID_DSBASE_2, TRUE); // DSCursor if (!rslt) rslt = Register_IF(pszDllPath, PROGID_DSCURSOR, PROGID_DSCURSOR_DESC, PROGID_DSCURSOR_2, NULL, CLSID_DSCURSOR_2, TRUE); if (!rslt) rslt = Register_IF(pszDllPath, PROGID_DSCURSOR_1, PROGID_DSCURSOR_DESC_1, NULL, NULL, CLSID_DSCURSOR_1, TRUE); if (!rslt) rslt = Register_IF(pszDllPath, PROGID_DSCURSOR_2, PROGID_DSCURSOR_DESC_2, NULL, PROGID_DSCURSOR, CLSID_DSCURSOR_2, TRUE); // DSDATAPACKET if (!rslt) rslt = Register_IF(pszDllPath, PROGID_DATAPACKETREAD, PROGID_DATAPACKETREAD_DESC, NULL, NULL, CLSID_DATAPACKETREAD, TRUE); if (!rslt) rslt = Register_IF(pszDllPath, PROGID_DATAPACKETWRITE, PROGID_DATAPACKETWRITE_DESC, NULL, NULL, CLSID_DATAPACKETWRITE, TRUE); #endif } return rslt; }