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()) else if (_kbhit())
#elif defined(OPENSSL_SYS_BEOS_R5) #elif defined(OPENSSL_SYS_BEOS_R5)
else if (stdin_set) else if (stdin_set)
#else #elif defined(OPENSSL_SYS_VMS)
#if defined(OPENSSL_SYS_VMS)
else if (FD_ISSET(stdin_sock, &readfds)) else if (FD_ISSET(stdin_sock, &readfds))
#else #else
else if (FD_ISSET(fileno(stdin), &readfds)) else if (FD_ISSET(fileno(stdin), &readfds))
#endif
#endif #endif
{ {
if (crlf) { if (crlf) {
int j, lf_num; int j, lf_num;
i = raw_read_stdin(cbuf, BUFSIZZ / 2);
#if defined(OPENSSL_SYS_VMS) #if defined(OPENSSL_SYS_VMS)
i = recv(stdin_sock, cbuf, BUFSIZZ / 2, 0); i = recv(stdin_sock, cbuf, BUFSIZZ / 2, 0);
#else #else
@ -2062,8 +2057,7 @@ int MAIN(int argc, char **argv)
} }
} }
assert(lf_num == 0); assert(lf_num == 0);
} else } else {
{
#if defined(OPENSSL_SYS_VMS) #if defined(OPENSSL_SYS_VMS)
i = recv(stdin_sock, cbuf, BUFSIZZ, 0); i = recv(stdin_sock, cbuf, BUFSIZZ, 0);
#else #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) # if defined(OPENSSL_SYS_VMS)
openssl_fdset(stdin_sock, &readfds); openssl_fdset(stdin_sock, &readfds);
# else # else
openssl_fdset(stdin),&readfds); openssl_fdset(fileno(stdin), &readfds);
# endif # endif
#endif #endif
openssl_fdset(s, &readfds); 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) #if defined(OPENSSL_SYS_VMS)
i=recv(stdin_sock, buf, bufsize / 2, 0); i=recv(stdin_sock, buf, bufsize / 2, 0);
#else #else
i = raw_read_stdin(buf, bufsize / 2) i = raw_read_stdin(buf, bufsize / 2);
#endif #endif
lf_num = 0; lf_num = 0;
/* both loops are skipped when i <= 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); assert(lf_num == 0);
} else } else {
#if defined(OPENSSL_SYS_VMS) #if defined(OPENSSL_SYS_VMS)
i = recv(stdin_sock, buf, bufsize, 0); i = recv(stdin_sock, buf, bufsize, 0);
#else #else
i = raw_read_stdin(buf, bufsize); i = raw_read_stdin(buf, bufsize);
#endif #endif
}
if (!s_quiet && !s_brief) { if (!s_quiet && !s_brief) {
if ((i <= 0) || (buf[0] == 'Q')) { if ((i <= 0) || (buf[0] == 'Q')) {
BIO_printf(bio_s_out, "DONE\n"); BIO_printf(bio_s_out, "DONE\n");

View File

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