5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi#ifndef VAR_EXPAND_PRIVATE_H
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi#define VAR_EXPAND_PRIVATE_H 1
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomistruct var_expand_context {
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi /* current variables */
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi const struct var_expand_table *table;
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi /* caller provided function table */
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi const struct var_expand_func_table *func_table;
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi /* caller provided context */
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi void *context;
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi /* last offset, negative counts from end*/
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi int offset;
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi /* last width, negative counts from end */
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi int width;
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi /* last zero padding */
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi bool zero_padding:1;
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi};
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi/* this can be used to register a *global* function that is
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi prepended to function table. These can be used to register some
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi special handling for keys.
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi you can call var_expand_with_funcs if you need to
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi expand something inside here.
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi return -1 on error, 0 on unknown variable, 1 on success
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi*/
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomitypedef int
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomivar_expand_extension_func_t(struct var_expand_context *ctx,
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi const char *key, const char *field,
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi const char **result_r, const char **error_r);
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomistruct var_expand_extension_func_table {
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi const char *key;
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi var_expand_extension_func_t *func;
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi};
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomiint var_expand_long(struct var_expand_context *ctx,
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi const void *key_start, size_t key_len,
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi const char **var_r, const char **error_r);
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomivoid var_expand_extensions_init(void);
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomivoid var_expand_extensions_deinit(void);
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi/* Functions registered here are placed before in-built functions,
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi so you can include your own implementation of something.
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi Be careful. Use NULL terminated list.
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi*/
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomivoid var_expand_register_func_array(const struct var_expand_extension_func_table *funcs);
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomivoid var_expand_unregister_func_array(const struct var_expand_extension_func_table *funcs);
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi
b3e71425659780a58cba2f1d84eceef5b4616762Aki Tuomiint var_expand_if(struct var_expand_context *ctx,
b3e71425659780a58cba2f1d84eceef5b4616762Aki Tuomi const char *key, const char *field,
b3e71425659780a58cba2f1d84eceef5b4616762Aki Tuomi const char **result_r, const char **error_r);
b3e71425659780a58cba2f1d84eceef5b4616762Aki Tuomi
5c00a22fcca7f68479a8768fec7ace7f679b344dAki Tuomi#endif