コード例 #1
0
ファイル: GConfNativePeer.c プロジェクト: 5432935/crossbridge
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_set_string
 * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string
  (JNIEnv *env, jclass clazz __attribute__ ((unused)),
   jstring key, jstring value)
{
  const char *_key = NULL;
  const char *_value = NULL;
  GError *err = NULL;

  gboolean result = JNI_FALSE;

  /* load an UTF string from the virtual machine. */
  _key = JCL_jstring_to_cstring (env, key);
  _value = JCL_jstring_to_cstring (env, value);
  if (_key == NULL || _value == NULL)
    {
      return JNI_FALSE;
    }

  gdk_threads_enter ();
  result = gconf_client_set_string (client, _key, _value, &err);
  gdk_threads_leave ();
  if (err != NULL)
  	{
	  g_error_free (err);
      err = NULL;
      result = JNI_FALSE;
  	}
	
  JCL_free_cstring (env, key, _key);
  JCL_free_cstring (env, value, _value);

  return (jboolean) result;
}
コード例 #2
0
JNIEXPORT jboolean JNICALL
Java_java_io_VMFile_create (JNIEnv * env,
			    jclass clazz __attribute__ ((__unused__)),
			    jstring name)
{
#ifndef WITHOUT_FILESYSTEM
  const char *filename;
  int fd;
  int result;

  filename = JCL_jstring_to_cstring (env, name);
  if (filename == NULL)
    {
      return (0);
    }

  TARGET_NATIVE_FILE_OPEN_CREATE (filename, fd, result);
  if (result != TARGET_NATIVE_OK)
    {
      /* XXX ??? NYI */
      if (errno != EEXIST)
	JCL_ThrowException (env,
			    "java/io/IOException",
			    TARGET_NATIVE_LAST_ERROR_STRING ());
      JCL_free_cstring (env, name, filename);
      return (0);
    }
  TARGET_NATIVE_FILE_CLOSE (fd, result);

  JCL_free_cstring (env, name, filename);
  return (1);
#else /* not WITHOUT_FILESYSTEM */
  return (0);
#endif /* not WITHOUT_FILESYSTEM */
}
コード例 #3
0
ファイル: GConfNativePeer.c プロジェクト: 5432935/crossbridge
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_unset
 * Signature: (Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset
  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key)
{
  const char *_key = NULL;
  gboolean result = JNI_FALSE;
  GError *err = NULL;

  _key = JCL_jstring_to_cstring (env, key);
  if (_key == NULL)
    {
      return JNI_FALSE;
    }

  gdk_threads_enter ();
  result = gconf_client_unset (client, _key, &err);
  gdk_threads_leave ();
  if (err != NULL)
    {
      result = JNI_FALSE;
      g_error_free (err);
      err = NULL;
    }
    
  JCL_free_cstring (env, key, _key);

  return result;
}
コード例 #4
0
ファイル: GConfNativePeer.c プロジェクト: 5432935/crossbridge
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_gconf_client_all_nodes
 * Signature: (Ljava/lang/String;)Ljava/util/List;
 */
JNIEXPORT jobject JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1nodes
  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
{
  const char *dir = NULL;
  GError *err = NULL;
  GSList *entries = NULL;
  GSList *tmp;

  /* java.util.ArrayList */
  jobject jlist = NULL;

  dir = JCL_jstring_to_cstring (env, node);
  if (dir == NULL)
    {
      return NULL;
    }

  gdk_threads_enter ();
  entries = gconf_client_all_dirs (client, dir, &err);
  gdk_threads_leave ();
  if (err != NULL)
    {
      throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
                               err->message);
      g_error_free (err);
      err = NULL;
      JCL_free_cstring (env, node, dir);
      return NULL;
    }

  jlist = get_jlist_reference (env, jlist_class);
  if (jlist == NULL)
    {
      throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
			       "Unable to get java.util.List reference in native code\n");
      JCL_free_cstring (env, node, dir);
      g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
      g_slist_free (entries);
      return NULL;
    }

  tmp = entries;
  while (tmp != NULL)
    {
      const char *_val = tmp->data;
      _val = strrchr (_val, '/');
      ++_val;
      (*env)->CallBooleanMethod (env, jlist, jlist_add_id,
				 (*env)->NewStringUTF (env, _val));
      tmp = g_slist_next (tmp);
    }

  /* clean up things */
  JCL_free_cstring (env, node, dir);
  g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
  g_slist_free (entries);

  return jlist;
}
コード例 #5
0
ファイル: javaio.c プロジェクト: mbref/gcc-412-microblaze
jint
_javaio_open_readwrite (JNIEnv * env, jstring name)
{
#ifndef WITHOUT_FILESYSTEM
  const char *filename;
  int fd;
  int result;

  filename = JCL_jstring_to_cstring (env, name);
  if (filename == NULL)
    return (-1);

  TARGET_NATIVE_FILE_OPEN_READWRITE (filename, fd, result);
  (*env)->ReleaseStringUTFChars (env, name, filename);
  if (result != TARGET_NATIVE_OK)
    {
      if (TARGET_NATIVE_LAST_ERROR () == TARGET_NATIVE_ERROR_NO_SUCH_FILE)
	JCL_ThrowException (env,
			    "java/io/FileNotFoundException",
			    TARGET_NATIVE_LAST_ERROR_STRING ());
      else
	JCL_ThrowException (env,
			    "java/io/IOException",
			    TARGET_NATIVE_LAST_ERROR_STRING ());
    }

  JCL_free_cstring (env, name, filename);
  return (fd);
#else /* not WITHOUT_FILESYSTEM */
  return (-1);
#endif /* not WITHOUT_FILESYSTEM */
}
コード例 #6
0
ファイル: GConfNativePeer.c プロジェクト: 5432935/crossbridge
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_remove_dir
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir
  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
{
  const char *dir = NULL;

  dir = JCL_jstring_to_cstring (env, node);
  if (dir == NULL)
    return;

  gdk_threads_enter ();
  gconf_client_remove_dir (client, dir, NULL);
  gdk_threads_leave ();

  JCL_free_cstring (env, node, dir);
}
コード例 #7
0
ファイル: GConfNativePeer.c プロジェクト: 5432935/crossbridge
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_add_dir
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir
  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
{
  const char *dir = NULL;

  dir = JCL_jstring_to_cstring (env, node);
  if (dir == NULL)
    return;

  /* ignore errors */
  gdk_threads_enter ();
  gconf_client_add_dir (client, dir, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
  gdk_threads_leave ();

  JCL_free_cstring (env, node, dir);
}
コード例 #8
0
ファイル: gstreamer_io_peer.c プロジェクト: 0day-ci/gcc
JNIEXPORT jboolean JNICALL
Java_gnu_javax_sound_sampled_gstreamer_io_GstAudioFileReaderNativePeer_gstreamer_1get_1audio_1format_1file
	(JNIEnv *env, jclass clazz __attribute__ ((unused)), jobject header)
{
  /* source file */
  const char *file = NULL;
    
  /* GStreamer elements */
  GstElement *source = NULL;

  jboolean result = JNI_FALSE;
  
  /* java fields */
  jstring _file = NULL;

  _file = (*env)->GetObjectField(env, header, fileFID);
  file = JCL_jstring_to_cstring (env, _file);
  if (file == NULL)
    {
      return JNI_FALSE;
    }

  gst_init (NULL, NULL);
 
  /* create the source element, will be used to read the file */
  source = gst_element_factory_make ("filesrc", "source");
  if (source == NULL)
    {
      JCL_free_cstring (env, _file, file);
      return JNI_FALSE;
    }
  
  /* set the file name */
  g_object_set (G_OBJECT (source), "location", file, NULL);

  result = process_audio (source, env, header);

  /* free stuff */
  JCL_free_cstring (env, _file, file);
  
  return result;
}
コード例 #9
0
ファイル: GConfNativePeer.c プロジェクト: 5432935/crossbridge
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_get_string
 * Signature: (Ljava/lang/String;)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string
  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key)
{
  const char *_key = NULL;
  const char *_value = NULL;
  GError *err = NULL;
  jstring result = NULL;

  _key = JCL_jstring_to_cstring (env, key);
  if (_key == NULL)
    {
      return NULL;
    }

  gdk_threads_enter ();
  _value = gconf_client_get_string (client, _key, &err);
  gdk_threads_leave ();
  JCL_free_cstring (env, key, _key);
  if (err != NULL)
    {
      /* just in case */
      if (_value != NULL) g_free ((gpointer) _value);
      g_error_free (err);
      err = NULL;
      
      return NULL;
    }

  /* Even if Gconf reported no error it is possible that NULL was returned */
  /* and it should be prevented to create a Java string from that value. */
  if (_value != NULL)
    {
      result = (*env)->NewStringUTF (env, _value);
      g_free ((gpointer) _value);
    }

  return result;
}
コード例 #10
0
ファイル: GConfNativePeer.c プロジェクト: 5432935/crossbridge
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_dir_exists
 * Signature: (Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists
  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
{
  const char *dir = NULL;
  GError *err = NULL;
  jboolean value = JNI_FALSE;

  dir = JCL_jstring_to_cstring (env, node);
  if (dir == NULL)
    return value;

  /* on error return false */
  gdk_threads_enter ();
  value = gconf_client_dir_exists (client, dir, &err);
  gdk_threads_leave ();
  if (err != NULL)
    value = JNI_FALSE;

  JCL_free_cstring (env, node, dir);

  return value;
}