aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/utils.h
AgeCommit message (Collapse)AuthorFilesLines
2008-11-29Merged revisions 159818 via svnmerge from kpfleming1-2/+2
https://origsvn.digium.com/svn/asterisk/trunk ........ r159818 | kpfleming | 2008-11-29 11:57:39 -0600 (Sat, 29 Nov 2008) | 18 lines incorporates r159808 from branches/1.4: ------------------------------------------------------------------------ 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/branches/1.6.0@159855 f38db490-d61c-443f-a65b-d21fe96a405b
2008-08-06Merged revisions 135900 via svnmerge from tilghman1-1/+1
https://origsvn.digium.com/svn/asterisk/trunk ................ r135900 | tilghman | 2008-08-05 22:04:01 -0500 (Tue, 05 Aug 2008) | 12 lines Merged revisions 135899 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r135899 | tilghman | 2008-08-05 22:02:59 -0500 (Tue, 05 Aug 2008) | 4 lines 1) Bugfix for debugging code 2) Reduce compiler warnings for another section of debugging code (Closes issue #13237) ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@135901 f38db490-d61c-443f-a65b-d21fe96a405b
2008-05-23Merged revisions 118049 via svnmerge from russell1-15/+2
https://origsvn.digium.com/svn/asterisk/trunk ................ r118049 | russell | 2008-05-23 07:37:31 -0500 (Fri, 23 May 2008) | 17 lines Merged revisions 118048 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r118048 | russell | 2008-05-23 07:30:53 -0500 (Fri, 23 May 2008) | 9 lines Don't declare a function that takes variable arguments as inline, because it's not valid, and on some compilers, will emit a warning. http://gcc.gnu.org/onlinedocs/gcc/Inline.html#Inline (closes issue #12289) Reported by: francesco_r Patches by Tilghman, final patch by me ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@118050 f38db490-d61c-443f-a65b-d21fe96a405b
2008-05-19Merged revisions 117088 via svnmerge from tilghman1-0/+1
https://origsvn.digium.com/svn/asterisk/trunk ................ r117088 | tilghman | 2008-05-19 11:07:09 -0500 (Mon, 19 May 2008) | 10 lines Merged revisions 117086 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r117086 | tilghman | 2008-05-19 11:05:05 -0500 (Mon, 19 May 2008) | 2 lines The addition of usleep(2) within ast_assert requires the inclusion of the unistd.h header ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@117089 f38db490-d61c-443f-a65b-d21fe96a405b
2008-05-15Merged revisions 116694 via svnmerge from tilghman1-2/+2
https://origsvn.digium.com/svn/asterisk/trunk ........ r116694 | tilghman | 2008-05-15 17:05:47 -0500 (Thu, 15 May 2008) | 4 lines Add an extra check in ast_strlen_zero, and make ast_assert() not print the file, line, and function name twice. (Closes issue #12650) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@116695 f38db490-d61c-443f-a65b-d21fe96a405b
2008-05-14Merged revisions 116469 via svnmerge from russell1-0/+27
https://origsvn.digium.com/svn/asterisk/trunk ................ r116469 | russell | 2008-05-14 16:40:43 -0500 (Wed, 14 May 2008) | 12 lines Merged revisions 116463 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r116463 | russell | 2008-05-14 16:32:00 -0500 (Wed, 14 May 2008) | 4 lines Add ast_assert(), which can be used to handle fatal errors. It is only compiled in if dev-mode is enabled, and only aborts if DO_CRASH is defined. (inspired by issue #12650) ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@116470 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-18Merged revisions 109447 via svnmerge from russell1-0/+2
https://origsvn.digium.com/svn/asterisk/trunk ........ r109447 | twilson | 2008-03-18 10:43:34 -0500 (Tue, 18 Mar 2008) | 3 lines Go through and fix a bunch of places where character strings were being 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/branches/1.6.0@109459 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-20move asterisk/paths.h outside asterisk.h and into those filesrizzo1-1/+0
who really need it. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89466 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-17start using asterisk/network.h for network related headers.rizzo1-27/+2
Also remove some unnecessary includes. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89380 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-16whitespace only change - adjust indentation and add somerizzo1-18/+23
comments on the content of these two files. utils.h (which is included in over 150 files) contains a lot of unrelated functions which require the inclusion of a large number of other headers. At some point we should partition its content in a better way. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89341 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-16remove redundant #include "asterisk/compat.h",rizzo1-3/+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-09-17Make the MALLOC_DEBUG output for free() useful again. After changing calls torussell1-5/+7
free to be ast_free, astmm said all calls to free were coming from utils.h git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82628 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-29Add inline function for signed linear subtraction.file1-0/+13
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81326 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-21Add support for using /dev/urandom to get random numbers on systems that ↵file1-4/+0
support it. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@76296 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-19After some study, thought, comparing, etc. I've backed out the previous ↵murf1-2/+66
universal mod to make ast_flags a 64 bit thing. Instead, I added a 64-bit version of ast_flags (ast_flags64), and 64-bit versions of the test-flag, set-flag, etc. macros, and an app_parse_options64 routine, and I use these in app_dial alone, to eliminate the 30-option limit it had grown to meet. There is room now for 32 more options and flags. I was heavily tempted to implement some of the other ideas that were presented, but this solution does not intro any new versions of dial, doesn't have a different API, has a minimal/zero impact on code outside of dial, and doesn't seriously (I hope) affect the code structure of dial. It's the best I can think of right now. My goal was NOT to rewrite dial. I leave that to a future, coordinated effort. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@75983 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-17via 10206, I have added an option (e) to Dial to allow the h exten to get ↵murf1-3/+3
run on peer. Had to upgrade ast_flag stuff to 64 bits to do this. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@75400 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-22Issue 9990 - New API ast_mkdir, which creates parent directories as ↵tilghman1-0/+10
necessary (and is faster than an outcall to mkdir -p) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@71040 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-14Merged revisions 69392 via svnmerge from kpfleming1-0/+7
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r69392 | kpfleming | 2007-06-14 16:50:40 -0500 (Thu, 14 Jun 2007) | 2 lines use ast_localtime() in every place localtime_r() was being used ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@69405 f38db490-d61c-443f-a65b-d21fe96a405b
2007-05-24Add a new API call for creating detached threads. Then, go replace all of therussell1-0/+13
places in the code where the same block of code for creating detached threads was replicated. (patch from bbryant) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@65968 f38db490-d61c-443f-a65b-d21fe96a405b
2007-03-06Add some documentation on the arguments to the base64 encode/decode functions.russell1-0/+19
(inspired by issue #9215) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@58149 f38db490-d61c-443f-a65b-d21fe96a405b
2007-02-24Doxygen additions, correctionsoej1-11/+12
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@56665 f38db490-d61c-443f-a65b-d21fe96a405b
2007-02-10Merged revisions 53810 via svnmerge from russell1-0/+3
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r53810 | russell | 2007-02-09 18:35:09 -0600 (Fri, 09 Feb 2007) | 24 lines Merge team/russell/sla_rewrite This is a completely new implementation of the SLA functionality introduced in Asterisk 1.4. It is now functional and ready for testing. However, I will be adding some additional features over the next week, as well. For information on how to set this up, see configs/sla.conf.sample and doc/sla.txt. In addition to the changes in app_meetme.c for the SLA implementation itself, this merge brings in various other changes: chan_sip: - Add the ability to indicate HOLD state in NOTIFY messages. - Queue HOLD and UNHOLD control frames even if the channel is not bridged to another channel. linkedlists.h: - Add support for rwlock based linked lists. dial.c: - Add the ability to run ast_dial_start() without a reference channel to inherit information from. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@53817 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-27Merged revisions 48987 via svnmerge from kpfleming1-0/+13
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r48987 | kpfleming | 2006-12-27 12:29:13 -0600 (Wed, 27 Dec 2006) | 2 lines allow 'show memory' and 'show memory summary' to distinguish memory allocations that were done for caching purposes, so they don't look like memory leaks ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48989 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-15move the dynamic string support in a better place i.e. string.hrizzo1-1/+2
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
2006-11-26- Add some comments on thread storage with a brief explanation of what it isrussell1-0/+10
as well as what the motivation is for using it. - Add a comment by the declaration of ast_inet_ntoa() noting that this function is not reentrant, and the result of a previous call to the function is no longer valid after calling it again. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48019 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-12Merged revisions 44956 via svnmerge from kpfleming1-0/+15
https://origsvn.digium.com/svn/asterisk/branches/1.4 ................ r44956 | kpfleming | 2006-10-12 13:38:51 -0500 (Thu, 12 Oct 2006) | 10 lines Merged revisions 44955 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r44955 | kpfleming | 2006-10-12 13:31:26 -0500 (Thu, 12 Oct 2006) | 2 lines ensure that IAX2 and SIP sockets allow UDP fragmentation when running on Linux (thanks to Brian Candler on the asterisk-dev list for the tip) ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@44957 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-04Merged revisions 44378 via svnmerge from kpfleming1-5/+20
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r44378 | kpfleming | 2006-10-04 14:47:22 -0500 (Wed, 04 Oct 2006) | 4 lines update thread creation code a bit reduce standard thread stack size slightly to allow the pthreads library to allocate the stack+data and not overflow a power-of-2 allocation in the kernel and waste memory/address space add a new stack size for 'background' threads (those that don't handle PBX calls) when LOW_MEMORY is defined ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@44379 f38db490-d61c-443f-a65b-d21fe96a405b
2006-09-15Many Solaris fixes - this moves some of the stuff from utils.c to strcompat.cqwell1-4/+0
Every OS uses strcompat now - this was done on purpose. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@42982 f38db490-d61c-443f-a65b-d21fe96a405b
2006-08-22Sorry, but this does not resemble malloc... so GCC was ignoring the ↵file1-2/+2
attribute and throwing a warning. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@40815 f38db490-d61c-443f-a65b-d21fe96a405b
2006-08-21use new configure-provided wrappers for attributeskpfleming1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@40785 f38db490-d61c-443f-a65b-d21fe96a405b
2006-08-21- use a common error message in all of the memory allocation macrosrussell1-66/+110
- add ast_asprintf() and ast_vasprintf() - tweak doxygen comments - simplify the definition of a flag macro git-svn-id: http://svn.digium.com/svn/asterisk/trunk@40775 f38db490-d61c-443f-a65b-d21fe96a405b
2006-08-21merge new_loader_completion branch, including (at least):kpfleming1-5/+5
- restructured build tree and makefiles to eliminate recursion problems - support for embedded modules - support for static builds - simpler cross-compilation support - simpler module/loader interface (no exported symbols) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@40722 f38db490-d61c-443f-a65b-d21fe96a405b
2006-08-08Merge team/russell/ast_verbose_threadstoragerussell1-0/+17
- instead of defining a free() wrapper in a bunch of files, define it as ast_free() in utils.h and remove the copies from all the files. - centralize and abstract the code used for doing thread storage. The code lives in threadstorage.h, with one function being implemented in utils.c. This new API includes generic thread storage as well as special functions for handling thread local dynamic length string buffers. - update ast_inet_ntoa() to use the new threadstorage API - update ast_state2str() to use the new threadstorage API - update ast_cli() to use the new threadstorage API - Modify manager_event() to use thread storage. Instead of using a buffer of 4096 characters as the workspace for building the manager event, use a thread local dynamic string. Now there is no length limitation on the length of the body of a manager event. - Significantly simplify the handling of ast_verbose() ... - Instead of using a static char buffer and a lock to make sure only one thread can be using ast_verbose() at a time, use a thread local dynamic string as the workspace for preparing the verbose message. Instead of locking around the entire function, the only locking done now is when the message has been built and is being deliviered to the list of registered verbose message handlers. - This function was doing a strdup() on every message passed to it and keeping a queue of the last 200 messages in memory. This has been completely removed. The only place this was used was that if there were any messages in the verbose queue when a verbose handler was registered, all of the messages in the queue would be fed to it. So, I just made sure that the console verbose handler and the network verbose handler (for remote asterisk consoles) were registered before any verbose messages. pbx_gtkconsole and pbx_kdeconsole will now lose a few verbose messages at startup, but I didn't feel the performance hit of this message queue was worth saving the initial verbose output for these very rarely used modules. - I have removed the last three arguments to the verbose handlers, leaving only the string itself because they aren't needed anymore. For example, ast_verbose had some logic for telling the verbose handler to add a newline if the buffer was completely full. Now that the buffer can grow as needed, this doesn't matter anymore. - remove unused function, ast_verbose_dmesg() which was to dispatch the message queue - Convert the list of verbose handlers to use the linked list macros. - add missing newline characters to a few ast_verbose() calls - convert the list of log channels to use the linked list macros in logger.c - fix close_logger() to close all of the files it opened for logging - update ast_log() to use a thread local dynamic string for its workspace for preparing log messages instead of a buffer of size BUFSIZ (8kB on my system) allocated on the stack. The dynamic string in this case is limited to only growing to a maximum size of BUFSIZ. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@39272 f38db490-d61c-443f-a65b-d21fe96a405b
2006-07-21Merge a new implementation of ast_inet_ntoa, our thread safe replacement forrussell1-1/+1
inet_ntoa, which uses thread specific data (aka thread local storage) instead of stack allocatted buffers to store the result. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@38042 f38db490-d61c-443f-a65b-d21fe96a405b
2006-06-01changes for base64 to work in multiline instancesmogorman1-0/+1
as well as being more efficient, patch from jcollie's base64 branch git-svn-id: http://svn.digium.com/svn/asterisk/trunk@31492 f38db490-d61c-443f-a65b-d21fe96a405b
2006-05-10remove almost all of the checks of the result from ast_strdupa() or alloca().russell1-6/+1
As it turns out, all of these checks were useless, because alloca will never return NULL. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@26451 f38db490-d61c-443f-a65b-d21fe96a405b
2006-05-10Allow media to go directly between IAX endpoints while signalling still markster1-0/+8
goes through the existing path. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@26314 f38db490-d61c-443f-a65b-d21fe96a405b
2006-05-05move ast_carefulwrite from manager.c to utils.c so that cli.c andrussell1-0/+11
res_agi.c no longer depend on manager.h (issue #6397, casper) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@25026 f38db490-d61c-443f-a65b-d21fe96a405b
2006-04-19add the malloc attribute to the memory allocation wrappersrussell1-5/+5
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@21681 f38db490-d61c-443f-a65b-d21fe96a405b
2006-04-12add 'show threads' and 'show profile' commands.rizzo1-2/+8
These are momstly debugging tools for developers, a bit documented in the header files (utils.h), although more documentation is definitely necessary. The performance impact is close to zero(*) so there is no need to compile it conditionally. (*) not completely true - thread destruction still needs to search a list _but_ this can be easily optimized if we end up with hundreds of active threads (in which case, though, the problem is clearly elsewhere). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@19544 f38db490-d61c-443f-a65b-d21fe96a405b
2006-03-19When astmm is in use, define ast_malloc and friends to malloc, etc., so thatrussell1-0/+15
it doesn't report that all allocations are coming from utils.h. Also, add some more information to the error message astmm reports when a memory allocation failure occurs. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@13513 f38db490-d61c-443f-a65b-d21fe96a405b
2006-02-24Reverting revision 10998 that was accidentaly committed to trunk. My apologies.oej1-8/+5
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10989 f38db490-d61c-443f-a65b-d21fe96a405b
2006-02-24Update to trunkoej1-5/+8
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10988 f38db490-d61c-443f-a65b-d21fe96a405b
2006-02-03Bug 6322 - Implementation of SHA1 in Asterisk (plus dialplan function to use it)tilghman1-0/+3
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@9138 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-21don't do the memcpy inside of ast_strdupa if we know that __builtin_alloca russell1-5/+3
was not successful git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8393 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-21remove optimization where its benefits are negligiblerussell1-5/+5
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8368 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-20- move ast_strdupa from channel.h to utils.hrussell1-5/+31
- attempt to log an error message if the __builtin_alloca inside of ast_strdupa fails. - document the fact that it is known and intended behavior for ast_strdupa to cause Asterisk to crash if the alloca fails - use __builtin_expect when checking for allocation failure in all of the allocation wrappers New Janitor Project! Anywhere that we check for a successful allocation after a call to ast_strdupa is unnecessary and should be removed. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8356 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-13Various cleanups from comments in an email from Luigi Rizzo. Thank you!russell1-17/+7
- Use a cleaner syntax for declaring the allocation macros - Fix return value for ast_strdup/ast_strndup - remove safe_strdup from app_macro, since ast_strup does the same thing - fix a place in app_queue where ast_calloc+strncpy was used instead of ast_strdup. If you are helping out with these conversions, please watch out for other places where this is done. - add a note to the coding guidelines about the fix to app_queue git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8065 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-10Add wrappers for commonly used memory allocation functions. These wrappersrussell1-0/+149
add an automatically generated Asterisk log message if the allocation fails for some reason. Otherwise, they are functionally the same, with the exception of ast_strdup and ast_strndup. These functions have the added ability to accept a NULL argument without error, which will just be ignored without generating an error. The coding guidelines have also been updated to reflect all of this information. (issue #4996) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7952 f38db490-d61c-443f-a65b-d21fe96a405b