/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1998,2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file contains native methods for the Java SLP implementation.
* So far this is just the syslog function.
*
* The file also contains two support functions, one for throwing exceptions
* given a class name, and one for correctly converting unicode Strings to C
* byte arrays.
*/
#include <malloc.h>
#include <jni.h>
#include <syslog.h>
/*
* Given a class name of an exception and a message attempt to throw
* a new instance of the exception.
*/
static void
{
/*
* If class is NULL FindClass() encountered a problem locating the
* desired class and has already called ThrowNew() with an
* exception.
*/
return;
}
}
/*
* Convert a Java String into a native set of characters using the
* method String.getBytes(). This will ensure that the appropriate
* character set encoding will be used. This is necessary if the
* Java String uses unicode characters that cannot be easily
* encoded into native chars.
*
* The buffer returned must be released by using free() once it is
* finished with.
*
* This function returns NULL if an exception has been thrown during its
* execution.
*/
static char
{
/*
* Need a local reference for (1) FindClass(), (2) the bytes and
* (3) the FindClass() in ThrowByName() if all goes wrong.
*/
env,
NULL);
return (NULL);
}
/*
* If class is NULL FindClass() encountered a problem locating the
* desired class and has already called ThrowNew() with an
* exception.
*/
return (NULL);
}
env,
/*
* If method is NULL GetMethodID() encountered a problem
* locating the desired method and has already called
* ThrowNew() with an exception.
*/
/*
* Call String.getBytes(), creating our temporary
* byte array
*/
/* See if CallObjectMethod() threw an exception */
/*
* Allocate a buffer for the native characters,
* need an extra char for string terminator.
* Note: calloc will provide the terminating
* '\0' for us.
*/
/*
* If allocation failed assume we are out of
* memory
*/
env,
NULL);
} else {
/*
* Copy the encoded bytes into the
* native string buffer
*/
(*env)->GetByteArrayRegion(
env,
0,
len,
}
}
}
}
/* Clean up by deleting the local references */
return (result);
}
/*
* Class: com_sun_slp_Syslog
* Method: syslog
*/
/* ARGSUSED */
/*
* Check to see if the String conversion was successful,
* if it wasn't an exception will have already been thrown.
*/
closelog();
}
}