]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/libjorte/createAppInfo.c
JORTE: update license headers and clean-up includes
[orte.git] / orte / libjorte / createAppInfo.c
index 69f17614f340f8955886f40cf3f7ac79fd5f5f6a..efc8b6b4466fc71136af5fc5d2694c276f6a0aad 100644 (file)
@@ -1,9 +1,32 @@
 /* createAppInfo.c  */
 
-#include <jni.h>
-#include "orte.h"
-#include "jorte/4all.h"
-#include "jorte/jorte_protos_api.h"
+/**
+  * This code provides conversion between JAVA a C environments.
+  * The C functions are calling here and results are send to JAVA
+  * native functions. It uses the header pregenerated by JAVA
+  * (by command 'javah -jni class_with_native_function')
+  *
+  * @author Lukas Pokorny (lukas_pokorny@centrum.cz)
+  * @author Martin Vajnar (martin.vajnar@gmail.com)
+  * @author CTU FEE Prague - Department of Control Engineering (dce.felk.cvut.cz)
+  * @author Project ORTE - OCERA Real Time Ethernet (www.ocera.org)
+  * @author dedication to Kj
+  * @version 0.1
+  *
+  *
+  * This program is free software; you can redistribute it and/or modify
+  * it under the terms of the GNU General Public License as published by
+  * the Free Software Foundation; either version 2 of the License, or
+  * (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  * GNU General Public License for more details.
+  *
+  */
+
+#include "jorte/jorte.h"
 
 jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
 {
@@ -19,7 +42,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
   do
   {
     // find cls
-    cls = (*env)->FindClass(env, "org/ocera/orte/types/AppInfo");
+    cls = findClass(env, "org.ocera.orte.types.AppInfo");
     if(cls == 0)
     {
       #ifdef TEST_STAGE
@@ -55,7 +78,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.hostId = %d \n",ainfo->hostId);
+       printf(":c: ainfo.hostId = %#"PRIx32" \n",ainfo->hostId);
     #endif
     (*env)->SetLongField(env,
                          obj,
@@ -72,7 +95,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.appId = %d \n",ainfo->appId);
+       printf(":c: ainfo.appId = %#"PRIx32" \n",ainfo->appId);
     #endif
     (*env)->SetLongField(env,
                          obj,
@@ -88,7 +111,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.unicastIPAddressList = %d \n",ainfo->unicastIPAddressList);
+       printf(":c: ainfo.unicastIPAddressList = %#"PRIxPTR"\n",(intptr_t)ainfo->unicastIPAddressList);
     #endif
     (*env)->SetLongField(env,
                          obj,
@@ -104,7 +127,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.unicastIPcount = %d \n",
+       printf(":c: ainfo.unicastIPcount = %hhu \n",
               ainfo->unicastIPAddressCount);
     #endif
     (*env)->SetByteField(env,
@@ -121,8 +144,8 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.multicastIPAddressList = %\n",
-              ainfo->metatrafficMulticastIPAddressList);
+       printf(":c: ainfo.multicastIPAddressList = %#"PRIxPTR"\n",
+              (intptr_t)ainfo->metatrafficMulticastIPAddressList);
     #endif
     (*env)->SetLongField(env,
                          obj,
@@ -138,7 +161,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.metatrafficMulticastIPAddressCount = %d \n",
+       printf(":c: ainfo.metatrafficMulticastIPAddressCount = %hhu \n",
               ainfo->metatrafficMulticastIPAddressCount);
     #endif
     (*env)->SetByteField(env,
@@ -156,7 +179,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.metatrafficUnicastPort = %d \n",
+       printf(":c: ainfo.metatrafficUnicastPort = %"PRIu32" \n",
               ainfo->metatrafficUnicastPort);
     #endif
     (*env)->SetLongField(env,
@@ -174,7 +197,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.userdataUnicastPort = %d \n",
+       printf(":c: ainfo.userdataUnicastPort = %"PRIu32" \n",
               ainfo->userdataUnicastPort);
     #endif
     (*env)->SetLongField(env,
@@ -183,7 +206,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
                          (jlong) ainfo->userdataUnicastPort);
 
     // find cls - VendorID
-    cls_tmp = (*env)->FindClass(env, "org/ocera/orte/types/VendorId");
+    cls_tmp = findClass(env, "org.ocera.orte.types.VendorId");
     if(cls_tmp == 0)
     {
       #ifdef TEST_STAGE
@@ -229,7 +252,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.vendorId: major = %d, minor = %d \n",
+       printf(":c: ainfo.vendorId: major = %"PRId8", minor = %"PRId8" \n",
               ainfo->vendorId.major, ainfo->vendorId.minor);
     #endif
     (*env)->SetObjectField(env,
@@ -238,7 +261,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
                            obj_tmp);
 
     // find cls - VendorID
-    cls_tmp = (*env)->FindClass(env, "org/ocera/orte/types/ProtocolVersion");
+    cls_tmp = findClass(env, "org.ocera.orte.types.ProtocolVersion");
     if(cls_tmp == 0)
     {
       #ifdef TEST_STAGE
@@ -284,7 +307,7 @@ jobject createAppInfo(JNIEnv *env, const ORTEAppInfo *ainfo)
       break;
     }
     #ifdef TEST_STAGE
-       printf(":c: ainfo.protocolVersion: major = %d, minor = %d \n",
+       printf(":c: ainfo.protocolVersion: major = %"PRId8", minor = %"PRId8" \n",
               ainfo->protocolVersion.major, ainfo->protocolVersion.minor);
     #endif
     (*env)->SetObjectField(env,