Skip to content

Instantly share code, notes, and snippets.

@sonOfRa
Created August 29, 2013 10:48
Show Gist options
  • Save sonOfRa/6376642 to your computer and use it in GitHub Desktop.
Save sonOfRa/6376642 to your computer and use it in GitHub Desktop.
typedef union {
uint8_t c[4];
uint16_t s[2];
uint32_t i;
} tox_IP;
typedef struct {
tox_IP ip;
uint16_t port;
/* not used for anything right now */
uint16_t padding;
} tox_IP_Port;
JNIEXPORT void JNICALL Java_im_tox_jtoxcore_JTox_tox_1bootstrap(JNIEnv * env,
jobject obj, jlong messenger, jbyteArray ip, jint port, jstring address) {
tox_IP_Port ipport;
tox_IP _ip;
jbyte *ip_array = (*env)->GetByteArrayElements(env, ip, 0);
jsize n = (*env)->GetArrayLength(env, ip);
int i;
for (i = 0; i < n; ++i) {
_ip.c[i] = ip_array[i];
printf("%i \n", _ip.c[i]);
}
fflush(stdout);
(*env)->ReleaseByteArrayElements(env, ip, ip_array, 0);
ipport.ip = _ip;
ipport.port = htonl(port);
const char *_address = (*env)->GetStringUTFChars(env, address, 0);
uint8_t __address[TOX_FRIEND_ADDRESS_SIZE];
hex_to_addr(_address, __address);
tox_bootstrap((Tox *) messenger, ipport, __address);
(*env)->ReleaseStringUTFChars(env, address, _address);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment