/*
This file is part of a common library
Copyright (C) 2002-6 Toby Thain, toby@telegraphics.com.au
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#include <stdlib.h>
#include "str.h"
#include "sprintf_tiny.h"
// convert C (null-terminated) to Pascal (length byte) string
// no bounds checking
unsigned char *myc2pstr(char *s){
*s = (unsigned char)n;
return (unsigned char*)s;
}
// convert Pascal string to C string
// no bounds checking
char *myp2cstr(unsigned char *s){
int n = *s;
s[n] = 0;
return (char*)s;
}
// copy Pascal string to C string
// no bounds checking
char *myp2cstrcpy(char *dst,const unsigned char *src){
dst[src[0]] = 0;
return dst;
}
unsigned char *myc2pstrcpy(unsigned char *dst,const char *src){
*dst = n <= 255 ? (unsigned char)n : 255;
return dst;
}
// copy null-terminated string;
// returns pointer after last character copied
char *cat(char *d,char *s){
while( (*d = *s++) )
d++;
return d;
}
void *my_memset(void *dst, int val, size_t len){
char *p;
for(p=(char*)dst;len--;)
*p++ = val;
return dst;
}
char *my_strdup(char *s){
if(p)
return p;
}
unsigned char *PLcstrcpy(unsigned char *s1,const char *s2){
if(n>255)
n = 255;
*s1 = (unsigned char)n;
return s1;
}
unsigned char *PLcstrcat(unsigned char * str1,const char * s2){
if(str1[0]+n > 255)
n = 255 - str1[0];
str1[0] += (unsigned char)n;
return str1;
}