diff --git a/Makefile b/Makefile index 7cfbadc..5066c3c 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,13 @@ all: $(TARGET) $(TARGET): filec $(OBJ) $(CC) -o $(DIST)$(TARGET) $(LDFLAGS) $(OBJ) -$(OBJ): $(SRC) - $(CC) $(CFLAGS) -c $< -o $@ - filec: src/file-to-c/main.o $(CC) -o file-to-c $< -src/file-to-c/main.o: src/file-to-c/main.c +%.o: %.c $(CC) $(CFLAGS) -c $< -o $@ -.PHONY: all +clean: + rm -f $(OBJ) src/file-to-c/main.o + +.PHONY: all filec clean diff --git a/config.h b/config.h new file mode 100644 index 0000000..3c2cdbb --- /dev/null +++ b/config.h @@ -0,0 +1,16 @@ +/* + * This is the config file for RatFE. Any changes you make here requires + * a recompile, but RatFE shouldn't take long to compile ;) + * + * You don't need to understand C, I've created simple types to represent + * what you need to set without any C knowledge. + */ + +#ifndef CONFIG_H +#define CONFIG_H +#define FALSE 0 +#define TRUE 1 + +static const char* config_canonical_name = "RatFE"; + +#endif // CONFIG_H diff --git a/src/index.c b/src/index.c new file mode 100644 index 0000000..708007d --- /dev/null +++ b/src/index.c @@ -0,0 +1,25 @@ +/* + * RatFE - Lightweight frontend for Pleroma + * Copyright (C) 2022 Nekobit + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include "index.h" + +void content_index() +{ + printf("Index.html\r\n"); +} diff --git a/src/index.h b/src/index.h new file mode 100644 index 0000000..7659408 --- /dev/null +++ b/src/index.h @@ -0,0 +1,24 @@ +/* + * RatFE - Lightweight frontend for Pleroma + * Copyright (C) 2022 Nekobit + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef INDEX_H +#define INDEX_H + +void content_index(); + +#endif // INDEX_H diff --git a/src/main.c b/src/main.c index cca0541..2d7e0a5 100644 --- a/src/main.c +++ b/src/main.c @@ -17,8 +17,19 @@ */ #include +#include +#include +#include "index.h" -int main(void) +int main() { - printf("Content-type: text/html\r\n\r\n

Release the rats

"); + char* path = getenv("PATH_INFO"); + // Content type is always HTML + fputs("Content-type: text/html\r\n\r\n", stdout); + + // Default index + if (path == NULL || (path && strcmp(path, "/"))) + { + content_index(); + } } diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..c83b793 --- /dev/null +++ b/static/index.html @@ -0,0 +1,11 @@ + + + + %s + + +
+ +
+ +