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

Resolves the runtime apps directory, fingerprints it for reload detection, logs startup state, and matches requests to mounted apps. More...

#include "native_runtime_stack.h"
#include "native_app_config.h"
#include "native_json_config.h"
#include "native_support.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

Go to the source code of this file.

Macros

#define PHAROS_RUNTIME_STACK_VERSION   "0.7.23"
#define native_runtime_stack_strdup   strdup

Functions

static char * shell_quote_runtime_stack_native (const char *value)
char * runtime_apps_dir_native (const char *conf_path)
 Resolves the apps directory configured for a runtime config file.
char * runtime_apps_fingerprint_native (const char *apps_dir)
 Builds a fingerprint string describing the current runtime apps directory state.
static void runtime_loaded_app_context_native (const AppRuntime *app, char *buffer, size_t buffer_len)
void runtime_log_banner_native (const RuntimeStack *stack, const ServeConfig *config, long load_ms)
 Emits a startup banner describing the loaded runtime stack.
AppRuntimeruntime_match_app_native (RuntimeStack *stack, const char *path)
 Finds the loaded app runtime that should handle a request path.

Detailed Description

Resolves the runtime apps directory, fingerprints it for reload detection, logs startup state, and matches requests to mounted apps.

Definition in file native_runtime_stack.c.

Macro Definition Documentation

◆ native_runtime_stack_strdup

#define native_runtime_stack_strdup   strdup

Definition at line 25 of file native_runtime_stack.c.

Referenced by shell_quote_runtime_stack_native().

◆ PHAROS_RUNTIME_STACK_VERSION

#define PHAROS_RUNTIME_STACK_VERSION   "0.7.23"

Definition at line 13 of file native_runtime_stack.c.

Referenced by runtime_log_banner_native().

Function Documentation

◆ runtime_apps_dir_native()

char * runtime_apps_dir_native ( const char * conf_path)

Resolves the apps directory configured for a runtime config file.

Parameters
conf_pathRuntime config file path.
Returns
Newly allocated apps directory path, or NULL when it cannot be resolved.

Definition at line 62 of file native_runtime_stack.c.

References conf_lookup_value(), current_working_directory(), and resolve_conf_relative_path_native().

Referenced by handle_native_runtime_command(), and serve_runtime_stack_native().

◆ runtime_apps_fingerprint_native()

char * runtime_apps_fingerprint_native ( const char * apps_dir)

Builds a fingerprint string describing the current runtime apps directory state.

Parameters
apps_dirDirectory containing discoverable apps.
Returns
Newly allocated fingerprint string, or NULL on failure.

Definition at line 78 of file native_runtime_stack.c.

References dup_range(), len, and shell_quote_runtime_stack_native().

Referenced by serve_runtime_stack_native().

◆ runtime_loaded_app_context_native()

void runtime_loaded_app_context_native ( const AppRuntime * app,
char * buffer,
size_t buffer_len )
static

Definition at line 115 of file native_runtime_stack.c.

References AppRuntime::app_id, and AppRuntime::base_path.

Referenced by runtime_log_banner_native().

◆ runtime_log_banner_native()

void runtime_log_banner_native ( const RuntimeStack * stack,
const ServeConfig * config,
long load_ms )

Emits a startup banner describing the loaded runtime stack.

Parameters
stackLoaded runtime stack.
configActive serve configuration.
load_msMilliseconds spent loading the runtime stack.

Definition at line 127 of file native_runtime_stack.c.

References RuntimeStack::apps, buffer_append(), buffer_free(), buffer_init(), RuntimeStack::count, Buffer::data, ServeConfig::host, Buffer::len, PHAROS_RUNTIME_STACK_VERSION, runtime_loaded_app_context_native(), and ServeConfig::socket_path.

Referenced by serve_runtime_stack_native().

◆ runtime_match_app_native()

AppRuntime * runtime_match_app_native ( RuntimeStack * stack,
const char * path )

Finds the loaded app runtime that should handle a request path.

Parameters
stackRuntime stack to search.
pathNormalized request path.
Returns
Pointer to the matching app runtime within stack, or NULL when no app matches.

Definition at line 162 of file native_runtime_stack.c.

References RuntimeStack::apps, AppRuntime::base_path, RuntimeStack::count, and starts_with().

Referenced by serve_runtime_stack_native().

◆ shell_quote_runtime_stack_native()

char * shell_quote_runtime_stack_native ( const char * value)
static

Definition at line 28 of file native_runtime_stack.c.

References len, and native_runtime_stack_strdup.

Referenced by runtime_apps_fingerprint_native().