utils

## utils utils — |

## Synopsis

    void        gsf_init                        (void);
    void        gsf_shutdown                    (void);
    extern      int libgsf_major_version;
    extern      int libgsf_minor_version;
    extern      int libgsf_micro_version;

    #define     GSF_CLASS                       (name, prefix, class_init, instance_init, parent)
    #define     GSF_CLASS_FULL                  (name, prefix, class_init, instance_init, parent_type, \
    		       abstract, interface_decl)
    #define     GSF_CLASS_ABSTRACT              (name, prefix, class_init, instance_init, parent)
    #define     GSF_DYNAMIC_CLASS               (name, prefix, class_init, instance_init, parent, plugin, type)
    #define     GSF_DYNAMIC_CLASS_FULL          (name, prefix, class_init, instance_init, parent_type, \
    			       abstract, interface_decl, plugin, type)
    #define     GSF_DYNAMIC_CLASS_ABSTRACT      (name, prefix, class_init, instance_init, parent, plugin, type)
    #define     GSF_INTERFACE                   (init_func, iface_type)
    #define     GSF_INTERFACE_FULL              (type, init_func, iface_type)

    void        gsf_mem_dump                    (guint8 const *ptr,
                                                 size_t len);
    void        gsf_input_dump                  (GsfInput *input,
                                                 gboolean dump_as_hex);

    #define     GSF_OFF_T_FORMAT
    typedef     gsf_off_t;
    char*       gsf_filename_to_utf8            (const char *filename,
                                                 gboolean quoted);
    void        gsf_iconv_close                 (GIConv handle);

    guint8*     gsf_base64_encode_simple        (guint8 const *data,
                                                 size_t len);
    size_t      gsf_base64_encode_close         (guint8 const *in,
                                                 size_t inlen,
                                                 gboolean break_lines,
                                                 guint8 *out,
                                                 int *state,
                                                 unsigned int *save);
    size_t      gsf_base64_encode_step          (guint8 const *in,
                                                 size_t len,
                                                 gboolean break_lines,
                                                 guint8 *out,
                                                 int *state,
                                                 unsigned int *save);
    size_t      gsf_base64_decode_simple        (guint8 *data,
                                                 size_t len);
    size_t      gsf_base64_decode_step          (guint8 const *in,
                                                 size_t len,
                                                 guint8 *out,
                                                 int *state,
                                                 unsigned *save);
    #define     GSF_LE_GET_GINT8                (p)
    #define     GSF_LE_GET_GUINT64              (p)
    #define     GSF_LE_GET_GINT16               (p)
    #define     GSF_LE_GET_GUINT8               (p)
    #define     GSF_LE_GET_GINT32               (p)
    #define     GSF_LE_GET_GUINT16              (p)
    #define     GSF_LE_GET_GUINT32              (p)
    #define     GSF_LE_GET_FLOAT                (p)
    #define     GSF_LE_GET_DOUBLE               (p)
    guint64     gsf_le_get_guint64              (void const *p);
    float       gsf_le_get_float                (void const *p);
    double      gsf_le_get_double               (void const *p);
    #define     GSF_LE_SET_GUINT8               (p, dat)
    #define     GSF_LE_SET_GUINT16              (p, dat)
    #define     GSF_LE_SET_GUINT32              (p, dat)
    #define     GSF_LE_SET_GINT8                (p,dat)
    #define     GSF_LE_SET_GINT16               (p,dat)
    #define     GSF_LE_SET_GINT32               (p,dat)
    #define     GSF_LE_SET_FLOAT                (p,dat)
    #define     GSF_LE_SET_DOUBLE               (p,dat)
    void        gsf_le_set_float                (void *p,
                                                 float f);
    void        gsf_le_set_double               (void *p,
                                                 double d);

    GsfTimestamp* gsf_timestamp_copy            (GsfTimestamp const *stamp);
    void        gsf_timestamp_free              (GsfTimestamp *stamp);
    GsfTimestamp* gsf_timestamp_new_now         (void);
    GType       gsf_timestamp_get_type          (void);
    char*       gsf_timestamp_as_string         (GsfTimestamp const *stamp);
    int         gsf_timestamp_parse             (char const *spec,
                                                 GsfTimestamp *stamp);
    guint       gsf_timestamp_hash              (GsfTimestamp const *stamp);
    gboolean    gsf_timestamp_equal             (GsfTimestamp const *a,
                                                 GsfTimestamp const *b);
    #define     GSF_TIMESTAMP_TYPE
                GsfTimestamp;
    GsfTimestamp* gsf_timestamp_new             (GDate const *date,
                                                 glong seconds,
                                                 char const *tz);

## Description

## Details

### gsf_init ()

    void        gsf_init                        (void);

Initializes the GSF library

### gsf_shutdown ()

    void        gsf_shutdown                    (void);

De-intializes the GSF library

### libgsf_major_version

    extern int libgsf_major_version;

### libgsf_minor_version

    extern int libgsf_minor_version;

### libgsf_micro_version

    extern int libgsf_micro_version;

### GSF_CLASS()

    #define     GSF_CLASS(name, prefix, class_init, instance_init, parent)

`name` : |
`prefix` : |
`class_init` : |
`instance_init` : |
`parent` : |

### GSF_CLASS_FULL()

    #define     GSF_CLASS_FULL(name, prefix, class_init, instance_init, parent_type, \
    		       abstract, interface_decl)

`name` : |
`prefix` : |
`class_init` : |
`instance_init` : |
`parent_type` : | @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract:
`interface_decl` : |

### GSF_CLASS_ABSTRACT()

    #define     GSF_CLASS_ABSTRACT(name, prefix, class_init, instance_init, parent)

`name` : |
`prefix` : |
`class_init` : |
`instance_init` : |
`parent` : |

### GSF_DYNAMIC_CLASS()

    #define     GSF_DYNAMIC_CLASS(name, prefix, class_init, instance_init, parent, plugin, type)

`name` : |
`prefix` : |
`class_init` : |
`instance_init` : |
`parent` : |
`plugin` : |
`type` : |

### GSF_DYNAMIC_CLASS_FULL()

    #define     GSF_DYNAMIC_CLASS_FULL(name, prefix, class_init, instance_init, parent_type, \
    			       abstract, interface_decl, plugin, type)

`name` : |
`prefix` : |
`class_init` : |
`instance_init` : |
`parent_type` : | @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract: @\ abstract:
`interface_decl` : |
`plugin` : |
`type` : |

### GSF_DYNAMIC_CLASS_ABSTRACT()

    #define     GSF_DYNAMIC_CLASS_ABSTRACT(name, prefix, class_init, instance_init, parent, plugin, type)

`name` : |
`prefix` : |
`class_init` : |
`instance_init` : |
`parent` : |
`plugin` : |
`type` : |

### GSF_INTERFACE()

    #define     GSF_INTERFACE(init_func, iface_type)

`init_func` : |
`iface_type` : |

### GSF_INTERFACE_FULL()

    #define     GSF_INTERFACE_FULL(type, init_func, iface_type)

`type` : |
`init_func` : |
`iface_type` : |

### gsf_mem_dump ()

    void        gsf_mem_dump                    (guint8 const *ptr,
                                                 size_t len);

Dump `len` bytes from the memory location given by `ptr`.

`ptr` : | memory area to be dumped.
`len` : | how many bytes will be dumped.

### gsf_input_dump ()

    void        gsf_input_dump                  (GsfInput *input,
                                                 gboolean dump_as_hex);

Dumps `input`'s contents to STDOUT, optionally in hex format.

`input` : | a GsfInput
`dump_as_hex` : | If TRUE, dump in hexidecmal format

### GSF_OFF_T_FORMAT

    #define GSF_OFF_T_FORMAT	G_GINT64_FORMAT

### gsf_off_t

    typedef gint64 gsf_off_t;

### gsf_filename_to_utf8 ()

    char*       gsf_filename_to_utf8            (const char *filename,
                                                 gboolean quoted);

A utility wrapper to make sure filenames are valid utf8. Caller must g_free the result.

`filename` : | file name suitable for open(2).
`quoted` : | if TRUE, the resulting utf8 file name will be quoted (unless it is invalid).
Returns : | `filename` using utf-8 encoding for display

### gsf_iconv_close ()

    void        gsf_iconv_close                 (GIConv handle);

`handle` : |

### gsf_base64_encode_simple ()

    guint8*     gsf_base64_encode_simple        (guint8 const *data,
                                                 size_t len);

`data` : |
`len` : |
Returns : |

### gsf_base64_encode_close ()

    size_t      gsf_base64_encode_close         (guint8 const *in,
                                                 size_t inlen,
                                                 gboolean break_lines,
                                                 guint8 *out,
                                                 int *state,
                                                 unsigned int *save);

`in` : |
`inlen` : |
`break_lines` : |
`out` : |
`state` : |
`save` : |
Returns : |

### gsf_base64_encode_step ()

    size_t      gsf_base64_encode_step          (guint8 const *in,
                                                 size_t len,
                                                 gboolean break_lines,
                                                 guint8 *out,
                                                 int *state,
                                                 unsigned int *save);

`in` : |
`len` : |
`break_lines` : |
`out` : |
`state` : |
`save` : |
Returns : |

### gsf_base64_decode_simple ()

    size_t      gsf_base64_decode_simple        (guint8 *data,
                                                 size_t len);

`data` : |
`len` : |
Returns : |

### gsf_base64_decode_step ()

    size_t      gsf_base64_decode_step          (guint8 const *in,
                                                 size_t len,
                                                 guint8 *out,
                                                 int *state,
                                                 unsigned *save);

Decodes a chunk of base64 encoded data

`in` : | input stream
`len` : | max length of data to decode
`out` : | output stream
`state` : | holds the number of bits that are stored in `save`
`save` : | leftover bits that have not yet been decoded
Returns : | the number of bytes converted

### GSF_LE_GET_GINT8()

    #define GSF_LE_GET_GINT8(p) ((gint8)GSF_LE_GET_GUINT8(p))

`p` : |

### GSF_LE_GET_GUINT64()

    #define GSF_LE_GET_GUINT64(p) (gsf_le_get_guint64 (p))

`p` : |

### GSF_LE_GET_GINT16()

    #define GSF_LE_GET_GINT16(p) ((gint16)GSF_LE_GET_GUINT16(p))

`p` : |

### GSF_LE_GET_GUINT8()

    #define GSF_LE_GET_GUINT8(p) (*(guint8 const *)(p))

`p` : |

### GSF_LE_GET_GINT32()

    #define GSF_LE_GET_GINT32(p) ((gint32)GSF_LE_GET_GUINT32(p))

`p` : |

### GSF_LE_GET_GUINT16()

    #define     GSF_LE_GET_GUINT16(p)

`p` : |

### GSF_LE_GET_GUINT32()

    #define     GSF_LE_GET_GUINT32(p)

`p` : |

### GSF_LE_GET_FLOAT()

    #define GSF_LE_GET_FLOAT(p) (gsf_le_get_float (p))

`p` : |

### GSF_LE_GET_DOUBLE()

    #define GSF_LE_GET_DOUBLE(p) (gsf_le_get_double (p))

`p` : |

### gsf_le_get_guint64 ()

    guint64     gsf_le_get_guint64              (void const *p);

`p` : |
Returns : |

### gsf_le_get_float ()

    float       gsf_le_get_float                (void const *p);

`p` : |
Returns : |

### gsf_le_get_double ()

    double      gsf_le_get_double               (void const *p);

`p` : |
Returns : |

### GSF_LE_SET_GUINT8()

    #define     GSF_LE_SET_GUINT8(p, dat)

`p` : |
`dat` : |

### GSF_LE_SET_GUINT16()

    #define     GSF_LE_SET_GUINT16(p, dat)

`p` : |
`dat` : |

### GSF_LE_SET_GUINT32()

    #define     GSF_LE_SET_GUINT32(p, dat)

`p` : |
`dat` : |

### GSF_LE_SET_GINT8()

    #define GSF_LE_SET_GINT8(p,dat) GSF_LE_SET_GUINT8((p),(dat))

`p` : |
`dat` : |

### GSF_LE_SET_GINT16()

    #define GSF_LE_SET_GINT16(p,dat) GSF_LE_SET_GUINT16((p),(dat))

`p` : |
`dat` : |

### GSF_LE_SET_GINT32()

    #define GSF_LE_SET_GINT32(p,dat) GSF_LE_SET_GUINT32((p),(dat))

`p` : |
`dat` : |

### GSF_LE_SET_FLOAT()

    #define GSF_LE_SET_FLOAT(p,dat) gsf_le_set_float((p),(dat))

`p` : |
`dat` : |

### GSF_LE_SET_DOUBLE()

    #define GSF_LE_SET_DOUBLE(p,dat) gsf_le_set_double((p),(dat))

`p` : |
`dat` : |

### gsf_le_set_float ()

    void        gsf_le_set_float                (void *p,
                                                 float f);

`p` : |
`f` : |

### gsf_le_set_double ()

    void        gsf_le_set_double               (void *p,
                                                 double d);

`p` : |
`d` : |

### gsf_timestamp_copy ()

    GsfTimestamp* gsf_timestamp_copy            (GsfTimestamp const *stamp);

`stamp` : |
Returns : |

### gsf_timestamp_free ()

    void        gsf_timestamp_free              (GsfTimestamp *stamp);

`stamp` : |

### gsf_timestamp_new_now ()

    GsfTimestamp* gsf_timestamp_new_now         (void);

Returns : |

### gsf_timestamp_get_type ()

    GType       gsf_timestamp_get_type          (void);

Returns : |

### gsf_timestamp_as_string ()

    char*       gsf_timestamp_as_string         (GsfTimestamp const *stamp);

`stamp` : |
Returns : |

### gsf_timestamp_parse ()

    int         gsf_timestamp_parse             (char const *spec,
                                                 GsfTimestamp *stamp);

`spec` : |
`stamp` : |
Returns : |

### gsf_timestamp_hash ()

    guint       gsf_timestamp_hash              (GsfTimestamp const *stamp);

`stamp` : |
Returns : |

### gsf_timestamp_equal ()

    gboolean    gsf_timestamp_equal             (GsfTimestamp const *a,
                                                 GsfTimestamp const *b);

`a` : |
`b` : |
Returns : |

### GSF_TIMESTAMP_TYPE

    #define GSF_TIMESTAMP_TYPE        (gsf_timestamp_get_type ())

### GsfTimestamp

    typedef struct {
    	GDate	  date;			/* In local timezone */
    	glong     seconds;		/* time of day */
    	GString	  time_zone;		/* possibly blank */

    	guint32	  timet;
    } GsfTimestamp;

### gsf_timestamp_new ()

    GsfTimestamp* gsf_timestamp_new             (GDate const *date,
                                                 glong seconds,
                                                 char const *tz);

`date` : |
`seconds` : |
`tz` : |
Returns : |