Revision 1919 trunk/base/ngobject.c

ngobject.c (revision 1919)
22 22

                
23 23
#include 
24 24
#include 
25
#include 
26

                
25 27
#include "nntpgrab_utils.h"
26 28

                
27 29
#ifdef HAVE_SOUP
... ...
78 80
}
79 81
#endif
80 82

                
83
#ifdef _MSC_VER
84
static void AppInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved)
85
{
86
    fprintf(stderr, "Invalid parameter detected in function %s. File: %s Line: %d\n", function, file, line);
87
    fprintf(stderr, "Expression: %s\n", expression);
88

                
89
    /* Cause a Debug Breakpoint */
90
    DebugBreak();
91
}
92
#endif
93

                
81 94
void nntpgrab_utils_perform_base_initialization(void)
82 95
{
83 96
#if defined(WIN32) || defined(DARWIN)
84 97
    char *dirname;
85 98
    char *dirname2;
99
    WORD wVersionRequested;
100
    WSADATA wsaData;
101
    int ret;
102

                
103
#ifdef _MSC_VER
104
    _set_invalid_parameter_handler(AppInvalidParameterHandler);
105
#else
106
    /* exchndl.dll is part of Dr. MinGW. By loading this DLL, every time the
107
     * program crashes a .RPT file will be created containing the backtrace */
108
    LoadLibraryA("exchndl.dll");
86 109
#endif
87 110

                
111
    /* Initialise Winsock */
112
    wVersionRequested = MAKEWORD(2, 2);
113

                
114
    ret = WSAStartup(wVersionRequested, &wsaData);
115
    if (ret != 0) {
116
        /* Tell the user that we could not find a usable */
117
        /* WinSock DLL.                                  */
118
        g_error(_("Winsock could not be initialised"));
119
        return;
120
    }
121

                
122
    /* Confirm that the WinSock DLL supports 2.2.        */
123
    /* Note that if the DLL supports versions greater    */
124
    /* than 2.2 in addition to 2.2, it will still return */
125
    /* 2.2 in wVersion since that is the version we      */
126
    /* requested.                                        */
127

                
128
    if (LOBYTE( wsaData.wVersion ) != 2 ||
129
        HIBYTE( wsaData.wVersion ) != 2) {
130
        /* Tell the user that we could not find a usable */
131
        /* WinSock DLL.                                  */
132
        WSACleanup();
133

                
134
        g_error(_("Winsock 2.2 or higher is required for this program"));
135

                
136
        return;
137
    }
138
#endif
139

                
88 140
    if (!g_thread_supported ()) g_thread_init (NULL);
89 141
    g_type_init();
90 142

                

Also available in: Unified diff