New indent parameters, many spurious changes

MAINT_6_0
Stephane Bortzmeyer 18 years ago
parent 3754822e91
commit b60d7eb6d2

@ -41,12 +41,9 @@ init (int argc, char **argv)
""},
POPT_AUTOHELP POPT_TABLEEND
};
poptcon = poptGetContext (NULL, argc,
argv, options, POPT_CONTEXT_KEEP_FIRST);
while ((value = poptGetNextOpt (poptcon)) > 0)
{
if (value < -1)
{
poptcon = poptGetContext(NULL, argc, argv, options, POPT_CONTEXT_KEEP_FIRST);
while ((value = poptGetNextOpt(poptcon)) > 0) {
if (value < -1) {
sprintf(msg, "%s: %s",
poptBadOption(poptcon, POPT_BADOPTION_NOALIAS),
poptStrerror(value));
@ -62,7 +59,8 @@ init (int argc, char **argv)
}
void
start_raw() {
start_raw()
{
/* Start up our XML-RPC client library. */
xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, CLIENT_NAME, CLIENT_VERSION);
@ -81,8 +79,7 @@ execute ()
xmlrpc_value *domain_h;
xmlrpc_int32 found;
xmlrpc_value *error;
/* char *dst;
dst = HTAnchor_findAddress(ENDPOINT); */
/* char *dst; dst = HTAnchor_findAddress(ENDPOINT); */
printf("Ready to call\n");
/* Call the server */
result = xmlrpc_client_call(&env, ENDPOINT, "domquery", "(s)", domain);
@ -91,10 +88,10 @@ execute ()
xmlrpc_parse_value(&env, result, "{s:i,*}", "found", &found);
die_if_fault_occurred(&env);
if (found)
{
if (found) {
printf("%s is there\n", domain);
xmlrpc_parse_value (&env, result, "{s:S,i,s:A,*}", "domain", &domain_h, "found", &found, "error", &error);
xmlrpc_parse_value(&env, result, "{s:S,i,s:A,*}", "domain",
&domain_h, "found", &found, "error", &error);
die_if_fault_occurred(&env);
}
/* Dispose of our result value. */

@ -16,8 +16,7 @@
void
die_if_fault_occurred(xmlrpc_env * env)
{
if (env->fault_occurred)
{
if (env->fault_occurred) {
fprintf(stderr, "XML-RPC Fault: %s (%d)\n",
env->fault_string, env->fault_code);
exit(1);
@ -38,8 +37,7 @@ main (int argc, char **argv)
char *domain;
char *date, *holder;
if (argc != 2)
{
if (argc != 2) {
fprintf(stderr, "Usage: %s domain\n", argv[0]);
exit(1);
}
@ -58,20 +56,17 @@ main (int argc, char **argv)
xmlrpc_parse_value(&env, result, "{s:i,*}", "found", &found);
die_if_fault_occurred(&env);
if (found)
{
if (found) {
printf("%s is there\n", domain);
xmlrpc_parse_value(&env, result, "{s:S,s:i,s:A,*}", "domain",
&domain_h, "found", &found, "error", &error);
die_if_fault_occurred(&env);
/* printf ("Type of domain: %d\n", xmlrpc_value_type(domain_h)); */
xmlrpc_parse_value (&env, domain_h, "{s:s,s:s,*}", "registered", &date,
"org", &holder);
xmlrpc_parse_value(&env, domain_h, "{s:s,s:s,*}", "registered",
&date, "org", &holder);
die_if_fault_occurred(&env);
printf("Registered on %s by %s\n", date, holder);
}
else
{
} else {
printf("Unknown domain %s\n", domain);
}
/* Dispose of our result value. */

@ -6,10 +6,8 @@
void
die_if_fault_occurred(xmlrpc_env * env)
{
if (env->fault_occurred)
{
if (env->fault_occurred) {
err_quit("XML-RPC Fault: %s (%d)\n",
env->fault_string, env->fault_code);
}
}

@ -15,7 +15,8 @@ char *
init(const int argc, const char **argv, echoping_options global_options)
{
if (global_options.udp)
err_quit ("Sorry, UDP is not yet compatible with this daytime plugin");
err_quit
("Sorry, UDP is not yet compatible with this daytime plugin");
options = global_options;
return "daytime";
}

@ -155,16 +155,19 @@ main(argc, argv)
{"size", 's', POPT_ARG_INT, &size, 's'},
{"number", 'n', POPT_ARG_INT, &number, 'n', "Number of iterations"},
#ifdef HAVE_USLEEP
{"wait", 'w', POPT_ARG_FLOAT, &wait, 'w', "Delay between iterations"},
{"wait", 'w', POPT_ARG_FLOAT, &wait, 'w',
"Delay between iterations"},
#else
{"wait", 'w', POPT_ARG_INT, &wait, 'w', "Delay between iterations"},
#endif
{"discard", 'd', POPT_ARG_NONE, &discard, 'd'},
{"chargen", 'c', POPT_ARG_NONE, &chargen, 'c'},
{"http", 'h', POPT_ARG_STRING, &url, 'h'},
{"accept-http-redirects", 'R', POPT_ARG_NONE, &accept_http_redirects, 'R',
{"accept-http-redirects", 'R', POPT_ARG_NONE, &accept_http_redirects,
'R',
"Accept HTTP return codes 3xx (redirections)"},
{"hostname", 'H', POPT_ARG_STRING, &http_hostname, 'H', "Hostname to use in HTTP Host: header"},
{"hostname", 'H', POPT_ARG_STRING, &http_hostname, 'H',
"Hostname to use in HTTP Host: header"},
{"icp", 'i', POPT_ARG_STRING, &url, 'i',
"ICP protocol, for Web proxies/caches"},
{"ttcp", 'r', POPT_ARG_NONE, &ttcp, 'r',
@ -279,7 +282,8 @@ main(argc, argv)
case 'f':
remaining--;
if (strlen(fill_s) > 1)
err_quit("Argument --fill should be a one-character string");
err_quit
("Argument --fill should be a one-character string");
fill = fill_s[0];
fill_requested = 1;
break;
@ -304,7 +308,8 @@ main(argc, argv)
exit(1);
}
if (size <= 0) {
(void) fprintf(stderr, "%s: illegal packet size.\n", progname);
(void) fprintf(stderr, "%s: illegal packet size.\n",
progname);
exit(1);
}
size_requested = 1;
@ -313,7 +318,8 @@ main(argc, argv)
remaining--;
timeout_requested = 1;
if (size <= 0) {
(void) fprintf(stderr, "%s: illegal timeout.\n", progname);
(void) fprintf(stderr, "%s: illegal timeout.\n",
progname);
exit(1);
}
break;
@ -342,7 +348,8 @@ main(argc, argv)
*/
{
(void) fprintf(stderr,
"%s: illegal waiting time.\n", progname);
"%s: illegal waiting time.\n",
progname);
exit(1);
}
break;
@ -357,7 +364,8 @@ main(argc, argv)
module_find = TRUE;
break;
default:
printf("Unknown character option %d (%c)", result, (char) result);
printf("Unknown character option %d (%c)", result,
(char) result);
usage(poptcon);
}
}
@ -390,22 +398,22 @@ main(argc, argv)
#endif
#ifndef HTTP
if (http) {
(void) fprintf(stderr,
"%s: Not compiled with HTTP support.\n", progname);
(void) fprintf(stderr, "%s: Not compiled with HTTP support.\n",
progname);
exit(1);
}
#endif
#ifndef SMTP
if (smtp) {
(void) fprintf(stderr,
"%s: Not compiled with SMTP support.\n", progname);
(void) fprintf(stderr, "%s: Not compiled with SMTP support.\n",
progname);
exit(1);
}
#endif
#ifndef ICP
if (icp) {
(void) fprintf(stderr,
"%s: Not compiled with ICP support.\n", progname);
(void) fprintf(stderr, "%s: Not compiled with ICP support.\n",
progname);
exit(1);
}
#endif
@ -422,8 +430,8 @@ main(argc, argv)
exit(1);
}
if (udp && ttcp) {
(void) fprintf(stderr,
"%s: UDP and T/TCP are incompatible.\n", progname);
(void) fprintf(stderr, "%s: UDP and T/TCP are incompatible.\n",
progname);
exit(1);
}
if (ssl && http) {
@ -461,13 +469,15 @@ main(argc, argv)
if (!plugin) {
/* Retries with the absolute name */
complete_plugin_name = (char *) malloc(MAX_LINE);
sprintf(complete_plugin_name, "%s/%s", PLUGINS_DIR, plugin_name);
sprintf(complete_plugin_name, "%s/%s", PLUGINS_DIR,
plugin_name);
plugin = dlopen(complete_plugin_name, RTLD_NOW);
}
if (!plugin) {
#if DEBIAN
/* A bit of help for the poor user */
fprintf(stderr, "You may have to load the recommended packages "
fprintf(stderr,
"You may have to load the recommended packages "
"to run this plugin.\n"
"'dpkg -s echoping | grep Recommends' to know them.\n\n");
#endif
@ -477,7 +487,8 @@ main(argc, argv)
}
plugin_init = dlsym(plugin, "init");
if (!plugin_init) {
err_sys("Cannot find init in %s: %s", plugin_name, dlerror());
err_sys("Cannot find init in %s: %s", plugin_name,
dlerror());
}
global_options.udp = udp;
global_options.ttcp = ttcp;
@ -505,13 +516,14 @@ main(argc, argv)
plugin_raw = TRUE;
plugin_raw_start = dlsym(plugin, "start_raw");
if (!plugin_raw_start) {
err_sys("Cannot find start_raw in %s: %s", plugin_name,
dlerror());
err_sys("Cannot find start_raw in %s: %s",
plugin_name, dlerror());
}
}
plugin_execute = dlsym(plugin, "execute");
if (!plugin_execute) {
err_sys("Cannot find execute in %s: %s", plugin_name, dlerror());
err_sys("Cannot find execute in %s: %s", plugin_name,
dlerror());
}
plugin_terminate = dlsym(plugin, "terminate");
if (!plugin_terminate) {
@ -589,8 +601,10 @@ main(argc, argv)
if (*p == ':') {
*p = 0;
text_port = p + 1;
if (strcmp(text_port, "")) /* See bug #850672 */
strncpy(port_name, text_port, NI_MAXSERV);
if (strcmp(text_port, "")) /* See bug *
* #850672 */
strncpy(port_name, text_port,
NI_MAXSERV);
}
}
}
@ -598,11 +612,18 @@ main(argc, argv)
error = getaddrinfo(server, port_name, &hints, &res);
if (error) {
if (error == EAI_SERVICE) {
if (strcmp(port_name, DEFAULT_HTTP_TCP_PORT) == 0) {
if (strcmp(port_name, DEFAULT_HTTP_TCP_PORT)
== 0) {
strcpy(port_name, "80");
} else if (strcmp(port_name, DEFAULT_HTTPS_TCP_PORT) == 0) {
} else
if (strcmp
(port_name, DEFAULT_HTTPS_TCP_PORT)
== 0) {
strcpy(port_name, "443");
} else if (strcmp(port_name, DEFAULT_ICP_UDP_PORT) == 0) {
} else
if (strcmp
(port_name, DEFAULT_ICP_UDP_PORT)
== 0) {
strcpy(port_name, "3130");
}
}
@ -625,10 +646,13 @@ main(argc, argv)
idna_to_ascii_8z(utf8_server, &ace_server,
IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) {
if (result == IDNA_CONTAINS_LDH)
err_quit("Illegal name for host: %s", server); /* foo@bar or similar
err_quit("Illegal name for host: %s", server); /* foo@bar
* or
* similar
* errors */
else
err_quit("IDN error for host: %s %d", server, result);
err_quit("IDN error for host: %s %d", server,
result);
}
if (strcmp(utf8_server, ace_server)) {
if (verbose)
@ -651,7 +675,8 @@ main(argc, argv)
}
if (plugin) {
if (verbose) {
printf("Running start() for the plugin %s...\n", plugin_name);
printf("Running start() for the plugin %s...\n",
plugin_name);
}
if (plugin_raw)
plugin_raw_start();
@ -667,9 +692,9 @@ main(argc, argv)
#endif
#ifdef SMTP
if (smtp) {
sendline = "QUIT\r\n"; /* Surprises some SMTP servers which
* log a frightening NOQUEUE. Anyone
* knows better? */
sendline = "QUIT\r\n"; /* Surprises some SMTP servers which log a
* frightening NOQUEUE. Anyone knows better?
*/
} else
#endif
#ifdef ICP
@ -685,13 +710,13 @@ main(argc, argv)
* http://devel.squid-cache.org/projects.html#ipv6,
* for instance the following code.
*/
sendline = make_icp_sendline(url, (void *) NULL, opcode, &length);
sendline =
make_icp_sendline(url, (void *) NULL, opcode, &length);
/*
- headerp->shostid = theOutICPAddr.s_addr;
+ ** FIXME ** we should get more unique data from IPv6 address
+xmemcpy (&headerp->shostid, &theOutICPAddr,
sizeof (headerp->shostid));
*/
* - headerp->shostid = theOutICPAddr.s_addr; + ** FIXME ** we
* should get more unique data from IPv6 address +xmemcpy
* (&headerp->shostid, &theOutICPAddr, sizeof
* (headerp->shostid)); */
}
} else
#endif
@ -728,7 +753,8 @@ main(argc, argv)
#ifdef USE_SIGACTION
mysigaction.sa_handler = SIG_IGN;
sigemptyset(&mysigaction.sa_mask);
if ((sigaction(SIGPIPE, &mysigaction, NULL)) < 0); /* Ignore it */
if ((sigaction(SIGPIPE, &mysigaction, NULL)) < 0); /* Ignore it
*/
#else
signal(SIGPIPE, SIG_IGN);
#endif
@ -751,10 +777,12 @@ main(argc, argv)
alarm(timeout);
if (i > 1) {
#ifdef HAVE_USLEEP
/* SUSv3 states that the argument to usleep() shall
be less * than 1000000, so split into two calls
if necessary. Bug #1473872, fix by Jeff Rizzo
- riz@sourceforge */
/*
* SUSv3 states that the argument to usleep() shall
* be less * than 1000000, so split into two calls if
* necessary. Bug #1473872, fix by Jeff Rizzo -
* riz@sourceforge
*/
if (wait >= 1) {
sleep((unsigned int) wait);
}
@ -796,14 +824,16 @@ main(argc, argv)
if (error) {
err_sys("getaddrinfo error");
}
if (bind(sockfd, res2->ai_addr, res2->ai_addrlen) < 0) {
if (bind(sockfd, res2->ai_addr, res2->ai_addrlen) <
0) {
err_sys("bind error");
}
}
#ifdef USE_PRIORITY
if (priority_requested) {
if (verbose) {
printf("Setting socket priority to %d (0x%02x)\n",
printf
("Setting socket priority to %d (0x%02x)\n",
priority, (unsigned int) priority);
}
if (setsockopt(sockfd,
@ -818,14 +848,16 @@ main(argc, argv)
#if USE_TOS
if (tos_requested) {
if (verbose) {
printf("Setting IP type of service octet to %d (0x%02x)\n",
printf
("Setting IP type of service octet to %d (0x%02x)\n",
tos, (unsigned int) tos);
}
if (setsockopt(sockfd,
SOL_IP,
IP_TOS, (void *) &tos,
(socklen_t) sizeof(tos))) {
err_sys("Failed setting IP type of service octet");
err_sys
("Failed setting IP type of service octet");
}
}
#endif
@ -851,7 +883,8 @@ main(argc, argv)
}
} else {
if (plugin_raw)
printf("Trying to call plugin %s...\n", plugin_name);
printf("Trying to call plugin %s...\n",
plugin_name);
else
printf
("Trying to call plugin %s for internet address %s %s...\n",
@ -863,10 +896,11 @@ main(argc, argv)
err_sys("I cannot flush");
}
#endif
if ((tcp || plugin) && timeout_requested) { /* echoping's timeout
* has a different
* semantic in TCP and
* UDP */
if ((tcp || plugin) && timeout_requested) { /* echoping's
* timeout has a
* different
* semantic in TCP
* and UDP */
#ifdef USE_SIGACTION
mysigaction.sa_handler = to_alarm;
sigemptyset(&mysigaction.sa_mask);
@ -894,8 +928,10 @@ main(argc, argv)
/*
* Connect to the server.
*/
(void) gettimeofday(&conntv, (struct timezone *) NULL);
if (connect(sockfd, res->ai_addr, res->ai_addrlen) < 0) {
(void) gettimeofday(&conntv,
(struct timezone *) NULL);
if (connect(sockfd, res->ai_addr, res->ai_addrlen) <
0) {
if ((errno == EINTR) && (timeout_flag)) {
printf("Timeout while connecting\n");
close(sockfd);
@ -910,13 +946,17 @@ main(argc, argv)
} else {
if (tcp) {
(void) gettimeofday(&connectedtv,
(struct timezone *) NULL);
(struct timezone
*)
NULL);
temp = connectedtv;
tvsub(&temp, &conntv);
if (verbose) {
printf("Connected...\n");
printf("TCP Latency: %d.%06d seconds\n",
(int) temp.tv_sec, (int) temp.tv_usec);
printf
("TCP Latency: %d.%06d seconds\n",
(int) temp.tv_sec,
(int) temp.tv_usec);
}
}
}
@ -934,8 +974,10 @@ main(argc, argv)
if (ssl) {
SSL_set_fd(sslh, sockfd);
if (SSL_connect(sslh) == -1)
if ((errno == EINTR) && (timeout_flag)) {
printf("Timeout while starting SSL\n");
if ((errno == EINTR)
&& (timeout_flag)) {
printf
("Timeout while starting SSL\n");
close(sockfd);
continue;
}
@ -950,31 +992,40 @@ main(argc, argv)
#endif
#ifdef GNUTLS
if (ssl) {
tls_result = gnutls_init(&session, GNUTLS_CLIENT);
tls_result =
gnutls_init(&session, GNUTLS_CLIENT);
if (tls_result != 0)
err_sys("Cannot create a new TLS session");
err_sys
("Cannot create a new TLS session");
gnutls_set_default_priority(session);
gnutls_certificate_type_set_priority(session,
cert_type_priority);
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
gnutls_credentials_set(session,
GNUTLS_CRD_CERTIFICATE,
xcred);
gnutls_transport_set_ptr(session,
(gnutls_transport_ptr) sockfd);
(gnutls_transport_ptr)
sockfd);
tls_result = gnutls_handshake(session);
if (tls_result < 0) {
if ((errno == EINTR) && (timeout_flag)) {
printf("Timeout while starting TLS\n");
if ((errno == EINTR)
&& (timeout_flag)) {
printf
("Timeout while starting TLS\n");
close(sockfd);
continue;
} else {
err_sys("Cannot start the TLS session: %s",
gnutls_strerror(tls_result));
err_sys
("Cannot start the TLS session: %s",
gnutls_strerror
(tls_result));
}
}
if (verbose)
printf("TLS connection using \"%s\"\n",
gnutls_cipher_get_name(gnutls_cipher_get
(session)));
printf
("TLS connection using \"%s\"\n",
gnutls_cipher_get_name
(gnutls_cipher_get(session)));
/*
* We could check the server's
* certificate or other funny things.
@ -990,13 +1041,14 @@ main(argc, argv)
else {
/* No initial connection */
}
if ((port_to_use == USE_ECHO) || (port_to_use == USE_DISCARD) ||
(port_to_use == USE_HTTP) || (port_to_use == USE_ICP) ||
(port_to_use == USE_SMTP)) {
if ((port_to_use == USE_ECHO) || (port_to_use == USE_DISCARD)
|| (port_to_use == USE_HTTP) || (port_to_use == USE_ICP)
|| (port_to_use == USE_SMTP)) {
#ifdef USE_TTCP
if (ttcp) {
if (sendto(sockfd, sendline, n, MSG_EOF,
res->ai_addr, res->ai_addrlen) != n)
res->ai_addr,
res->ai_addrlen) != n)
err_sys("sendto error on socket");
if (verbose) {
printf("T/TCP connection done\n");
@ -1010,29 +1062,41 @@ main(argc, argv)
* server
*/
if (writen(sockfd, sendline, n) != n) {
if ((nr < 0 || nr != n) && timeout_flag) {
if ((nr < 0 || nr != n)
&& timeout_flag) {
printf
("Timeout while writing (%d byte(s) written so far)\n",
(nr == -1) ? 0 : nr);
(nr ==
-1) ? 0 : nr);
nr = n;
close(sockfd);
continue;
} else
err_sys("writen error on TCP socket %d", sockfd);
err_sys
("writen error on TCP socket %d",
sockfd);
}
}
#ifdef OPENSSL
else {
if ((rc = SSL_write(sslh, sendline, n)) != n) {
if ((nr < 0 || nr != n) && timeout_flag) {
if ((rc =
SSL_write(sslh, sendline,
n)) != n) {
if ((nr < 0 || nr != n)
&& timeout_flag) {
nr = n;
printf("Timeout while writing\n");
printf
("Timeout while writing\n");
close(sockfd);
continue;
} else {
sslcode = ERR_get_error();
err_sys("SSL_write error on socket: %s",
ERR_error_string(sslcode, NULL));
sslcode =
ERR_get_error();
err_sys
("SSL_write error on socket: %s",
ERR_error_string
(sslcode,
NULL));
}
}
}
@ -1041,17 +1105,24 @@ main(argc, argv)
else
{
if ((rc =
gnutls_record_send(session, sendline,
strlen(sendline))) != n) {
if ((nr < 0 || nr != n) && timeout_flag) {
gnutls_record_send(session,
sendline,
strlen
(sendline)))
!= n) {
if ((nr < 0 || nr != n)
&& timeout_flag) {
nr = n;
printf("Timeout while writing\n");
printf
("Timeout while writing\n");
close(sockfd);
continue;
} else {
err_sys
("gnutls_record_send error %d on socket: %s",
rc, gnutls_strerror(rc));
rc,
gnutls_strerror
(rc));
}
}
}
@ -1059,9 +1130,12 @@ main(argc, argv)
} else {
#ifdef ICP
if (icp) {
if (sendto(sockfd, sendline, length, 0,
res->ai_addr, res->ai_addrlen) != length)
err_sys("sendto error on socket");
if (sendto
(sockfd, sendline, length, 0,
res->ai_addr,
res->ai_addrlen) != length)
err_sys
("sendto error on socket");
} else
#endif
/*
@ -1073,10 +1147,13 @@ main(argc, argv)
err_sys("send error on socket");
}
if (verbose) {
(void) gettimeofday(&sendtv, (struct timezone *) NULL);
(void) gettimeofday(&sendtv,
(struct timezone *)
NULL);
#ifdef ICP
if (icp)
printf("Sent (%d bytes)...\n", length);
printf("Sent (%d bytes)...\n",
length);
else
#endif
printf("Sent (%d bytes)...\n", n);
@ -1109,21 +1186,26 @@ main(argc, argv)
#endif
FD_SET(n, &mask);
if (select(n + 1, &mask, 0, 0, NULL) > 0) {
(void) gettimeofday(&recvtv, (struct timezone *) NULL);
(void) gettimeofday(&recvtv,
(struct timezone *)
NULL);
temp = recvtv;
tvsub(&temp, &sendtv);
if (verbose)
printf("Application Latency: %d.%06d seconds\n",
(int) temp.tv_sec, (int) temp.tv_usec);
printf
("Application Latency: %d.%06d seconds\n",
(int) temp.tv_sec,
(int) temp.tv_usec);
}
}
if ((port_to_use == USE_ECHO) || (port_to_use == USE_CHARGEN) ||
(port_to_use == USE_HTTP) || (port_to_use == USE_ICP) ||
(port_to_use == USE_SMTP)) {
if ((port_to_use == USE_ECHO) || (port_to_use == USE_CHARGEN)
|| (port_to_use == USE_HTTP) || (port_to_use == USE_ICP)
|| (port_to_use == USE_SMTP)) {
if (!udp) {
if (!http && !smtp && !discard) {
/* Read from the server */
nr = readline(files, recvline, n, stop_at_newlines);
nr = readline(files, recvline, n,
stop_at_newlines);
} else if (discard) {
/* No reply, no read */
}
@ -1139,14 +1221,14 @@ main(argc, argv)
else
channel.tls = session;
#endif
nr =
read_from_server(channel, ssl,
nr = read_from_server(channel, ssl,
accept_http_redirects);
}
#endif
#ifdef SMTP
else if (smtp) {
nr = smtp_read_response_from_server(files);
nr = smtp_read_response_from_server
(files);
}
#endif
@ -1159,15 +1241,18 @@ main(argc, argv)
#else
mysigaction.sa_flags = (int) 0;
#endif
if ((sigaction(SIGALRM, &mysigaction, NULL)) < 0)
if ((sigaction(SIGALRM, &mysigaction, NULL))
< 0)
err_sys("Cannot set signal handler");
#else
signal(SIGALRM, to_alarm);
#endif
timeout_flag = 0; /* for signal handler */
timeout_flag = 0; /* for signal
* handler */
#ifdef ICP
if (icp) {
nr = recv_icp(sockfd, recvline, retcode);
nr = recv_icp(sockfd, recvline,
retcode);
if (verbose) {
printf("%s\n", retcode);
}
@ -1184,12 +1269,15 @@ main(argc, argv)
* Todo: in UDP, we should loop to read: we
* can have several reads necessary.
*/
if ((nr < 0) && (errno == EINTR) && (timeout_flag)) {
if ((nr < 0) && (errno == EINTR)
&& (timeout_flag)) {
nr = n;
printf("Timeout\n");
#ifdef FLUSH_OUTPUT
if (fflush((FILE *) NULL) != 0) {
err_sys("I cannot flush");
if (fflush((FILE *) NULL) !=
0) {
err_sys
("I cannot flush");
}
#endif
}
@ -1205,7 +1293,8 @@ main(argc, argv)
* timeout_flag)
*/
{
printf("Timeout while reading (%d byte(s) read)\n",
printf
("Timeout while reading (%d byte(s) read)\n",
(nr == -1) ? 0 : nr);
nr = n;
#ifdef FLUSH_OUTPUT
@ -1275,7 +1364,8 @@ main(argc, argv)
if (port_to_use == USE_ECHO) {
if (strcmp(sendline, recvline) != 0) {
printf(" I wrote:\n%s\n", sendline);
printf(" and I got back:\n%s\n", recvline);
printf(" and I got back:\n%s\n",
recvline);
err_quit("Strange server");
}
if (verbose) {
@ -1296,8 +1386,11 @@ main(argc, argv)
* the size is lower than the
* length of CHARGENERATED
*/
printf(" I got back:\n%s\n", recvline);
printf(" instead of the most common:\n%s\n", sendline);
printf(" I got back:\n%s\n",
recvline);
printf
(" instead of the most common:\n%s\n",
sendline);
err_ret("Strange server");
}
if (verbose) {
@ -1368,7 +1461,8 @@ printstats()
if (successes > 1) {
printf("---\n");
if (successes < attempts)
printf("Warning: %d message(s) lost (%d %%)\n", attempts - successes,
printf("Warning: %d message(s) lost (%d %%)\n",
attempts - successes,
((attempts - successes) * 100) / attempts);
printf("Minimum time: %d.%06d seconds (%.0f bytes per sec.)\n",
(int) min.tv_sec, (int) min.tv_usec,
@ -1394,7 +1488,8 @@ printstats()
good_results[j++] = results[i].timevalue;
}
if (successes != j) /* Todo: bug! */
err_quit("successes (%d) is different from j (%d)", successes, j);
err_quit("successes (%d) is different from j (%d)",
successes, j);
qsort(good_results, successes, sizeof(struct timeval), tvcmp);
/*
* for (i = 1; i <= number; i++) { printf("---\nTime %d th:

@ -107,12 +107,9 @@ sys_err_str ()
{
static char msgstr[200];
if (errno != 0)
{
if (errno != 0) {
sprintf(msgstr, "(%s)", strerror(errno));
}
else
{
} else {
msgstr[0] = '\0';
}
return (msgstr);

@ -18,21 +18,30 @@ make_http_sendline(char *url, char *host, int port, int nocache)
char *cache_directive = "";
#ifdef HTTP10
if (nocache)
cache_directive = "Pragma: no-cache\r\n"; /* RFC 1945, "Hypertext
* Transfer Protocol --
* HTTP/1.0" */
cache_directive = "Pragma: no-cache\r\n"; /* RFC 1945,
* "Hypertext
* Transfer Protocol
* -- HTTP/1.0" */
sprintf(sendline,
"GET %s HTTP/1.0\r\nUser-Agent: Echoping/%s\r\n%s\r\n",
url, VERSION, cache_directive);
#else
if (nocache) {
if (nocache == 1)
cache_directive = "Cache-control: max-age=0\r\n"; /* Simply force a
* recheck with the
* server */
cache_directive = "Cache-control: max-age=0\r\n"; /* Simply
* force
* a
* recheck
* with
* the
* server
*/
else
cache_directive = "Cache-control: no-cache\r\n"; /* RFC 2616 "Hypertext
* Transfer Protocol --
cache_directive = "Cache-control: no-cache\r\n"; /* RFC
* 2616
* "Hypertext
* Transfer
* Protocol --
* HTTP/1.1" */
}
strcpy(hostname, HTParse(url, "", PARSE_HOST));
@ -75,7 +84,8 @@ read_from_server(CHANNEL fs, short ssl, boolean accept_redirects)
{
nr = TLS_readline(fs.tls, big_recvline, MAXTOREAD, TRUE);
if (nr == -1) {
err_ret("TLS_readline error: %s", gnutls_strerror(nr));
err_ret("TLS_readline error: %s",
gnutls_strerror(nr));
}
}
#endif
@ -100,7 +110,8 @@ read_from_server(CHANNEL fs, short ssl, boolean accept_redirects)
if (first_line) {
reply_code = big_recvline[9]; /* 9 because "HTTP/1.x
* 200..." */
if (reply_code != '2' && !(reply_code == '3' && accept_redirects))
if (reply_code != '2'
&& !(reply_code == '3' && accept_redirects))
/*
* Status codes beginning with 3 are not
* errors See bug #850674 and RFC 2616,
@ -128,7 +139,7 @@ read_from_server(CHANNEL fs, short ssl, boolean accept_redirects)
*/
if ((nr < 2) && (timeout_flag)) /* Probably a timeout */
return -1;
if (nr < 2) /* Hmm, if the body is empty, we'll get a
if (nr < 2) /* Hmm, if the body is empty, we'll get a *
* meaningless error message */
err_sys("Error reading HTTP body");
total = total + nr;

@ -90,8 +90,7 @@ recv_icp (sockfd, buf, retcode)
nr = recvfrom(sockfd, buf, DEFLINE, 0, (struct sockaddr *) 0, (int *) 0);
if (nr < 0)
{
if (nr < 0) {
if (timeout_flag)
err_quit("Timeout while reading");
else

@ -38,8 +38,7 @@ nsError (error, domain)
int error;
char *domain;
{
switch (error)
{
switch (error) {
case HOST_NOT_FOUND:
err_ret("Unknown domain: %s\n", domain);
return -1;
@ -89,11 +88,9 @@ init (const int argc, const char **argv)
};
dns_poptcon = poptGetContext(NULL, argc,
argv, options, POPT_CONTEXT_KEEP_FIRST);
while ((value = poptGetNextOpt (dns_poptcon)) > 0)
{
while ((value = poptGetNextOpt(dns_poptcon)) > 0) {
}
if (value < -1)
{
if (value < -1) {
sprintf(msg, "%s: %s",
poptBadOption(dns_poptcon, POPT_BADOPTION_NOALIAS),
poptStrerror(value));
@ -103,13 +100,10 @@ init (const int argc, const char **argv)
request = (char *) poptGetArg(dns_poptcon);
if (request == NULL)
dns_usage("Mandatory request missing");
if ((type_name == NULL) || !strcmp (type_name, ""))
{
if ((type_name == NULL) || !strcmp(type_name, "")) {
type = T_A;
type_name = "A";
}
else
{
} else {
upper_type_name = (char *) to_upper(type_name);
/*
* TODO: a better algorithm. Use dns_rdatatype_fromtext in
@ -149,16 +143,15 @@ start (struct addrinfo *res)
struct sockaddr_in6 name_server_sockaddr_in6;
name_server = *res;
name_server_sockaddr = *name_server.ai_addr;
if (name_server_sockaddr.sa_family == AF_INET)
{
if (name_server_sockaddr.sa_family == AF_INET) {
/* Converts a generic sockaddr to an IPv4 sockaddr_in */
(void) memcpy ((void *) &name_server_sockaddr_in, &name_server_sockaddr,
sizeof (struct sockaddr));
}
else if (name_server_sockaddr.sa_family == AF_INET6)
{
/* TODO: the code for IPv6 servers is hopelessly broken. Start again */
fprintf (stderr, "WARNING: IPv6 nameservers not really supported yet (experts may apply). Falling back to IPv4 and the default server. You may use -4, too\n");
(void) memcpy((void *) &name_server_sockaddr_in,
&name_server_sockaddr, sizeof(struct sockaddr));
} else if (name_server_sockaddr.sa_family == AF_INET6) {
/* TODO: the code for IPv6 servers is hopelessly broken. Start again
*/
fprintf(stderr,
"WARNING: IPv6 nameservers not really supported yet (experts may apply). Falling back to IPv4 and the default server. You may use -4, too\n");
#ifdef HAVE_RES_EXT
/* Converts a generic sockaddr to an IPv6 sockaddr_in6 */
(void) memcpy((void *) &name_server_sockaddr_in6,
@ -167,32 +160,26 @@ start (struct addrinfo *res)
err_quit
("IPv6 name servers not supported on this platform, may be you should use the -4 option");
#endif
}
else
{
} else {
err_quit("Unknown family for address of the server");
}
if (res_init() < 0)
err_sys("res_init");
if (name_server_sockaddr.sa_family == AF_INET)
{
if (name_server_sockaddr.sa_family == AF_INET) {
_res.nsaddr_list[0] = name_server_sockaddr_in;
}
else if (name_server_sockaddr.sa_family == AF_INET6)
{
} else if (name_server_sockaddr.sa_family == AF_INET6) {
#ifdef HAVE_RES_EXT
/* TODO: completely broken, dioes not work. Check in Stevens */
(void)memcpy(_res_ext.nsaddr_list, &name_server_sockaddr_in6, sizeof(struct sockaddr_in6));
(void) memcpy(_res_ext.nsaddr_list, &name_server_sockaddr_in6,
sizeof(struct sockaddr_in6));
#endif
}
_res.nscount = 1;
_res.options &= ~(RES_DNSRCH | RES_DEFNAMES | RES_NOALIASES);
if (use_tcp)
{
if (use_tcp) {
_res.options |= RES_USEVC;
}
if (no_recurse)
{
if (no_recurse) {
_res.options &= ~RES_RECURSE;
}
}
@ -200,19 +187,17 @@ start (struct addrinfo *res)
int
execute()
{
union
{
union {
HEADER hdr; /* defined in resolv.h */
u_char buf[PACKETSZ]; /* defined in arpa/nameser.h */
} response; /* response buffers */
int response_length; /* buffer length */
if ((response_length = res_query (request, /* the domain we care
* about */
if ((response_length = res_query(request, /* the domain we care about */
C_IN, /* Internet class records */
type, (u_char *) & response, /* response buffer */
type, (u_char *) & response, /* response
* buffer */
sizeof(response))) /* buffer size */
< 0)
{ /* If negative */
<0) { /* If negative */
nsError(h_errno, request); /* report the error */
if (h_errno == TRY_AGAIN)
return -1; /* More luck next time? */

@ -23,8 +23,7 @@ echoping_options global_options;
void
ldap_usage(const char *msg)
{
if (msg)
{
if (msg) {
printf("LDAP plugin error: %s\n", msg);
}
poptPrintUsage(ldap_poptcon, stdout, 0);
@ -56,11 +55,9 @@ init (const int argc, const char **argv,
err_quit("UDP makes no sense for a LDAP connection");
ldap_poptcon = poptGetContext(NULL, argc,
argv, options, POPT_CONTEXT_KEEP_FIRST);
while ((value = poptGetNextOpt (ldap_poptcon)) > 0)
{
while ((value = poptGetNextOpt(ldap_poptcon)) > 0) {
}
if (value < -1)
{
if (value < -1) {
sprintf(msg, "%s: %s",
poptBadOption(ldap_poptcon, POPT_BADOPTION_NOALIAS),
poptStrerror(value));
@ -70,8 +67,7 @@ init (const int argc, const char **argv,
port = LDAP_PORT;
hostname = poptGetArg(ldap_poptcon);
rest = poptGetArg(ldap_poptcon);
if (rest != NULL)
{
if (rest != NULL) {
fprintf(stderr, "%s: ", rest);
ldap_usage("Additional arguments");
}
@ -79,8 +75,7 @@ init (const int argc, const char **argv,
base = "";
if (request == NULL || !strcmp(request, ""))
request = "(objectclass=*)";
if (scope_string != NULL)
{
if (scope_string != NULL) {
scope_string = to_upper(scope_string);
if (!strcmp(scope_string, "BASE"))
scope = LDAP_SCOPE_BASE;
@ -91,12 +86,9 @@ init (const int argc, const char **argv,
else
err_quit("Invalid scope \"%s\"", scope_string);
}
if (port == LDAP_PORT)
{
if (port == LDAP_PORT) {
return "ldap";
}
else
{
} else {
port_text = malloc(99);
sprintf(port_text, "%d", port);
return port_text;
@ -126,10 +118,12 @@ start ()
*
* So, we perform a dummy search immediately.
*/
result = ldap_search_s (session, base, LDAP_SCOPE_ONELEVEL, "(objectclass=*)", NULL, /* Return all attributes */
result = ldap_search_s(session, base, LDAP_SCOPE_ONELEVEL, "(objectclass=*)", NULL, /* Return
* all
* attributes
*/
1, &response);
if (result != 0)
{
if (result != 0) {
err_quit
("Cannot connect to %s (no LDAP server or wrong base, probably): %s",
hostname, ldap_err2string(result));
@ -141,13 +135,15 @@ execute ()
{
int result;
LDAPMessage *response;
result = ldap_search_s (session, base, scope, request, NULL, /* Return all attributes */
0, /* Return attribute types *and*
* values */
result = ldap_search_s(session, base, scope, request, NULL, /* Return
* all
* attributes
*/
0, /* Return attribute types *and* values */
&response);
if (result != 0)
{
err_ret ("Cannot search \"%s\": %s", request, ldap_err2string (result));
if (result != 0) {
err_ret("Cannot search \"%s\": %s", request,
ldap_err2string(result));
return -1;
}
if (global_options.verbose)

@ -28,8 +28,7 @@ echoping_options global_options;
void
postgresql_usage(const char *msg)
{
if (msg)
{
if (msg) {
printf("PostgreSQL plugin error: %s\n", msg);
}
poptPrintUsage(postgresql_poptcon, stdout, 0);
@ -63,11 +62,9 @@ init (const int argc, const char **argv,
postgresql_poptcon = poptGetContext(NULL, argc,
argv, options,
POPT_CONTEXT_POSIXMEHARDER);
while ((value = poptGetNextOpt (postgresql_poptcon)) > 0)
{
while ((value = poptGetNextOpt(postgresql_poptcon)) > 0) {
}
if (value < -1)
{
if (value < -1) {
sprintf(msg, "%s: %s",
poptBadOption(postgresql_poptcon, POPT_BADOPTION_NOALIAS),
poptStrerror(value));
@ -81,21 +78,19 @@ init (const int argc, const char **argv,
postgresql_usage("Erroneous additional arguments");
if (conninfo == NULL)
conninfo = "";
return NULL; /* We only use the conninfo, echoping does not see our hostname or port */
return NULL; /* We only use the conninfo, echoping does not see
* our hostname or port */
}
void
start_raw()
{
if (!connect_each_time)
{
if (!connect_each_time) {
conn = PQconnectdb(conninfo);
if (conn == NULL)
{
if (conn == NULL) {
err_quit("Cannot create connection\n");
}
if (PQstatus (conn) == CONNECTION_BAD)
{
if (PQstatus(conn) == CONNECTION_BAD) {
err_quit("Connection failed: %s\n", PQerrorMessage(conn));
}
}
@ -106,44 +101,36 @@ execute ()
{
unsigned int row, column;
char *result;
if (connect_each_time)
{
if (connect_each_time) {
conn = PQconnectdb(conninfo);
if (conn == NULL)
{
if (conn == NULL) {
err_ret("Cannot create connection\n");
return -1;
}
if (PQstatus (conn) == CONNECTION_BAD)
{
if (PQstatus(conn) == CONNECTION_BAD) {
err_ret("Connection failed: %s\n", PQerrorMessage(conn));
return -1;
}
}
res = PQexec(conn, request);
if (PQresultStatus (res) != PGRES_TUPLES_OK)
{
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
err_ret("Cannot run \"%s\": %s\n", request,
PQresultErrorMessage(res));
return -1;
}
if (global_options.verbose)
printf("%d tuples returned\n", PQntuples(res));
if (readall)
{
for (row = 0; row < PQntuples (res); row++)
{
for (column = 0; column < PQnfields (res); column++)
{
if (readall) {
for (row = 0; row < PQntuples(res); row++) {
for (column = 0; column < PQnfields(res); column++) {
result = PQgetvalue(res, row, column);
if (result == NULL)
{
err_ret ("Cannot retrieve value [%d,%d]\n", row, column);
if (result == NULL) {
err_ret("Cannot retrieve value [%d,%d]\n",
row, column);
return -1;
}
/* else {
printf ("DEBUG: [%d,%d] %s\n", row, column, result);
} */
/* else { printf ("DEBUG: [%d,%d] %s\n", row,
* column, result); } */
}
}
}

@ -15,10 +15,12 @@ init (const int argc, const char *argv[])
struct timeval tv;
(void) gettimeofday(&tv, (struct timezone *) NULL);
srand(tv.tv_usec);
return "7"; /* Not used, just to say we use the cooked interface */
return "7"; /* Not used, just to say we use the cooked interface
*/
}
void start ()
void
start()
{
}
@ -29,4 +31,7 @@ execute ()
return 1;
}
void terminate() {}
void
terminate()
{
}

@ -25,8 +25,7 @@ poptContext whois_poptcon;
void
whois_usage(const char *msg)
{
if (msg)
{
if (msg) {
printf("Error: %s\n", msg);
}
poptPrintUsage(whois_poptcon, stdout, 0);
@ -49,13 +48,12 @@ init (const int argc, const char **argv, echoping_options global_options)
};
if (global_options.udp)
err_quit("UDP is incompatible with this whois plugin");
/* Will probably be catched before because /etc/services have no entry for UDP port 43 */
/* Will probably be catched before because /etc/services have no entry for
* UDP port 43 */
whois_poptcon = poptGetContext(NULL, argc,
argv, options, POPT_CONTEXT_POSIXMEHARDER);
while ((value = poptGetNextOpt (whois_poptcon)) > 0)
{
switch ((char) value)
{
while ((value = poptGetNextOpt(whois_poptcon)) > 0) {
switch ((char) value) {
case 'd':
break;
default:
@ -63,8 +61,7 @@ init (const int argc, const char **argv, echoping_options global_options)
whois_usage(msg);
}
}
if (value < -1)
{
if (value < -1) {
sprintf(msg, "%s: %s",
poptBadOption(whois_poptcon, POPT_BADOPTION_NOALIAS),
poptStrerror(value));

@ -18,30 +18,23 @@ readline (fs, ptr, maxlen, ln)
char *rc;
int r;
/* Reading with fgets or fread instead of read
one-character-at-a-time is more than ten times faster, on a local
server. */
if (ln)
{
/* Reading with fgets or fread instead of read one-character-at-a-time is
* more than ten times faster, on a local server. */
if (ln) {
rc = fgets(ptr, maxlen + 1, fs);
if (rc == NULL)
{
if (rc == NULL) {
if (timeout_flag)
return n;
return (-1);
}
n = strlen(rc);
return n;
}
else
{
while (n < maxlen)
{
} else {
while (n < maxlen) {
r = fread(ptr, 1, maxlen, fs);
if (timeout_flag)
return r;
if (r == 0)
{
if (r == 0) {
if (n == 1)
return (0); /* EOF, no data read */
else
@ -69,11 +62,9 @@ SSL_readline (sslh, ptr, maxlen, ln)
int rc = 0;
int n = 0;
int i, oi;
if (ln)
{
if (ln) {
/* Empty buffer */
if (buf_end == 0)
{
if (buf_end == 0) {
rc = SSL_read(sslh, SSL_buffer, maxlen);
if (rc == -1)
return rc;
@ -81,53 +72,42 @@ SSL_readline (sslh, ptr, maxlen, ln)
buf_ptr = 0;
}
/* No more data in the buffer */
else if (buf_ptr == buf_end)
{
else if (buf_ptr == buf_end) {
buf_ptr = 0;
rc = SSL_read(sslh, SSL_buffer, maxlen);
if (rc == -1)
return rc;
buf_end = rc;
}
else if (SSL_buffer[buf_end] != '\n')
{
/* We have a probleme here is the first SSL_read sent back
a text not finished by a \n. See www.SSL.de for an
example. We get more data. See bug #230384 */
} else if (SSL_buffer[buf_end] != '\n') {
/* We have a probleme here is the first SSL_read sent back a
* text not finished by a \n. See www.SSL.de for an example.
* We get more data. See bug #230384 */
rc = SSL_read(sslh, SSL_buffer + buf_end, maxlen);
if (rc == -1)
return rc;
buf_end = buf_end + rc;
}
for (oi = buf_ptr, i = buf_ptr;
i <= buf_end && SSL_buffer[i] != '\n'; i++)
{
i <= buf_end && SSL_buffer[i] != '\n'; i++) {
*ptr++ = SSL_buffer[i];
buf_ptr++;
}
if (SSL_buffer[i] == '\n')
buf_ptr++;
*ptr = '\0';
/* if (ln)
printf ("SSL_readline returns %d (%s)\n", i - oi, SSL_buffer); */
/* if (ln) printf ("SSL_readline returns %d (%s)\n", i - oi,
* SSL_buffer); */
return (i - oi);
}
else
{
} else {
/* OpenSSL reads at most 4096 characters */
rc = 1; /* Just to avoid exiting too soon */
while (n < maxlen && rc != 0)
{
if ((buf_end == 0) || (buf_ptr > buf_end))
{
while (n < maxlen && rc != 0) {
if ((buf_end == 0) || (buf_ptr > buf_end)) {
rc = SSL_read(sslh, ptr, maxlen);
buf_end = 0;
buf_ptr = 0;
}
else
{
for (i = buf_ptr; i < maxlen && i <= buf_end; i++)
{
} else {
for (i = buf_ptr; i < maxlen && i <= buf_end; i++) {
*ptr++ = SSL_buffer[i];
rc++;
}
@ -156,11 +136,9 @@ TLS_readline (session, ptr, maxlen, ln)
int rc = 0;
int n = 0;
int i, oi;
if (ln)
{
if (ln) {
/* Empty buffer */
if (buf_end == 0)
{
if (buf_end == 0) {
rc = gnutls_record_recv(session, TLS_buffer, maxlen);
if (rc == -1)
return rc;
@ -168,51 +146,43 @@ TLS_readline (session, ptr, maxlen, ln)
buf_ptr = 0;
}
/* No more data in the buffer */
else if (buf_ptr == buf_end)
{
else if (buf_ptr == buf_end) {
buf_ptr = 0;
rc = gnutls_record_recv(session, TLS_buffer, maxlen);
if (rc == -1)
return rc;
buf_end = rc;
}
else if (TLS_buffer[buf_end] != '\n')
{
rc = gnutls_record_recv (session, TLS_buffer + buf_end, maxlen);
} else if (TLS_buffer[buf_end] != '\n') {
rc = gnutls_record_recv(session, TLS_buffer + buf_end,
maxlen);
if (rc == -1)
return rc;
buf_end = buf_end + rc;
}
for (oi = buf_ptr, i = buf_ptr;
i <= buf_end && TLS_buffer[i] != '\n'; i++)
{
i <= buf_end && TLS_buffer[i] != '\n'; i++) {
*ptr++ = TLS_buffer[i];
buf_ptr++;
}
if (TLS_buffer[i] == '\n')
buf_ptr++;
*ptr = '\0';
/* printf ("DEBUG: TLS_readline returns %d (%s)\n", i - oi, TLS_buffer); */
/* printf ("DEBUG: TLS_readline returns %d (%s)\n", i - oi,
* TLS_buffer); */
return (i - oi);
}
else
{
} else {
rc = 1; /* Just to avoid exiting too soon */
while (n < maxlen && rc > 0)
{
if ((buf_end == 0) || (buf_ptr > buf_end))
{
while (n < maxlen && rc > 0) {
if ((buf_end == 0) || (buf_ptr > buf_end)) {
rc = gnutls_record_recv(session, ptr, maxlen);
buf_end = 0;
buf_ptr = 0;
}
else
{
for (i = buf_ptr; i < maxlen && i <= buf_end; i++)
{
} else {
for (i = buf_ptr; i < maxlen && i <= buf_end; i++) {
*ptr++ = TLS_buffer[i];
rc++;
/* printf ("DEBUG: Now %d chars read\n", rc); */
/* printf ("DEBUG: Now %d chars read\n",
* rc); */
}
buf_ptr = i;
}

@ -16,19 +16,15 @@ smtp_read_response_from_server (FILE *fs)
int nr;
int i;
for (i = 0; i < MAXSMTPLINES; i++)
{
for (i = 0; i < MAXSMTPLINES; i++) {
nr = readline(fs, big_recvline, MAXTOREAD, TRUE);
if (nr <= 4)
{
if (nr <= 4) {
return -1;
}
if (big_recvline[3] == ' ')
{
if (big_recvline[3] == ' ') {
return nr;
}
if (big_recvline[3] != '-')
{
if (big_recvline[3] != '-') {
return -1;
}
}

@ -23,8 +23,7 @@ random_string (unsigned length)
/* Initialize random generator */
(void) initstate(seed, state, STATES);
for (i = 0; i < length; i++)
{
for (i = 0; i < length; i++) {
number = (random() % 94) + 33;
/* printf ("Number for %d is %d\n", i, number); */
result[i] = (char) number;
@ -57,8 +56,7 @@ void
tvsub(out, in)
struct timeval *out, *in;
{
if ((out->tv_usec -= in->tv_usec) < 0)
{
if ((out->tv_usec -= in->tv_usec) < 0) {
--out->tv_sec;
out->tv_usec += 1000000;
}
@ -70,8 +68,7 @@ void
tvadd(out, in)
struct timeval *out, *in;
{
if ((out->tv_usec += in->tv_usec) >= 1000000)
{
if ((out->tv_usec += in->tv_usec) >= 1000000) {
++out->tv_sec;
out->tv_usec -= 1000000;
}
@ -107,21 +104,16 @@ tvstddev (out, number, average, results)
struct timeval result, avg, var = null_timeval;
struct timeval square, large, small;
*out = null_timeval;
for (i = 0; i < number; i++)
{
if (results[i].valid == 1)
{
for (i = 0; i < number; i++) {
if (results[i].valid == 1) {
result = results[i].timevalue;
/* printf ("value is %f (average is %f)\n",
tv2double (result), tv2double (average)); */
/* printf ("value is %f (average is %f)\n", tv2double
* (result), tv2double (average)); */
avg = average;
if (tvcmp (&result, &avg) == -1)
{
if (tvcmp(&result, &avg) == -1) {
small = result;
large = avg;
}
else
{
} else {
large = result;
small = avg;
}
@ -142,20 +134,16 @@ int
tvcmp(left, right)
struct timeval *left, *right;
{
if (left->tv_sec < right->tv_sec)
{
if (left->tv_sec < right->tv_sec) {
return -1;
}
if (left->tv_sec > right->tv_sec)
{
if (left->tv_sec > right->tv_sec) {
return 1;
}
if (left->tv_usec < right->tv_usec)
{
if (left->tv_usec < right->tv_usec) {
return -1;
}
if (left->tv_usec > right->tv_usec)
{
if (left->tv_usec > right->tv_usec) {
return 1;
}
return 0;
@ -167,8 +155,7 @@ void
tvmin(champion, challenger)
struct timeval *champion, *challenger;
{
if (tvcmp (champion, challenger) == 1)
{
if (tvcmp(champion, challenger) == 1) {
champion->tv_sec = challenger->tv_sec;
champion->tv_usec = challenger->tv_usec;
}
@ -179,8 +166,7 @@ void
tvmax(champion, challenger)
struct timeval *champion, *challenger;
{
if (tvcmp (champion, challenger) == -1)
{
if (tvcmp(champion, challenger) == -1) {
champion->tv_sec = challenger->tv_sec;
champion->tv_usec = challenger->tv_usec;
}

@ -16,14 +16,13 @@ writen (fd, ptr, nbytes)
int nleft, nwritten;
nleft = nbytes;
while (nleft > 0)
{
while (nleft > 0) {
nwritten = write(fd, ptr, nleft);
if (nwritten <= 0)
return (nwritten); /* error */
/* Some systems, such as Digital's OSF1 (Digital Unix) doesn't set the returned
value to -1, even when interrupted by an alarm, whatever says the documentation.
errno is not set. */
/* Some systems, such as Digital's OSF1 (Digital Unix) doesn't set
* the returned value to -1, even when interrupted by an alarm,
* whatever says the documentation. errno is not set. */
if ((nwritten < nleft) && timeout_flag)
return nwritten;
nleft -= nwritten;

Loading…
Cancel
Save