comparison mupdf-source/platform/java/jni/cookie.c @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Copyright (C) 2004-2021 Artifex Software, Inc.
2 //
3 // This file is part of MuPDF.
4 //
5 // MuPDF is free software: you can redistribute it and/or modify it under the
6 // terms of the GNU Affero General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or (at your option)
8 // any later version.
9 //
10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17 //
18 // Alternative licensing terms are available from the licensor.
19 // For commercial licensing, see <https://www.artifex.com/> or contact
20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21 // CA 94129, USA, for further information.
22
23 /* Cookie interface */
24
25 JNIEXPORT void JNICALL
26 FUN(Cookie_finalize)(JNIEnv *env, jobject self)
27 {
28 fz_context *ctx = get_context(env);
29 fz_cookie *cookie = from_Cookie_safe(env, self);
30 if (!ctx || !cookie) return;
31 (*env)->SetLongField(env, self, fid_Cookie_pointer, 0);
32 fz_free(ctx, cookie);
33 }
34
35 JNIEXPORT jlong JNICALL
36 FUN(Cookie_newNative)(JNIEnv *env, jobject self)
37 {
38 fz_context *ctx = get_context(env);
39 fz_cookie *cookie = NULL;
40
41 if (!ctx) return 0;
42
43 fz_try(ctx)
44 cookie = fz_malloc_struct(ctx, fz_cookie);
45 fz_catch(ctx)
46 jni_rethrow(env, ctx);
47
48 return jlong_cast(cookie);
49 }
50
51 JNIEXPORT void JNICALL
52 FUN(Cookie_abort)(JNIEnv *env, jobject self)
53 {
54 fz_context *ctx = get_context(env);
55 fz_cookie *cookie = from_Cookie(env, self);
56
57 if (!ctx || !cookie) return;
58
59 cookie->abort = 1;
60 }
61
62 JNIEXPORT jint JNICALL
63 FUN(Cookie_getProgress)(JNIEnv *env, jobject self)
64 {
65 fz_context *ctx = get_context(env);
66 fz_cookie *cookie = from_Cookie(env, self);
67
68 if (!ctx || !cookie) return 0;
69
70 return cookie->progress;
71 }
72
73 JNIEXPORT jint JNICALL
74 FUN(Cookie_getProgressMax)(JNIEnv *env, jobject self)
75 {
76 fz_context *ctx = get_context(env);
77 fz_cookie *cookie = from_Cookie(env, self);
78
79 if (!ctx || !cookie) return 0;
80
81 return cookie->progress_max;
82 }
83
84 JNIEXPORT jint JNICALL
85 FUN(Cookie_getErrors)(JNIEnv *env, jobject self)
86 {
87 fz_context *ctx = get_context(env);
88 fz_cookie *cookie = from_Cookie(env, self);
89
90 if (!ctx || !cookie) return 0;
91
92 return cookie->errors;
93 }
94
95 JNIEXPORT jboolean JNICALL
96 FUN(Cookie_getIncomplete)(JNIEnv *env, jobject self)
97 {
98 fz_context *ctx = get_context(env);
99 fz_cookie *cookie = from_Cookie(env, self);
100
101 if (!ctx || !cookie) return JNI_FALSE;
102
103 return cookie->incomplete ? JNI_TRUE : JNI_FALSE;
104 }