#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <unistd.h>
#include <clist.h>
#include "defines.h"
#include "intl.h"
#include "logging.h"
#include "x_alloc.h"
#include "utils.h"
Include dependency graph for utils.c:
Defines | |
#define | SMTP_MAX_LINE_LEN 998 |
#define | MAX_ALLOWED_BEGIN_LINE_LEN (1024 - 1) |
#define | SCAN_FUNC_NB 4 |
Typedefs | |
typedef XePUtilsInlinedData *(* | XePUtilsTextScanFunc )(const char *data, size_t size) |
Functions | |
char * | a_Utils_printf (char *template, XePUtilsFormat *format) |
char * | a_Utils_append (char *dest,...) |
void | a_Utils_string_unfold (char *string) |
char * | a_Utils_magic_data_mime_type (const char *data, size_t size) |
char * | a_Utils_magic_file_mime_type (const char *filename) |
char * | a_Utils_magic_get_charset (const char *magic_mime_type) |
void | a_Utils_format_size (char *buf, size_t size) |
int | a_Utils_write (int fd, const char *data, size_t size) |
char * | a_Utils_save_temp (const char *data, size_t size) |
int | a_Utils_read (int fd, char **data, size_t *size) |
int | a_Utils_load_file (const char *filename, char **data, size_t *size) |
int | a_Utils_file_backup (const char *filename) |
XePUtilsInlinedData * | a_Utils_inlined_text_new (XePUtilsInlinedDataType type, const char *data, size_t size, const char *plain_text, size_t plain_size, int privacy_sig_status, int privacy_enc_status, void *extra) |
XePUtilsInlinedData * | a_Utils_inlined_file_new (XePUtilsInlinedDataType type, const char *data, size_t size, const char *filename, void *extra) |
void | a_Utils_inlined_list_free (clist *inlined_list) |
void | a_Utils_inlined_data_free (XePUtilsInlinedData *inlined_data) |
int | a_Utils_inlined_file_decode_as (XePUtilsInlinedData *inlined_data, const char *save_as) |
char * | a_Utils_uulib_decode_file (const char *filename, void(*msg_cb)(void *adata, const char *msg, int msg_type), void(*busy_cb)(void *adata, uuprogress *aprogress), void *data) |
XePUtilsInlinedData * | a_Utils_data_has_uuencoded (const char *data, size_t size) |
XePUtilsInlinedData * | a_Utils_data_has_yencoded (const char *data, size_t size) |
XePUtilsInlinedData * | a_Utils_data_has_yencoded2 (const char *data, size_t size) |
XePUtilsInlinedData * | a_Utils_data_has_binhex (const char *data, size_t size) |
int | a_Utils_orig_date_to_localtime (struct mailimf_date_time *date_time, struct tm *local_tm) |
void * | a_Utils_memmem (const void *haystack, size_t haystack_len, const void *needle, size_t needle_len) |
int | a_Utils_quote_text_for_reply (const char *text, size_t text_size, const char *text_charset, char **quoted_text) |
clist * | a_Utils_parse_mailto (const char *mailto) |
int | a_Utils_exec_cmd (char *cmd, int fd_in, int fd_out, int fd_err, int *fd_mon, pid_t *pid, int sync) |
char * | a_Utils_basename (const char *path) |
char * | a_Utils_magic_get_bare_mime_type (const char *mime_type) |
void | a_Utils_to_b_encoding (const char *s, size_t *is, char *t, size_t *it) |
void | a_Utils_to_q_encoding (const char *s, size_t *is, char *t, size_t *it, int is_phrase, int is_comment) |
char * | a_Utils_encode_8bit_header (const char *text, const char *charset, XePUtilsEncodingType encoding, int is_phrase, int is_comment) |
char * | a_Utils_encode_8bit_subject (const char *subject, const char *charset, XePUtilsEncodingType encoding) |
int | a_Utils_has_8bit (const char *text, size_t size) |
clist * | a_Utils_parse_body_text (const char *text, size_t size) |
const char * | a_Utils_inlined_data_type_as_string (XePUtilsInlinedDataType type) |
int | a_Utils_text_new_copy_with_rfc2822_lines (const char *text, size_t size, char **rfc2822_text, size_t *rfc2822_size) |
Variables | |
long int | timezone |
XePUtilsCharsetMapping | xetpan_charsets [] |
|
|
|
|
|
Max line length supported by SMTP servers, not including |
|
|
|
Append a NULL terminated list of strings to the first one
|
|
Return the basename of a pathname
|
|
Check if in-memory data contains a BinHex 4.0 encoded data Scan the data for a valid "(This file must be converted with BinHex 4.0)" line followed by a stream of characters delimited by ':'. Each line must by of length 64 but the last one which size must be >= 2 and <= 65 including the trailing ':'.
|
Here is the call graph for this function:
|
Check if in-memory data contains a uuencoded or xxencoded data Scan the data for a valid "begin 000 filename" line
|
Here is the call graph for this function:
|
Check if in-memory data contains a yEncoded data
|
|
Check if in-memory data contains a yEnc2 encoded data Scan the data for a valid "=ybegin2 " line
|
|
Encode a header that consist of non US-ASCII characters using the scheme proposed by RFC 2047 BUG: Currently, there is no limitation on the length of the result string even though RFC 2047 says we should not overcome the 76 limit and RFC 822/2822 the 998 limit
|
Here is the call graph for this function:
|
Encode a subject that contains 8bit bytes. If the subject is pure 7bit, return a copy of it.
|
Here is the call graph for this function:
|
Execute a shell command Uses the double fork technique
|
|
Create a backup of a file The file is renamed by appending to its name the suffix ".bak" This function reports success if the file does not exist.
|
|
Format a size into a readable string with an adhoc unit Maximum supported size: 9999 Yotta bytes.. 9999*2^70.
|
|
Check if the string contains 8bit bytes
|
|
Free the data structure representing an inlined file
|
|
Return the inlined data type as a human-readable string
|
|
Decode and save uuencoded data from a XePUtilsUUData structure
|
Here is the call graph for this function:
|
Create a structure containing the encoded and inlined file
|
|
Free a list of XePUtilsInlinedData
|
Here is the call graph for this function:
|
|
|
Load file into memory
|
Here is the call graph for this function:
|
Guess the mime type of in-memory data using libmagic
|
|
Guess the mime type of a filedata using libmagic
|
|
Strip unwanted info provided by libmagic in the mime type: E.g. when libmagic returns "text/plain, English", this function will return the bare MIME type ("text/plain")
|
|
Extract the charset part of a magic mime type
|
|
Find an array of chars in a block of memory. This is equivalent in function to GNU's memmem and will use it if available at compile time |
|
Convert a message original date to a local time
|
|
Parse a body text and return a structured description This function parses a text and detect text parts and inlined attachments. Text parts which are signed/encrypted are detected
|
Here is the call graph for this function:
|
Parse a mailto URL scheme and return a list of header/value pairs
|
|
Format a string using a template Tokens are prefixed with '%'
|
|
Quote a text for reply TODO: This functions uses the global user preference to quote the text.
|
|
Read data from a file descriptor. The file descriptor must be a file from the file system because it preallocates a buffer with a size taken from the result of fstat.
|
|
Save data in a temporary file
|
Here is the call graph for this function:
|
FIXME: this function should be called 'clear_crlf' |
|
Ensure line endings are
|
|
Encode the next 3 bytes of a string into 4 base64 bytes When the function encounters the end of string, it does the padding as described in RFC 2045 and trailing '=' are added to the output. The target string must be allocated in a way that it can hold the next 4 bytes.
|
|
Encode the next byte of a string into quoted-printable This version encodes all non mail-safe characters as defined in RFC 2047 and encodes according to RFC 2045. The output is suitable for inclusion in field body (RFC 2047). The non-encoded characters are the alphanumerical ones (a-z, A-Z, 0-9) and some mail-safe characters ('*', '+', '-', '/') plus some others that are encoded only if in a 'phrase' (is_phrase set) ("'", ".", "," ":") plus some others that are encoded only if in a phrase or in a 'comment' (is_comment set) ('(' and ')'). The NUL character is encoded to =00. The alphabetic hex digits are in capital.
|
|
Decode a file using UUDeview library (uulib)
|
|
Write data to a file descriptor
|
|
|
|
|