67 const char *eol,
const char *
name,
73 if ( ( ! match ) || ( match >= eol ) )
79 if (
attr->value[0] ==
'"' )
125 DBGC2 (
image,
"MIME %s found content transfer encoding\n",
132 .name =
"Content-Type:",
137 .name =
"Content-Transfer-Encoding:",
185 for ( line = text ; ; line =
next ) {
188 eol =
strchr ( line,
'\n' );
190 DBGC (
image,
"MIME %s premature end of file\n",
199 if ( eol[-1] ==
'\r' )
240 struct image *decoded ) {
265 struct image *decoded ) {
281 DBGC (
image,
"MIME %s could not decode base64: %s\n",
285 assert ( ( (
size_t )
len ) <= max_len );
354 struct image *extracted ) {
361 DBGC (
image,
"MIME %s has unrecognised encoding\n",
365 DBGC (
image,
"MIME %s has encoding %s\n",
389 pos =
strstr ( pos,
"\n--" );
394 boundary->
len ) != 0 ) {
417 pos += ( 2 + boundary->
len );
420 if (
strcmp ( pos,
"--" ) == 0 )
424 while ( ( *pos !=
'\n' ) &&
isspace ( *pos ) )
428 if ( *pos !=
'\n' ) {
429 DBGC (
image,
"MIME %s malformed boundary marker\n",
452 struct image *extracted ) {
471 DBGC (
image,
"MIME %s found part at [%#zx,%#zx)\n",
481 DBGC (
image,
"MIME %s found part with type %s\n",
516 .name =
"multipart/mixed",
520 .name =
"text/x-ipxe",
#define NULL
NULL pointer (VOID *).
struct arbelprm_rc_send_wqe rc
pseudo_bit_t value[0x00020]
uint8_t headers[IB_MAX_HEADER_SIZE]
int image_extract_exec(struct image *image)
Extract and execute image.
#define assert(condition)
Assert a condition at run-time.
int base64_decode(const char *encoded, void *data, size_t len)
Base64-decode string.
static size_t base64_decoded_max_len(const char *encoded)
Calculate maximum length of base64-decoded string.
int isspace(int character)
Check to see if character is a space.
uint32_t next
Next descriptor address.
uint32_t type
Operating system type.
struct ena_llq_option header
Header locations.
#define __unused
Declare a variable or data structure as unused.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define ENOENT
No such file or directory.
#define EINVAL
Invalid argument.
#define ENOTSUP
Operation not supported.
int image_set_len(struct image *image, size_t len)
Set image length.
#define PROBE_NORMAL
Normal image probe priority.
#define __image_type(probe_order)
An executable image type.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
uint8_t attr
Type and attributes.
static int mime_extract(struct image *image, struct image *extracted)
Extract MIME image.
static void mime_parse_encoding(struct image *image, const char *value, const char *eol __unused, struct mime_headers *headers)
Parse Content-Transfer-Encoding header.
static const struct mime_type mime_types[]
MIME types.
static const struct mime_encoding mime_encodings[]
MIME encodings.
static void mime_parse_attribute(struct image *image, const char *value, const char *eol, const char *name, struct mime_attribute *attr)
Parse MIME attribute.
static int mime_probe(struct image *image)
Probe MIME image.
static void mime_parse_type(struct image *image, const char *value, const char *eol, struct mime_headers *headers)
Parse Content-Type header.
static int mime_decode_identity(struct image *image, const struct mime_headers *headers, struct image *decoded)
Decode MIME entity with identity encoding.
static const char * mime_part_end(struct image *image, const struct mime_attribute *boundary, const char *pos)
Find end of current part in multipart MIME image.
static const struct mime_type * mime_type(const char *name)
Identify MIME type.
static int mime_decode_base64(struct image *image, const struct mime_headers *headers, struct image *decoded)
Decode MIME entity with Base64 encoding.
static int mime_parse(struct image *image, const char *text, struct mime_headers *headers)
Parse MIME headers.
static const char * mime_part_next(struct image *image, const struct mime_attribute *boundary, const char *pos)
Find start of next part in multipart MIME image.
static const struct mime_header * mime_header(const char *line)
Identify MIME header.
static int mime_extract_entity(struct image *image, const struct mime_headers *headers, struct image *extracted)
Extract single MIME entity.
static int mime_extract_part(struct image *image, const struct mime_headers *headers, struct image *extracted)
Extract part from multipart MIME image.
static const struct mime_encoding * mime_encoding(const char *name)
Identify MIME encoding.
uint32_t end
Ending offset.
char * strerror(int errno)
Retrieve string representation of error number.
int strcmp(const char *first, const char *second)
Compare strings.
char * strchr(const char *src, int character)
Find character within a string.
int strncasecmp(const char *first, const char *second, size_t max)
Compare case-insensitive strings.
int strncmp(const char *first, const char *second, size_t max)
Compare strings.
char * strstr(const char *haystack, const char *needle)
Find substring.
char * strcasestr(const char *haystack, const char *needle)
Find case-insensitive substring.
size_t strlen(const char *src)
Get length of string.
An executable image type.
const void * data
Read-only data.
size_t len
Length of raw file image.
const char * text
Read-only text (guaranteed to be NUL terminated).
void * rwdata
Writable data.
size_t len
Length of value.
const char * value
Attribute value (not NUL-terminated).
A MIME content transfer encoding.
int(* decode)(struct image *image, const struct mime_headers *headers, struct image *decoded)
Decode entity.