aboutsummaryrefslogtreecommitdiffstats
path: root/utils.c
AgeCommit message (Collapse)AuthorFilesLines
2006-08-21merge new_loader_completion branch, including (at least):kpfleming1-1231/+0
- 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-22/+40
- 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-27fix crashes with MALLOC_DEBUG enabled that were a result of my recent threadrussell1-1/+10
storage changes (fixes issue #7595) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@38286 f38db490-d61c-443f-a65b-d21fe96a405b
2006-07-21Merge a new implementation of ast_inet_ntoa, our thread safe replacement forrussell1-2/+19
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-07-12Merged revisions 37419 via svnmerge from kpfleming1-8/+0
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r37419 | kpfleming | 2006-07-12 08:54:10 -0500 (Wed, 12 Jul 2006) | 2 lines remove some more bad examples of using printf ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@37433 f38db490-d61c-443f-a65b-d21fe96a405b
2006-07-10Fixed. Done. Good. Make ast_join work like it used to.file1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@37348 f38db490-d61c-443f-a65b-d21fe96a405b
2006-07-10Whitespace changes onlytilghman1-11/+13
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@37345 f38db490-d61c-443f-a65b-d21fe96a405b
2006-06-07simplify autoconfig include mechanism (make tholo happy he can use lint ↵kpfleming1-5/+4
again :-) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@32846 f38db490-d61c-443f-a65b-d21fe96a405b
2006-06-01changes for base64 to work in multiline instancesmogorman1-35/+34
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-06-01fix an incorrect comment (issue #7259, tardieu)russell1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@31360 f38db490-d61c-443f-a65b-d21fe96a405b
2006-05-05move ast_carefulwrite from manager.c to utils.c so that cli.c andrussell1-0/+28
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-05-05use ast_malloc instead of mallocrussell1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@24880 f38db490-d61c-443f-a65b-d21fe96a405b
2006-04-12add 'show threads' and 'show profile' commands.rizzo1-1/+46
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-04-10Bug 6829 - asprintf for Solaristilghman1-0/+34
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@18755 f38db490-d61c-443f-a65b-d21fe96a405b
2006-03-30initial implementation of support for native atomic ops.rizzo1-0/+11
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@16601 f38db490-d61c-443f-a65b-d21fe96a405b
2006-03-23don't wrap this in ifdef... using va_start is safe on all platforms :-)kpfleming1-4/+0
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@14479 f38db490-d61c-443f-a65b-d21fe96a405b
2006-03-07Doxygen changesoej1-14/+16
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@12344 f38db490-d61c-443f-a65b-d21fe96a405b
2006-03-06Portability issue - make stringfields work on FreeBSD 4.x (oej/rizzo)oej1-0/+4
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@12012 f38db490-d61c-443f-a65b-d21fe96a405b
2006-02-23add 'consumed' argument to ast_get_time_t, so callers can know how many ↵kpfleming1-2/+5
characters were used in the parser update pbx_dundi to use ast_get_time_t eliminate some compiler warnings git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10871 f38db490-d61c-443f-a65b-d21fe96a405b
2006-02-15add API function for parsing strings to time_t (issue #6320, with mods)kpfleming1-0/+24
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10105 f38db490-d61c-443f-a65b-d21fe96a405b
2006-02-11eliminate warning on older versions of gccrussell1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@9629 f38db490-d61c-443f-a65b-d21fe96a405b
2006-02-03Bug 6322 - Implementation of SHA1 in Asterisk (plus dialplan function to use it)tilghman1-1/+20
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@9138 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-26string field manager improvements:kpfleming1-33/+49
use multiple memory blocks, instead of realloc(), ensuring that field pointers will never become invalid or change don't run vs(n)printf twice when doing a field build unless required git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8697 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-10Declare missing randomlockoej1-0/+3
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7936 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-10Bug 5961 - new RAND() functiontilghman1-0/+13
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7920 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-06ensure that string field 'build' operation only evaluates arguments one timekpfleming1-2/+23
fix some minor documentation errors return proper type from string field space allocator git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7841 f38db490-d61c-443f-a65b-d21fe96a405b
2006-01-04add memory-pool based string field management for structureskpfleming1-3/+55
convert chan_sip sip_pvt and sip_registry structures to use string fields add 'const' qualifiers to a few API calls that don't modify their input strings add an asprintf() wrapper to astmm git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7797 f38db490-d61c-443f-a65b-d21fe96a405b
2005-12-20- move the string join() function to utils.c since it is used in both cli.c ↵russell1-0/+19
and res_agi.c - reimplement ast_join to be of linear effieciency instead of quadratic - remove some useless checks for "if (e)" - reorder checks for strings starting with '_' to avoid a useless call to ast_join() - check array bounds when parsing arguments to AGI (issue #5868) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7556 f38db490-d61c-443f-a65b-d21fe96a405b
2005-12-13Merged revisions 7468 via svnmerge from kpfleming1-2/+2
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r7468 | kpfleming | 2005-12-13 10:06:27 -0600 (Tue, 13 Dec 2005) | 2 lines correct broken math in tvfix() for timestamp values over one million ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7469 f38db490-d61c-443f-a65b-d21fe96a405b
2005-11-29git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7221 ↵kpfleming1-0/+0
f38db490-d61c-443f-a65b-d21fe96a405b
2005-11-08issue #5569 minus lock.h changeskpfleming1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7024 f38db490-d61c-443f-a65b-d21fe96a405b
2005-11-01issue #4678kpfleming1-1/+6
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6936 f38db490-d61c-443f-a65b-d21fe96a405b
2005-11-01issue #5549kpfleming1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6930 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-31provide an alternate getloadavg implementation and a fallback for systems ↵kpfleming1-6/+42
that don't have it at all (issue #5549 with minor mods) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6903 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-31silence compiler warningkpfleming1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6898 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-26change ast_strlen_zero to also check for the string to be definedrussell1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6862 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-26remove duplicate headerrussell1-1/+0
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6859 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-26more doxygenification (issue #5513)russell1-8/+8
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6852 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-24Doxygen documentation update from oej (issue #5505)russell1-2/+5
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6847 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-21Fix segfault in CVS head (sorry about that)markster1-1/+3
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6839 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-21Be sure to avoid octal interpretations of IP's (bug #5477)markster1-2/+13
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6838 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-16More utility cleanupsmarkster1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6798 f38db490-d61c-443f-a65b-d21fe96a405b
2005-10-01add ast_build_string_va(), which accepts a varargs list directlykpfleming1-4/+13
ensure the _entire_ manager_event() output is either queued or sent via ast_carefulwrite() git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6708 f38db490-d61c-443f-a65b-d21fe96a405b
2005-09-29ensure scheduling priority is inherited into new threads (issue #5293)kpfleming1-0/+13
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6692 f38db490-d61c-443f-a65b-d21fe96a405b
2005-09-23move process_quotes_and_slashes to utils.c since it is used by both pbx_ael ↵russell1-0/+26
and pbx_config clean up some formatting remove some commented out reference code move unload_module in pbx_ael down to be with the rest of the standard module functions git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6630 f38db490-d61c-443f-a65b-d21fe96a405b
2005-09-14update MANY more files with proper copyright/license info (thanks Ian!)kpfleming1-4/+15
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6596 f38db490-d61c-443f-a65b-d21fe96a405b
2005-09-14don't double define our own string functions on platforms that don't have ↵kpfleming1-2/+2
them (issue #5169) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6587 f38db490-d61c-443f-a65b-d21fe96a405b
2005-09-02fix a couple of warnings on osxrussell1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6500 f38db490-d61c-443f-a65b-d21fe96a405b
2005-08-29encode/decode URIs in 'pedantic' mode (issue #3923)kpfleming1-83/+143
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6441 f38db490-d61c-443f-a65b-d21fe96a405b
2005-08-23make the warning message be LOG_WARNING (issue #4960)kpfleming1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6388 f38db490-d61c-443f-a65b-d21fe96a405b