1 /* JGetORTEConstant.c */
3 * This code provides conversion between JAVA a C environments.
4 * The C functions are calling here and results are send to JAVA
5 * native functions. It uses the header pregenerated by JAVA
6 * (by command 'javah -jni class_with_native_function')
8 * @author Lukas Pokorny (lukas_pokorny@centrum.cz)
9 * @author CTU FEE Prague - Department of Control Engineering (dce.felk.cvut.cz)
10 * @author Project ORTE - OCERA Real Time Ethernet (www.ocera.org)
11 * @author dedication to Kj
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
28 /* pregenerated header */
29 #include "jorte/org_ocera_orte_tools_GetORTEConstant.h"
30 /* library header file's path */
33 /* macro for comparing 2 strings */
34 /* if(a==b) -> strcmp = 0 */
35 #define compare(a,b) ((strcmp((const char *)(a), (const char*)(b)) == 0) ? 1 : 0)
38 /* global variables */
40 JNIEnv *globalJavaEnv;
47 /* native function - prototype declared in pregenerated header */
48 JNIEXPORT jint JNICALL
49 Java_org_ocera_tools_GetORTEConstant_getConstant
50 (JNIEnv *env, jobject jobj, jstring jname)
55 /* get the constant name from JAVA Enviromnent*/
56 constant = (*env)->GetStringUTFChars(env,jname,0);
61 /* check if the name of the constant is correct *
62 * if yes, return the constant value *
65 /* RTPS_HEADER_LENGTH */
66 #ifdef RTPS_HEADER_LENGTH
67 if (compare(constant,"RTPS_HEADER_LENGTH"))
68 const_value = RTPS_HEADER_LENGTH;
74 if (compare(constant,"MAX_PATHNAME"))
75 const_value = MAX_PATHNAME;
81 if (compare(constant,"MAX_TYPENAME"))
82 const_value = MAX_TYPENAME;
88 if (compare(constant,"ORTE_TRUE"))
89 const_value = ORTE_TRUE;
95 if (compare(constant,"ORTE_FALSE"))
96 const_value = ORTE_FALSE;
118 /* return the result value*/
119 if (const_value == 0) return (-1);
121 return (const_value);
132 const char *c = "MAX";
135 printf("je definovano \n");
139 printf("neni definovano \n");
144 int get_const(char *konstanta)
146 #define xxx(name) if (strcmp((const char *)konstanta, (const char*)#name)) return name
152 // command cpp c_file