2022-07-06 17:51:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* arguments.c
|
|
|
|
|
*
|
|
|
|
|
* Created on: 6 июл. 2022 г.
|
|
|
|
|
* Author: alexander
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "arguments.h"
|
2022-07-07 16:35:48 +00:00
|
|
|
|
#include "node_settings.h"
|
2022-07-08 16:45:45 +00:00
|
|
|
|
#include "concat.h"
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-18 11:13:49 +00:00
|
|
|
|
#include "rxrandr.h"
|
2022-07-13 17:49:49 +00:00
|
|
|
|
#include "db.h"
|
2022-07-18 11:13:49 +00:00
|
|
|
|
#include "monitor.h"
|
2022-07-11 17:06:05 +00:00
|
|
|
|
|
2022-07-18 12:01:15 +00:00
|
|
|
|
void settingsLoad(char *pathDB)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-18 12:01:15 +00:00
|
|
|
|
getPathDB(pathDB);
|
|
|
|
|
|
2022-07-18 11:13:49 +00:00
|
|
|
|
dbLoadData();
|
2022-07-11 17:06:05 +00:00
|
|
|
|
|
2022-07-18 15:38:38 +00:00
|
|
|
|
Monitors *monitors = loadMonitors();
|
2022-07-18 11:13:49 +00:00
|
|
|
|
for (size_t i = 0; i < monitors->size; ++i)
|
2022-07-11 17:06:05 +00:00
|
|
|
|
{
|
2022-07-18 11:13:49 +00:00
|
|
|
|
addParameterValue(PARAMETER_MONITORS, i, monitors->monitor[i]->data[3], !i);
|
2022-07-11 17:06:05 +00:00
|
|
|
|
}
|
2022-07-18 11:13:49 +00:00
|
|
|
|
|
|
|
|
|
dbFreeMonitors(monitors);
|
2022-07-08 16:45:45 +00:00
|
|
|
|
}
|
2022-07-07 16:35:48 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
void settingsFree()
|
|
|
|
|
{
|
|
|
|
|
freeSettings();
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
void buildArguments(Arguments *args)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
args->argc = 0;
|
|
|
|
|
args->argv = (char **)malloc(sizeof(char *) * settings.countParameterSet);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
for (NodeParameter *head = settings.parameter; head; head = head->next)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (head->set)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (head->value)
|
|
|
|
|
args->argv[(args->argc)++] = concat(head->key, getSetNodeValue(head)->current);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
else
|
2022-07-08 16:45:45 +00:00
|
|
|
|
args->argv[(args->argc)++] = concat(head->key, NULL);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-07 16:35:48 +00:00
|
|
|
|
void freeArguments(Arguments *args)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
for (int i = 0; i < args->argc; ++i)
|
|
|
|
|
{
|
|
|
|
|
free(args->argv[i]);
|
|
|
|
|
}
|
2022-07-07 16:35:48 +00:00
|
|
|
|
free(args->argv);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|