jdk/src/share/npt/npt.h
changeset 25144 e2bf17cee34b
parent 25143 aade36e70da0
parent 25086 f5f41ed620d5
child 25145 82fa3e8aabee
child 25200 360a141ded8f
equal deleted inserted replaced
25143:aade36e70da0 25144:e2bf17cee34b
     1 /*
       
     2  * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 /* Native Platform Toolkit */
       
    27 
       
    28 #ifndef  _NPT_H
       
    29 #define _NPT_H
       
    30 
       
    31 #define NPT_VERSION "0.0.0"
       
    32 
       
    33 #include <stdio.h>
       
    34 
       
    35 #include "jni.h"
       
    36 
       
    37 #include "npt_md.h"
       
    38 #include "utf.h"
       
    39 
       
    40 #define NPT_ERROR(s) { (void)fprintf(stderr, "NPT ERROR: %s\n", s); exit(1); }
       
    41 
       
    42 #ifdef __cplusplus
       
    43 extern "C" {
       
    44 #endif
       
    45 
       
    46 typedef struct {
       
    47 
       
    48     /* Used to save handle to our own dynamicly loaded library */
       
    49     void *libhandle;
       
    50 
       
    51     /* Copy of the options sent in at initialization */
       
    52     char *options;
       
    53 
       
    54     /* Can be used to save the UtfInst handle */
       
    55     struct UtfInst *utf;
       
    56 
       
    57     /* UTF interfaces, see utf.c */
       
    58     struct UtfInst* (JNICALL *utfInitialize)
       
    59                          (char *options);
       
    60     void     (JNICALL *utfTerminate)
       
    61                          (struct UtfInst *utf, char *options);
       
    62     int      (JNICALL *utf8ToPlatform)
       
    63                          (struct UtfInst *utf, jbyte *utf8, int len,
       
    64                           char *output, int outputMaxLen);
       
    65     int      (JNICALL *utf8FromPlatform)
       
    66                          (struct UtfInst *utf, char *str, int len,
       
    67                           jbyte *output, int outputMaxLen);
       
    68     int      (JNICALL *utf8ToUtf16)
       
    69                          (struct UtfInst *utf, jbyte *utf8, int len,
       
    70                           jchar *output, int outputMaxLen);
       
    71     int      (JNICALL *utf16ToUtf8m)
       
    72                          (struct UtfInst *utf, jchar *utf16, int len,
       
    73                           jbyte *output, int outputMaxLen);
       
    74     int      (JNICALL *utf16ToUtf8s)
       
    75                          (struct UtfInst *utf, jchar *utf16, int len,
       
    76                           jbyte *output, int outputMaxLen);
       
    77     int      (JNICALL *utf8sToUtf8mLength)
       
    78                          (struct UtfInst *utf, jbyte *string, int length);
       
    79     void     (JNICALL *utf8sToUtf8m)
       
    80                          (struct UtfInst *utf, jbyte *string, int length,
       
    81                           jbyte *newString, int newLength);
       
    82     int      (JNICALL *utf8mToUtf8sLength)
       
    83                          (struct UtfInst *utf, jbyte *string, int length);
       
    84     void     (JNICALL *utf8mToUtf8s)
       
    85                          (struct UtfInst *utf, jbyte *string, int length,
       
    86                           jbyte *newString, int newLength);
       
    87 
       
    88 } NptEnv;
       
    89 
       
    90 /* Typedefs for the only 2 'extern' functions in npt library:
       
    91  *    nptInitialize and nptTerminate
       
    92  *    See NPT_INITIALIZE() and NPT_TERMINATE() in npt_md.h.
       
    93  */
       
    94 
       
    95 JNIEXPORT void JNICALL nptInitialize
       
    96                        (NptEnv **pnpt, char *nptVersion, char *options);
       
    97 typedef void (JNICALL *NptInitialize)
       
    98              (NptEnv **pnpt, char *nptVersion, char *options);
       
    99 
       
   100 JNIEXPORT void JNICALL nptTerminate
       
   101                        (NptEnv* npt, char *options);
       
   102 typedef void (JNICALL *NptTerminate)
       
   103              (NptEnv* npt, char *options);
       
   104 
       
   105 #ifdef __cplusplus
       
   106 } /* extern "C" */
       
   107 #endif /* __cplusplus */
       
   108 
       
   109 #endif