~ubuntu-branches/ubuntu/gutsy/wpasupplicant/gutsy

« back to all changes in this revision

Viewing changes to wpa_supplicant/main_winmain.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler, Alexander Sack
  • Date: 2007-08-26 16:06:57 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070826160657-2m8pxoweuxe8f93t
Tags: 0.6.0+0.5.8-0ubuntu1
* New upstream release
* remove patch 11_erroneous_manpage_ref, applied upstream
* remove patch 25_wpas_dbus_unregister_iface_fix, applied upstream

[ Alexander Sack ]
* bumping upstream version to replace development version 0.6.0 with
  this package from stable release branch.
* attempt to fix wierd timeout and high latency issues by going
  back to stable upstream version (0.5.9) (LP: #140763,
  LP: #141233).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * WPA Supplicant / WinMain() function for Windows-based applications
3
 
 * Copyright (c) 2006, Jouni Malinen <j@w1.fi>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License version 2 as
7
 
 * published by the Free Software Foundation.
8
 
 *
9
 
 * Alternatively, this software may be distributed under the terms of BSD
10
 
 * license.
11
 
 *
12
 
 * See README and COPYING for more details.
13
 
 */
14
 
 
15
 
#include "includes.h"
16
 
 
17
 
#include "common.h"
18
 
#include "wpa_supplicant_i.h"
19
 
 
20
 
#ifdef _WIN32_WCE
21
 
#define CMDLINE LPWSTR
22
 
#else /* _WIN32_WCE */
23
 
#define CMDLINE LPSTR
24
 
#endif /* _WIN32_WCE */
25
 
 
26
 
 
27
 
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
28
 
                   CMDLINE lpCmdLine, int nShowCmd)
29
 
{
30
 
        int i;
31
 
        struct wpa_interface *ifaces, *iface;
32
 
        int iface_count, exitcode = -1;
33
 
        struct wpa_params params;
34
 
        struct wpa_global *global;
35
 
 
36
 
        if (os_program_init())
37
 
                return -1;
38
 
 
39
 
        os_memset(&params, 0, sizeof(params));
40
 
        params.wpa_debug_level = MSG_MSGDUMP;
41
 
        params.wpa_debug_use_file = 1;
42
 
        params.wpa_debug_show_keys = 1;
43
 
 
44
 
        iface = ifaces = os_zalloc(sizeof(struct wpa_interface));
45
 
        if (ifaces == NULL)
46
 
                return -1;
47
 
        iface_count = 1;
48
 
 
49
 
        iface->confname = "default";
50
 
        iface->driver = "ndis";
51
 
        iface->ifname = "";
52
 
 
53
 
        exitcode = 0;
54
 
        global = wpa_supplicant_init(&params);
55
 
        if (global == NULL) {
56
 
                printf("Failed to initialize wpa_supplicant\n");
57
 
                exitcode = -1;
58
 
        }
59
 
 
60
 
        for (i = 0; exitcode == 0 && i < iface_count; i++) {
61
 
                if ((ifaces[i].confname == NULL &&
62
 
                     ifaces[i].ctrl_interface == NULL) ||
63
 
                    ifaces[i].ifname == NULL) {
64
 
                        if (iface_count == 1 && (params.ctrl_interface ||
65
 
                                                 params.dbus_ctrl_interface))
66
 
                                break;
67
 
                        exitcode = -1;
68
 
                        break;
69
 
                }
70
 
                if (wpa_supplicant_add_iface(global, &ifaces[i]) == NULL)
71
 
                        exitcode = -1;
72
 
        }
73
 
 
74
 
        if (exitcode == 0)
75
 
                exitcode = wpa_supplicant_run(global);
76
 
 
77
 
        wpa_supplicant_deinit(global);
78
 
 
79
 
        os_free(ifaces);
80
 
 
81
 
        os_program_deinit();
82
 
 
83
 
        return exitcode;
84
 
}