1 /*
2 This file is part of "Avanor, the Land of Mystery" roguelike game
3 Home page: http://www.avanor.com/
4 Copyright (C) 2000-2003 Vadim Gaidukevich
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "xstring.h"
22
x_strchr(char * str,char c)23 char * x_strchr(char * str, char c)
24 {
25 while(true)
26 {
27 if(*str == 0x1F) { str += 2; continue; }
28 if(*str == c) return str;
29 if(*str++ == 0) return 0;
30 }
31 }
32
x_strlen(const char * str)33 int x_strlen(const char * str)
34 {
35 int count = 0;
36 while(*str != 0)
37 {
38 if(*str == 0x1F) { str += 2; continue; }
39 count++; str++;
40 }
41 return count;
42 }
43
x_strsize(const char * str)44 int x_strsize(const char * str)
45 {
46 int count = 0;
47 while(str[count] != 0) if(str[count++] == 0x1F) count++;
48 return count;
49 }
50
x_strcpy(char * dst,const char * src)51 void x_strcpy(char * dst, const char * src)
52 {
53 while(true)
54 {
55 if(*src == 0x1F) { *dst++ = *src++; *dst++ = *src++; continue; }
56 if((*dst++ = *src++) == 0) return;
57 }
58 }
59