first steps

This commit is contained in:
2024-11-08 18:39:38 +01:00
parent 08b0bce492
commit e2bded0456
10 changed files with 74 additions and 1 deletions

3
.clang-format Normal file
View File

@@ -0,0 +1,3 @@
UseTab: Always
IndentWidth: 8
TabWidth: 8

3
.gitignore vendored
View File

@@ -1,3 +1,6 @@
build/
.cache/
# Prerequisites # Prerequisites
*.d *.d

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"clangd.path": "/usr/bin/clangd"
}

View File

@@ -1,2 +1,28 @@
# cws # cws
A Web Server written in C (educational project) A Web Server written in C (educational purposes)
## Requirements
- [meson](https://mesonbuild.com/index.html)
## How to build
```bash
$ meson setup build
$ cd build
$ meson compile
```
And then run `cws`!
## Roadmap
- [ ] Understading basic web server concepts
- [ ] Basic server
- [ ] Enhance web server
- [ ] Request parser (methods and headers)
- [ ] Serve static files
- [ ] Multithreading (non blocking I/O with `epoll`)
- [ ] Logging
- [ ] Advanced
- [ ] HTTPS support
- [ ] Caching
## Resources
- [Beej's Guide to Network Programming](https://beej.us/guide/bgnet/)

7
include/main.h Normal file
View File

@@ -0,0 +1,7 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#define GREEN_COLOR "\033[32m"
#define RESET_COLOR "\033[0m"
#endif

13
include/server.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef __SERVER_H__
#define __SERVER_H__
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#define PORT 3030
// how many pending connections the queue will hold
#define BACKLOG 10
#endif

6
meson.build Normal file
View File

@@ -0,0 +1,6 @@
project('tutorial', 'c')
subdir('src')
incdir = include_directories('include')
executable('cws', sources, include_directories: incdir)

6
src/main.c Normal file
View File

@@ -0,0 +1,6 @@
#include "main.h"
#include <stdio.h>
int main(void) {
puts(GREEN_COLOR "Running cws..." RESET_COLOR);
}

1
src/meson.build Normal file
View File

@@ -0,0 +1 @@
sources = files('main.c', 'server.c')

5
src/server.c Normal file
View File

@@ -0,0 +1,5 @@
#include "server.h"
int start_server(void) {
return 0;
}