Dillo v3.1.1-46-g8a360e32
Loading...
Searching...
No Matches
misc.h File Reference
#include <stddef.h>
Include dependency graph for misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define d_isascii(c)   (((c) & ~0x7f) == 0)
 

Functions

char * a_Misc_escape_chars (const char *str, const char *esc_set)
 Escape characters as XX sequences.
 
int a_Misc_expand_tabs (char **start, char *end, char *buf, int buflen)
 Takes a string and converts any tabs to spaces.
 
int a_Misc_get_content_type_from_data (void *Data, size_t Size, const char **PT)
 Detects 'Content-Type' from a data stream sample.
 
int a_Misc_content_type_check (const char *EntryType, const char *DetectedType)
 Check the server-supplied 'Content-Type' against our detected type.
 
void a_Misc_parse_content_type (const char *str, char **major, char **minor, char **charset)
 Parse Content-Type string, e.g., "text/html; charset=utf-8".
 
int a_Misc_content_type_cmp (const char *ct1, const char *ct2)
 Compare two Content-Type strings.
 
int a_Misc_parse_geometry (char *geom, int *x, int *y, int *w, int *h)
 Parse a geometry string.
 
int a_Misc_parse_search_url (char *source, char **label, char **urlstr)
 Parse dillorc's search_url string ([<label> ]<url>) Return value: -1 on error, 0 on success (and label and urlstr pointers)
 
char * a_Misc_encode_base64 (const char *in)
 Encodes string using base64 encoding.
 
Dstra_Misc_file2dstr (const char *filename)
 Load a local file into a dStr.
 

Macro Definition Documentation

◆ d_isascii

#define d_isascii (   c)    (((c) & ~0x7f) == 0)

Definition at line 11 of file misc.h.

Function Documentation

◆ a_Misc_content_type_check()

int a_Misc_content_type_check ( const char *  EntryType,
const char *  DetectedType 
)

Check the server-supplied 'Content-Type' against our detected type.

(some servers seem to default to "text/plain").

Returns
  • 0, if they match
  • -1, if a mismatch is detected

There are many MIME types Dillo doesn't know, they're handled as "application/octet-stream" (as the SPEC says).

A mismatch happens when receiving a binary stream as "text/plain" or "text/html", or an image that's not an image of its kind.

Note: this is a basic security procedure.

Definition at line 321 of file misc.c.

References _MSG, dStrnAsciiCasecmp(), and MimeTypes.

Referenced by Cache_process_queue().

◆ a_Misc_content_type_cmp()

int a_Misc_content_type_cmp ( const char *  ct1,
const char *  ct2 
)

Compare two Content-Type strings.

Return 0 if they are equivalent, and 1 otherwise.

Definition at line 274 of file misc.c.

References a_Misc_parse_content_type(), dFree(), and dStrAsciiCasecmp().

Referenced by a_Cache_set_content_type(), and Html_update_content_type().

◆ a_Misc_encode_base64()

char * a_Misc_encode_base64 ( const char *  in)

Encodes string using base64 encoding.

Return value: new string or NULL if input string is empty.

Definition at line 425 of file misc.c.

References dMalloc().

Referenced by a_Http_set_proxy_passwd(), and Auth_do_auth_dialog_cb().

◆ a_Misc_escape_chars()

char * a_Misc_escape_chars ( const char *  str,
const char *  esc_set 
)

Escape characters as XX sequences.

Return value: New string.

Definition at line 26 of file misc.c.

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

Referenced by a_Dialog_open_file(), and makeStartUrl().

◆ a_Misc_expand_tabs()

int a_Misc_expand_tabs ( char **  start,
char *  end,
char *  buf,
int  buflen 
)

Takes a string and converts any tabs to spaces.

Definition at line 54 of file misc.c.

References a_Utf8_combining_char(), a_Utf8_decode(), and TAB_SIZE.

◆ a_Misc_file2dstr()

Dstr * a_Misc_file2dstr ( const char *  filename)

Load a local file into a dStr.

Return value: dStr on success, NULL on error. TODO: a filesize threshold may be implemented.

Definition at line 464 of file misc.c.

References dStr_append_l(), and dStr_sized_new().

Referenced by StyleEngine::buildUserStyle().

◆ a_Misc_get_content_type_from_data()

int a_Misc_get_content_type_from_data ( void *  Data,
size_t  Size,
const char **  PT 
)

Detects 'Content-Type' from a data stream sample.

It uses the magic(5) logic from file(1). Currently, it only checks the few mime types that Dillo supports.

'Data' is a pointer to the first bytes of the raw data.

Return value: (0 on success, 1 on doubt, 2 on lack of data).

Definition at line 136 of file misc.c.

References a_Utf8_end_of_char(), a_Utf8_test(), dIsspace, dStrnAsciiCasecmp(), DT_IMAGE_GIF, DT_IMAGE_JPG, DT_IMAGE_PNG, DT_OCTET_STREAM, DT_TEXT_HTML, DT_TEXT_PLAIN, MimeTypes, and MIN.

Referenced by Cache_process_queue().

◆ a_Misc_parse_content_type()

void a_Misc_parse_content_type ( const char *  type,
char **  major,
char **  minor,
char **  charset 
)

Parse Content-Type string, e.g., "text/html; charset=utf-8".

Content-Type is defined in RFC 2045 section 5.1.

Definition at line 210 of file misc.c.

References d_isascii, dStriAsciiStr(), dStrnAsciiCasecmp(), and dStrndup().

Referenced by a_Cache_set_content_type(), a_Misc_content_type_cmp(), a_UIcmd_view_page_source(), and DilloHtml::DilloHtml().

◆ a_Misc_parse_geometry()

int a_Misc_parse_geometry ( char *  geom,
int *  x,
int *  y,
int *  w,
int *  h 
)

Parse a geometry string.

Definition at line 360 of file misc.c.

References _MSG.

Referenced by main(), and parseOption().

◆ a_Misc_parse_search_url()

int a_Misc_parse_search_url ( char *  source,
char **  label,
char **  urlstr 
)

Parse dillorc's search_url string ([<label> ]<url>) Return value: -1 on error, 0 on success (and label and urlstr pointers)

Definition at line 391 of file misc.c.

References MIN, and MSG.

Referenced by a_Dialog_input(), and UIcmd_make_search_str().