Compare commits
2 Commits
d3e06434e6
...
ec3064e0a1
| Author | SHA1 | Date | |
|---|---|---|---|
| ec3064e0a1 | |||
| af8e60f8c3 |
@@ -1,6 +1,7 @@
|
||||
#include "httpd.js.h"
|
||||
|
||||
#include "http.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
#include "ssb.db.h"
|
||||
#include "ssb.h"
|
||||
@@ -8,6 +9,7 @@
|
||||
#include "util.js.h"
|
||||
|
||||
#include "picohttpparser.h"
|
||||
#include "uv.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -211,7 +213,12 @@ void tf_httpd_endpoint_app(tf_http_request_t* request)
|
||||
tf_ssb_run_work(ssb, _httpd_endpoint_app_blob_work, _httpd_endpoint_app_blob_after_work, data);
|
||||
}
|
||||
|
||||
void tf_httpd_endpoint_app_socket(tf_http_request_t* request)
|
||||
static void _tf_httpd_endpoint_app_socket_c(tf_http_request_t* request)
|
||||
{
|
||||
tf_printf("Unimplemented.\n");
|
||||
}
|
||||
|
||||
static void _tf_httpd_endpoint_app_socket_js(tf_http_request_t* request)
|
||||
{
|
||||
tf_task_t* task = request->user_data;
|
||||
tf_ssb_t* ssb = tf_task_get_ssb(task);
|
||||
@@ -250,3 +257,25 @@ void tf_httpd_endpoint_app_socket(tf_http_request_t* request)
|
||||
JS_FreeValue(context, exports);
|
||||
JS_FreeValue(context, global);
|
||||
}
|
||||
|
||||
void tf_httpd_endpoint_app_socket(tf_http_request_t* request)
|
||||
{
|
||||
static bool checked_env;
|
||||
static bool use_c;
|
||||
if (!checked_env)
|
||||
{
|
||||
char buffer[8] = { 0 };
|
||||
size_t buffer_size = sizeof(buffer);
|
||||
use_c = uv_os_getenv("TF_APP_C", buffer, &buffer_size) == 0 && strcmp(buffer, "1") == 0;
|
||||
checked_env = true;
|
||||
}
|
||||
|
||||
if (use_c)
|
||||
{
|
||||
_tf_httpd_endpoint_app_socket_c(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tf_httpd_endpoint_app_socket_js(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2402,7 +2402,6 @@ tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, const char* db_path
|
||||
|
||||
char buffer[8] = { 0 };
|
||||
size_t buffer_size = sizeof(buffer);
|
||||
buffer_size = sizeof(buffer);
|
||||
ssb->verbose = uv_os_getenv("TF_SSB_VERBOSE", buffer, &buffer_size) == 0 && strcmp(buffer, "1") == 0;
|
||||
|
||||
if (context)
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
|
||||
/** An event loop. */
|
||||
typedef struct uv_loop_s uv_loop_t;
|
||||
/** A timer. */
|
||||
typedef struct uv_timer_s uv_timer_t;
|
||||
|
||||
/** A task identifier. */
|
||||
typedef int taskid_t;
|
||||
|
||||
@@ -21,9 +21,6 @@ typedef enum _tf_setting_kind_t
|
||||
k_kind_string,
|
||||
} tf_setting_kind_t;
|
||||
|
||||
/** An event loop. */
|
||||
typedef struct uv_loop_s uv_loop_t;
|
||||
|
||||
/**
|
||||
** Register utility script functions.
|
||||
** @param context The JS context.
|
||||
|
||||
Reference in New Issue
Block a user