From ca0e9cec0111f8135dccd5f1421ad3202905eeae Mon Sep 17 00:00:00 2001 From: nc543 Date: Wed, 28 May 2025 22:23:13 -0400 Subject: [PATCH] Flushed out config.cfg structure --- .gitignore | 3 +- config.cfg | 54 +++++++++++++++++-- controller | Bin 16584 -> 0 bytes makefile | 2 +- ServerController.c => src/ServerController.c | 20 ++----- src/ServerController.h | 15 ++++++ 6 files changed, 73 insertions(+), 21 deletions(-) delete mode 100755 controller rename ServerController.c => src/ServerController.c (57%) create mode 100644 src/ServerController.h diff --git a/.gitignore b/.gitignore index ac4a0fb..5534f44 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ *.code-workspace -.secrets \ No newline at end of file +.secrets +controller \ No newline at end of file diff --git a/config.cfg b/config.cfg index e46ef44..44b3748 100644 --- a/config.cfg +++ b/config.cfg @@ -1,3 +1,51 @@ -port 8888 -# Minecraft is a cool game yep -program minecraft # still cool \ No newline at end of file +# Syntax for this config file: +# Comments are marked with # +# Every line needs 2 things, a name and a value +# Name and value are separated by whitespace +# Leading and trailing whitespace is irrelevant, so feel free to indent to increase readability +# There must not be any whitespace inside of values. +# For example, file paths must not have spaces in them, otherwise the parser will not work +# Names are case sensitive + +# The port the web server will listen on +port 8888 # Inline comments are supported + +# program defines the name of a program to launch and manage. +# It also marks the beginning of the program definition +# The program name needs to have at least these attributes immediately following: +# - id +# - path +program Godot + # ID is the internal ID of the program. It is an unsigned char, so there cannot be more than 255 programs total + id 0 # REQUIRED + + # The path to the program binary / executable + # The controller will fork, replace stdin, stdout, and sterr with pipes, and then execv this path + path ~/Documents/Godot/Versions/Godot_v4.4.1-stable_linux.x86_64 # REQUIRED + + # Indicates if the site/api should allow viewing if the program is running or not + status-console 1 # Optional. Will default to 1 if not defined + + # Boolean. 0 for false, 1 for true. Indicates if the site/api should allow sending commands to the program stdin + # Useful for game servers that allow console commands + admin-console 0 # Optional. Will default to 0 if not defined + +# user defines the name of a use +user Nolan + # Like program IDs, it is an unsigned char. Maximum value of 255 + id 0 # REQUIRED + + # Indicates a program that a user has admin access to by ID + # -1 indicates universal admin access + # This name can be repeated as many times as necessary + admin -1 # Optional + + # Indicates a program that a user can turn on or off by ID + # -1 indicates universal admin access + # This name can be repeated as many times as necessary + launch -1 # Optional + + # Indicates a program that a user may view, but without admin access by ID + # -1 indicates universal view privilages + # This name can be repeated as many times as necessary + view -1 # Optional diff --git a/controller b/controller deleted file mode 100755 index bc497719e334e16859171c546409b2de0d720e73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16584 zcmeHOYiu0V6~4Q+!H|bHA%PHRvV=HB0>0r66C%gtE@|Iwxg1pj(1xs!rO5{~bvs3{~5wbmzSBF{B zz4BL7C`-0G^@WiPDJ;*9d<-2Rv2^n=Hv85{v)H$_TppviJWY~$s3LEOctgZvIYafa zFM0?n&C|?Yg(Ek*-T`;Yy!3`3g;4}YZJooI5?cuRDeV`7?_U*ffNaI|IY80Ro3;Q@34a#wu-6&%3*o5b zKUxLfPz9e`1@EhZW4|la`_(GAUIqUR;9)qtX$XKy<>T#G313kKe+Td|9NvW2HFCV^ z8UPl;=%1oWa6Dv6_G@NV4CUaYs#!A@zfFw~+@>aDdP*b>O%vL%ZVJsXGKNTIhP1TE znnntQs=_54M~Y#pgE1YE_;5^3>giZYze5x8SSpo?iy=c#n@N$?`vC_ZJ)4Pd-mGS` z@mM-3_8YpX2`mY({T8vKtFyIDT_3sL$u&E<4W;b*$VQ=d_Uu#>nxXaUSyMB5cDAK5 zX{{&Lm(rk`{=rO|8mHQ>6&>-4uYs#QDF13n1_7y)d9>g)5rC)PA&`9EU#9Ex@a{Z9 z*dnRditm#C)C1pv+owi6MtW|kei7F7BhWGN^O~QNlQb>^^gL#KAK~>;NfV5-K7FH& zaPA}8W?eY_%a)X3!tp-E_;4C^;rP7abe{{C|0l_C z#D!xYI30E2SO=#`7tXOj+mkLF0_~(@F8pE#72;_ZKF5XUT{sM|lTNzu`3@??lnbx= zP;~kGSw8}P1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1,5 +1,5 @@ controller: - gcc -Wall ServerController.c -o controller -lmicrohttpd -lyaml + gcc -Wall src/ServerController.c -o controller -lmicrohttpd clean: rm controller \ No newline at end of file diff --git a/ServerController.c b/src/ServerController.c similarity index 57% rename from ServerController.c rename to src/ServerController.c index 8fb808b..f776877 100644 --- a/ServerController.c +++ b/src/ServerController.c @@ -1,16 +1,6 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ServerController.h" -#define CONFIG "config.cfg" +#define CONFIG "../config.cfg" #define SECRETS ".secrets" const int PORT; @@ -29,17 +19,15 @@ void readConfig(){ FILE *file = fopen("config.cfg", "r"); char buf[1024]; while (fgets(buf, 1024, file) != NULL){ - printf("Line: \n%s\n", buf); char *newbuf = calloc(1024, 1); for (int i = 0; i < 1024; i++){ if (buf[i] == '#') break; else newbuf[i] = buf[i]; } - printf("Newbuf: %s\n", newbuf); char buf1[512]; char buf2[512]; - if (sscanf(newbuf, "%s %s", buf1, buf2) == 2){ - printf("Values: %s %s\n", buf1, buf2); + if (sscanf(newbuf, "%s %s\n", buf1, buf2) == 2){ + printf("(%s,%s)\n", buf1, buf2); } free(newbuf); } diff --git a/src/ServerController.h b/src/ServerController.h new file mode 100644 index 0000000..9872576 --- /dev/null +++ b/src/ServerController.h @@ -0,0 +1,15 @@ +#ifndef CONTROLLER + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif \ No newline at end of file