Flushed out config.cfg structure
This commit is contained in:
parent
204c177b2f
commit
ca0e9cec01
3
.gitignore
vendored
3
.gitignore
vendored
@ -14,4 +14,5 @@
|
|||||||
|
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
|
|
||||||
.secrets
|
.secrets
|
||||||
|
controller
|
54
config.cfg
54
config.cfg
@ -1,3 +1,51 @@
|
|||||||
port 8888
|
# Syntax for this config file:
|
||||||
# Minecraft is a cool game yep
|
# Comments are marked with #
|
||||||
program minecraft # still cool
|
# 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
|
||||||
|
BIN
controller
BIN
controller
Binary file not shown.
2
makefile
2
makefile
@ -1,5 +1,5 @@
|
|||||||
controller:
|
controller:
|
||||||
gcc -Wall ServerController.c -o controller -lmicrohttpd -lyaml
|
gcc -Wall src/ServerController.c -o controller -lmicrohttpd
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm controller
|
rm controller
|
@ -1,16 +1,6 @@
|
|||||||
#include <sys/types.h>
|
#include "ServerController.h"
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <microhttpd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define CONFIG "config.cfg"
|
#define CONFIG "../config.cfg"
|
||||||
#define SECRETS ".secrets"
|
#define SECRETS ".secrets"
|
||||||
|
|
||||||
const int PORT;
|
const int PORT;
|
||||||
@ -29,17 +19,15 @@ void readConfig(){
|
|||||||
FILE *file = fopen("config.cfg", "r");
|
FILE *file = fopen("config.cfg", "r");
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
while (fgets(buf, 1024, file) != NULL){
|
while (fgets(buf, 1024, file) != NULL){
|
||||||
printf("Line: \n%s\n", buf);
|
|
||||||
char *newbuf = calloc(1024, 1);
|
char *newbuf = calloc(1024, 1);
|
||||||
for (int i = 0; i < 1024; i++){
|
for (int i = 0; i < 1024; i++){
|
||||||
if (buf[i] == '#') break;
|
if (buf[i] == '#') break;
|
||||||
else newbuf[i] = buf[i];
|
else newbuf[i] = buf[i];
|
||||||
}
|
}
|
||||||
printf("Newbuf: %s\n", newbuf);
|
|
||||||
char buf1[512];
|
char buf1[512];
|
||||||
char buf2[512];
|
char buf2[512];
|
||||||
if (sscanf(newbuf, "%s %s", buf1, buf2) == 2){
|
if (sscanf(newbuf, "%s %s\n", buf1, buf2) == 2){
|
||||||
printf("Values: %s %s\n", buf1, buf2);
|
printf("(%s,%s)\n", buf1, buf2);
|
||||||
}
|
}
|
||||||
free(newbuf);
|
free(newbuf);
|
||||||
}
|
}
|
15
src/ServerController.h
Normal file
15
src/ServerController.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef CONTROLLER
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <microhttpd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user