aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2024-10-05 23:23:17 +0200
committerMattias Andrée <m@maandree.se>2024-10-05 23:23:17 +0200
commit98a8ac8498974e499fc129878ab05b9a7bf8ba30 (patch)
tree2914967687516632a93da9af59818f22d3120861 /src/libmdsserver
parentUpdate e-mail (diff)
downloadmds-98a8ac8498974e499fc129878ab05b9a7bf8ba30.tar.gz
mds-98a8ac8498974e499fc129878ab05b9a7bf8ba30.tar.bz2
mds-98a8ac8498974e499fc129878ab05b9a7bf8ba30.tar.xz
misc + update e-mailHEADmaster
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/libmdsserver')
-rw-r--r--src/libmdsserver/client-list.c2
-rw-r--r--src/libmdsserver/client-list.h2
-rw-r--r--src/libmdsserver/config.h.in2
-rw-r--r--src/libmdsserver/fd-table.c2
-rw-r--r--src/libmdsserver/fd-table.h2
-rw-r--r--src/libmdsserver/hash-help.h2
-rw-r--r--src/libmdsserver/hash-list.h2
-rw-r--r--src/libmdsserver/hash-table.c2
-rw-r--r--src/libmdsserver/hash-table.h2
-rw-r--r--src/libmdsserver/linked-list.c2
-rw-r--r--src/libmdsserver/linked-list.h2
-rw-r--r--src/libmdsserver/macro-bits.h2
-rw-r--r--src/libmdsserver/macros.h118
-rw-r--r--src/libmdsserver/mds-message.c6
-rw-r--r--src/libmdsserver/mds-message.h2
-rw-r--r--src/libmdsserver/table-common.h2
-rw-r--r--src/libmdsserver/util.c145
-rw-r--r--src/libmdsserver/util.h34
18 files changed, 38 insertions, 293 deletions
diff --git a/src/libmdsserver/client-list.c b/src/libmdsserver/client-list.c
index 02d555e..57609ef 100644
--- a/src/libmdsserver/client-list.c
+++ b/src/libmdsserver/client-list.c
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/client-list.h b/src/libmdsserver/client-list.h
index ffe828a..b4ae0b2 100644
--- a/src/libmdsserver/client-list.h
+++ b/src/libmdsserver/client-list.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/config.h.in b/src/libmdsserver/config.h.in
index abacfa1..11b0444 100644
--- a/src/libmdsserver/config.h.in
+++ b/src/libmdsserver/config.h.in
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/fd-table.c b/src/libmdsserver/fd-table.c
index fafaa65..1344a0e 100644
--- a/src/libmdsserver/fd-table.c
+++ b/src/libmdsserver/fd-table.c
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/fd-table.h b/src/libmdsserver/fd-table.h
index e484937..cb7f152 100644
--- a/src/libmdsserver/fd-table.h
+++ b/src/libmdsserver/fd-table.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/hash-help.h b/src/libmdsserver/hash-help.h
index 0d80cf3..2dda579 100644
--- a/src/libmdsserver/hash-help.h
+++ b/src/libmdsserver/hash-help.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/hash-list.h b/src/libmdsserver/hash-list.h
index 2087bce..fb12341 100644
--- a/src/libmdsserver/hash-list.h
+++ b/src/libmdsserver/hash-list.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/hash-table.c b/src/libmdsserver/hash-table.c
index 2a7bc3c..a9247eb 100644
--- a/src/libmdsserver/hash-table.c
+++ b/src/libmdsserver/hash-table.c
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/hash-table.h b/src/libmdsserver/hash-table.h
index 448a52d..32b0716 100644
--- a/src/libmdsserver/hash-table.h
+++ b/src/libmdsserver/hash-table.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/linked-list.c b/src/libmdsserver/linked-list.c
index 954c6fe..235a474 100644
--- a/src/libmdsserver/linked-list.c
+++ b/src/libmdsserver/linked-list.c
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/linked-list.h b/src/libmdsserver/linked-list.h
index fa115f1..bd38f1e 100644
--- a/src/libmdsserver/linked-list.h
+++ b/src/libmdsserver/linked-list.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/macro-bits.h b/src/libmdsserver/macro-bits.h
index a93b39e..7b697c2 100644
--- a/src/libmdsserver/macro-bits.h
+++ b/src/libmdsserver/macro-bits.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/macros.h b/src/libmdsserver/macros.h
index 45412b9..26ef4c0 100644
--- a/src/libmdsserver/macros.h
+++ b/src/libmdsserver/macros.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,31 +22,15 @@
#include "config.h"
#include "macro-bits.h"
-#include <stdio.h>
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
-#include <time.h>
-#include <stddef.h>
-#include <sys/socket.h>
-
/*
#include <pthread.h>
-#include <string.h>
#include <sys/types.h>
-#include <dirent.h>
-#include <stdlib.h>
*/
/* # pragma GCC diagnostic ignored "-Wpedantic" */
-/* CLOCK_MONOTONIC_RAW is a Linux-specific bug-fix */
-#ifndef CLOCK_MONOTONIC_RAW
-# define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
-#endif
-
/* Define TEMP_FAILURE_RETRY if not defined, however
* this version does not return a value, it will hoever
* clear `errno` if no error occurs. */
@@ -64,48 +48,6 @@
#endif
-/* Ensure that all aliases for AF_UNIX are defined */
-#if !defined(AF_LOCAL) && !defined(AF_UNIX) && defined(AF_FILE)
-# define AF_LOCAL AF_FILE
-# define AF_UNIX AF_FILE
-#elif !defined(AF_LOCAL) && defined(AF_UNIX)
-# define AF_LOCAL AF_UNIX
-#elif defined(AF_LOCAL) && !defined(AF_UNIX)
-# define AF_UNIX AF_LOCAL
-#endif
-#if !defined(AF_FILE) && defined(AF_LOCAL)
-# define AF_FILE AF_LOCAL
-#endif
-
-/* Ensure that all aliases for PF_UNIX are defined */
-#if !defined(PF_LOCAL) && !defined(PF_UNIX) && defined(PF_FILE)
-# define PF_LOCAL PF_FILE
-# define PF_UNIX PF_FILE
-#elif !defined(PF_LOCAL) && defined(PF_UNIX)
-# define PF_LOCAL PF_UNIX
-#elif defined(PF_LOCAL) && !defined(PF_UNIX)
-# define PF_UNIX PF_LOCAL
-#endif
-#if !defined(PF_FILE) && defined(PF_LOCAL)
-# define PF_FILE PF_LOCAL
-#endif
-
-/* Ensure that all aliases for AF_NETLINK are defined */
-#if !defined(AF_NETLINK) && defined(AF_ROUTE)
-# define AF_NETLINK AF_ROUTE
-#elif defined(AF_NETLINK) && !defined(AF_ROUTE)
-# define AF_ROUTE AF_NETLINK
-#endif
-
-/* Ensure that all aliases for PF_NETLINK are defined */
-#if !defined(PF_NETLINK) && defined(PF_ROUTE)
-# define PF_NETLINK PF_ROUTE
-#elif defined(PF_NETLINK) && !defined(PF_ROUTE)
-# define PF_ROUTE PF_NETLINK
-#endif
-
-
-
/**
* Wrapper around `asprintf` that makes sure that first
* argument gets set to `NULL` on error and that zero is
@@ -223,28 +165,6 @@
/**
- * Return the maximum value of two values
- *
- * @param a One of the values
- * @param b The other one of the values
- * @return The maximum value
- */
-#define max(a, b)\
- ((a) < (b) ? (b) : (a))
-
-
-/**
- * Return the minimum value of two values
- *
- * @param a One of the values
- * @param b The other one of the values
- * @return The minimum value
- */
-#define min(a, b)\
- ((a) < (b) ? (a) : (b))
-
-
-/**
* Cast a buffer to another type and get the slot for an element
*
* @param buffer:char* The buffer
@@ -335,28 +255,6 @@
/**
- * Check whether two strings are equal
- *
- * @param a:const char* One of the strings
- * @param b:const char* The other of the strings
- * @return :int Whether the strings are equal
- */
-#define strequals(a, b)\
- (!strcmp(a, b))
-
-
-/**
- * Check whether a string starts with another string
- *
- * @param haystack:const char* The string to inspect
- * @param needle:const char* The string `haystack` should start with
- * @return :int Whether `haystack` starts with `needle`
- */
-#define startswith(haystack, needle)\
- (strstr(haystack, needle) == haystack)
-
-
-/**
* Set effective user and the effective group to the
* real user and the real group, respectively. If the
* group cannot be set, the user till not be set either.
@@ -664,7 +562,7 @@
/**
* `strdup` wrapper that returns whether the allocation was not successful
*
- * This macro was added because GCC 6.1.1 warns of `original` is known to
+ * This macro was added because GCC 6.1.1 warns if `original` is known to
* be nonnull, when using `xstrdup`.
*
* @param var:char* The variable to which to assign the duplicate
@@ -748,18 +646,6 @@
/**
- * The way to get a pointer to the end of a string
- *
- * `strchr(str, '\0')` is faster than `str + strlen(str)`,
- * at least in the GNU C Library. If this is not true for
- * the compiler you are using, you may want to edit this
- * macro.
- */
-#define STREND(str)\
- (strchr(str, '\0'))
-
-
-/**
* The system is running out of memory.
* Quick, free up all your unused memory or kill yourself!
*/
diff --git a/src/libmdsserver/mds-message.c b/src/libmdsserver/mds-message.c
index c3d968f..0e93520 100644
--- a/src/libmdsserver/mds-message.c
+++ b/src/libmdsserver/mds-message.c
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -196,7 +196,7 @@ validate_header(const char *header, size_t length)
{
char *p = memchr(header, ':', length * sizeof(char));
- if (verify_utf8(header, 0) < 0)
+ if (!isutf8(header, 0))
/* Either the string is not UTF-8, or your are under an UTF-8 attack,
let's just call this unrecoverable because the client will not correct. */
return -2;
@@ -392,7 +392,7 @@ mds_message_read(mds_message_t *restrict this, int fd)
/* How much of the payload that has not yet been filled. */
need = this->payload_size - this->payload_ptr;
/* How much we have of that what is needed. */
- move = min(this->buffer_ptr, need);
+ move = MIN(this->buffer_ptr, need);
/* Copy what we have, and remove it from the the read buffer. */
memcpy(this->payload + this->payload_ptr, this->buffer, move * sizeof(char));
diff --git a/src/libmdsserver/mds-message.h b/src/libmdsserver/mds-message.h
index c6627e9..66023a2 100644
--- a/src/libmdsserver/mds-message.h
+++ b/src/libmdsserver/mds-message.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/table-common.h b/src/libmdsserver/table-common.h
index f21675a..6282693 100644
--- a/src/libmdsserver/table-common.h
+++ b/src/libmdsserver/table-common.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/libmdsserver/util.c b/src/libmdsserver/util.c
index 09d996a..5a7450a 100644
--- a/src/libmdsserver/util.c
+++ b/src/libmdsserver/util.c
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,19 +19,7 @@
#include "config.h"
#include "macros.h"
-#include <alloca.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <limits.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/socket.h>
-#include <errno.h>
-#include <ctype.h>
-#include <time.h>
-#include <sys/wait.h>
-#include <stdint.h>
-#include <inttypes.h>
+#include <libsimple.h>
@@ -68,20 +56,6 @@ parse_client_id(const char *str)
/**
- * Read an environment variable, but handle it as undefined if empty
- *
- * @param var The environment variable's name
- * @return The environment variable's value, `NULL` if empty or not defined
- */
-char *
-getenv_nonempty(const char *var)
-{
- char *rc = getenv(var);
- return (rc && *rc) ? rc : NULL;
-}
-
-
-/**
* Prepare the server so that it can reexec into
* a newer version of the executed file.
*
@@ -197,7 +171,7 @@ send_message(int socket, const char *message, size_t length)
errno = 0;
while (length > 0) {
- if ((just_sent = send(socket, message + sent, min(block_size, length), MSG_NOSIGNAL)) < 0) {
+ if ((just_sent = send(socket, message + sent, MIN(block_size, length), MSG_NOSIGNAL)) < 0) {
if (errno == EPIPE)
errno = ECONNRESET;
if (errno == EMSGSIZE) {
@@ -275,17 +249,13 @@ strict_atoj(const char *str, intmax_t *value, intmax_t min, intmax_t max)
return -1;
while ((c = *str)) {
- if ('0' <= c && c <= '9') {
- if (r > INTMAX_MAX / 10) {
- return -1;
- } else if (r == INTMAX_MAX / 10) {
- if ((c & 15) > INTMAX_MAX % 10)
- return -1;
- }
- r = r * 10 + (c & 15);
- } else {
+ if (!isdigit(c))
return -1;
- }
+ if (r > INTMAX_MAX / 10)
+ return -1;
+ if (r == INTMAX_MAX / 10 && (c & 15) > INTMAX_MAX % 10)
+ return -1;
+ r = r * 10 + (c & 15);
}
if (neg)
@@ -326,17 +296,13 @@ strict_atouj(const char *str, uintmax_t *value, uintmax_t min, uintmax_t max)
return -1;
while ((c = *str)) {
- if ('0' <= c && c <= '9') {
- if (r > INTMAX_MAX / 10) {
- return -1;
- } else if (r == INTMAX_MAX / 10) {
- if ((c & 15) > INTMAX_MAX % 10)
- return -1;
- }
- r = r * 10 + (c & 15);
- } else {
+ if (!isdigit(c))
return -1;
- }
+ if (r > INTMAX_MAX / 10)
+ return -1;
+ if (r == INTMAX_MAX / 10 && (c & 15) > INTMAX_MAX % 10)
+ return -1;
+ r = r * 10 + (c & 15);
}
if (r < min || r > max)
@@ -588,8 +554,8 @@ full_write(int fd, const char *buffer, size_t length)
errno = 0;
wrote = write(fd, buffer, length);
fail_if (errno && errno != EINTR);
- length -= (size_t)max(wrote, 0);
- buffer += (size_t)max(wrote, 0);
+ length -= (size_t)MAX(wrote, 0);
+ buffer += (size_t)MAX(wrote, 0);
}
return 0;
fail:
@@ -686,11 +652,9 @@ startswith_n(const char *haystack, const char *needle, size_t haystack_n, size_t
size_t i;
if (haystack_n < needle_n)
return 0;
-
for (i = 0; i < needle_n; i++)
if (haystack[i] != needle[i])
return 0;
-
return 1;
}
@@ -732,81 +696,6 @@ fail:
/**
- * Check whether a NUL-terminated string is encoded in UTF-8
- *
- * @param string The string
- * @param allow_modified_nul Whether Modified UTF-8 is allowed, which allows a two-byte encoding for NUL
- * @return Zero if good, -1 on encoding error
- */
-int
-verify_utf8(const char *string, int allow_modified_nul)
-{
- static long BYTES_TO_MIN_BITS[] = {0, 0, 8, 12, 17, 22, 37};
- static long BYTES_TO_MAX_BITS[] = {0, 7, 11, 16, 21, 26, 31};
- long bytes = 0, read_bytes = 0, bits = 0, c, character;
-
- /* min bits max bits
- 0....... 0 7
- 110..... 10...... 8 11
- 1110.... 10...... 10...... 12 16
- 11110... 10...... 10...... 10...... 17 21
- 111110.. 10...... 10...... 10...... 10...... 22 26
- 1111110. 10...... 10...... 10...... 10...... 10...... 27 31
- */
-
- while ((c = (long)(*string++))) {
- if (read_bytes == 0) {
- /* First byte of the character. */
-
- if (!(c & 0x80))
- /* Single-byte character. */
- continue;
-
- if ((c & 0xC0) == 0x80)
- /* Single-byte character marked as multibyte, or
- a non-first byte in a multibyte character. */
- return -1;
-
- /* Multibyte character. */
- while ((c & 0x80))
- bytes++, c <<= 1;
- read_bytes = 1;
- character = c & 0x7F;
- if (bytes > 6)
- /* 31-bit characters can be encoded with 6-bytes,
- and UTF-8 does not cover higher code points. */
- return -1;
- } else {
- /* Not first byte of the character. */
-
- if ((c & 0xC0) != 0x80)
- /* Beginning of new character before a
- multibyte character has ended. */
- return -1;
-
- character = (character << 6) | (c & 0x7F);
-
- if (++read_bytes < bytes)
- /* Not at last byte yet. */
- continue;
-
- /* Check that the character is not unnecessarily long. */
- while (character)
- character >>= 1, bits++;
- bits = ((bits == 0) && (bytes == 2) && allow_modified_nul) ? 8 : bits;
- if ((bits < BYTES_TO_MIN_BITS[bytes]) || (BYTES_TO_MAX_BITS[bytes] < bits))
- return -1;
-
- read_bytes = bytes = bits = 0;
- }
- }
-
- /* Make sure we did not stop at the middle of a multibyte character. */
- return read_bytes == 0 ? 0 : -1;
-}
-
-
-/**
* Construct an error message to be sent to a client
*
* @param recv_client_id The client ID attached on the message that was received, must not be `NULL`
diff --git a/src/libmdsserver/util.h b/src/libmdsserver/util.h
index 77cfa17..9f2953d 100644
--- a/src/libmdsserver/util.h
+++ b/src/libmdsserver/util.h
@@ -1,6 +1,6 @@
/**
* mds — A micro-display server
- * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se)
+ * Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,20 +23,9 @@
#include <stdint.h>
#include <sys/types.h>
+#include <libsimple.h>
-#ifndef __USE_GNU
-static inline void *__attribute__((pure, nonnull))
-rawmemchr(const void *str, int chr)
-{
- intptr_t str_address = (intptr_t)str;
- void *str_nonconst = (void*)str_address;
- char *s = str_nonconst;
- while ((int)*s++ != chr);
- return s - 1;
-}
-#endif
-
/**
* Convert a client ID string into a client ID integer
@@ -48,15 +37,6 @@ __attribute__((pure, nonnull))
uint64_t parse_client_id(const char *str);
/**
- * Read an environment variable, but handle it as undefined if empty
- *
- * @param var The environment variable's name
- * @return The environment variable's value, `NULL` if empty or not defined
- */
-__attribute__((nonnull))
-char *getenv_nonempty(const char *var);
-
-/**
* Prepare the server so that it can reexec into
* a newer version of the executed file.
*
@@ -409,16 +389,6 @@ int startswith_n(const char *haystack, const char *needle, size_t haystack_n, si
pid_t uninterruptable_waitpid(pid_t pid, int *restrict status, int options);
/**
- * Check whether a NUL-terminated string is encoded in UTF-8
- *
- * @param string The string
- * @param allow_modified_nul Whether Modified UTF-8 is allowed, which allows a two-byte encoding for NUL
- * @return Zero if good, -1 on encoding error
- */
-__attribute__((pure, nonnull))
-int verify_utf8(const char *string, int allow_modified_nul);
-
-/**
* Construct an error message to be sent to a client
*
* @param recv_client_id The client ID attached on the message that was received, must not be `NULL`