sds

simple/sensor data server
git clone git://git.hanetzok.net/sds
Log | Files | Refs | README | LICENSE

commit 52e590ab776862e9aaba4c34ad9dc704757f7007
parent a05fbc8d7ea2faae31414faf1929c0231de29331
Author: Markus Hanetzok <markus@hanetzok.net>
Date:   Thu, 20 Jun 2024 13:28:36 +0200

reformatting code

Diffstat:
Msds | 0
Msds.c | 24++++++++++++++----------
2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/sds b/sds Binary files differ. diff --git a/sds.c b/sds.c @@ -14,14 +14,14 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ +#include <ctype.h> #include <stdio.h> -#include <sys/socket.h> -#include <curl/curl.h> -#include <arpa/inet.h> -#include <string.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> -#include <ctype.h> +#include <arpa/inet.h> +#include <curl/curl.h> +#include <sys/socket.h> #define BUFFER_SIZE 1024 @@ -46,8 +46,17 @@ void die(char *msg) { exit(1); } +void buildsite(char response[], char *name, char *val, char *unit); +size_t writemem(void *contents, size_t size, size_t nmemb, void *userp); +void writeresponse(char response[], int clientfd, size_t responselen); + #include "sensors.h" +void buildsite(char response[], char *name, char *val, char *unit) { + snprintf(response + strlen(response), BUFFER_SIZE - strlen(response), + "<li>%s: %s%s</li>", name, val, unit); +} + size_t writemem(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; MemoryStruct *mem = (MemoryStruct *)userp; @@ -65,11 +74,6 @@ size_t writemem(void *contents, size_t size, size_t nmemb, void *userp) { return realsize; } -void buildsite(char response[], char *name, char *val, char *unit) { - snprintf(response + strlen(response), BUFFER_SIZE - strlen(response), - "<li>%s: %s%s</li>", name, val, unit); -} - void writeresponse(char response[], int clientfd, size_t responselen) { write(clientfd, response, strlen(response)); close(clientfd);