How z101/quark works
Project type and purpose
• quark is a minimalist, single-host HTTP web server written in C.
• Its core features are:
• Serving static files from a specified web-root directory
• Basic CGI support for dynamic content
File structure
• Top-level C source and headers:
• quark.c – main server loop, dispatch, request parser
• arg.h – command-line argument definitions
• config.def.h – compile-time defaults for ports, paths, etc.
• config.mk – user’s local build/install configuration
• Build and packaging:
• Makefile – build, clean, install targets
• LICENSE, .gitignore, patches, Debian init script (quark.daemon.debian)
• quark.1 – manpage for server usage
README for additional insights
• Confirms configuration via config.mk
• Installation path (/usr/local/bin) and startup invocation (sudo quark)
• Operational flow: change into <web-root>, run quark to bind port 80 and handle HTTP requests
a. Main components
1. Client (Web browser or HTTP client)
2. quark Server Process
• Command‐line / config parser
• Listener / socket accept loop
• HTTP request parser
• Static file handler
• CGI launcher (fork + exec)
• Response generator (headers, payload)
• Logger (optional status logging)
3. File System (web-root directory, CGI scripts)
4. Operating System / Network Stack (TCP/IP, process management)
b. Relationships and interactions
• Client → TCP/IP stack → quark listener socket
• quark request parser dispatches to either:
• Static file handler → File I/O → File System → build response
• CGI handler → fork/exec CGI script → capture stdout → build response
• quark → TCP/IP stack → client (response)
• quark logs events (errors/status) to stdout or log file
c. Architectural patterns & design principles
• Single-process, sequential or simple event loop (no thread pool)
• Modular dispatch: parsing → handler → response
• Compile‐time configuration via headers and Makefile
d. Key technologies & libraries
• POSIX sockets for networking
• Standard C library for file I/O, string parsing, fork/exec
• Makefile for build automation
• CGI standard for dynamic scripts
Detailed capture of essential elements
1. Config & Argument Parser
2. Socket Acceptor
3. HTTP Parser
4. Static File Server
5. CGI Dispatcher
6. Logger
• How build files (config.mk, config.def.h) feed into the compiled binary (quark).
• Call out the manpage and Debian init script as deployment artifacts (not part of runtime flow but part of the overall system lifecycle).