Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_network_mock.c File Reference
#include "nilorea/n_str.h"
#include "nilorea/n_log.h"
#include "nilorea/n_network.h"
#include "nilorea/n_common.h"
#include <getopt.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
+ Include dependency graph for ex_network_mock.c:

Go to the source code of this file.

Macros

#define MOCK_PORT   19090
 mock server port
 

Functions

int main (int argc, char *argv[])
 
static void on_request (N_HTTP_REQUEST *req, N_HTTP_RESPONSE *resp, void *user_data)
 Request handler: returns JSON for GET /api/test, 404 otherwise.
 
static void * server_thread (void *arg)
 Thread function that runs the server accept loop.
 

Variables

static N_MOCK_SERVERg_server = NULL
 global server pointer for thread
 

Macro Definition Documentation

◆ MOCK_PORT

#define MOCK_PORT   19090

mock server port

Examples
ex_network_mock.c.

Definition at line 38 of file ex_network_mock.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ on_request()

static void on_request ( N_HTTP_REQUEST req,
N_HTTP_RESPONSE resp,
void *  user_data 
)
static

Request handler: returns JSON for GET /api/test, 404 otherwise.

Parameters
reqparsed HTTP request
respresponse to fill
user_dataunused
Examples
ex_network_mock.c.

Definition at line 49 of file ex_network_mock.c.

References N_HTTP_RESPONSE::body, char_to_nstr(), N_HTTP_RESPONSE::content_type, LOG_INFO, N_HTTP_REQUEST::method, n_log, N_HTTP_REQUEST::path, and N_HTTP_RESPONSE::status_code.

Referenced by main(), and n_mock_server_start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ server_thread()

static void * server_thread ( void *  arg)
static

Thread function that runs the server accept loop.

Parameters
argunused
Returns
NULL
Examples
ex_network_mock.c.

Definition at line 72 of file ex_network_mock.c.

References g_server, and n_mock_server_run().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ g_server

N_MOCK_SERVER* g_server = NULL
static

global server pointer for thread

Examples
ex_network_mock.c.

Definition at line 41 of file ex_network_mock.c.

Referenced by main(), and server_thread().