本文整理汇总了C++中JNU_ReleaseStringPlatformChars函数的典型用法代码示例。如果您正苦于以下问题:C++ JNU_ReleaseStringPlatformChars函数的具体用法?C++ JNU_ReleaseStringPlatformChars怎么用?C++ JNU_ReleaseStringPlatformChars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JNU_ReleaseStringPlatformChars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Java_sun_tools_attach_BsdVirtualMachine_createAttachFile
/*
* Class: sun_tools_attach_BSDVirtualMachine
* Method: createAttachFile
* Signature: (Ljava.lang.String;)V
*/
JNIEXPORT void JNICALL Java_sun_tools_attach_BsdVirtualMachine_createAttachFile(JNIEnv *env, jclass cls, jstring path)
{
const char* _path;
jboolean isCopy;
int fd, rc;
_path = GetStringPlatformChars(env, path, &isCopy);
if (_path == NULL) {
JNU_ThrowIOException(env, "Must specify a path");
return;
}
RESTARTABLE(open(_path, O_CREAT | O_EXCL, S_IWUSR | S_IRUSR), fd);
if (fd == -1) {
/* release p here before we throw an I/O exception */
if (isCopy) {
JNU_ReleaseStringPlatformChars(env, path, _path);
}
JNU_ThrowIOExceptionWithLastError(env, "open");
return;
}
RESTARTABLE(chown(_path, geteuid(), getegid()), rc);
RESTARTABLE(close(fd), rc);
/* release p here */
if (isCopy) {
JNU_ReleaseStringPlatformChars(env, path, _path);
}
}
示例2: Java_sun_print_Win32PrintService_getCopiesSupported
JNIEXPORT jint JNICALL
Java_sun_print_Win32PrintService_getCopiesSupported(JNIEnv *env,
jobject peer,
jstring printer,
jstring port)
{
LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
if (printerName == NULL || printerPort == NULL) {
if (printerName != NULL) {
JNU_ReleaseStringPlatformChars(env, printer, printerName);
}
if (printerPort != NULL) {
JNU_ReleaseStringPlatformChars(env, port, printerPort);
}
return 1;
}
SAVE_CONTROLWORD
int numCopies = ::DeviceCapabilities(printerName, printerPort,
DC_COPIES, NULL, NULL);
RESTORE_CONTROLWORD
if (numCopies == -1)
return 1; // default
JNU_ReleaseStringPlatformChars(env, printer, printerName);
JNU_ReleaseStringPlatformChars(env, port, printerPort);
return numCopies;
}
示例3: Java_sun_print_Win32PrintService_getAllResolutions
/*
PostScript Drivers return wrong support info for the following code:
DWORD dmFields = (::DeviceCapabilities(printerName,
NULL, DC_FIELDS, NULL, NULL)) ;
if ((dmFields & DM_YRESOLUTION) )
isSupported = true;
Returns not supported even if it supports resolution. Therefore, we use the
function _getAllResolutions.
*/
JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getAllResolutions(JNIEnv *env,
jobject peer,
jstring printer,
jstring port)
{
LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
if (printerName == NULL || printerPort == NULL) {
if (printerName != NULL) {
JNU_ReleaseStringPlatformChars(env, printer, printerName);
}
if (printerPort != NULL) {
JNU_ReleaseStringPlatformChars(env, port, printerPort);
}
return NULL;
}
SAVE_CONTROLWORD
int nResolutions = ::DeviceCapabilities(printerName, printerPort,
DC_ENUMRESOLUTIONS, NULL, NULL);
RESTORE_CONTROLWORD
jintArray resolutionArray = NULL;
if (nResolutions > 0) {
resolutionArray = env->NewIntArray(nResolutions*2);
if (resolutionArray != NULL) {
jint *jpcIndices = env->GetIntArrayElements(resolutionArray, NULL);
if (jpcIndices != NULL) {
jint *saveFormats = jpcIndices;
LPTSTR resBuf = NULL;
try {
resBuf = (LPTSTR)new char[nResolutions * sizeof(LONG) * 2];
} catch (std::bad_alloc&) {
resBuf = NULL;
}
if (resBuf != NULL) {
if (::DeviceCapabilities(printerName, printerPort,
DC_ENUMRESOLUTIONS, resBuf,
NULL) != -1) {
LONG *pResolution = (LONG *)resBuf;
for (int i = 0; i < nResolutions; i++) {
jpcIndices[i*2] = *pResolution++;
jpcIndices[i*2+1] = *pResolution++;
}
}
RESTORE_CONTROLWORD
delete[] resBuf;
}
env->ReleaseIntArrayElements(resolutionArray, saveFormats, 0);
}
}
}
JNU_ReleaseStringPlatformChars(env, printer, printerName);
JNU_ReleaseStringPlatformChars(env, printer, printerPort);
return resolutionArray;
}
示例4: getIDs
jintArray getIDs(JNIEnv *env, jstring printer, jstring port, int dm_id)
{
LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
if (printerName == NULL || printerPort == NULL) {
if (printerName != NULL) {
JNU_ReleaseStringPlatformChars(env, printer, printerName);
}
if (printerPort != NULL) {
JNU_ReleaseStringPlatformChars(env, port, printerPort);
}
return NULL;
}
SAVE_CONTROLWORD
int numIDs = ::DeviceCapabilities(printerName, printerPort, dm_id,
NULL, NULL);
RESTORE_CONTROLWORD
jintArray idArray = NULL;
if (numIDs > 0) {
idArray = env->NewIntArray(numIDs);
if (idArray != NULL) {
jint *jpcIndices = env->GetIntArrayElements(idArray, NULL);
if (jpcIndices != NULL) {
jint *saveFormats = jpcIndices;
LPTSTR buf = NULL;
try {
buf = (LPTSTR)new char[numIDs * sizeof(WORD)];
} catch (std::bad_alloc&) {
buf = NULL;
}
if (buf != NULL) {
if (::DeviceCapabilities(printerName, printerPort,
dm_id, buf, NULL) != -1) {
WORD *id = (WORD *)buf;
for (int i = 0; i < numIDs; i++, id++) {
jpcIndices[i] = *id;
}
}
RESTORE_CONTROLWORD
delete[] buf;
}
env->ReleaseIntArrayElements(idArray, saveFormats, 0);
}
}
}
JNU_ReleaseStringPlatformChars(env, printer, printerName);
JNU_ReleaseStringPlatformChars(env, port, printerPort);
return idArray;
}
示例5: Java_sun_print_Win32PrintService_getAllMediaSizes
JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getAllMediaSizes(JNIEnv *env,
jobject peer,
jstring printer,
jstring port)
{
TRY;
LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
printer, NULL);
LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
jintArray mediaArray = NULL;
SAVE_CONTROLWORD
int nPapers = ::DeviceCapabilities(printerName, printerPort,
DC_PAPERSIZE, NULL, NULL) ;
RESTORE_CONTROLWORD
if (nPapers > 0) {
mediaArray = env->NewIntArray(nPapers*2);
if (mediaArray == NULL) {
throw std::bad_alloc();
}
jboolean isCopy;
jint *jpcIndices = env->GetIntArrayElements(mediaArray,
&isCopy), *saveFormats = jpcIndices;
LPTSTR buf = (LPTSTR)new char[nPapers * sizeof(POINT)]; // array of POINTs
if (::DeviceCapabilities(printerName, printerPort,
DC_PAPERSIZE, buf, NULL) != -1) {
POINT *pDim = (POINT *)buf;
for (int i = 0; i < nPapers; i++) {
jpcIndices[i*2] = (pDim+i)->x;
jpcIndices[i*2+1] = (pDim+i)->y;
}
}
RESTORE_CONTROLWORD
delete[] buf;
env->ReleaseIntArrayElements(mediaArray, saveFormats, 0);
}
JNU_ReleaseStringPlatformChars(env, printer, printerName);
JNU_ReleaseStringPlatformChars(env, port, printerPort);
return mediaArray;
CATCH_BAD_ALLOC_RET(NULL);
}
示例6: Java_sun_print_Win32PrintService_getAllMediaTrays
JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getAllMediaTrays(JNIEnv *env,
jobject peer,
jstring printer,
jstring port)
{
TRY;
LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
printer, NULL);
LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
jintArray mediaTrayArray = NULL;
SAVE_CONTROLWORD
int nBins = ::DeviceCapabilities(printerName, printerPort,
DC_BINS, NULL, NULL) ;
RESTORE_CONTROLWORD
if (nBins > 0) {
mediaTrayArray = env->NewIntArray(nBins);
if (mediaTrayArray == NULL) {
throw std::bad_alloc();
}
jboolean isCopy;
jint *jpcIndices = env->GetIntArrayElements(mediaTrayArray,
&isCopy), *saveFormats = jpcIndices;
LPTSTR buf = (LPTSTR)new char[nBins * sizeof(WORD)];
if (::DeviceCapabilities(printerName, printerPort,
DC_BINS, buf, NULL) != -1) {
RESTORE_CONTROLWORD
WORD *pBins = (WORD *)buf;
for (int i = 0; i < nBins; i++) {
jpcIndices[i] = *(pBins+i);
}
}
delete[] buf;
env->ReleaseIntArrayElements(mediaTrayArray, saveFormats, 0);
}
JNU_ReleaseStringPlatformChars(env, printer, printerName);
JNU_ReleaseStringPlatformChars(env, port, printerPort);
return mediaTrayArray;
CATCH_BAD_ALLOC_RET(NULL);
}
示例7: GetStringPlatformChars
/*
* Class: sun_tools_attach_VirtualMachineImpl
* Method: open
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_open
(JNIEnv *env, jclass cls, jstring path)
{
jboolean isCopy;
const char* p = GetStringPlatformChars(env, path, &isCopy);
if (p == NULL) {
return 0;
} else {
int fd;
int err = 0;
fd = open(p, O_RDWR);
if (fd == -1) {
err = errno;
}
if (isCopy) {
JNU_ReleaseStringPlatformChars(env, path, p);
}
if (fd == -1) {
if (err == ENOENT) {
JNU_ThrowByName(env, "java/io/FileNotFoundException", NULL);
} else {
char* msg = strdup(strerror(err));
JNU_ThrowIOException(env, msg);
if (msg != NULL) {
free(msg);
}
}
}
return fd;
}
}
示例8: JNI_CHECK_PEER_GOTO
void AwtList::_AddItems(void *param)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
AddItemsStruct *ais = (AddItemsStruct *)param;
jobject self = ais->list;
jobjectArray items = ais->items;
jint index = ais->index;
jint width = ais->width;
int badAlloc = 0;
AwtList *l = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
JNI_CHECK_NULL_GOTO(items, "null items", ret);
l = (AwtList*)pData;
if (::IsWindow(l->GetHWnd()))
{
int itemCount = env->GetArrayLength(items);
if (itemCount > 0)
{
AwtList* l = (AwtList*)pData;
l->SendListMessage(WM_SETREDRAW, (WPARAM)FALSE, 0);
for (jsize i=0; i < itemCount; i++)
{
LPTSTR itemPtr = NULL;
jstring item = (jstring)env->GetObjectArrayElement(items, i);
if (env->ExceptionCheck()) goto ret;
if (item == NULL) goto next_item;
itemPtr = (LPTSTR)JNU_GetStringPlatformChars(env, item, 0);
if (itemPtr == NULL)
{
badAlloc = 1;
}
else
{
l->InsertString(index+i, itemPtr);
JNU_ReleaseStringPlatformChars(env, item, itemPtr);
}
env->DeleteLocalRef(item);
next_item:
;
}
l->SendListMessage(WM_SETREDRAW, (WPARAM)TRUE, 0);
l->InvalidateList(NULL, TRUE);
l->CheckMaxWidth(width);
}
}
ret:
env->DeleteGlobalRef(self);
env->DeleteGlobalRef(items);
delete ais;
if (badAlloc)
{
throw std::bad_alloc();
}
}
示例9: GetMenuContainer
void AwtPopupMenu::Enable(BOOL isEnabled)
{
AwtMenu *menu = GetMenuContainer();
if (menu != NULL) {
AwtMenu::Enable(isEnabled);
return;
}
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (env->EnsureLocalCapacity(1) < 0) {
return;
}
jobject target = GetTarget(env);
int nCount = CountItem(target);
for (int i = 0; i < nCount; ++i) {
AwtMenuItem *item = GetItem(target,i);
jobject jitem = item->GetTarget(env);
BOOL bItemEnabled = isEnabled && (jboolean)env->GetBooleanField(jitem,
AwtMenuItem::enabledID);
jstring labelStr = static_cast<jstring>(env->GetObjectField(jitem, AwtMenuItem::labelID));
LPCWSTR labelStrW = JNU_GetStringPlatformChars(env, labelStr, NULL);
if (labelStrW && wcscmp(labelStrW, L"-") != 0) {
item->Enable(bItemEnabled);
}
JNU_ReleaseStringPlatformChars(env, labelStr, labelStrW);
env->DeleteLocalRef(labelStr);
env->DeleteLocalRef(jitem);
}
env->DeleteLocalRef(target);
}
示例10: Java_sun_print_Win32PrintServiceLookup_notifyFirstPrinterChange
JNIEXPORT jlong JNICALL
Java_sun_print_Win32PrintServiceLookup_notifyFirstPrinterChange(JNIEnv *env,
jobject peer,
jstring printer) {
HANDLE hPrinter;
LPTSTR printerName = NULL;
if (printer != NULL) {
printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
printer,
NULL);
JNU_ReleaseStringPlatformChars(env, printer, printerName);
}
// printerName - "Win NT/2K/XP: If NULL, it indicates the local printer
// server" - MSDN. Win9x : OpenPrinter returns 0.
BOOL ret = OpenPrinter(printerName, &hPrinter, NULL);
if (!ret) {
return (jlong)-1;
}
// PRINTER_CHANGE_PRINTER = PRINTER_CHANGE_ADD_PRINTER |
// PRINTER_CHANGE_SET_PRINTER |
// PRINTER_CHANGE_DELETE_PRINTER |
// PRINTER_CHANGE_FAILED_CONNECTION_PRINTER
HANDLE chgObj = FindFirstPrinterChangeNotification(hPrinter,
PRINTER_CHANGE_PRINTER,
0,
NULL);
return (chgObj == INVALID_HANDLE_VALUE) ? (jlong)-1 : (jlong)chgObj;
}
示例11: Java_sun_nio_ch_InheritedChannel_open0
JNIEXPORT jint JNICALL
Java_sun_nio_ch_InheritedChannel_open0(JNIEnv *env, jclass cla, jstring path, jint oflag)
{
const char* str;
int oflag_actual;
/* convert to OS specific value */
switch (oflag) {
case sun_nio_ch_InheritedChannel_O_RDWR :
oflag_actual = O_RDWR;
break;
case sun_nio_ch_InheritedChannel_O_RDONLY :
oflag_actual = O_RDONLY;
break;
case sun_nio_ch_InheritedChannel_O_WRONLY :
oflag_actual = O_WRONLY;
break;
default :
JNU_ThrowInternalError(env, "Unrecognized file mode");
return -1;
}
str = JNU_GetStringPlatformChars(env, path, NULL);
if (str == NULL) {
return (jint)-1;
} else {
int fd = open(str, oflag_actual);
if (fd < 0) {
JNU_ThrowIOExceptionWithLastError(env, str);
}
JNU_ReleaseStringPlatformChars(env, path, str);
return (jint)fd;
}
}
示例12: GetStringPlatformChars
/*
* Class: sun_tools_attach_VirtualMachineImpl
* Method: checkPermissions
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
(JNIEnv *env, jclass cls, jstring path)
{
jboolean isCopy;
const char* p = GetStringPlatformChars(env, path, &isCopy);
if (p != NULL) {
struct stat64 sb;
uid_t uid, gid;
int res;
/*
* Check that the path is owned by the effective uid/gid of this
* process. Also check that group/other access is not allowed.
*/
uid = geteuid();
gid = getegid();
res = stat64(p, &sb);
if (res != 0) {
/* save errno */
res = errno;
}
if (res == 0) {
char msg[100];
jboolean isError = JNI_FALSE;
if (sb.st_uid != uid) {
jio_snprintf(msg, sizeof(msg)-1,
"file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
isError = JNI_TRUE;
} else if (sb.st_gid != gid) {
jio_snprintf(msg, sizeof(msg)-1,
"file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
isError = JNI_TRUE;
} else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
jio_snprintf(msg, sizeof(msg)-1,
"file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
isError = JNI_TRUE;
}
if (isError) {
char buf[256];
jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
JNU_ThrowIOException(env, buf);
}
} else {
char* msg = strdup(strerror(res));
JNU_ThrowIOException(env, msg);
if (msg != NULL) {
free(msg);
}
}
if (isCopy) {
JNU_ReleaseStringPlatformChars(env, path, p);
}
}
}
示例13: JNI_CHECK_PEER_GOTO
void AwtCheckbox::_SetLabel(void *param)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
SetLabelStruct *sls = (SetLabelStruct *)param;
jobject checkbox = sls->checkbox;
jstring label = sls->label;
int badAlloc = 0;
AwtCheckbox *c = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(checkbox, done);
c = (AwtCheckbox *)pData;
if (::IsWindow(c->GetHWnd()))
{
LPCTSTR labelStr = NULL;
// By convension null label means empty string
if (label == NULL)
{
labelStr = TEXT("");
}
else
{
labelStr = JNU_GetStringPlatformChars(env, label, JNI_FALSE);
}
if (labelStr == NULL)
{
badAlloc = 1;
}
else
{
c->SetText(labelStr);
c->VerifyState();
if (label != NULL) {
JNU_ReleaseStringPlatformChars(env, label, labelStr);
}
}
}
done:
env->DeleteGlobalRef(checkbox);
if (label != NULL)
{
env->DeleteGlobalRef(label);
}
delete sls;
if (badAlloc) {
throw std::bad_alloc();
}
}
示例14: Java_sun_awt_DebugHelperImpl_printlnImpl
/* Implementation of DebugHelperImpl.printlnImpl */
JNIEXPORT void JNICALL
Java_sun_awt_DebugHelperImpl_printlnImpl(JNIEnv *env, jclass cls, jstring msg) {
const char * cstr;
cstr = JNU_GetStringPlatformChars(env, msg, NULL);
if ( cstr == NULL ) {
return;
}
DTrace_JavaPrintln(cstr);
JNU_ReleaseStringPlatformChars(env, msg, cstr);
}
示例15: Java_java_util_prefs_FileSystemPreferences_chmod
JNIEXPORT jint JNICALL
Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env,
jclass thisclass, jstring java_fname, jint permission) {
const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE);
int result;
result = chmod(fname, permission);
if (result != 0)
result = errno;
JNU_ReleaseStringPlatformChars(env, java_fname, fname);
return (jint) result;
}