I have function declaration in Java and same function definition written in C programming language.. A JNI call from Java is made to a fuction...Function would set the environment variable { putenv(cEnvString1);} using C-built -in function ..and later return the encrypted string...
putenv is used to set the environment variable in C...Is there any alternate function to set the environment variable..? Looks like putenv is working here.
getenv function works well..
C function definition for a JNI call:-
-----------------------------------------
JNIEXPORT jstring JNICALL Java_gdm_schema_main_encryption_encryptStr
(JNIEnv *j_env, jobject j_obj)
{
char *cConnString = NULL ;
char *cEnvUserPasswd = NULL;
char cEnvString1[200]= {"FND_HIDDEN_USERPASS="};
/**
** If environment variable is not set
*/
/
if (cEnvUserPasswd == NULL)
{
fprintf(stderr,"\nError in finding connect string info. exiting ...Shafi\n");
exit(-1);
}
*/
/**
** If Environment variable contains unencrypted login-password
** i.e. called directly from bin, return it .
*/
/
if (strchr(cEnvUserPasswd , (int)'/') != NULL)
return convertToJavaString( j_env, cEnvUserPasswd ,strlen(cEnvUserPasswd));
else
{
cConnString = process_string ("INSTALL/install@fnd9i", "0", ENCRYPT);
return convertToJavaString( j_env, cConnString , strlen(cConnString));
}
*/
fprintf(stderr,"\nEncryption block.... ...\n");
cConnString = process_string ("INSTALL/install@fnd9i", "0", ENCRYPT);
putenv\("FND\_HIDDEN_USERPASS=NONE"\);
/* Prepare string for putenv function
sprintf\(cEnvUserPasswd,"%s",cConnString\);
*/
strcat\(cEnvString1,cConnString\);
/* Keep the Connect string and position in Environment */
putenv\(cEnvString1\);
fprintf\(stderr,"\\nAfter calling encryption %s.... ...\\n",cEnvString1\);
fprintf\(stderr,"\\nAfter calling encryption %s..%s..%d ...\\n",j_env,cConnString,strlen\(cConnString\)\);
return convertToJavaString\( j_env, cConnString , strlen\(cConnString\)\);
}
------------------------