mime.h File Reference
libpurple

Rudimentary parsing of multi-part MIME messages into more accessible structures. More...

`#include <glib.h>`

Go to the source code of this file.

## Typedefs

typedef struct _PurpleMimeDocument | PurpleMimeDocument
| A MIME document.
typedef struct _PurpleMimePart | PurpleMimePart
| A part of a multipart MIME document.

## Functions

PurpleMimeDocument * | purple_mime_document_new (void)
| Allocate an empty MIME document.
void | purple_mime_document_free (PurpleMimeDocument *doc)
| Frees memory used in a MIME document and all of its parts and fields. More...
PurpleMimeDocument * | purple_mime_document_parse (const char *buf)
| Parse a MIME document from a NUL-terminated string. More...
PurpleMimeDocument * | purple_mime_document_parsen (const char *buf, gsize len)
| Parse a MIME document from a string. More...
void | purple_mime_document_write (PurpleMimeDocument *doc, GString *str)
| Write (append) a MIME document onto a GString.
GList * | purple_mime_document_get_fields (PurpleMimeDocument *doc)
| The list of fields in the header of a document. More...
const char * | purple_mime_document_get_field (PurpleMimeDocument *doc, const char *field)
| Get the value of a specific field in the header of a document. More...
void | purple_mime_document_set_field (PurpleMimeDocument *doc, const char *field, const char *value)
| Set or replace the value of a specific field in the header of a document. More...
GList * | purple_mime_document_get_parts (PurpleMimeDocument *doc)
| The list of parts in a multipart document. More...
PurpleMimePart * | purple_mime_part_new (PurpleMimeDocument *doc)
| Create and insert a new part into a MIME document. More...
GList * | purple_mime_part_get_fields (PurpleMimePart *part)
| The list of fields in the header of a document part. More...
const char * | purple_mime_part_get_field (PurpleMimePart *part, const char *field)
| Get the value of a specific field in the header of a document part. More...
char * | purple_mime_part_get_field_decoded (PurpleMimePart *part, const char *field)
| Get the decoded value of a specific field in the header of a document part.
void | purple_mime_part_set_field (PurpleMimePart *part, const char *field, const char *value)
| Set or replace the value of a specific field in the header of a document. More...
const char * | purple_mime_part_get_data (PurpleMimePart *part)
| Get the (possibly encoded) data portion of a MIME document part. More...
void | purple_mime_part_get_data_decoded (PurpleMimePart *part, guchar **data, gsize *len)
| Get the data portion of a MIME document part, after attempting to decode it according to the content-transfer-encoding field. More...
gsize | purple_mime_part_get_length (PurpleMimePart *part)
| Get the length of the data portion of a MIME document part. More...
void | purple_mime_part_set_data (PurpleMimePart *part, const char *data)

## Detailed Description

Rudimentary parsing of multi-part MIME messages into more accessible structures.

Definition in file mime.h.

## Function Documentation

void purple_mime_document_free | ( | PurpleMimeDocument * | doc | ) |

Frees memory used in a MIME document and all of its parts and fields.

Parameters

  doc | The MIME document to free.

const char* purple_mime_document_get_field | ( | PurpleMimeDocument * | doc,
|  | const char * | field
| ) |  |

Get the value of a specific field in the header of a document.

Parameters

  doc | The MIME document.
  field | Case-insensitive field name.

Returns
  Value associated with the indicated header field, or NULL if the field doesn't exist.

GList* purple_mime_document_get_fields | ( | PurpleMimeDocument * | doc | ) |

The list of fields in the header of a document.

Parameters

  doc | The MIME document.

Note
  The return value of this function must not be modified or freed.

Returns
  A list of strings indicating the fields (but not the values of the fields) in the header of doc.

GList* purple_mime_document_get_parts | ( | PurpleMimeDocument * | doc | ) |

The list of parts in a multipart document.

Parameters

  doc | The MIME document.

Note
  The return value of this function must not be modified or freed.

Returns
  List of PurpleMimePart contained within doc.

PurpleMimeDocument* purple_mime_document_parse | ( | const char * | buf | ) |

Parse a MIME document from a NUL-terminated string.

Parameters

  buf | The NULL-terminated string containing the MIME-encoded data.

Returns
  A MIME document.

PurpleMimeDocument* purple_mime_document_parsen | ( | const char * | buf,
|  | gsize | len
| ) |  |

Parse a MIME document from a string.

Parameters

  buf | The string containing the MIME-encoded data.
  len | Length of buf.

Returns
  A MIME document.

void purple_mime_document_set_field | ( | PurpleMimeDocument * | doc,
|  | const char * | field,
|  | const char * | value
| ) |  |

Set or replace the value of a specific field in the header of a document.

Parameters

  doc | The MIME document.
  field | Case-insensitive field name.
  value | Value to associate with the indicated header field, of NULL to remove the field.

const char* purple_mime_part_get_data | ( | PurpleMimePart * | part | ) |

Get the (possibly encoded) data portion of a MIME document part.

Parameters

  part | The MIME document part.

Returns
  NULL-terminated data found in the document part

void purple_mime_part_get_data_decoded | ( | PurpleMimePart * | part,
|  | guchar ** | data,
|  | gsize * | len
| ) |  |

Get the data portion of a MIME document part, after attempting to decode it according to the content-transfer-encoding field.

If the specified encoding method is not supported, this function will return NULL.

Parameters

  part | The MIME documemt part.
  data | Buffer for the data.
  len | The length of the buffer.

const char* purple_mime_part_get_field | ( | PurpleMimePart * | part,
|  | const char * | field
| ) |  |

Get the value of a specific field in the header of a document part.

Parameters

  part | The MIME document part.
  field | Case-insensitive name of the header field.

Returns
  Value of the specified header field, or NULL if the field doesn't exist.

GList* purple_mime_part_get_fields | ( | PurpleMimePart * | part | ) |

The list of fields in the header of a document part.

Parameters

  part | The MIME document part.

Note
  The return value of this function must not be modified or freed.

Returns
  List of strings indicating the fields (but not the values of the fields) in the header of part.

gsize purple_mime_part_get_length | ( | PurpleMimePart * | part | ) |

Get the length of the data portion of a MIME document part.

Parameters

  part | The MIME document part.

Returns
  Length of the data in the document part.

PurpleMimePart* purple_mime_part_new | ( | PurpleMimeDocument * | doc | ) |

Create and insert a new part into a MIME document.

Parameters

  doc | The new part's parent MIME document.

void purple_mime_part_set_field | ( | PurpleMimePart * | part,
|  | const char * | field,
|  | const char * | value
| ) |  |

Set or replace the value of a specific field in the header of a document.

Parameters

  part | The part of the MIME document.
  field | Case-insensitive field name
  value | Value to associate with the indicated header field, of NULL to remove the field.