summaryrefslogtreecommitdiff
path: root/accent.h
diff options
context:
space:
mode:
authorauric <104602845+ihateamongus@users.noreply.github.com>2025-09-08 21:19:14 -0500
committerauric <104602845+ihateamongus@users.noreply.github.com>2025-09-08 21:19:14 -0500
commite61da07522a060da98fa3a56db3d0360469b26cf (patch)
treec72d276bffa4dafe22ae0e4f694acfadb40b8ca1 /accent.h
parentd11aec86841f77edd6eba3e07aa1e7e591e9da2a (diff)
organize repository layout
Diffstat (limited to 'accent.h')
-rw-r--r--accent.h52
1 files changed, 0 insertions, 52 deletions
diff --git a/accent.h b/accent.h
deleted file mode 100644
index 8c9c6d4..0000000
--- a/accent.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef ACCENT_H
-#define ACCENT_H
-#include <stdint.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#define SHMNAME "/breathing_color_shm"
-#define SHM_MAGIC 0xBEEFCAFEu
-#define SHM_VERSION 1u
-
-typedef struct {
- uint32_t magic;
- uint32_t version;
- volatile uint32_t seq;
- char color[8];
-} ColorShm;
-
-static inline ColorShm *
-mapaccent(void)
-{
- int fd;
- ColorShm *blk;
- if ((fd = shm_open(SHMNAME, O_RDONLY, 0)) < 0)
- return NULL;
- blk = mmap(NULL, sizeof(ColorShm), PROT_READ, MAP_SHARED, fd, 0);
- close(fd);
- if (blk == MAP_FAILED)
- return NULL;
- if (blk->magic != SHM_MAGIC || blk->version != SHM_VERSION) {
- munmap(blk, sizeof(ColorShm));
- return NULL;
- }
- return blk;
-}
-
-static inline int
-readaccent(ColorShm **blk, char out[8])
-{
- uint32_t s1, s2;
- if (!*blk && !(*blk = mapaccent()))
- return 0;
- do {
- s1 = (*blk)->seq;
- memcpy(out, (*blk)->color, 8);
- s2 = (*blk)->seq;
- } while (s1 != s2);
- return out[0] == '#';
-}
-
-#endif /* ACCENT_H */