ELinks 0.18.0
string Struct Reference

#include <string.h>

Data Fields

int magic
union { 
   const char *   csource 
   char *   source 
}; 
int length

(Note that these are not member symbols.)

struct stringadd_long_to_string (struct string *string, long long number)
struct stringadd_knum_to_string (struct string *string, long long num)
struct stringadd_xnum_to_string (struct string *string, long long xnum)
struct stringadd_duration_to_string (struct string *string, long seconds)
struct stringadd_timeval_to_string (struct string *string, timeval_T *timeval)
NONSTATIC_INLINE struct stringadd_to_string (struct string *string, const char *source)
NONSTATIC_INLINE struct stringadd_crlf_to_string (struct string *string)
NONSTATIC_INLINE struct stringadd_string_to_string (struct string *string, const struct string *from)
struct stringadd_file_to_string (struct string *string, const char *filename)
NONSTATIC_INLINE struct stringadd_char_to_string (struct string *string, unsigned char character)
struct stringinit_string (struct string *string)
 Initializes the passed string struct by preallocating the string.source member.
void done_string (struct string *string)
 Resets string and free()s the string.source member.
struct stringstring_concat (struct string *string,...)
 Adds each C string to string until a terminating (char *) NULL is met.
struct stringadd_xchar_to_string (struct string *string, unsigned char character, int times)
 Extends the string with times number of character.
struct stringadd_format_to_string (struct string *string, const char *format,...)
 Add printf()-style format string to string.
static char * squeezastring (struct string *string)
 Get a regular newly allocated stream of bytes from string.

They encode and add to the string.

This way we don't need to first allocate and encode a temporary string, add it and then free it. Can be used as backends for encoder.

struct stringadd_string_replace (struct string *string, char *src, int len, unsigned char replaceable, unsigned char replacement)
 A simple generic encoder.
#define add_optname_to_string(str, src, len)
#define add_real_optname_to_string(str, src, len)
 Maybe a bad name but it is actually the real name, but you may also think of it as adding the decoded option name.
struct stringadd_html_to_string (struct string *string, const char *html, int htmllen)
 Convert reserved chars to html &#xx;.
struct stringadd_cp_html_to_string (struct string *string, int src_codepage, const char *html, int htmllen)
 Convert reserved or non-ASCII chars to html &#xx;.
struct stringadd_quoted_to_string (struct string *string, const char *q, int qlen)
 Escapes \ and " with a \.
struct stringadd_shell_quoted_to_string (struct string *string, const char *src, int len)
 Adds ', len bytes of src with all single-quotes converted to '\'', and ' to string.

◆ add_char_to_string()

NONSTATIC_INLINE struct string * add_char_to_string ( struct string * string,
unsigned char character )
related

◆ add_cp_html_to_string()

struct string * add_cp_html_to_string ( struct string * string,
int src_codepage,
const char * html,
int htmllen )
related

Convert reserved or non-ASCII chars to html &#xx;.

The resulting string can be correctly parsed in any charset where bytes 0x20...0x7E match ASCII.

◆ add_crlf_to_string()

NONSTATIC_INLINE struct string * add_crlf_to_string ( struct string * string)
related

◆ add_duration_to_string()

struct string * add_duration_to_string ( struct string * string,
long seconds )
related

◆ add_file_to_string()

struct string * add_file_to_string ( struct string * string,
const char * filename )
related

◆ add_format_to_string()

struct string * add_format_to_string ( struct string * string,
const char * format,
... )
related

Add printf()-style format string to string.

◆ add_html_to_string()

struct string * add_html_to_string ( struct string * string,
const char * html,
int htmllen )
related

Convert reserved chars to html &#xx;.

This function copies bytes 0x80...0xFF unchanged, so the caller should ensure that the resulting HTML will be parsed with the same charset as the original string. (This function cannot use the &#160; syntax for non-ASCII, because HTML wants Unicode numbers there and this function does not know the charset of the input data.)

◆ add_knum_to_string()

struct string * add_knum_to_string ( struct string * string,
long long num )
related

◆ add_long_to_string()

struct string * add_long_to_string ( struct string * string,
long long number )
related

◆ add_optname_to_string

#define add_optname_to_string ( str,
src,
len )
related
Value:
add_string_replace(str, src, len, '.', '*')
struct string * add_string_replace(struct string *string, char *src, int len, unsigned char replaceable, unsigned char replacement)
A simple generic encoder.
Definition conv.c:269

◆ add_quoted_to_string()

struct string * add_quoted_to_string ( struct string * string,
const char * q,
int qlen )
related

Escapes \ and " with a \.

◆ add_real_optname_to_string

#define add_real_optname_to_string ( str,
src,
len )
related
Value:
add_string_replace(str, src, len, '*', '.')

Maybe a bad name but it is actually the real name, but you may also think of it as adding the decoded option name.

◆ add_shell_quoted_to_string()

struct string * add_shell_quoted_to_string ( struct string * string,
const char * src,
int len )
related

Adds ', len bytes of src with all single-quotes converted to '\'', and ' to string.

◆ add_string_replace()

struct string * add_string_replace ( struct string * string,
char * src,
int len,
unsigned char replaceable,
unsigned char replacement )
related

A simple generic encoder.

Should maybe take replaceable as a string so we could also use it for adding shell safe strings.

◆ add_string_to_string()

NONSTATIC_INLINE struct string * add_string_to_string ( struct string * string,
const struct string * from )
related

◆ add_timeval_to_string()

struct string * add_timeval_to_string ( struct string * string,
timeval_T * timeval )
related

◆ add_to_string()

NONSTATIC_INLINE struct string * add_to_string ( struct string * string,
const char * source )
related

◆ add_xchar_to_string()

struct string * add_xchar_to_string ( struct string * string,
unsigned char character,
int times )
related

Extends the string with times number of character.

◆ add_xnum_to_string()

struct string * add_xnum_to_string ( struct string * string,
long long xnum )
related

◆ done_string()

void done_string ( struct string * string)
related

Resets string and free()s the string.source member.

◆ init_string()

struct string * init_string ( struct string * string)
related

Initializes the passed string struct by preallocating the string.source member.

Returns
string if successful, or NULL if out of memory.
Postcondition
done_string(string) is safe, even if this returned NULL.

◆ squeezastring()

char * squeezastring ( struct string * string)
related

Get a regular newly allocated stream of bytes from string.

◆ string_concat()

struct string * string_concat ( struct string * string,
... )
related

Adds each C string to string until a terminating (char *) NULL is met.

Field Documentation

◆ [union]

union { ... } string

◆ csource

const char* string::csource

◆ length

int string::length

◆ magic

int string::magic

◆ source

char* string::source

The documentation for this struct was generated from the following files: