#include <string.h>
#include <stdarg.h>
#include "asterisk/inline_api.h"
#include "asterisk/compiler.h"
#include "asterisk/compat.h"
Include dependency graph for strings.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | ast_restrdupa(ra, s) |
Functions | |
| size_t const char | __attribute__ ((format(printf, 3, 4))) |
| int | ast_build_string_va (char **buffer, size_t *space, const char *fmt, va_list ap) |
| Build a string in a buffer, designed to be called repeatedly. | |
| int | ast_false (const char *val) |
| AST_INLINE_API (void ast_copy_string(char *dst, const char *src, size_t size),{while(*src &&size){*dst++=*src++;size--;}if(__builtin_expect(!size, 0)) dst--;*dst= '\0';}) int ast_build_string(char **buffer | |
| Size-limited null-terminating string copy. Build a string in a buffer, designed to be called repeatedly. | |
| AST_INLINE_API (char *ast_skip_blanks(char *str),{while(*str &&*str< 33) str++;return str;}) AST_INLINE_API(char *ast_trim_blanks(char *str) | |
| Gets a pointer to the first non-whitespace character in a string. Trims trailing whitespace characters from a string. | |
| static force_inline int | ast_strlen_zero (const char *s) |
| int | ast_true (const char *val) |
| char * | strcasestr (const char *, const char *) |
| char * | strndup (const char *, size_t) |
| size_t | strnlen (const char *, size_t) |
| uint64_t | strtoq (const char *nptr, char **endptr, int base) |
| int | vasprintf (char **strp, const char *fmt, va_list ap) |
Variables | |
| size_t const char * | fmt |
| size_t * | space |
Definition in file strings.h.
|
|
|
|
|
Referenced by get_unaligned_uint16(), get_unaligned_uint32(), put_unaligned_uint16(), and put_unaligned_uint32(). |
|
||||||||||||||||||||
|
Build a string in a buffer, designed to be called repeatedly. This is a wrapper for snprintf, that properly handles the buffer pointer and buffer space available.
Definition at line 533 of file utils.c. Referenced by ast_build_string(), and manager_event(). 00534 {
00535 int result;
00536
00537 if (!buffer || !*buffer || !space || !*space)
00538 return -1;
00539
00540 result = vsnprintf(*buffer, *space, fmt, ap);
00541
00542 if (result < 0)
00543 return -1;
00544 else if (result > *space)
00545 result = *space;
00546
00547 *buffer += result;
00548 *space -= result;
00549 return 0;
00550 }
|
|
|
Determine if a string containing a boolean value is "false". This function checks to see whether a string passed to it is an indication of an "false" value. It checks to see if the string is "no", "false", "n", "f", "off" or "0". Returns 0 if val is a NULL pointer, -1 if "false", and 0 otherwise. Definition at line 581 of file utils.c. References ast_strlen_zero(). Referenced by ast_rtp_reload(), ast_strings_to_mask(), handle_common_options(), and pbx_load_module(). 00582 {
00583 if (ast_strlen_zero(s))
00584 return 0;
00585
00586 /* Determine if this is a false value */
00587 if (!strcasecmp(s, "no") ||
00588 !strcasecmp(s, "false") ||
00589 !strcasecmp(s, "n") ||
00590 !strcasecmp(s, "f") ||
00591 !strcasecmp(s, "0") ||
00592 !strcasecmp(s, "off"))
00593 return -1;
00594
00595 return 0;
00596 }
|
|
|
Size-limited null-terminating string copy. Build a string in a buffer, designed to be called repeatedly. This is a wrapper for snprintf, that properly handles the buffer pointer and buffer space available.
|
|
|
Gets a pointer to the first non-whitespace character in a string. Trims trailing whitespace characters from a string.
|
|
|
|
||||||||||||
|
Definition at line 662 of file utils.c. References ast_log(), LOG_ERROR, offset, and upper(). Referenced by anti_injection(), do_directory(), find_sdp(), gettag(), handle_response_register(), handle_show_applications(), modlist_modentry(), parse_register_contact(), playback_exec(), reqprep(), and respprep(). 00663 {
00664 char *u1, *u2;
00665 int u1len = strlen(haystack) + 1, u2len = strlen(needle) + 1;
00666
00667 u1 = alloca(u1len);
00668 u2 = alloca(u2len);
00669 if (u1 && u2) {
00670 char *offset;
00671 if (u2len > u1len) {
00672 /* Needle bigger than haystack */
00673 return NULL;
00674 }
00675 offset = strstr(upper(haystack, u1, u1len), upper(needle, u2, u2len));
00676 if (offset) {
00677 /* Return the offset into the original string */
00678 return ((char *)((unsigned long)haystack + (unsigned long)(offset - u1)));
00679 } else {
00680 return NULL;
00681 }
00682 } else {
00683 ast_log(LOG_ERROR, "Out of memory\n");
00684 return NULL;
00685 }
00686 }
|
|
||||||||||||
|
Definition at line 703 of file utils.c. References malloc, and strnlen(). 00704 {
00705 size_t len = strnlen(s, n);
00706 char *new = malloc(len + 1);
00707
00708 if (!new)
00709 return NULL;
00710
00711 new[len] = '\0';
00712 return memcpy(new, s, len);
00713 }
|
|
||||||||||||
|
Definition at line 690 of file utils.c. Referenced by strndup(). 00691 {
00692 size_t len;
00693
00694 for (len=0; len < n; len++)
00695 if (s[len] == '\0')
00696 break;
00697
00698 return len;
00699 }
|
|
||||||||||||||||
|
Definition at line 752 of file utils.c. References LONG_MAX, LONG_MIN, and s. 00753 {
00754 const char *s;
00755 uint64_t acc;
00756 unsigned char c;
00757 uint64_t qbase, cutoff;
00758 int neg, any, cutlim;
00759
00760 /*
00761 * Skip white space and pick up leading +/- sign if any.
00762 * If base is 0, allow 0x for hex and 0 for octal, else
00763 * assume decimal; if base is already 16, allow 0x.
00764 */
00765 s = nptr;
00766 do {
00767 c = *s++;
00768 } while (isspace(c));
00769 if (c == '-') {
00770 neg = 1;
00771 c = *s++;
00772 } else {
00773 neg = 0;
00774 if (c == '+')
00775 c = *s++;
00776 }
00777 if ((base == 0 || base == 16) &&
00778 c == '\0' && (*s == 'x' || *s == 'X')) {
00779 c = s[1];
00780 s += 2;
00781 base = 16;
00782 }
00783 if (base == 0)
00784 base = c == '\0' ? 8 : 10;
00785
00786 /*
00787 * Compute the cutoff value between legal numbers and illegal
00788 * numbers. That is the largest legal value, divided by the
00789 * base. An input number that is greater than this value, if
00790 * followed by a legal input character, is too big. One that
00791 * is equal to this value may be valid or not; the limit
00792 * between valid and invalid numbers is then based on the last
00793 * digit. For instance, if the range for quads is
00794 * [-9223372036854775808..9223372036854775807] and the input base
00795 * is 10, cutoff will be set to 922337203685477580 and cutlim to
00796 * either 7 (neg==0) or 8 (neg==1), meaning that if we have
00797 * accumulated a value > 922337203685477580, or equal but the
00798 * next digit is > 7 (or 8), the number is too big, and we will
00799 * return a range error.
00800 *
00801 * Set any if any `digits' consumed; make it negative to indicate
00802 * overflow.
00803 */
00804 qbase = (unsigned)base;
00805 cutoff = neg ? (uint64_t)-(LONG_MIN + LONG_MAX) + LONG_MAX : LONG_MAX;
00806 cutlim = cutoff % qbase;
00807 cutoff /= qbase;
00808 for (acc = 0, any = 0;; c = *s++) {
00809 if (!isascii(c))
00810 break;
00811 if (isdigit(c))
00812 c -= '\0';
00813 else if (isalpha(c))
00814 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
00815 else
00816 break;
00817 if (c >= base)
00818 break;
00819 if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
00820 any = -1;
00821 else {
00822 any = 1;
00823 acc *= qbase;
00824 acc += c;
00825 }
00826 }
00827 if (any < 0) {
00828 acc = neg ? LONG_MIN : LONG_MAX;
00829 } else if (neg)
00830 acc = -acc;
00831 if (endptr != 0)
00832 *((const char **)endptr) = any ? s - 1 : nptr;
00833 return acc;
00834 }
|
|
||||||||||||||||
|
Definition at line 717 of file utils.c. 00718 {
00719 int size;
00720 va_list ap2;
00721 char s;
00722
00723 *strp = NULL;
00724 va_copy(ap2, ap);
00725 size = vsnprintf(&s, 1, fmt, ap2);
00726 va_end(ap2);
00727 *strp = malloc(size + 1);
00728 if (!*strp)
00729 return -1;
00730 vsnprintf(*strp, size + 1, fmt, ap);
00731
00732 return size;
00733 }
|
|
|
Definition at line 179 of file strings.h. Referenced by __oh323_new(), ast_cdr_getvar(), ast_cli_netstats(), ast_openvstream(), ast_request(), check_header(), do_chanreads(), iax2_request(), mgcp_new(), setformat(), sip_new(), skinny_new(), try_suggested_sip_codec(), vpb_write(), and write_header(). |
|
|
Definition at line 179 of file strings.h. Referenced by dundi_decrypt(), and phone_write_buf(). |
1.4.2