2 * WPA Supplicant / main() function for Amiga-like OSes
3 * Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2010-2015, Neil Cafferkey
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Alternatively, this software may be distributed under the terms of BSD
13 * See README and COPYING for more details.
19 #include "wpa_supplicant_i.h"
21 #include <exec/types.h>
24 #include <proto/dos.h>
27 #include <proto/exec.h>
28 int start_gui(struct wpa_global
*global
);
32 struct Process
*gui_proc
;
33 extern struct wpa_global
*gui_global
;
34 extern struct Task
*main_task
;
47 static const TEXT
template[] = "DEVICE/A,UNIT/K/N,CONFIG/K,VERBOSE/S,NOGUI/S";
48 const TEXT version_string
[] = "$VER: WirelessManager 1.6 (8.3.2015)";
49 static const TEXT config_file_name
[] = "ENV:Sys/Wireless.prefs";
52 int main(int argc
, char *argv
[])
54 struct RDArgs
*read_args
;
55 LONG error
= 0, unit_no
= 0;
64 args
= {NULL
, &unit_no
, config_file_name
, FALSE
, FALSE
};
66 struct wpa_interface
*ifaces
, *iface
;
67 int iface_count
, exitcode
= RETURN_FAIL
;
68 struct wpa_params params
;
69 struct wpa_global
*global
;
72 if (os_program_init())
75 os_memset(¶ms
, 0, sizeof(params
));
76 params
.wpa_debug_level
= MSG_INFO
;
78 iface
= ifaces
= os_zalloc(sizeof(struct wpa_interface
));
84 read_args
= ReadArgs(template, (PINT
*)&args
, NULL
);
85 if (read_args
== NULL
)
91 iface
->ifname
= ifname
= os_malloc(strlen((const char *)args
.device
)
95 error
= ERROR_NO_FREE_STORE
;
99 sprintf(ifname
, "%s:%ld", args
.device
, (long int)*args
.unit
);
101 iface
->confname
= (char *) args
.config
;
104 params
.wpa_debug_level
-= 2;
107 global
= wpa_supplicant_init(¶ms
);
108 if (global
== NULL
) {
109 wpa_printf(MSG_ERROR
, "Failed to initialize WirelessManager");
110 exitcode
= RETURN_FAIL
;
114 for (i
= 0; exitcode
== 0 && i
< iface_count
; i
++) {
115 if ((ifaces
[i
].confname
== NULL
&&
116 ifaces
[i
].ctrl_interface
== NULL
) ||
117 ifaces
[i
].ifname
== NULL
) {
118 if (iface_count
== 1 && (params
.ctrl_interface
||
119 params
.dbus_ctrl_interface
))
121 error
= ERROR_REQUIRED_ARG_MISSING
;
122 exitcode
= RETURN_FAIL
;
125 if (wpa_supplicant_add_iface(global
, &ifaces
[i
]) == NULL
)
126 exitcode
= RETURN_FAIL
;
130 if (exitcode
== 0 && !args
.no_gui
)
131 exitcode
= start_gui(global
);
135 exitcode
= wpa_supplicant_run(global
);
137 wpa_supplicant_deinit(global
);
142 // os_program_deinit();
149 /* Print error message */
151 PrintFault(error
, NULL
);
154 exitcode
= RETURN_FAIL
;
160 int start_gui(struct wpa_global
*global
)
163 main_task
= FindTask(NULL
);
164 gui_proc
= CreateNewProcTags(NP_Entry
, MUIGUI
,
165 NP_Name
, "WirelessManager GUI", TAG_END
);
172 if (gui_proc
!= NULL
)
174 Signal((struct Task
*) gui_proc
, SIGBREAKF_CTRL_C
);