本文整理汇总了C++中write_log函数的典型用法代码示例。如果您正苦于以下问题:C++ write_log函数的具体用法?C++ write_log怎么用?C++ write_log使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expamem_wget
static uae_u32 REGPARAM2 expamem_wget (uaecptr addr)
{
uae_u32 v = (expamem_bget (addr) << 8) | expamem_bget (addr + 1);
write_log ("warning: READ.W from address $%lx=%04x PC=%x\n", addr, v & 0xffff, M68K_GETPC);
return v;
}
示例2: write_log
bool CSymbolEngineOpenPPLHandAndBoardExpression::EvaluateSymbol(const char *name, double *result, bool log /* = false */) {
// First check, if hand$ or board$ and/or Suited
// At the same time remove the unnecessary parts of the expression
if (memcmp(name, "hand$", 5) == 0) {
is_hand_expression = true;
is_board_expression = false;
hand_or_board_expression = name;
write_log(preferences.debug_hand_and_baord_expressions(),
"[CSymbolEngineOpenPPLHandAndBoardExpression] Evaluating %s\n",
hand_or_board_expression);
hand_or_board_expression = CStringRemoveLeft(hand_or_board_expression, 5);
prime_coded_available_ranks = _prime_coded_hole_cards;
} else if (memcmp(name, "board$", 6) == 0) {
is_hand_expression = false;
is_board_expression = true;
hand_or_board_expression = name;
write_log(preferences.debug_hand_and_baord_expressions(),
"[CSymbolEngineOpenPPLHandAndBoardExpression] Evaluating %s\n",
hand_or_board_expression);
hand_or_board_expression = CStringRemoveLeft(hand_or_board_expression, 6);
prime_coded_available_ranks = _prime_coded_board_cards;
} else {
// Quick exit on other symbols
return false;
}
write_log(preferences.debug_hand_and_baord_expressions(),
"[CSymbolEngineOpenPPLHandAndBoardExpression] Encoded available ranks> %i\n",
prime_coded_available_ranks);
bool is_suited_expression = false;
assert(is_hand_expression || is_board_expression);
if (hand_or_board_expression.Right(6).MakeLower() == "suited") {
write_log(preferences.debug_hand_and_baord_expressions(),
"[CSymbolEngineOpenPPLHandAndBoardExpression] Suited expression\n");
is_suited_expression = true;
hand_or_board_expression = CStringRemoveRight(
hand_or_board_expression, 6);
}
// Checking ranks with potential multiplicity > 1, not caring about suits.
// We do this at the very beginning, as this is a very quick test
// and most real-world-use-cases will be false, so we get a fast exit.
int prime_coded_search_expression = PrimeCodedRanks(hand_or_board_expression);
write_log(preferences.debug_hand_and_baord_expressions(),
"[CSymbolEngineOpenPPLHandAndBoardExpression] Encoded searched ranks> %i\n",
prime_coded_available_ranks);
if ((prime_coded_available_ranks % prime_coded_search_expression) != 0) {
// Division without reminder not possible.
// Therefore different primes in the search-expression
// Therefore ranks that do not fit available ranks.
write_log(preferences.debug_hand_and_baord_expressions(),
"[CSymbolEngineOpenPPLHandAndBoardExpression] No match, because ranks do not fit\n");
*result = false;
return true;
}
// This was super-elegant, but unfortunatelly there can be
// SUITED expressions, which we can only solve with srankbits.
// Ranks in the expression (to be searched)
if (is_suited_expression) {
int rankbits_to_be_searched = CardStringToRankbits(((char*)hand_or_board_expression.GetString()));
write_log(preferences.debug_hand_and_baord_expressions(),
"[CSymbolEngineOpenPPLHandAndBoardExpression] rank bits for %s = %i\n",
hand_or_board_expression.GetString(), rankbits_to_be_searched);
if (is_hand_expression) {
// Suited hand-expression
// Ranks already checked, there are only 2, this simplifies things
if (!p_symbol_engine_cards->issuited()) {
write_log(preferences.debug_hand_and_baord_expressions(),
"[CSymbolEngineOpenPPLHandAndBoardExpression] No match, because off-suited hole-cards\n");
// No suited ranks available
*result = false;
return true;
}
} else {
// Suited board-expression
int rankbits_available = p_symbol_engine_pokerval->srankbitscommon();
// Check ranks in expression against available ranks
if ((rankbits_to_be_searched & rankbits_available) != rankbits_to_be_searched)
{
write_log(preferences.debug_hand_and_baord_expressions(),
"[CSymbolEngineOpenPPLHandAndBoardExpression] No match, because suited rankbits do not fit\n");
*result = false;
return true;
}
}
}
// Third case: cards with individual suits
int length = hand_or_board_expression.GetLength();
for (int i=0; i<(length-1); i++) {
if (IsCardRankCharacter(hand_or_board_expression[i])
&& IsCardSuitCharacter(hand_or_board_expression[i+1])) {
CString card_with_specific_suit =
CString(hand_or_board_expression[i])
+ CString(hand_or_board_expression[i+1]);
int icard_with_specific_suit = CardStringToCardNumber(
((char*)card_with_specific_suit.GetString()));
//.........这里部分代码省略.........
示例3: SQL_updateAttend_contest
void SQL_updateAttend_contest(int contestId,int verdictId,int problemId,char *num,char *username,time_t start_time,time_t end_time){
//已经AC的不需要修改attend
//update ac_time
long AC_time=0;
time_t first_ac_t;
SQL_SemP();
if(SQL_getFirstACTime_contest(contestId,problemId,username,first_ac_t,start_time,end_time))
{
AC_time=getdiftime(first_ac_t,start_time);
}
else
{
AC_time=0;
first_ac_t = end_time;
}
sprintf(query,"update attend set %s_time=%ld where contest_id=%d and username='%s';",num,AC_time,contestId,username);
//cout<<query<<endl;
if(mysql_real_query(mysql,query,(unsigned int)strlen(query)))
{
write_log(JUDGE_ERROR,mysql_error(mysql));
}
long ac_nCount=SQL_countProblemVerdict(contestId,problemId,V_AC,username);
int score_ = SQL_getContestScore(contestId,username,start_time,end_time);
string s_t,e_t,fAC_t;
API_TimeToString(s_t,start_time);
API_TimeToString(e_t,end_time);
API_TimeToString(fAC_t,first_ac_t);
//update score solved ,wrongsubmits
sprintf(query,"update attend set solved=(SELECT count(DISTINCT problem_id) FROM solution WHERE contest_id=%d and username='%s' and verdict=%d and submit_date between '%s' and '%s'),%s_wrongsubmits=(SELECT count(solution_id) FROM solution WHERE contest_id=%d and problem_id=%d and username='%s' and verdict>%d and submit_date between '%s' and '%s'),score=%d where contest_id=%d and username='%s';",contestId,username,V_AC,s_t.c_str(),e_t.c_str(), num,contestId,problemId,username,V_AC,s_t.c_str(),fAC_t.c_str(), score_, contestId,username);
if(mysql_real_query(mysql,query,(unsigned int)strlen(query)))
{
write_log(JUDGE_ERROR,mysql_error(mysql));
}
//penalty
int nCountProblems=SQL_countContestProblems(contestId);
char index='A';
long penalty=0;
for(int i=0;i<nCountProblems;i++)
{
long a_time_=0;
int wrongsubmits_=0;
SQL_getContestAttend(contestId,username,index+i,a_time_,wrongsubmits_);
if(a_time_>0)
{
penalty=penalty+a_time_+wrongsubmits_*60*20;
}
}
sprintf(query,"update attend set penalty=%ld where contest_id=%d and username='%s';",penalty,contestId,username);
if(mysql_real_query(mysql,query,(unsigned int)strlen(query)))
{
write_log(JUDGE_ERROR,mysql_error(mysql));
}
SQL_SemV();
}
示例4: my_stat
bool my_stat (const TCHAR *name, struct mystat *statbuf)
{
DWORD attr, ok;
FILETIME ft, lft;
HANDLE h;
BY_HANDLE_FILE_INFORMATION fi;
const TCHAR *namep;
bool fat;
TCHAR path[MAX_DPATH];
if (currprefs.win32_filesystem_mangle_reserved_names == false) {
_tcscpy (path, PATHPREFIX);
_tcscat (path, name);
namep = path;
} else {
namep = name;
}
// FILE_FLAG_BACKUP_SEMANTICS = can also "open" directories
h = CreateFile (namep, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (h == INVALID_HANDLE_VALUE)
return false;
fat = isfat (h);
ok = GetFileInformationByHandle (h, &fi);
CloseHandle (h);
attr = 0;
ft.dwHighDateTime = ft.dwLowDateTime = 0;
if (ok) {
attr = fi.dwFileAttributes;
if (fat) {
// fat lastwritetime only has 2 second resolution
// fat creationtime has 10ms resolution
// use creationtime if creationtime is inside lastwritetime 2s resolution
ULARGE_INTEGER ct, wt;
ct.HighPart = fi.ftCreationTime.dwHighDateTime;
ct.LowPart = fi.ftCreationTime.dwLowDateTime;
wt.HighPart = fi.ftLastWriteTime.dwHighDateTime;
wt.LowPart = fi.ftLastWriteTime.dwLowDateTime;
uae_u64 ctsec = ct.QuadPart / 10000000;
uae_u64 wtsec = wt.QuadPart / 10000000;
if (wtsec == ctsec || wtsec + 1 == ctsec) {
ft = fi.ftCreationTime;
} else {
ft = fi.ftLastAccessTime;
}
} else {
ft = fi.ftLastWriteTime;
}
statbuf->size = ((uae_u64)fi.nFileSizeHigh << 32) | fi.nFileSizeLow;
} else {
write_log (_T("GetFileInformationByHandle(%s) failed: %d\n"), namep, GetLastError ());
return false;
}
statbuf->mode = (attr & FILE_ATTRIBUTE_READONLY) ? FILEFLAG_READ : FILEFLAG_READ | FILEFLAG_WRITE;
if (attr & FILE_ATTRIBUTE_ARCHIVE)
statbuf->mode |= FILEFLAG_ARCHIVE;
if (attr & FILE_ATTRIBUTE_DIRECTORY)
statbuf->mode |= FILEFLAG_DIR;
FileTimeToLocalFileTime (&ft,&lft);
uae_u64 t = (*(__int64 *)&lft-((__int64)(369*365+89)*(__int64)(24*60*60)*(__int64)10000000));
statbuf->mtime.tv_sec = t / 10000000;
statbuf->mtime.tv_usec = (t / 10) % 1000000;
return true;
}
示例5: load
//Function: load
//Description: loads the key_count and property_count from the respective file
// loads the inventory table data from secondary memory to primary
//Input param: NULL
//Return Type: integer
// success status on successful operation
// respective error status code otherwise
int load()
{
// Start the log file
open_log();
// Use a file pointer to open various files to load the values
FILE *fp;
//Local variables
int index = 0;
int key_index = 0;
int status = 0;
int file_status = 0;
//check whether key_count.txt file is empty or not.
file_status = file_empty_check("key_count.txt");
if (file_status == 1006)
return FAILURE;
//check whether property_count.txt file is empty or not.
file_status = file_empty_check("property_count.txt");
if (file_status == 1006)
return FAILURE;
//check whether inventory_file.txt file is empty or not
file_status = file_empty_check("inventory_file.txt");
if (file_status == 1006)
return FAILURE;
// Open the key_count file to read the number of keywords
fp = fopen("key_count.txt","r");
if(fp == NULL) {
write_log("load", "FILE_OPEN_ERROR", "Unable to open the key_count file");
return FAILURE;
}
fscanf(fp,"%d", &key_count);
if(key_count <= 0 ) {
write_log("load", "FAILURE", "Key count is 0 or less than 0");
return FAILURE;
}
write_log("load", "SUCCESS", "Key count read successfully");
fclose(fp);
// Open the property_count file to read the number of properties
fp = fopen("property_count.txt","r");
if(fp == NULL) {
write_log("load", "FILE_OPEN_ERROR", "Unable to open the property_count file");
return FAILURE;
}
fscanf(fp,"%d", &property_count);
if (property_count <= 0) {
write_log("load", "FAILURE", "property count is 0 or less than 0");
return FAILURE;
}
write_log("load", "SUCCESS", "Property count read successfully");
fclose(fp);
// Open the inventory_file to read the available inventory details
fp = fopen("inventory_file.txt", "r");
if (fp == NULL) {
write_log("load", "FILE_OPEN_ERROR", "Error in opening the inventory_file");
return FAILURE;
}
// Allocate the memory for inventory table
status = inventory_memory_allocation();
if(status == 1002) {
write_log("load", "MEMORY_ALLOCATION_ERROR", "No memory for inventory table");
return FAILURE;
}
// Load the details from file to main memory
while(!feof(fp)) {
for(index = 0; index <= key_count; index++) {
fscanf(fp, "%s ", inventory[key_index][index]);
}
key_index++;
}
fclose(fp);
write_log("load", "SUCCESS", "Inventory Load Successful");
return SUCCESS;
}
示例6: main
int main(int argc, char *argv[])
{
char* cmd;
if ((cmd = strrchr(argv[0],'/')) == NULL)
{
cmd = argv[0];
}
else
cmd++;
const char* server_name = "synctool";
char path[BUFSIZE];
char server_path[BUFSIZE];
memset(path,0,BUFSIZE);
memset(server_path,0,BUFSIZE);
getcwd(path,BUFSIZE);
strcat(path,"/");
memcpy(server_path,path,BUFSIZE);
strcat(server_path,server_name);
memcpy(log_name,path,BUFSIZE);
strcat(log_name,"daemon_log.txt");
char now_time[40];
get_time(now_time,40);
write_log("synctool daemon start time : %s\n",now_time);
/// 先判断守护进程是否已经运行
///
if(just_running(LOCKDAEM,NULL) == 0)
{
printf("the sync_daemon is already running !\n");
return 0;
}
daemonize(cmd);
signal(SIGTERM,sigterm_handle);
/// 记录守护进程pid
if(record_pid(LOCKDAEM) != 0)
{
printf("sync_daemon write pid failed !\n");
return 0;
}
while(_running)
{
pid_t pid;
if((pid = fork()) < 0)
{
write_log("fork error !\n");
}
else if(pid == 0)
{
if(record_pid(LOCKFILE) == 0)
{
if(execl(server_path,server_name,path,(char*)0) < 0)
{
write_log(strerror(errno));
remove(LOCKFILE);
}
}
}
else
{
pid_t sub_pid = wait(NULL);
if (sub_pid != pid)
{
write_log("wait synctool pid (%d) not equal fork return pid(%d)! \n",sub_pid,pid);
}
remove(LOCKFILE);
write_log("restart synctool server !\n");
}
}
return 0;
}
示例7: FAST_EXIT_ON_OPENPPL_SYMBOLS
bool CSymbolEnginePokerTracker::EvaluateSymbol(const char *name, double *result, bool log /* = false */)
{
FAST_EXIT_ON_OPENPPL_SYMBOLS(name);
if (memcmp(name,"pt_",3)!=0)
{
// Symbol of a different symbol-engine
return false;
}
CString s = name;
CheckForChangedPlayersOncePerHeartbeatAndSymbolLookup();
if (IsOldStylePTSymbol(s))
{
CString error_message;
error_message.Format(
"Old style PokerTracker symbol detected: %s.\n"
"\n"
"PokerTracker symbol start with \"pt_\".\n"
"Possible postfixes:\n"
" * chair number (0..9)\n"
" * _raischair\n"
" * _headsup\n"
" * _smallblind\n"
" * _bigblind\n"
" * _dealer\n"
" * _cutoff\n"
" * _user\n"
" * _firstraiser\n"
" * _firstcaller\n"
" * _lastcaller\n", s);
OH_MessageBox_Formula_Error(
error_message,
"ERROR: Invalid PokerTracker Symbol");
*result = kUndefined;
return true;
}
if (!PT_DLL_IsValidSymbol(CString(s)))
{
// Invalid PokerTracker symbol
WarnAboutInvalidPTSymbol(s);
*result = kUndefined;
return true;
}
int chair = 0;
if (!p_pokertracker_thread->IsConnected()) {
if (!p_symbol_engine_userchair->userchair_confirmed() || p_formula_parser->IsParsing()) {
// We are not yet seated or formula is getting parsed.
// Symbol-lookup happens, because of Formula-validation.
// Not a problem, if we do not yet have a DB-connection.
// Don't throw a warning here.
write_log(preferences.debug_pokertracker(), "[PokerTracker] Not yet seated or formula parsing.\n");
} else {
// We are seated and playing.
// Serious problem, if we do not have a DB-connection.
OH_MessageBox_Error_Warning("Not connected to PokerTracker database.\n"
"Can't use PokerTracker symbols.");
}
*result = kUndefined;
return true;
}
CString standard_symbol_name;
assert(StringAIsPrefixOfStringB("pt_", s));
// PokerTracker symbols for the raise-chair
if (s.Right(10) == "_raischair") {
chair = p_symbol_engine_raisers->raischair();
}
// PokerTracker symbols for the opponent headsup chair
else if (s.Right(8) == "_headsup") {
chair = p_symbol_engine_chairs->opponent_headsup_chair();
}
// PokerTracker symbols for the smallblind chair
else if (s.Right(11) == "_smallblind") {
chair = p_symbol_engine_chairs->smallblind_chair();
}
// PokerTracker symbols for the bigblind chair
else if (s.Right(9) == "_bigblind") {
chair = p_symbol_engine_chairs->bigblind_chair();
}
// PokerTracker symbols for the cutoff chair
else if (s.Right(7) == "_cutoff") {
chair = p_symbol_engine_chairs->cutoff_chair();
}
// PokerTracker symbols for the firstcaller chair
else if (s.Right(12) == "_firstcaller") {
chair = p_symbol_engine_callers->firstcaller_chair();
}
// PokerTracker symbols for the lastcaller chair
else if (s.Right(11) == "_lastcaller") {
chair = p_symbol_engine_callers->lastcaller_chair();
}
// PokerTracker symbols for the firstraiser chair
else if (s.Right(12) == "_firstraiser") {
chair = p_symbol_engine_raisers->firstraiser_chair();
}
// PokerTracker symbols for the dealerchair chair
else if (s.Right(7) == "_dealer") {
chair = p_symbol_engine_dealerchair->dealerchair();
}
// PokerTracker symbols for the chair
//.........这里部分代码省略.........
示例8: write_log
void CTableLimits::CalcTableLimits()
{
// This is basically the old function CSymbols::CalcStakes()
// with some extension at the end to auto-lock the blinds,
// if the values are reasonable.
write_log(3, "CTableLimits::CalcTableLimits()\n");
if (!IsCalculationNeccessary())
{
return;
}
SetSmallBlind(0);
SetBigBlind(0);
SetBigBet(0);
SetAnte(0);
// Save the parts we scraped successfully
if (p_scraper->s_limit_info()->found_sblind)
SetSmallBlind(p_scraper->s_limit_info()->sblind); // sblind
if (p_scraper->s_limit_info()->found_bblind)
SetBigBlind(p_scraper->s_limit_info()->bblind); // bblind
if (p_scraper->s_limit_info()->found_ante)
SetAnte(p_scraper->s_limit_info()->ante); // ante
if (p_scraper->s_limit_info()->found_limit)
SetGametype(p_scraper->s_limit_info()->limit); // lim
if (p_scraper->s_limit_info()->found_bbet)
SetBigBet(p_scraper->s_limit_info()->bbet);
_istournament = p_scraper->s_limit_info()->istournament;
write_log(3, "CTableLimits: input from scraper: small blind: %f\n", tablelimit_unreliable_input.sblind);
write_log(3, "CTableLimits: input from scraper: big blind: %f\n", tablelimit_unreliable_input.bblind);
write_log(3, "CTableLimits: input from scraper: big bet: %f\n", tablelimit_unreliable_input.bbet);
write_log(3, "CTableLimits: input from scraper: gametype: %d\n", _gametype);
// Figure out bb/sb based on game type
if (gametype() == k_gametype_NL || gametype() == k_gametype_PL)
{
CalcTableLimits_NL_PL();
}
else if (gametype() == k_gametype_FL || gametype() == k_gametype_unknown)
{
CalcTableLimits_FL_AndUnknownGametype();
}
// if we still do not have blinds, then infer them from the posted bets
if (p_betround_calculator->betround() == k_betround_preflop && (tablelimit_unreliable_input.sblind==0 || tablelimit_unreliable_input.bblind==0))
{
SearchTableForSbAndBbValue();
}
write_log(3, "CTableLimits: calculated result: small blind: %f\n", tablelimit_unreliable_input.sblind);
write_log(3, "CTableLimits: calculated result: big blind: %f\n", tablelimit_unreliable_input.bblind);
write_log(3, "CTableLimits: calculated result: big bet: %f\n", tablelimit_unreliable_input.bbet);
AdjustForReasonableness();
write_log(3, "CTableLimits: adjusted result: small blind: %f\n", tablelimit_unreliable_input.sblind);
write_log(3, "CTableLimits: adjusted result: big blind: %f\n", tablelimit_unreliable_input.bblind);
write_log(3, "CTableLimits: adjusted result: big bet: %f\n", tablelimit_unreliable_input.bbet);
AcceptNewValuesIfGood();
AutoLockBlinds();
// Calc miminum betsizes for every streeet (after! we have potentially locked the blinds)
CalcBetsizesForEveryStreet();
}
示例9: sampler_getsample
uae_u8 sampler_getsample (int channel)
{
#if 0
int cur_pos;
static int cap_pos;
static float diffsample;
#endif
static double doffset_offset;
HRESULT hr;
DWORD t;
void *p1, *p2;
DWORD len1, len2;
evt cycles;
int sample, samplecnt;
double doffset;
int offset;
if (!currprefs.sampler_stereo)
channel = 0;
if (!inited) {
DWORD pos;
if (!capture_init ()) {
capture_free ();
return 0;
}
inited = 1;
oldcycles = get_cycles ();
oldoffset = -1;
doffset_offset = 0;
hr = lpDSB2r->GetCurrentPosition (&t, &pos);
if (FAILED (hr)) {
sampler_free ();
return 0;
}
if (t >= pos)
safediff = t - pos;
else
safediff = recordbufferframes * SAMPLESIZE - pos + t;
write_log (_T("SAMPLER: safediff %d %d\n"), safediff, safediff + sampleframes * SAMPLESIZE);
safediff += 4 * sampleframes * SAMPLESIZE;
#if 0
diffsample = 0;
safepos = -recordbufferframes / 10 * SAMPLESIZE;
hr = lpDSB2r->GetCurrentPosition (&t, &pos);
cap_pos = pos;
cap_pos += safepos;
if (cap_pos < 0)
cap_pos += recordbufferframes * SAMPLESIZE;
if (cap_pos >= recordbufferframes * SAMPLESIZE)
cap_pos -= recordbufferframes * SAMPLESIZE;
if (FAILED (hr)) {
sampler_free ();
return 0;
}
#endif
}
if (clockspersample < 1)
return 0;
uae_s16 *sbuf = (uae_s16*)samplebuffer;
vsynccnt = 0;
sample = 0;
samplecnt = 0;
cycles = (int)get_cycles () - (int)oldcycles;
doffset = doffset_offset + cycles / clockspersample;
offset = (int)doffset;
if (oldoffset < 0 || offset >= sampleframes || offset < 0) {
if (offset >= sampleframes) {
doffset -= offset;
doffset_offset = doffset;
}
if (oldoffset >= 0 && offset >= sampleframes) {
while (oldoffset < sampleframes) {
sample += sbuf[oldoffset * SAMPLESIZE / 2 + channel];
oldoffset++;
samplecnt++;
}
}
hr = lpDSB2r->GetCurrentPosition (&t, NULL);
int pos = t;
pos -= safediff;
if (pos < 0)
pos += recordbufferframes * SAMPLESIZE;
hr = lpDSB2r->Lock (pos, sampleframes * SAMPLESIZE, &p1, &len1, &p2, &len2, 0);
if (FAILED (hr)) {
write_log (_T("SAMPLER: Lock() failed %x\n"), hr);
return 0;
}
memcpy (samplebuffer, p1, len1);
if (p2)
memcpy (samplebuffer + len1, p2, len2);
lpDSB2r->Unlock (p1, len1, p2, len2);
#if 0
cap_pos = t;
cap_pos += sampleframes * SAMPLESIZE;
if (cap_pos < 0)
cap_pos += RECORDBUFFER * SAMPLESIZE;
//.........这里部分代码省略.........
示例10: GetDiskFreeSpaceEx
void CReplayFrame::CreateReplayFrame(void)
{
FILE *fp = NULL;
int i = 0;
time_t ltime = 0;
tm now_time = {0};
char now_time_str[100] = {0};
ULARGE_INTEGER free_bytes_for_user_on_disk = {0},
total_bytes_on_disk = {0},
free_bytes_total_on_disk = {0};
int e = SUCCESS;
// Sanity check: Enough disk-space for replay frame?
GetDiskFreeSpaceEx(
p_filenames->OpenHoldemDirectory(), // Directory on disk of interest
&free_bytes_for_user_on_disk,
&total_bytes_on_disk,
&free_bytes_total_on_disk);
if (free_bytes_for_user_on_disk.QuadPart < FREE_SPACE_NEEDED_FOR_REPLAYFRAME)
{
write_log(prefs.debug_replayframes(), "[CReplayFrame] Not enough disk-space\n");
OH_MessageBox_Error_Warning("Not enough disk space to create replay-frame.", "ERROR");
return;
}
// Get current time
time(<ime);
localtime_s(&now_time, <ime);
strftime(now_time_str, 100, "%Y-%m-%d %H:%M:%S", &now_time);
// Get exclusive access to CScraper and CSymbols variables
// (Wait for scrape/symbol cycle to finish before saving frame)
EnterCriticalSection(&p_heartbeat_thread->cs_update_in_progress);
CreateBitMapFile();
// Create HTML file
CString path = p_filenames->ReplayHTMLFilename(_next_replay_frame);
if (fopen_s(&fp, path.GetString(), "w")==0)
{
write_log(prefs.debug_replayframes(), "[CReplayFrame] Creating HTML file: $s\n", path);
// First line has to be the "title" of the table.
// This is no longer valid HTML, but the way Ray.E.Bornert did it
// for WinHoldem and WinScrape.
fprintf(fp, "%s\n", p_scraper->title());
// HTML header
fprintf(fp, "<html>\n");
fprintf(fp, " <head>\n");
fprintf(fp, " <title>%s</title>\n", p_scraper->title());
fprintf(fp, " </head>");
fprintf(fp, "<style>\n");
fprintf(fp, "td {text-align:right;}\n");
fprintf(fp, "</style>\n");
fprintf(fp, "<body>\n");
fprintf(fp, "<font face=courier>\n");
// Bitmap image
fprintf(fp, "<img src=\"frame%06d.bmp\">\n", _next_replay_frame);
fprintf(fp, "<br>\n");
// Table title
fprintf(fp, "[%s]", p_scraper->title());
fprintf(fp, "<br>\n");
// Session, frame number and time
fprintf(fp, " [Session %lu]", p_sessioncounter->session_id());
fprintf(fp, " [Frame: %06d]", _next_replay_frame);
fprintf(fp, " [%s]<br>\n", now_time_str);
fprintf(fp, "<br>\n");
// Links forwards and backwards to the next frames
fprintf(fp, "%s", LPCSTR(GetLinksToPrevAndNextFile()));
fprintf(fp, "<br>\n");
fprintf(fp, "<br>\n");
// Header of main table for smaller data tables
fprintf(fp, "<table>\n");
fprintf(fp, "<tr>\n");
fprintf(fp, "<td>\n");
// Data tables
fprintf(fp, "%s", LPCSTR(GetPlayerInfoAsHTML()));
fprintf(fp, "/<td>\n");
fprintf(fp, "<td>\n");
fprintf(fp, "%s", LPCSTR(GetButtonStatesAsHTML()));
fprintf(fp, "%s", LPCSTR(GetBlindInfoAsHTML()));
fprintf(fp, "%s", LPCSTR(GetCommonCardsAsHTML()));
fprintf(fp, "%s", LPCSTR(GetPotsAsHTML()));
fprintf(fp, "</td>\n");
// Footer of main table
fprintf(fp, "</tr>\n");
fprintf(fp, "</table>\n");
// End of HTML
fprintf(fp, "</body></html>\n");
fclose(fp);
}
//.........这里部分代码省略.........
示例11: th_uptime
/*
* Uptime thread...
*/
void *
th_uptime(void *arg)
{
int ret,n;
struct timeval timeout;
sigset_t mask;
write_log(0,"\n th_uptime thread = %d\n",(int)pthread_self());
sigfillset(&mask);
if (pthread_sigmask(SIG_BLOCK, &mask, NULL))
{
thread_error("th_uptime pthread_sigmask()",errno);
th_uptime_exit();
}
if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL))
{
thread_error("th_uptime pthread_setcancelstate()",errno);
th_uptime_exit();
}
pthread_cleanup_push( &th_uptime_clean, (void *)NULL );
if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL))
{
thread_error("th_uptime pthread_setcancelstate()",errno);
th_uptime_exit();
}
if (pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL))
{
n=errno;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
thread_error("th_uptime pthread_setcanceltype()",n);
th_uptime_exit();
}
while(1)
{
timeout.tv_sec = 1;
timeout.tv_usec = 0;
if ( (ret=select( 0, NULL, NULL, NULL, &timeout ) ) == -1 )
{
n=errno;
thread_error("th_uptime select()",n);
continue;
}
if ( !ret ) /* Timeout, update uptime... */
uptime++;
}
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
pthread_cleanup_pop(0);
return (NULL);
}
示例12: doloop
/*
* David, pon algo coherente!!!
*/
void
doloop(struct term_node *node, int mode)
{
struct term_tty *term_tty;
struct attack *theattack = NULL;
struct timeval timeout;
fd_set read_set;
int ret, fail;
struct termios old_term, term;
term_tty = node->specific;
theattack = protocols[mode].attacks;
if (term_tty->attack >= 0)
{
if (theattack[term_tty->attack].nparams)
{
printf("\n<*> Ouch!! At the moment the command line interface doesn't support attacks <*>\n");
printf("<*> that needs parameters and the one you've choosed needs %d <*>\n",
theattack[term_tty->attack].nparams);
}
else
{
printf("<*> Starting %s attack %s...\n",
(theattack[term_tty->attack].type)?"DOS":"NONDOS",
theattack[term_tty->attack].s);
if (attack_launch(node, mode, term_tty->attack, NULL, 0) < 0)
write_log(1, "Error launching attack %d (mode %d)!!\n",
term_tty->attack, mode);
fflush(stdin); fflush(stdout);
setvbuf(stdout, NULL, _IONBF, 0);
tcgetattr(0,&old_term);
tcgetattr(0,&term);
term.c_cc[VMIN] = 1;
term.c_cc[VTIME] = _POSIX_VDISABLE;
term.c_lflag &= ~ICANON;
term.c_lflag &= ~ECHO;
tcsetattr(0,TCSANOW,&term);
if (theattack[term_tty->attack].single == CONTINOUS) {
printf("<*> Press any key to stop the attack <*>\n");
fail = 0;
while(!fail && !node->thread.stop)
{
FD_ZERO(&read_set);
FD_SET(0, &read_set);
timeout.tv_sec = 0;
timeout.tv_usec = 200000;
if ( (ret=select(1, &read_set, NULL, NULL, &timeout) ) == -1 )
{
thread_error("network_peer_th select()",errno);
continue;
}
if ( !ret ) /* Timeout, decrement timers... */
continue;
else
{
if (FD_ISSET(0, &read_set))
{
getchar();
fail = 1;
}
}
}
} else
/* Command line, only one attack (0), let's wait for its conclusion... */
while (node->protocol[mode].attacks[0].up)
thread_usleep(150000);
tcsetattr(0,TCSANOW, &old_term);
}
} /* if term_tty->attack */
}
示例13: th_tty_peer
/*
* Thread for handling command line attacks (TERM_TTY)
* Use global variable struct term_tty *tty_tmp
*/
void *
th_tty_peer(void *args)
{
int fail;
time_t this_time;
struct cl_args *arguments;
struct term_tty *tty;
struct term_node *term_node=NULL;
sigset_t mask;
terms->work_state = RUNNING;
write_log(0, "\n th_tty_peer thread = %d...\n",(int)pthread_self());
sigfillset(&mask);
if (pthread_sigmask(SIG_BLOCK, &mask,NULL))
{
thread_error("th_tty_peer pthread_sigmask()",errno);
th_tty_peer_exit(NULL);
}
if (pthread_mutex_lock(&terms->mutex) != 0)
{
thread_error("th_tty_peer pthread_mutex_lock",errno);
th_tty_peer_exit(NULL);
}
fail = term_add_node(&term_node, TERM_TTY, (int)NULL, pthread_self());
if (fail == -1)
{
if (pthread_mutex_unlock(&terms->mutex) != 0)
thread_error("th_tty_peer pthread_mutex_unlock",errno);
th_tty_peer_exit(term_node);
}
if (term_node == NULL)
{
write_log(1,"Ouch!! No more than %d %s accepted!!\n",
term_type[TERM_TTY].max, term_type[TERM_TTY].name);
if (pthread_mutex_unlock(&terms->mutex) != 0)
thread_error("th_tty_peer pthread_mutex_unlock",errno);
th_tty_peer_exit(term_node);
}
tty = term_node->specific;
memcpy(tty,tty_tmp,sizeof(struct term_tty));
this_time = time(NULL);
#ifdef HAVE_CTIME_R
#ifdef SOLARIS
ctime_r(&this_time,term_node->since, sizeof(term_node->since));
#else
ctime_r(&this_time,term_node->since);
#endif
#else
pthread_mutex_lock(&mutex_ctime);
strncpy(term_node->since, ctime(&this_time), sizeof(term_node->since));
pthread_mutex_unlock(&mutex_ctime);
#endif
/* Just to remove the cr+lf...*/
term_node->since[sizeof(term_node->since)-2] = 0;
/* This is a tty so, man... ;) */
strncpy(term_node->from_ip, "127.0.0.1", sizeof(term_node->from_ip));
/* Parse config file */
if (strlen(tty_tmp->config_file))
if (parser_read_config_file(tty_tmp, term_node) < 0)
{
write_log(0, "Error reading configuration file\n");
th_tty_peer_exit(term_node);
}
if (init_attribs(term_node) < 0)
{
if (pthread_mutex_unlock(&terms->mutex) != 0)
thread_error("th_tty_peer pthread_mutex_unlock",errno);
th_tty_peer_exit(term_node);
}
arguments = args;
/* In command line mode we initialize the values by default */
if (protocols[arguments->proto_index].init_attribs)
{
fail = (*protocols[arguments->proto_index].init_attribs)
(term_node);
} else
write_log(0, "Warning, proto %d has no init_attribs function!!\n", arguments->proto_index);
//.........这里部分代码省略.........
示例14: amiga_clipboard_proc_start
uae_u32 amiga_clipboard_proc_start (void)
{
write_log ("clipboard process init: %08x\n", clipboard_data);
signaling = 1;
return clipboard_data;
}
示例15: Process_Track
static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR *b2, USHORT cmd, USHORT opt, int32_t dmsflags, struct zfile **extra){
USHORT hcrc, dcrc, usum, number, pklen1, pklen2, unpklen, l;
UCHAR cmode, flags;
int32_t crcerr = 0;
l = (USHORT)zfile_fread(b1,1,THLEN,fi);
if (l != THLEN) {
if (l==0)
return DMS_FILE_END;
else
return ERR_SREAD;
}
/* "TR" identifies a Track Header */
if ((b1[0] != 'T')||(b1[1] != 'R')) return ERR_NOTTRACK;
/* Track Header CRC */
hcrc = (USHORT)((b1[THLEN-2] << 8) | b1[THLEN-1]);
if (dms_CreateCRC(b1,(ULONG)(THLEN-2)) != hcrc) return ERR_THCRC;
number = (USHORT)((b1[2] << 8) | b1[3]); /* Number of track */
pklen1 = (USHORT)((b1[6] << 8) | b1[7]); /* Length of packed track data as in archive */
pklen2 = (USHORT)((b1[8] << 8) | b1[9]); /* Length of data after first unpacking */
unpklen = (USHORT)((b1[10] << 8) | b1[11]); /* Length of data after subsequent rle unpacking */
flags = b1[12]; /* control flags */
cmode = b1[13]; /* compression mode used */
usum = (USHORT)((b1[14] << 8) | b1[15]); /* Track Data CheckSum AFTER unpacking */
dcrc = (USHORT)((b1[16] << 8) | b1[17]); /* Track Data CRC BEFORE unpacking */
if (dolog)
write_log ("DMS: track=%d\n", number);
if (dolog) {
if (number==80)
write_log (" FileID ");
else if (number==0xffff)
write_log (" Banner ");
else if ((number==0) && (unpklen==1024))
write_log (" FakeBB ");
else
write_log (" %2d ",(short)number);
write_log ("%5d %5d %s %04X %04X %04X %0d\n", pklen1, unpklen, modes[cmode], usum, hcrc, dcrc, flags);
}
if ((pklen1 > TRACK_BUFFER_LEN) || (pklen2 >TRACK_BUFFER_LEN) || (unpklen > TRACK_BUFFER_LEN)) return ERR_BIGTRACK;
if (zfile_fread(b1,1,(size_t)pklen1,fi) != pklen1) return ERR_SREAD;
if (dms_CreateCRC(b1,(ULONG)pklen1) != dcrc) {
log_error (number);
crcerr = 1;
}
/* track 80 is FILEID.DIZ, track 0xffff (-1) is Banner */
/* and track 0 with 1024 bytes only is a fake boot block with more advertising */
/* FILE_ID.DIZ is never encrypted */
//if (pwd && (number!=80)) dms_decrypt(b1,pklen1);
if ((cmd == CMD_UNPACK) && (number<80) && (unpklen>2048)) {
memset(b2, 0, unpklen);
if (!crcerr)
Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, dmsflags & DMSFLAG_ENCRYPTED);
if (number == 0 && zfile_ftell (fo) == 512 * 22) {
// did we have another cylinder 0 already?
uint8_t *p;
zfile_fseek (fo, 0, SEEK_SET);
p = xcalloc (uint8_t, 512 * 22);
zfile_fread (p, 512 * 22, 1, fo);
addextra("BigFakeBootBlock", extra, p, 512 * 22);
xfree (p);
}
zfile_fseek (fo, number * 512 * 22 * ((dmsflags & DMSFLAG_HD) ? 2 : 1), SEEK_SET);
if (zfile_fwrite(b2,1,(size_t)unpklen,fo) != unpklen)
return ERR_CANTWRITE;
} else if (number == 0 && unpklen == 1024) {
memset(b2, 0, unpklen);
if (!crcerr)
Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, dmsflags & DMSFLAG_ENCRYPTED);
addextra("FakeBootBlock", extra, b2, unpklen);
}
if (crcerr)
return NO_PROBLEM;
if (number == 0xffff && extra){
Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, dmsflags & DMSFLAG_ENCRYPTED);
addextra("Banner", extra, b2, unpklen);
printbandiz(b2,unpklen);
}
if (number == 80 && extra) {
Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, dmsflags & DMSFLAG_ENCRYPTED);
addextra("FILEID.DIZ", extra, b2, unpklen);
printbandiz(b2,unpklen);
}
//.........这里部分代码省略.........