diff options
author | flaviojs <flaviojs@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-06-16 10:22:35 +0000 |
---|---|---|
committer | flaviojs <flaviojs@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-06-16 10:22:35 +0000 |
commit | e054cbbdb28a9b555faafd689282140c01d55b3e (patch) | |
tree | a0a637c944d902df0086900009a644c5b84d39e2 /src/common/strlib.h | |
parent | 83c890478d5588179ffd81b29a95d4bafd0fb118 (diff) | |
download | hercules-e054cbbdb28a9b555faafd689282140c01d55b3e.tar.gz hercules-e054cbbdb28a9b555faafd689282140c01d55b3e.tar.bz2 hercules-e054cbbdb28a9b555faafd689282140c01d55b3e.tar.xz hercules-e054cbbdb28a9b555faafd689282140c01d55b3e.zip |
* Merges from charmerge:
- Added DBMap::exists. (r14090)
- Added sv_parse_next, a stepped version of sv_parse (delim-separated parser). (r14100 r14104)
- Added missing fd check to do_close. (r14145)
- Normalized, refactored and restructured some code (in preparation for shutdown/reconnect code). (r14145 r14150)
- Changed the char select request code to allow the char-server to reject it. (player in map-server trying to go to char select) (r14150)
- Added shutdown support to the servers. (incomplete) (r14152)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14851 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/strlib.h')
-rw-r--r-- | src/common/strlib.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common/strlib.h b/src/common/strlib.h index 3f4f984cf..f5819bbcb 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -78,6 +78,27 @@ typedef enum e_svopt /// Other escape sequences supported by the C compiler. #define SV_ESCAPE_C_SUPPORTED "abtnvfr\?\"'\\" +/// Parse state. +/// The field is [start,end[ +struct s_svstate +{ + const char* str; //< string to parse + int len; //< string length + int off; //< current offset in the string + int start; //< where the field starts + int end; //< where the field ends + enum e_svopt opt; //< parse options + char delim; //< field delimiter + bool done; //< if all the text has been parsed +}; + +/// Parses a single field in a delim-separated string. +/// The delimiter after the field is skipped. +/// +/// @param sv Parse state +/// @return 1 if a field was parsed, 0 if done, -1 on error. +int sv_parse_next(struct s_svstate* sv); + /// Parses a delim-separated string. /// Starts parsing at startoff and fills the pos array with position pairs. /// out_pos[0] and out_pos[1] are the start and end of line. |