merge with 3.14.12-pre1

This commit is contained in:
zimoch
2013-11-27 13:48:31 +00:00
parent 66bf8d9afe
commit 4782e22cb7
5 changed files with 100 additions and 120 deletions

View File

@@ -545,10 +545,19 @@ iocshBody (const char *pathname, const char *commandLine)
lineno++;
/*
* Ignore comment lines other than to echo
* them if they came from a script.
* Skip leading white-space
*/
if (*raw == '#') {
icin = 0;
while ((c = raw[icin]) && isspace(c)) {
icin++;
}
/*
* Ignore comment lines other than to echo
* them if they came from a script. This
* avoids macLib errors from comments.
*/
if (c == '#') {
if ((prompt == NULL) && (commandLine == NULL))
puts(raw);
continue;
@@ -562,15 +571,28 @@ iocshBody (const char *pathname, const char *commandLine)
continue;
/*
* Echo commands read from scripts
* Skip leading white-space coming from a macro
*/
while ((c = line[icin]) && isspace(c)) {
icin++;
}
/*
* Echo non-empty lines read from a script
*/
if ((prompt == NULL) && *line && (commandLine == NULL))
puts(line);
/*
* Ignore lines that became a comment or empty after macro expansion
*/
if (!c || c == '#')
continue;
/*
* Break line into words
*/
icout = icin = 0;
icout = 0;
inword = 0;
argc = 0;
quote = EOF;

View File

@@ -3,11 +3,10 @@
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd
/* Revision-Id: anj@aps.anl.gov-20131119212622-758nq4pce6q9ahih
*
* Implementation of utility macro substitution library (macLib)
*
@@ -51,11 +50,11 @@ epicsShareAPI macParseDefns(
int quote;
int escape;
size_t nbytes;
const unsigned char **ptr;
const unsigned char **end;
const char **ptr;
const char **end;
int *del;
char *memCp, **memCpp;
const unsigned char *c;
const char *c;
char *s, *d, **p;
enum { preName, inName, preValue, inValue } state;
@@ -68,8 +67,8 @@ epicsShareAPI macParseDefns(
numMax = strlen( defns );
if ( numMax < altNumMax )
numMax = altNumMax;
ptr = (const unsigned char **) calloc( numMax, sizeof( char * ) );
end = (const unsigned char **) calloc( numMax, sizeof( char * ) );
ptr = (const char **) calloc( numMax, sizeof( char * ) );
end = (const char **) calloc( numMax, sizeof( char * ) );
del = (int *) calloc( numMax, sizeof( int ) );
if ( ptr == NULL || end == NULL || del == NULL ) goto error;
@@ -80,7 +79,7 @@ epicsShareAPI macParseDefns(
del[0] = FALSE;
quote = 0;
state = preName;
for ( c = (const unsigned char *) defns; *c != '\0'; c++ ) {
for ( c = (const char *) defns; *c != '\0'; c++ ) {
/* handle quotes */
if ( quote )
@@ -226,8 +225,8 @@ epicsShareAPI macParseDefns(
}
/* free workspace */
free( ptr );
free( end );
free( ( void * ) ptr );
free( ( void * ) end );
free( ( char * ) del );
/* debug output */
@@ -240,8 +239,8 @@ epicsShareAPI macParseDefns(
/* error exit */
error:
errlogPrintf( "macParseDefns: failed to allocate memory\n" );
if ( ptr != NULL ) free( ptr );
if ( end != NULL ) free( end );
if ( ptr != NULL ) free( ( void * ) ptr );
if ( end != NULL ) free( ( void * ) end );
if ( del != NULL ) free( ( char * ) del );
*pairs = NULL;
return -1;

View File

@@ -1,11 +1,10 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* rational replacement for inet_addr()
@@ -13,49 +12,25 @@
* author: Jeff Hill
*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#define epicsExportSharedSymbols
#include "osiSock.h"
#ifndef NELEMENTS
#define NELEMENTS(A) (sizeof(A)/sizeof(A[0]))
#endif /*NELEMENTS*/
/*
* addrArrayToUL ()
*/
static int addrArrayToUL (const unsigned short *pAddr, unsigned nElements, struct in_addr *pIpAddr)
{
unsigned i;
unsigned long addr = 0ul;
for ( i=0u; i < nElements; i++ ) {
if ( pAddr[i] > 0xff ) {
return -1;
}
addr <<= 8;
addr |= pAddr[i];
}
pIpAddr->s_addr = htonl ( addr );
return 0;
}
#include "epicsStdlib.h"
/*
* initIPAddr()
* !! ipAddr should be passed in in network byte order !!
* !! port is passed in in host byte order !!
*/
static int initIPAddr (struct in_addr ipAddr, unsigned short port, struct sockaddr_in *pIP)
static int initIPAddr (struct in_addr ipAddr, unsigned short port,
struct sockaddr_in *pIP)
{
memset (pIP, '\0', sizeof(*pIP));
pIP->sin_family = AF_INET;
pIP->sin_port = htons(port);
pIP->sin_addr = ipAddr;
return 0;
memset(pIP, '\0', sizeof(*pIP));
pIP->sin_family = AF_INET;
pIP->sin_port = htons(port);
pIP->sin_addr = ipAddr;
return 0;
}
/*
@@ -69,68 +44,46 @@ static int initIPAddr (struct in_addr ipAddr, unsigned short port, struct sockad
* "pAddrString" does not contain an address of the form
* "n.n.n.n:p"
*/
epicsShareFunc int epicsShareAPI
aToIPAddr(const char *pAddrString, unsigned short defaultPort, struct sockaddr_in *pIP)
epicsShareFunc int epicsShareAPI
aToIPAddr(const char *pAddrString, unsigned short defaultPort,
struct sockaddr_in *pIP)
{
int status;
unsigned short addr[4];
unsigned long rawAddr;
char hostName[512]; /* !! change n elements here requires change in format below !! */
unsigned short port;
struct in_addr ina;
int status;
char hostName[512]; /* !! change n elements here requires change in format below !! */
char *endp;
unsigned int port;
unsigned long numaddr;
struct in_addr ina;
/*
* dotted ip addresses
*/
status = sscanf (pAddrString, " %hu.%hu.%hu.%hu:%hu",
addr, addr+1u, addr+2u, addr+3u, &port);
if (status>0) {
if (status>=4) {
if ( addrArrayToUL ( addr, NELEMENTS ( addr ), &ina ) < 0 ) {
return -1;
}
if (status==4) {
port = defaultPort;
}
return initIPAddr (ina, port, pIP);
}
else {
return -1;
}
}
/*
* IP address as a raw number
*/
status = sscanf ( pAddrString, " %lu:%hu", &rawAddr, &port );
if (status>=1) {
if ( rawAddr > 0xffffffff ) {
return -1;
}
if ( status == 1 ) {
port = defaultPort;
}
ina.s_addr = htonl ( rawAddr );
return initIPAddr ( ina, port, pIP );
}
/*
* check for a valid host name before giving up
*/
status = sscanf ( pAddrString, " %511[^:]:%hu", hostName, &port );
if ( status >= 1 ) {
if ( status == 1 ) {
port = defaultPort;
}
status = hostToIPAddr ( hostName, &ina );
if ( status == 0 ) {
return initIPAddr ( ina, port, pIP );
}
else {
return -1;
}
}
else {
/*
* Scan for a port number
*/
status = sscanf( pAddrString, " %511[^:]:%u", hostName, &port );
if ( status == 0 ) {
return -1;
}
if ( status == 1 ) {
port = defaultPort;
}
else if (status == 2 && port > 65535) {
return -1;
}
/*
* Look for a valid host name or dotted quad
*/
status = hostToIPAddr( hostName, &ina );
if ( status == 0 ) {
return initIPAddr( ina, port, pIP );
}
/*
* Try the IP address as a decimal integer
*/
numaddr = strtoul( hostName, &endp, 10 );
if (*endp)
return -1;
ina.s_addr = htonl( numaddr );
return initIPAddr( ina, port, pIP );
}

View File

@@ -3,12 +3,14 @@
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*epicsConvert.h*/
#ifndef INC_epicsConvert_H
#define INC_epicsConvert_H
#include <shareLib.h>
#ifdef __cplusplus
@@ -21,3 +23,4 @@ epicsShareFunc float epicsConvertDoubleToFloat(double value);
}
#endif
#endif /* INC_epicsConvert_H */

View File

@@ -3,13 +3,15 @@
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*epicsStdlib.h*/
/*Author: Eric Norum */
#ifndef INC_epicsStdlib_H
#define INC_epicsStdlib_H
#include <shareLib.h>
#ifdef __cplusplus
@@ -26,3 +28,4 @@ epicsShareFunc int epicsScanFloat(const char *str, float *dest);
}
#endif
#endif /* INC_epicsStdlib_H */