Dillo v3.2.0-151-g90488cbf
Loading...
Searching...
No Matches
dlib.h File Reference
#include <ctype.h>
#include <stdio.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include "d_size.h"
Include dependency graph for dlib.h:

Go to the source code of this file.

Classes

struct  Dstr
 
struct  Dlist
 

Macros

#define FALSE   (0)
 
#define TRUE   (!FALSE)
 
#define MAX(a, b)   (((a) > (b)) ? (a) : (b))
 
#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
 
#define D_ASCII_TOUPPER(c)   (((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))
 
#define D_ASCII_TOLOWER(c)   (((c) >= 'A' && (c) <= 'Z') ? (c) + 0x20 : (c))
 
#define BUFSIZ   4096
 
#define VOIDP2INT(p)   ((long)(p))
 
#define INT2VOIDP(i)   ((void*)((long)(i)))
 
#define dNew(type, count)    ((type *) dMalloc ((unsigned) sizeof (type) * (count)))
 
#define dNew0(type, count)    ((type *) dMalloc0 ((unsigned) sizeof (type) * (count)))
 
#define D_STMT_START   do
 
#define D_STMT_END   while (0)
 
#define dReturn_if(expr)
 
#define dReturn_val_if(expr, val)
 
#define dReturn_if_fail(expr)
 
#define dReturn_val_if_fail(expr, val)
 
#define dStrerror   strerror
 
#define Dstr_char_t   char
 

Typedefs

typedef int(* dCompareFunc) (const void *a, const void *b)
 

Functions

static int dIsalnum (unsigned char c)
 
static int dIsalpha (unsigned char c)
 
static int dIscntrl (unsigned char c)
 
static int dIsdigit (unsigned char c)
 
static int dIsprint (unsigned char c)
 
static int dIspunct (unsigned char c)
 
static int dIsspace (unsigned char c)
 
static int dIsxdigit (unsigned char c)
 
static int dTolower (unsigned char c)
 
static int dIsascii (unsigned char c)
 
void * dMalloc (size_t size)
 
void * dRealloc (void *mem, size_t size)
 
void * dMalloc0 (size_t size)
 
void dFree (void *mem)
 
char * dStrdup (const char *s)
 
char * dStrndup (const char *s, size_t sz)
 
char * dStrconcat (const char *s1,...)
 Concatenate a NULL-terminated list of strings.
 
char * dStrstrip (char *s)
 Remove leading and trailing whitespace.
 
char * dStrnfill (size_t len, char c)
 Return a new string of length 'len' filled with 'c' characters.
 
char * dStrsep (char **orig, const char *delim)
 strsep() implementation
 
void dStrshred (char *s)
 Clear the contents of the string.
 
char * dStriAsciiStr (const char *haystack, const char *needle)
 Case insensitive strstr.
 
int dStrAsciiCasecmp (const char *s1, const char *s2)
 
int dStrnAsciiCasecmp (const char *s1, const char *s2, size_t n)
 
DstrdStr_new (const char *s)
 Create a new string.
 
DstrdStr_sized_new (int sz)
 Create a new string with a given size.
 
void dStr_fit (Dstr *ds)
 Return memory if there's too much allocated.
 
void dStr_free (Dstr *ds, int all)
 Free a dillo string.
 
void dStr_append_c (Dstr *ds, int c)
 Append one character.
 
void dStr_append (Dstr *ds, const char *s)
 Append a C string to a Dstr.
 
void dStr_append_l (Dstr *ds, const char *s, int l)
 Append a C string to a Dstr (providing length).
 
void dStr_insert (Dstr *ds, int pos_0, const char *s)
 Insert a C string, at a given position, into a Dstr.
 
void dStr_insert_l (Dstr *ds, int pos_0, const char *s, int l)
 Insert a C string, at a given position, into a Dstr (providing length).
 
void dStr_truncate (Dstr *ds, int len)
 Truncate a Dstr to be 'len' bytes long.
 
void dStr_shred (Dstr *ds)
 Clear a Dstr.
 
void dStr_erase (Dstr *ds, int pos_0, int len)
 Erase a substring.
 
void dStr_vsprintfa (Dstr *ds, const char *format, va_list argp)
 vsprintf-like function that appends.
 
void dStr_vsprintf (Dstr *ds, const char *format, va_list argp)
 vsprintf-like function.
 
void dStr_sprintf (Dstr *ds, const char *format,...)
 Printf-like function.
 
void dStr_sprintfa (Dstr *ds, const char *format,...)
 Printf-like function that appends.
 
int dStr_cmp (Dstr *ds1, Dstr *ds2)
 Compare two dStrs.
 
char * dStr_memmem (Dstr *haystack, Dstr *needle)
 Return a pointer to the first occurrence of needle in haystack.
 
const char * dStr_printable (Dstr *in, int maxlen)
 Return a printable representation of the provided Dstr, limited to a length of roughly maxlen.
 
void dStr_shorten (Dstr *dst, const char *src, int n)
 Shorten string so it fits in n characters.
 
DlistdList_new (int size)
 Create a new empty list.
 
void dList_free (Dlist *lp)
 Free a list (not its elements)
 
void dList_append (Dlist *lp, void *data)
 Append a data item to the list.
 
void dList_prepend (Dlist *lp, void *data)
 Prepend a data item to the list.
 
void dList_insert_pos (Dlist *lp, void *data, int pos0)
 Insert an element at a given position [0 based].
 
int dList_length (Dlist *lp)
 For completing the ADT.
 
void dList_remove (Dlist *lp, const void *data)
 
void dList_remove_fast (Dlist *lp, const void *data)
 Remove a data item without preserving order.
 
void * dList_nth_data (Dlist *lp, int n0)
 Return the nth data item, NULL when not found or 'n0' is out of range.
 
void * dList_find (Dlist *lp, const void *data)
 Return the found data item, or NULL if not present.
 
int dList_find_idx (Dlist *lp, const void *data)
 Search a data item.
 
void * dList_find_custom (Dlist *lp, const void *data, dCompareFunc func)
 Search a data item using a custom function.
 
void dList_sort (Dlist *lp, dCompareFunc func)
 Sort the list using a custom function.
 
void dList_insert_sorted (Dlist *lp, void *data, dCompareFunc func)
 Insert an element into a sorted list.
 
void * dList_find_sorted (Dlist *lp, const void *data, dCompareFunc func)
 Search a sorted list.
 
int dParser_parse_rc_line (char **line, char **name, char **value)
 Take a dillo rc line and return 'name' and 'value' pointers to it.
 
void dLib_show_messages (bool_t show)
 
char * dGetcwd (void)
 Return the current working directory in a new string.
 
char * dGethomedir (void)
 Return the home directory in a static string (don't free)
 
char * dGetline (FILE *stream)
 Get a line from a FILE stream.
 
int dClose (int fd)
 Close a FD handling EINTR.
 
int dUsleep (unsigned long us)
 Portable usleep() function.
 

Macro Definition Documentation

◆ BUFSIZ

#define BUFSIZ   4096

Definition at line 64 of file dlib.h.

◆ D_ASCII_TOLOWER

#define D_ASCII_TOLOWER (   c)    (((c) >= 'A' && (c) <= 'Z') ? (c) + 0x20 : (c))

Definition at line 60 of file dlib.h.

◆ D_ASCII_TOUPPER

#define D_ASCII_TOUPPER (   c)    (((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))

Definition at line 59 of file dlib.h.

◆ D_STMT_END

#define D_STMT_END   while (0)

Definition at line 92 of file dlib.h.

◆ D_STMT_START

#define D_STMT_START   do

Definition at line 91 of file dlib.h.

◆ dNew

#define dNew (   type,
  count 
)     ((type *) dMalloc ((unsigned) sizeof (type) * (count)))

Definition at line 78 of file dlib.h.

◆ dNew0

#define dNew0 (   type,
  count 
)     ((type *) dMalloc0 ((unsigned) sizeof (type) * (count)))

Definition at line 80 of file dlib.h.

◆ dReturn_if

#define dReturn_if (   expr)
Value:
if (expr) { return; }; \
#define D_STMT_START
Definition dlib.h:91
#define D_STMT_END
Definition dlib.h:92

Definition at line 93 of file dlib.h.

◆ dReturn_if_fail

#define dReturn_if_fail (   expr)
Value:
if (!(expr)) { return; }; \

Definition at line 101 of file dlib.h.

◆ dReturn_val_if

#define dReturn_val_if (   expr,
  val 
)
Value:
if (expr) { return val; }; \

Definition at line 97 of file dlib.h.

◆ dReturn_val_if_fail

#define dReturn_val_if_fail (   expr,
  val 
)
Value:
if (!(expr)) { return val; }; \

Definition at line 105 of file dlib.h.

◆ Dstr_char_t

#define Dstr_char_t   char

Definition at line 129 of file dlib.h.

◆ dStrerror

#define dStrerror   strerror

Definition at line 124 of file dlib.h.

◆ FALSE

#define FALSE   (0)

Definition at line 32 of file dlib.h.

◆ INT2VOIDP

#define INT2VOIDP (   i)    ((void*)((long)(i)))

Definition at line 73 of file dlib.h.

◆ MAX

#define MAX (   a,
 
)    (((a) > (b)) ? (a) : (b))

Definition at line 40 of file dlib.h.

◆ MIN

#define MIN (   a,
 
)    (((a) < (b)) ? (a) : (b))

Definition at line 43 of file dlib.h.

◆ TRUE

#define TRUE   (!FALSE)

Definition at line 36 of file dlib.h.

◆ VOIDP2INT

#define VOIDP2INT (   p)    ((long)(p))

Definition at line 72 of file dlib.h.

Typedef Documentation

◆ dCompareFunc

typedef int(* dCompareFunc) (const void *a, const void *b)

Definition at line 174 of file dlib.h.

Function Documentation

◆ dClose()

◆ dFree()

void dFree ( void *  mem)

Definition at line 67 of file dlib.c.

Referenced by a_Bitvec_free(), a_Bookmarks_add(), a_Bookmarks_chat_add(), a_Bw_free(), a_Cache_set_content_type(), a_Capi_ccc(), a_Capi_dpi_send_data(), a_Capi_open_url(), a_Cookies_get_query(), a_Cookies_get_query(), a_Cookies_set(), a_Cookies_set(), a_Decode_free(), a_Decode_transfer_free(), a_Dialog_input(), a_Dicache_close(), a_Dicache_freeall(), a_Dicache_set_cmap(), a_Dns_freeall(), a_Domain_freeall(), a_Domain_parse(), a_Dpi_ccc(), a_Dpi_rd_dpi_socket_dir(), a_Dpi_srs(), a_Dpiapi_dialog(), a_Dpip_check_auth(), a_Dpip_dsh_free(), a_History_freeall(), a_History_set_title_by_url(), a_Hsts_set(), a_Html_common_image_attrs(), a_Html_image_new(), a_Html_load_stylesheet(), a_Http_ccc(), a_Http_connect_done(), a_Http_freeall(), a_Http_set_proxy_passwd(), a_IO_ccc(), a_Klist_free(), a_Klist_remove(), a_Menu_history_popup(), a_Menu_page_popup(), a_Misc_content_type_cmp(), a_Misc_parse_content_disposition(), a_Nav_expect_done(), a_Nav_free(), a_Prefs_freeall(), a_UIcmd_get_passwd(), a_UIcmd_open_file(), a_UIcmd_open_urlstr(), a_UIcmd_search_dialog(), a_UIcmd_view_page_source(), a_Url_free(), a_Url_new(), a_Web_free(), Auth_do_auth_dialog(), Auth_do_auth_dialog_cb(), Auth_do_auth_required(), Auth_parse_free(), Auth_realm_add_path(), Auth_realm_delete(), Bms_check_import(), Bms_del(), Bms_load(), Bms_save(), Bms_sec_del(), Bms_update_sec_title(), Bms_update_title(), Bmsrv_add_bm(), Bmsrv_dpi_send_status_msg(), Bmsrv_modify_add_section(), Bmsrv_modify_add_url(), Bmsrv_modify_update(), Bmsrv_parse_token(), Bmsrv_send_modify_answer(), Bmsrv_send_modify_page(), Bmsrv_send_modify_update(), Bmsrv_send_reload_request(), StyleEngine::buildUserStyle(), Cache_auth_callback(), Cache_auth_free(), Cache_client_dequeue(), Cache_entry_free(), Cache_parse_header(), Cache_process_queue(), Cache_provide_redirection_blocked_page(), Cache_savelink_cb(), Capi_conn_resume(), Capi_conn_unref(), Capi_dpi_send_source(), Capi_url_uses_dpi(), UI::change_panel(), cleanup(), Cookie_control_init(), Cookies_delete_node(), Cookies_free_cookie(), Cookies_get(), Cookies_init(), Cookies_parse(), Cookies_parse_date(), Cookies_rc_check(), Cookies_server_timediff(), Cookies_validate_path(), Decode_charset_free(), Decode_compression_free(), Decode_deflate(), Keys::delKeyCmd(), dGetcwd(), Dicache_remove(), dList_free(), Dns_queue_remove(), Dns_server_req(), Dpi_conn_free(), Dpi_connect_socket(), Dpi_connect_socket(), Dpi_get_server_port(), Dpi_get_server_port(), Dpi_parse_token(), Dpi_read_comm_keys(), Dpi_read_comm_keys(), Dpi_read_comm_keys(), Dpi_start_dpid(), Dpi_start_dpid(), Dpiapi_dialog_answer_cb(), dStr_free(), dStr_resize(), expires_extremes(), expires_server_ahead(), expires_server_behind(), File_dillodir_free(), File_dillodir_new(), File_info2html(), File_normalize_path(), File_print_parent_dir(), File_remove_client(), File_send_dir(), File_send_error_page(), File_send_file(), File_serve_client(), File_toggle_html_style(), fill_services_list(), CssProperty::free(), Keys::free(), Paths::free(), free_dpi_attr(), free_plugin_list(), free_services_list(), DilloHtml::freeParseData(), get_command(), get_dpi_attr(), get_dpi_dir(), get_message(), Paths::getPrefsFP(), help_cb(), Hsts_free_policy(), Html_parse_doctype(), Html_parse_entity(), Html_process_space(), Html_process_word(), Html_tag_content_frame(), Html_tag_content_map(), Html_tag_content_textarea(), Html_tag_open_a(), Html_tag_open_button(), Html_tag_open_font(), Html_tag_open_form(), Html_tag_open_hr(), Html_tag_open_input(), Html_tag_open_meta(), Html_tag_open_select(), Html_write_raw(), Http_connect_queued_sockets(), Http_connect_tls(), Http_dns_cb(), Http_fd_map_remove_all(), Http_fd_map_remove_entry(), Http_get(), Http_get_connect_str(), Http_make_query_str(), Http_must_use_proxy(), Http_send_query(), Http_server_remove(), Http_servers_remove_all(), Http_socket_free(), Image_free(), Paths::init(), init_sockdir(), IO_free(), main(), main(), make_wget_argv(), makeStartUrl(), maxage(), Menu_bugmeter_validate(), mk_sockdir(), Nav_stack_clean(), Nav_stack_truncate(), Keys::parse(), CssParser::parseImport(), Keys::parseKey(), parseOption(), Png_free(), read_req_cb(), register_all(), register_service(), save_comm_keys(), send_bm_page(), send_decoded_data(), send_failure_message(), send_html_text(), send_numbered_text(), send_plain_text(), send_sockport(), srv_parse_tok(), stop_active_dpis(), testHashSet(), testHashTable(), testVector1(), testVector2(), Tls_cert_authorities_freeall(), Tls_check_cert_hostname(), Tls_close_by_key(), Tls_close_by_key(), Tls_examine_certificate(), Tls_examine_certificate(), Tls_fd_map_remove_all(), Tls_fd_map_remove_all(), Tls_fd_map_remove_entry(), Tls_fd_map_remove_entry(), Tls_load_certificates(), Tls_load_certificates(), Tls_remove_duplicate_certificates(), Tls_servers_freeall(), Tls_servers_freeall(), try_ftp_transfer(), tst_dir(), UIcmd_make_save_filename(), UIcmd_make_search_str(), UIcmd_save(), DilloHtml::write(), CssSimpleSelector::~CssSimpleSelector(), DilloHtml::~DilloHtml(), and DoctreeNode::~DoctreeNode().

◆ dGetcwd()

char * dGetcwd ( void  )

Return the current working directory in a new string.

Definition at line 915 of file dlib.c.

References dFree(), and dNew.

Referenced by Paths::init().

◆ dGethomedir()

◆ dGetline()

char * dGetline ( FILE *  stream)

Get a line from a FILE stream.

Return value: read line on success, NULL on EOF.

Definition at line 955 of file dlib.c.

References dReturn_val_if_fail, dStr_append_c(), dStr_free(), dStr_sized_new(), Dstr::len, and Dstr::str.

Referenced by a_Domain_parse(), a_Dpi_rd_dpi_socket_dir(), a_Dpip_check_auth(), Bms_load(), Dpi_read_comm_keys(), Dpi_read_comm_keys(), Dpi_read_comm_keys(), fill_services_list(), get_dpi_dir(), and Keys::parse().

◆ dIsalnum()

static int dIsalnum ( unsigned char  c)
inlinestatic

◆ dIsalpha()

static int dIsalpha ( unsigned char  c)
inlinestatic

◆ dIsascii()

static int dIsascii ( unsigned char  c)
inlinestatic

◆ dIscntrl()

static int dIscntrl ( unsigned char  c)
inlinestatic

◆ dIsdigit()

◆ dIsprint()

static int dIsprint ( unsigned char  c)
inlinestatic

Definition at line 51 of file dlib.h.

Referenced by dStr_printable().

◆ dIspunct()

static int dIspunct ( unsigned char  c)
inlinestatic

Definition at line 52 of file dlib.h.

Referenced by dw::Textblock::drawText(), and dw::Textblock::textWidth().

◆ dIsspace()

◆ dIsxdigit()

static int dIsxdigit ( unsigned char  c)
inlinestatic

◆ dLib_show_messages()

void dLib_show_messages ( bool_t  show)

Definition at line 903 of file dlib.c.

References dLib_show_msg.

Referenced by main().

◆ dList_append()

◆ dList_find()

void * dList_find ( Dlist lp,
const void *  data 
)

Return the found data item, or NULL if not present.

Definition at line 699 of file dlib.c.

References dList_find_idx(), and Dlist::list.

Referenced by a_Bw_remove_client(), a_Bw_remove_doc(), a_Web_valid(), Cache_delayed_process_queue(), and Capi_conn_valid().

◆ dList_find_custom()

◆ dList_find_idx()

int dList_find_idx ( Dlist lp,
const void *  data 
)

Search a data item.

Return value: its index if found, -1 if not present. (this is useful for a list of integers, for finding number zero).

Definition at line 710 of file dlib.c.

References Dlist::len, and Dlist::list.

Referenced by dList_find().

◆ dList_find_sorted()

◆ dList_free()

◆ dList_insert_pos()

void dList_insert_pos ( Dlist lp,
void *  data,
int  pos0 
)

Insert an element at a given position [0 based].

Definition at line 603 of file dlib.c.

References dRealloc(), Dlist::len, Dlist::list, and Dlist::sz.

Referenced by Cookies_add_matching_cookies(), dList_append(), dList_insert_sorted(), dList_prepend(), and Http_socket_enqueue().

◆ dList_insert_sorted()

void dList_insert_sorted ( Dlist lp,
void *  data,
dCompareFunc  func 
)

Insert an element into a sorted list.

The comparison function receives two list elements.

Definition at line 796 of file dlib.c.

References dList_insert_pos(), Dlist::len, and Dlist::list.

Referenced by a_Klist_insert(), a_Tls_mbedtls_connect_ready(), a_Tls_openssl_connect_ready(), Cache_entry_add(), Cookies_add_cookie(), Dicache_add_entry(), Hsts_set_policy(), Keys::init(), Keys::parseKey(), and Tls_update_cert_authorities_data().

◆ dList_length()

◆ dList_new()

◆ dList_nth_data()

void * dList_nth_data ( Dlist lp,
int  n0 
)

Return the nth data item, NULL when not found or 'n0' is out of range.

Definition at line 689 of file dlib.c.

References Dlist::len, and Dlist::list.

Referenced by a_Auth_do_auth(), a_Bw_cleanup(), a_Bw_free(), a_Bw_get_current_doc(), a_Bw_stop_clients(), a_Cache_client_get_if_unique(), a_Cache_freeall(), a_Cache_process_dbuf(), a_Capi_conn_abort_by_url(), a_Cookies_set(), a_Dialog_input(), a_Dicache_cleanup(), a_Dicache_freeall(), a_Dicache_stats(), a_Dns_freeall(), a_Hsts_freeall(), a_Klist_free(), a_Nav_get_top_uidx(), a_Nav_get_uidx(), a_Prefs_freeall(), actions_parse(), Auth_host_by_url(), Auth_realm_add_path(), Auth_realm_by_name(), Auth_realm_by_path(), Auth_realm_delete(), Auth_realm_includes_path(), Bms_free(), Bms_normalize(), Bms_save(), Bmsrv_send_modify_page(), Cache_auth_free(), Cache_delayed_process_queue_callback(), Cache_entry_remove(), Cache_parse_header(), Cache_process_queue(), Cache_stats(), Capi_conn_resume(), Cookies_add_matching_cookies(), Cookies_get(), Cookies_get_LRU(), Cookies_rm_expired_cookies(), Cookies_save_and_free(), Dns_server(), File_check_fds(), File_dillodir_free(), File_send_dir(), File_serve_clients(), Keys::free(), free_services_list(), Keys::genAboutKeys(), get_link_menu(), get_page_menu(), Keys::getShortcut(), Http_connect_queued_sockets(), Http_connect_socket(), Http_fd_map_remove_all(), Http_server_get(), Http_server_remove(), Http_servers_remove_all(), Http_socket_enqueue(), Http_socket_reuse(), Nav_get_scroll_pos(), Nav_save_scroll_pos(), Nav_stack_clean(), Nav_stack_truncate(), parseOption(), send_bm_page(), Tls_cert_authorities_freeall(), Tls_cert_authorities_print_summary(), Tls_fd_map_remove_all(), Tls_fd_map_remove_all(), Tls_servers_freeall(), Tls_servers_freeall(), UIcmd_find_search_str(), and UIcmd_make_search_str().

◆ dList_prepend()

void dList_prepend ( Dlist lp,
void *  data 
)

Prepend a data item to the list.

Definition at line 632 of file dlib.c.

References dList_insert_pos().

◆ dList_remove()

◆ dList_remove_fast()

◆ dList_sort()

void dList_sort ( Dlist lp,
dCompareFunc  func 
)

Sort the list using a custom function.

Definition at line 785 of file dlib.c.

References Dlist::len, Dlist::list, and QuickSort().

Referenced by File_dillodir_new(), and fill_services_list().

◆ dMalloc()

void * dMalloc ( size_t  size)

◆ dMalloc0()

void * dMalloc0 ( size_t  size)

Definition at line 60 of file dlib.c.

References dMalloc().

◆ dParser_parse_rc_line()

int dParser_parse_rc_line ( char **  line,
char **  name,
char **  value 
)

Take a dillo rc line and return 'name' and 'value' pointers to it.

Notes:

  • line is modified!
  • it skips blank lines and lines starting with '#'

Return value: 1 on blank line or comment, 0 on successful value/pair, -1 otherwise.

Definition at line 861 of file dlib.c.

References dIsspace(), dReturn_val_if_fail, and dStrstrip().

Referenced by fill_services_list(), and Keys::parse().

◆ dRealloc()

void * dRealloc ( void *  mem,
size_t  size 
)

◆ dStr_append()

◆ dStr_append_c()

◆ dStr_append_l()

◆ dStr_cmp()

int dStr_cmp ( Dstr ds1,
Dstr ds2 
)

Compare two dStrs.

Definition at line 477 of file dlib.c.

References Dstr::len, MIN, and Dstr::str.

Referenced by a_Url_cmp().

◆ dStr_erase()

◆ dStr_fit()

void dStr_fit ( Dstr ds)

Return memory if there's too much allocated.

Definition at line 268 of file dlib.c.

References dStr_resize(), and Dstr::len.

Referenced by a_Cache_entry_inject(), Cache_finish_msg(), and Cache_get_header().

◆ dStr_free()

void dStr_free ( Dstr ds,
int  all 
)

◆ dStr_insert()

void dStr_insert ( Dstr ds,
int  pos_0,
const char *  s 
)

Insert a C string, at a given position, into a Dstr.

Definition at line 297 of file dlib.c.

References dStr_insert_l().

◆ dStr_insert_l()

void dStr_insert_l ( Dstr ds,
int  pos_0,
const char *  s,
int  l 
)

Insert a C string, at a given position, into a Dstr (providing length).

Note: It also works with embedded nil characters.

Definition at line 277 of file dlib.c.

References dStr_resize(), Dstr::len, Dstr::str, and Dstr::sz.

Referenced by dStr_append_l(), and dStr_insert().

◆ dStr_memmem()

char * dStr_memmem ( Dstr haystack,
Dstr needle 
)

Return a pointer to the first occurrence of needle in haystack.

Definition at line 489 of file dlib.c.

References Dstr::len, and Dstr::str.

◆ dStr_new()

◆ dStr_printable()

const char * dStr_printable ( Dstr in,
int  maxlen 
)

Return a printable representation of the provided Dstr, limited to a length of roughly maxlen.

This is NOT threadsafe.

Definition at line 512 of file dlib.c.

References dIsprint(), dStr_append(), dStr_append_c(), dStr_append_l(), dStr_sized_new(), dStr_truncate(), HEX, Dstr::len, and Dstr::str.

Referenced by a_Capi_dpi_verify_request(), a_IO_ccc(), and Http_make_query_str().

◆ dStr_shorten()

void dStr_shorten ( Dstr dst,
const char *  src,
int  n 
)

Shorten string so it fits in n characters.

Cuts the string src so that it fits in n by replacing the middle of the string with "...", but leaving both the start and the end.

The length n must be at least 9. If the src string is already shorter than n, it is appended as-is.

The resulting string is appended to out.

Definition at line 550 of file dlib.c.

References dStr_append(), and dStr_append_l().

Referenced by a_Dicache_stats(), and Cache_stats().

◆ dStr_shred()

void dStr_shred ( Dstr ds)

Clear a Dstr.

Definition at line 378 of file dlib.c.

References Dstr::str, and Dstr::sz.

Referenced by a_Digest_compute_digest().

◆ dStr_sized_new()

◆ dStr_sprintf()

◆ dStr_sprintfa()

◆ dStr_truncate()

◆ dStr_vsprintf()

void dStr_vsprintf ( Dstr ds,
const char *  format,
va_list  argp 
)

vsprintf-like function.

Definition at line 438 of file dlib.c.

References dStr_truncate(), and dStr_vsprintfa().

Referenced by a_UIcmd_set_msg(), and dStr_sprintf().

◆ dStr_vsprintfa()

void dStr_vsprintfa ( Dstr ds,
const char *  format,
va_list  argp 
)

vsprintf-like function that appends.

Used by: dStr_vsprintf(), dStr_sprintf() and dStr_sprintfa().

Definition at line 400 of file dlib.c.

References dStr_resize(), Dstr::len, Dstr::str, and Dstr::sz.

Referenced by DilloHtml::bugMessage(), dStr_sprintfa(), and dStr_vsprintf().

◆ dStrAsciiCasecmp()

int dStrAsciiCasecmp ( const char *  s1,
const char *  s2 
)

Definition at line 202 of file dlib.c.

References D_ASCII_TOLOWER.

Referenced by a_Cache_download_enabled(), a_Cache_open_url(), a_Capi_dpi_verify_request(), a_Capi_open_url(), a_Color_parse(), a_Decode_charset_init(), a_Decode_content_init(), a_Decode_transfer_init(), a_Dns_resolve(), a_Domain_parse(), a_Domain_permit(), a_Hsts_set(), a_Html_image_new(), a_Html_tag_set_align_attr(), a_Html_tag_set_valign_attr(), a_Menu_page_popup(), a_Misc_content_type_cmp(), a_UIcmd_view_page_source(), a_Url_hostname(), a_Url_new(), a_Url_same_organization(), StyleEngine::apply(), Auth_host_by_url(), Auth_parse_basic_challenge_cb(), Auth_parse_digest_challenge_cb(), Cache_parse_header(), Capi_request_permitted(), Cookie_control_init(), Cookies_control_check_domain(), Cookies_domain_matches(), Cookies_get(), Cookies_parse(), Cookies_rc_check(), Css_property_info_cmp(), Css_shorthand_info_cmp(), datauri_get_mime(), Dns_assign_channels(), Dns_queue_find(), Domain_match(), Domain_node_by_domain_cmp(), Domain_node_cmp(), Domain_node_cmp(), Domain_node_domain_str_cmp(), File_ext(), File_send_file(), Keys::getCmdCode(), Keys::getKeyCode(), Keys::getModifier(), Hsts_preload(), Html_get_radio_input(), Html_parse_doctype(), Html_tag_content_area(), Html_tag_open_button(), Html_tag_open_form(), Html_tag_open_input(), Html_tag_open_link(), Html_tag_open_meta(), Html_tag_open_style(), Html_tag_open_table(), Html_tag_open_ul(), Http_get(), Http_must_use_proxy(), Http_server_get(), Http_socket_reuse_compatible(), main(), CssSimpleSelector::match(), Menu_bugmeter_validate(), Nav_reload_callback(), CssParser::parse(), CssParser::parseImport(), CssParser::parseMedia(), parseOption(), CssParser::parseUrl(), CssParser::parseValue(), CssParser::parseWeight(), Tls_servers_by_url_cmp(), Tls_servers_by_url_cmp(), Tls_servers_cmp(), Tls_servers_cmp(), and CssParser::tokenMatchesProperty().

◆ dStrconcat()

◆ dStrdup()

char * dStrdup ( const char *  s)

Definition at line 76 of file dlib.c.

References dNew.

Referenced by a_Auth_get_auth_str(), a_Bookmarks_chat_add(), a_Cache_set_content_type(), a_Cookies_get_query(), a_Cookies_get_query(), a_Dialog_input(), a_Domain_parse(), a_History_set_title_by_url(), a_Html_get_attr_wdef(), a_Html_image_new(), a_Http_init(), a_Menu_page_popup(), a_Nav_save_url(), a_Prefs_init(), a_Tls_mbedtls_connect_ready(), a_Tls_openssl_connect_ready(), a_UIcmd_get_location_text(), a_UIcmd_init(), a_Url_decode_hex_str(), a_Url_string_strip_delimiters(), action_parse(), dw::core::Layout::addAnchor(), dw::fltk::ui::FltkOptionMenuResource::addItem(), lout::misc::StringBuffer::append(), CssPropertyList::apply(), Auth_do_auth_dialog_cb(), Auth_do_auth_required(), Auth_parse_basic_challenge_cb(), Auth_parse_digest_challenge_cb(), Auth_realm_add_path(), Bmsrv_modify_add_section(), Bmsrv_modify_add_url(), Bmsrv_modify_update(), Bmsrv_parse_token(), Bmsrv_send_modify_update(), Cache_process_queue(), Capi_conn_new(), Capi_url_uses_dpi(), UI::change_panel(), Cookie_control_init(), Cookies_add_cookie(), Cookies_get(), Cookies_load_cookies(), Cookies_validate_domain(), Cookies_validate_path(), dw::core::style::Font::copyAttrs(), CssPropertyList::CssPropertyList(), datauri_get_data(), datauri_get_mime(), dGethomedir(), DilloHtml::DilloHtml(), Dns_cache_add(), Dns_queue_add(), Dns_server_req(), expires_extremes(), expires_server_ahead(), expires_server_behind(), File_dillodir_new(), File_prepare_send_dir(), File_prepare_send_error_page(), File_prepare_send_file(), File_print_parent_dir(), fill_services_list(), dw::fltk::ui::FltkEntryResource::FltkEntryResource(), dw::fltk::ui::FltkLabelButtonResource::FltkLabelButtonResource(), dw::fltk::ui::FltkMultiLineTextResource::FltkMultiLineTextResource(), form::Form::FormClickedReceiver::FormClickedReceiver(), get_dpi_attr(), get_dpi_dir(), Hsts_set_policy(), Html_tag_content_frame(), Html_tag_content_textarea(), Html_tag_open_font(), Html_tag_open_form(), Html_tag_open_input(), Html_tag_open_meta(), Html_tag_open_optgroup(), Http_get(), Http_get_connect_str(), Http_get_referer(), Http_must_use_proxy(), Http_server_get(), dw::Image::Image(), Keys::init(), dw::fltk::FltkFont::initSystemFonts(), dw::TrieBuilder::insert(), main(), main(), makeStartUrl(), maxage(), Menu_bugmeter_validate(), CssParser::parseImport(), Keys::parseKey(), parseOption(), CssParser::parseUrl(), CssParser::parseValue(), dw::fltk::ui::FltkOptionMenuResource::pushGroup(), form::Form::RadioButtonResourceDecorator::RadioButtonResourceDecorator(), register_all(), register_service(), form::Form::ResourceDecorator::ResourceDecorator(), dw::core::FindtextState::search(), form::Form::SelectionResourceDecorator::SelectionResourceDecorator(), TipWinButton::set_tooltip(), TipWinInput::set_tooltip(), dw::core::Layout::setAnchor(), StyleEngine::setId(), dw::fltk::ui::FltkLabelButtonResource::setLabel(), StyleEngine::setNonCssHint(), CssSimpleSelector::setSelect(), dw::fltk::ui::FltkEntryResource::setText(), TipWinButton::TipWinButton(), TipWinInput::TipWinInput(), Tls_update_cert_authorities_data(), lout::object::Object::toString(), UIcmd_save(), Unescape_html_str(), and Unescape_uri_str().

◆ dStriAsciiStr()

char * dStriAsciiStr ( const char *  haystack,
const char *  needle 
)

◆ dStrnAsciiCasecmp()

◆ dStrndup()

◆ dStrnfill()

char * dStrnfill ( size_t  len,
char  c 
)

Return a new string of length 'len' filled with 'c' characters.

Definition at line 148 of file dlib.c.

References dNew.

Referenced by Html_process_space().

◆ dStrsep()

char * dStrsep ( char **  orig,
const char *  delim 
)

strsep() implementation

Definition at line 158 of file dlib.c.

Referenced by Cookies_load_cookies(), Html_tag_open_form(), and Http_must_use_proxy().

◆ dStrshred()

void dStrshred ( char *  s)

Clear the contents of the string.

Definition at line 139 of file dlib.c.

Referenced by Auth_do_auth_dialog_cb().

◆ dStrstrip()

char * dStrstrip ( char *  s)

◆ dTolower()

static int dTolower ( unsigned char  c)
inlinestatic

Definition at line 55 of file dlib.h.

Referenced by dw::core::FindtextState::charsEqual(), and pattern_match().

◆ dUsleep()

int dUsleep ( unsigned long  usec)

Portable usleep() function.

The usleep() function is deprecated in POSIX.1-2001 and removed in POSIX.1-2008, see usleep(3).

Definition at line 994 of file dlib.c.

Referenced by Dpi_blocking_start_dpid(), and Dpi_blocking_start_dpid().