xref: /unit/src/java/nxt_jni.h (revision 977:4f9268f27b57)
1 
2 /*
3  * Copyright (C) NGINX, Inc.
4  */
5 
6 #ifndef _NXT_JAVA_JNI_H_INCLUDED_
7 #define _NXT_JAVA_JNI_H_INCLUDED_
8 
9 
10 #include <jni.h>
11 #include <nxt_unit_typedefs.h>
12 
13 
14 int nxt_java_jni_init(JNIEnv *env);
15 
16 void nxt_java_throw_NoSuchElementException(JNIEnv *env, const char *msg);
17 
18 void nxt_java_throw_IOException(JNIEnv *env, const char *msg);
19 
20 void nxt_java_throw_IllegalStateException(JNIEnv *env, const char *msg);
21 
22 nxt_unit_field_t *nxt_java_findHeader(nxt_unit_field_t *f, nxt_unit_field_t *e,
23     const char *name, uint8_t name_len);
24 
25 int nxt_java_strcaseeq(const char *str1, const char *str2, int len);
26 
27 jstring nxt_java_newString(JNIEnv *env, char *str, uint32_t len);
28 
29 
30 typedef struct {
31     uint32_t          header_size;
32     uint32_t          buf_size;
33 
34     jobject           jreq;
35     jobject           jresp;
36 
37     nxt_unit_buf_t    *first;
38     nxt_unit_buf_t    *buf;
39 
40 } nxt_java_request_data_t;
41 
42 
43 static inline jlong
nxt_ptr2jlong(void * ptr)44 nxt_ptr2jlong(void *ptr)
45 {
46     return (jlong) (intptr_t) ptr;
47 }
48 
49 static inline void *
nxt_jlong2ptr(jlong l)50 nxt_jlong2ptr(jlong l)
51 {
52     return (void *) (intptr_t) l;
53 }
54 
55 #endif  /* _NXT_JAVA_JNI_H_INCLUDED_ */
56