]>
jfr.im git - irc/gameservirc.git/blob - gameserv/strings.cpp
1 /* This file contains functions dealing with strings */
8 char *strtok(char *str
, const char *delim
);
11 int stricmp(const char *s1
, const char *s2
);
12 int strnicmp(const char *s1
, const char *s2
, size_t len
);
15 int stricmp(const char *s1
, const char *s2
)
19 while ((c
= tolower(*s1
)) == tolower(*s2
)) {
32 char *spaces(int len
, char *seperator
)
37 strcpy(final
, seperator
);
38 for (y
= 0; y
< 30 - len
; y
++)
39 strcat(final
, seperator
);
45 int strnicmp(const char *s1
, const char *s2
, size_t len
)
51 while ((c
= tolower(*s1
)) == tolower(*s2
) && len
> 0) {
52 if (c
== 0 || --len
== 0)
63 char *strtok(char *str
, const char *delim
)
65 static char *current
= NULL
;
72 current
+= strspn(current
, delim
);
73 ret
= *current
? current
: NULL
;
74 current
+= strcspn(current
, delim
);
83 int isstringnum(char *num
)
86 for (x
= 0; x
< strlen(num
); x
++)
88 if ((int)num
[x
] < 48 || (int)num
[x
] > 57)
94 long int stringtoint(char *number
)
99 long int pow(int x
, int y
)
105 if (x
!= 0 && y
!= 0)
107 for (count
= 1; count
<= y
- 1; count
++)
117 long int chartoint(char ch
)
119 if (int(ch
) >= 48 && int(ch
) <= 57)