source: trunk/indexers/mg/jni/MGPassesWrapperImpl.c@ 7452

Last change on this file since 7452 was 7452, checked in by kjdon, 20 years ago

tidied up the setting filename and basepath path stuff

  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/*
2 * MGPassesWrapperImpl.c
3 * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20
21#include <jni.h>
22#include <assert.h>
23#include "sysfuncs.h"
24#include "org_greenstone_mg_MGPassesWrapper.h"
25
26/* if we need to use java objects, we should initialise their field ids here*/
27JNIEXPORT void JNICALL
28Java_org_greenstone_mg_MGPassesWrapper_initIDs(JNIEnv *j_env, jclass j_cls)
29{
30 return;
31}
32
33JNIEXPORT jboolean JNICALL
34Java_org_greenstone_mg_MGPassesWrapper_initCSide(JNIEnv *j_env, jobject j_obj)
35{
36 clear_variables();
37 return 1; /* true - no errors */
38}
39
40
41JNIEXPORT void JNICALL
42Java_org_greenstone_mg_MGPassesWrapper_addPass(JNIEnv *j_env,
43 jobject j_obj,
44 jchar j_pass_type,
45 jchar j_pass_num)
46{
47 /* get the level as a c char */
48 const char pass_type = j_pass_type;
49 const char pass_num = j_pass_num;
50 add_pass(pass_type, pass_num);
51
52}
53
54/* Set the filename */
55JNIEXPORT void JNICALL
56Java_org_greenstone_mg_MGPassesWrapper_setFileName(JNIEnv *j_env, jobject j_obj,
57 jstring j_filename)
58{
59 /* Get the filename as a C string */
60 const char* filename = (*j_env)->GetStringUTFChars(j_env, j_filename, NULL);
61
62 assert(filename != NULL);
63 set_filename(filename);
64
65 /* Release the string */
66 (*j_env)->ReleaseStringUTFChars(j_env, j_filename, filename);
67
68}
69
70/* Set the base path */
71JNIEXPORT void JNICALL
72Java_org_greenstone_mg_MGPassesWrapper_setBasePath(JNIEnv *j_env,
73 jobject j_obj,
74 jstring j_basepath)
75{
76 /* Get the base_path as a C string */
77 const char* basepath = (*j_env)->GetStringUTFChars(j_env, j_basepath, NULL);
78 assert(basepath != NULL);
79
80 set_basepath(basepath);
81
82
83 /* Release the string */
84 (*j_env)->ReleaseStringUTFChars(j_env, j_basepath, basepath);
85
86}
87
88
89JNIEXPORT void JNICALL
90Java_org_greenstone_mg_MGPassesWrapper_setInvfLevel(JNIEnv *j_env,
91 jobject j_obj,
92 jchar j_level)
93{
94 /* get the level as a c char */
95 const char level = j_level;
96 set_invf_level(level);
97
98}
99
100/* */
101JNIEXPORT void JNICALL
102Java_org_greenstone_mg_MGPassesWrapper_setStemOptions(JNIEnv *j_env,
103 jobject j_obj,
104 jstring j_stemmer,
105 jint j_method)
106{
107
108 const char* stemmer = (*j_env)->GetStringUTFChars(j_env, j_stemmer, NULL);
109 int method = j_method;
110
111 assert(stemmer != NULL);
112 set_stem_options(stemmer, method);
113 }
114
115JNIEXPORT jboolean JNICALL
116Java_org_greenstone_mg_MGPassesWrapper_init(JNIEnv *j_env,
117 jobject j_obj) {
118
119 init_driver();
120 return 1;
121}
122
123JNIEXPORT jboolean JNICALL
124Java_org_greenstone_mg_MGPassesWrapper_finish(JNIEnv *j_env,
125 jobject j_obj) {
126
127 finalise_driver();
128 return 1;
129}
130
131JNIEXPORT jboolean JNICALL
132Java_org_greenstone_mg_MGPassesWrapper_processMGDocument(JNIEnv *j_env,
133 jobject j_obj,
134 jbyteArray j_doc_text) {
135 /* Get the text as a C string */
136 int length = (*j_env)->GetArrayLength(j_env, j_doc_text);
137 u_char * text_buffer = (u_char *)(*j_env)->GetByteArrayElements(j_env, j_doc_text, NULL);
138 process_document(text_buffer, length);
139 /* Release the string */
140 (*j_env)->ReleaseByteArrayElements(j_env, j_doc_text, text_buffer,0);
141 return 1;
142}
143
144
145
Note: See TracBrowser for help on using the repository browser.