Standardize on a single definition of auth_alg bitfield values
[hostap-gosc2009.git] / wpa_supplicant / main_winmain.c
blob19d9950ab34ea4da15ce8dce51f1b26966e6c0b8
1 /*
2 * WPA Supplicant / WinMain() function for Windows-based applications
3 * Copyright (c) 2006, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #include "includes.h"
17 #include "common.h"
18 #include "wpa_supplicant_i.h"
20 #ifdef _WIN32_WCE
21 #define CMDLINE LPWSTR
22 #else /* _WIN32_WCE */
23 #define CMDLINE LPSTR
24 #endif /* _WIN32_WCE */
27 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
28 CMDLINE lpCmdLine, int nShowCmd)
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;
36 if (os_program_init())
37 return -1;
39 os_memset(&params, 0, sizeof(params));
40 params.wpa_debug_level = MSG_MSGDUMP;
41 params.wpa_debug_file_path = "\\Temp\\wpa_supplicant-log.txt";
42 params.wpa_debug_show_keys = 1;
44 iface = ifaces = os_zalloc(sizeof(struct wpa_interface));
45 if (ifaces == NULL)
46 return -1;
47 iface_count = 1;
49 iface->confname = "default";
50 iface->driver = "ndis";
51 iface->ifname = "";
53 exitcode = 0;
54 global = wpa_supplicant_init(&params);
55 if (global == NULL) {
56 printf("Failed to initialize wpa_supplicant\n");
57 exitcode = -1;
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;
70 if (wpa_supplicant_add_iface(global, &ifaces[i]) == NULL)
71 exitcode = -1;
74 if (exitcode == 0)
75 exitcode = wpa_supplicant_run(global);
77 wpa_supplicant_deinit(global);
79 os_free(ifaces);
81 os_program_deinit();
83 return exitcode;