Mercurial > hg > th-libs
diff th_network.c @ 735:31bc1ed07cf5
Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 07 Dec 2022 12:14:39 +0200 |
parents | 29e44a58bc73 |
children |
line wrap: on
line diff
--- a/th_network.c Wed Dec 07 11:58:54 2022 +0200 +++ b/th_network.c Wed Dec 07 12:14:39 2022 +0200 @@ -10,7 +10,7 @@ #include <errno.h> -static BOOL th_network_inited = FALSE; +static bool th_network_inited = false; static th_llist_t *th_conn_list = NULL; @@ -114,14 +114,14 @@ } -BOOL th_base_conn_init(th_base_conn_t *base, ssize_t bufsize) +bool th_base_conn_init(th_base_conn_t *base, ssize_t bufsize) { // Allocate connection data buffer base->bufsize = (bufsize <= 0) ? TH_CONNBUF_SIZE : bufsize; if ((base->buf = th_malloc(base->bufsize)) == NULL) - return FALSE; + return false; - return TRUE; + return true; } @@ -150,17 +150,17 @@ } -static BOOL th_get_addr(struct in_addr *addr, struct hostent *hst) +static bool th_get_addr(struct in_addr *addr, struct hostent *hst) { if (hst != NULL) { *addr = *(struct in_addr *) (hst->h_addr_list[0]); - return TRUE; + return true; } else { addr->s_addr = 0; - return FALSE; + return false; } } @@ -321,9 +321,9 @@ goto out; } - th_growbuf_puts(&buf, conn->proxy.userid, TRUE); + th_growbuf_puts(&buf, conn->proxy.userid, true); if (conn->proxy.addr_type == TH_PROXY_ADDR_DOMAIN) - th_growbuf_puts(&buf, host, TRUE); + th_growbuf_puts(&buf, host, true); // Send request if ((err = th_conn_proxy_send(conn, &buf)) != THERR_OK) @@ -465,9 +465,9 @@ th_growbuf_put_u8(&buf, 0x01); th_growbuf_put_u8(&buf, strlen(conn->proxy.userid)); - th_growbuf_puts(&buf, conn->proxy.userid, FALSE); + th_growbuf_puts(&buf, conn->proxy.userid, false); th_growbuf_put_u8(&buf, strlen(conn->proxy.passwd)); - th_growbuf_puts(&buf, conn->proxy.passwd, FALSE); + th_growbuf_puts(&buf, conn->proxy.passwd, false); // Send request if ((err = th_conn_proxy_send(conn, &buf)) != THERR_OK) @@ -829,10 +829,10 @@ } -BOOL th_conn_check(th_conn_t *conn) +bool th_conn_check(th_conn_t *conn) { if (conn == NULL) - return FALSE; + return false; return conn->err == 0 && conn->status == TH_CONN_OPEN; } @@ -851,7 +851,7 @@ } #endif - th_network_inited = TRUE; + th_network_inited = true; th_conn_list = NULL; @@ -877,25 +877,25 @@ #endif } - th_network_inited = FALSE; + th_network_inited = false; } -BOOL th_conn_buf_check(th_conn_t *conn, size_t n) +bool th_conn_buf_check(th_conn_t *conn, size_t n) { return conn && (conn->base.ptr + n <= conn->base.in_ptr); } -BOOL th_conn_buf_skip(th_conn_t *conn, size_t n) +bool th_conn_buf_skip(th_conn_t *conn, size_t n) { if (th_conn_buf_check(conn, n)) { conn->base.ptr += n; - return TRUE; + return true; } else - return FALSE; + return false; }