mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Battery: rename BatteryResult to FFBatteryResult
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
#define FF_BATTERY_TEMP_UNSET (0/0.0)
|
||||
|
||||
typedef struct BatteryResult
|
||||
typedef struct FFBatteryResult
|
||||
{
|
||||
FFstrbuf manufacturer;
|
||||
FFstrbuf modelName;
|
||||
@@ -15,7 +15,7 @@ typedef struct BatteryResult
|
||||
double capacity;
|
||||
FFstrbuf status;
|
||||
double temperature;
|
||||
} BatteryResult;
|
||||
} FFBatteryResult;
|
||||
|
||||
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results)
|
||||
if (!yyjson_is_obj(root))
|
||||
return "Battery info result is not a JSON object";
|
||||
|
||||
BatteryResult* battery = ffListAdd(results);
|
||||
FFBatteryResult* battery = ffListAdd(results);
|
||||
battery->temperature = FF_BATTERY_TEMP_UNSET;
|
||||
ffStrbufInit(&battery->manufacturer);
|
||||
ffStrbufInit(&battery->modelName);
|
||||
@@ -68,7 +68,7 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results)
|
||||
return NULL;
|
||||
ffStrbufClear(&temp);
|
||||
|
||||
BatteryResult* battery = ffListAdd(results);
|
||||
FFBatteryResult* battery = ffListAdd(results);
|
||||
battery->temperature = FF_BATTERY_TEMP_UNSET;
|
||||
ffStrbufInit(&battery->manufacturer);
|
||||
ffStrbufInit(&battery->modelName);
|
||||
@@ -78,7 +78,7 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results)
|
||||
if (ffParsePropLines(start, "AC powered: ", &temp) && ffStrbufEqualS(&temp, "true"))
|
||||
ffStrbufAppendS(&battery->status, "AC powered");
|
||||
ffStrbufClear(&temp);
|
||||
|
||||
|
||||
if (ffParsePropLines(start, "USB powered: ", &temp) && ffStrbufEqualS(&temp, "true"))
|
||||
{
|
||||
if (battery->status.length) ffStrbufAppendS(&battery->status, ", ");
|
||||
|
||||
@@ -38,7 +38,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
|
||||
bool boolValue;
|
||||
const char* error;
|
||||
|
||||
BatteryResult* battery = ffListAdd(results);
|
||||
FFBatteryResult* battery = ffListAdd(results);
|
||||
battery->capacity = 0.0/0.0;
|
||||
int currentCapacity, maxCapacity;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r
|
||||
if(ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) < 0 || (battio.battinfo.state == ACPI_BATT_STAT_NOT_PRESENT))
|
||||
continue;
|
||||
|
||||
BatteryResult* battery = ffListAdd(results);
|
||||
FFBatteryResult* battery = ffListAdd(results);
|
||||
battery->temperature = FF_BATTERY_TEMP_UNSET;
|
||||
ffStrbufInit(&battery->manufacturer);
|
||||
ffStrbufInit(&battery->modelName);
|
||||
|
||||
@@ -27,7 +27,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
|
||||
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Device") == 0)
|
||||
return;
|
||||
|
||||
BatteryResult* result = ffListAdd(results);
|
||||
FFBatteryResult* result = ffListAdd(results);
|
||||
|
||||
//capacity must exist and be not empty
|
||||
ffStrbufAppendS(dir, "/capacity");
|
||||
|
||||
@@ -74,7 +74,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
|
||||
if(!(bi.Capabilities & BATTERY_SYSTEM_BATTERY))
|
||||
continue;
|
||||
|
||||
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
|
||||
FFBatteryResult* battery = (FFBatteryResult*)ffListAdd(results);
|
||||
|
||||
if(memcmp(bi.Chemistry, "PbAc", 4) == 0)
|
||||
ffStrbufInitS(&battery->technology, "Lead Acid");
|
||||
@@ -143,7 +143,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
|
||||
SYSTEM_BATTERY_STATE info;
|
||||
if (NT_SUCCESS(NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent)
|
||||
{
|
||||
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
|
||||
FFBatteryResult* battery = (FFBatteryResult*)ffListAdd(results);
|
||||
ffStrbufInit(&battery->modelName);
|
||||
ffStrbufInit(&battery->manufacturer);
|
||||
ffStrbufInit(&battery->technology);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#define FF_BATTERY_NUM_FORMAT_ARGS 5
|
||||
|
||||
static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8_t index)
|
||||
static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8
|
||||
|
||||
void ffPrintBattery(FFBatteryOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(BatteryResult));
|
||||
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFBatteryResult));
|
||||
|
||||
const char* error = ffDetectBattery(options, &results);
|
||||
|
||||
@@ -88,7 +88,7 @@ void ffPrintBattery(FFBatteryOptions* options)
|
||||
{
|
||||
for(uint8_t i = 0; i < (uint8_t) results.length; i++)
|
||||
{
|
||||
BatteryResult* result = ffListGet(&results, i);
|
||||
FFBatteryResult* result = ffListGet(&results, i);
|
||||
printBattery(options, result, i);
|
||||
|
||||
ffStrbufDestroy(&result->manufacturer);
|
||||
@@ -178,7 +178,7 @@ void ffParseBatteryJsonObject(FFBatteryOptions* options, yyjson_val* module)
|
||||
|
||||
void ffGenerateBatteryJson(FFBatteryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(BatteryResult));
|
||||
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFBatteryResult));
|
||||
|
||||
const char* error = ffDetectBattery(options, &results);
|
||||
if (error)
|
||||
@@ -190,7 +190,7 @@ void ffGenerateBatteryJson(FFBatteryOptions* options, yyjson_mut_doc* doc, yyjso
|
||||
yyjson_mut_val* arr = yyjson_mut_arr(doc);
|
||||
yyjson_mut_obj_add_val(doc, module, "result", arr);
|
||||
|
||||
FF_LIST_FOR_EACH(BatteryResult, battery, results)
|
||||
FF_LIST_FOR_EACH(FFBatteryResult, battery, results)
|
||||
{
|
||||
yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr);
|
||||
yyjson_mut_obj_add_real(doc, obj, "capacity", battery->capacity);
|
||||
@@ -201,7 +201,7 @@ void ffGenerateBatteryJson(FFBatteryOptions* options, yyjson_mut_doc* doc, yyjso
|
||||
yyjson_mut_obj_add_real(doc, obj, "temperature", battery->temperature);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(BatteryResult, battery, results)
|
||||
FF_LIST_FOR_EACH(FFBatteryResult, battery, results)
|
||||
{
|
||||
ffStrbufDestroy(&battery->manufacturer);
|
||||
ffStrbufDestroy(&battery->modelName);
|
||||
|
||||
Reference in New Issue
Block a user