void tcn_Throw(JNIEnv *env, char *fmt, ...) { throwIllegalStateException(env, fmt); //TODO /* char msg[8124] = {'\0'}; va_list ap; va_start(ap, fmt); snprintf(msg, 8124, fmt, ap); throwIllegalStateException(env, msg); va_end(ap);*/ }
static void writeBitmapPixels(JNIEnv* env, jclass /* clazz */, jobject jbitmap, jint fd) { // Get the info. AndroidBitmapInfo info; int result = AndroidBitmap_getInfo(env, jbitmap, &info); if (result < 0) { throwIllegalStateException(env, (char*) "Cannot get bitmap info"); return; } // Write the info. bool written = writeAllBytes(fd, (void*) &info, sizeof(AndroidBitmapInfo)); if (!written) { throwIllegalStateException(env, (char*) "Cannot write bitmap info"); return; } // Lock the pixels. void* pixels; result = AndroidBitmap_lockPixels(env, jbitmap, &pixels); if (result < 0) { throwIllegalStateException(env, (char*) "Cannot lock bitmap pixels"); return; } // Write the pixels. size_t byteCount = info.stride * info.height; written = writeAllBytes(fd, (void*) pixels, byteCount); if (!written) { throwIllegalStateException(env, (char*) "Cannot write bitmap pixels"); return; } // Unlock the pixels. result = AndroidBitmap_unlockPixels(env, jbitmap); if (result < 0) { throwIllegalStateException(env, (char*) "Cannot unlock bitmap pixels"); } }
WF_OPENSSL(void, setSSLVerify)(JNIEnv *e, jobject o, jlong ssl, jint level, jint depth) { #pragma comment(linker, "/EXPORT:"__FUNCTION__"="__FUNCDNAME__) tcn_ssl_ctxt_t *c; int verify; SSL *ssl_ = J2P(ssl, SSL *); if (ssl_ == NULL) { throwIllegalStateException(e, "ssl is null"); return; } c = SSL_get_app_data2(ssl_); verify = SSL_VERIFY_NONE; UNREFERENCED(o); c->verify_mode = level; if (c->verify_mode == SSL_CVERIFY_UNSET) c->verify_mode = SSL_CVERIFY_NONE; if (depth > 0) c->verify_depth = depth; /* * Configure callbacks for SSL context */ if (c->verify_mode == SSL_CVERIFY_REQUIRE) verify |= SSL_VERIFY_PEER_STRICT; if ((c->verify_mode == SSL_CVERIFY_OPTIONAL) || (c->verify_mode == SSL_CVERIFY_OPTIONAL_NO_CA)) verify |= SSL_VERIFY_PEER; if (!c->store) { if (ssl_methods.SSL_CTX_set_default_verify_paths(c->ctx)) { c->store = ssl_methods.SSL_CTX_get_cert_store(c->ctx); crypto_methods.X509_STORE_set_flags(c->store, 0); } else { /* XXX: See if this is fatal */ } } ssl_methods.SSL_set_verify(ssl_, verify, SSL_callback_SSL_verify); }