Reformat to fit OpenSSL source code standards

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Richard Levitte 2016-09-14 20:54:30 +02:00
parent a2d2120033
commit b50826727e
4 changed files with 476 additions and 497 deletions

View File

@ -2028,20 +2028,15 @@ int MAIN(int argc, char **argv)
else if (_kbhit())
#elif defined(OPENSSL_SYS_BEOS_R5)
else if (stdin_set)
#else
#if defined(OPENSSL_SYS_VMS)
#elif defined(OPENSSL_SYS_VMS)
else if (FD_ISSET(stdin_sock, &readfds))
#else
else if (FD_ISSET(fileno(stdin), &readfds))
#endif
#endif
{
if (crlf) {
int j, lf_num;
i = raw_read_stdin(cbuf, BUFSIZZ / 2);
#if defined(OPENSSL_SYS_VMS)
i = recv(stdin_sock, cbuf, BUFSIZZ / 2, 0);
#else
@ -2062,8 +2057,7 @@ int MAIN(int argc, char **argv)
}
}
assert(lf_num == 0);
} else
{
} else {
#if defined(OPENSSL_SYS_VMS)
i = recv(stdin_sock, cbuf, BUFSIZZ, 0);
#else

View File

@ -2338,7 +2338,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
# if defined(OPENSSL_SYS_VMS)
openssl_fdset(stdin_sock, &readfds);
# else
openssl_fdset(stdin),&readfds);
openssl_fdset(fileno(stdin), &readfds);
# endif
#endif
openssl_fdset(s, &readfds);
@ -2407,7 +2407,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
#if defined(OPENSSL_SYS_VMS)
i=recv(stdin_sock, buf, bufsize / 2, 0);
#else
i = raw_read_stdin(buf, bufsize / 2)
i = raw_read_stdin(buf, bufsize / 2);
#endif
lf_num = 0;
/* both loops are skipped when i <= 0 */
@ -2423,12 +2423,13 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
}
}
assert(lf_num == 0);
} else
} else {
#if defined(OPENSSL_SYS_VMS)
i = recv(stdin_sock, buf, bufsize, 0);
#else
i = raw_read_stdin(buf, bufsize);
#endif
}
if (!s_quiet && !s_brief) {
if ((i <= 0) || (buf[0] == 'Q')) {
BIO_printf(bio_s_out, "DONE\n");

View File

@ -12,7 +12,7 @@
# pragma message disable DOLLARID
#include <openssl/OPENSSLCONF.H>
# include <openssl/opensslconf.h>
# if !defined(_POSIX_C_SOURCE) && defined(OPENSSL_SYS_VMS)
/*
@ -131,8 +131,7 @@ int TermSock,
len;
LogMessage ("Enter 'q' or 'Q' to quit ...");
while (strcasecmp (TermBuff, "Q"))
{
while (strcasecmp (TermBuff, "Q")) {
/*
** Create the terminal socket
*/
@ -172,15 +171,13 @@ $DESCRIPTOR (TerminalDeviceDesc, "SYS$COMMAND");
/*
** Process the requested function code
*/
switch (FunctionCode)
{
switch (FunctionCode) {
case TERM_SOCK_CREATE:
/*
** Create a socket pair
*/
status = CreateSocketPair (AF_INET, SOCK_STREAM, 0, TerminalSocketPair);
if (status == -1)
{
if (status == -1) {
LogMessage ("TerminalSocket: CreateSocketPair () - %08X", status);
if (TerminalSocketPair[0])
close (TerminalSocketPair[0]);
@ -195,8 +192,7 @@ switch (FunctionCode)
status = sys$assign (&TerminalDeviceDesc,
&TerminalDeviceChan,
0, 0, 0);
if (! (status & 1))
{
if (! (status & 1)) {
LogMessage ("TerminalSocket: SYS$ASSIGN () - %08X", status);
close (TerminalSocketPair[0]);
close (TerminalSocketPair[1]);
@ -215,8 +211,7 @@ switch (FunctionCode)
TerminalDeviceBuff,
sizeof (TerminalDeviceBuff) - 2,
0, 0, 0, 0);
if (! (status & 1))
{
if (! (status & 1)) {
LogMessage ("TerminalSocket: SYS$QIO () - %08X", status);
close (TerminalSocketPair[0]);
close (TerminalSocketPair[1]);
@ -234,8 +229,7 @@ switch (FunctionCode)
** Cancel any pending IO on the terminal channel
*/
status = sys$cancel (TerminalDeviceChan);
if (! (status & 1))
{
if (! (status & 1)) {
LogMessage ("TerminalSocket: SYS$CANCEL () - %08X", status);
close (TerminalSocketPair[0]);
close (TerminalSocketPair[1]);
@ -246,8 +240,7 @@ switch (FunctionCode)
** Deassign the terminal channel
*/
status = sys$dassgn (TerminalDeviceChan);
if (! (status & 1))
{
if (! (status & 1)) {
LogMessage ("TerminalSocket: SYS$DASSGN () - %08X", status);
close (TerminalSocketPair[0]);
close (TerminalSocketPair[1]);
@ -285,8 +278,7 @@ return (TERM_SOCK_SUCCESS);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static int CreateSocketPair (
int SocketFamily,
static int CreateSocketPair (int SocketFamily,
int SocketType,
int SocketProtocol,
int *SocketPair)
@ -317,8 +309,7 @@ $DESCRIPTOR (TcpDeviceDesc, "TCPIP$DEVICE");
** Create a socket
*/
SockDesc1 = socket (SocketFamily, SocketType, 0);
if (SockDesc1 < 0)
{
if (SockDesc1 < 0) {
LogMessage ("CreateSocketPair: socket () - %d", errno);
return (-1);
}
@ -336,8 +327,7 @@ sin.sin_port = 0;
** Bind the socket to the local IP
*/
status = bind (SockDesc1, (struct sockaddr *) &sin, slen);
if (status < 0)
{
if (status < 0) {
LogMessage ("CreateSocketPair: bind () - %d", errno);
close (SockDesc1);
return (-1);
@ -347,13 +337,11 @@ if (status < 0)
** Get the socket name so we can save the port number
*/
status = getsockname (SockDesc1, (struct sockaddr *) &sin, &slen);
if (status < 0)
{
if (status < 0) {
LogMessage ("CreateSocketPair: getsockname () - %d", errno);
close (SockDesc1);
return (-1);
}
else
} else
LocalHostPort = sin.sin_port;
/*
@ -368,8 +356,7 @@ sprintf (AscTimeBuff, "0 0:0:%02d.00", SOCKET_PAIR_TIMEOUT_VALUE);
AscTimeDesc.dsc$w_length = strlen (AscTimeBuff);
AscTimeDesc.dsc$a_pointer = AscTimeBuff;
status = sys$bintim (&AscTimeDesc, BinTimeBuff);
if (! (status & 1))
{
if (! (status & 1)) {
LogMessage ("CreateSocketPair: SYS$BINTIM () - %08X", status);
close (SockDesc1);
return (-1);
@ -380,8 +367,7 @@ if (! (status & 1))
** This is the channel that ends up being connected to.
*/
status = sys$assign (&TcpDeviceDesc, &TcpDeviceChan, 0, 0, 0);
if (! (status & 1))
{
if (! (status & 1)) {
LogMessage ("CreateSocketPair: SYS$ASSIGN () - %08X", status);
close (SockDesc1);
return (-1);
@ -402,8 +388,7 @@ status = sys$qio (EFN$C_ENF,
0, 0, 0, 0, 0,
&TcpDeviceChan,
0, 0);
if (! (status & 1))
{
if (! (status & 1)) {
LogMessage ("CreateSocketPair: SYS$QIO () - %08X", status);
close (SockDesc1);
sys$dassgn (TcpDeviceChan);
@ -414,8 +399,7 @@ if (! (status & 1))
** Create the second socket to do the connect
*/
SockDesc2 = socket (SocketFamily, SocketType, 0);
if (SockDesc2 < 0)
{
if (SockDesc2 < 0) {
LogMessage ("CreateSocketPair: socket () - %d", errno);
sys$cancel (TcpAcceptChan);
close (SockDesc1);
@ -430,16 +414,15 @@ sptb.SockChan1 = TcpAcceptChan;
sptb.SockChan2 = decc$get_sdc (SockDesc2);
/*
** Before we block on the connect, set a timer that can cancel I/O on our two
** sockets if it never connects.
** Before we block on the connect, set a timer that can cancel I/O on our
** two sockets if it never connects.
*/
status = sys$setimr (EFN$C_ENF,
BinTimeBuff,
SocketPairTimeoutAst,
&sptb,
0);
if (! (status & 1))
{
if (! (status & 1)) {
LogMessage ("CreateSocketPair: SYS$SETIMR () - %08X", status);
sys$cancel (TcpAcceptChan);
close (SockDesc1);
@ -457,8 +440,7 @@ sin.sin_addr.s_addr = inet_addr (LocalHostAddr) ;
sin.sin_port = LocalHostPort ;
status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof (sin));
if (status < 0 )
{
if (status < 0 ) {
LogMessage ("CreateSocketPair: connect () - %d", errno);
sys$cantim (&sptb, 0);
sys$cancel (TcpAcceptChan);
@ -470,17 +452,16 @@ if (status < 0 )
/*
** Wait for the asynch $QIO to finish. Note that if the I/O was aborted
** (SS$_ABORT), then we probably canceled it from the AST routine - so log a
** timeout.
** (SS$_ABORT), then we probably canceled it from the AST routine - so log
** a timeout.
*/
status = sys$synch (EFN$C_ENF, &iosb);
if (! (iosb.iosb$w_status & 1))
{
if (! (iosb.iosb$w_status & 1)) {
if (iosb.iosb$w_status == SS$_ABORT)
LogMessage ("CreateSocketPair: SYS$QIO(iosb) timeout");
else
{
LogMessage ("CreateSocketPair: SYS$QIO(iosb) - %d", iosb.iosb$w_status);
else {
LogMessage ("CreateSocketPair: SYS$QIO(iosb) - %d",
iosb.iosb$w_status);
sys$cantim (&sptb, 0);
}
close (SockDesc1);
@ -490,9 +471,9 @@ if (! (iosb.iosb$w_status & 1))
}
/*
** Here we're successfully connected, so cancel the timer, convert the I/O
** channel to a socket fd, close the listener socket and return the connected
** pair.
** Here we're successfully connected, so cancel the timer, convert the
** I/O channel to a socket fd, close the listener socket and return the
** connected pair.
*/
sys$cantim (&sptb, 0);
@ -534,7 +515,8 @@ strcat (TerminalDeviceBuff, "\n");
/*
** Send the data read from the terminal device throught the socket pair
*/
send (TerminalSocketPair[0], TerminalDeviceBuff, TerminalDeviceIosb.iosb$w_bcnt + 1, 0);
send (TerminalSocketPair[0], TerminalDeviceBuff,
TerminalDeviceIosb.iosb$w_bcnt + 1, 0);
/*
** Queue another async IO to the terminal device
@ -585,11 +567,13 @@ LocTime = localtime (&CurTime);
** Format the message buffer
*/
sprintf (MsgBuff, "%02d-%s-%04d %02d:%02d:%02d [%08X] %s\n",
LocTime->tm_mday, Month[LocTime->tm_mon], (LocTime->tm_year + 1900),
LocTime->tm_hour, LocTime->tm_min, LocTime->tm_sec, pid, msg);
LocTime->tm_mday, Month[LocTime->tm_mon],
(LocTime->tm_year + 1900), LocTime->tm_hour, LocTime->tm_min,
LocTime->tm_sec, pid, msg);
/*
** Get any variable arguments and add them to the print of the message buffer
** Get any variable arguments and add them to the print of the message
** buffer
*/
va_start (args, msg);
vfprintf (stderr, MsgBuff, args);