JNIEXPORT jint JNICALL Java_com_toolkits_libsvgandroid_SvgRaster_svgAndroidParseChunk (JNIEnv *env, jclass jc, jlong _svg_android_r, jstring _bfr) { svg_android_t *svg_android = (svg_android_t *)_svg_android_r; const char *buf = (*env)->GetStringUTFChars(env, _bfr, JNI_FALSE); svg_android_status_t status = svg_parse_chunk (svg_android->svg, buf, strlen(buf)); (*env)->ReleaseStringUTFChars(env, _bfr, buf); return status; }
svg_status_t svg_parse_buffer (svg_t *svg, const char *buf, size_t count) { svg_status_t status; status = svg_parse_chunk_begin (svg); if (status) return status; status = svg_parse_chunk (svg, buf, count); if (status) return status; status = svg_parse_chunk_end (svg); return status; }
svg_status_t svg_parse_file (svg_t *svg, FILE *file) { svg_status_t status = SVG_STATUS_SUCCESS; gzFile zfile; char buf[SVG_PARSE_BUFFER_SIZE]; int read; zfile = gzdopen (dup(fileno(file)), "r"); if (zfile == NULL) { switch (errno) { case ENOMEM: return SVG_STATUS_NO_MEMORY; case ENOENT: return SVG_STATUS_FILE_NOT_FOUND; default: return SVG_STATUS_IO_ERROR; } } status = svg_parse_chunk_begin (svg); if (status) goto CLEANUP; while (! gzeof (zfile)) { read = gzread (zfile, buf, SVG_PARSE_BUFFER_SIZE); if (read > -1) { status = svg_parse_chunk (svg, buf, read); if (status) goto CLEANUP; } else { status = SVG_STATUS_IO_ERROR; goto CLEANUP; } } status = svg_parse_chunk_end (svg); CLEANUP: gzclose (zfile); return status; }