Commit ad4b436c authored by Claes Sjofors's avatar Claes Sjofors

Web crossref list, size max limit added

parent 46ad1fef
...@@ -68,6 +68,12 @@ typedef struct { ...@@ -68,6 +68,12 @@ typedef struct {
pwr_tRefId refid; pwr_tRefId refid;
} sJid; } sJid;
typedef struct {
char buf[4000];
int len;
int truncated;
} gdh_sCrrCtx;
#if ( defined OS_POSIX) && defined HW_X86_64 #if ( defined OS_POSIX) && defined HW_X86_64
static tree_sTable *jid_table = 0; static tree_sTable *jid_table = 0;
static int jid_next = 1; static int jid_next = 1;
...@@ -2365,27 +2371,42 @@ static void gdh_crr_insert_cb( void *ctx, void *parent_node, ...@@ -2365,27 +2371,42 @@ static void gdh_crr_insert_cb( void *ctx, void *parent_node,
navc_eItemType item_type, navc_eItemType item_type,
char *text1, char *text2, int write) char *text1, char *text2, int write)
{ {
char *buf = (char *)ctx; gdh_sCrrCtx *crrctx = (gdh_sCrrCtx *)ctx;
if ( crrctx->truncated)
return;
if ( crrctx->len > sizeof(crrctx->buf) - 260) {
strcat( crrctx->buf, "\n0 ** List truncated **\n");
crrctx->truncated = 1;
return;
}
switch( item_type) { switch( item_type) {
case navc_eItemType_Crossref: case navc_eItemType_Crossref:
if ( strcmp( buf, "") != 0) if ( strcmp( crrctx->buf, "") != 0) {
strcat( buf, "\n"); strcat( crrctx->buf, "\n");
crrctx->len++;x
}
switch ( write) { switch ( write) {
case 0: case 0:
strcat( buf, "0"); strcat( crrctx->buf, "0");
crrctx->len++;
break; break;
case 1: case 1:
strcat( buf, "1"); strcat( crrctx->buf, "1");
crrctx->len++;
break; break;
case 2: case 2:
strcat( buf, "2"); strcat( crrctx->buf, "2");
crrctx->len++;
break; break;
} }
// printf( "Insert %s %s\n", text1, text2); // printf( "Insert %s %s\n", text1, text2);
strcat( buf, text1); strcat( crrctx->buf, text1);
strcat( buf, " "); strcat( crrctx->buf, " ");
strcat( buf, text2); strcat( crrctx->buf, text2);
crrctx->len += strlen(text1) + 2 + strlen(text2);
// new ItemCrossref( brow, text1, text2, // new ItemCrossref( brow, text1, text2,
// write, parent_node, flow_eDest_IntoLast); // write, parent_node, flow_eDest_IntoLast);
break; break;
...@@ -2427,7 +2448,7 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrObject ...@@ -2427,7 +2448,7 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrObject
jobject return_obj; jobject return_obj;
jint jsts; jint jsts;
jstring jbuf = NULL; jstring jbuf = NULL;
char *buf; gdh_sCrrCtx *crrctx;
jclass cdhrString_id; jclass cdhrString_id;
static jmethodID cdhrString_cid = NULL; static jmethodID cdhrString_cid = NULL;
...@@ -2439,20 +2460,20 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrObject ...@@ -2439,20 +2460,20 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrObject
//printf("cdhrString_cid initierad\n"); //printf("cdhrString_cid initierad\n");
} }
buf = (char *)calloc( 1, 2000); crrctx = (gdh_sCrrCtx *)calloc( 1, sizeof(gdh_sCrrCtx));
str = (*env)->GetStringUTFChars( env, name, 0); str = (*env)->GetStringUTFChars( env, name, 0);
cstr = (char *)str; cstr = (char *)str;
gdh_ConvertUTFstring( cstr, cstr); gdh_ConvertUTFstring( cstr, cstr);
// printf( "crrObject name: %s %s\n", str, cstr); // printf( "crrObject name: %s %s\n", str, cstr);
sts = crr_object( buf, cstr, gdh_crr_insert_cb, gdh_crr_name_to_objid_cb, sts = crr_object( crrctx, cstr, gdh_crr_insert_cb, gdh_crr_name_to_objid_cb,
gdh_crr_get_volume_cb); gdh_crr_get_volume_cb);
(*env)->ReleaseStringUTFChars( env, name, cstr); (*env)->ReleaseStringUTFChars( env, name, cstr);
if ( ODD(sts)) if ( ODD(sts))
jbuf = (*env)->NewStringUTF( env, buf); jbuf = (*env)->NewStringUTF( env, crrctx->buf);
free( buf); free( crrctx);
jsts = (jint) sts; jsts = (jint) sts;
return_obj = (*env)->NewObject( env, cdhrString_id, return_obj = (*env)->NewObject( env, cdhrString_id,
...@@ -2469,7 +2490,7 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrSignal ...@@ -2469,7 +2490,7 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrSignal
jobject return_obj; jobject return_obj;
jint jsts; jint jsts;
jstring jbuf = NULL; jstring jbuf = NULL;
char *buf; gdh_sCrrCtx *crrctx;
jclass cdhrString_id; jclass cdhrString_id;
static jmethodID cdhrString_cid = NULL; static jmethodID cdhrString_cid = NULL;
...@@ -2481,20 +2502,20 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrSignal ...@@ -2481,20 +2502,20 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrSignal
//printf("cdhrString_cid initierad\n"); //printf("cdhrString_cid initierad\n");
} }
buf = (char *)calloc( 1, 2000); crrctx = (gdh_sCrrCtx *)calloc( 1, sizeof(gdh_sCrrCtx));
str = (*env)->GetStringUTFChars( env, name, 0); str = (*env)->GetStringUTFChars( env, name, 0);
cstr = (char *)str; cstr = (char *)str;
gdh_ConvertUTFstring( cstr, cstr); gdh_ConvertUTFstring( cstr, cstr);
// printf( "crrObject name: %s %s\n", str, cstr); // printf( "crrObject name: %s %s\n", str, cstr);
sts = crr_signal( buf, cstr, gdh_crr_insert_cb, gdh_crr_name_to_objid_cb, sts = crr_signal( crrctx, cstr, gdh_crr_insert_cb, gdh_crr_name_to_objid_cb,
gdh_crr_get_volume_cb); gdh_crr_get_volume_cb);
(*env)->ReleaseStringUTFChars( env, name, cstr); (*env)->ReleaseStringUTFChars( env, name, cstr);
if ( ODD(sts)) if ( ODD(sts))
jbuf = (*env)->NewStringUTF( env, buf); jbuf = (*env)->NewStringUTF( env, crrctx->buf);
free( buf); free( crrctx);
jsts = (jint) sts; jsts = (jint) sts;
return_obj = (*env)->NewObject( env, cdhrString_id, return_obj = (*env)->NewObject( env, cdhrString_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment