BOOL Module::Attach(HINSTANCE hModule) { m_hModule = hModule; HRESULT hr = ErrorInfo::Init(); if (FAILED(hr)) return FALSE; hr = CoCreateInstance(CLSID_StdGlobalInterfaceTable, NULL, CLSCTX_INPROC_SERVER, IID_IGlobalInterfaceTable, (void**) &m_pGIT); if (FAILED(hr)) { LOGCALL(("Cannot create a global interface table instance.\n")); return false; } m_dwTlsIndex = TlsAlloc(); if (m_dwTlsIndex == TLS_OUT_OF_INDEXES) { LOGCALL(("Cannot allocate a TLS index.\n")); return FALSE; } return TRUE; }
int tagfs_unlink(const char *file){ LOGCALL(); char **tagsbuf; comm_getTags(file,&tagsbuf); char **tmp = tagsbuf, **tmp2; int cpt = 0, i; tmp2 = tmp; while(*tmp != NULL){ tmp2 = tmp; tmp++; cpt++; } cpt--; if(!exist_file(db, *tmp2)){ comm_freeTags(tagsbuf); return FAILURE; } for(i = 0 ; i < cpt ; i++){ delete_tag_from_file(db,*tmp2,tagsbuf[i]); } comm_freeTags(tagsbuf); return SUCCESS; }
int tagfs_link(const char *file, const char *tags){ LOGCALL(); char **tagsbuf; comm_getTags(tags, &tagsbuf); char **tmp = tagsbuf; int cpt = 0, i; while(tmp != NULL && strcmp(file + 1, *tmp) != 0){ tmp++; cpt++; } if(*tmp == NULL || *(tmp + 1) != NULL){ comm_freeTags(tagsbuf); return FAILURE; } if (!exist_file(db, file + 1)) add_new_file(db, file + 1); for(i = 0; i < cpt; ++i) add_tag_to_file(db, file + 1, tagsbuf[i]); comm_freeTags(tagsbuf); return SUCCESS; }
int tagfs_chown(const char *a, uid_t b, gid_t c){ LOGCALL(); (void) a; (void) b; (void) c; return 1; }
int tagfs_fsyncdir(const char *a, int b, struct fuse_file_info *c){ LOGCALL(); (void) a; (void) b; (void) c; return 1; }
STDMETHODIMP CConnectionPoint::QueryInterface(REFIID riid, void** ppv) { LOGCALL(("CConnectionPoint::QueryInterface(riid = %s)\n", StringFromGuid(riid))); if (ppv == NULL) return E_INVALIDARG; *ppv = NULL; if (riid == IID_IUnknown || riid == IID_IConnectionPoint) { AddRef(); *ppv = static_cast<IConnectionPoint*>(this); return S_OK; } else if (riid == IID_IMarshal) { CriticalSection critical_section(&Module::m_GlobalSync); if (m_pUnkFTM == NULL) CoCreateFreeThreadedMarshaler(static_cast<IConnectionPoint*>(this), &m_pUnkFTM); if (m_pUnkFTM != NULL) return m_pUnkFTM->QueryInterface(riid, ppv); } return E_NOINTERFACE; }
CConnectionPoint::CConnectionPoint(REFIID riid) : m_riid(riid) { LOGCALL(("CConnectionPoint::CConnectionPoint()\n")); m_pUnkFTM = NULL; }
int tagfs_readlink(const char *a, char *b, size_t c){ LOGCALL(); (void) a; (void) b; (void) c; return 1; }
STDMETHODIMP CEnumConnections::Skip(ULONG cConnections) { LOGCALL(("CEnumConnections::Skip()\n")); CriticalSection critical_section(this); if (cConnections > 0) { bool fHasNext = false; DWORD dwCookie; if (m_fReset) { fHasNext = m_pCP->GetFirstConnection(&dwCookie, NULL); if (fHasNext) m_fReset = false; } else { fHasNext = m_pCP->GetNextConnection(m_dwCookieCurrent, &dwCookie, NULL); } while (fHasNext) { cConnections--; m_dwCookieCurrent = dwCookie; fHasNext = m_pCP->GetNextConnection(m_dwCookieCurrent, &dwCookie, NULL); } } return cConnections ? S_FALSE : S_OK; }
int tagfs_rename(const char *a, const char *b){ LOGCALL(); char **tagsbuf; comm_getTags(a,&tagsbuf); char **tmp = tagsbuf, **tmp2; int cpt = 0; tmp2 = tmp; while(*tmp != NULL){ tmp2 = tmp; tmp++; cpt ++; } cpt--; char name[strlen(*tmp2)+5]; name[0] = '/'; name[1] = '\0'; strcat(name,*tmp2); if(cpt == 1 && exist_file(db, *tmp2)){ tagfs_link(name, b); tagfs_unlink(a); comm_freeTags(tagsbuf); return SUCCESS; } comm_freeTags(tagsbuf); return FAILURE; }
int tagfs_rmdir(const char *tag){ LOGCALL(); // remove tag (function checks the existence of the tag) delete_tag(db, tag+1); return SUCCESS; }
STDMETHODIMP CMultipleResults::GetResult ( IUnknown* pUnkOuter, DBRESULTFLAG lResultFlag, REFIID riid, DBROWCOUNT* pcRowsAffected, IUnknown** ppRowset ) { LOGCALL(("CMultipleResults::GetResult()\n")); ErrorCheck error(IID_IMultipleResults, DISPID_IMultipleResults_GetResult); if (pcRowsAffected != NULL) *pcRowsAffected = DB_COUNTUNAVAILABLE; if (ppRowset != NULL) *ppRowset = NULL; if (pUnkOuter != NULL && riid != IID_IUnknown) return ErrorInfo::Set(DB_E_NOAGGREGATION); if (lResultFlag != DBRESULTFLAG_DEFAULT && lResultFlag != DBRESULTFLAG_ROWSET) return ErrorInfo::Set(E_INVALIDARG); #if 0 if (riid != IID_NULL && ppRowset == NULL) return ErrorInfo::Set(E_INVALIDARG); #endif return m_pCommandHandler->GetResult(pUnkOuter, riid, pcRowsAffected, ppRowset); }
int tagfs_getdir(const char *a, fuse_dirh_t b, fuse_dirfil_t c){ LOGCALL(); (void) a; (void) b; (void) c; return 1; }
int tagfs_mknod(const char *a, mode_t b, dev_t c){ LOGCALL(); (void) a; (void) b; (void) c; return 1; }
STDMETHODIMP CEnumConnectionPoints::Next(ULONG cConnections, IConnectionPoint** rgpCP, ULONG* pcFetched) { LOGCALL(("CEnumConnectionPoints::Next(%ld)\n", cConnections)); if (rgpCP == NULL) return E_POINTER; if (cConnections > 1 && pcFetched == NULL) return E_POINTER; CriticalSection critical_section(this); ULONG iConnections = 0; while (iConnections < cConnections) { IConnectionPoint* pCP = m_rgpCP[m_iCurrent]; if (pCP == NULL) break; m_iCurrent++; rgpCP[iConnections++] = pCP; pCP->AddRef(); } if (pcFetched) *pcFetched = iConnections; return iConnections < cConnections ? S_FALSE : S_OK; }
/** * assign a vector of character (an array of strings) to the variable. If you need * a factor then you should execute code to convert it after this command. In * recent versions of R a vector of strings does not need any more memory than * a factor and it is easier to append new elements to it. */ int MT4_EXPFUNC RAssignStringVector_(char* variable, char* vector[], int size) { LOGCALL(); try { std::vector<std::string> value; value.reserve(size); for(int i=0;i<size;++i) { value.push_back(vector[i]); } RInside::instance()[variable] = value; return 0; } catch(std::exception& ex) { logger::instance() << __FUNCTION__ << " Exception caught: " << ex.what() << std::endl; return -1; } catch(...) { logger::instance() << __FUNCTION__ << " Unknown exception caught" << std::endl; return -1; } }
HRESULT Module::GetClassObject(REFCLSID rclsid, REFIID riid, void** ppv) { LOGCALL(("Module::GetClassObject(rclsid=%s, riid=%s)\n", STRINGFROMGUID(rclsid), STRINGFROMGUID(riid))); if (ppv == NULL) return E_INVALIDARG; #if DEBUG int tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); tmpDbgFlag |= _CRTDBG_CHECK_ALWAYS_DF; _CrtSetDbgFlag(tmpDbgFlag); #endif *ppv = NULL; static ComClassFactory<ComAggregateObj <CDataSource> > ds_factory; static ComClassFactory<ComAdaptiveObjCreator <CErrorLookup> > el_factory; static ComClassFactory<ComAdaptiveObjCreator <CConnectionPage> > cp_factory; #if ADVANCED_PAGE static ComClassFactory<ComAdaptiveObjCreator <CAdvancedPage> > ap_factory; #endif if (rclsid == CLSID_VIRTOLEDB) return ds_factory.QueryInterface(riid, ppv); else if (rclsid == CLSID_VIRTOLEDB_ERROR) return el_factory.QueryInterface(riid, ppv); else if (rclsid == CLSID_VIRTOLEDB_CONNECTION_PAGE) return cp_factory.QueryInterface(riid, ppv); #if ADVANCED_PAGE else if (rclsid == CLSID_VIRTOLEDB_ADVANCED_PAGE) return ap_factory.QueryInterface(riid, ppv); #endif return CLASS_E_CLASSNOTAVAILABLE; }
void RefCountedImpl::AddRef() { LOGCALL(("RefCountedImpl::AddRef() (%s), count=%d\n", object_identity, ref_count + 1)); if (InterlockedIncrement(&ref_count) == 1) Referenced(); }
bool CConnectionPoint::HasConnections() { LOGCALL (("CConnectionPoint::HasConnections()\n")); CriticalSection critical_section(this); return !m_cookies.empty(); }
void RefCountedImpl::Release() { LOGCALL(("RefCountedImpl::Release() (%s), count=%d\n", object_identity, ref_count - 1)); if (InterlockedDecrement(&ref_count) == 0) Unreferenced(); }
STDMETHODIMP CGetDataSequentialStream::Read(void* pv, ULONG cb, ULONG* pcbRead) { LOGCALL(("CGetDataSequentialStream::Read(cb = %d)\n", cb)); if (pcbRead != NULL) *pcbRead = 0; if (cb == 0) return S_OK; if (pv == NULL) return STG_E_INVALIDPOINTER; assert(m_pStreamSync != NULL); CriticalSection critical_section(m_pStreamSync); if (m_status == STATUS_ZOMBIE) return E_UNEXPECTED; if (m_status == STATUS_FINISHED) return S_FALSE; SQLLEN cbRead; if (m_status == STATUS_INITIALIZED) { #if 0 HRESULT hr = m_pdsp->ResetLongData(m_iRecordID, m_iFieldOrdinal); if (FAILED(hr)) return hr; #endif m_status = STATUS_INPROGRESS; } HRESULT hr = m_pgd->GetLongData(m_iRecordID, m_iFieldOrdinal, m_wSqlCType, (char*) pv, cb, cbRead); if (FAILED(hr)) return hr; if (hr == S_FALSE) { m_status = STATUS_FINISHED; return hr; } ULONG cbTerm = 0; if (m_wSqlCType == SQL_C_CHAR) cbTerm = sizeof(CHAR); else if (m_wSqlCType == SQL_C_WCHAR) cbTerm = sizeof(WCHAR); if (cbRead == SQL_NO_TOTAL || cbRead + cbTerm > cb) { cbRead = cb - cbTerm; if (m_wSqlCType == SQL_C_WCHAR) cbRead -= cbRead % sizeof(WCHAR); // FIXME: Is it necessary to fill the last 0-3 bytes of the buffer? } if (pcbRead != NULL) *pcbRead = (ULONG)cbRead; return S_OK; }
CGetDataSequentialStream::CGetDataSequentialStream() { LOGCALL(("CGetDataSequentialStream::CGetDataSequentialStream()\n")); m_status = STATUS_UNINITIALIZED; m_pStreamSync = NULL; m_pgd = NULL; m_pUnkFTM = NULL; }
void CGetDataSequentialStream::Kill() { LOGCALL(("CGetDataSequentialStream::Kill()\n")); assert(m_pStreamSync != NULL); CriticalSection critical_section(m_pStreamSync); m_status = STATUS_ZOMBIE; }
int tagfs_write(const char *a, const char *b, size_t c, off_t d, struct fuse_file_info *e){ LOGCALL(); (void) a; (void) b; (void) c; (void) d; (void) e; return 1; }
CEnumConnectionPoints::CEnumConnectionPoints() { LOGCALL(("CEnumConnectionPoints::CEnumConnectionPoints()\n")); m_pUnkCPC = NULL; m_pUnkFTM = NULL; m_rgpCP = NULL; m_iCurrent = 0; }
CEnumConnections::CEnumConnections() { LOGCALL(("CEnumConnections::CEnumConnections()\n")); m_pCP = NULL; m_pUnkFTM = NULL; m_fReset = true; m_dwCookieCurrent = 0; }
STDMETHODIMP CEnumConnectionPoints::Reset() { LOGCALL(("CEnumConnectionPoints::Reset()\n")); CriticalSection critical_section(this); m_iCurrent = 0; return S_OK; }
STDMETHODIMP CConnectionPoint::GetConnectionInterface(IID *pIID) { LOGCALL(("CConnectionPoint::GetConnectionInterface()\n")); if (pIID == NULL) return E_POINTER; *pIID = m_riid; return S_OK; }
STDMETHODIMP CEnumConnections::Reset() { LOGCALL(("CEnumConnections::Reset()\n")); CriticalSection critical_section(this); m_fReset = true; return S_OK; }
int tagfs_mkdir(const char *tag, mode_t b){ LOGCALL(); (void) b; if(comm_isSingleTag(tag+1)){ // add tag (function checks the existence of the tag) add_new_tag(db, tag+1); return SUCCESS; } return FAILURE; }