static void __release_category(void* cat, loc_destroy_func_t destroy_fun, loc_name_func_t get_name, Category_Map** M) { #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) _STLP_auto_lock sentry(get_locale_catalog_category_hash_lock()); # else _STLP_auto_lock sentry(__category_hash_lock); # endif if (cat && (*M)) { // Find the name of the category object. char buf[_Locale_MAX_SIMPLE_NAME + 1]; char* name = get_name(cat, buf); if (name != 0) { Category_Map::iterator it = (*M)->find(name); if (it != (*M)->end()) { // Decrement the ref count. If it goes to zero, delete this category // from the map. if (--((*it).second.second) == 0) { void* cat1 = (*it).second.first; destroy_fun(cat1); (*M)->erase(it); delete (*M); *M = NULL; } } } } }
int CgroupLimits::set_cpu_shares(uint64_t shares) { if (!m_cgroup.isValid() || !CgroupManager::getInstance().isMounted(CgroupManager::CPU_CONTROLLER)) { dprintf(D_ALWAYS, "Unable to set CPU shares because cgroup is invalid.\n"); return 1; } int err; struct cgroup *cpucg = &m_cgroup.getCgroup(); struct cgroup_controller *cpu_controller; if ((cpu_controller = cgroup_get_controller(cpucg, CPU_CONTROLLER_STR)) == NULL) { dprintf(D_ALWAYS, "Unable to add cgroup CPU controller for %s.\n", m_cgroup_string.c_str()); return 1; } else if ((err = cgroup_set_value_uint64(cpu_controller, "cpu.shares", shares))) { dprintf(D_ALWAYS, "Unable to set CPU shares for %s: %u %s\n", m_cgroup_string.c_str(), err, cgroup_strerror(err)); return 1; } else { TemporaryPrivSentry sentry(PRIV_ROOT); if ((err = cgroup_modify_cgroup(cpucg))) { dprintf(D_ALWAYS, "Unable to commit CPU shares for %s" ": %u %s\n", m_cgroup_string.c_str(), err, cgroup_strerror(err)); return 1; } } return 0; }
int DockerAPI::stats(const std::string &container, uint64_t &memUsage, uint64_t &netIn, uint64_t &netOut) { newstats(container, memUsage, netIn, netOut); ArgList args; if ( ! add_docker_arg(args)) return -1; args.AppendArg( "stats" ); args.AppendArg( "--no-stream" ); args.AppendArg( container.c_str() ); MyString displayString; TemporaryPrivSentry sentry(PRIV_ROOT); args.GetArgsStringForLogging( & displayString ); dprintf( D_FULLDEBUG, "Attempting to run: %s\n", displayString.c_str() ); // Read from Docker's combined output and error streams. FILE * dockerResults = my_popen( args, "r", 1 , 0, false); if( dockerResults == NULL ) { dprintf( D_ALWAYS | D_FAILURE, "Failed to run '%s'.\n", displayString.c_str() ); return -2; } const int statLineSize = 256; char header[statLineSize]; char data[statLineSize]; if( NULL == fgets( header, statLineSize, dockerResults ) ) { my_pclose(dockerResults); return -2; } if( NULL == fgets( data, statLineSize, dockerResults ) ) { my_pclose(dockerResults); return -2; } my_pclose(dockerResults); dprintf(D_FULLDEBUG, "Docker stats data is:\n%s\n", data); // condor stats output looks like: // Name cpu% mem usage/limit mem% net i/o block i/o // container 0.00% 0 B / 0 B 0.00% 0 B / 0 B 0 B / 0 B // char memUsageUnit[2]; char netInUnit[2]; char netOutUnit[2]; double memRaw, netInRaw, netOutRaw; int matches = sscanf(data, "%*s %*g%% %lg %s / %*g %*s %*g%% %lg %s / %lg %s", &memRaw, &memUsageUnit[0], &netInRaw, &netInUnit[0], &netOutRaw, &netOutUnit[0]); if (matches < 6) { return -2; } memUsage = convertUnits(memRaw, memUsageUnit); netIn = convertUnits(netInRaw, netInUnit); netOut = convertUnits(netOutRaw, netOutUnit); dprintf(D_FULLDEBUG, "memUsage is %g (%s), net In is %g (%s), net Out is %g (%s)\n", memRaw, memUsageUnit, netInRaw, netInUnit, netOutRaw, netOutUnit); return 0; }
std::ostream & operator<<(std::ostream & out, const Configuration & configuration) { std::ostream::sentry sentry(out); if (sentry) { out << "mode: " << configuration.mode << "\n"; out << "endpoint: " << configuration.endpoint << "\n"; out << "send_bandwidth: " << configuration.send_bandwidth << "/s\n"; out << "receive_bandwidth: " << configuration.receive_bandwidth << "/s\n"; out << "bandwidth_sampling_frequency: " << configuration.bandwidth_sampling_frequency << "Hz\n"; out << "verify: " << configuration.verify << "\n"; if (configuration.windows != 0) out << "windows: " << configuration.windows << "\n"; else out << "windows: default system value\n"; out << "size: " << configuration.size << "\n"; if (configuration.duration_margin.is_special()) out << "duration_margin: default\n"; else out << "duration_margin: " << configuration.duration_margin << "\n"; out << "shutdown_policy: " << configuration.shutdown_policy << "\n"; out << std::flush; } return out; }
void TimerWheel::OnEvent() { DWORD nowTick = GetTickCount(); std::vector<Entity> expiredTimes; expiredTimes.clear(); Entity sentry(nowTick, NULL); TimerList::iterator end = _allTimers.lower_bound(sentry); assert(end == _allTimers.end() || nowTick < end->first); std::copy(_allTimers.begin(), end, back_inserter(expiredTimes)); _allTimers.erase(_allTimers.begin(), end); for (std::vector<Entity>::iterator iter = expiredTimes.begin() ; iter != expiredTimes.end() ; ++iter) { iter->second->_timer->OnTimer(nowTick); if (iter->second->_interval != 0) { iter->second->_when = nowTick + iter->second->_interval; _allTimers.insert(Entity(iter->second->_when, iter->second)); } else { delete iter->second; } } }
inline bool load(text_wrapper<T> & wrapper) { BOOST_STATIC_ASSERT( (boost::is_arithmetic<T>::value) ); T & t = wrapper.data(); try { rollback_sentry sentry(this); std::istreambuf_iterator<char> input_first(&m_sb); std::istreambuf_iterator<char> input_last; std::string buffer; std::streamsize ls = 0; bool bOk = false; while (input_first != input_last) { ++ls; char ch = *input_first++; if (ch == ' ') { bOk = true; break; } buffer += ch; } m_acc += ls; t = boost::lexical_cast<T>(buffer); return sentry.wrap(bOk); } catch(std::exception &) { return false; } }
void ClientStub::instantiateTransport() { CurrentClientStubSentry sentry(*this); if (!mTransport.get()) { RCF_VERIFY(mEndpoint.get(), Exception(_RcfError_NoEndpoint())); mTransport.reset( mEndpoint->createClientTransport().release() ); RCF_VERIFY(mTransport.get(), Exception(_RcfError_TransportCreation())); } if ( mAsync && !mTransport->isAssociatedWithIoService()) { RcfServer * preferred = getAsyncDispatcher(); AsioIoService * pIoService = NULL; if (preferred) { ServerTransport & transport = preferred->getServerTransport(); AsioServerTransport & asioTransport = dynamic_cast<AsioServerTransport &>(transport); pIoService = & asioTransport.getIoService(); } else { pIoService = & getAmiThreadPool().getIoService(); } mTransport->associateWithIoService(*pIoService); } }
static void __release_category(void* cat, loc_destroy_func_t destroy_fun, loc_name_func_t get_name, Category_Map* M) { _STL_auto_lock sentry(__category_hash_lock); if (cat && M) { // Find the name of the category object. char buf[_Locale_MAX_SIMPLE_NAME + 1]; char* name = get_name(cat, buf); if (name != 0) { Category_Map::iterator it = M->find(name); if (it != M->end()) { // Decrement the ref count. If it goes to zero, delete this category // from the map. if (--((*it).second.second) == 0) { void* cat1 = (*it).second.first; destroy_fun(cat1); M->erase(it); } } } } }
void ClientStub::flushBatch(unsigned int timeoutMs) { CurrentClientStubSentry sentry(*this); if (timeoutMs == 0) { timeoutMs = getRemoteCallTimeoutMs(); } try { std::vector<ByteBuffer> buffers; buffers.push_back( ByteBuffer(mBatchBufferPtr) ); int err = getTransport().send(*this, buffers, timeoutMs); RCF_UNUSED_VARIABLE(err); mBatchBufferPtr->resize(0); ++mBatchCount; mBatchMessageCount = 0; } catch(const RemoteException & e) { RCF_UNUSED_VARIABLE(e); mEncodedByteBuffers.resize(0); throw; } catch(...) { mEncodedByteBuffers.resize(0); disconnect(); throw; } }
static void __release_category(void* cat, loc_destroy_func_t destroy_fun, loc_name_func_t get_name, Category_Map** M) { Category_Map *pM = *M; if (cat && pM) { // Find the name of the category object. char buf[_Locale_MAX_SIMPLE_NAME + 1]; char* name = get_name(cat, buf); if (name != 0) { _STLP_auto_lock sentry(__category_hash_lock); Category_Map::iterator it = pM->find(name); if (it != pM->end()) { // Decrement the ref count. If it goes to zero, delete this category // from the map. if (--((*it).second.second) == 0) { void* cat1 = (*it).second.first; destroy_fun(cat1); pM->erase(it); #ifdef _STLP_LEAKS_PEDANTIC if (pM->empty()) { delete pM; *M = 0; } #endif /* _STLP_LEAKS_PEDANTIC */ } } } } }
// // JobExit() is called after file transfer. // bool DockerProc::JobExit() { dprintf( D_ALWAYS, "DockerProc::JobExit()\n" ); { TemporaryPrivSentry sentry(PRIV_ROOT); ClassAd dockerAd; CondorError error; int rv = DockerAPI::inspect( containerName, & dockerAd, error ); if( rv < 0 ) { dprintf( D_ALWAYS | D_FAILURE, "Failed to inspect (for removal) container '%s'.\n", containerName.c_str() ); return VanillaProc::JobExit(); } bool running; if( ! dockerAd.LookupBool( "Running", running ) ) { dprintf( D_ALWAYS | D_FAILURE, "Inspection of container '%s' failed to reveal its running state.\n", containerName.c_str() ); return VanillaProc::JobExit(); } if( running ) { dprintf( D_ALWAYS | D_FAILURE, "Inspection reveals that container '%s' is still running.\n", containerName.c_str() ); return VanillaProc::JobExit(); } rv = DockerAPI::rm( containerName, error ); if( rv < 0 ) { dprintf( D_ALWAYS | D_FAILURE, "Failed to remove container '%s'.\n", containerName.c_str() ); } } return VanillaProc::JobExit(); }
static uint8_t readHexByte(std::istream & s) { std::istream::sentry sentry(s, true); if (sentry) { char c1 = 0, c2 = 0; s.get(c1); s.get(c2); if (s.fail()) { if (s.eof()) { throw std::runtime_error("Unexpected end of line."); } else { throw std::runtime_error("Failed to read hex digit."); } } int v1 = hexDigitValue(c1); int v2 = hexDigitValue(c2); if (v1 < 0 || v2 < 0) { throw std::runtime_error("Invalid hex digit."); } return v1 * 16 + v2; } return 0; }
int CgroupLimits::set_blockio_weight(uint64_t weight) { if (!m_cgroup.isValid() || !CgroupManager::getInstance().isMounted(CgroupManager::BLOCK_CONTROLLER)) { dprintf(D_ALWAYS, "Unable to set blockio weight because cgroup is invalid.\n"); return 1; } int err; struct cgroup *blkiocg = &m_cgroup.getCgroup(); struct cgroup_controller *blkio_controller; if ((blkio_controller = cgroup_get_controller(blkiocg, BLOCK_CONTROLLER_STR)) == NULL) { dprintf(D_ALWAYS, "Unable to get cgroup block IO controller for %s.\n", m_cgroup_string.c_str()); return 1; } else if ((err = cgroup_set_value_uint64(blkio_controller, "blkio.weight", weight))) { dprintf(D_ALWAYS, "Unable to set block IO weight for %s: %u %s\n", m_cgroup_string.c_str(), err, cgroup_strerror(err)); return 1; } else { TemporaryPrivSentry sentry(PRIV_ROOT); if ((err = cgroup_modify_cgroup(blkiocg))) { dprintf(D_ALWAYS, "Unable to commit block IO weight for %s" ": %u %s\n", m_cgroup_string.c_str(), err, cgroup_strerror(err)); return 1; } } return 0; }
void DockerProc::Suspend() { dprintf( D_ALWAYS, "DockerProc::Suspend()\n" ); int rv = 0; { TemporaryPrivSentry sentry(PRIV_ROOT); CondorError error; rv = DockerAPI::pause( containerName, error ); } TemporaryPrivSentry sentry(PRIV_ROOT); if( rv < 0 ) { dprintf( D_ALWAYS | D_FAILURE, "Failed to suspend container '%s'.\n", containerName.c_str() ); } is_suspended = true; }
CgroupLimits::CgroupLimits(std::string &cgroup) : m_cgroup_string(cgroup) { TemporaryPrivSentry sentry(PRIV_ROOT); CgroupManager::getInstance().create(m_cgroup_string, m_cgroup, CgroupManager::MEMORY_CONTROLLER | CgroupManager::CPU_CONTROLLER | CgroupManager::BLOCK_CONTROLLER, CgroupManager::NO_CONTROLLERS, false, false); }
// Takes a reference to a locale::id, and returns its numeric index. // If no numeric index has yet been assigned, assigns one. The return // value is always positive. size_t _Stl_loc_get_index(locale::id& id) { if (id._M_index == 0) { _STL_auto_lock sentry(_Index_lock); size_t new_index = locale::id::_S_max++; id._M_index = new_index; } return id._M_index; }
IgstkToolPtr IgstkToolManager::addIgstkTools(ToolFileParser::ToolInternalStructure& toolStructure) { IgstkToolPtr igstkTool(new IgstkTool(toolStructure)); if (igstkTool->isValid()) { QMutexLocker sentry(&mToolMutex); mTools[igstkTool->getUid()] = igstkTool; connect(igstkTool.get(), SIGNAL(attachedToTracker(bool)), this, SLOT(deviceInitializedSlot(bool))); }
void ClientStub::clearParameters() { if (mpParameters) { CurrentClientStubSentry sentry(*this); mpParameters->~I_Parameters(); mpParameters = NULL; } }
void CCheckTextControlDlg::OnCheckRichTextControl() { CRichEditCtrl *richEditCtrl = (CRichEditCtrl *)GetDlgItem(IDC_RICHEDIT1); CSentrySpellDlg sentry(this); SSCE_S16 rv = sentry.Check(richEditCtrl); if (rv < 0) { CString msg; msg.Format(_T("Check returned %hd"), rv); } }
static void* __acquire_category(const char* name, loc_create_func_t create_obj, loc_default_name_func_t default_obj, Category_Map ** M) { typedef Category_Map::iterator Category_iterator; pair<Category_iterator, bool> result; #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) _STLP_auto_lock sentry(get_locale_catalog_category_hash_lock()); # else _STLP_auto_lock sentry(__category_hash_lock); # endif typedef const char* key_type; if (!*M) *M = new Category_Map(); #if defined(__SC__) //*TY 06/01/2000 - added workaround for SCpp if(!*M) delete *M; //*TY 06/01/2000 - it forgets to generate dtor for Category_Map class. This fake code forces to generate one. #endif //*TY 06/01/2000 - // Find what name to look for. Be careful if user requests the default. char buf[_Locale_MAX_SIMPLE_NAME]; if (name == 0 || name[0] == 0) name = default_obj(buf); if (name == 0 || name[0] == 0) name = "C"; pair<const key_type, pair<void*,size_t> > __e(name, pair<void*,size_t>((void*)0,size_t(0))); // Look for an existing entry with that name. result = (*M)->insert_noresize(__e); // There was no entry in the map already. Create the category. if (result.second) (*result.first).second.first = create_obj(name); // Increment the reference count. ++((*result.first).second.second); return (*result.first).second.first; }
Starter* StarterMgr::makeStarter( const char* path ) { Starter* new_starter; FILE* fp; char *args[] = { const_cast<char*>(path), const_cast<char*>("-classad"), NULL }; char buf[1024]; // first, try to execute the given path with a "-classad" // option, and grab the output as a ClassAd // note we run the starter here as root if possible, // since that is how the starter will be invoked for real, // and the real uid of the starter may influence the // list of capabilities the "-classad" option returns. { TemporaryPrivSentry sentry(PRIV_ROOT); fp = my_popenv( args, "r", FALSE ); } if( ! fp ) { dprintf( D_ALWAYS, "Failed to execute %s, ignoring\n", path ); return NULL; } ClassAd* ad = new ClassAd; bool read_something = false; while( fgets(buf, 1024, fp) ) { read_something = true; if( ! ad->Insert(buf) ) { dprintf( D_ALWAYS, "Failed to insert \"%s\" into ClassAd, " "ignoring invalid starter\n", buf ); delete( ad ); pclose( fp ); return NULL; } } my_pclose( fp ); if( ! read_something ) { dprintf( D_ALWAYS, "\"%s -classad\" did not produce any output, ignoring\n", path ); delete( ad ); return NULL; } new_starter = new Starter(); new_starter->setAd( ad ); new_starter->setPath( path ); int is_dc = 0; ad->LookupBool( ATTR_IS_DAEMON_CORE, is_dc ); new_starter->setIsDC( (bool)is_dc ); return new_starter; }
static void* __acquire_category(const char* &name, char *buf, _Locale_name_hint* hint, loc_extract_name_func_t extract_name, loc_create_func_t create_obj, loc_default_name_func_t default_name, Category_Map ** M, int *__err_code) { typedef Category_Map::iterator Category_iterator; pair<Category_iterator, bool> result; *__err_code = _STLP_LOC_UNDEFINED; // Find what name to look for. Be careful if user requests the default. if (name[0] == 0) { name = default_name(buf); if (name == 0 || name[0] == 0) name = "C"; } else { const char* cname = extract_name(name, buf, hint, __err_code); if (cname == 0) { return 0; } name = cname; } Category_Map::value_type __e(name, pair<void*,size_t>((void*)0,size_t(0))); _STLP_auto_lock sentry(category_hash_mutex()); if (!*M) *M = new Category_Map(); // Look for an existing entry with that name. result = (*M)->insert_noresize(__e); if (result.second) { // There was no entry in the map already. Create the category. (*result.first).second.first = create_obj(name, hint, __err_code); if (!(*result.first).second.first) { (*M)->erase(result.first); #if defined (_STLP_LEAKS_PEDANTIC) if ((*M)->empty()) { delete *M; *M = 0; } #endif return 0; } } // Increment the reference count. ++((*result.first).second.second); return (*result.first).second.first; }
std::ostream &operator<<(std::ostream &str, const mean_result<T> &self) { internal::check_valid(self); internal::format_sentry sentry(str); verbosity verb = internal::get_format(str, PRINT_TERSE); if (verb == PRINT_VERBOSE) str << "<X> = "; str << self.mean(); return str; }
// GTK CALLBACKS void TexturePreviewCombo::_onExpose (GtkWidget* widget, GdkEventExpose* ev, TexturePreviewCombo* self) { // Grab the GLWidget with sentry gtkutil::GLWidgetSentry sentry(widget); // Initialise viewport glClearColor(0.3, 0.3, 0.3, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDisable( GL_DEPTH_TEST); glEnable( GL_TEXTURE_2D); // If no texture is loaded, leave window blank if (self->_texName.empty()) return; glMatrixMode( GL_PROJECTION); glLoadIdentity(); glOrtho(0, 1, 0, 1, -1, 1); // Get a reference to the selected shader IShader* shader = GlobalShaderSystem().getShaderForName(self->_texName); // Bind the texture from the shader GLTexture* tex = shader->getTexture(); glBindTexture(GL_TEXTURE_2D, tex->texture_number); // Calculate the correct aspect ratio for preview float aspect = float(tex->width) / float(tex->height); float hfWidth, hfHeight; if (aspect > 1.0) { hfWidth = 0.5; hfHeight = 0.5 / aspect; } else { hfHeight = 0.5; hfWidth = 0.5 * aspect; } // Draw a polygon glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glColor3f(1, 1, 1); glBegin( GL_QUADS); glTexCoord2i(0, 1); glVertex2f(0.5 - hfWidth, 0.5 - hfHeight); glTexCoord2i(1, 1); glVertex2f(0.5 + hfWidth, 0.5 - hfHeight); glTexCoord2i(1, 0); glVertex2f(0.5 + hfWidth, 0.5 + hfHeight); glTexCoord2i(0, 0); glVertex2f(0.5 - hfWidth, 0.5 + hfHeight); glEnd(); shader->DecRef(); }
void CamWnd::draw() { m_drawing = true; gtkutil::GLWidgetSentry sentry(m_gl_widget); if (GlobalMap().isValid() && ScreenUpdates_Enabled()) { Cam_Draw(); m_XORRectangle.set(rectangle_t()); } m_drawing = false; }
// Takes a reference to a locale::id, and returns its numeric index. // If no numeric index has yet been assigned, assigns one. The return // value is always positive. static size_t _Stl_loc_get_index(locale::id& id) { if (id._M_index == 0) { #if defined (_STLP_ATOMIC_INCREMENT) id._M_index = _STLP_ATOMIC_INCREMENT(&(locale::id::_S_max)); #else static _STLP_STATIC_MUTEX _Index_lock _STLP_MUTEX_INITIALIZER; _STLP_auto_lock sentry(_Index_lock); size_t new_index = locale::id::_S_max++; id._M_index = new_index; #endif } return id._M_index; }
// Takes a reference to a locale::id, assign a numeric index if not already // affected and returns it. The returned index is always positive. static const locale::id& _Stl_loc_get_index(locale::id& id) { if (id._M_index == 0) { #if defined (_STLP_ATOMIC_INCREMENT) && !defined (_STLP_WIN95_LIKE) static _STLP_VOLATILE __stl_atomic_t _S_index = __STATIC_CAST(__stl_atomic_t, locale::id::_S_max); id._M_index = _STLP_ATOMIC_INCREMENT(&_S_index); #else static _STLP_STATIC_MUTEX _Index_lock _STLP_MUTEX_INITIALIZER; _STLP_auto_lock sentry(_Index_lock); size_t new_index = locale::id::_S_max++; id._M_index = new_index; #endif } return id; }
int VanillaProc::setupOOMScore(int oom_adj, int oom_score_adj) { #if !(defined(HAVE_EVENTFD)) if (oom_adj + oom_score_adj) // Done to suppress compiler warnings. return 0; return 0; #else TemporaryPrivSentry sentry(PRIV_ROOT); // oom_adj is deprecated on modern kernels and causes a deprecation warning when used. int oom_score = oom_adj; // assume the old way int oom_score_fd = open("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC); if (oom_score_fd == -1) { if (errno != ENOENT) { dprintf(D_ALWAYS, "Unable to open oom_score_adj for the starter: (errno=%u, %s)\n", errno, strerror(errno)); return 1; } else { oom_score_fd = open("/proc/self/oom_adj", O_WRONLY | O_CLOEXEC); if (oom_score_fd == -1) { dprintf(D_ALWAYS, "Unable to open oom_adj for the starter: (errno=%u, %s)\n", errno, strerror(errno)); return 1; } } } else { // oops, we've got the new kind. Use that. oom_score = oom_score_adj; } std::stringstream ss; ss << oom_score; std::string new_score_str = ss.str(); ssize_t nwritten = full_write(oom_score_fd, new_score_str.c_str(), new_score_str.length()); if (nwritten < 0) { dprintf(D_ALWAYS, "Unable to write into oom_adj file for the starter: (errno=%u, %s)\n", errno, strerror(errno)); close(oom_score_fd); return 1; } close(oom_score_fd); return 0; #endif }
inline std::ostream& operator<<(std::ostream& os, ostream_wrapper<string> s) { std::ostream::sentry sentry(os); const char* str = s.first.raw()->GetStringUTFChars(s.second.raw(), 0); if(str) { os << str; s.first.raw()->ReleaseStringUTFChars(s.second.raw(), str); return os; } else return os << "[allocation error while returning string]"; }
void CAutoCorrectDlg::OnStart() { CSentrySpellDlg sentry(this); // Make sure auto correction is enabled. sentry.SetAutoCorrect(TRUE); // Check the contents of the edit control. CEdit *editCtrl = (CEdit *)GetDlgItem(IDC_EDIT1); SSCE_S16 rv = sentry.Check(editCtrl); if (rv < 0) { CString msg; msg.Format(_T("Check returned %hd"), rv); } }