void dumpChar( __bytefield__ *f, __WORD__ pos ) {
    __WORD__ addr = (__WORD__)f->field + pos;
    __ptd_hdr__ *phdr = (__ptd_hdr__*)addr;

    /* Address */
    dumpAddr(f, (__WORD__)phdr);

    /* Hex value */
    dumpValue(f, phdr->hdr);

    /* Desc */
    printf("char: ");
    int intval = (int)(phdr->hdr >> __CHAR_VAL_SHFT__);

    switch(intval) {
    case __CH_newline__:
        printf("newline");
        break;

    case __CH_space__:
        printf("space");
        break;

    default:
        putchar(intval);
        break;
    }

    printf("\n");

    /* State */
    dumpPtdState(f, pos + __WORDSIZE__);
}
void dumpStr( __bytefield__ *f, __WORD__ pos ) {
    __WORD__ addr = (__WORD__)f->field + pos;
    __ptd_hdr__ *phdr = (__ptd_hdr__*)addr;

    /* Address */
    dumpAddr(f, (__WORD__)phdr);

    /* Hex value */
    dumpValue(f, phdr->hdr);

    /* Desc */
    /* __WORD__ slen = (__WORD__)(phdr->hdr >> __STR_LEN_SHFT__); */
    __WORD__ slen = __unboxint(_A1_, __stringLength(_A1_, __boxptd(_A1_, addr)));
    printf("string length: ");
    dumpIntWord(f, slen);
    printf("\n");

    /* State */
    dumpPtdState(f, pos + __WORDSIZE__);

    /* String content */
    __WORD__ wholelines = ((slen + 1) / __WORDSIZE__);
    __WORD__ tailline = ((slen + 1) % __WORDSIZE__);
    if (tailline != 0)
        tailline = 1;
    for (__WORD__ i = 0; i < (wholelines + tailline); ++i) {
        dumpStrLine(f, phdr, i);
    }
}
void dumpPairState( __bytefield__ *f, __WORD__ pos ) {
    __WORD__ addr = (__WORD__)f->field + pos;

    dumpAddr(f, addr);
    dumpValue(f, *(__WORD__*)addr);
    printf("state: 0x");
    dumpWord(f, *(__WORD__*)addr);
    printf("\n");
}
void 
dumpHostAndAddr(char *header, struct sockaddr_in *addrPtr)
{
    size_t              addrLen;
    struct  hostent     *pHostEnt;

    addrLen = sizeof(*addrPtr);

    /* serach the host name using the ip addr */
    if ((pHostEnt = gethostbyaddr((void *)&addrPtr->sin_addr, addrLen, 
                                  AF_INET)) == NULL)
    {
        dumpAddr(header, "---", addrPtr);
    }
    else
    {
        dumpAddr(header, pHostEnt->h_name, addrPtr);
    }
}
Exemple #5
0
char *
dumpHost(const struct hostent FAR *hp, char *buff, size_t size) {
    char *p = buff;

    p[0] = '\0';
    if (strlen(hp->h_name) + 1 < size) {
        sprintf(p, "%s ", hp->h_name);
        p += strlen(p);
        size -= strlen(p);
    }
    dumpAddr(hp->h_addr_list[0], hp->h_length, p, size);
    return (buff);
}
void dumpInt( __bytefield__ *f, __WORD__ pos ) {
    /* Address */
    __WORD__ addr = ( __WORD__)f->field + pos;
    __BWORD__ val = *(__BWORD__*)addr;
    dumpAddr(f, addr);

    /* Hex value */
    dumpValue(f, val);

    /* Desc */
    printf("Boxed integer: ");
    dumpIntWord(f, __unboxint(_A1_, val));
    printf("\n");
}
void dumpStrLine( __bytefield__ *f, __ptd_hdr__ *phdr, __WORD__ i) {
    __WORD__ lineAddr = (__WORD__)((__WORD__*)((__WORD__)phdr + sizeof(__ptd_hdr__)) + i);

    /* Address */
    dumpAddr(f, lineAddr);

    /* Hex value */
    dumpValue(f, *(__WORD__*)lineAddr);

    /* Desc */
    for (__WORD__ k = 0; k < __WORDSIZE__; ++k)
        putchar((int)*((char*)lineAddr + k));
    printf("\n");
}
void dumpBoxed( __bytefield__ *f, __WORD__ pos ) {
    /* Address */
    __WORD__ addr = ( __WORD__)f->field + pos;
    __BWORD__ bval = *(__BWORD__*)addr;
    __WORD__ t = __boxtype(_A1_, bval);
    __WORD__ saddr = 0;
    __WORD__ subt;

    if (t == __INT_TYPE__)
        dumpInt(f, pos);
    else {
        dumpAddr(f, addr);

        /* Hex value */
        dumpValue(f, bval);

        /* Desc */
        printf ("Boxed ");
        switch (t) {
        case __PTD_TYPE__:
            saddr = __unboxptd(_A1_, bval);
            subt = __boxsubtype(_A1_, saddr);
            if (subt == __VEC_TYPE__)
                printf("vector at ");
            else if (subt == __STR_TYPE__)
                printf("string at ");
            else if (subt == __CHAR_TYPE__)
                printf("char at ");
            break;

        case __PAIR_TYPE__:
            saddr = __unboxpair(_A1_, bval);
            printf("pair at ");
            break;

        case __LAMBDA_TYPE__:
            saddr = __unboxlambda(_A1_, bval);
            printf("lambda at ");
            break;

        default:
            printf("unknown type");
            break;
        }

        dumpWord(f, saddr);
        printf("\n");
    }
}
void dumpVecIndex( __bytefield__ *f, __ptd_hdr__ *phdr, __WORD__ i ) {
    __WORD__ cellAddr = (__WORD__)((__WORD__*)((__WORD__)phdr + sizeof(__ptd_hdr__)) + i);

    /* Address */
    dumpAddr(f, cellAddr);

    /* Hex value */
    dumpValue(f, *(__WORD__*)cellAddr);

    /* Desc */
    printf("v[");
    dumpIntWord(f, i);
    printf("]: ");
    dumpWord(f, *(__WORD__*)cellAddr);
    printf("\n");
}
Exemple #10
0
WRAPPER_EXPORT HANDLE PASCAL FAR
WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char FAR * addr,
		      int len, int type, char FAR * buf, int buflen)
{
	HANDLE  ret;
	char    abuff[256];
	idn_resconf_t	encodeCtx;
    
	encodeCtx = idnGetContext();

	if (encodeCtx != NULL) {
		idnHook(hWnd, wMsg, buf, encodeCtx);
	}

	TRACE("ENTER WSAAsyncGetHostByAddr <%s>\n",
	      dumpAddr(addr, len, abuff, sizeof(abuff)));
	ret = _org_WSAAsyncGetHostByAddr(hWnd, wMsg, addr, len, type,
					 buf, buflen);
	TRACE("LEAVE WSAAsyncGetHostByAddr HANDLE %08x\n", ret);

	return (ret);
}
Exemple #11
0
WRAPPER_EXPORT struct hostent FAR * PASCAL FAR
gethostbyaddr(const char FAR * addr, int len, int type) {
	struct hostent FAR *ret;
	char    nbuff[256];
	char    abuff[256];
	char    hbuff[256];
	BOOL    stat;
	idn_resconf_t	encodeCtx;
    
	TRACE("ENTER gethostbyaddr <%s>\n",
	      dumpAddr(addr, len, abuff, sizeof(abuff)));

	encodeCtx = idnGetContext();

	ret = _org_gethostbyaddr(addr, len, type);

	if (ret != NULL && encodeCtx != NULL) {
		TRACE("Resulting Name <%s>\n",
		      dumpName(ret->h_name, hbuff, sizeof(hbuff)));
		stat = idnConvRsp(encodeCtx, ret->h_name,
				  nbuff, sizeof(nbuff));
		if (stat == FALSE) {
			TRACE("Decoding failed - return the name verbatim\n");
		} else {
			TRACE("Converted Back <%s>\n",
			      dumpName(nbuff, hbuff, sizeof(hbuff)));
			strcpy(ret->h_name, nbuff);
		}
	}

	if (ret == NULL) {
		TRACE("LEAVE gethostbyaddr NULL\n") ;
	} else {
		TRACE("LEAVE gethostbyaddr <%s>\n",
		      dumpHost(ret, hbuff, sizeof(hbuff)));
	}    
	return (ret);
}
void dumpVec( __bytefield__ *f, __WORD__ pos ) {
    __WORD__ addr = (__WORD__)f->field + pos;
    __ptd_hdr__ *phdr = (__ptd_hdr__*)addr;

    /* Address */
    dumpAddr(f, (__WORD__)phdr);

    /* Hex value */
    dumpValue(f, phdr->hdr);

    /* Desc */
    __WORD__ vlen = (__WORD__)(phdr->hdr >> __VEC_LEN_SHFT__);
    printf("vector size: ");
    dumpIntWord(f, vlen);
    printf("\n");

    /* State */
    dumpPtdState(f, pos + __WORDSIZE__);

    /* Vector content */
    for (__WORD__ i = 0; i < vlen; ++i) {
        dumpVecIndex(f, phdr, i);
    }
}