1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

read_tcp: get rid of heavy indenting

This commit is contained in:
Phil Sutter 2009-09-10 23:10:07 +02:00
parent 9f22bab657
commit 925ac2b7ba

View File

@ -1020,35 +1020,35 @@ static void generate_text_internal(char *p, int p_max_size,
OBJ(read_tcp) {
int sock, received;
struct sockaddr_in addr;
struct hostent* he = gethostbyname(obj->data.read_tcp.host);
if(he != NULL) {
sock = socket(he->h_addrtype, SOCK_STREAM, 0);
if(sock != -1) {
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = obj->data.read_tcp.port;
memcpy(&addr.sin_addr, he->h_addr, he->h_length);
if (connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr)) == 0) {
fd_set readfds;
struct timeval tv;
FD_ZERO(&readfds);
FD_SET(sock, &readfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
if(select(sock + 1, &readfds, NULL, NULL, &tv) > 0){
received = recv(sock, p, p_max_size, 0);
p[received] = 0;
}
close(sock);
} else {
NORM_ERR("read_tcp: Couldn't create a connection");
}
}else{
NORM_ERR("read_tcp: Couldn't create a socket");
}
}else{
struct hostent* he;
fd_set readfds;
struct timeval tv;
if (!(he = gethostbyname(obj->data.read_tcp.host))) {
NORM_ERR("read_tcp: Problem with resolving the hostname");
break;
}
if ((sock = socket(he->h_addrtype, SOCK_STREAM, 0)) == -1) {
NORM_ERR("read_tcp: Couldn't create a socket");
break;
}
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = obj->data.read_tcp.port;
memcpy(&addr.sin_addr, he->h_addr, he->h_length);
if (!connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr))) {
NORM_ERR("read_tcp: Couldn't create a connection");
break;
}
FD_ZERO(&readfds);
FD_SET(sock, &readfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
if(select(sock + 1, &readfds, NULL, NULL, &tv) > 0){
received = recv(sock, p, p_max_size, 0);
p[received] = 0;
}
close(sock);
}
#ifndef __OpenBSD__
OBJ(acpitemp) {