mirror of
https://github.com/javalsai/lidm.git
synced 2025-07-03 06:15:03 +02:00
fix: simplified code
This commit is contained in:
parent
4a83e5d825
commit
a08ffa5a75
@ -7,21 +7,13 @@
|
|||||||
|
|
||||||
#include "launch_state.h"
|
#include "launch_state.h"
|
||||||
|
|
||||||
static void serialize_lstate(FILE* f, struct LaunchState st) {
|
|
||||||
fprintf(f, "%i;%i", st.user_opt, st.session_opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void deserialize_lstate(FILE* f, struct LaunchState* st) {
|
|
||||||
fscanf(f, "%i;%i", &st->user_opt, &st->session_opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct LaunchState read_launch_state() {
|
struct LaunchState read_launch_state() {
|
||||||
struct LaunchState state;
|
struct LaunchState state;
|
||||||
state.user_opt = 1;
|
state.user_opt = 1;
|
||||||
state.session_opt = 1;
|
state.session_opt = 1;
|
||||||
FILE* f = fopen(STATE_PATH, "r");
|
FILE* f = fopen(STATE_PATH, "r");
|
||||||
if(!f) return state;
|
if(!f) return state;
|
||||||
deserialize_lstate(f, &state);
|
fscanf(f, "%i;%i", &state.user_opt, &state.session_opt);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -29,7 +21,7 @@ struct LaunchState read_launch_state() {
|
|||||||
bool write_launch_state(struct LaunchState state) {
|
bool write_launch_state(struct LaunchState state) {
|
||||||
FILE* f = fopen(STATE_PATH, "w");
|
FILE* f = fopen(STATE_PATH, "w");
|
||||||
if(!f) return false;
|
if(!f) return false;
|
||||||
serialize_lstate(f, state);
|
fprintf(f, "%i;%i", state.user_opt, state.session_opt);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user