Beispiel #1
0
u8 *StringAppendN(u8 *dest, const u8 *src, u8 n)
{
    while (*dest != EOS)
        dest++;

    return StringCopyN(dest, src, n);
}
Beispiel #2
0
char_t* StocksValidatePortfolioName(const char_t* portfolio)
{
    ulong_t len = Len(portfolio);
    strip(portfolio, len);
    if (0 == len)
        return NULL;
    return StringCopyN(portfolio, len);
}
Beispiel #3
0
static jc_char* jcc_string_create(const jc_char *value , jc_int startIndex, jc_int length)
{
	jc_int len = 0;
	jc_char* data;

	if(value)
		len = length;
	data = (jc_char*)g_oInterface.Malloc(len + 1);
	StringCopyN(data, &(value[startIndex]), len);
	data[len] = 0;

	return data;
}
Beispiel #4
0
char_t* StocksValidateTicker(const char_t* ticker)
{
    ulong_t len = Len(ticker);
    strip(ticker, len);
    if (0 == len)
        return NULL;
    char_t* t = StringCopyN(ticker, len);
    if (NULL == t)
        return NULL;
          
    for (ulong_t i = 0; i < len; ++i)
        t[i] = toUpper(t[i]);
    return t;
}
Beispiel #5
0
static void AppendVal(CJcScanner* pScanner, CJcToken *pToken)
{
	jc_int reqMem = (pScanner->tlen + 1) * sizeof(jc_char);
	if (((jc_char*) pScanner->pHeapTop + reqMem) >= (jc_char*) pScanner->pHeapEnd)
	{
		if(reqMem > HEAP_BLOCK_SIZE)
		{
			g_oInterface.PrintError(0, "%s\n", "--- Too long token value");
			g_oInterface.Abort();
		}
		CreateHeapBlock(pScanner);
	}
	pToken->val = (jc_char*) pScanner->pHeapTop;
	pScanner->pHeapTop = (void*) ((jc_char*) pScanner->pHeapTop + reqMem);
	StringCopyN(pToken->val, pScanner->tval, pScanner->tlen);
	pToken->val[pScanner->tlen] = '\0';
}
status_t parseUniversalDataFormatTextLine(const char* line, ulong_t len, UniversalDataFormat& out, ulong_t& lineNo, ulong_t& controlDataLength)
{
    long resultLong;
    const char* data = line; 
    UniversalDataFormat::Vector_t vec;
    ErrTry {
        if (lineNo == 0)
        {
            if (errNone != numericValue(data, data + len, resultLong))
                ErrReturn(SocketConnection::errResponseMalformed);

            out.setHeaderSize(resultLong);
        }
        else if (lineNo <= out.headerSize_)
        {
            //read values from vector
            const char* dataOffset = data;
            while (data + len > dataOffset)
            {
                const char* dataOffsetEnd = dataOffset;
                while (dataOffsetEnd < data + len && dataOffsetEnd[0] != ' ')
                    dataOffsetEnd++;
                    
                if (errNone != numericValue(dataOffset, dataOffsetEnd, resultLong))
		          ErrReturn(SocketConnection::errResponseMalformed);

                vec.push_back(resultLong);
                controlDataLength += resultLong + 1;
                dataOffset = dataOffsetEnd + 1;
            }
            out.header_.push_back(vec);
        }
        else
        {
            if (lineNo == out.headerSize_ + 1)
            {
                free(out.data_);
                out.dataLen_ = 0; 
                out.data_ = StringCopyN(line, len);
                if (NULL == out.data_)
					ErrReturn(memErrNotEnoughSpace);
						
				out.dataLen_ = len; 
            } 
            else
            {
				out.data_ = StrAppend(out.data_, out.dataLen_, "\n", 1);
				if (NULL == out.data_)
					ErrReturn(memErrNotEnoughSpace);
				
				++out.dataLen_;
				out.data_ = StrAppend(out.data_, out.dataLen_, line, len);
				if (NULL == out.data_)
					ErrReturn(memErrNotEnoughSpace);
					
				out.dataLen_ += len;
            }
        }
        lineNo++;
    }
    ErrCatch (ex) {
        return ex;
    } ErrEndCatch
    return errNone;
}