From 67a0cdf1c306952a28a25216cd0afde8d658bb13 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 6 May 2007 23:35:45 +0000 Subject: [PATCH] added StrCat stock --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40755 --- plugins/include/string.inc | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/plugins/include/string.inc b/plugins/include/string.inc index d4bae793..7509dbd8 100644 --- a/plugins/include/string.inc +++ b/plugins/include/string.inc @@ -208,6 +208,20 @@ native FloatToString(Float:num, String:str[], maxlength); */ native StrBreak(const String:source[], String:arg[], argLen); +/** + * Finds the first "argument" in a string; either a set of space + * terminated characters, or a fully quoted string. After the + * argument is found, whitespace is read until the next portion + * of the string is reached. If nothing remains, -1 is returned. + * Otherwise, the index to the first character is returned. + * + * @param source Source input string. + * @param arg Stores argument read from string. + * @param argLen Maximum length of argument buffer. + * @return Index to next piece of string, or -1 if none. + */ +native StrBreak(const String:source[], String:arg[], argLen); + /** * Returns the number of bytes a character is using. This is * for multi-byte characters (UTF-8). For normal ASCII characters, @@ -309,4 +323,21 @@ stock CharToLower(chr) return chr; } - +/** + * Concatenates one string onto another. + * + * @param buffer String to append to. + * @param maxlength Maximum length of entire buffer. + * @param source Source string to concatenate. + * @return Number of bytes written. + */ +stock StrCat(String:buffer[], maxlength, const String:source[]) +{ + new len = strlen(source); + if (len >= maxlength) + { + return 0; + } + + return Format(buffer[len], maxlength-len, "%s", source); +}