autoar-format-filter

## autoar-format-filter autoar-format-filter — Utilities for handling archive formats and filters |

## Functions

int | (*AutoarFormatFunc) ()
int | (*AutoarFilterFunc) ()
int | autoar_format_last ()
gboolean | autoar_format_is_valid ()
const char * | autoar_format_get_mime_type ()
const char * | autoar_format_get_extension ()
const char * | autoar_format_get_description ()
gchar * | autoar_format_get_description_libarchive ()
int | autoar_format_get_format_libarchive ()
AutoarFormatFunc | autoar_format_get_libarchive_read ()
AutoarFormatFunc | autoar_format_get_libarchive_write ()
int | autoar_filter_last ()
gboolean | autoar_filter_is_valid ()
const char * | autoar_filter_get_mime_type ()
const char * | autoar_filter_get_extension ()
const char * | autoar_filter_get_description ()
gchar * | autoar_filter_get_description_libarchive ()
int | autoar_filter_get_filter_libarchive ()
AutoarFilterFunc | autoar_filter_get_libarchive_read ()
AutoarFilterFunc | autoar_filter_get_libarchive_write ()
gchar * | autoar_format_filter_get_mime_type ()
gchar * | autoar_format_filter_get_extension ()
gchar * | autoar_format_filter_get_description ()

## Types and Values

enum | AutoarFormat
enum | AutoarFilter

## Includes

    #include <gnome-autoar/autoar.h>

## Description

autoar-format-filter is a collection of functions providing information of archive formats and filters.

## Functions

### AutoarFormatFunc ()

    int
    (*AutoarFormatFunc) (struct archive *a);

### AutoarFilterFunc ()

    int
    (*AutoarFilterFunc) (struct archive *a);

### autoar_format_last ()

    int
    autoar_format_last (void);

Gets the maximal allowed values of AutoarFormat

#### Returns

maximal allowed values of AutoarFormat

### autoar_format_is_valid ()

    gboolean
    autoar_format_is_valid (AutoarFormat format);

Checks whether an AutoarFormat is valid.

#### Parameters

format | an AutoarFormat |

#### Returns

`TRUE` if the value of `format` is valid

### autoar_format_get_mime_type ()

    const char *
    autoar_format_get_mime_type (AutoarFormat format);

Gets the MIME type of the format from the internal static data.

#### Parameters

format | an AutoarFormat |

#### Returns

an MIME type.

[transfer none]

### autoar_format_get_extension ()

    const char *
    autoar_format_get_extension (AutoarFormat format);

Gets the file name extension of the format from the internal static data.

#### Parameters

format | an AutoarFormat |

#### Returns

a file name extension.

[transfer none]

### autoar_format_get_description ()

    const char *
    autoar_format_get_description (AutoarFormat format);

Gets description of the format from the internal static data.

#### Parameters

format | an AutoarFormat |

#### Returns

description about the format.

[transfer none]

### autoar_format_get_description_libarchive ()

    gchar *
    autoar_format_get_description_libarchive
                                   (AutoarFormat format);

Gets description of the format from libarchive. This function creates and destroys an archive object in order to get the description string.

#### Parameters

format | an AutoarFormat |

#### Returns

description about the format. Free the returned string with `g_free()`.

[transfer full]

### autoar_format_get_format_libarchive ()

    int
    autoar_format_get_format_libarchive (AutoarFormat format);

Gets the format code used by libarchive. You can use the return value as the argument for `archive_read_support_format_by_code()` and `archive_write_set_format()`. However, some format cannot be set using these two functions because of problems inside libarchive. Use `autoar_format_get_libarchive_read()` and `autoar_format_get_libarchive_write()` to get the function pointer is the more reliable way to set format on the archive object.

#### Parameters

format | an AutoarFormat |

#### Returns

an integer

### autoar_format_get_libarchive_read ()

    AutoarFormatFunc
    autoar_format_get_libarchive_read (AutoarFormat format);

Gets the function used to set format on the object returned by `archive_read_new()`.

[skip]

#### Parameters

format | an AutoarFormat |

#### Returns

function pointer to the setter function provided by libarchive

### autoar_format_get_libarchive_write ()

    AutoarFormatFunc
    autoar_format_get_libarchive_write (AutoarFormat format);

Gets the function used to set format on the object returned by `archive_write_new()`.

[skip]

#### Parameters

format | an AutoarFormat |

#### Returns

function pointer to the setter function provided by libarchive

### autoar_filter_last ()

    int
    autoar_filter_last (void);

Gets the maximal allowed values of AutoarFilter

#### Returns

maximal allowed values of AutoarFilter

### autoar_filter_is_valid ()

    gboolean
    autoar_filter_is_valid (AutoarFilter filter);

Checks whether an AutoarFilter is valid.

#### Parameters

filter | an AutoarFilter |

#### Returns

`TRUE` if the value of `filter` is valid

### autoar_filter_get_mime_type ()

    const char *
    autoar_filter_get_mime_type (AutoarFilter filter);

Gets the MIME type of the filter from the internal static data.

#### Parameters

filter | an AutoarFilter |

#### Returns

an MIME type.

[transfer none]

### autoar_filter_get_extension ()

    const char *
    autoar_filter_get_extension (AutoarFilter filter);

Gets the file name extension of the filter from the internal static data.

#### Parameters

filter | an AutoarFilter |

#### Returns

a file name extension.

[transfer none]

### autoar_filter_get_description ()

    const char *
    autoar_filter_get_description (AutoarFilter filter);

Gets description of the filter from the internal static data.

#### Parameters

filter | an AutoarFilter |

#### Returns

description about the filter.

[transfer none]

### autoar_filter_get_description_libarchive ()

    gchar *
    autoar_filter_get_description_libarchive
                                   (AutoarFilter filter);

Gets description of the filter from libarchive. This function creates and destroys an archive object in order to get the description string.

#### Parameters

filter | an AutoarFilter |

#### Returns

description about the filter. Free the returned string with `g_free()`.

[transfer full]

### autoar_filter_get_filter_libarchive ()

    int
    autoar_filter_get_filter_libarchive (AutoarFilter filter);

Gets the filter code used by libarchive. You can use the return value as the argument for `archive_write_add_filter()`.

#### Parameters

filter | an AutoarFilter |

#### Returns

an integer

### autoar_filter_get_libarchive_read ()

    AutoarFilterFunc
    autoar_filter_get_libarchive_read (AutoarFilter filter);

Gets the function used to add filter on the object returned by `archive_read_new()`.

[skip]

#### Parameters

filter | an AutoarFilter |

#### Returns

function pointer to the setter function provided by libarchive

### autoar_filter_get_libarchive_write ()

    AutoarFilterFunc
    autoar_filter_get_libarchive_write (AutoarFilter filter);

Gets the function used to add filter on the object returned by `archive_write_new()`.

[skip]

#### Parameters

filter | an AutoarFilter |

#### Returns

function pointer to the setter function provided by libarchive

### autoar_format_filter_get_mime_type ()

    gchar *
    autoar_format_filter_get_mime_type (AutoarFormat format,
                                        AutoarFilter filter);

Gets the MIME type for an archive `format` compressed by `filter` . This function always succeed, but it is not guaranteed that the returned MIME type exists and can be recognized by applications. Some combination of format and filter seldom exists in application, so this function can only generate the string based on some non-standard rules.

#### Parameters

format | an AutoarFormat |
filter | an AutoarFilter |

#### Returns

an MIME type. Free the returned string with `g_free()`.

[transfer full]

### autoar_format_filter_get_extension ()

    gchar *
    autoar_format_filter_get_extension (AutoarFormat format,
                                        AutoarFilter filter);

Gets the file name extension for an archive `format` compressed by `filter` . The first character of the returned string is always '.'

#### Parameters

format | an AutoarFormat |
filter | an AutoarFilter |

#### Returns

a file name extension. Free the returned string with `g_free()`.

[transfer full]

### autoar_format_filter_get_description ()

    gchar *
    autoar_format_filter_get_description (AutoarFormat format,
                                          AutoarFilter filter);

Gets the description for an archive `format` compressed by `filter` using GContentType and `autoar_format_filter_get_mime_type()`.

#### Parameters

format | an AutoarFormat |
filter | an AutoarFilter |

#### Returns

description about the archive. Free the returned string with `g_free()`.

[transfer full]

## Types and Values

### enum AutoarFormat

This is a non-negative number which represents formats supported by libarchive. A libarchive format is a file format which can store many files as a archive file.

#### Members

AUTOAR_FORMAT_ZIP | `ARCHIVE_FORMAT_ZIP`: Zip archive |
AUTOAR_FORMAT_TAR | `ARCHIVE_FORMAT_TAR_PAX_RESTRICTED`: Tar archive, use ustar format is possible. If there are extended headers which cannot be represented in the ustar format, libarchive will use pax interchage format instead. |
AUTOAR_FORMAT_CPIO | `ARCHIVE_FORMAT_CPIO_POSIX`: CPIO archive, POSIX standard cpio interchage format. |
AUTOAR_FORMAT_7ZIP | `ARCHIVE_FORMAT_7ZIP`: 7-zip archive |
AUTOAR_FORMAT_AR_BSD | `ARCHIVE_FORMAT_AR_BSD`: BSD variant of Unix archive format. This format does not support storing directories. |
AUTOAR_FORMAT_AR_SVR4 | `ARCHIVE_FORMAT_AR_GNU`: GNU/SVR4 variant of Unix archive format. This format does not support storing directories. |
AUTOAR_FORMAT_CPIO_NEWC | `ARCHIVE_FORMAT_CPIO_SVR4_NOCRC`: CPIO archive, SVR4 non-CRC variant |
AUTOAR_FORMAT_GNUTAR | `ARCHIVE_FORMAT_TAR_GNUTAR`: Tar archive, support most popular GNU extensions. |
AUTOAR_FORMAT_ISO9660 | `ARCHIVE_FORMAT_ISO9660`: Raw CD image |
AUTOAR_FORMAT_PAX | `ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE`: Tar archive, use pax interchage format |
AUTOAR_FORMAT_USTAR | `ARCHIVE_FORMAT_TAR_USTAR`: Tar archive, use old ustar format |
AUTOAR_FORMAT_XAR | `ARCHIVE_FORMAT_XAR`: Xar archive |

### enum AutoarFilter

This is a non-negative number which represents filters supported by libarchive. A libarchive filter is a filter which can convert a regular file into a compressed file.

#### Members

AUTOAR_FILTER_NONE | `ARCHIVE_FILTER_NONE`: No filter |
AUTOAR_FILTER_COMPRESS | `ARCHIVE_FILTER_COMPRESS`: UNIX-compressed |
AUTOAR_FILTER_GZIP | `ARCHIVE_FILTER_GZIP`: Gzip |
AUTOAR_FILTER_BZIP2 | `ARCHIVE_FILTER_BZIP2`: Bzip2 |
AUTOAR_FILTER_XZ | `ARCHIVE_FILTER_XZ`: XZ |
AUTOAR_FILTER_LZMA | `ARCHIVE_FILTER_LZMA`: LZMA |
AUTOAR_FILTER_LZIP | `ARCHIVE_FILTER_LZIP`: Lzip |
AUTOAR_FILTER_LZOP | `ARCHIVE_FILTER_LZOP`: LZO |
AUTOAR_FILTER_GRZIP | `ARCHIVE_FILTER_GRZIP`: GRZip |
AUTOAR_FILTER_LRZIP | `ARCHIVE_FILTER_LRZIP`: Long Range ZIP (lrzip) |