1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 02:55:12 +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,17 +1020,26 @@ 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) {
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)) == 0) {
fd_set readfds;
struct timeval tv;
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;
@ -1040,15 +1049,6 @@ static void generate_text_internal(char *p, int p_max_size,
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{
NORM_ERR("read_tcp: Problem with resolving the hostname");
}
}
#ifndef __OpenBSD__
OBJ(acpitemp) {