aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/seat.h1
-rw-r--r--include/server.h4
-rw-r--r--seatd/server.c15
3 files changed, 10 insertions, 10 deletions
diff --git a/include/seat.h b/include/seat.h
index 60d3b29..30f7cc4 100644
--- a/include/seat.h
+++ b/include/seat.h
@@ -26,6 +26,7 @@ struct seat_device {
};
struct seat {
+ struct linked_list link; // server::seats
char *seat_name;
struct linked_list clients;
struct client *active_client;
diff --git a/include/server.h b/include/server.h
index a225668..587047e 100644
--- a/include/server.h
+++ b/include/server.h
@@ -3,7 +3,7 @@
#include <stdbool.h>
-#include "list.h"
+#include "linked_list.h"
#include "poller.h"
struct client;
@@ -12,7 +12,7 @@ struct server {
bool running;
struct poller poller;
- struct list seats;
+ struct linked_list seats;
};
int server_init(struct server *server);
diff --git a/seatd/server.c b/seatd/server.c
index 7368ea3..4562a71 100644
--- a/seatd/server.c
+++ b/seatd/server.c
@@ -12,7 +12,6 @@
#include <unistd.h>
#include "client.h"
-#include "list.h"
#include "log.h"
#include "poller.h"
#include "seat.h"
@@ -26,7 +25,7 @@ static int server_handle_kill(int signal, void *data);
int server_init(struct server *server) {
poller_init(&server->poller);
- list_init(&server->seats);
+ linked_list_init(&server->seats);
if (poller_add_signal(&server->poller, SIGUSR1, server_handle_vt_rel, server) == NULL ||
poller_add_signal(&server->poller, SIGUSR2, server_handle_vt_acq, server) == NULL ||
@@ -45,24 +44,24 @@ int server_init(struct server *server) {
return -1;
}
- list_add(&server->seats, seat);
+ linked_list_insert(&server->seats, &seat->link);
server->running = true;
return 0;
}
void server_finish(struct server *server) {
assert(server);
- for (size_t idx = 0; idx < server->seats.length; idx++) {
- struct seat *seat = server->seats.items[idx];
+ while (!linked_list_empty(&server->seats)) {
+ struct seat *seat = (struct seat *)server->seats.next;
seat_destroy(seat);
}
- list_free(&server->seats);
poller_finish(&server->poller);
}
struct seat *server_get_seat(struct server *server, const char *seat_name) {
- for (size_t idx = 0; idx < server->seats.length; idx++) {
- struct seat *seat = server->seats.items[idx];
+ for (struct linked_list *elem = server->seats.next; elem != &server->seats;
+ elem = elem->next) {
+ struct seat *seat = (struct seat *)elem;
if (strcmp(seat->seat_name, seat_name) == 0) {
return seat;
}