string.h
author glx
Sun, 08 Oct 2006 19:31:01 +0000
changeset 4777 bab9aa91c186
parent 4300 c7e43c47a2b9
child 5101 88ee12d71503
permissions -rw-r--r--
(svn r6691) -Fix r3907: check the transport type under the bridge when you want to get the road bits under a bridge (thanx hylje)
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1317
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1317
diff changeset
     2
1317
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
     3
#ifndef STRING_H
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
     4
#define STRING_H
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
     5
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
     6
/*
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
     7
 * dst: destination buffer
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
     8
 * src: string to copy/concatenate
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
     9
 * size: size of the destination buffer
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    10
 * usage: ttd_strlcpy(dst, src, lengthof(dst));
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    11
 */
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    12
void ttd_strlcat(char *dst, const char *src, size_t size);
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    13
void ttd_strlcpy(char *dst, const char *src, size_t size);
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    14
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    15
/*
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    16
 * dst: destination buffer
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    17
 * src: string to copy
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    18
 * last: pointer to the last element in the dst array
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    19
 *       if NULL no boundary check is performed
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    20
 * returns a pointer to the terminating \0 in the destination buffer
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    21
 * usage: strecpy(dst, src, lastof(dst));
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    22
 */
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    23
char* strecat(char* dst, const char* src, const char* last);
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    24
char* strecpy(char* dst, const char* src, const char* last);
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff changeset
    25
2234
8a9b4c6d9c2a (svn r2754) Move str_fmt into string.[ch]
tron
parents: 2186
diff changeset
    26
char* CDECL str_fmt(const char* str, ...);
8a9b4c6d9c2a (svn r2754) Move str_fmt into string.[ch]
tron
parents: 2186
diff changeset
    27
2775
a18db0ab5e51 (svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
Darkvater
parents: 2436
diff changeset
    28
/** Scans the string for valid characters and if it finds invalid ones,
a18db0ab5e51 (svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
Darkvater
parents: 2436
diff changeset
    29
 * replaces them with a question mark '?' */
a18db0ab5e51 (svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
Darkvater
parents: 2436
diff changeset
    30
void str_validate(char *str);
a18db0ab5e51 (svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
Darkvater
parents: 2436
diff changeset
    31
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    32
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    33
 * Valid filter types for IsValidAsciiChar.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    34
 */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    35
typedef enum CharSetFilter {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    36
	CS_ALPHANUMERAL,      //! Both numeric and alphabetic and spaces and stuff
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    37
	CS_NUMERAL,           //! Only numeric ones
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    38
	CS_ALPHA,             //! Only alphabetic values
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    39
} CharSetFilter;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    40
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    41
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    42
 * Only allow certain keys. You can define the filter to be used. This makes
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    43
 *  sure no invalid keys can get into an editbox, like BELL.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    44
 * @param key character to be checked
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    45
 * @param afilter the filter to use
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    46
 * @return true or false depending if the character is printable/valid or not
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    47
 */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    48
bool IsValidAsciiChar(byte key, CharSetFilter afilter);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    49
4200
e6ba94085b81 (svn r5684) - Codechange: create an strtolower() function that uses tolower() on a whole string and apply it in the places this was used.
Darkvater
parents: 2775
diff changeset
    50
/** Convert the given string to lowercase */
e6ba94085b81 (svn r5684) - Codechange: create an strtolower() function that uses tolower() on a whole string and apply it in the places this was used.
Darkvater
parents: 2775
diff changeset
    51
void strtolower(char *str);
e6ba94085b81 (svn r5684) - Codechange: create an strtolower() function that uses tolower() on a whole string and apply it in the places this was used.
Darkvater
parents: 2775
diff changeset
    52
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2234
diff changeset
    53
#endif /* STRING_H */