ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
network.c File Reference

Network function stubs for WASM. More...

Go to the source code of this file.

Typedefs

typedef struct websocket_client_t websocket_client_t
 
typedef struct tcp_client_t tcp_client_t
 
typedef struct app_callbacks_t app_callbacks_t
 
typedef void app_callbacks_reg_t
 
typedef void app_client_t
 
typedef void connection_attempt_context_t
 

Functions

asciichat_error_t platform_popen (const char *name, const char *command, const char *mode, FILE **out_stream)
 Execute a command and return a file stream for reading/writing.
 
asciichat_error_t platform_pclose (FILE **stream_ptr)
 Close a process stream opened with platform_popen()
 
int platform_execute_subprocess (const char *executable, const char **argv, char *output_buffer, size_t output_size)
 Execute a subprocess and optionally capture its output.
 
void websocket_client_destroy (websocket_client_t *client)
 
void tcp_client_destroy (tcp_client_t *client)
 
app_callbacks_t * app_callbacks_get (void)
 
void app_callbacks_register (app_callbacks_reg_t *callbacks)
 
app_client_t * app_client_create (void)
 Create and initialize client application context.
 
void app_client_destroy (app_client_t *client)
 
asciichat_error_t connection_context_init (connection_attempt_context_t *ctx)
 Initialize connection attempt context.
 
void connection_context_cleanup (connection_attempt_context_t *ctx)
 Cleanup connection attempt context.
 
tcp_client_t * tcp_client_create (void)
 Create and initialize a TCP client instance.
 

Detailed Description

Network function stubs for WASM.

Definition in file platform/wasm/stubs/network.c.

Typedef Documentation

◆ app_callbacks_reg_t

typedef void app_callbacks_reg_t

Definition at line 50 of file platform/wasm/stubs/network.c.

◆ app_callbacks_t

Definition at line 34 of file platform/wasm/stubs/network.c.

◆ app_client_t

typedef void app_client_t

Definition at line 51 of file platform/wasm/stubs/network.c.

◆ connection_attempt_context_t

Definition at line 52 of file platform/wasm/stubs/network.c.

◆ tcp_client_t

typedef struct tcp_client_t tcp_client_t

Definition at line 33 of file platform/wasm/stubs/network.c.

◆ websocket_client_t

Definition at line 32 of file platform/wasm/stubs/network.c.

Function Documentation

◆ app_callbacks_get()

app_callbacks_t * app_callbacks_get ( void  )

Get registered callbacks (returns NULL if not registered)

Definition at line 46 of file platform/wasm/stubs/network.c.

46 {
47 return NULL; // No app callbacks in WASM
48}

◆ app_callbacks_register()

void app_callbacks_register ( app_callbacks_reg_t *  callbacks)

Definition at line 54 of file platform/wasm/stubs/network.c.

54 {
55 (void)callbacks;
56}

◆ app_client_create()

app_client_t * app_client_create ( void  )

Create and initialize client application context.

Returns
Pointer to initialized context, or NULL on failure

Definition at line 58 of file platform/wasm/stubs/network.c.

58 {
59 return NULL;
60}

◆ app_client_destroy()

void app_client_destroy ( app_client_t *  client)

Definition at line 62 of file platform/wasm/stubs/network.c.

62 {
63 (void)client;
64}

◆ connection_context_cleanup()

void connection_context_cleanup ( connection_attempt_context_t *  ctx)

Cleanup connection attempt context.

Closes and releases any active transports. Called on connection success, failure, or shutdown.

Parameters
ctxConnection context to cleanup

Definition at line 71 of file platform/wasm/stubs/network.c.

71 {
72 (void)ctx;
73}

◆ connection_context_init()

asciichat_error_t connection_context_init ( connection_attempt_context_t *  ctx)

Initialize connection attempt context.

Sets up initial state, resets timeouts, and prepares for connection attempt.

Parameters
ctxConnection context to initialize
Returns
ASCIICHAT_OK on success, error code otherwise

Definition at line 66 of file platform/wasm/stubs/network.c.

66 {
67 (void)ctx;
68 return SET_ERRNO(ERROR_NOT_SUPPORTED, "connection_context_init not supported in WASM");
69}
#define SET_ERRNO(code, context_msg,...)
Set error code with custom context message and log it, returning the error code.
@ ERROR_NOT_SUPPORTED
Definition error_codes.h:74

References ERROR_NOT_SUPPORTED, and SET_ERRNO.

◆ tcp_client_create()

tcp_client_t * tcp_client_create ( void  )

Create and initialize a TCP client instance.

Allocates a new tcp_client_t structure and initializes all fields to safe defaults. This function must be called before starting any worker threads.

Initialization Steps

  1. Allocate tcp_client_t structure
  2. Zero-initialize all fields
  3. Set atomic flags to initial states
  4. Initialize mutexes and condition variables
  5. Set socket to INVALID_SOCKET_VALUE

Error Handling

Returns NULL if allocation fails or mutex initialization fails. Check errno or use HAS_ERRNO() for detailed error information.

Returns
Pointer to initialized client, or NULL on failure
Note
Caller must call tcp_client_destroy() when done
See also
tcp_client_destroy() For proper cleanup

Create and initialize a TCP client instance.

Allocates tcp_client_t and initializes all fields to safe defaults.

Definition at line 75 of file platform/wasm/stubs/network.c.

75 {
76 return NULL;
77}

◆ tcp_client_destroy()

void tcp_client_destroy ( tcp_client_t *  client)

Definition at line 41 of file platform/wasm/stubs/network.c.

41 {
42 (void)client;
43 // No-op - TCP client not used in WASM mirror mode
44}

◆ websocket_client_destroy()

void websocket_client_destroy ( websocket_client_t *  client)

Definition at line 36 of file platform/wasm/stubs/network.c.

36 {
37 (void)client;
38 // No-op - websocket client not used in WASM mirror mode
39}