More FTP client debug fixes

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3662 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2011-06-02 23:45:31 +00:00
parent 134a1a930e
commit 2c351f21eb
4 changed files with 32 additions and 13 deletions
+3
View File
@@ -322,12 +322,14 @@ CONFIG_HAVE_LIBM=n
# thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
# CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up
# the worker thread. Default: 4
# CONFIG_SCHED_WAITPID - Enable the waitpid() function
#
#CONFIG_APPS_DIR=
CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_SYMBOLS=n
CONFIG_DEBUG_NET=n
CONFIG_DEBUG_FTPC=y
CONFIG_MM_REGIONS=2
CONFIG_ARCH_LOWPUTC=y
CONFIG_RR_INTERVAL=200
@@ -352,6 +354,7 @@ CONFIG_SCHED_WORKPRIORITY=50
CONFIG_SCHED_WORKPERIOD=(50*1000)
CONFIG_SCHED_WORKSTACKSIZE=1024
CONFIG_SIG_SIGWORK=4
CONFIG_SCHED_WAITPID=y
#
# Settings for NXFLAT
+20 -11
View File
@@ -99,18 +99,22 @@ int asprintf (FAR char **ptr, const char *fmt, ...)
struct lib_memoutstream_s memoutstream;
FAR char *buf;
va_list ap;
int n;
int nbytes;
DEBUGASSERT(ptr && fmt);
/* First, use a nullstream to get the size of the buffer */
/* First, use a nullstream to get the size of the buffer. The number
* of bytes returned may or may not include the null terminator.
*/
lib_nulloutstream(&nulloutstream);
va_start(ap, fmt);
n = lib_vsprintf((FAR struct lib_outstream_s *)&nulloutstream, fmt, ap);
nbytes = lib_vsprintf((FAR struct lib_outstream_s *)&nulloutstream, fmt, ap);
va_end(ap);
/* Then allocate a buffer to hold that number of characters */
/* Then allocate a buffer to hold that number of characters, adding one
* for the null terminator.
*/
buf = (FAR char *)malloc(nulloutstream.nput + 1);
if (!buf)
@@ -118,24 +122,29 @@ int asprintf (FAR char **ptr, const char *fmt, ...)
return ERROR;
}
/* Initialize a memory stream to write into the allocated buffer */
/* Initialize a memory stream to write into the allocated buffer. The
* memory stream will reserve one byte at the end of the buffer for the
* null terminator and will not report this in the number of output bytes.
*/
lib_memoutstream((FAR struct lib_memoutstream_s *)&memoutstream,
buf, nulloutstream.nput);
buf, nulloutstream.nput + 1);
/* Then let lib_vsprintf do it's real thing */
va_start(ap, fmt);
n = lib_vsprintf((FAR struct lib_outstream_s *)&memoutstream.public, fmt, ap);
nbytes = lib_vsprintf((FAR struct lib_outstream_s *)&memoutstream.public, fmt, ap);
va_end(ap);
/* Terminate the string and return a pointer to the string to the caller.
/* Return a pointer to the string to the caller. NOTE: the memstream put()
* method has already added the NUL terminator to the end of the string (not
* included in the nput count).
*
* Hmmm.. looks like the memory would be stranded if lib_vsprintf() returned
* an error. Does that ever happen?
*/
DEBUGASSERT(n < 0 || n == nulloutstream.nput);
buf[nulloutstream.nput] = '\0';
DEBUGASSERT(nbytes < 0 || nbytes == nulloutstream.nput);
*ptr = buf;
return n;
return nbytes;
}
+1 -1
View File
@@ -52,7 +52,7 @@ static int meminstream_getc(FAR struct lib_instream_s *this)
FAR struct lib_meminstream_s *mthis = (FAR struct lib_meminstream_s *)this;
int ret;
if (this && this->nget < mthis->buflen - 1)
if (this && this->nget < mthis->buflen)
{
ret = mthis->buffer[this->nget];
this->nget++;
+8 -1
View File
@@ -50,7 +50,13 @@
static void memoutstream_putc(FAR struct lib_outstream_s *this, int ch)
{
FAR struct lib_memoutstream_s *mthis = (FAR struct lib_memoutstream_s *)this;
if (this && this->nput < mthis->buflen - 1)
/* If this will not overrun the buffer, then write the character to the
* buffer. Not that buflen was pre-decremented when the stream was
* created so it is okay to write past the end of the buflen by one.
*/
if (this && this->nput < mthis->buflen)
{
mthis->buffer[this->nput] = ch;
this->nput++;
@@ -89,6 +95,7 @@ void lib_memoutstream(FAR struct lib_memoutstream_s *memoutstream,
memoutstream->public.nput = 0; /* Will be buffer index */
memoutstream->buffer = bufstart; /* Start of buffer */
memoutstream->buflen = buflen - 1; /* Save space for null terminator */
memoutstream->buffer[0] = '\0'; /* Start with an empty string */
}