File r38/lisp/csl/cslbase/wstring.h artifact ee8be6c1ff part of check-in b5833487d7


/*
wstring.h

Copyright (C) 2003-2006 Gil Dabah, http://ragestorm.net/distorm/
This library is licensed under the BSD license. See the file COPYING.
*/


#ifndef ___WSTRING_H__
#define ___WSTRING_H__

#include <string.h>

#include "diconfig.h"

// Make sure the buffer isn't overflowed.
#define MAX_TEXT_SIZE (60)

typedef struct {
	unsigned int pos;
	unsigned char p[MAX_TEXT_SIZE];
} _WString;

// Warning, this macro should be used only when the compiler knows the size of string in advance!
// This macro is used in order to spare the call to strlen when the strings are known already.
// Note: sizeof includes NULL terminated character.
#define strcat_WSN(s, t) strcatlen_WS((s), (t), sizeof((t))-1)
#define strcpy_WSN(s, t) strcpylen_WS((s), (t), sizeof((t))-1)

void _FASTCALL_ strcpy_WS(_WString* s, const char* buf);
void _FASTCALL_ strcpylen_WS(_WString* s, const char* buf, unsigned int len);
void _FASTCALL_ strcatlen_WS(_WString* s, const char* buf, unsigned int len);

_INLINE_ void strclear_WS(_WString* s)
{
	s->p[0] = '\0';
	s->pos = 0;
}

_INLINE_ void chrcat_WS(_WString* s, unsigned char ch)
{
	s->p[s->pos] = ch;
	s->p[s->pos + 1] = '\0';
	s->pos += 1;
}


#endif // ___WSTRING_H__


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]