| OLD | NEW |
| (Empty) |
| 1 /* Licensed to the Apache Software Foundation (ASF) under one or more | |
| 2 * contributor license agreements. See the NOTICE file distributed with | |
| 3 * this work for additional information regarding copyright ownership. | |
| 4 * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 5 * (the "License"); you may not use this file except in compliance with | |
| 6 * the License. You may obtain a copy of the License at | |
| 7 * | |
| 8 * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 * | |
| 10 * Unless required by applicable law or agreed to in writing, software | |
| 11 * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 * See the License for the specific language governing permissions and | |
| 14 * limitations under the License. | |
| 15 */ | |
| 16 | |
| 17 /* | |
| 18 * | |
| 19 * @author Mladen Turk | |
| 20 * @version $Id: mmap.c 1442587 2013-02-05 13:49:48Z rjung $ | |
| 21 */ | |
| 22 | |
| 23 #include "tcn.h" | |
| 24 #include "apr_mmap.h" | |
| 25 | |
| 26 TCN_IMPLEMENT_CALL(jlong, Mmap, create)(TCN_STDARGS, jlong file, | |
| 27 jlong offset, jlong size, | |
| 28 jint flag, jlong pool) | |
| 29 { | |
| 30 #if APR_HAS_MMAP | |
| 31 apr_pool_t *p = J2P(pool, apr_pool_t *); | |
| 32 apr_file_t *f = J2P(file, apr_file_t *); | |
| 33 apr_mmap_t *m = NULL; | |
| 34 | |
| 35 UNREFERENCED(o); | |
| 36 TCN_THROW_IF_ERR(apr_mmap_create(&m, f, (apr_off_t)offset, | |
| 37 (apr_size_t)size, | |
| 38 (apr_uint32_t)flag, p), m); | |
| 39 | |
| 40 cleanup: | |
| 41 return P2J(m); | |
| 42 #else | |
| 43 UNREFERENCED(o); | |
| 44 tcn_ThrowAPRException(e, APR_ENOTIMPL); | |
| 45 return 0; | |
| 46 #endif | |
| 47 } | |
| 48 | |
| 49 TCN_IMPLEMENT_CALL(jlong, Mmap, dup)(TCN_STDARGS, jlong mmap, | |
| 50 jlong pool) | |
| 51 { | |
| 52 #if APR_HAS_MMAP | |
| 53 apr_pool_t *p = J2P(pool, apr_pool_t *); | |
| 54 apr_mmap_t *m = J2P(mmap, apr_mmap_t *); | |
| 55 apr_mmap_t *newm = NULL; | |
| 56 | |
| 57 UNREFERENCED(o); | |
| 58 TCN_THROW_IF_ERR(apr_mmap_dup(&newm, m, p), newm); | |
| 59 | |
| 60 cleanup: | |
| 61 return P2J(newm); | |
| 62 #else | |
| 63 UNREFERENCED(o); | |
| 64 tcn_ThrowAPRException(e, APR_ENOTIMPL); | |
| 65 return 0; | |
| 66 #endif | |
| 67 } | |
| 68 | |
| 69 TCN_IMPLEMENT_CALL(jint, Mmap, delete)(TCN_STDARGS, jlong mmap) | |
| 70 { | |
| 71 #if APR_HAS_MMAP | |
| 72 apr_mmap_t *m = J2P(mmap, apr_mmap_t *); | |
| 73 | |
| 74 UNREFERENCED_STDARGS; | |
| 75 return apr_mmap_delete(m); | |
| 76 | |
| 77 #else | |
| 78 UNREFERENCED_STDARGS; | |
| 79 UNREFERENCED(mmap); | |
| 80 return APR_ENOTIMPL; | |
| 81 #endif | |
| 82 } | |
| 83 | |
| 84 TCN_IMPLEMENT_CALL(jlong, Mmap, offset)(TCN_STDARGS, jlong mmap, | |
| 85 jlong offset) | |
| 86 { | |
| 87 #if APR_HAS_MMAP | |
| 88 apr_mmap_t *m = J2P(mmap, apr_mmap_t *); | |
| 89 void *r; | |
| 90 | |
| 91 UNREFERENCED(o); | |
| 92 TCN_THROW_IF_ERR(apr_mmap_offset(&r, m, (apr_off_t)offset), r); | |
| 93 | |
| 94 cleanup: | |
| 95 return P2J(r); | |
| 96 | |
| 97 #else | |
| 98 UNREFERENCED(o); | |
| 99 tcn_ThrowAPRException(e, APR_ENOTIMPL); | |
| 100 return 0; | |
| 101 #endif | |
| 102 } | |
| OLD | NEW |