Mercurial > hg > nnchat
comparison main.c @ 502:52da406caf54
Rename some variables to be a bit more sane.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 01 Jun 2012 17:45:38 +0300 |
parents | ca88945d8eda |
children | bac3f9af112c |
comparison
equal
deleted
inserted
replaced
501:ca88945d8eda | 502:52da406caf54 |
---|---|
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 insertMode = TRUE; | 1348 insertMode = TRUE; |
1349 time_t prevTime; | 1349 time_t prevKeepAlive; |
1350 char *tmpStr; | 1350 char *tmpStr; |
1351 nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE); | 1351 nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE); |
1352 nn_editbuf_t *histBuf[SET_MAX_HISTORY+2]; | 1352 nn_editbuf_t *histBuf[SET_MAX_HISTORY+2]; |
1353 int histPos = 0, histMax = 0, index; | 1353 int histPos = 0, histMax = 0, index; |
1354 | 1354 |
1573 | 1573 |
1574 // Initialize user commands | 1574 // Initialize user commands |
1575 nn_usercmd_init(); | 1575 nn_usercmd_init(); |
1576 | 1576 |
1577 // Initialize random numbers | 1577 // Initialize random numbers |
1578 prevTime = time(NULL); | 1578 prevKeepAlive = time(NULL); |
1579 srandom((int) prevTime); | 1579 srandom((int) prevKeepAlive); |
1580 | 1580 |
1581 if (cursesInit) | 1581 if (cursesInit) |
1582 { | 1582 { |
1583 // Initialize rest of interactive UI code | 1583 // Initialize rest of interactive UI code |
1584 nn_editbuf_clear(editBuf); | 1584 nn_editbuf_clear(editBuf); |
1783 isError = TRUE; | 1783 isError = TRUE; |
1784 } | 1784 } |
1785 else | 1785 else |
1786 { | 1786 { |
1787 // Update time value of last sent message for unidle timeouts | 1787 // Update time value of last sent message for unidle timeouts |
1788 prevTime = time(NULL); | 1788 prevKeepAlive = time(NULL); |
1789 } | 1789 } |
1790 | 1790 |
1791 updateMain = update = TRUE; | 1791 updateMain = update = TRUE; |
1792 } | 1792 } |
1793 break; | 1793 break; |
1952 } // cursesInit | 1952 } // cursesInit |
1953 | 1953 |
1954 if (++updateCount > 10) | 1954 if (++updateCount > 10) |
1955 { | 1955 { |
1956 time_t tmpTime = time(NULL); | 1956 time_t tmpTime = time(NULL); |
1957 if (tmpTime - prevTime > SET_KEEPALIVE) | 1957 if (tmpTime - prevKeepAlive > SET_KEEPALIVE) |
1958 { | 1958 { |
1959 size_t n = ((size_t) random()) % th_llist_length(setIdleMessages); | 1959 size_t n = ((size_t) random()) % th_llist_length(setIdleMessages); |
1960 qlist_t *node = th_llist_get_nth(setIdleMessages, n); | 1960 qlist_t *node = th_llist_get_nth(setIdleMessages, n); |
1961 nn_conn_send_msg(conn, optUserNameEnc, node->data); | 1961 nn_conn_send_msg(conn, optUserNameEnc, node->data); |
1962 prevTime = tmpTime; | 1962 prevKeepAlive = tmpTime; |
1963 } | 1963 } |
1964 | 1964 |
1965 if (!colorSet) | 1965 if (!colorSet) |
1966 { | 1966 { |
1967 colorSet = TRUE; | 1967 colorSet = TRUE; |