summaryrefslogtreecommitdiff
path: root/src/common/strlib.h
AgeCommit message (Collapse)AuthorFilesLines
2020-01-13Update copyright headers for year 2020Haru1-2/+2
Signed-off-by: Haru <haru@dotalux.com>
2018-08-25Add const-safe wrappers for strchr(), strrchr() and strstr() using c11 genericsHaru1-0/+21
C99 compilers will still use the normal, const-unsafe, version Signed-off-by: Haru <haru@dotalux.com>
2018-05-312012-2018 !Maytichai Saowa1-1/+1
2016-05-08Removed some legacy checks for MSVC <= 2003Haru1-2/+2
Signed-off-by: Haru <haru@dotalux.com>
2016-04-16Added const qualifier to the input parameter of bin2hexHaru1-2/+2
Signed-off-by: Haru <haru@dotalux.com>
2015-12-15Added GPL-compliant header to all sources and build scriptsHaru1-4/+20
Signed-off-by: Haru <haru@dotalux.com>
2015-08-15HPM compatibility improvementsHaru1-7/+5
Improved compatibility, portability and standards conformance. - Since it is not possible to portably and reliably re-use the core's symbols in plugins, symbols are no longer exported unless explicitly required, in the UNIX builds. This mimics the Windows behavior and adds HPM compatibility to OSes such as FreeBSD. Credits to Andrei Karas for making this possible. - For convenience, it is no longer necessary to call GET_SYMBOL, since the plugin will automatically import all the available symbols when it's loaded, depending on the included headers. - Plugins are now supposed to include the "common/hercules.h" header before including anything else. Incluing common/HPMi.h, common/cbasetypes.h or conf/core.h is no longer necessary, as those are guaranteed to be automatically included by hercules.h. - HPM API version bumped to 1.1. Signed-off-by: Haru <haru@dotalux.com>
2015-08-15Cleaned up strlib interfaceHaru1-43/+34
- Replaced some macro calls with the proper interface syntax - Removed useless macros and workarounds - Removed no longer needed library function re-definitions API changes summary: - The macros remove_control_chars(), trim(), normalize_name(), stristr(), e_mail_check(), config_switch(), safestrncpy(), safestrnlen(), safesnprintf(), strline(), bin2hex() can now be safely used both inside and outside strlib.c - The macros strnlen() and strtok_r() can now be safely used both inside and outside strlib.c, on the systems where they are necessary. The systems that provide those natively, aren't affected by this change. - jstrescape() is now strlib->jstrescape() - jstrescapecpy() is now strlib->jstrescapecpy() - jmemescapecpy() is now strlib->jmemescapecpy() - a custom strtoull() implementation is no longer provided, since all supported systems and compilers provide a library implementation. Signed-off-by: Haru <haru@dotalux.com>
2015-06-19Removed ".." from include directivesHaru1-2/+2
- Include directives are now directory-independent. - This will allow building plugins from other directories in future. Signed-off-by: Haru <haru@dotalux.com>
2015-01-12Blocked compilation of plugins that use unavailable functionsHaru1-0/+2
- Rather than failing at runtime, plugins that try to access non-interfaced, unavailable functions or variables, will now show an error at compile-time. Signed-off-by: Haru <haru@dotalux.com>
2014-11-16Whitespace cleanup (no code changes)Haru1-13/+13
This includes, and is not limited to: mixed or wrong indentation, excess whitespace (horizontal and vertical), misalignment, trailing spaces. Signed-off-by: Haru <haru@dotalux.com>
2014-11-16Moved strlib_s, stringbuf_s and sv_s into strlib.cHaru1-3/+3
Signed-off-by: Haru <haru@dotalux.com>
2014-08-07Corrected several format-string errors through the codeHaru1-2/+2
- Functions that expect a printf-style format string are now marked as such, so that gcc/clang will emit a warning warn you if you mismatch format string and arguments. Signed-off-by: Haru <haru@dotalux.com>
2014-07-11Fixed reserved __identifier violationsHaru1-7/+7
- Complies with CERT DCL37-C - Fixes issue #293 (special thanks to elfring) Signed-off-by: Haru <haru@dotalux.com>
2014-05-30Fixed typos inside src/Shido1-5/+5
2014-05-25Improved CFLAGS/CPPFLAGS handlingHaru1-8/+1
- Language extensions, such as _GNU_SOURCE are now enabled through CPPFLAGS by the configure script, rather than within the source code. - Moved some configure-time CFLAGS to CPPFLAGS, where appropriate. - Fixes bugreport:8211, thanks to Neoth http://hercules.ws/board/tracker/issue-8211-compiling-warning-in-linux Signed-off-by: Haru <haru@dotalux.com>
2014-05-10Re-commit of "Fixed order of includes in all source files"Haru1-7/+8
This reverts commit 94657284973f4037596bae468ebfbee5c217e02b.
2014-05-10Revert "Fixed order of includes in all source files"panikon1-8/+7
This reverts commit b6b3f58795288701d0e162d43fa6f0a47af913b3. Fixes issue 8184 http://hercules.ws/board/tracker/issue-8184-cart-related/
2014-05-09Fixed order of includes in all source filesHaru1-7/+8
- Changed order according to the (upcoming) code style guidelines. - Fixes several issues caused by missing headers when their include order is changed or in plugins. Signed-off-by: Haru <haru@dotalux.com>
2014-02-02Introducing HPM Datacheckshennetsind1-3/+3
http://hercules.ws/board/topic/4283-introducing-hpm-datacheck/ Signed-off-by: shennetsind <ind@henn.et>
2014-01-23Minor fixes to the strlib interfaceHaru1-1/+1
- Fixed a typo in the strnlen() macro (was strnln) - Initialized strlib->strnlen and strlib->strtoull to NULL on platforms that don't require them. Please note that those two functions are supposed to never be called directly but only through the strnlen() and strtoull() macros, which take care of the platform abstraction. - Removed localized versions of yes/no from config_switch (if you really want to be able to use "oui", "ja", "si", "non", "nein", feel free to add them back yourself following the example in strlib.c) Signed-off-by: Haru <haru@dotalux.com>
2014-01-18Socket interfacedshennetsind1-0/+1
We designed this one with having as little changes required elsewhere in mind, thus the way most socket-related things are called has not changed. Plugins may now take a greater advantage of the socket features. Signed-off-by: shennetsind <ind@henn.et>
2014-01-18Modified strlib interface to be compliant with hpmhooksshennetsind1-5/+3
aka no #ifdef within the interface. Thanks to Haruna. Signed-off-by: shennetsind <ind@henn.et>
2013-11-19Sanitized and improved several macros through the codeHaru1-16/+16
- Sanitized all potentially unsafe macros (related eA:15259) - Improved some function-like macros to evaluate their argument only once and keep it in a temporary variable. This improves performance in the damage calculation related code. Signed-off-by: Haru <haru@dotalux.com>
2013-09-25Renamed more forgotten variables during interface conversionsHaru1-2/+2
(related: b9c8f57) Most renames are trivial (just to avoid shadowing global variables, even if they currently did no harm), but there were some cases of partly renamed variables that caused some NULL checks to always pass and who knows what could have been happened when they were too subtle to make the application crash. Also corrected some potentially unsafe macro definitions Signed-off-by: Haru <haru@dotalux.com>
2013-06-14Fixed the '"__USE_GNU" redefined' warnings on selected platformsshennetsind1-3/+7
Special Thanks to Takkun~! Signed-off-by: shennetsind <ind@henn.et>
2013-05-15Fixed Bug #7246shennetsind1-1/+1
http://hercules.ws/board/tracker/issue-7246-compiling-in-vstudio/ Signed-off-by: shennetsind <ind@henn.et>
2013-05-15HPM Updateshennetsind1-104/+140
Made SQL and strlib functions HPM-friendly, special thanks to Yommy for bringing the issue up. Added partial map.c support, for the all-handy map[] array, beware that soon the whole map.c renewal design will be commit and when that happens your usage of map.c functions in plugins might require some updates. Signed-off-by: shennetsind <ind@henn.et>
2012-12-05- Undid r16968: SVN Replaced with source:/trunk/src/@16966 (tid:74924).brianluau1-58/+61
[16969:16991/trunk/src/] will be re-committed in the next 24 hours. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16992 54d463be-8e91-2dee-dedb-b68131a5f0ec
2012-11-25Applied AStyle code formating as discussed on tid:74602.greenboxal21-61/+58
Removed /SAFESEH option from MSVC11 projects. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16968 54d463be-8e91-2dee-dedb-b68131a5f0ec
2011-06-30Removed extra guards around cbasetypes.h include lines, since they give no ↵ultramage1-2/+0
performance improvement. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14876 54d463be-8e91-2dee-dedb-b68131a5f0ec
2011-06-16* Merges from charmerge:flaviojs1-0/+21
- 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
2011-02-16* Updated configure/make scripts to resolve various issues.ai4rei1-1/+5
- Added detection whether or not -fPIC switch is required when compiling shared objects (plug-ins) to resolve compile issues on 64-bit platforms (topic:208746). - Native 'strnlen' implementations are now detected and disable the one in strlib (bugreport:1261). - Define 'DB_MANUAL_CAST_TO_UNION' is now set when necessary (bugreport:1261). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14708 54d463be-8e91-2dee-dedb-b68131a5f0ec
2010-11-19* Various VC6-related fixes and tweaks. [Ai4rei]ai4rei1-1/+1
- Fixed a typo in VC6 project files, that prevented login-server from compiling (bugreport:4061, since r12727). - Fixed usage of 'long long' in Sql_P_BindSqlDataType preventing SQL VC6 projects from compiling (bugreport:1741, since r10779). - Fixed usage of 'long long' in strtoull preventing VC6 projects from compiling (bugreport:4059, follow up to r14245). - Made strtoull default to base 10 and actually process base 8, to match the normal behavior of this function (bugreport:4059, follow up to r14245). - Fixed functions in db.c not being returned as pointer, causing warnings on VC6. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14466 54d463be-8e91-2dee-dedb-b68131a5f0ec
2010-02-15Added visual studio equivalent of libc's strtoull() - name redefine for ↵ultramage1-0/+4
newer VS versions, custom implementation for VS6 (I hope it works). This should fix the compilation error from r14242 (bugreport:4059). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14245 54d463be-8e91-2dee-dedb-b68131a5f0ec
2009-04-20* Fixed safestrncpy trashing the memory before dst when n == 0. (since ↵FlavioJS1-1/+1
r10667, bugreport:2996) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13681 54d463be-8e91-2dee-dedb-b68131a5f0ec
2008-08-09Fixed login printing raw passwdenc passwords to console (bugreport:826).ultramage1-0/+4
Added strlib function bin2hex(). Cleaned up the md5calc interface a bit. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13055 54d463be-8e91-2dee-dedb-b68131a5f0ec
2008-04-23* Fixed script strings not being handled properly (only skipped the \).FlavioJS1-0/+3
* Added skip_escaped_c to strlib.c/h. * Fixed sv_unescape_c not handling hex/octal escapes properly. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12639 54d463be-8e91-2dee-dedb-b68131a5f0ec
2008-04-15 * Corrected some invalid syntax in skill_db.txt (wrong usage of commas)ultramage1-0/+4
* Renamed BA_FROSTJOKE to BA_FROSTJOKER (aegis server-side name) * Implemented a generic framework for parsing delimited db files (allows specifying min/max column ranges and max number of rows to read) * Corrected a typo in quest_update_objective() * Cleaned up pc.c a bit git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12599 54d463be-8e91-2dee-dedb-b68131a5f0ec
2008-04-02* Added SV_KEEP_TERMINATOR option to not split the line terminator.FlavioJS1-1/+3
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12461 54d463be-8e91-2dee-dedb-b68131a5f0ec
2008-04-02* Added sv_split to strlib.c/h (similar to sv_parse).FlavioJS1-3/+12
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12459 54d463be-8e91-2dee-dedb-b68131a5f0ec
2008-03-26Adjusted eAthena code to compile cleanly in C++ mode.ultramage1-3/+3
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12436 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-12-09* Added a generic 'delimiter-separated values' string parser to strlib.c/h.FlavioJS1-0/+36
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11878 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-11-27* Added safesnprintf to strlib.c/h (bugreport:372)FlavioJS1-0/+5
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11828 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-10-17* Reworked the parsing at npc.c.FlavioJS1-0/+4
- Fixes npc.c discarding the '}' at the end of file, when there is no newline. (uncovered as a side-effect of r11487) * Empty script functions always have code now (won't report as missing when you try to call them). * Changed userfunc_db to not limit the name to 50 characters. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11502 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-09-22* Added 'safestrnlen' to prevent null pointer crashesultramage1-0/+3
* Fixed global chat logging always crashing on a null pointer * Applied changes to clif_parse_globalmessage() from my WiP code - clearer processing of the individual packet components - proper code ordering, some more integrity checks - fixes to some poorly chosen ShowWarning() format strings - global chat logging no longer logs the entire string (w/ player name) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11271 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-09-20* Merged the tmpsql branch:FlavioJS1-0/+22
- Abstraction for the sql code (sql.c/h). - New configure script and makefiles. - Restored txt zeny logging code. (r10814) - Rewrote mapserver's sql code - itemdb, mobdb, mapreg, logs. (r10814) - Fixed a precedence issue (&& and ) in char_sql/char.c. (r10833) - Improved db reading code a bit for consistency. (r11077) - Added separate atcommand for mail deletion. (r11077) - Corrected a few messages that said "new" instead of "unread". (r11077) - Broadcast (*) messages now use "*" as the target's name (not ""). (r11077) - Moved StringBuf code from utils.c/h to strlib.c/h. (r11084 r11117) - Some misc login server cleanups (reformatting etc). (r11136) - Corrected/modified some header entries. (r11141 r11147 11148) - Adjusted VS project files. (r11147) - Adjusted the way the sql charserver does item saving. (r11192) - Corrected usage of reserved keyword 'friend' in mmo.h. (r11192) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11245 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-06-02* Displaying op names instead of numbers in script engine errors.FlavioJS1-2/+7
* Fixed a bug introduced in the last rework of the fame ranking. * Created safestrncpy that ensures the string is nul-terminated. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10667 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-04-21- Removed the +25% mdef, -50% def effect from Freeze statusultramage1-1/+2
- Changed autocast skills, they now only work with normal attacks - Fixed a few spots where the attack_type flag was getting truncated - Hopefully fixed the cygwin + size_t problem (using stddef.h as source) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10298 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-04-16* Finally fixed mingw problems, managed to build both TXT and SQLultramage1-1/+1
* Fixed the uint32 platform problem (Microsoft failed so I removed it :) * Removed the cbasetypes.h dependency from the mapcache generator * Removed some random compilation warnings git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10270 54d463be-8e91-2dee-dedb-b68131a5f0ec