コード例 #1
0
ファイル: Dictionary.cpp プロジェクト: ddaroo/tpgk2012
void CDictionary::validateWordlist()
{
	CHECK_TIME("Validating wordlist");
	for(int i = 0; i < (int)words.size() - 1; i++)
		if(!(words[i] < words[i+1]))
			LOGFL("Problem - word %d \"%s\" should be before word %d \"%s\"!", i % words[i] % (i+1) % words[i+1]);

	for(int i = 0; i < (int)words.size(); i++)
		if(!strlen(words[i].ptr))
			LOGFL("Problem - word %d is empty!", i);
}
コード例 #2
0
/** 
 * @brief try the best to read @a size bytes from the fd
 * 
 * @param fd 
 * @param data 
 * @param size 
 * 
 * @return 1. OK: val equals @a size 2. Riched the END: 0 <= val < @a size 3. -1 on Error
 */
int read_n_l (int fd, void *data, size_t size) {
    int done_size = 0;
    const int total_size = size;
    uint8_t *pbuf = (uint8_t*)(data);
    while (done_size != total_size) {
        int once = read(fd, pbuf, total_size-done_size);
        LOG_IF_RETURN_CODE(once == 0, done_size,
                           "peer closed the socket, finished reading %d bytes", done_size);
        LOG_IF_RETURN(once < 0, "ERR: while reading socket:%d perror:%s", fd, strerror(errno));
        done_size += once;
        pbuf += once;
    }
    LOGFL("read_n with %d:%d bytes ok", done_size, size);
    return done_size;
}
コード例 #3
0
ファイル: StopWatch.cpp プロジェクト: ddaroo/tpgk2012
TimeChecker::~TimeChecker()
{
	LOGFL("%s: %d ms", text % timer.getDiff());
}