Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
ucal_static_server.c File Reference

Provides a minimal loopback static server for serving UCAL build artifacts and route-mapped files directly from a build root. More...

#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

Go to the source code of this file.

Functions

static int send_all (int fd, const char *buf, size_t len)
static char * read_file (const char *path, size_t *len_out)
static int path_has_parent_reference (const char *path)
static const char * content_type_for_path (const char *path)
static int resolve_direct_asset (const char *root, const char *path, char *file_path, size_t file_path_len, char *content_type, size_t content_type_len)
static int lookup_route_map (const char *root, const char *path, char *artifact, size_t artifact_len, char *content_type, size_t content_type_len)
static void handle_client (int client, const char *root)
 Serves one loopback client request from the UCAL build root.
int main (int argc, char **argv)
 Starts the minimal UCAL loopback static server.

Detailed Description

Provides a minimal loopback static server for serving UCAL build artifacts and route-mapped files directly from a build root.

Definition in file ucal_static_server.c.

Function Documentation

◆ content_type_for_path()

const char * content_type_for_path ( const char * path)
static

Definition at line 51 of file ucal_static_server.c.

Referenced by resolve_direct_asset().

◆ handle_client()

void handle_client ( int client,
const char * root )
static

Serves one loopback client request from the UCAL build root.

Definition at line 122 of file ucal_static_server.c.

References lookup_route_map(), read_file(), resolve_direct_asset(), and send_all().

Referenced by main().

◆ lookup_route_map()

int lookup_route_map ( const char * root,
const char * path,
char * artifact,
size_t artifact_len,
char * content_type,
size_t content_type_len )
static

Definition at line 78 of file ucal_static_server.c.

Referenced by handle_client().

◆ main()

int main ( int argc,
char ** argv )

Starts the minimal UCAL loopback static server.

Definition at line 178 of file ucal_static_server.c.

References handle_client().

◆ path_has_parent_reference()

int path_has_parent_reference ( const char * path)
static

Definition at line 47 of file ucal_static_server.c.

Referenced by resolve_direct_asset().

◆ read_file()

char * read_file ( const char * path,
size_t * len_out )
static

Definition at line 29 of file ucal_static_server.c.

Referenced by handle_client().

◆ resolve_direct_asset()

int resolve_direct_asset ( const char * root,
const char * path,
char * file_path,
size_t file_path_len,
char * content_type,
size_t content_type_len )
static

Definition at line 67 of file ucal_static_server.c.

References content_type_for_path(), and path_has_parent_reference().

Referenced by handle_client().

◆ send_all()

int send_all ( int fd,
const char * buf,
size_t len )
static

Definition at line 19 of file ucal_static_server.c.

References len.

Referenced by handle_client().