comparison main.c @ 489:ba48840b8525

Move network initialization/shutdown flag checking to network module.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 27 May 2012 03:31:35 +0300
parents d48327519b17
children 56689f94e827
comparison
equal deleted inserted replaced
488:bbe05594f29d 489:ba48840b8525
1343 nn_conn_t *conn = NULL; 1343 nn_conn_t *conn = NULL;
1344 int updateCount = 0; 1344 int updateCount = 0;
1345 BOOL argsOK, isError = FALSE, 1345 BOOL argsOK, isError = FALSE,
1346 exitProg = FALSE, 1346 exitProg = FALSE,
1347 colorSet = FALSE, 1347 colorSet = FALSE,
1348 networkInit = FALSE,
1349 insertMode = TRUE, 1348 insertMode = TRUE,
1350 firstUpdate = TRUE; 1349 firstUpdate = TRUE;
1351 time_t prevTime; 1350 time_t prevTime;
1352 char *tmpStr; 1351 char *tmpStr;
1353 nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE); 1352 nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE);
1480 if (!nn_network_init()) 1479 if (!nn_network_init())
1481 { 1480 {
1482 THERR("Could not initialize network subsystem.\n"); 1481 THERR("Could not initialize network subsystem.\n");
1483 goto err_exit; 1482 goto err_exit;
1484 } 1483 }
1485 else
1486 networkInit = TRUE;
1487 1484
1488 // Initialize curses windowing 1485 // Initialize curses windowing
1489 if (!optDaemon && !nnwin_init(SET_DELAY)) 1486 if (!optDaemon && !nnwin_init(SET_DELAY))
1490 goto err_exit; 1487 goto err_exit;
1491 1488
2001 nn_editbuf_free(editBuf); 1998 nn_editbuf_free(editBuf);
2002 1999
2003 for (index = 0; index <= SET_MAX_HISTORY; index++) 2000 for (index = 0; index <= SET_MAX_HISTORY; index++)
2004 nn_editbuf_free(histBuf[index]); 2001 nn_editbuf_free(histBuf[index]);
2005 2002
2006 nnwin_shutdown();
2007
2008 #ifdef __WIN32 2003 #ifdef __WIN32
2009 if (errorMessages) 2004 if (errorMessages)
2010 { 2005 {
2011 char *tmp; 2006 char *tmp;
2012 wclear(editWin); 2007 wclear(editWin);
2013 tmp = nnwin_prompt_requester(editWin, "Press enter to quit.\n", FALSE); 2008 tmp = nnwin_prompt_requester(editWin, "Press enter to quit.\n", FALSE);
2014 th_free(tmp); 2009 th_free(tmp);
2015 } 2010 }
2016 #endif 2011 #endif
2017 2012
2013 nnwin_shutdown();
2018 2014
2019 #ifndef __WIN32 2015 #ifndef __WIN32
2020 if (errorMessages) 2016 if (errorMessages)
2021 THERR("%s", errorMessages); 2017 THERR("%s", errorMessages);
2022 #endif 2018 #endif
2023 2019
2024 th_free(optUserNameEnc); 2020 th_free(optUserNameEnc);
2025
2026 nn_conn_close(conn); 2021 nn_conn_close(conn);
2027 2022 nn_network_close();
2028 if (networkInit)
2029 nn_network_close();
2030 2023
2031 THMSG(1, "Connection terminated.\n"); 2024 THMSG(1, "Connection terminated.\n");
2032 2025
2033 logFileClose(); 2026 logFileClose();
2034 2027