Merge branch '7.0' into PSI-7.0

This commit is contained in:
2023-08-21 14:14:16 +02:00
37 changed files with 1657 additions and 59 deletions
+6 -1
View File
@@ -113,8 +113,8 @@ int main(void)
pserver->pfdctx = (void *) fdmgr_init();
if (!pserver->pfdctx) {
free(pserver);
fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
free(pserver);
return IOCLS_ERROR;
}
@@ -149,6 +149,7 @@ int main(void)
fprintf (stderr,
"iocLogServer: a server is already installed on port %u?\n",
(unsigned)ioc_log_port);
free(pserver);
return IOCLS_ERROR;
}
@@ -158,6 +159,7 @@ int main(void)
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
fprintf(stderr, "iocLogServer: listen err %s\n", sockErrBuf);
free(pserver);
return IOCLS_ERROR;
}
@@ -174,6 +176,7 @@ int main(void)
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
fprintf(stderr, "iocLogServer: ioctl FIONBIO err %s\n", sockErrBuf);
free(pserver);
return IOCLS_ERROR;
}
@@ -190,6 +193,7 @@ int main(void)
"File access problems to `%s' because `%s'\n",
ioc_log_file_name,
strerror(errno));
free(pserver);
return IOCLS_ERROR;
}
@@ -202,6 +206,7 @@ int main(void)
if (status < 0) {
fprintf(stderr,
"iocLogServer: failed to add read callback\n");
free(pserver);
return IOCLS_ERROR;
}
+6 -2
View File
@@ -30,6 +30,7 @@ macDefExpand(const char *str, MAC_HANDLE *macros)
static const char * pairs[] = { "", "environ", NULL, NULL };
long destCapacity = 128;
char *dest = NULL;
char *newdest = NULL;
int n;
if (macros) {
@@ -61,8 +62,11 @@ macDefExpand(const char *str, MAC_HANDLE *macros)
} else {
size_t unused = destCapacity - ++n;
if (unused >= 20)
dest = realloc(dest, n);
if (unused >= 20) {
newdest = realloc(dest, n);
if (newdest)
dest = newdest;
}
}
done:
+2 -2
View File
@@ -87,8 +87,8 @@ LIBCOM_API int
* \brief Convert a string to a double type
*
* \param str Pointer to a constant character array
* \param to Pointer to the specified type (this will be set during the conversion)
* \param units Pointer to a char * (this will be set with the units string)
* \param to Pointer to the specified type (this will be set only upon successful conversion)
* \param units Pointer to a char * (this will be set with the units string only upon successful conversion)
* \return Status code (0=OK, see macro definitions for possible errors)
*/
LIBCOM_API int
+24 -12
View File
@@ -231,27 +231,39 @@ int epicsStrPrintEscaped(FILE *fp, const char *s, size_t len)
{
int nout = 0;
if (fp == NULL)
return -1;
if (s == NULL || strlen(s) == 0 || len == 0)
return 0; // No work to do
while (len--) {
char c = *s++;
int rc = 0;
switch (c) {
case '\a': nout += fprintf(fp, "\\a"); break;
case '\b': nout += fprintf(fp, "\\b"); break;
case '\f': nout += fprintf(fp, "\\f"); break;
case '\n': nout += fprintf(fp, "\\n"); break;
case '\r': nout += fprintf(fp, "\\r"); break;
case '\t': nout += fprintf(fp, "\\t"); break;
case '\v': nout += fprintf(fp, "\\v"); break;
case '\\': nout += fprintf(fp, "\\\\"); break;
case '\'': nout += fprintf(fp, "\\'"); break;
case '\"': nout += fprintf(fp, "\\\""); break;
case '\a': rc = fprintf(fp, "\\a"); break;
case '\b': rc = fprintf(fp, "\\b"); break;
case '\f': rc = fprintf(fp, "\\f"); break;
case '\n': rc = fprintf(fp, "\\n"); break;
case '\r': rc = fprintf(fp, "\\r"); break;
case '\t': rc = fprintf(fp, "\\t"); break;
case '\v': rc = fprintf(fp, "\\v"); break;
case '\\': rc = fprintf(fp, "\\\\"); break;
case '\'': rc = fprintf(fp, "\\'"); break;
case '\"': rc = fprintf(fp, "\\\""); break;
default:
if (isprint(0xff & (int)c))
nout += fprintf(fp, "%c", c);
rc = fprintf(fp, "%c", c);
else
nout += fprintf(fp, "\\x%02x", (unsigned char)c);
rc = fprintf(fp, "\\x%02x", (unsigned char)c);
break;
}
if (rc < 0) {
return rc;
} else {
nout += rc;
}
}
return nout;
}
@@ -41,12 +41,17 @@ epicsMessageQueueCreate(unsigned int capacity, unsigned int maximumMessageSize)
{
struct mq_attr the_attr;
epicsMessageQueueId id = (epicsMessageQueueId)calloc(1, sizeof(*id));
if (!id) {
fprintf (stderr, "Can't allocate message queue: %s\n", strerror(errno));
return NULL;
}
sprintf(id->name, "MQ_%0d", epicsAtomicIncrIntT(&idCnt));
the_attr.mq_maxmsg = capacity;
the_attr.mq_msgsize = maximumMessageSize;
id->id = mq_open(id->name, O_RDWR | O_CREAT | O_EXCL, 0644, &the_attr);
if (id->id <0) {
fprintf (stderr, "Can't create message queue: %s\n", strerror (errno));
free(id);
return NULL;
}
return id;