fprintf returns a negative value in order to signal an error. We have to
detect this situation in epicsStrPrintEscaped and return a negative
when fprintf returns a negative value in order to give the calling code
a chance to detect this situation.
The old implementation (of simply accumulating the return values of
fprintf) was wrong anyway, because it would not only lead to an error in
fprintf to be lost but would also cause the returned number to be too
small (not representing the actual number of bytes written) in such a
case.
The only case where the old implementation would work correctly was when
all calls to fprintf succeeded or all these calls failed.
There were already some comments here, but they were missing a doxygen
\file declaration, so the annotations weren't shown in the doxygen
output.
Also added some formatting for the code example and definition of MAIN macro.
These changes to the functions epicsStrnRawFromEscaped() and
epicsStrnEscapedFromRaw() were prompted by the addition of JSON5
support to the dbStatic parser.
* \0 now represents a zero byte
* Unprintable characters are now escaped in hex
Tests for the octal escapes have been removed.
\x only takes 2 hex digits now, and the octal parser ignores a 3rd
digit if it would take the value over 0xff:
"\400" => ' ' then '0'
"\x088" => '\b' then '8'
With additional tests.
In some cases the license-identification header was missing,
so I added that as well. Replaced the remaining headers that
specifically identified "Versions 3.13.7 and higher".
Makefiles and the build system were deliberately excluded.
For linux, enable softIoc to find .dbd relative to the executable
location.
The same could be done for other targets
*bsd
may have symlink /proc/curproc/file
fallback to sysctl() with KERN_PROC_PATHNAME
solaris
getexecname()
mac
_NSGetExecutablePath()
WIN32
GetModuleFileName(NULL)
others
out of luck...