#include <stdio.h>#include <stdarg.h>#include "list.h"Include dependency graph for octstr.h:

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

Go to the source code of this file.
Defines | |
| #define | octstr_create(cstr) (Octstr*)gw_claim_area(octstr_create_real((cstr), __FILE__, __LINE__, __func__)) |
| #define | octstr_create_from_data(data, len) (Octstr*)gw_claim_area(octstr_create_from_data_real((data), (len), __FILE__, __LINE__, __func__)) |
| #define | octstr_create_from_data_trace(data, len, file, line, func) (Octstr*)gw_claim_area(octstr_create_from_data_real(data, len, file, line, func)) |
| #define | octstr_copy(ostr, from, len) gw_claim_area(octstr_copy_real((ostr), (from), (len), __FILE__, __LINE__, __func__)) |
| #define | octstr_duplicate(ostr) gw_claim_area(octstr_duplicate_real((ostr), __FILE__, __LINE__, __func__)) |
| #define | octstr_get_cstr(ostr) (octstr_get_cstr_real(ostr, __FILE__, __LINE__, __func__)) |
| #define | octstr_dump(ostr, level,) octstr_dump_real(ostr, level, GW_DEBUG, ##__VA_ARGS__) |
| #define | octstr_format_valist(fmt, args) gw_claim_area(octstr_format_valist_real(fmt, args)) |
Typedefs | |
| typedef Octstr | Octstr |
| typedef int(* | octstr_func_t )(int) |
Functions | |
| void | octstr_init (void) |
| void | octstr_shutdown (void) |
| Octstr * | octstr_create_real (const char *cstr, const char *file, long line, const char *func) |
| Octstr * | octstr_create_from_data_real (const char *data, long len, const char *file, long line, const char *func) |
| Octstr * | octstr_imm (const char *cstr) |
| void | octstr_destroy (Octstr *ostr) |
| void | octstr_destroy_item (void *os) |
| long | octstr_len (const Octstr *ostr) |
| Octstr * | octstr_copy_real (const Octstr *ostr, long from, long len, const char *file, long line, const char *func) |
| Octstr * | octstr_duplicate_real (const Octstr *ostr, const char *file, long line, const char *func) |
| Octstr * | octstr_cat (Octstr *ostr1, Octstr *ostr2) |
| int | octstr_get_char (const Octstr *ostr, long pos) |
| void | octstr_set_char (Octstr *ostr, long pos, int ch) |
| void | octstr_get_many_chars (char *buf, Octstr *ostr, long pos, long len) |
| char * | octstr_get_cstr_real (const Octstr *ostr, const char *file, long line, const char *func) |
| void | octstr_append_from_hex (Octstr *ostr, char *hex) |
| void | octstr_binary_to_hex (Octstr *ostr, int uppercase) |
| int | octstr_hex_to_binary (Octstr *ostr) |
| void | octstr_binary_to_base64 (Octstr *ostr) |
| void | octstr_base64_to_binary (Octstr *ostr) |
| long | octstr_parse_long (long *number, Octstr *ostr, long pos, int base) |
| long | octstr_parse_double (double *number, Octstr *ostr, long pos) |
| int | octstr_check_range (Octstr *ostr, long pos, long len, octstr_func_t filter) |
| void | octstr_convert_range (Octstr *ostr, long pos, long len, octstr_func_t map) |
| void | octstr_convert_printable (Octstr *ostr) |
| int | octstr_compare (const Octstr *ostr1, const Octstr *ostr2) |
| int | octstr_case_compare (const Octstr *ostr1, const Octstr *ostr2) |
| int | octstr_ncompare (const Octstr *ostr1, const Octstr *ostr2, long n) |
| int | octstr_str_compare (const Octstr *ostr1, const char *str) |
| int | octstr_str_case_compare (const Octstr *ostr1, const char *str) |
| int | octstr_str_ncompare (const Octstr *ostr, const char *str, long n) |
| int | octstr_print (FILE *f, Octstr *ostr) |
| int | octstr_search_char (const Octstr *ostr, int ch, long pos) |
| int | octstr_search_chars (const Octstr *ostr, const Octstr *chars, long pos) |
| int | octstr_search (const Octstr *haystack, const Octstr *needle, long pos) |
| int | octstr_case_search (const Octstr *haystack, const Octstr *needle, long pos) |
| int | octstr_case_nsearch (const Octstr *haystack, const Octstr *needle, long pos, long n) |
| int | octstr_pretty_print (FILE *f, Octstr *ostr) |
| int | octstr_write_to_socket (int socket, Octstr *ostr) |
| long | octstr_write_data (Octstr *ostr, int fd, long from) |
| int | octstr_append_from_socket (Octstr *ostr, int socket) |
| void | octstr_insert (Octstr *ostr1, const Octstr *ostr2, long pos) |
| void | octstr_insert_data (Octstr *ostr, long pos, const char *data, long len) |
| void | octstr_insert_char (Octstr *ostr, long pos, const char c) |
| void | octstr_append_data (Octstr *ostr, const char *data, long len) |
| void | octstr_append (Octstr *ostr1, const Octstr *ostr2) |
| void | octstr_append_cstr (Octstr *ostr, const char *cstr) |
| void | octstr_append_char (Octstr *ostr, int ch) |
| void | octstr_truncate (Octstr *ostr, int new_len) |
| void | octstr_strip_blanks (Octstr *ostr) |
| void | octstr_strip_crlfs (Octstr *ostr) |
| void | octstr_strip_nonalphanums (Octstr *ostr) |
| void | octstr_shrink_blanks (Octstr *ostr) |
| void | octstr_delete (Octstr *ostr1, long pos, long len) |
| Octstr * | octstr_read_file (const char *filename) |
| Octstr * | octstr_read_pipe (FILE *f) |
| List * | octstr_split_words (const Octstr *ostr) |
| List * | octstr_split (const Octstr *os, const Octstr *sep) |
| int | octstr_item_match (void *item, void *pattern) |
| int | octstr_item_case_match (void *item, void *pattern) |
| void | octstr_dump_real (const Octstr *ostr, int level,...) |
| void | octstr_dump_short (Octstr *ostr, int level, const char *name) |
| int | octstr_url_decode (Octstr *ostr) |
| void | octstr_url_encode (Octstr *ostr) |
| long | octstr_get_bits (Octstr *ostr, long bitpos, int numbits) |
| void | octstr_set_bits (Octstr *ostr, long bitpos, int numbits, unsigned long value) |
| void | octstr_append_uintvar (Octstr *ostr, unsigned long value) |
| long | octstr_extract_uintvar (Octstr *ostr, unsigned long *value, long pos) |
| void | octstr_append_decimal (Octstr *ostr, long value) |
| Octstr * | octstr_format (const char *fmt,...) |
| Octstr * | octstr_format_valist_real (const char *fmt, va_list args) |
| void | octstr_format_append (Octstr *os, const char *fmt,...) |
| unsigned long | octstr_hash_key (Octstr *ostr) |
| int | octstr_recode (Octstr *tocode, Octstr *fromcode, Octstr *orig) |
| void | octstr_strip_char (Octstr *text, char ch) |
| int | octstr_isnum (Octstr *ostr1) |
| void | octstr_replace (Octstr *haystack, Octstr *needle, Octstr *repl) |
| int | octstr_symbolize (Octstr *ostr) |
| void | octstr_delete_matching (Octstr *haystack, Octstr *needle) |
| int | octstr_is_all_hex (Octstr *os) |
| void | octstr_convert_to_html_entities (Octstr *input) |
| void | octstr_convert_from_html_entities (Octstr *input) |
|
|
|
|
|
Definition at line 136 of file octstr.h. Referenced by octstr_copy_real(), octstr_create_real(), and octstr_duplicate_real(). |
|
|
|
|
Definition at line 681 of file octstr.h. Referenced by octstr_format(), and octstr_format_append(). |
|
|
|
Definition at line 104 of file octstr.h. Referenced by cgwop_create(), for_each_file(), parse_data(), and wait_for_client(). |
|
|
|
|
||||||||||||
Here is the call graph for this function:

|
||||||||||||
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1451 of file octstr.c. References Octstr::len, and octstr_insert_data(). Referenced by add_content_transfer_encoding_type(), append_uuid(), at2_read_line(), at2_wait_modem_command(), bb_print_status(), boxc_status(), cfg_read(), clickatell_send_sms(), create_onetrans(), get_pattern(), http_header_get_content_type(), httpd_serve(), kannel_send_sms(), mime_entity_dump_real(), mime_something_to_entity(), octstr_append_decimal(), operation_name(), packet_extract(), parse_cookie(), radius_type_convert(), smasi_pdu_pack(), smsc2_status(), store_file_status(), store_spool_status(), and urltrans_fill_escape_codes(). 01452 {
01453 octstr_insert_data(ostr, ostr->len, cstr, strlen(cstr));
01454 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1437 of file octstr.c. References data, gw_assert, Octstr::len, and octstr_insert_data(). Referenced by add_wsp_connect(), append_integer(), at2_read_buffer(), charset_convert(), conn_write_data(), conn_write_withlen(), convert(), gen_data(), get_pattern(), octstr_append_from_socket(), octstr_append_uintvar(), octstr_format_valist_real(), octstr_read_pipe(), radius_authenticate_pdu(), read_data(), read_line(), set_charset(), unlocked_read(), and wap_msg_send(). 01438 {
01439 gw_assert(ostr != NULL);
01440 octstr_insert_data(ostr, ostr->len, data, len);
01441 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1913 of file octstr.c. References octstr_append_cstr(). Referenced by cgw_handle_op(), cgwop_create(), convert(), get_pattern(), msg_to_emimsg(), pack_server_address(), smsc_emi2_create(), unpack_parameter(), unpack_range_value(), urltrans_fill_escape_codes(), wsp_unpack_integer_value(), wsp_unpack_version_value(), and wsp_unpack_well_known_field(). 01914 {
01915 char tmp[128];
01916
01917 sprintf(tmp, "%ld", value);
01918 octstr_append_cstr(ostr, tmp);
01919 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 446 of file octstr.c. References gw_assert, Octstr::immutable, octstr_append(), octstr_create, octstr_destroy(), octstr_hex_to_binary(), and seems_valid. Referenced by cimd_submit_msg(), client_thread(), main(), ota_pack_push_headers(), ota_pack_udh(), ota_tokenize_bookmarks(), and ota_tokenize_settings(). 00447 {
00448 Octstr *output;
00449
00450 seems_valid(ostr);
00451 gw_assert(!ostr->immutable);
00452
00453 output = octstr_create(hex);
00454 octstr_hex_to_binary(output);
00455 octstr_append(ostr, output);
00456 octstr_destroy(output);
00457 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1220 of file octstr.c. References error(), gw_assert, Octstr::immutable, octstr_append_data(), and seems_valid. Referenced by cimd2_get_packet(), cimd2_receive_msg(), oisd_get_packet(), and oisd_receive_msg(). 01221 {
01222 unsigned char buf[4096];
01223 int len;
01224
01225 seems_valid(ostr);
01226 gw_assert(!ostr->immutable);
01227
01228 again:
01229 len = recv(socket, buf, sizeof(buf), 0);
01230 if (len < 0 && errno == EINTR)
01231 goto again;
01232
01233 if (len < 0) {
01234 error(errno, "Could not read from socket %d", socket);
01235 return -1;
01236 }
01237
01238 octstr_append_data(ostr, buf, len);
01239 return len;
01240 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1868 of file octstr.c. References octstr_append_data(). Referenced by add_wsp_disconnect(), add_wsp_get(), ota_pack_push_headers(), output_variable(), pack_content_range(), pack_qvalue(), pack_range_value(), parse_attribute(), parse_element(), reply_known_capabilities(), simple_binary_output(), string_table_apply(), wml_binary_output(), wsp_cap_pack_list(), and wsp_pack_value(). 01869 {
01870 /* A uintvar is defined to be up to 32 bits large, so it will
01871 * fit in 5 octets. */
01872 unsigned char octets[5];
01873 int i;
01874 int start;
01875
01876 /* Handle last byte separately; it has no continuation bit,
01877 * and must be encoded even if value is 0. */
01878 octets[4] = value & 0x7f;
01879 value >>= 7;
01880
01881 for (i = 3; value > 0 && i >= 0; i--) {
01882 octets[i] = 0x80 | (value & 0x7f);
01883 value >>= 7;
01884 }
01885 start = i + 1;
01886
01887 octstr_append_data(ostr, octets + start, 5 - start);
01888 }
|
Here is the call graph for this function:

|
|
Definition at line 658 of file octstr.c. References Octstr::data, data, gw_assert, Octstr::immutable, Octstr::len, seems_valid, and warning(). Referenced by extract_base64(), pack_credentials(), pack_md5(), and soap_msgdata_deps(). 00659 {
00660 long triplet;
00661 long pos, len;
00662 long to;
00663 int quadpos = 0;
00664 int warned = 0;
00665 unsigned char *data;
00666
00667 seems_valid(ostr);
00668 gw_assert(!ostr->immutable);
00669
00670 len = ostr->len;
00671 data = ostr->data;
00672
00673 if (len == 0)
00674 return;
00675
00676 to = 0;
00677 triplet = 0;
00678 quadpos = 0;
00679 for (pos = 0; pos < len; pos++) {
00680 int c = data[pos];
00681 int sixbits;
00682
00683 if (c >= 'A' && c <= 'Z') {
00684 sixbits = c - 'A';
00685 } else if (c >= 'a' && c <= 'z') {
00686 sixbits = 26 + c - 'a';
00687 } else if (c >= '0' && c <= '9') {
00688 sixbits = 52 + c - '0';
00689 } else if (c == '+') {
00690 sixbits = 62;
00691 } else if (c == '/') {
00692 sixbits = 63;
00693 } else if (c == '=') {
00694 /* These can only occur at the end of encoded
00695 * text. RFC 2045 says we can assume it really
00696 * is the end. */
00697 break;
00698 } else if (isspace(c)) {
00699 /* skip whitespace */
00700 continue;
00701 } else {
00702 if (!warned) {
00703 warning(0, "Unusual characters in base64 "
00704 "encoded text.");
00705 warned = 1;
00706 }
00707 continue;
00708 }
00709
00710 triplet = (triplet << 6) | sixbits;
00711 quadpos++;
00712
00713 if (quadpos == 4) {
00714 data[to++] = (triplet >> 16) & 0xff;
00715 data[to++] = (triplet >> 8) & 0xff;
00716 data[to++] = triplet & 0xff;
00717 quadpos = 0;
00718 }
00719 }
00720
00721 /* Deal with leftover octets */
00722 switch (quadpos) {
00723 case 0:
00724 break;
00725 case 3: /* triplet has 18 bits, we want the first 16 */
00726 data[to++] = (triplet >> 10) & 0xff;
00727 data[to++] = (triplet >> 2) & 0xff;
00728 break;
00729 case 2: /* triplet has 12 bits, we want the first 8 */
00730 data[to++] = (triplet >> 4) & 0xff;
00731 break;
00732 case 1:
00733 warning(0, "Bad padding in base64 encoded text.");
00734 break;
00735 }
00736
00737 ostr->len = to;
00738 data[to] = '\0';
00739
00740 seems_valid(ostr);
00741 }
|
Here is the call graph for this function:

|
|
Definition at line 537 of file octstr.c. References Octstr::data, data, gw_assert, Octstr::immutable, Octstr::len, octstr_grow(), octstr_imm(), octstr_insert(), and seems_valid. Referenced by http_add_basic_auth(), proxy_add_authentication(), soap_o2o_msgdata_attribute(), transfer_encode(), unpack_credentials(), and wsp_unpack_well_known_field(). 00538 {
00539 static const unsigned char base64[64] =
00540 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
00541 long triplets;
00542 long lines;
00543 long orig_len;
00544 unsigned char *data;
00545 long from, to;
00546 int left_on_line;
00547
00548 seems_valid(ostr);
00549 gw_assert(!ostr->immutable);
00550
00551 if (ostr->len == 0) {
00552 /* Always terminate with CR LF */
00553 octstr_insert(ostr, octstr_imm("\015\012"), 0);
00554 return;
00555 }
00556
00557 /* The lines must be 76 characters each (or less), and each
00558 * triplet will expand to 4 characters, so we can fit 19
00559 * triplets on one line. We need a CR LF after each line,
00560 * which will add 2 octets per 19 triplets (rounded up). */
00561 triplets = (ostr->len + 2) / 3; /* round up */
00562 lines = (triplets + 18) / 19;
00563
00564 octstr_grow(ostr, triplets * 4 + lines * 2);
00565 orig_len = ostr->len;
00566 data = ostr->data;
00567
00568 ostr->len = triplets * 4 + lines * 2;
00569 data[ostr->len] = '\0';
00570
00571 /* This function works back-to-front, so that encoded data will
00572 * not overwrite source data.
00573 * from points to the start of the last triplet (which may be
00574 * an odd-sized one), and to points to the start of where the
00575 * last quad should go. */
00576 from = (triplets - 1) * 3;
00577 to = (triplets - 1) * 4 + (lines - 1) * 2;
00578
00579 /* First write the CR LF after the last quad */
00580 data[to + 5] = 10; /* LF */
00581 data[to + 4] = 13; /* CR */
00582 left_on_line = triplets - ((lines - 1) * 19);
00583
00584 /* base64 encoding is in 3-octet units. To handle leftover
00585 * octets, conceptually we have to zero-pad up to the next
00586 * 6-bit unit, and pad with '=' characters for missing 6-bit
00587 * units.
00588 * We do it by first completing the first triplet with
00589 * zero-octets, and after the loop replacing some of the
00590 * result characters with '=' characters.
00591 * There is enough room for this, because even with a 1 or 2
00592 * octet source string, space for four octets of output
00593 * will be reserved.
00594 */
00595 switch (orig_len % 3) {
00596 case 0:
00597 break;
00598 case 1:
00599 data[orig_len] = 0;
00600 data[orig_len + 1] = 0;
00601 break;
00602 case 2:
00603 data[orig_len + 1] = 0;
00604 break;
00605 }
00606
00607 /* Now we only have perfect triplets. */
00608 while (from >= 0) {
00609 long whole_triplet;
00610
00611 /* Add a newline, if necessary */
00612 if (left_on_line == 0) {
00613 to -= 2;
00614 data[to + 5] = 10; /* LF */
00615 data[to + 4] = 13; /* CR */
00616 left_on_line = 19;
00617 }
00618
00619 whole_triplet = (data[from] << 16) |
00620 (data[from + 1] << 8) |
00621 data[from + 2];
00622 data[to + 3] = base64[whole_triplet % 64];
00623 data[to + 2] = base64[(whole_triplet >> 6) % 64];
00624 data[to + 1] = base64[(whole_triplet >> 12) % 64];
00625 data[to] = base64[(whole_triplet >> 18) % 64];
00626
00627 to -= 4;
00628 from -= 3;
00629 left_on_line--;
00630 }
00631
00632 gw_assert(left_on_line == 0);
00633 gw_assert(from == -3);
00634 gw_assert(to == -4);
00635
00636 /* Insert padding characters in the last quad. Remember that
00637 * there is a CR LF between the last quad and the end of the
00638 * string. */
00639 switch (orig_len % 3) {
00640 case 0:
00641 break;
00642 case 1:
00643 gw_assert(data[ostr->len - 3] == 'A');
00644 gw_assert(data[ostr->len - 4] == 'A');
00645 data[ostr->len - 3] = '=';
00646 data[ostr->len - 4] = '=';
00647 break;
00648 case 2:
00649 gw_assert(data[ostr->len - 3] == 'A');
00650 data[ostr->len - 3] = '=';
00651 break;
00652 }
00653
00654 seems_valid(ostr);
00655 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 460 of file octstr.c. References Octstr::data, gw_assert, Octstr::immutable, Octstr::len, octstr_grow(), and seems_valid. Referenced by at2_scan_for_telnet_escapes(), bb_alog_sms(), convert(), get_pattern(), kannel_send_sms(), main(), make_emi60(), msg_to_cgwop(), msg_to_emimsg(), ota_pack_push_headers(), pack_7bit(), packet_add_hex_parm(), soap_msgdata_attribute(), status_cb(), and store_file_status(). 00461 {
00462 unsigned char *hexits;
00463 long i, tmp;
00464
00465 seems_valid(ostr);
00466 gw_assert(!ostr->immutable);
00467 if (ostr->len == 0)
00468 return;
00469
00470 hexits = uppercase ? "0123456789ABCDEF" : "0123456789abcdef";
00471 octstr_grow(ostr, ostr->len * 2);
00472
00473 /* In-place modification must be done back-to-front to avoid
00474 * overwriting the data while we read it. Even the order of
00475 * the two assignments is important, to get i == 0 right. */
00476 for (i = ostr->len - 1; i >= 0; i--) {
00477 tmp = i << 1; /* tmp = i * 2; */
00478 ostr->data[tmp + 1] = hexits[ostr->data[i] & 0xf];
00479 ostr->data[tmp] = hexits[ostr->data[i] >> 4];
00480 }
00481
00482 ostr->len = ostr->len * 2;
00483 ostr->data[ostr->len] = '\0';
00484
00485 seems_valid(ostr);
00486 }
|
Here is the call graph for this function:

|
||||||||||||
|
||||||||||||||||||||
|
Definition at line 1103 of file octstr.c. References Octstr::data, gw_assert, Octstr::len, and seems_valid. Referenced by check_control_content_type_header(), check_data_content_type_header(), drop_extension_headers(), drop_optional_header(), pass_extension_headers(), and pass_optional_header(). 01104 {
01105 long i, j;
01106 int c1, c2;
01107
01108 seems_valid(haystack);
01109 seems_valid(needle);
01110 gw_assert(pos >= 0);
01111
01112 /* Always "find" an empty string */
01113 if (needle->len == 0)
01114 return 0;
01115
01116 for (i = pos; i <= haystack->len - needle->len && i < n; ++i) {
01117 for (j = 0; j < needle->len && j < n; ++j) {
01118 c1 = toupper(haystack->data[i + j]);
01119 c2 = toupper(needle->data[j]);
01120 if (c1 != c2)
01121 break;
01122 }
01123 if (j == needle->len)
01124 return i;
01125 }
01126
01127 return -1;
01128 }
|
|
||||||||||||||||
|
Definition at line 1076 of file octstr.c. References Octstr::data, gw_assert, Octstr::len, and seems_valid. Referenced by check_control_content_type_header(), drop_extension_headers(), get_mime_boundary(), http_something_accepted(), parse_appid_header(), parse_url(), strip_prefix_and_suffix(), and type_is(). 01077 {
01078 long i, j;
01079 int c1, c2;
01080
01081 seems_valid(haystack);
01082 seems_valid(needle);
01083 gw_assert(pos >= 0);
01084
01085 /* Always "find" an empty string */
01086 if (needle->len == 0)
01087 return 0;
01088
01089 for (i = pos; i <= haystack->len - needle->len; ++i) {
01090 for (j = 0; j < needle->len; ++j) {
01091 c1 = toupper(haystack->data[i + j]);
01092 c2 = toupper(needle->data[j]);
01093 if (c1 != c2)
01094 break;
01095 }
01096 if (j == needle->len)
01097 return i;
01098 }
01099
01100 return -1;
01101 }
|
|
||||||||||||
|
Definition at line 377 of file octstr.c. References Octstr::data, gw_assert, Octstr::immutable, Octstr::len, octstr_create, seems_valid, and Octstr::size. 00378 {
00379 Octstr *ostr;
00380
00381 seems_valid(ostr1);
00382 seems_valid(ostr2);
00383 gw_assert(!ostr1->immutable);
00384
00385 ostr = octstr_create("");
00386 ostr->len = ostr1->len + ostr2->len;
00387 ostr->size = ostr->len + 1;
00388 ostr->data = gw_malloc(ostr->size);
00389
00390 if (ostr1->len > 0)
00391 memcpy(ostr->data, ostr1->data, ostr1->len);
00392 if (ostr2->len > 0)
00393 memcpy(ostr->data + ostr1->len, ostr2->data, ostr2->len);
00394 ostr->data[ostr->len] = '\0';
00395
00396 seems_valid(ostr);
00397 return ostr;
00398 }
|
|
||||||||||||||||||||
|
Definition at line 809 of file octstr.c. References Octstr::data, gw_assert, Octstr::len, and seems_valid. Referenced by convert_addr_from_pdu(), get_originator_type(), handle_dlr(), handle_pdu(), is_token(), msg_to_cgwop(), msg_to_emimsg(), msg_to_pdu(), octstr_hex_to_binary(), octstr_symbolize(), oisd_send_delivery_request(), pack_parameter(), packet_add_address_parm(), packet_check(), packet_check_header(), packet_check_parameter(), packet_encode_message(), parm_valid_address(), and run_batch(). 00811 {
00812 long end = pos + len;
00813
00814 seems_valid(ostr);
00815 gw_assert(len >= 0);
00816
00817 if (pos >= ostr->len)
00818 return 1;
00819 if (end > ostr->len)
00820 end = ostr->len;
00821
00822 for ( ; pos < end; pos++) {
00823 if (!filter(ostr->data[pos]))
00824 return 0;
00825 }
00826
00827 return 1;
00828 }
|
|
||||||||||||
|
|
Definition at line 2709 of file octstr.c. References octstr_copy, octstr_delete(), octstr_destroy(), octstr_find_entity(), octstr_insert_char(), and octstr_search_char(). 02710 {
02711 int startpos = 0, endpos;
02712 int entity;
02713 Octstr *match;
02714
02715 while ((startpos = octstr_search_char(input, '&', startpos)) != -1) {
02716 endpos = octstr_search_char(input, ';', startpos + 1);
02717 if (endpos >= 0) {
02718 match = octstr_copy(input, startpos + 1, endpos - startpos - 1);
02719 entity = octstr_find_entity(match, 0, 0);
02720 if (entity >= 0) {
02721 octstr_delete(input, startpos, endpos - startpos + 1);
02722 octstr_insert_char(input, startpos, entity);
02723 }
02724 octstr_destroy(match);
02725 }
02726 startpos++;
02727 }
02728 }
|
Here is the call graph for this function:

|
|
Definition at line 859 of file octstr.c. References Octstr::len, make_printable(), and octstr_convert_range(). Referenced by bb_alog_sms(), and get_pattern(). 00860 {
00861 octstr_convert_range(ostr, 0, ostr->len, make_printable);
00862 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 831 of file octstr.c. References Octstr::data, gw_assert, Octstr::immutable, Octstr::len, and seems_valid. Referenced by check_variable_syntax(), create_onetrans(), find_translation(), octstr_convert_printable(), parse_charset(), and parse_constant(). 00833 {
00834 long end = pos + len;
00835
00836 seems_valid(ostr);
00837 gw_assert(!ostr->immutable);
00838 gw_assert(len >= 0);
00839
00840 if (pos >= ostr->len)
00841 return;
00842 if (end > ostr->len)
00843 end = ostr->len;
00844
00845 for ( ; pos < end; pos++) {
00846 ostr->data[pos] = map(ostr->data[pos]);
00847 }
00848
00849 seems_valid(ostr);
00850 }
|
|
|
Definition at line 2643 of file octstr.c. References octstr_get_char(), and octstr_len(). Referenced by soap_msgdata_attribute(), soap_o2o_msgdata_attribute(), and xmlrpc_scalar_print(). 02644 {
02645 int i;
02646
02647 for (i = 0; i < octstr_len(input); ++i) {
02648 switch (octstr_get_char(input, i)) {
02649 #define ENTITY(a,b) \
02650 case a: \
02651 octstr_delete(input, i, 1); \
02652 octstr_insert(input, octstr_imm("&" b ";"), i); \
02653 i += sizeof(b); break;
02654 #include "gwlib/html-entities.def"
02655 #undef ENTITY
02656 }
02657 }
02658 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||
|
Definition at line 348 of file octstr.c. References Octstr::data, file, gw_assert, Octstr::len, octstr_create, octstr_create_from_data_trace, and seems_valid. Referenced by http_header_find_first_real(). 00350 {
00351 seems_valid(ostr);
00352 gw_assert(from >= 0);
00353 gw_assert(len >= 0);
00354
00355 if (from >= ostr->len)
00356 return octstr_create("");
00357
00358 if (len > ostr->len - from)
00359 len = ostr->len - from;
00360
00361 return octstr_create_from_data_trace(ostr->data + from, len, file,
00362 line, func);
00363 }
|
|
||||||||||||||||||||||||
|
Definition at line 247 of file octstr.c. References Octstr::data, data, file, gw_assert, Octstr::immutable, Octstr::len, seems_valid, and Octstr::size. 00249 {
00250 Octstr *ostr;
00251
00252 gw_assert(len >= 0);
00253 if (data == NULL)
00254 gw_assert(len == 0);
00255
00256 /* if gw_assert is disabled just return NULL
00257 * and caller will check for NULL or just crash.
00258 */
00259 if (len < 0 || (data == NULL && len != 0))
00260 return NULL;
00261
00262 ostr = gw_malloc_trace(sizeof(*ostr), file, line, func);
00263 if (len == 0) {
00264 ostr->len = 0;
00265 ostr->size = 0;
00266 ostr->data = NULL;
00267 } else {
00268 ostr->len = len;
00269 ostr->size = len + 1;
00270 ostr->data = gw_malloc_trace(ostr->size, file, line, func);
00271 memcpy(ostr->data, data, len);
00272 ostr->data[len] = '\0';
00273 }
00274 ostr->immutable = 0;
00275 seems_valid(ostr);
00276 return ostr;
00277 }
|
|
||||||||||||||||||||
|
Definition at line 240 of file octstr.c. References file, gw_assert, and octstr_create_from_data_trace. 00242 {
00243 gw_assert(cstr != NULL);
00244 return octstr_create_from_data_trace(cstr, strlen(cstr), file, line, func);
00245 }
|
|
||||||||||||||||
|
||||||||||||
|
Definition at line 2607 of file octstr.c. References gw_assert, Octstr::immutable, octstr_delete(), octstr_len(), octstr_search(), and seems_valid. Referenced by push_content_create(). 02608 {
02609 int p = 0;
02610 long len;
02611
02612 seems_valid(haystack);
02613 seems_valid(needle);
02614 gw_assert(!haystack->immutable);
02615 len = octstr_len(needle);
02616
02617 while ((p = octstr_search(haystack, needle, p)) != -1) {
02618 octstr_delete(haystack, p, len);
02619 }
02620 }
|
Here is the call graph for this function:

|
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 2052 of file octstr.c. References error(), GW_DEBUG, GW_ERROR, GW_INFO, GW_WARNING, info(), octstr_dump_debug(), octstr_dump_LOGLEVEL, and warning(). 02053 {
02054 va_list p;
02055 unsigned int loglevel;
02056
02057 va_start(p, level);
02058 loglevel = va_arg(p, unsigned int);
02059 va_end(p);
02060
02061 switch (loglevel) {
02062 case GW_DEBUG:
02063 octstr_dump_debug(ostr, level);
02064 break;
02065 case GW_INFO:
02066 octstr_dump_LOGLEVEL(info, ostr, level);
02067 break;
02068 case GW_WARNING:
02069 octstr_dump_LOGLEVEL(warning, ostr, level);
02070 break;
02071 case GW_ERROR:
02072 octstr_dump_LOGLEVEL(error, ostr, level);
02073 break;
02074 default:
02075 octstr_dump_debug(ostr, level);
02076 break;
02077 }
02078 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 2081 of file octstr.c. References Octstr::data, debug(), Octstr::len, name, octstr_dump, and seems_valid. Referenced by main(), and radius_pdu_unpack(). 02082 {
02083 char buf[100];
02084 char *p;
02085 long i;
02086 int c;
02087
02088 if (ostr == NULL) {
02089 debug("gwlib.octstr", 0, "%*s%s: NULL", level, "", name);
02090 return;
02091 }
02092
02093 seems_valid(ostr);
02094
02095 if (ostr->len < 20) {
02096 p = buf;
02097 for (i = 0; i < ostr->len; i++) {
02098 c = ostr->data[i];
02099 if (c == '\n') {
02100 *p++ = '\\';
02101 *p++ = 'n';
02102 } else if (!isprint(c)) {
02103 break;
02104 } else if (c == '"') {
02105 *p++ = '\\';
02106 *p++ = '"';
02107 } else if (c == '\\') {
02108 *p++ = '\\';
02109 *p++ = '\\';
02110 } else {
02111 *p++ = c;
02112 }
02113 }
02114 if (i == ostr->len) {
02115 *p++ = 0;
02116 /* We got through the loop without hitting nonprintable
02117 * characters. */
02118 debug("gwlib.octstr", 0, "%*s%s: \"%s\"", level, "", name, buf);
02119 return;
02120 }
02121 }
02122
02123 debug("gwlib.octstr", 0, "%*s%s:", level, "", name);
02124 octstr_dump(ostr, level + 1);
02125 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 367 of file octstr.c. References Octstr::data, file, Octstr::len, octstr_create_from_data_trace, and seems_valid. 00369 {
00370 if (ostr == NULL)
00371 return NULL;
00372 seems_valid(ostr);
00373 return octstr_create_from_data_trace(ostr->data, ostr->len, file, line, func);
00374 }
|
|
||||||||||||||||
|
Definition at line 1891 of file octstr.c. References octstr_get_char(). Referenced by is_default_cap(), parse_get_uintvar(), sanitize_capabilities(), wsp_cap_get_client_sdu(), wsp_cap_get_server_sdu(), and wsp_cap_unpack_list(). 01892 {
01893 int c;
01894 int count;
01895 unsigned long ui;
01896
01897 ui = 0;
01898 for (count = 0; count < 5; count++) {
01899 c = octstr_get_char(ostr, pos + count);
01900 if (c < 0)
01901 return -1;
01902 ui = (ui << 7) | (c & 0x7f);
01903 if (!(c & 0x80)) {
01904 *value = ui;
01905 return pos + count + 1;
01906 }
01907 }
01908
01909 return -1;
01910 }
|
Here is the call graph for this function:

|
||||||||||||
|
||||||||||||||||
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 2402 of file octstr.c. References convert(), format_flags(), format_prec(), format_type(), format_width(), gw_assert, octstr_append_data(), octstr_create, seems_valid, and VARGS. 02403 {
02404 Octstr *os;
02405 size_t n;
02406
02407 os = octstr_create("");
02408
02409 while (*fmt != '\0') {
02410 struct format format = { 0, };
02411
02412 n = strcspn(fmt, "%");
02413 octstr_append_data(os, fmt, n);
02414 fmt += n;
02415
02416 gw_assert(*fmt == '%' || *fmt == '\0');
02417 if (*fmt == '\0')
02418 continue;
02419
02420 ++fmt;
02421 format_flags(&format, &fmt);
02422 format_width(&format, &fmt, VARGS(args));
02423 format_prec(&format, &fmt, VARGS(args));
02424 format_type(&format, &fmt);
02425 convert(os, &format, &fmt, VARGS(args));
02426 }
02427
02428 seems_valid(os);
02429 return os;
02430 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1740 of file octstr.c. References Octstr::data, gw_assert, Octstr::len, result, and seems_valid. Referenced by deduce_tid(), get_tid(), unpack_ack(), unpack_tpis(), wtp_type(), and wtp_unpack_wdp_datagram(). 01741 {
01742 long pos;
01743 long result;
01744 int mask;
01745 int shiftwidth;
01746
01747 seems_valid(ostr);
01748 gw_assert(bitpos >= 0);
01749 gw_assert(numbits <= 32);
01750 gw_assert(numbits >= 0);
01751
01752 pos = bitpos / 8;
01753 bitpos = bitpos % 8;
01754
01755 /* This also takes care of the len == 0 case */
01756 if (pos >= ostr->len)
01757 return 0;
01758
01759 mask = (1 << numbits) - 1;
01760
01761 /* It's easy if the range fits in one octet */
01762 if (bitpos + numbits <= 8) {
01763 /* shiftwidth is the number of bits to ignore on the right.
01764 * bitpos 0 is the leftmost bit. */
01765 shiftwidth = 8 - (bitpos + numbits);
01766 return (ostr->data[pos] >> shiftwidth) & mask;
01767 }
01768
01769 /* Otherwise... */
01770 result = 0;
01771 while (bitpos + numbits > 8) {
01772 result = (result << 8) | ostr->data[pos];
01773 numbits -= (8 - bitpos);
01774 bitpos = 0;
01775 pos++;
01776 if (pos >= ostr->len)
01777 return (result << numbits) & mask;
01778 }
01779
01780 gw_assert(bitpos == 0);
01781 result <<= numbits;
01782 result |= ostr->data[pos] >> (8 - numbits);
01783 return result & mask;
01784 }
|
|
||||||||||||
|
||||||||||||||||||||
|
Definition at line 434 of file octstr.c. References Octstr::data, file, Octstr::len, and seems_valid_real(). 00436 {
00437 if (!ostr)
00438 return "(null)";
00439 seems_valid_real(ostr, file, line, func);
00440 if (ostr->len == 0)
00441 return "";
00442 return ostr->data;
00443 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 420 of file octstr.c. References Octstr::data, gw_assert, Octstr::len, and seems_valid. Referenced by cimd_submit_msg(), compare_octstr_sequence(), conn_read_withlen(), convert_html_entity(), html_comment_begins(), packet_extract(), parse_integer(), parse_msg_to_rawmessage(), read_msg(), smpp_pdu_read_len(), wap_msg_recv(), and write_data(). 00421 {
00422 gw_assert(buf != NULL);
00423 seems_valid(ostr);
00424
00425 if (pos >= ostr->len)
00426 return;
00427 if (pos + len > ostr->len)
00428 len = ostr->len - pos;
00429 if (len > 0)
00430 memcpy(buf, ostr->data + pos, len);
00431 }
|
|
|
Definition at line 2446 of file octstr.c. References octstr_get_char(), and octstr_len(). Referenced by key_to_index(), and store_spool_save(). 02447 {
02448 unsigned long key = 0;
02449 long i;
02450
02451 if (ostr == NULL)
02452 return 0;
02453
02454 for (i = 0; i < octstr_len(ostr); i++)
02455 key = key + octstr_get_char(ostr, i);
02456
02457 return key;
02458 }
|
Here is the call graph for this function:

|
|
Definition at line 489 of file octstr.c. References Octstr::data, gw_assert, gw_isxdigit(), Octstr::immutable, Octstr::len, octstr_check_range(), and seems_valid. Referenced by accept_escaped(), at2_pdu_extract(), decode_binary_data(), get_x_kannel_from_headers(), get_x_kannel_from_xml(), handle_operation(), main(), octstr_append_from_hex(), packet_get_hex_parm(), push_content_create(), soap_msgdata_deps(), and store_file_status(). 00490 {
00491 long len, i;
00492 unsigned char *p;
00493
00494 seems_valid(ostr);
00495 gw_assert(!ostr->immutable);
00496
00497 if (ostr->len == 0)
00498 return 0;
00499
00500 /* Check if it's in the right format */
00501 if (!octstr_check_range(ostr, 0, ostr->len, gw_isxdigit))
00502 return -1;
00503
00504 len = ostr->len;
00505
00506 /* Convert ascii data to binary values */
00507 for (i = 0, p = ostr->data; i < len; i++, p++) {
00508 if (*p >= '0' && *p <= '9')
00509 *p -= '0';
00510 else if (*p >= 'a' && *p <= 'f')
00511 *p = *p - 'a' + 10;
00512 else if (*p >= 'A' && *p <= 'F')
00513 *p = *p - 'A' + 10;
00514 else {
00515 /* isxdigit checked the whole string, so we should
00516 * not be able to get here. */
00517 gw_assert(0);
00518 *p = 0;
00519 }
00520 }
00521
00522 /* De-hexing will compress data by factor of 2 */
00523 len = ostr->len / 2;
00524
00525 for (i = 0; i < len; i++) {
00526 ostr->data[i] = ostr->data[i * 2] * 16 | ostr->data[i * 2 + 1];
00527 }
00528
00529 ostr->len = len;
00530 ostr->data[len] = '\0';
00531
00532 seems_valid(ostr);
00533 return 0;
00534 }
|
Here is the call graph for this function:

|
|
|
Definition at line 215 of file octstr.c. References immutables_init, immutables_mutex, mutex_init_static, and urlcode_init(). Referenced by gwlib_init(). 00216 {
00217 urlcode_init();
00218 mutex_init_static(&immutables_mutex);
00219 immutables_init = 1;
00220 }
|
Here is the call graph for this function:

|
||||||||||||||||
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1421 of file octstr.c. References Octstr::data, gw_assert, Octstr::immutable, Octstr::len, octstr_grow(), and seems_valid. Referenced by convert_addr_from_pdu(), init_smsbox_routes(), and octstr_convert_from_html_entities(). 01422 {
01423 seems_valid(ostr);
01424 gw_assert(!ostr->immutable);
01425 gw_assert(pos <= ostr->len);
01426
01427 octstr_grow(ostr, ostr->len + 1);
01428 if (ostr->len > pos)
01429 memmove(ostr->data + pos + 1, ostr->data + pos, ostr->len - pos);
01430 memcpy(ostr->data + pos, &c, 1);
01431 ostr->len += 1;
01432 ostr->data[ostr->len] = '\0';
01433
01434 seems_valid(ostr);
01435 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
Here is the call graph for this function:

|
|
Definition at line 2622 of file octstr.c. References gw_isxdigit(), octstr_get_char(), octstr_len(), and seems_valid. Referenced by main(), and push_content_create(). 02623 {
02624 long len, i;
02625 int ch;
02626
02627 seems_valid(os);
02628 len = octstr_len(os);
02629 for (i = 0; i < len; ++i) {
02630 ch = octstr_get_char(os, i);
02631 if (!gw_isxdigit(ch))
02632 return 0;
02633 }
02634
02635 return 1;
02636 }
|
Here is the call graph for this function:

|
|
Definition at line 2554 of file octstr.c. References octstr_get_char(), octstr_len(), and seems_valid. 02555 {
02556 int start = 0;
02557 char c;
02558
02559 seems_valid(ostr1);
02560 while (start < octstr_len(ostr1)) {
02561 c = octstr_get_char(ostr1, start);
02562 if (!isdigit(c) && (c!='+'))
02563 return 0;
02564 start++;
02565 }
02566 return 1;
02567 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1607 of file octstr.c. References octstr_case_compare(). 01608 {
01609 return octstr_case_compare(item, pattern) == 0;
01610 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1601 of file octstr.c. References octstr_compare(). Referenced by at2_detect_modem_type(), at2_init_device(), cfg_read(), check_allowed_translation(), smsbox_req_handle(), and smscconn_usable(). 01602 {
01603 return octstr_compare(item, pattern) == 0;
01604 }
|
Here is the call graph for this function:

|