Example #1
2
BOOL CIperfThread::InitInstance()
{
    // TODO:  スレッドごとの初期化をここで実行します。
    HANDLE hOldIn = GetStdHandle(STD_INPUT_HANDLE);
    HANDLE hOldOut = GetStdHandle(STD_OUTPUT_HANDLE);
    HANDLE hOldErr = GetStdHandle(STD_ERROR_HANDLE);

    STARTUPINFOA si;
    memset(&si,0,sizeof(STARTUPINFO));
    si.cb = sizeof(STARTUPINFO);
    si.dwFlags |= STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_HIDE;


    m_uniqid = mkhash(m_CmdLine, m_uniqid) ;
    m_uniqid += (WORD)m_nThreadID;
    m_uniqid += (WORD)m_nThreadID >> 4;

    FreeConsole();
    AllocConsole();

    CreateIperfPipe();

    if(CreateProcess(NULL, m_CmdLine, NULL, NULL, TRUE, 0,
        NULL, NULL, &si, &m_ProcessInfo) == FALSE ) {
        return FALSE;
    }

    EnumWindows(WindowHidden, (LPARAM)(PROCESS_INFORMATION *)&m_ProcessInfo);
    WaitForInputIdle(m_ProcessInfo.hProcess, INFINITE);
    SetStdHandle(STD_OUTPUT_HANDLE,hOldOut);
    SetStdHandle(STD_INPUT_HANDLE,hOldIn);
    SetStdHandle(STD_ERROR_HANDLE,hOldErr);
    EnumWindows(WindowHidden, (LPARAM)(PROCESS_INFORMATION *)&m_ProcessInfo);
    return TRUE;
}
Example #2
0
int lookup(location* robot, unsigned remainingDepth) {
    unsigned hash = 0;
    for (int i=0; i<4; i++) {
        hash = 37*hash+robot[i];
    }
    
    hash &= (1<<24)-1;
    if (!table[hash]) {
        table[hash] = mkhash(robot, remainingDepth);
        return 0;
    }

    hashEntry* entry = table[hash];
    while (1) {
        if (match(robot, entry->robots)) {
            if (remainingDepth<=entry->remainingDepth) {
                return 1;
            }

            entry->remainingDepth = remainingDepth;
            return 0;
        }

        if (!entry->next) {
            entry->next = mkhash(robot, remainingDepth);
            return 0;
        }

        entry = entry->next;
    }
}
Example #3
0
int main() {
    Hash htable;
    Avl key;

    assert(mkhash(&htable, 5) == 0);

    inserthash(&htable, &key);

    Avl *a = lookuphash(&htable, &key);

    printf("%p\n", a);
}
Example #4
0
static void print_prime(int idx, int val)
{
	if (idx < 10)
		print_str(" ");
	print_dec(idx);
	if (idx / 10 == 1)
		goto force_th;
	switch (idx % 10) {
		case 1: print_str("st"); break;
		case 2: print_str("nd"); break;
		case 3: print_str("rd"); break;
	force_th:
		default: print_str("th"); break;
	}
	print_str(" prime is ");
	print_dec(val);
	print_str(".\n");

	hash = mkhash(hash, idx);
	hash = mkhash(hash, val);
}
static int htdbm_make(htdbm_t *htdbm)
{
    char cpw[MAX_STRING_LEN];
    int ret;

    htdbm->ctx.out = cpw;
    htdbm->ctx.out_len = sizeof(cpw);
    ret = mkhash(&htdbm->ctx);
    if (ret != 0) {
        fprintf(stderr, "Error: %s\n", htdbm->ctx.errstr);
        return ret;
    }
    htdbm->ctx.passwd = apr_pstrdup(htdbm->ctx.pool, cpw);
    return 0;
}
Example #6
0
static int mkrecord(struct passwd_ctx *ctx, char *user)
{
    char hash_str[MAX_STRING_LEN];
    int ret;
    ctx->out = hash_str;
    ctx->out_len = sizeof(hash_str);

    ret = mkhash(ctx);
    if (ret)
        return ret;

    ctx->out = apr_pstrcat(ctx->pool, user, ":", hash_str, NL, NULL);
    if (strlen(ctx->out) >= MAX_STRING_LEN) {
        ctx->errstr = "resultant record too long";
        return ERR_OVERFLOW;
    }
    return 0;
}
Example #7
0
extern int
mk_hash_index(struct tuple4 addr)
{
  int hash=mkhash(addr.saddr, addr.source, addr.daddr, addr.dest);
  return hash % tcp_stream_table_size;
}