## preludedb-plugin-sql preludedb-plugin-sql |

## Synopsis

    typedef             preludedb_plugin_sql_t;
    const char *        (*preludedb_plugin_sql_get_column_name_func_t)
                                                            (void *session,
                                                             void *resource,
                                                             unsigned int column_num);
    const char *        (*preludedb_plugin_sql_get_operator_string_func_t)
                                                            (idmef_criterion_operator_t operator);
    int                 (*preludedb_plugin_sql_build_constraint_string_func_t)
                                                            (prelude_string_t *out,
                                                             const char *field,
                                                             idmef_criterion_operator_t operator,
                                                             const char *value);
    int                 (*preludedb_plugin_sql_unescape_binary_func_t)
                                                            (void *session,
                                                             const char *input,
                                                             unsigned char **output,
                                                             size_t *output_size);
    int                 (*preludedb_plugin_sql_escape_binary_func_t)
                                                            (void *session,
                                                             unsigned char *input,
                                                             size_t input_size,
                                                             char **output);
    int                 (*preludedb_plugin_sql_query_func_t)
                                                            (void *session,
                                                             const char *query,
                                                             void **res);
    int                 (*preludedb_plugin_sql_get_column_num_func_t)
                                                            (void *session,
                                                             void *resource,
                                                             const char *column_name);
    void                (*preludedb_plugin_sql_resource_destroy_func_t)
                                                            (void *session,
                                                             void *resource);
    int                 (*preludedb_plugin_sql_build_timestamp_string_func_t)
                                                            (const struct tm *t,
                                                             char *out,
                                                             size_t size);
    int                 (*preludedb_plugin_sql_build_limit_offset_string_func_t)
                                                            (void *session,
                                                             int limit,
                                                             int offset,
                                                             prelude_string_t *output);
    void                preludedb_plugin_sql_set_build_timestamp_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_timestamp_string_func_t func);
    int                 (*preludedb_plugin_sql_build_time_interval_string_func_t)
                                                            (preludedb_sql_time_constraint_type_t type,
                                                             int value,
                                                             char *buf,
                                                             size_t size);
    int                 (*preludedb_plugin_sql_open_func_t) (preludedb_sql_settings_t *settings,
                                                             void **session);
    int                 (*preludedb_plugin_sql_fetch_field_func_t)
                                                            (void *session,
                                                             void *resource,
                                                             void *row,
                                                             unsigned int column_num,
                                                             const char **value,
                                                             size_t *len);
    void                preludedb_plugin_sql_set_get_operator_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_operator_string_func_t func);
    void                (*preludedb_plugin_sql_close_func_t)
                                                            (void *session);
    int                 (*preludedb_plugin_sql_build_time_constraint_string_func_t)
                                                            (prelude_string_t *output,
                                                             const char *field,
                                                             preludedb_sql_time_constraint_type_t type,
                                                             idmef_criterion_operator_t operator,
                                                             int value,
                                                             int gmt_offset);
    int                 (*preludedb_plugin_sql_escape_func_t)
                                                            (void *session,
                                                             const char *input,
                                                             size_t input_size,
                                                             char **output);
    int                 (*preludedb_plugin_sql_fetch_row_func_t)
                                                            (void *session,
                                                             void *resource,
                                                             void **row);
    int                 preludedb_plugin_sql_new            (preludedb_plugin_sql_t **plugin);
    void                preludedb_plugin_sql_set_open_func  (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_open_func_t func);
    void                preludedb_plugin_sql_set_close_func (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_close_func_t func);
    void                preludedb_plugin_sql_set_escape_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_escape_func_t func);
    void                preludedb_plugin_sql_set_escape_binary_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_escape_binary_func_t func);
    void                preludedb_plugin_sql_set_unescape_binary_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_unescape_binary_func_t func);
    void                preludedb_plugin_sql_set_query_func (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_query_func_t func);
    void                preludedb_plugin_sql_set_get_column_count_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_column_count_func_t func);
    void                preludedb_plugin_sql_set_get_row_count_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_row_count_func_t func);
    void                preludedb_plugin_sql_set_get_column_name_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_column_name_func_t func);
    void                preludedb_plugin_sql_set_get_column_num_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_column_num_func_t func);
    void                preludedb_plugin_sql_set_resource_destroy_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_resource_destroy_func_t func);
    void                preludedb_plugin_sql_set_fetch_row_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_fetch_row_func_t func);
    void                preludedb_plugin_sql_set_fetch_field_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_fetch_field_func_t func);
    void                preludedb_plugin_sql_set_build_time_constraint_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_time_constraint_string_func_t func);
    void                preludedb_plugin_sql_set_build_time_interval_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_time_interval_string_func_t func);
    void                preludedb_plugin_sql_set_build_limit_offset_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_limit_offset_string_func_t func);
    void                preludedb_plugin_sql_set_build_constraint_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_constraint_string_func_t func);

## Description

## Details

### preludedb_plugin_sql_t

    typedef struct preludedb_plugin_sql preludedb_plugin_sql_t;

### preludedb_plugin_sql_get_column_name_func_t ()

    const char *        (*preludedb_plugin_sql_get_column_name_func_t)
                                                            (void *session,
                                                             void *resource,
                                                             unsigned int column_num);

`session` : |
`resource` : |
`column_num` : |
Returns : |

### preludedb_plugin_sql_get_operator_string_func_t ()

    const char *        (*preludedb_plugin_sql_get_operator_string_func_t)
                                                            (idmef_criterion_operator_t operator);

`operator` : |
Returns : |

### preludedb_plugin_sql_build_constraint_string_func_t ()

    int                 (*preludedb_plugin_sql_build_constraint_string_func_t)
                                                            (prelude_string_t *out,
                                                             const char *field,
                                                             idmef_criterion_operator_t operator,
                                                             const char *value);

`out` : |
`field` : |
`operator` : |
`value` : |
Returns : |

### preludedb_plugin_sql_unescape_binary_func_t ()

    int                 (*preludedb_plugin_sql_unescape_binary_func_t)
                                                            (void *session,
                                                             const char *input,
                                                             unsigned char **output,
                                                             size_t *output_size);

`session` : |
`input` : |
`output` : |
`output_size` : |
Returns : |

### preludedb_plugin_sql_escape_binary_func_t ()

    int                 (*preludedb_plugin_sql_escape_binary_func_t)
                                                            (void *session,
                                                             unsigned char *input,
                                                             size_t input_size,
                                                             char **output);

`session` : |
`input` : |
`input_size` : |
`output` : |
Returns : |

### preludedb_plugin_sql_query_func_t ()

    int                 (*preludedb_plugin_sql_query_func_t)
                                                            (void *session,
                                                             const char *query,
                                                             void **res);

`session` : |
`query` : |
`res` : |
Returns : |

### preludedb_plugin_sql_get_column_num_func_t ()

    int                 (*preludedb_plugin_sql_get_column_num_func_t)
                                                            (void *session,
                                                             void *resource,
                                                             const char *column_name);

`session` : |
`resource` : |
`column_name` : |
Returns : |

### preludedb_plugin_sql_resource_destroy_func_t ()

    void                (*preludedb_plugin_sql_resource_destroy_func_t)
                                                            (void *session,
                                                             void *resource);

`session` : |
`resource` : |

### preludedb_plugin_sql_build_timestamp_string_func_t ()

    int                 (*preludedb_plugin_sql_build_timestamp_string_func_t)
                                                            (const struct tm *t,
                                                             char *out,
                                                             size_t size);

`t` : |
`out` : |
`size` : |
Returns : |

### preludedb_plugin_sql_build_limit_offset_string_func_t ()

    int                 (*preludedb_plugin_sql_build_limit_offset_string_func_t)
                                                            (void *session,
                                                             int limit,
                                                             int offset,
                                                             prelude_string_t *output);

`session` : |
`limit` : |
`offset` : |
`output` : |
Returns : |

### preludedb_plugin_sql_set_build_timestamp_string_func ()

    void                preludedb_plugin_sql_set_build_timestamp_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_timestamp_string_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_build_time_interval_string_func_t ()

    int                 (*preludedb_plugin_sql_build_time_interval_string_func_t)
                                                            (preludedb_sql_time_constraint_type_t type,
                                                             int value,
                                                             char *buf,
                                                             size_t size);

`type` : |
`value` : |
`buf` : |
`size` : |
Returns : |

### preludedb_plugin_sql_open_func_t ()

    int                 (*preludedb_plugin_sql_open_func_t) (preludedb_sql_settings_t *settings,
                                                             void **session);

`settings` : |
`session` : |
Returns : |

### preludedb_plugin_sql_fetch_field_func_t ()

    int                 (*preludedb_plugin_sql_fetch_field_func_t)
                                                            (void *session,
                                                             void *resource,
                                                             void *row,
                                                             unsigned int column_num,
                                                             const char **value,
                                                             size_t *len);

`session` : |
`resource` : |
`row` : |
`column_num` : |
`value` : |
`len` : |
Returns : |

### preludedb_plugin_sql_set_get_operator_string_func ()

    void                preludedb_plugin_sql_set_get_operator_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_operator_string_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_close_func_t ()

    void                (*preludedb_plugin_sql_close_func_t)
                                                            (void *session);

`session` : |

### preludedb_plugin_sql_build_time_constraint_string_func_t ()

    int                 (*preludedb_plugin_sql_build_time_constraint_string_func_t)
                                                            (prelude_string_t *output,
                                                             const char *field,
                                                             preludedb_sql_time_constraint_type_t type,
                                                             idmef_criterion_operator_t operator,
                                                             int value,
                                                             int gmt_offset);

`output` : |
`field` : |
`type` : |
`operator` : |
`value` : |
`gmt_offset` : |
Returns : |

### preludedb_plugin_sql_escape_func_t ()

    int                 (*preludedb_plugin_sql_escape_func_t)
                                                            (void *session,
                                                             const char *input,
                                                             size_t input_size,
                                                             char **output);

`session` : |
`input` : |
`input_size` : |
`output` : |
Returns : |

### preludedb_plugin_sql_fetch_row_func_t ()

    int                 (*preludedb_plugin_sql_fetch_row_func_t)
                                                            (void *session,
                                                             void *resource,
                                                             void **row);

`session` : |
`resource` : |
`row` : |
Returns : |

### preludedb_plugin_sql_new ()

    int                 preludedb_plugin_sql_new            (preludedb_plugin_sql_t **plugin);

`plugin` : |
Returns : |

### preludedb_plugin_sql_set_open_func ()

    void                preludedb_plugin_sql_set_open_func  (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_open_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_close_func ()

    void                preludedb_plugin_sql_set_close_func (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_close_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_escape_func ()

    void                preludedb_plugin_sql_set_escape_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_escape_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_escape_binary_func ()

    void                preludedb_plugin_sql_set_escape_binary_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_escape_binary_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_unescape_binary_func ()

    void                preludedb_plugin_sql_set_unescape_binary_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_unescape_binary_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_query_func ()

    void                preludedb_plugin_sql_set_query_func (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_query_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_get_column_count_func ()

    void                preludedb_plugin_sql_set_get_column_count_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_column_count_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_get_row_count_func ()

    void                preludedb_plugin_sql_set_get_row_count_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_row_count_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_get_column_name_func ()

    void                preludedb_plugin_sql_set_get_column_name_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_column_name_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_get_column_num_func ()

    void                preludedb_plugin_sql_set_get_column_num_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_get_column_num_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_resource_destroy_func ()

    void                preludedb_plugin_sql_set_resource_destroy_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_resource_destroy_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_fetch_row_func ()

    void                preludedb_plugin_sql_set_fetch_row_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_fetch_row_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_fetch_field_func ()

    void                preludedb_plugin_sql_set_fetch_field_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_fetch_field_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_build_time_constraint_string_func ()

    void                preludedb_plugin_sql_set_build_time_constraint_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_time_constraint_string_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_build_time_interval_string_func ()

    void                preludedb_plugin_sql_set_build_time_interval_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_time_interval_string_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_build_limit_offset_string_func ()

    void                preludedb_plugin_sql_set_build_limit_offset_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_limit_offset_string_func_t func);

`plugin` : |
`func` : |

### preludedb_plugin_sql_set_build_constraint_string_func ()

    void                preludedb_plugin_sql_set_build_constraint_string_func
                                                            (preludedb_plugin_sql_t *plugin,
                                                             preludedb_plugin_sql_build_constraint_string_func_t func);

`plugin` : |
`func` : |