Skip to content

Commit add6bf9

Browse files
committed
build: resolved signed/unsigned comparison warnings
1 parent fb2031c commit add6bf9

File tree

16 files changed

+489
-389
lines changed

16 files changed

+489
-389
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
bazel-*
2+
*.bazel
3+
*.bazelrc
4+
bazel-bin/
5+
bazel-out/
6+
bazel-testlogs/
7+
bazel-genfiles/

MODULE.bazel.lock

Lines changed: 66 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
## Vaayu
22

3-
A tiny, auditable HTTP/1.0 server in C designed for serving static files safely. Built with security and simplicity in mind.
4-
5-
⚠️ **Important**: This is a small HTTP server designed for personal use. Use at your own discretion.
3+
A tiny, auditable HTTP/1.0 static file server in C.
64

75
### Development
86

@@ -18,7 +16,7 @@ A tiny, auditable HTTP/1.0 server in C designed for serving static files safely.
1816
# Build all targets
1917
bazel build //...
2018

21-
# Build just the server
19+
# Build just server
2220
bazel build //examples/static_server:static_server
2321

2422
# Run tests
@@ -31,13 +29,13 @@ cd tests/smoke && ./test_smoke.sh
3129
#### Usage
3230

3331
```bash
34-
# Basic usage (serves ./www on port 8080)
32+
# Basic usage
3533
bazel run //examples/static_server:static_server
3634

3735
# Custom port and document root
3836
bazel run //examples/static_server:static_server -- -p 3000 -r /path/to/files
3937

40-
# All options
38+
# All
4139
bazel run //examples/static_server:static_server -- -h
4240
```
4341

@@ -54,7 +52,7 @@ Try these commands after starting the server:
5452
# Basic GET request
5553
curl -i http://localhost:8080/
5654

57-
# HEAD request (headers only)
55+
# HEAD
5856
curl -I http://localhost:8080/index.html
5957

6058
# Test different MIME types
@@ -64,6 +62,6 @@ curl -i http://localhost:8080/data.json
6462
# Test 404
6563
curl -i http://localhost:8080/nonexistent.txt
6664

67-
# Test 405 (method not allowed)
65+
# Test 405
6866
curl -i -X POST http://localhost:8080/
6967
```

examples/static_server/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ cc_binary(
55
srcs = ["main.c"],
66
deps = ["//lib/http:http"],
77
copts = ["-O2", "-Wall", "-Wextra", "-pedantic", "-Werror", "-std=c99"],
8+
visibility = ["//visibility:public"],
89
)

examples/static_server/main.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#include "tinyhttp.h"
1+
#include "vaayu_http.h"
22
#include <stdio.h>
33
#include <stdlib.h>
44
#include <string.h>
55
#include <unistd.h>
66
#include <signal.h>
77
#include <errno.h>
88

9-
static th_server server;
9+
static vh_server server;
1010
static volatile int running = 1;
1111

1212
static void sigint_handler(int sig) {
1313
(void)sig;
1414
running = 0;
15-
th_close(&server);
15+
vh_close(&server);
1616
exit(0);
1717
}
1818

@@ -63,7 +63,7 @@ int main(int argc, char *argv[]) {
6363
}
6464

6565
// Initialize server
66-
int ret = th_init(&server, docroot, port, index_file);
66+
int ret = vh_init(&server, docroot, port, index_file);
6767
if (ret != 0) {
6868
fprintf(stderr, "Failed to initialize server: %s\n", strerror(ret));
6969
return 1;
@@ -75,16 +75,16 @@ int main(int argc, char *argv[]) {
7575
signal(SIGINT, sigint_handler);
7676
signal(SIGTERM, sigint_handler);
7777

78-
printf("Starting tinyc HTTP server on port %d, serving %s\n", port, docroot);
78+
printf("Starting HTTP server on port %d, serving %s\n", port, docroot);
7979

8080
// Main server loop
8181
while (running) {
82-
ret = th_serve_once(&server);
82+
ret = vh_serve_once(&server);
8383
if (ret != 0 && running) {
8484
fprintf(stderr, "Error serving request: %s\n", strerror(ret));
8585
}
8686
}
8787

88-
th_close(&server);
88+
vh_close(&server);
8989
return 0;
9090
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
filegroup(
2+
name = "www",
3+
srcs = glob(["**/*"]),
4+
visibility = ["//visibility:public"],
5+
)
6+
17
exports_files(glob(["**/*"]))

examples/static_server/www/script.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
// TinyC HTTP Server Demo Script
2-
console.log("TinyC HTTP Server is serving JavaScript files correctly!");
1+
console.log("Server serving JS file");
32

43
document.addEventListener("DOMContentLoaded", function () {
54
const timestamp = new Date().toISOString();
65
console.log("Page loaded at:", timestamp);
76

8-
// Add a simple interactive element
97
document.body.addEventListener("click", function (e) {
108
if (e.target.tagName === "A") {
119
console.log("Navigating to:", e.target.href);
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
This is a plain text file served by the TinyC HTTP server.
2-
3-
It demonstrates serving text/plain content with proper MIME type detection.
1+
This is a plain text file served by the HTTP server.

lib/http/BUILD.bazel

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
22

33
cc_library(
44
name = "http",
5-
srcs = ["src/tinyhttp.c"],
6-
hdrs = ["include/tinyhttp.h"],
5+
srcs = [
6+
"src/http_server.c",
7+
"src/http_mime.c",
8+
"src/http_util.c",
9+
],
10+
hdrs = ["include/vaayu_http.h"],
711
includes = ["include"],
812
visibility = ["//visibility:public"],
913
copts = ["-O2", "-Wall", "-Wextra", "-pedantic", "-Werror", "-std=c99"],

lib/http/include/tinyhttp.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)