|
From: <wsh...@us...> - 2003-08-08 14:53:52
|
Update of /cvsroot/emc/rcslib/src/print
In directory sc8-pr-cvs1:/tmp/cvs-serv6081
Added Files:
Tag: wps_multiplat_dev_branch
sepwords.cc
Log Message:
.
--- NEW FILE: sepwords.cc ---
#if HAVE_CONFIG_H
#include "rcs_config_include.h"
#else
#include "rcs_defs.hh"
#include <stdlib.h>
#include <string.h>
#endif
#include "rcs_prnt.hh"
/* In windows DLLs for Microsoft Visual C++ sscanf is not supported so
use separate_words to parse the string followed by commands like strtod to
convert each word. */
int RCS_EXPORT
separate_words (char RCS_FAR ** _dest, int _max, char RCS_FAR * _src)
{
static char word_buffer[256];
int i;
if (NULL == _dest || NULL == _src)
{
return -1;
}
if (strlen (_src) > 255)
{
rcs_print_error("separate_words string to long (%s)\n",_src);
return -1;
}
strcpy (word_buffer, _src);
for(i = 0; i < _max ; i++)
{
_dest[i]=0;
}
_dest[0] = strtok (word_buffer, " \n\r\t");
for (i = 0; NULL != _dest[i] && i < _max - 1; i++)
{
_dest[i + 1] = strtok (NULL, " \n\r\t");
}
if (_dest[_max - 1] == NULL && i == _max - 1)
{
i--;
}
return (i + 1);
}
|