Hi All,
would appreciate help pls..
I am trying to prepare a JAVA-API wrapper on C-API for Remedy software.
i have asked some more questions on this also if you want to take a look at my other questions on the same subject.
I am trying to work on ARGetEntry.
This is what my C function looks like:
#include <stdlib.h>
#include <string.h>
#include <ar.h>
#include <arstruct.h>
#include <arextern.h>
#include <arfree.h>
#include <jni.h>
#include "NeTkt.h"
/*************************
**********
**********
**********
**********
**********
**/
/* */
/* PrintInt */
/* */
/*************************
**********
**********
**********
**********
**********
**/
void PrintInt(header, value)
char *header; /* IN; header string for the value */
int value; /* IN; value to print */
{
printf("\nPrintInt\n");
printf("%s %d\n", header, value);
}
/*************************
**********
**********
**********
**********
**********
**/
/* */
/* PrintChar */
/* */
/*************************
**********
**********
**********
**********
**********
**/
void PrintChar(header, value)
char *header; /* IN; header string for the value */
char *value; /* IN; value to print */
{
printf("\nPrintChar\n");
if (value == NULL)
printf("%s\n", header);
else
printf("%s %s\n", value);
}
void PrintARValueStruct(header,
value)
char *header; /* IN; header string for the value */
ARValueStruct *value; /* IN; value to print */
{
char buff[82]; /* buffer to hold second line header */
printf("%sValue: ", header);
printf("%sValue 1: ", value);
switch (value->dataType)
{
case AR_DATA_TYPE_NULL : /* NULL value (incl. no default) */
printf("NULL\n");
break;
case AR_DATA_TYPE_KEYWORD :
PrintInt("(keyword) ", value->u.keyNum);
break;
case AR_DATA_TYPE_CHAR :
printf("(char) %s ", value->u.charVal);
//return value->u.charVal;
break;
default :
printf("<undefined data type tag = %u>\n",
value->dataType);
break;
}
}
void PrintARInternalId(header, value)
char *header; /* IN; header string for the value */
ARInternalId value; /* IN; value to print */
{
printf("%s %lu\n", header, value);
}
void PrintARFieldValueStruct(va
lue)
ARFieldValueStruct *value; /* IN; value to print */
{
printf("Field Value Struct:\n");
PrintARInternalId(" Field Id :", value->fieldId);
if ((value->fieldId == AR_CORE_STATUS_HISTORY) &&
(value->value.dataType == AR_DATA_TYPE_CHAR))
printf(" Value: ", value->value.u.charVal);
else
PrintARValueStruct(" ", &value->value);
}
void PrintARFieldValueList(valu
e)
ARFieldValueList *value; /* IN; value to print */
{
int i; /* working index */
ARFieldValueStruct *tempPtr;/* working pointer */
printf("Field Value List : %u items\n", value);
printf("Field Value List : %u items\n", value->numItems);
if (value->numItems != 0)
{
tempPtr = value->fieldValueList;
for (i = 0; i < (int) value->numItems; i++)
{
PrintARFieldValueStruct(te
mpPtr);
tempPtr++;
}
}
}
JNIEXPORT void JNICALL Java_NeTkt_Initialize(JNIE
nv *env,jobject obj,
jstring jRemedyServer, jstring jRemedyUser, jstring jRemedyPassword, jstring jSchemaName, jstring jeid)
{
printf("Hello world for different method!\n");
ARStatusList status;
ARControlStruct control;
int result;
const char *sRemedyUser = (*env)->GetStringUTFChars(
env, jRemedyUser, 0);
const char *sRemedyPassword = (*env)->GetStringUTFChars(
env, jRemedyPassword, 0);
const char *sRemedyServer = (*env)->GetStringUTFChars(
env, jRemedyServer, 0);
const char *sSchemaName = (*env)->GetStringUTFChars(
env, jSchemaName, 0);
const char *seid = (*env)->GetStringUTFChars(
env, jeid, 0);
const char *sResult="";
printf(sRemedyUser);
printf("\n");
printf(sRemedyPassword);
printf("\n");
printf(sRemedyServer);
printf("\n");
printf(sSchemaName);
printf("\n");
printf(seid);
printf("\n");
control.cacheId = 0;
control.sessionId = 0;
strcpy(control.user, sRemedyUser);
strcpy(control.password, sRemedyPassword);
strcpy(control.language, "");
strcpy(control.server, sRemedyServer);
result = ARInitialization(&control,
&status);
switch (result)
{
case AR_RETURN_OK :
printf("OK\n");
break;
case AR_RETURN_WARNING :
printf("WARNING\n");
break;
case AR_RETURN_ERROR :
printf("ERROR\n");
break;
case AR_RETURN_FATAL :
printf("FATAL\n");
break;
case AR_RETURN_BAD_STATUS :
printf("BAD STATUS\n");
break;
default :
printf("<unknown return>\n");
break;
}
/* Verify user/password/server */
result=ARVerifyUser(&contr
ol, NULL,NULL,NULL,&status);
switch (result)
{
case AR_RETURN_OK :
printf("OK\n");
break;
case AR_RETURN_WARNING :
printf("WARNING\n");
break;
case AR_RETURN_ERROR :
printf("ERROR\n");
break;
case AR_RETURN_FATAL :
printf("FATAL\n");
break;
case AR_RETURN_BAD_STATUS :
printf("BAD STATUS\n");
break;
default :
printf("<unknown return>\n");
break;
}
/* Set the entryid of the record we want */
AREntryIdList entryId;
entryId.numItems = 1;
entryId.entryIdList = (AREntryIdType *) calloc(1, sizeof(AREntryIdType));
strncpy( entryId.entryIdList[0], seid, AR_MAX_ENTRYID_SIZE );
entryId.entryIdList[0][AR_
MAX_ENTRYI
D_SIZE] = '\0';
/* Get the entry */
ARFieldValueList fieldValues;
result = ARGetEntry(&control, sSchemaName, &entryId, NULL, &fieldValues, &status);
switch (result)
{
case AR_RETURN_OK :
printf("OK\n");
break;
case AR_RETURN_WARNING :
printf("WARNING\n");
break;
case AR_RETURN_ERROR :
printf("ERROR\n");
break;
case AR_RETURN_FATAL :
printf("FATAL\n");
break;
case AR_RETURN_BAD_STATUS :
printf("BAD STATUS\n");
break;
default :
printf("<unknown return>\n");
break;
}
if(result >= AR_RETURN_ERROR) {
printf("\nEntry Error\n");
} else {
printf("Got Entry");
PrintARFieldValueList(fiel
dValues);
}
//return;
/*
jclass cls = (*env)->GetObjectClass(env
, obj);
jmethodID mid = (*env)->GetMethodID(env, cls, "method1", "(Ljava/lang/Object;)V");
if (mid == 0) {
return;
}
printf("\nIn C, depth = %d, about to enter Java\n", 0);
jobject callbackArg = (*env)->NewObject(env, fieldValues);
(*env)->CallVoidMethod(env
, obj, mid, callbackArg);
*/
}
Now this fieldValue (which is of Type ARFieldValueList).. I am wondering How to deal with this.
Defination for C API and data types for Remedy can be found at
http://remedy.ncsu.edu/html/ver4/PDF/programmers.pdfwould appreciate help here plz..
regards