mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 23:07:18 +00:00
[common] option: implement ability to dump config into ini
This is intended to be used for saving filter options into an ini file.
This commit is contained in:
parent
e22a070dd3
commit
f0624ccf89
@ -22,6 +22,7 @@
|
|||||||
#define _H_COMMON_OPTION_
|
#define _H_COMMON_OPTION_
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include "common/stringlist.h"
|
#include "common/stringlist.h"
|
||||||
|
|
||||||
enum OptionType
|
enum OptionType
|
||||||
@ -94,6 +95,9 @@ bool option_validate(void);
|
|||||||
// print out the options, help, and their current values
|
// print out the options, help, and their current values
|
||||||
void option_print(void);
|
void option_print(void);
|
||||||
|
|
||||||
|
// dump the options in ini format into the file
|
||||||
|
bool option_dump(FILE * file, const char * module);
|
||||||
|
|
||||||
// final cleanup
|
// final cleanup
|
||||||
void option_free(void);
|
void option_free(void);
|
||||||
|
|
||||||
|
@ -747,6 +747,25 @@ void option_print(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dump the options in ini format into the file
|
||||||
|
bool option_dump(FILE * file, const char * module)
|
||||||
|
{
|
||||||
|
fprintf(file, "[%s]\n", module);
|
||||||
|
|
||||||
|
for (int i = 0; i < state.oCount; ++i)
|
||||||
|
{
|
||||||
|
struct Option * o = state.options[i];
|
||||||
|
if (strcasecmp(o->module, module) != 0)
|
||||||
|
continue;
|
||||||
|
char * value = o->toString(o);
|
||||||
|
fprintf(file, "%s=%s\n", o->name, value);
|
||||||
|
free(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
fputc('\n', file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
struct Option * option_get(const char * module, const char * name)
|
struct Option * option_get(const char * module, const char * name)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < state.oCount; ++i)
|
for(int i = 0; i < state.oCount; ++i)
|
||||||
|
Loading…
Reference in New Issue
Block a user