Dnia 2011-10-18, wto o godzinie 21:02 +0200, Bartosz Brachaczek pisze:
> Różnice między oryginalnym libgadu a naszym forkiem są dość spore i w
> wielu miejscach nadmiarowe, ale kompiluje się on i działa nawet pod
> MSVC.

Bardzo spore. Na początek pozamieniałem socketowe write() i read() na
send() i recv(). Chętnie bym pozbył się problemu z socketowym errno
jakąś magia makr. Na przykład do pliku nagłówkowego dać:

    #ifdef WIN32
    #define recv gg_win32_recv
    #define send gg_win32_send
    #endif

A do pliku źródłowego:

    #undef recv
    #undef send

    int map_wsa_error_to_errno(void)
    {
        switch (WSAGetLastError()) {
            case WSAEINPROGRESS: return EINPROGRESS;
            case WSAENOTCONN: return ENOTCONN;
            case WSAEINTR: return EINTR;
            case WSAECONNRESET: return ECONNRESET;
            case WSAETIMEDOUT: return ETIMEDOUT;
        }

        return EINVAL;
    }

    ssize_t gg_win32_recv(int sockfd, void *buf, size_t len, int flags)
    {
        ssize_t res;

        res = recv(sockfd, buf, len, flags);

        if (res == -1)
            errno = map_wsa_error_to_errno();

        return res;
    }

    ssize_t send(int sockfd, const void *buf, size_t len, int flags)
    {
        ssize_t res;

        res = send(sockfd, buf, len, flags);

        if (res == -1)
            errno = map_wsa_error_to_errno();

        return res;
    }

Plus/minus to, co się dzieje w gg_socket_busy(). Dzięki temu większość
zmian z patcha by zniknęło. Co o tym sądzisz?

Pozdr,
Wojtek

_______________________________________________
libgadu-devel mailing list
libgadu-devel@lists.ziew.org
http://lists.ziew.org/mailman/listinfo/libgadu-devel

Reply via email to