const fcache_map_t& cache_write(const string &dir, fcache_map_t *fm) { fcache_map_t::iterator itr = fm->begin(); while(itr != fm->end()){ if (itr ->second.cache.size()) { if (!itr->second.file.length()) { // the file is first time to synchronize to disk itr -> second.file = dir; string wname = itr->first; string::size_type slash = wname.find('/'); while (slash != string::npos) { wname.replace(slash, 1, ","); slash = wname.find('/'); } itr -> second.file += "/"; itr -> second.file += wname; vwritef(itr->second.file, itr->second.cache, "w"); } else { vwritef(itr->second.file, itr->second.cache, "a+"); } #ifdef DEBUG_PRINT_L3 printf("cache file:%s\n", itr->second.file.c_str()); #endif itr->second.cache.clear(); // release the memory } ++itr; } return *fm; }
void CProtocolUtil::writef(synergy::IStream* stream, const char* fmt, ...) { assert(stream != NULL); assert(fmt != NULL); LOG((CLOG_DEBUG2 "writef(%s)", fmt)); va_list args; va_start(args, fmt); UInt32 size = getLength(fmt, args); va_end(args); va_start(args, fmt); vwritef(stream, fmt, size, args); va_end(args); }
static void error_child(const char *err, va_list params) { vwritef(child_err, "error: ", err, params); }
static NORETURN void die_child(const char *err, va_list params) { vwritef(child_err, "fatal: ", err, params); exit(128); }