Index: trunk/indexers/mg/jni/MGPassesWrapperImpl.c
===================================================================
--- trunk/indexers/mg/jni/MGPassesWrapperImpl.c	(revision 7411)
+++ trunk/indexers/mg/jni/MGPassesWrapperImpl.c	(revision 7411)
@@ -0,0 +1,132 @@
+/*
+ *    MGPassesWrapperImpl.c
+ *    Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
+ *
+ *    This program is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program; if not, write to the Free Software
+ *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include <jni.h>
+#include <assert.h>
+#include "sysfuncs.h"
+#include "org_greenstone_mg_MGPassesWrapper.h"
+
+/* if we need to use java objects, we should initialise their field ids here*/
+JNIEXPORT void JNICALL
+Java_org_greenstone_mg_MGPassesWrapper_initIDs(JNIEnv *j_env, jclass j_cls)
+{
+  return;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_greenstone_mg_MGPassesWrapper_initCSide(JNIEnv *j_env, jobject j_obj)
+{
+  clear_variables();
+  return 1;  /* true - no errors */
+}  
+
+
+JNIEXPORT void JNICALL
+Java_org_greenstone_mg_MGPassesWrapper_addPass(JNIEnv *j_env, 
+					       jobject j_obj, 
+					       jchar j_pass_type,
+					       jchar j_pass_num)
+{
+  /* get the level as a c char */
+  const char pass_type = j_pass_type;
+  const char pass_num = j_pass_num;
+  add_pass(pass_type, pass_num);
+  
+}
+
+
+/* Set the paths */
+JNIEXPORT void JNICALL
+Java_org_greenstone_mg_MGPassesWrapper_setPaths(JNIEnv *j_env, jobject j_obj,
+					  jstring j_basepath, jstring j_filename)
+{
+  /* Get the base_path as a C string */
+  const char* basepath = (*j_env)->GetStringUTFChars(j_env, j_basepath, NULL);
+  assert(basepath != NULL);
+
+  /* Get the filename as a C string */
+  const char* filename = (*j_env)->GetStringUTFChars(j_env, j_filename, NULL);
+  assert(filename != NULL);
+  
+  set_paths(basepath, filename);
+
+  /* Release the strings */
+  (*j_env)->ReleaseStringUTFChars(j_env, j_basepath, basepath);
+  (*j_env)->ReleaseStringUTFChars(j_env, j_filename, filename);
+
+}
+
+
+JNIEXPORT void JNICALL
+Java_org_greenstone_mg_MGPassesWrapper_setInvfLevel(JNIEnv *j_env, 
+						    jobject j_obj, 
+						    jchar j_level)
+{
+  /* get the level as a c char */
+  const char level = j_level;
+  set_invf_level(level);
+  
+}
+
+/* Choose boolean AND or boolean OR queries */
+JNIEXPORT void JNICALL 
+Java_org_greenstone_mg_MGPassesWrapper_setStemOptions(JNIEnv *j_env, 
+						      jobject j_obj,
+						      jstring j_stemmer, 
+						      jint j_method)
+{
+
+  const char* stemmer = (*j_env)->GetStringUTFChars(j_env, j_stemmer, NULL);
+  assert(stemmer != NULL);
+  
+  int method = j_method;
+
+  set_stem_options(stemmer, method);
+ }
+
+JNIEXPORT jboolean JNICALL 
+Java_org_greenstone_mg_MGPassesWrapper_init(JNIEnv *j_env, 
+					    jobject j_obj) {
+
+  init_driver();
+}
+
+JNIEXPORT jboolean JNICALL 
+Java_org_greenstone_mg_MGPassesWrapper_finish(JNIEnv *j_env, 
+					    jobject j_obj) {
+  
+  finalise_driver();
+}
+
+JNIEXPORT jboolean JNICALL 
+Java_org_greenstone_mg_MGPassesWrapper_processMGDocument(JNIEnv *j_env, 
+						       jobject j_obj,
+						       jbyteArray j_doc_text) {
+  /* Get the text as a C string */
+  int length = (*j_env)->GetArrayLength(j_env, j_doc_text);
+  u_char * text_buffer = (u_char *)(*j_env)->GetByteArrayElements(j_env, j_doc_text, NULL);
+  process_document(text_buffer, length);
+  /* Release the string */
+  (*j_env)->ReleaseByteArrayElements(j_env, j_doc_text, text_buffer,0);
+
+}
+
+
+
