GnomeVFS - Filesystem Abstraction library
<<< Previous Page | Home | Up | Next Page >>>

# Algorithmic Sniff Buffer

## Name

Algorithmic Sniff Buffer -- algorithmic detection of mime type for select file types

## Synopsis

    GnomeVFSResult (*GnomeVFSSniffBufferSeekCall)
                                                (gpointer context,
                                                 GnomeVFSSeekPosition whence,
                                                 GnomeVFSFileOffset offset);
    GnomeVFSResult (*GnomeVFSSniffBufferReadCall)
                                                (gpointer context,
                                                 gpointer buffer,
                                                 GnomeVFSFileSize bytes,
                                                 GnomeVFSFileSize *bytes_read);
    void        gnome_vfs_mime_clear_magic_table
                                                (void);
    GnomeVFSMimeSniffBuffer* gnome_vfs_mime_sniff_buffer_new_from_handle
                                                (GnomeVFSHandle *file);
    GnomeVFSMimeSniffBuffer* gnome_vfs_mime_sniff_buffer_new_from_memory
                                                (const guchar *buffer,
                                                 gssize buffer_size);
    GnomeVFSMimeSniffBuffer* gnome_vfs_mime_sniff_buffer_new_from_existing_data
                                                (const guchar *buffer,
                                                 gssize buffer_size);
    GnomeVFSMimeSniffBuffer* gnome_vfs_mime_sniff_buffer_new_generic
                                                (GnomeVFSSniffBufferSeekCall seek_callback,
                                                 GnomeVFSSniffBufferReadCall read_callback,
                                                 gpointer context);
    void        gnome_vfs_mime_sniff_buffer_free
                                                (GnomeVFSMimeSniffBuffer *buffer);
    GnomeVFSResult gnome_vfs_mime_sniff_buffer_get
                                                (GnomeVFSMimeSniffBuffer *buffer,
                                                 gssize size);
    const char* gnome_vfs_get_mime_type_for_buffer
                                                (GnomeVFSMimeSniffBuffer *buffer);
    gboolean    gnome_vfs_sniff_buffer_looks_like_text
                                                (GnomeVFSMimeSniffBuffer *buffer);
    gboolean    gnome_vfs_sniff_buffer_looks_like_mp3
                                                (GnomeVFSMimeSniffBuffer *buffer);
    gboolean    gnome_vfs_sniff_buffer_looks_like_gzip
                                                (GnomeVFSMimeSniffBuffer *sniff_buffer,
                                                 const char *file_name);

## Description

## Details

### GnomeVFSSniffBufferSeekCall ()

    GnomeVFSResult (*GnomeVFSSniffBufferSeekCall)
                                                (gpointer context,
                                                 GnomeVFSSeekPosition whence,
                                                 GnomeVFSFileOffset offset);

`context` : |
`whence` : |
`offset` : |
Returns : |

### GnomeVFSSniffBufferReadCall ()

    GnomeVFSResult (*GnomeVFSSniffBufferReadCall)
                                                (gpointer context,
                                                 gpointer buffer,
                                                 GnomeVFSFileSize bytes,
                                                 GnomeVFSFileSize *bytes_read);

`context` : |
`buffer` : |
`bytes` : |
`bytes_read` : |
Returns : |

### gnome_vfs_mime_clear_magic_table ()

    void        gnome_vfs_mime_clear_magic_table
                                                (void);

### gnome_vfs_mime_sniff_buffer_new_from_handle ()

    GnomeVFSMimeSniffBuffer* gnome_vfs_mime_sniff_buffer_new_from_handle
                                                (GnomeVFSHandle *file);

`file` : |
Returns : |

### gnome_vfs_mime_sniff_buffer_new_from_memory ()

    GnomeVFSMimeSniffBuffer* gnome_vfs_mime_sniff_buffer_new_from_memory
                                                (const guchar *buffer,
                                                 gssize buffer_size);

`buffer` : |
`buffer_size` : |
Returns : |

### gnome_vfs_mime_sniff_buffer_new_from_existing_data ()

    GnomeVFSMimeSniffBuffer* gnome_vfs_mime_sniff_buffer_new_from_existing_data
                                                (const guchar *buffer,
                                                 gssize buffer_size);

`buffer` : |
`buffer_size` : |
Returns : |

### gnome_vfs_mime_sniff_buffer_new_generic ()

    GnomeVFSMimeSniffBuffer* gnome_vfs_mime_sniff_buffer_new_generic
                                                (GnomeVFSSniffBufferSeekCall seek_callback,
                                                 GnomeVFSSniffBufferReadCall read_callback,
                                                 gpointer context);

`seek_callback` : |
`read_callback` : |
`context` : |
Returns : |

### gnome_vfs_mime_sniff_buffer_free ()

    void        gnome_vfs_mime_sniff_buffer_free
                                                (GnomeVFSMimeSniffBuffer *buffer);

`buffer` : |

### gnome_vfs_mime_sniff_buffer_get ()

    GnomeVFSResult gnome_vfs_mime_sniff_buffer_get
                                                (GnomeVFSMimeSniffBuffer *buffer,
                                                 gssize size);

`buffer` : |
`size` : |
Returns : |

### gnome_vfs_get_mime_type_for_buffer ()

    const char* gnome_vfs_get_mime_type_for_buffer
                                                (GnomeVFSMimeSniffBuffer *buffer);

This routine uses a magic database to guess the mime type of the data represented by `buffer`.

`buffer` : | a sniff buffer referencing either a file or data in memory
Returns : | a pointer to an internal copy of the mime-type for `buffer`.

### gnome_vfs_sniff_buffer_looks_like_text ()

    gboolean    gnome_vfs_sniff_buffer_looks_like_text
                                                (GnomeVFSMimeSniffBuffer *buffer);

`buffer` : |
Returns : |

### gnome_vfs_sniff_buffer_looks_like_mp3 ()

    gboolean    gnome_vfs_sniff_buffer_looks_like_mp3
                                                (GnomeVFSMimeSniffBuffer *buffer);

`buffer` : |
Returns : |

### gnome_vfs_sniff_buffer_looks_like_gzip ()

    gboolean    gnome_vfs_sniff_buffer_looks_like_gzip
                                                (GnomeVFSMimeSniffBuffer *sniff_buffer,
                                                 const char *file_name);

`sniff_buffer` : |
`file_name` : |
Returns : |

<<< Previous Page | Home | Up | Next Page >>>
MIME types & the Application Registry | Application Registry