aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/strings.h
AgeCommit message (Collapse)AuthorFilesLines
2009-12-15Is it Friday yet?tilghman1-0/+5
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@235229 f38db490-d61c-443f-a65b-d21fe96a405b
2009-05-21Const-ify the world (or at least a good part of it)kpfleming1-5/+9
This patch adds 'const' tags to a number of Asterisk APIs where they are appropriate (where the API already demanded that the function argument not be modified, but the compiler was not informed of that fact). The list includes: - CLI command handlers - CLI command handler arguments - AGI command handlers - AGI command handler arguments - Dialplan application handler arguments - Speech engine API function arguments In addition, various file-scope and function-scope constant arrays got 'const' and/or 'static' qualifiers where they were missing. Review: https://reviewboard.asterisk.org/r/251/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@196072 f38db490-d61c-443f-a65b-d21fe96a405b
2009-04-01Merge changes from str_substitution that are unrelated to that branch.tilghman1-3/+10
Included is a small bugfix to an ast_str helper, but most of these changes are simply doxygen fixes. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@185912 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-25Improve performance of the ast_event cache functionality.russell1-0/+23
This code comes from svn/asterisk/team/russell/event_performance/. Here is a summary of the changes that have been made, in order of both invasiveness and performance impact, from smallest to largest. 1) Asterisk 1.6.1 introduces some additional logic to be able to handle distributed device state. This functionality comes at a cost. One relatively minor change in this patch is that the extra processing required for distributed device state is now completely bypassed if it's not needed. 2) One of the things that I noticed when profiling this code was that a _lot_ of time was spent doing string comparisons. I changed the way strings are represented in an event to include a hash value at the front. So, before doing a string comparison, we do an integer comparison on the hash. 3) Finally, the code that handles the event cache has been re-written. I tried to do this in a such a way that it had minimal impact on the API. I did have to change one API call, though - ast_event_queue_and_cache(). However, the way it works now is nicer, IMO. Each type of event that can be cached (MWI, device state) has its own hash table and rules for hashing and comparing objects. This by far made the biggest impact on performance. For additional details regarding this code and how it was tested, please see the review request. (closes issue #14738) Reported by: russell Review: http://reviewboard.digium.com/r/205/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@184339 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-11Add MALLOC_DEBUG to various utility APIs, so that memory leaks can be ↵tilghman1-0/+27
tracked back to their source. (related to issue #14636) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@181028 f38db490-d61c-443f-a65b-d21fe96a405b
2009-01-19ast_str_SQLGetData is *not* part of the ast_str API, it's part of the ↵kpfleming1-48/+16
ast_odbc API and just happens to use an ast_str as the buffer; move all of it to res_odbc.c and res_odbc.h, renaming appropriately along the way fix some minor coding style issues in strings.h and add some attribute_pure annotations to functions in the ast_str API git-svn-id: http://svn.digium.com/svn/asterisk/trunk@169438 f38db490-d61c-443f-a65b-d21fe96a405b
2009-01-15Resolve issue with negative vs non-negative length parameters.tilghman1-5/+6
(closes issue #14245) Reported by: dveiga git-svn-id: http://svn.digium.com/svn/asterisk/trunk@168719 f38db490-d61c-443f-a65b-d21fe96a405b
2009-01-09When using ast_str with a non-ast_str-enabled API, we need to update the buffertilghman1-0/+10
or otherwise, we cannot use ast_str_strlen(). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@168090 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-18Remove duplicate code from the ast_str API. We now use __AST_STR_* toeliel1-172/+58
access 'struct ast_str' members, but this must only be used inside the API implementation. (closes issue #14098) Reported by: eliel Patches: ast_str.patch uploaded by eliel (license 64) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@165502 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-15Revert ast_str opacity in chan_sip for now, since something wasn't quite righttilghman1-2/+2
in the merge. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@164417 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-15I was getting this warning during a compilemurf1-2/+2
on a 64-bit machine running ubuntu server 8.10, and gcc-4.3.2: [CXXi] chan_vpb.ii -> chan_vpb.oo cc1plus: warnings being treated as errors In file included from /home/murf/asterisk/trunk/include/asterisk/utils.h:671, from chan_vpb.cc:46: /home/murf/asterisk/trunk/include/asterisk/strings.h: In function ‘char* ast_str_truncate(ast_str*, ssize_t)’: /home/murf/asterisk/trunk/include/asterisk/strings.h:479: error: comparison between signed and unsigned integer expressions make[1]: *** [chan_vpb.oo] Error 1 make: *** [channels] Error 2 which this fix silences git-svn-id: http://svn.digium.com/svn/asterisk/trunk@164415 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-15Fix a couple more build issues related to ast_str_opaquerussell1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@164309 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-14Don't pass a negative to an unsigned type and expect things to work correctly.tilghman1-3/+3
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@164168 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-13Merge ast_str_opaque branch (discontinue usage of ast_str internals)tilghman1-5/+239
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@163991 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-29incorporates r159808 from branches/1.4:kpfleming1-8/+8
------------------------------------------------------------------------ r159808 | kpfleming | 2008-11-29 10:58:29 -0600 (Sat, 29 Nov 2008) | 7 lines update dev-mode compiler flags to match the ones used by default on Ubuntu Intrepid, so all developers will see the same warnings and errors since this branch already had some printf format attributes, enable checking for them and tag functions that didn't have them format attributes in a consistent way ------------------------------------------------------------------------ in addition: move some format attributes from main/utils.c to the header files they belong in, and fix up references to the relevant functions based on new compiler warnings git-svn-id: http://svn.digium.com/svn/asterisk/trunk@159818 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-19Starting with a change to ensure that ast_verbose() preserves ABI compatibilitytilghman1-60/+46
in 1.6.1 (as compared to 1.6.0 and versions of 1.4), this change also deprecates the use of Asterisk with FreeBSD 4, given the central use of va_copy in core functions. va_copy() is C99, anyway, and we already require C99 for other purposes, so this isn't really a big change anyway. This change also simplifies some of the core ast_str_* functions. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@157639 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-14Fix some refcounting in app_queue.c and change themmichelson1-0/+19
hashing used by app_queue.c to be case-insensitive. This is accomplished by adding a new case-insensitive hashing function. This was necessary to prevent bad refcount errors (and potential crashes) which would occur due to the fact that queues were initially read from the config file in a case-sensitive manner. Then, when a user issued a CLI command or manager action, we allowed for case-insensitive input and used that input to directly try to find the queue in the hash table. The result was either that we could not find a queue that was input or worse, we would end up hashing to a completely bogus value based on the input. This commit resolves the problem presented in issue #13703. However, that issue was reported against 1.6.0. Since this fix introduces a behavior change, I am electing to not place this same fix in to the 1.6.0 or 1.6.1 branches, and instead will opt for a change which does not change behavior. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@156883 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-11use some fancy compiler magic (thanks to Matthew Woehlke on the gcc-help ↵kpfleming1-8/+2
mailing list) to restore type-safety to S_OR by going back to a macro, but preserve the side-effect-safe usage of the macro arguments git-svn-id: http://svn.digium.com/svn/asterisk/trunk@155967 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-08 - Check for failure when putting the packet in the ast_strrussell1-1/+1
- fix a spelling error in a header file git-svn-id: http://svn.digium.com/svn/asterisk/trunk@155516 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-06make S_OR and S_COR safe to use even if the parameters are function calls or ↵kpfleming1-2/+8
have side effects. it still bothers me that these are called S_OR and not something like ast_string_or, but that's water over the bridge git-svn-id: http://svn.digium.com/svn/asterisk/trunk@155079 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-01Merge changes from team/group/appdocsxmlrussell1-0/+15
This commit introduces the first phase of an effort to manage documentation of the interfaces in Asterisk in an XML format. Currently, a new format is available for applications and dialplan functions. A good number of conversions to the new format are also included. For more information, see the following message to asterisk-dev: http://lists.digium.com/pipermail/asterisk-dev/2008-October/034968.html git-svn-id: http://svn.digium.com/svn/asterisk/trunk@153365 f38db490-d61c-443f-a65b-d21fe96a405b
2008-10-14Add additional memory debugging to several core APIs, and fix several memorytilghman1-0/+25
leaks found with these changes. (Closes issue #13505, closes issue #13543) Reported by: mav3rick, triccyx Patches: 20081001__bug13505.diff.txt uploaded by Corydon76 (license 14) Tested by: mav3rick, triccyx git-svn-id: http://svn.digium.com/svn/asterisk/trunk@149199 f38db490-d61c-443f-a65b-d21fe96a405b
2008-10-14Merge realtime_update2 branch, which adds a new realtime API call namedtilghman1-2/+2
'update2', which permits updates which match across multiple columns, instead of requiring all tables to have a single unique identifier. All of the other API calls with the exception of 'update' already had the ability to match on multiple fields, so it was a missing and very desireable feature that an API call implementing an update should have this, too. This does not change any outward performance of Asterisk, but it should make life easier for application developers who use the RealTime framework. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@148570 f38db490-d61c-443f-a65b-d21fe96a405b
2008-08-07Merge in a few more changes. This time the include/ directory.seanbright1-7/+7
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@136402 f38db490-d61c-443f-a65b-d21fe96a405b
2008-07-02Fix a bunch of places where \arg was used instead of \param. Using \argrussell1-25/+21
to document arguments seems logical, and does work, but is not the best thing to use. \arg in doxygen is simply for creating non-nested unordered lists. \param is the correct tag to use to document function parameters, and will come out better in the generated documentation. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@127401 f38db490-d61c-443f-a65b-d21fe96a405b
2008-05-15Add an extra check in ast_strlen_zero, and make ast_assert() not print thetilghman1-0/+15
file, line, and function name twice. (Closes issue #12650) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@116694 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-28Temporary revert of 111662. It's causing lots of trouble and appears to not bemmichelson1-1/+1
the proper solution to the problem reported anyway. (related to issue #12884) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@111777 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-28The copy_request function did not take into account the necessary null ↵mmichelson1-1/+1
terminator for the string to be copied into. This resulted in parse_request reading invalid memory beyond the end of the string, and in some cases led to crashes. Thanks to falves11 for providing the valgrind output which led to the closure of this issue. (closes issue #12284) Reported by: falves11 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@111662 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-18Go through and fix a bunch of places where character strings were being ↵twilson1-1/+1
interpreted as format strings. Most of these changes are solely to make compiling with -Wsecurity and -Wformat=2 happy, and were not actual problems, per se. I also added format attributes to any printf wrapper functions I found that didn't have them. -Wsecurity and -Wmissing-format-attribute added to --enable-dev-mode. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@109447 f38db490-d61c-443f-a65b-d21fe96a405b
2008-02-15Fix up some doxygen issues.qwell1-5/+4
(closes issue #11996) Patches: bug_11996_doxygen.diff uploaded by snuffy (license 35) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@103723 f38db490-d61c-443f-a65b-d21fe96a405b
2007-12-19Add a new API function, written at least twice in app_voicemail.crizzo1-0/+8
and likely in other places too. This is quite useful when placing mail/html stuff in config files. /*! \brief Convert some C escape sequences (\b\f\n\r\t) into the equivalent characters. \brief s The string to be converted (will be modified). \return The converted string. */ char *ast_unescape_c(char *s); git-svn-id: http://svn.digium.com/svn/asterisk/trunk@93950 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-27Add an S_COR macro, which is similar to the existing S_OR macro,qwell1-1/+7
except with an additional boolean arg. A hack such as: foo ? S_OR(bar, "baz") : "baz" becomes: S_COR(foo, bar, "baz") git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89683 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-16remove redundant #include "asterisk/compat.h",rizzo1-2/+0
but make sure that asterisk/compiler.h is included everywhere git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89336 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-16Start untangling header inclusion in a way that does not affectrizzo1-4/+0
build times - tested, there is no measureable difference before and after this commit. In this change: use asterisk/compat.h to include a small set of system headers: inttypes.h, unistd.h, stddef.h, stddint.h, sys/types.h, stdarg.h, stdlib.h, alloca.h, stdio.h Where available, the inclusion is conditional on HAVE_FOO_H as determined by autoconf. Normally, source files should not include any of the above system headers, and instead use either "asterisk.h" or "asterisk/compat.h" which does it better. For the time being I have left alone second-level directories (main/db1-ast, etc.). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89333 f38db490-d61c-443f-a65b-d21fe96a405b
2007-10-15Merged revisions 85561 via svnmerge from russell1-3/+3
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r85561 | russell | 2007-10-15 11:34:13 -0500 (Mon, 15 Oct 2007) | 4 lines Make a few changes so that characters in the upper half of the ISO-8859-1 character set don't get stripped when reading configuration. (closes issue #10982, dandre) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85562 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-05Doxygen cleanups/fixes.qwell1-8/+8
Closes issue #10654, patch by snuffy git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81560 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-22Merged revisions 80362 via svnmerge from russell1-1/+19
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r80362 | russell | 2007-08-22 15:21:36 -0500 (Wed, 22 Aug 2007) | 34 lines Merge changes from team/russell/iax_refcount. This set of changes fixes problems with the handling of iax2_user and iax2_peer objects. It was very possible for a thread to still hold a reference to one of these objects while a reload operation tries to delete them. The fix here is to ensure that all references to these objects are tracked so that they can't go away while still in use. To accomplish this, I used the astobj2 reference counted object model. This code has been in one of Luigi Rizzo's branches for a long time and was primarily developed by one of his students, Marta Carbone. I wanted to go ahead and bring this in to 1.4 because there are other problems similar to the ones fixed by these changes, so we might as well go ahead and use the new astobj if we're going to go through all of the work necessary to fix the problems. As a nice side benefit of these changes, peer and user handling got more efficient. Using astobj2 lets us not hold the container lock for peers or users nearly as long while iterating. Also, by changing a define at the top of chan_iax2.c, the objects will be distributed in a hash table, drastically increasing lookup speed in these containers, which will have a very big impact on systems that have a large number of users or peers. The use of the hash table will be made the default in trunk. It is not the default in 1.4 because it changes the behavior slightly. Previously, since peers and users were stored in memory in the same order they were specified in the configuration file, you could influence peer and user matching order based on the order they are specified in the configuration. The hash table does not guarantee any order in the container, so this behavior will be going away. It just means that you have to be a little more careful ensuring that peers and users are matched explicitly and not forcing chan_iax2 to have to guess which user is the right one based on secret, host, and access list settings, instead of simply using the username. If you have any questions, feel free to ask on the asterisk-dev list. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@80387 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-17Merged revisions 79904 via svnmerge from qwell1-0/+7
https://origsvn.digium.com/svn/asterisk/branches/1.4 (closes issue #10430) ........ r79904 | qwell | 2007-08-17 14:12:19 -0500 (Fri, 17 Aug 2007) | 11 lines Don't send a semicolon over the wire in sip notify messages. Caused by fix for issue 9938. I basically took the code that existed before 9938 was fixed, and copied it into a new function - ast_unescape_semicolon There should be very few places this will be needed (pbx_config does NOT need this (see issue 9938 for details)) Issue 10430, patch by me, with help/ideas from murf (thanks murf). ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@79905 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-18Merge in ast_strftime branch, which changes timestamps to be accurate to the ↵tilghman1-0/+10
microsecond, instead of only to the second git-svn-id: http://svn.digium.com/svn/asterisk/trunk@75706 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-16Merge a bunch of doxygen updates to header files. This includes changes torussell1-10/+18
use the \retval tag for documenting return values, fixing various warnings when generating the documentation, and various other things. (closes issue #10203, snuffy) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@75164 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-28Remove the ill-advised ast_restrdupa API call and related structurestilghman1-18/+0
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@72492 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-07Fix a bunch of doxygen errors and document more thingsrussell1-12/+12
(issue #9842, snuffy) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@68339 f38db490-d61c-443f-a65b-d21fe96a405b
2007-01-19As the comment in the diff says:rizzo1-6/+16
AST_INLINE_API() is a macro that takes a block of code as an argument. Using preprocessor #directives in the argument is not supported by all compilers, and it is a bit of an obfuscation anyways, so avoid it. As a workaround, define a macro that produces either its argument or nothing, and use that instead of #ifdef/#endif within the argument to AST_INLINE_API(). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@51312 f38db490-d61c-443f-a65b-d21fe96a405b
2007-01-10Return the useless casts that ensure this file is C++ clean. (issue #8602 ↵file1-4/+6
reported by mikma) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@50397 f38db490-d61c-443f-a65b-d21fe96a405b
2007-01-04ensure that the proper file/function/line shows up for dynamic string ↵kpfleming1-3/+27
threadstorage objects remove pointless casts git-svn-id: http://svn.digium.com/svn/asterisk/trunk@49580 f38db490-d61c-443f-a65b-d21fe96a405b
2007-01-04Merged revisions 49553 via svnmerge from kpfleming1-1/+9
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r49553 | kpfleming | 2007-01-04 16:51:01 -0600 (Thu, 04 Jan 2007) | 2 lines add support for tracking thread-local-storage objects that exist via 'threadstorage' CLI commands ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@49578 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-18apply the proposed fix for bug 8602rizzo1-6/+30
http://bugs.digium.com/view.php?id=8602 (i am not sure if there is still missing cast in front of the alloca() call - being a macro this is probably triggered only when actually used). Add function ast_str_reset() to reinitialize the string to an empty string instead of playing with the internal fields. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48560 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-16replace ast_build_string() with ast_str_*() functions.rizzo1-0/+21
This makes the code easier to follow and saves some copies to intermediate buffers. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48515 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-15simplify the ast_dynamic_str_*.... routines byrizzo1-147/+61
renaming them to ast_str ... and putting the struct ast_threadstorage pointer into the struct ast_str. This makes the code a lot more readable. At this point we can use these routines also to replace ast_build_string(). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48510 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-15move the dynamic string support in a better place i.e. string.hrizzo1-0/+396
While doing this, add a bit of documentation, and slightly extend the functionality as follows: + a max_len of -1 means that we take whatever the current size is, and never try to extend the buffer; + add support for alloca()-ted dynamic strings, which is very useful for all cases where we do an ast_build_string() now. Next step is to simplify the interface by using shorter names (e.g. ast_str as a prefix) and removing the _thread variant of the functions by saving the threadstorage reference into the struct ast_str. This can be done by overloading the 'type' field. Finally, I will do my best to remove the convoluted interface that results from trying to support platforms without va_copy(). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48509 f38db490-d61c-443f-a65b-d21fe96a405b