oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004, Adam Dunkels. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above |
| 11 | * copyright notice, this list of conditions and the following |
| 12 | * disclaimer in the documentation and/or other materials provided |
| 13 | * with the distribution. |
| 14 | * 3. All advertising materials mentioning features or use of this |
| 15 | * software must display the following acknowledgement: |
| 16 | * This product includes software developed by Adam Dunkels. |
| 17 | * 4. The name of the author may not be used to endorse or promote |
| 18 | * products derived from this software without specific prior |
| 19 | * written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 22 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 27 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | * |
| 33 | * This file is part of the Contiki desktop environment |
| 34 | * |
oliverschmidt | 0dca928 | 2005-05-06 00:05:46 +0000 | [diff] [blame^] | 35 | * $Id: configedit.c,v 1.6 2005/05/06 00:05:46 oliverschmidt Exp $ |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 36 | * |
| 37 | */ |
| 38 | |
| 39 | |
| 40 | #include <string.h> |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 41 | |
| 42 | #include "uiplib.h" |
| 43 | #include "resolv.h" |
| 44 | #include "ctk.h" |
| 45 | |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 46 | #include "program-handler.h" |
| 47 | #include "packet-service.h" |
oliverschmidt | bc1dc14 | 2005-04-12 21:54:08 +0000 | [diff] [blame] | 48 | #include "kfs.h" |
oliverschmidt | 4c19ccb | 2005-03-20 00:23:28 +0000 | [diff] [blame] | 49 | #include "cfs.h" |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 50 | |
oliverschmidt | 0dca928 | 2005-05-06 00:05:46 +0000 | [diff] [blame^] | 51 | #include "ctk-textentry-checkbox.h" |
| 52 | |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 53 | #include "config.h" |
| 54 | |
| 55 | |
| 56 | static config_t config; |
| 57 | static struct ctk_window window; |
| 58 | |
| 59 | #ifdef __APPLE2ENH__ |
| 60 | |
| 61 | static struct ctk_label backgroundlabel = |
| 62 | {CTK_LABEL(0, 1, 10, 1, "Background")}; |
| 63 | static char bkgnd[2]; |
| 64 | static struct ctk_textentry backgroundtextentry = |
oliverschmidt | 0dca928 | 2005-05-06 00:05:46 +0000 | [diff] [blame^] | 65 | {CTK_TEXTENTRY_INPUT(11, 1, 1, 1, bkgnd, 1, ctk_textentry_checkbox_input)}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 66 | static struct ctk_label backgrounddescr = |
| 67 | {CTK_LABEL(16, 1, 12, 1, "('x' or ' ')")}; |
| 68 | |
| 69 | #endif /* __APPLE2ENH__ */ |
| 70 | |
| 71 | static struct ctk_label slotlabel = |
| 72 | {CTK_LABEL(0, 3, 10, 1, "LAN slot")}; |
| 73 | static char slot[2]; |
| 74 | static struct ctk_textentry slottextentry = |
| 75 | {CTK_TEXTENTRY(11, 3, 1, 1, slot, 1)}; |
| 76 | static struct ctk_label slotdescr = |
| 77 | {CTK_LABEL(16, 3, 12, 1, "('1' to '7')")}; |
| 78 | |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 79 | static struct ctk_label driverlabel = |
| 80 | {CTK_LABEL(0, 5, 10, 1, "LAN driver")}; |
| 81 | static char driver[16]; |
| 82 | static struct ctk_textentry drivertextentry = |
| 83 | {CTK_TEXTENTRY(11, 5, 15, 1, driver, 15)}; |
| 84 | |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 85 | static struct ctk_label ipaddrlabel = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 86 | {CTK_LABEL(0, 7, 10, 1, "IP address")}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 87 | static char ipaddr[16]; |
| 88 | static struct ctk_textentry ipaddrtextentry = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 89 | {CTK_TEXTENTRY(11, 7, 15, 1, ipaddr, 15)}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 90 | |
| 91 | #ifdef WITH_ETHERNET |
| 92 | |
| 93 | static struct ctk_label netmasklabel = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 94 | {CTK_LABEL(0, 9, 10, 1, "Netmask")}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 95 | static char netmask[16]; |
| 96 | static struct ctk_textentry netmasktextentry = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 97 | {CTK_TEXTENTRY(11, 9, 15, 1, netmask, 15)}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 98 | |
| 99 | static struct ctk_label gatewaylabel = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 100 | {CTK_LABEL(0, 11, 10, 1, "Gateway")}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 101 | static char gateway[16]; |
| 102 | static struct ctk_textentry gatewaytextentry = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 103 | {CTK_TEXTENTRY(11, 11, 15, 1, gateway, 15)}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 104 | |
| 105 | static struct ctk_label dnsserverlabel = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 106 | {CTK_LABEL(0, 13, 10, 1, "DNS server")}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 107 | static char dnsserver[16]; |
| 108 | static struct ctk_textentry dnsservertextentry = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 109 | {CTK_TEXTENTRY(11, 13, 15, 1, dnsserver, 15)}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 110 | |
| 111 | #else /* WITH_ETHERNET */ |
| 112 | |
| 113 | static struct ctk_label dnsserverlabel = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 114 | {CTK_LABEL(0, 9, 10, 1, "DNS server")}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 115 | static char dnsserver[16]; |
| 116 | static struct ctk_textentry dnsservertextentry = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 117 | {CTK_TEXTENTRY(11, 9, 15, 1, dnsserver, 15)}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 118 | |
| 119 | #endif /* WITH_ETHERNET */ |
| 120 | |
| 121 | static struct ctk_button okbutton = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 122 | {CTK_BUTTON(0, 15, 12, "Save & close")}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 123 | static struct ctk_button cancelbutton = |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 124 | {CTK_BUTTON(21, 15, 6, "Cancel")}; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 125 | |
| 126 | EK_EVENTHANDLER(config_eventhandler, ev, data); |
| 127 | EK_PROCESS(p, "Configuration", EK_PRIO_NORMAL, |
| 128 | config_eventhandler, NULL, NULL); |
| 129 | static ek_id_t id = EK_ID_NONE; |
oliverschmidt | 3b308a6 | 2005-02-01 00:21:36 +0000 | [diff] [blame] | 130 | static ek_id_t driverid = EK_ID_NONE; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 131 | |
| 132 | /*-----------------------------------------------------------------------------------*/ |
| 133 | LOADER_INIT_FUNC(config_init, arg) |
| 134 | { |
| 135 | arg_free(arg); |
| 136 | |
| 137 | if(id == EK_ID_NONE) { |
| 138 | id = ek_start(&p); |
| 139 | } |
| 140 | } |
| 141 | /*-----------------------------------------------------------------------------------*/ |
| 142 | static char * |
| 143 | makebyte(u8_t byte, char *str) |
| 144 | { |
| 145 | if(byte >= 100) { |
| 146 | *str++ = (byte / 100 ) % 10 + '0'; |
| 147 | } |
| 148 | if(byte >= 10) { |
| 149 | *str++ = (byte / 10) % 10 + '0'; |
| 150 | } |
| 151 | *str++ = (byte % 10) + '0'; |
| 152 | |
| 153 | return str; |
| 154 | } |
| 155 | /*-----------------------------------------------------------------------------------*/ |
| 156 | static void |
| 157 | makeaddr(u16_t *addr, char *str) |
| 158 | { |
| 159 | str = makebyte(HTONS(addr[0]) >> 8, str); |
| 160 | *str++ = '.'; |
| 161 | str = makebyte(HTONS(addr[0]) & 0xff, str); |
| 162 | *str++ = '.'; |
| 163 | str = makebyte(HTONS(addr[1]) >> 8, str); |
| 164 | *str++ = '.'; |
| 165 | str = makebyte(HTONS(addr[1]) & 0xff, str); |
| 166 | *str++ = 0; |
| 167 | } |
| 168 | /*-----------------------------------------------------------------------------------*/ |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 169 | static int |
| 170 | makedriver(const char *name, char *str) |
| 171 | { |
| 172 | char *pattern = PACKET_SERVICE_NAME ": "; |
| 173 | |
| 174 | while(*pattern) { |
| 175 | if(*name++ != *pattern++) { |
| 176 | return 0; |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | while(*name) { |
| 181 | *str++ = *name++; |
| 182 | } |
| 183 | strcpy(str, ".drv"); |
| 184 | |
| 185 | return 1; |
| 186 | } |
| 187 | /*-----------------------------------------------------------------------------------*/ |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 188 | static void |
| 189 | makestrings(void) |
| 190 | { |
| 191 | u16_t addr[2], *addrptr; |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 192 | struct ek_proc *p; |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 193 | |
| 194 | #ifdef __APPLE2ENH__ |
| 195 | |
| 196 | if(ctk_draw_getbackground()) { |
| 197 | *bkgnd = 'x'; |
| 198 | } |
| 199 | |
| 200 | #endif /* __APPLE2ENH__ */ |
| 201 | |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 202 | *slot = config_getlanslot() + '0'; |
| 203 | |
| 204 | for(p = EK_PROCS(); p != NULL; p = p->next) { |
| 205 | if(makedriver(p->name, driver)) { |
oliverschmidt | 3b308a6 | 2005-02-01 00:21:36 +0000 | [diff] [blame] | 206 | driverid = p->id; |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 207 | break; |
| 208 | } |
| 209 | } |
| 210 | |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 211 | #ifdef WITH_UIP |
| 212 | |
| 213 | uip_gethostaddr(addr); |
| 214 | makeaddr(addr, ipaddr); |
| 215 | |
| 216 | #ifdef WITH_ETHERNET |
| 217 | |
| 218 | uip_getnetmask(addr); |
| 219 | makeaddr(addr, netmask); |
| 220 | |
| 221 | uip_getdraddr(addr); |
| 222 | makeaddr(addr, gateway); |
| 223 | |
| 224 | #endif /* WITH_ETHERNET */ |
| 225 | |
| 226 | addrptr = resolv_getserver(); |
| 227 | if(addrptr != NULL) { |
| 228 | makeaddr(addrptr, dnsserver); |
| 229 | } |
| 230 | |
| 231 | #endif /* WITH_UIP */ |
| 232 | |
| 233 | } |
| 234 | /*-----------------------------------------------------------------------------------*/ |
| 235 | static void |
| 236 | nullterminate(char *cptr) |
| 237 | { |
| 238 | /* Find the first space character in the ipaddr and put a zero there |
| 239 | to end the string. */ |
| 240 | for(; *cptr != ' ' && *cptr != 0; ++cptr); |
| 241 | *cptr = 0; |
| 242 | } |
| 243 | /*-----------------------------------------------------------------------------------*/ |
| 244 | static void |
| 245 | makeconfig(void) |
| 246 | { |
| 247 | u16_t addr[2]; |
| 248 | |
| 249 | #ifdef __APPLE2ENH__ |
| 250 | |
oliverschmidt | 0dca928 | 2005-05-06 00:05:46 +0000 | [diff] [blame^] | 251 | config.bkgnd = (*bkgnd == 'x'); |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 252 | |
| 253 | #endif /* __APPLE2ENH__ */ |
| 254 | |
| 255 | if(*slot >= '1' && *slot <= '7') { |
| 256 | config.slot = *slot - '0'; |
| 257 | } |
| 258 | |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 259 | nullterminate(driver); |
| 260 | strcpy(config.driver, driver); |
| 261 | |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 262 | #ifdef WITH_UIP |
| 263 | |
| 264 | nullterminate(ipaddr); |
| 265 | if(uiplib_ipaddrconv(ipaddr, (unsigned char *)addr)) { |
| 266 | config.ipaddr[0] = addr[0]; |
| 267 | config.ipaddr[1] = addr[1]; |
| 268 | } |
| 269 | |
| 270 | #ifdef WITH_ETHERNET |
| 271 | |
| 272 | nullterminate(netmask); |
| 273 | if(uiplib_ipaddrconv(netmask, (unsigned char *)addr)) { |
| 274 | config.netmask[0] = addr[0]; |
| 275 | config.netmask[1] = addr[1]; |
| 276 | } |
| 277 | |
| 278 | nullterminate(gateway); |
| 279 | if(uiplib_ipaddrconv(gateway, (unsigned char *)addr)) { |
| 280 | config.gateway[0] = addr[0]; |
| 281 | config.gateway[1] = addr[1]; |
| 282 | } |
| 283 | |
| 284 | #endif /* WITH_ETHERNET */ |
| 285 | |
| 286 | nullterminate(dnsserver); |
| 287 | if(uiplib_ipaddrconv(dnsserver, (unsigned char *)addr)) { |
| 288 | config.dnsserver[0] = addr[0]; |
| 289 | config.dnsserver[1] = addr[1]; |
| 290 | } |
| 291 | |
| 292 | #endif /* WITH_UIP */ |
| 293 | } |
| 294 | /*-----------------------------------------------------------------------------------*/ |
| 295 | static void |
| 296 | config_apply(void) |
| 297 | { |
| 298 | #ifdef __APPLE2ENH__ |
| 299 | |
| 300 | ctk_draw_setbackground(config.bkgnd); |
| 301 | |
| 302 | #endif /* __APPLE2ENH__ */ |
| 303 | |
oliverschmidt | 3b308a6 | 2005-02-01 00:21:36 +0000 | [diff] [blame] | 304 | if(driverid != EK_ID_NONE) { |
| 305 | ek_post(driverid, EK_EVENT_REQUEST_EXIT, NULL); |
| 306 | } |
| 307 | |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 308 | config_setlanslot(config.slot); |
| 309 | |
| 310 | if(*config.driver) { |
| 311 | program_handler_load(config.driver, NULL); |
| 312 | } |
| 313 | |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 314 | #ifdef WITH_UIP |
| 315 | |
| 316 | uip_sethostaddr(config.ipaddr); |
| 317 | |
| 318 | #ifdef WITH_ETHERNET |
| 319 | |
| 320 | uip_setnetmask(config.netmask); |
| 321 | uip_setdraddr(config.gateway); |
| 322 | |
| 323 | #endif /* WITH_ETHERNET */ |
| 324 | |
| 325 | resolv_conf(config.dnsserver); |
| 326 | |
| 327 | #endif /* WITH_UIP */ |
| 328 | } |
| 329 | /*-----------------------------------------------------------------------------------*/ |
| 330 | static void |
| 331 | config_save(void) |
| 332 | { |
| 333 | int fd; |
| 334 | |
oliverschmidt | bc1dc14 | 2005-04-12 21:54:08 +0000 | [diff] [blame] | 335 | fd = cfs_open(strcat(kfs_getdir(), "contiki.cfg"), CFS_WRITE); |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 336 | if(fd == -1) { |
| 337 | return; |
| 338 | } |
oliverschmidt | 4c19ccb | 2005-03-20 00:23:28 +0000 | [diff] [blame] | 339 | cfs_write(fd, &config, sizeof(config)); |
| 340 | cfs_close(fd); |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 341 | } |
| 342 | /*-----------------------------------------------------------------------------------*/ |
| 343 | EK_EVENTHANDLER(config_eventhandler, ev, data) |
| 344 | { |
| 345 | EK_EVENTHANDLER_ARGS(ev, data); |
| 346 | |
| 347 | if(ev == EK_EVENT_INIT) { |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 348 | ctk_window_new(&window, 29, 16, "Config editor"); |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 349 | #ifdef __APPLE2ENH__ |
| 350 | CTK_WIDGET_ADD(&window, &backgroundlabel); |
| 351 | CTK_WIDGET_ADD(&window, &backgroundtextentry); |
| 352 | CTK_WIDGET_ADD(&window, &backgrounddescr); |
| 353 | #endif /* __APPLE2ENH__ */ |
| 354 | CTK_WIDGET_ADD(&window, &slotlabel); |
| 355 | CTK_WIDGET_ADD(&window, &slottextentry); |
| 356 | CTK_WIDGET_ADD(&window, &slotdescr); |
oliverschmidt | 2fa3323 | 2005-01-26 21:33:29 +0000 | [diff] [blame] | 357 | CTK_WIDGET_ADD(&window, &driverlabel); |
| 358 | CTK_WIDGET_ADD(&window, &drivertextentry); |
| 359 | CTK_WIDGET_ADD(&window, &ipaddrlabel); |
oliverschmidt | 76872e8 | 2004-12-26 14:13:34 +0000 | [diff] [blame] | 360 | CTK_WIDGET_ADD(&window, &ipaddrtextentry); |
| 361 | #ifdef WITH_ETHERNET |
| 362 | CTK_WIDGET_ADD(&window, &netmasklabel); |
| 363 | CTK_WIDGET_ADD(&window, &netmasktextentry); |
| 364 | CTK_WIDGET_ADD(&window, &gatewaylabel); |
| 365 | CTK_WIDGET_ADD(&window, &gatewaytextentry); |
| 366 | #endif /* WITH_ETHERNET */ |
| 367 | CTK_WIDGET_ADD(&window, &dnsserverlabel); |
| 368 | CTK_WIDGET_ADD(&window, &dnsservertextentry); |
| 369 | CTK_WIDGET_ADD(&window, &okbutton); |
| 370 | CTK_WIDGET_ADD(&window, &cancelbutton); |
| 371 | #ifdef __APPLE2ENH__ |
| 372 | CTK_WIDGET_FOCUS(&window, &backgroundtextentry); |
| 373 | #else /* __APPLE2ENH__ */ |
| 374 | CTK_WIDGET_FOCUS(&window, &slottextentry); |
| 375 | #endif /* __APPLE2ENH__ */ |
| 376 | |
| 377 | /* Fill the configuration strings with values from the current |
| 378 | configuration */ |
| 379 | makestrings(); |
| 380 | ctk_window_open(&window); |
| 381 | } else if(ev == ctk_signal_button_activate) { |
| 382 | if(data == (ek_data_t)&okbutton) { |
| 383 | |
| 384 | /* Fill the configuration with values from the current |
| 385 | configuration strings */ |
| 386 | makeconfig(); |
| 387 | config_apply(); |
| 388 | config_save(); |
| 389 | goto quit; |
| 390 | } else if(data == (ek_data_t)&cancelbutton) { |
| 391 | goto quit; |
| 392 | } |
| 393 | |
| 394 | } else if(ev == ctk_signal_window_close || |
| 395 | ev == EK_EVENT_REQUEST_EXIT) { |
| 396 | goto quit; |
| 397 | } |
| 398 | return; |
| 399 | |
| 400 | quit: |
| 401 | ctk_window_close(&window); |
| 402 | ek_exit(); |
| 403 | id = EK_ID_NONE; |
| 404 | LOADER_UNLOAD(); |
| 405 | } |
| 406 | /*-----------------------------------------------------------------------------------*/ |