Skip to content
Permalink
Browse files

Cleanup Logger.c

Instead of having one giant entangled if ISA if OS function mess for dumping registers, instead separate into per-OS functions
  • Loading branch information...
UnknownShadow200 committed Jul 9, 2019
1 parent dccabb9 commit 9244323a19585b86cf4647ea420b3c03d6cb57ca
Showing with 183 additions and 143 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 src/Entity.c
  3. +21 −11 src/Http.c
  4. +3 −3 src/Http.h
  5. +149 −125 src/Logger.c
  6. +6 −2 src/Platform.h
  7. +2 −1 src/Program.c
@@ -11,6 +11,7 @@
*.VC.VC.opendb

# Build results
[Aa]ndroid/
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
@@ -710,7 +710,7 @@ static void Player_CheckSkin(struct Player* p) {
if (!p->FetchedSkin && e->Model->UsesSkin) {
first = Player_FirstOtherWithSameSkinAndFetchedSkin(p);
if (!first) {
Http_AsyncGetSkin(&skin, &skin);
Http_AsyncGetSkin(&skin);
} else {
Player_CopySkin(p, first);
}
@@ -722,10 +722,12 @@ static void Http_SysFree(void) {
}
#elif defined CC_BUILD_ANDROID
#include <android_native_app_glue.h>
#include "<jni.h>"
#include <jni.h>

static void CallVoidJavaMethod(const char* name, const char* sig, ..) {
jmethodID method = env->GetStaticMethodID(clazz_algo, "init", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
static void CallJavaVoid(JNIEnv* env, const char* name, const char* sig, jvalue* args) {
jclass clazz = (*env)->FindClass(env, "com/classicube/Wrappers");
jmethodID method = (*env)->GetStaticMethodID(env, clazz, name, sig);
(*env)->CallStaticVoidMethodA(env, clazz, method, args);
}

bool Http_DescribeError(ReturnCode res, String* dst) {
@@ -735,30 +737,38 @@ bool Http_DescribeError(ReturnCode res, String* dst) {
static void Http_SysInit(void) { }

static void Http_AddHeader(const char* key, const String* value) {
jni
JavaVM* vm = (JavaVM*)VM_Handle;
JNIEnv* env;
jvalue args[2];

(*vm)->AttachCurrentThread(vm, &env, NULL);
args[0].l = (*env)->NewStringUTF(env, key);
jni value

CallJavaVoid(env, "httpSetHeader", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args);
}

/* Processes a HTTP header downloaded from the server */
static JNIEXPORT void JNICALL Java_com_classicube_Wrappers_httpParseHeader(JNIEnv* env, jlcass, jstring header) {
static JNIEXPORT void JNICALL Java_com_classicube_Wrappers_httpParseHeader(JNIEnv* env, jclass c, jstring header) {
String line;
const char* src = (*env)->GetStringUTFChars(env, header, NULL);
jsize length = (*env)->GetStringLength(env, header);

line = String_Init(src, length, length);
Http_ParseHeader(req, &line);
(*env)->ReleaseStringUTFChars(env, src);
(*env)->ReleaseStringUTFChars(env, header, src);
}

/* Processes a chunk of data downloaded from the web server */
static JNIEXPORT void JNICALL Java_com_classicube_Wrappers_httpAppendData(JNIEnv* env, jlcass, jbytearray arr, jint len) {
jbyte* src = (*env)->->GetByteArrayElements(env, NULL, 0);
static JNIEXPORT void JNICALL Java_com_classicube_Wrappers_httpAppendData(JNIEnv* env, jclass c, jbyteArray arr, jint len) {
jbyte* src = (*env)->GetByteArrayElements(env, NULL, 0);

if (!bufferSize) Http_BufferInit(req);
Http_BufferEnsure(req, len);

Mem_Copy(&req->Data[req->Size], src, len);
Http_BufferExpanded(req, len);
(*env)->ReleaseByteArrayElements(env, src, JNI_ABORT);
(*env)->ReleaseByteArrayElements(env, arr, src, JNI_ABORT);
}

/* Sets general curl options for a request */
@@ -868,7 +878,7 @@ static void Http_WorkerLoop(void) {
#define SKIN_SERVER "http://static.classicube.net/skins/"
#endif

void Http_AsyncGetSkin(const String* id, const String* skinName) {
void Http_AsyncGetSkin(const String* skinName) {
String url; char urlBuffer[STRING_SIZE];
String_InitArray(url, urlBuffer);

@@ -879,7 +889,7 @@ void Http_AsyncGetSkin(const String* id, const String* skinName) {
String_AppendColorless(&url, skinName);
String_AppendConst(&url, ".png");
}
Http_AsyncGetData(&url, false, id);
Http_AsyncGetData(&url, false, skinName);
}

void Http_AsyncGetData(const String* url, bool priority, const String* id) {
@@ -42,9 +42,9 @@ struct HttpRequest {
void HttpRequest_Free(struct HttpRequest* request);

/* Aschronously performs a http GET request to download a skin. */
/* If url is a skin, this is the same as Http_AsyncGetData. */
/* If not, instead downloads from http://static.classicube.net/skins/[skinName].png */
void Http_AsyncGetSkin(const String* id, const String* skinName);
/* If url is a skin, downloads from there. (if not, http://static.classicube.net/skins/[skinName].png) */
/* ID of the request is set to skinName. */
void Http_AsyncGetSkin(const String* skinName);
/* Asynchronously performs a http GET request. (e.g. to download data) */
void Http_AsyncGetData(const String* url, bool priority, const String* id);
/* Asynchronously performs a http HEAD request. (e.g. to get Content-Length header) */

0 comments on commit 9244323

Please sign in to comment.
You can’t perform that action at this time.