< prev index next >

jdk/src/java.prefs/windows/native/libprefs/WindowsPreferences.c

Print this page

        

*** 44,67 **** int tmp[2]; int errorCode=-1; jintArray result; str = (*env)->GetByteArrayElements(env, lpSubKey, NULL); CHECK_NULL_RETURN(str, NULL); ! errorCode = RegOpenKeyEx((HKEY)hKey, str, 0, securityMask, &handle); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); ! tmp[0]= (int) handle; tmp[1]= errorCode; result = (*env)->NewIntArray(env,2); if (result != NULL) { (*env)->SetIntArrayRegion(env, result, 0, 2, tmp); } return result; } JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCloseKey (JNIEnv* env, jclass this_class, jint hKey) { ! return (jint) RegCloseKey((HKEY) hKey); }; JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCreateKeyEx (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) { HKEY handle; --- 44,67 ---- int tmp[2]; int errorCode=-1; jintArray result; str = (*env)->GetByteArrayElements(env, lpSubKey, NULL); CHECK_NULL_RETURN(str, NULL); ! errorCode = RegOpenKeyEx((HKEY)(uintptr_t)hKey, str, 0, securityMask, &handle); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); ! tmp[0]= (int)(uintptr_t) handle; tmp[1]= errorCode; result = (*env)->NewIntArray(env,2); if (result != NULL) { (*env)->SetIntArrayRegion(env, result, 0, 2, tmp); } return result; } JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCloseKey (JNIEnv* env, jclass this_class, jint hKey) { ! return (jint) RegCloseKey((HKEY)(uintptr_t) hKey); }; JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCreateKeyEx (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) { HKEY handle;
*** 70,84 **** DWORD lpdwDisposition; int errorCode; jintArray result = NULL; str = (*env)->GetByteArrayElements(env, lpSubKey, NULL); CHECK_NULL_RETURN(str, NULL); ! errorCode = RegCreateKeyEx((HKEY)hKey, str, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &handle, &lpdwDisposition); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); ! tmp[0]= (int) handle; tmp[1]= errorCode; tmp[2]= lpdwDisposition; result = (*env)->NewIntArray(env,3); if (result != NULL) { (*env)->SetIntArrayRegion(env, result, 0, 3, tmp); --- 70,84 ---- DWORD lpdwDisposition; int errorCode; jintArray result = NULL; str = (*env)->GetByteArrayElements(env, lpSubKey, NULL); CHECK_NULL_RETURN(str, NULL); ! errorCode = RegCreateKeyEx((HKEY)(uintptr_t)hKey, str, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &handle, &lpdwDisposition); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); ! tmp[0]= (int)(uintptr_t) handle; tmp[1]= errorCode; tmp[2]= lpdwDisposition; result = (*env)->NewIntArray(env,3); if (result != NULL) { (*env)->SetIntArrayRegion(env, result, 0, 3, tmp);
*** 90,108 **** (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) { char* str; int result; str = (*env)->GetByteArrayElements(env, lpSubKey, NULL); CHECK_NULL_RETURN(str, -1); ! result = RegDeleteKey((HKEY)hKey, str); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); return result; }; JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegFlushKey (JNIEnv* env, jclass this_class, jint hKey) { ! return RegFlushKey ((HKEY)hKey); } JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryValueEx (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName) { char* valueNameStr; --- 90,108 ---- (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) { char* str; int result; str = (*env)->GetByteArrayElements(env, lpSubKey, NULL); CHECK_NULL_RETURN(str, -1); ! result = RegDeleteKey((HKEY)(uintptr_t)hKey, str); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); return result; }; JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegFlushKey (JNIEnv* env, jclass this_class, jint hKey) { ! return RegFlushKey ((HKEY)(uintptr_t)hKey); } JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryValueEx (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName) { char* valueNameStr;
*** 110,128 **** jbyteArray result; DWORD valueType; DWORD valueSize; valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL); CHECK_NULL_RETURN(valueNameStr, NULL); ! if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, NULL, &valueSize) != ERROR_SUCCESS) { (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); return NULL; } buffer = (char*)malloc(valueSize); if (buffer != NULL) { ! if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer, &valueSize) != ERROR_SUCCESS) { free(buffer); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); return NULL; } --- 110,128 ---- jbyteArray result; DWORD valueType; DWORD valueSize; valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL); CHECK_NULL_RETURN(valueNameStr, NULL); ! if (RegQueryValueEx((HKEY)(uintptr_t)hKey, valueNameStr, NULL, &valueType, NULL, &valueSize) != ERROR_SUCCESS) { (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); return NULL; } buffer = (char*)malloc(valueSize); if (buffer != NULL) { ! if (RegQueryValueEx((HKEY)(uintptr_t)hKey, valueNameStr, NULL, &valueType, buffer, &valueSize) != ERROR_SUCCESS) { free(buffer); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); return NULL; }
*** 159,169 **** size = (*env)->GetArrayLength(env, data); dataStr = (*env)->GetByteArrayElements(env, data, NULL); CHECK_NULL_RETURN(dataStr, -1); valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL); if (valueNameStr != NULL) { ! error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0, REG_SZ, dataStr, size); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); } (*env)->ReleaseByteArrayElements(env, data, dataStr, 0); return error_code; --- 159,169 ---- size = (*env)->GetArrayLength(env, data); dataStr = (*env)->GetByteArrayElements(env, data, NULL); CHECK_NULL_RETURN(dataStr, -1); valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL); if (valueNameStr != NULL) { ! error_code = RegSetValueEx((HKEY)(uintptr_t)hKey, valueNameStr, 0, REG_SZ, dataStr, size); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); } (*env)->ReleaseByteArrayElements(env, data, dataStr, 0); return error_code;
*** 174,184 **** char* valueNameStr; int error_code = -1; if (valueName == NULL) {return -1;} valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL); CHECK_NULL_RETURN(valueNameStr, -1); ! error_code = RegDeleteValue((HKEY)hKey, valueNameStr); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); return error_code; } JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey --- 174,184 ---- char* valueNameStr; int error_code = -1; if (valueName == NULL) {return -1;} valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL); CHECK_NULL_RETURN(valueNameStr, -1); ! error_code = RegDeleteValue((HKEY)(uintptr_t)hKey, valueNameStr); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); return error_code; } JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey
*** 188,198 **** int valuesNumber = -1; int maxValueNameLength = -1; int maxSubKeyLength = -1; int subKeysNumber = -1; int errorCode = -1; ! errorCode = RegQueryInfoKey((HKEY)hKey, NULL, NULL, NULL, &subKeysNumber, &maxSubKeyLength, NULL, &valuesNumber, &maxValueNameLength, NULL, NULL, NULL); tmp[0]= subKeysNumber; tmp[1]= (int)errorCode; --- 188,198 ---- int valuesNumber = -1; int maxValueNameLength = -1; int maxSubKeyLength = -1; int subKeysNumber = -1; int errorCode = -1; ! errorCode = RegQueryInfoKey((HKEY)(uintptr_t)hKey, NULL, NULL, NULL, &subKeysNumber, &maxSubKeyLength, NULL, &valuesNumber, &maxValueNameLength, NULL, NULL, NULL); tmp[0]= subKeysNumber; tmp[1]= (int)errorCode;
*** 214,224 **** buffer = (char*)malloc(maxKeyLength); if (buffer == NULL) { JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); return NULL; } ! if (RegEnumKeyEx((HKEY) hKey, subKeyIndex, buffer, &size, NULL, NULL, NULL, NULL) != ERROR_SUCCESS){ free(buffer); return NULL; } result = (*env)->NewByteArray(env, size + 1); --- 214,224 ---- buffer = (char*)malloc(maxKeyLength); if (buffer == NULL) { JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); return NULL; } ! if (RegEnumKeyEx((HKEY)(uintptr_t) hKey, subKeyIndex, buffer, &size, NULL, NULL, NULL, NULL) != ERROR_SUCCESS){ free(buffer); return NULL; } result = (*env)->NewByteArray(env, size + 1);
*** 238,248 **** buffer = (char*)malloc(maxValueNameLength); if (buffer == NULL) { JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); return NULL; } ! error_code = RegEnumValue((HKEY) hKey, valueIndex, buffer, &size, NULL, NULL, NULL, NULL); if (error_code!= ERROR_SUCCESS){ free(buffer); return NULL; } --- 238,248 ---- buffer = (char*)malloc(maxValueNameLength); if (buffer == NULL) { JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); return NULL; } ! error_code = RegEnumValue((HKEY)(uintptr_t) hKey, valueIndex, buffer, &size, NULL, NULL, NULL, NULL); if (error_code!= ERROR_SUCCESS){ free(buffer); return NULL; }
< prev index next >