Commit 346c02a0 authored by 周尚's avatar 周尚

init

parents
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/libjsonpay.iml" filepath="$PROJECT_DIR$/libjsonpay.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK
include_directories(src/main/include)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/jni/native-lib.cpp
src/main/jni/bcccode.c
src/main/jni/bccmd5.c
src/main/jni/cJSON.c
src/main/jni/do_log.c
src/main/jni/do_trans.c
src/main/jni/do_trans_pax.c
src/main/jni/http.c
)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib} )
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
defaultConfig {
ndk {
moduleName "jsonpay"
}
applicationId "com.xingdata.zxpay"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.xingdata.zxpay;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.xingdata.zxpay", appContext.getPackageName());
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xingdata.zxpay">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" />
</manifest>
insprint:
| 字段名称 | 字段Key | 格式 | 必填 | 备注 |
|------------------+-------------------+--------------+------+----------------------------------------------------------- |
| 商户交易类型 | OrderType | String(1,40) | Y | 01 普通消费 02 查询交易 03 撤销交易 04 退货交易 05 异步通知 |
| 用户所选渠道类型 | PayChannelType | String(2) | Y | "1 现金 2 微信 3 支付宝 4 银行卡 5 银联二维码 8 会员卡 |
| 设备类型 | DeviceType | String(4) | Y | "01 刷卡支付 :通过扫描枪扫用户的二维码或者一维码 |
| | | | | 02 扫码支付 :用户扫描商户展示在各种场景的二维码进行支付 |
| | | | | 03 公众号支付:用户扫描商户展示在各种场景的二维码进行支付 |
| 商户号 | Mch_id | String(15) | Y | 终端上送 |
| 终端号 | Ter_id | String(8) | Y | 终端上送 |
| 商户订单交易时间 | OrderDateTime | String(14) | Y | yyyyMMddHHmmss |
| 商户订单币种类型 | CurrencyType | String(3) | Y | 156 人民币 |
| 商户订单交易金额 | OrderAmt | Number(22) | Y | 单位(人民币):分 整数,无小数点 |
| 商户商品名称 | OrderName | String(1,40) | Y | 终端上送 |
| 商户订单号 | OrderNo | String(1,40) | Y | 终端上送 |
| 原交易商户订单号 | OldOrderNo | String(1,40) | N | 终端上送 |
| 支付授权码 | ChannelAuthCode | String(1,64) | N | 非二维码支付没有的话填NULL |
eg:
{"OrderType":"01","PayChannelType":"12","DeviceType":"02","Mch_id":"100000000000001","Ter_id":"10000001","OrderDateTime":"20170612101520","CurrencyType":"156","OrderAmt":"000000000012","OrderName":"商品名称/商户名称+门店消费","OrderNo":"00000000000000000001","OldOrderNo":"00000000000000000001","ChannelAuthCode":"扫码得到的授权码/NULL"}
outsprint:
| 字段名称 | 字段Key | 格式 | 必填 | 备注 |
|-------------------+--------------+---------------+------+------------------------------------------|
| 响应码 | ResponseCode | String(4) | Y | 成功 0000 |
| 响应信息 | ResponseMsg | String(1,100) | Y | 交易成功 |
| 交易状态 | TradeStatus | String(6) | Y | 正常 000000 |
| 商户号 | Mch_id | String(15) | Y | 商户号 |
| 终端号 | Ter_id | String(8) | Y | 终端号 |
| 商户订单号 | OrderNo | String(1,40) | Y | 没有就填空 |
| 原交易商户订单号 | OldOrderNo | String(1,40) | Y | 没有就填空 |
| 商户退款/撤销单号 | RefundNo | String(1,40) | Y | 没有就填空 |
| 商户退款/撤销金额 | amount | Number(12) | Y | "单位(人民币):分 |
| | | | | 整数,无小数点" |
| 支付调起凭证 | tn | String(1,1000)| Y | 二维码 url 地址;没有则会返回空 |
eg:
{"ResponseCode":"0000","ResponseMsg":"交易成功","TradeStatus":"000000","Mch_id":"100000000000001","Ter_id":"10000001","OrderNo":"00000000000000000001","OldOrderNo":"00000000000000000001","RefundNo":"00000000000000000001","amount":"000000000012","tn":""}
ResponseCode意义:
"ResponseCode":"0000","ResponseMsg":"交易成功"
"ResponseCode":"0003","ResponseMsg":"无效商户"
"ResponseCode":"0005","ResponseMsg":"身份认证失败"
"ResponseCode":"0013","ResponseMsg":"无效金额"
"ResponseCode":"0014","ResponseMsg":"无效卡号"
"ResponseCode":"0025","ResponseMsg":"找不到原始交易"
"ResponseCode":"0030","ResponseMsg":"报文格式错误"
"ResponseCode":"0038","ResponseMsg":"密码错误超限"
"ResponseCode":"0040","ResponseMsg":"请求的功能尚不支持"
"ResponseCode":"0051","ResponseMsg":"金额不足"
"ResponseCode":"0055","ResponseMsg":"密码错误"
"ResponseCode":"0057","ResponseMsg":"不允许该卡进行此交易"
"ResponseCode":"0058","ResponseMsg":"不允许该终端进行此交易"
"ResponseCode":"0061","ResponseMsg":"超出金额限制"
"ResponseCode":"0064","ResponseMsg":"原始金额错误"
"ResponseCode":"0090","ResponseMsg":"系统正在进行日终处理"
"ResponseCode":"0092","ResponseMsg":"发卡方线路异常请稍后重试"
"ResponseCode":"0094","ResponseMsg":"重复交易"
"ResponseCode":"0096","ResponseMsg":"交易失败"
"ResponseCode":"0097","ResponseMsg":"终端未登记"
"ResponseCode":"0098","ResponseMsg":"交易正在处理中"
insprint:
| 字段名称 | 字段Key | 格式 | 必填 | 备注 |
|------------------+-------------------+--------------+------+----------------------------------------------------------- |
| 商户号 | Mch_id | String(15) | Y | 终端上送 |
| 商户全称 | Shop_Name | String(90) | Y | 终端上送 |
| 商户简称 | Shop_NameB | String(60) | Y | 终端上送 |
| 终端号 | Ter_id | String(8) | Y | 终端上送 |
| 终端SN号 | Ter_Sn | String(20) | Y | 终端上送 |
| 标记 | flag | String(1) | Y | 1:新建商户; |
| | | | | 2:在现有商户上增加终端; |
| | | | | 3:修改商户和终端; |
| | | | | 4:注销商户; |
| | | | | 5:注销终端 |
eg:
{"Mch_id":"100000000000001","Shop_Name":"浙星信息技术有限公司","Shop_NameB":"浙星","Ter_id":"10000001","Ter_Sn":"ZX000000000000000001","flag":"1"}
outsprint:
| 字段名称 | 字段Key | 格式 | 必填 | 备注 |
|-------------------+--------------+---------------+------+------------------------------------------|
| 响应码 | ResponseCode | String(4) | Y | 成功 0000 |
| 响应信息 | ResponseMsg | String(1,100) | Y | 交易成功 |
| 交易状态 | TradeStatus | String(6) | Y | 正常 000000 |
| 商户号 | Mch_id | String(15) | Y | 商户号 |
| 终端号 | Ter_id | String(8) | Y | 终端号 |
| 终端SN号 | Ter_Sn | String(20) | Y | 终端SN号 |
eg:
{"ResponseCode":"0000","ResponseMsg":"交易成功","TradeStatus":"000000","Mch_id":"100000000000001","Ter_id":"10000001","Ter_Sn":"00000000000000000001"}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2018-01-19 Fri 11:43 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>&lrm;</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="zhoushang" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2018 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org0e0a317">1. API</a></li>
<li><a href="#orgc31a797">2. 交易接口</a>
<ul>
<li><a href="#org8a6ea5a">2.1. 刷卡支付</a>
<ul>
<li><a href="#org53cd845">2.1.1. 请求参数</a></li>
<li><a href="#org749d572">2.1.2. 返回参数</a></li>
</ul>
</li>
<li><a href="#orgb6dfeb6">2.2. 扫码支付</a>
<ul>
<li><a href="#org9ec27b9">2.2.1. 请求参数</a></li>
<li><a href="#orga364abd">2.2.2. 返回参数</a></li>
</ul>
</li>
<li><a href="#orgdf85500">2.3. 公众号支付</a>
<ul>
<li><a href="#orged90326">2.3.1. 请求参数</a></li>
<li><a href="#org39c332e">2.3.2. 返回参数</a></li>
</ul>
</li>
<li><a href="#orgb726429">2.4. 查询交易</a>
<ul>
<li><a href="#org51b73fc">2.4.1. 请求参数</a></li>
<li><a href="#orgb2a0805">2.4.2. 返回参数</a></li>
</ul>
</li>
<li><a href="#org919a513">2.5. 退货交易</a>
<ul>
<li><a href="#org3532c72">2.5.1. 请求参数</a></li>
<li><a href="#org6ce5cd2">2.5.2. 返回参数</a></li>
</ul>
</li>
<li><a href="#org9055231">2.6. 撤销交易</a></li>
</ul>
</li>
<li><a href="#orgd9123c6">3. 响应码表</a></li>
<li><a href="#orgbfaf7d8">4. 测试数据</a>
<ul>
<li><a href="#orgcba975d">4.1. 刷卡支付</a>
<ul>
<li><a href="#orgf27db04">4.1.1. 请求数据</a></li>
<li><a href="#org3efb985">4.1.2. 返回数据</a></li>
</ul>
</li>
<li><a href="#org996ccca">4.2. 查询</a>
<ul>
<li><a href="#org230bf6b">4.2.1. 请求数据</a></li>
<li><a href="#org901f7be">4.2.2. 返回数据</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org0e0a317" class="outline-2">
<h2 id="org0e0a317"><span class="section-number-2">1</span> API</h2>
<div class="outline-text-2" id="text-1">
<div class="org-src-container">
<pre class="src src-C++">JNIEXPORT jstring <span style="color: #ce537a; font-weight: bold;">JNICALL</span> <span style="color: #bc6ec5; font-weight: bold;">Java_com_xingdata_zzdpos_zxpay_jsonpay</span><span style="color: #4f97d7;">(</span><span style="color: #ce537a; font-weight: bold;">JNIEnv</span> *<span style="color: #7590db;">env</span>, <span style="color: #ce537a; font-weight: bold;">jclass</span> <span style="color: #7590db;">jcl</span>, <span style="color: #ce537a; font-weight: bold;">jstring</span> <span style="color: #7590db;">jc</span><span style="color: #4f97d7;">)</span>;
</pre>
</div>
</div>
</div>
<div id="outline-container-orgc31a797" class="outline-2">
<h2 id="orgc31a797"><span class="section-number-2">2</span> 交易接口</h2>
<div class="outline-text-2" id="text-2">
</div>
<div id="outline-container-org8a6ea5a" class="outline-3">
<h3 id="org8a6ea5a"><span class="section-number-3">2.1</span> 刷卡支付</h3>
<div class="outline-text-3" id="text-2-1">
</div>
<div id="outline-container-org53cd845" class="outline-4">
<h4 id="org53cd845"><span class="section-number-4">2.1.1</span> 请求参数</h4>
<div class="outline-text-4" id="text-2-1-1">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">参数</th>
<th scope="col" class="org-left">名称</th>
<th scope="col" class="org-left">格式</th>
<th scope="col" class="org-left">必填</th>
<th scope="col" class="org-left">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">OrderType</td>
<td class="org-left">商户交易类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1 普通消费 2 查询交易 3 撤销交易 4 退货交易</td>
</tr>
<tr>
<td class="org-left">PayChannelType</td>
<td class="org-left">用户所选渠道类型</td>
<td class="org-left">int</td>
<td class="org-left">N</td>
<td class="org-left">1 现金 2 微信 3 支付宝 4 银行卡 5 银联二维码 8 会员卡</td>
</tr>
<tr>
<td class="org-left">DeviceType</td>
<td class="org-left">设备类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1</td>
</tr>
<tr>
<td class="org-left">Agent_id</td>
<td class="org-left">机构号</td>
<td class="org-left">String(8)</td>
<td class="org-left">N</td>
<td class="org-left">由支付平台决定(百富机构接入必填)</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">OrderNo</td>
<td class="org-left">商户订单号</td>
<td class="org-left">String(64)</td>
<td class="org-left">N</td>
<td class="org-left">终端上送(百富不需要)</td>
</tr>
<tr>
<td class="org-left">PosTrace</td>
<td class="org-left">流水号</td>
<td class="org-left">String(6)</td>
<td class="org-left">N</td>
<td class="org-left">流水号(没有则使用时间HHMMSS)</td>
</tr>
<tr>
<td class="org-left">OrderDateTime</td>
<td class="org-left">商户订单交易时间</td>
<td class="org-left">String(14)</td>
<td class="org-left">Y</td>
<td class="org-left">yyyymmddHHMMSS</td>
</tr>
<tr>
<td class="org-left">CurrencyType</td>
<td class="org-left">商户订单币种类型</td>
<td class="org-left">String(3)</td>
<td class="org-left">N</td>
<td class="org-left">默认: 156 人民币</td>
</tr>
<tr>
<td class="org-left">OrderAmt</td>
<td class="org-left">商户订单交易金额</td>
<td class="org-left">String(22)</td>
<td class="org-left">Y</td>
<td class="org-left">单位(人民币):分 整数,无小数点</td>
</tr>
<tr>
<td class="org-left">OrderName</td>
<td class="org-left">商户商品名称</td>
<td class="org-left">String(40)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">ChannelAuthCode</td>
<td class="org-left">支付授权码</td>
<td class="org-left">String(32)</td>
<td class="org-left">Y</td>
<td class="org-left">微信或支付宝授权码</td>
</tr>
<tr>
<td class="org-left">Key</td>
<td class="org-left">密钥</td>
<td class="org-left">String(32)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">NotifyUrl</td>
<td class="org-left">异步服务器地址</td>
<td class="org-left">String(255)</td>
<td class="org-left">N</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org749d572" class="outline-4">
<h4 id="org749d572"><span class="section-number-4">2.1.2</span> 返回参数</h4>
<div class="outline-text-4" id="text-2-1-2">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">字段Key</th>
<th scope="col" class="org-left">字段名称</th>
<th scope="col" class="org-left">格式</th>
<th scope="col" class="org-left">必填</th>
<th scope="col" class="org-left">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">OrderType</td>
<td class="org-left">用户交易类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1</td>
</tr>
<tr>
<td class="org-left">ResponseCode</td>
<td class="org-left">响应码</td>
<td class="org-left">String(4)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">ResponseMsg</td>
<td class="org-left">响应信息</td>
<td class="org-left">String(100)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">TradeStatus</td>
<td class="org-left">交易状态</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">Agent_id</td>
<td class="org-left">机构号</td>
<td class="org-left">String(8)</td>
<td class="org-left">N</td>
<td class="org-left">由支付平台决定(百富机构接入必填)</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">商户号</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端号</td>
</tr>
<tr>
<td class="org-left">OrderNo</td>
<td class="org-left">商户订单号</td>
<td class="org-left">String(64)</td>
<td class="org-left">N</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left">OrderAmt</td>
<td class="org-left">商户退款/撤销金额</td>
<td class="org-left">String(22)</td>
<td class="org-left">Y</td>
<td class="org-left">单位(人民币):分 整数,无小数点</td>
</tr>
<tr>
<td class="org-left">OrderDateTime</td>
<td class="org-left">商户订单交易时间</td>
<td class="org-left">String(14)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">HostOrderNo</td>
<td class="org-left">主机订单号</td>
<td class="org-left">String(32)</td>
<td class="org-left">Y</td>
<td class="org-left">(PAXPAY)为每笔交易产生的订单号</td>
</tr>
<tr>
<td class="org-left">PlatOrderNo</td>
<td class="org-left">支付订单号</td>
<td class="org-left">String(32)</td>
<td class="org-left">N</td>
<td class="org-left">支付宝或微信产生的订单号</td>
</tr>
<tr>
<td class="org-left">PayChannelType</td>
<td class="org-left">用户所选渠道类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">2 微信 3 支付宝</td>
</tr>
<tr>
<td class="org-left">paySign</td>
<td class="org-left">签名</td>
<td class="org-left">String(255)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="outline-container-orgb6dfeb6" class="outline-3">
<h3 id="orgb6dfeb6"><span class="section-number-3">2.2</span> 扫码支付</h3>
<div class="outline-text-3" id="text-2-2">
</div>
<div id="outline-container-org9ec27b9" class="outline-4">
<h4 id="org9ec27b9"><span class="section-number-4">2.2.1</span> 请求参数</h4>
<div class="outline-text-4" id="text-2-2-1">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">参数</th>
<th scope="col" class="org-left">名称</th>
<th scope="col" class="org-left">格式</th>
<th scope="col" class="org-left">必填</th>
<th scope="col" class="org-left">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">OrderType</td>
<td class="org-left">商户交易类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1 普通消费 2 查询交易 3 撤销交易 4 退货交易</td>
</tr>
<tr>
<td class="org-left">PayChannelType</td>
<td class="org-left">用户所选渠道类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1 现金 2 微信 3 支付宝 4 银行卡 5 银联二维码 8 会员卡</td>
</tr>
<tr>
<td class="org-left">DeviceType</td>
<td class="org-left">设备类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">2</td>
</tr>
<tr>
<td class="org-left">Agent_id</td>
<td class="org-left">机构号</td>
<td class="org-left">String(8)</td>
<td class="org-left">N</td>
<td class="org-left">由支付平台决定(百富机构接入必填)</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">OrderNo</td>
<td class="org-left">商户订单号</td>
<td class="org-left">String(64)</td>
<td class="org-left">N</td>
<td class="org-left">终端上送(百富不需要)</td>
</tr>
<tr>
<td class="org-left">PosTrace</td>
<td class="org-left">流水号</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">流水号</td>
</tr>
<tr>
<td class="org-left">OrderDateTime</td>
<td class="org-left">商户订单交易时间</td>
<td class="org-left">String(14)</td>
<td class="org-left">Y</td>
<td class="org-left">yyyymmddHHMMSS</td>
</tr>
<tr>
<td class="org-left">CurrencyType</td>
<td class="org-left">商户订单币种类型</td>
<td class="org-left">String(3)</td>
<td class="org-left">N</td>
<td class="org-left">默认: 156 人民币</td>
</tr>
<tr>
<td class="org-left">OrderAmt</td>
<td class="org-left">商户订单交易金额</td>
<td class="org-left">String(22)</td>
<td class="org-left">Y</td>
<td class="org-left">单位(人民币):分 整数,无小数点</td>
</tr>
<tr>
<td class="org-left">OrderName</td>
<td class="org-left">商户商品名称</td>
<td class="org-left">String(40)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">ChannelAuthCode</td>
<td class="org-left">支付授权码</td>
<td class="org-left">String(32)</td>
<td class="org-left">Y</td>
<td class="org-left">微信或支付宝授权码</td>
</tr>
<tr>
<td class="org-left">Key</td>
<td class="org-left">密钥</td>
<td class="org-left">String(32)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">NotifyUrl</td>
<td class="org-left">异步服务器地址</td>
<td class="org-left">String(255)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-orga364abd" class="outline-4">
<h4 id="orga364abd"><span class="section-number-4">2.2.2</span> 返回参数</h4>
<div class="outline-text-4" id="text-2-2-2">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">参数</th>
<th scope="col" class="org-left">名称</th>
<th scope="col" class="org-left">格式</th>
<th scope="col" class="org-left">必填</th>
<th scope="col" class="org-left">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">OrderType</td>
<td class="org-left">用户交易类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">2</td>
</tr>
<tr>
<td class="org-left">ResponseCode</td>
<td class="org-left">响应码</td>
<td class="org-left">String(4)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">ResponseMsg</td>
<td class="org-left">响应信息</td>
<td class="org-left">String(100)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">TradeStatus</td>
<td class="org-left">交易状态</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">商户号</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端号</td>
</tr>
<tr>
<td class="org-left">OrderNo</td>
<td class="org-left">商户订单号</td>
<td class="org-left">String(64)</td>
<td class="org-left">N</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left">tn</td>
<td class="org-left">支付二维码链接</td>
<td class="org-left">String(255)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">paySign</td>
<td class="org-left">签名</td>
<td class="org-left">String(255)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="outline-container-orgdf85500" class="outline-3">
<h3 id="orgdf85500"><span class="section-number-3">2.3</span> 公众号支付</h3>
<div class="outline-text-3" id="text-2-3">
</div>
<div id="outline-container-orged90326" class="outline-4">
<h4 id="orged90326"><span class="section-number-4">2.3.1</span> 请求参数</h4>
<div class="outline-text-4" id="text-2-3-1">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left">参数</td>
<td class="org-left">名称</td>
<td class="org-left">格式</td>
<td class="org-left">必填</td>
<td class="org-left">备注</td>
</tr>
<tr>
<td class="org-left">OrderType</td>
<td class="org-left">商户交易类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1 普通消费 2 查询交易 3 撤销交易 4 退货交易</td>
</tr>
<tr>
<td class="org-left">PayChannelType</td>
<td class="org-left">用户所选渠道类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1 现金 2 微信 3 支付宝 4 银行卡 5 银联二维码 8 会员卡</td>
</tr>
<tr>
<td class="org-left">DeviceType</td>
<td class="org-left">设备类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">3</td>
</tr>
<tr>
<td class="org-left">Agent_id</td>
<td class="org-left">机构号</td>
<td class="org-left">String(8)</td>
<td class="org-left">N</td>
<td class="org-left">由支付平台决定(百富机构接入必填)</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">Open_id</td>
<td class="org-left">用户标识</td>
<td class="org-left">String(128)</td>
<td class="org-left">Y</td>
<td class="org-left">微信用户公众号appid下唯一标识</td>
</tr>
<tr>
<td class="org-left">OrderDateTime</td>
<td class="org-left">商户订单交易时间</td>
<td class="org-left">String(14)</td>
<td class="org-left">Y</td>
<td class="org-left">yyyymmddHHMMSS</td>
</tr>
<tr>
<td class="org-left">CurrencyType</td>
<td class="org-left">商户订单币种类型</td>
<td class="org-left">String(3)</td>
<td class="org-left">N</td>
<td class="org-left">默认: 156 人民币</td>
</tr>
<tr>
<td class="org-left">OrderAmt</td>
<td class="org-left">商户订单交易金额</td>
<td class="org-left">String(22)</td>
<td class="org-left">Y</td>
<td class="org-left">单位(人民币):分 整数,无小数点</td>
</tr>
<tr>
<td class="org-left">OrderName</td>
<td class="org-left">商户商品名称</td>
<td class="org-left">String(1,40)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">OrderNo</td>
<td class="org-left">商户订单号</td>
<td class="org-left">String(64)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">PosTrace</td>
<td class="org-left">流水号</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">流水号</td>
</tr>
<tr>
<td class="org-left">Key</td>
<td class="org-left">密钥</td>
<td class="org-left">String(32)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">NotifyUrl</td>
<td class="org-left">异步服务器地址</td>
<td class="org-left">String(255)</td>
<td class="org-left">N</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org39c332e" class="outline-4">
<h4 id="org39c332e"><span class="section-number-4">2.3.2</span> 返回参数</h4>
<div class="outline-text-4" id="text-2-3-2">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">参数</th>
<th scope="col" class="org-left">名称</th>
<th scope="col" class="org-left">格式</th>
<th scope="col" class="org-left">必填</th>
<th scope="col" class="org-left">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">ResponseCode</td>
<td class="org-left">响应码</td>
<td class="org-left">String(4)</td>
<td class="org-left">Y</td>
<td class="org-left">成功 0000</td>
</tr>
<tr>
<td class="org-left">ResponseMsg</td>
<td class="org-left">响应信息</td>
<td class="org-left">String(100)</td>
<td class="org-left">Y</td>
<td class="org-left">交易成功</td>
</tr>
<tr>
<td class="org-left">TradeStatus</td>
<td class="org-left">交易状态</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">正常 000000</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">商户号</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端号</td>
</tr>
<tr>
<td class="org-left">OrderNo</td>
<td class="org-left">商户订单号</td>
<td class="org-left">String(64)</td>
<td class="org-left">Y</td>
<td class="org-left">没有就填空</td>
</tr>
<tr>
<td class="org-left">OrderAmt</td>
<td class="org-left">商户退款/撤销金额</td>
<td class="org-left">String(22)</td>
<td class="org-left">Y</td>
<td class="org-left">单位(人民币):分 整数,无小数点"</td>
</tr>
<tr>
<td class="org-left">CodeUrl</td>
<td class="org-left">支付二维码链接</td>
<td class="org-left">String(255)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">payTime</td>
<td class="org-left">支付时间</td>
<td class="org-left">String(14)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="outline-container-orgb726429" class="outline-3">
<h3 id="orgb726429"><span class="section-number-3">2.4</span> 查询交易</h3>
<div class="outline-text-3" id="text-2-4">
</div>
<div id="outline-container-org51b73fc" class="outline-4">
<h4 id="org51b73fc"><span class="section-number-4">2.4.1</span> 请求参数</h4>
<div class="outline-text-4" id="text-2-4-1">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left">参数</td>
<td class="org-left">名称</td>
<td class="org-left">格式</td>
<td class="org-left">必填</td>
<td class="org-left">备注</td>
</tr>
<tr>
<td class="org-left">OrderType</td>
<td class="org-left">商户交易类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">2</td>
</tr>
<tr>
<td class="org-left">Agent_id</td>
<td class="org-left">机构号</td>
<td class="org-left">String(8)</td>
<td class="org-left">N</td>
<td class="org-left">由支付平台决定(百富机构接入必填)</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">PosTrace</td>
<td class="org-left">原流水号</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">OrderDateTime</td>
<td class="org-left">商户订单交易时间</td>
<td class="org-left">String(14)</td>
<td class="org-left">Y</td>
<td class="org-left">yyyymmddHHMMSS</td>
</tr>
<tr>
<td class="org-left">CurrencyType</td>
<td class="org-left">商户订单币种类型</td>
<td class="org-left">String(3)</td>
<td class="org-left">N</td>
<td class="org-left">默认: 156 人民币</td>
</tr>
<tr>
<td class="org-left">Key</td>
<td class="org-left">密钥</td>
<td class="org-left">String(32)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">NotifyUrl</td>
<td class="org-left">异步服务器地址</td>
<td class="org-left">String(255)</td>
<td class="org-left">N</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-orgb2a0805" class="outline-4">
<h4 id="orgb2a0805"><span class="section-number-4">2.4.2</span> 返回参数</h4>
<div class="outline-text-4" id="text-2-4-2">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left">参数</td>
<td class="org-left">名称</td>
<td class="org-left">格式</td>
<td class="org-left">必填</td>
<td class="org-left">备注</td>
</tr>
<tr>
<td class="org-left">ResponseCode</td>
<td class="org-left">响应码</td>
<td class="org-left">String(4)</td>
<td class="org-left">Y</td>
<td class="org-left">成功 0000</td>
</tr>
<tr>
<td class="org-left">ResponseMsg</td>
<td class="org-left">响应信息</td>
<td class="org-left">String(100)</td>
<td class="org-left">Y</td>
<td class="org-left">交易成功</td>
</tr>
<tr>
<td class="org-left">TradeStatus</td>
<td class="org-left">交易状态</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">正常 000000</td>
</tr>
<tr>
<td class="org-left">Agent_id</td>
<td class="org-left">机构号</td>
<td class="org-left">String(8)</td>
<td class="org-left">N</td>
<td class="org-left">由支付平台决定(百富机构必填)</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">商户号</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端号</td>
</tr>
<tr>
<td class="org-left">PosTrace</td>
<td class="org-left">流水号</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">流水号</td>
</tr>
<tr>
<td class="org-left">OrderNo</td>
<td class="org-left">商户订单号</td>
<td class="org-left">String(64)</td>
<td class="org-left">Y</td>
<td class="org-left">没有就填空</td>
</tr>
<tr>
<td class="org-left">OrderAmt</td>
<td class="org-left">商户退款/撤销金额</td>
<td class="org-left">String(22)</td>
<td class="org-left">Y</td>
<td class="org-left">单位(人民币):分 整数,无小数点"</td>
</tr>
<tr>
<td class="org-left">CodeUrl</td>
<td class="org-left">支付二维码链接</td>
<td class="org-left">String(255)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">OrderType</td>
<td class="org-left">交易类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1 消费 3 撤销 4 退货</td>
</tr>
<tr>
<td class="org-left">PayChannelType</td>
<td class="org-left">用户所选渠道类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">2 微信 3 支付宝 4 银行卡 5 银联二维码</td>
</tr>
<tr>
<td class="org-left">DeviceType</td>
<td class="org-left">设备类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1 刷卡支付</td>
</tr>
<tr>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">2 扫码支付</td>
</tr>
<tr>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">3 公众号支付</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="outline-container-org919a513" class="outline-3">
<h3 id="org919a513"><span class="section-number-3">2.5</span> 退货交易</h3>
<div class="outline-text-3" id="text-2-5">
</div>
<div id="outline-container-org3532c72" class="outline-4">
<h4 id="org3532c72"><span class="section-number-4">2.5.1</span> 请求参数</h4>
<div class="outline-text-4" id="text-2-5-1">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left">参数</td>
<td class="org-left">名称</td>
<td class="org-left">格式</td>
<td class="org-left">必填</td>
<td class="org-left">备注</td>
</tr>
<tr>
<td class="org-left">OrderType</td>
<td class="org-left">商户交易类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">2</td>
</tr>
<tr>
<td class="org-left">Agent_id</td>
<td class="org-left">机构号</td>
<td class="org-left">String(8)</td>
<td class="org-left">N</td>
<td class="org-left">由支付平台决定(百富机构接入必填)</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端上送</td>
</tr>
<tr>
<td class="org-left">PosTrace</td>
<td class="org-left">原流水号</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">OrderDateTime</td>
<td class="org-left">商户订单交易时间</td>
<td class="org-left">String(14)</td>
<td class="org-left">Y</td>
<td class="org-left">yyyymmddHHMMSS</td>
</tr>
<tr>
<td class="org-left">CurrencyType</td>
<td class="org-left">商户订单币种类型</td>
<td class="org-left">String(3)</td>
<td class="org-left">N</td>
<td class="org-left">默认: 156 人民币</td>
</tr>
<tr>
<td class="org-left">Key</td>
<td class="org-left">密钥</td>
<td class="org-left">String(32)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">NotifyUrl</td>
<td class="org-left">异步服务器地址</td>
<td class="org-left">String(255)</td>
<td class="org-left">N</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org6ce5cd2" class="outline-4">
<h4 id="org6ce5cd2"><span class="section-number-4">2.5.2</span> 返回参数</h4>
<div class="outline-text-4" id="text-2-5-2">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left">参数</td>
<td class="org-left">名称</td>
<td class="org-left">格式</td>
<td class="org-left">必填</td>
<td class="org-left">备注</td>
</tr>
<tr>
<td class="org-left">ResponseCode</td>
<td class="org-left">响应码</td>
<td class="org-left">String(4)</td>
<td class="org-left">Y</td>
<td class="org-left">成功 0000</td>
</tr>
<tr>
<td class="org-left">ResponseMsg</td>
<td class="org-left">响应信息</td>
<td class="org-left">String(100)</td>
<td class="org-left">Y</td>
<td class="org-left">交易成功</td>
</tr>
<tr>
<td class="org-left">TradeStatus</td>
<td class="org-left">交易状态</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">正常 000000</td>
</tr>
<tr>
<td class="org-left">Agent_id</td>
<td class="org-left">机构号</td>
<td class="org-left">String(8)</td>
<td class="org-left">N</td>
<td class="org-left">由支付平台决定(百富机构必填)</td>
</tr>
<tr>
<td class="org-left">Mch_id</td>
<td class="org-left">商户号</td>
<td class="org-left">String(15)</td>
<td class="org-left">Y</td>
<td class="org-left">商户号</td>
</tr>
<tr>
<td class="org-left">Ter_id</td>
<td class="org-left">终端号</td>
<td class="org-left">String(8)</td>
<td class="org-left">Y</td>
<td class="org-left">终端号</td>
</tr>
<tr>
<td class="org-left">PosTrace</td>
<td class="org-left">流水号</td>
<td class="org-left">String(6)</td>
<td class="org-left">Y</td>
<td class="org-left">流水号</td>
</tr>
<tr>
<td class="org-left">OrderNo</td>
<td class="org-left">商户订单号</td>
<td class="org-left">String(64)</td>
<td class="org-left">Y</td>
<td class="org-left">没有就填空</td>
</tr>
<tr>
<td class="org-left">OrderAmt</td>
<td class="org-left">商户退款/撤销金额</td>
<td class="org-left">String(22)</td>
<td class="org-left">Y</td>
<td class="org-left">单位(人民币):分 整数,无小数点"</td>
</tr>
<tr>
<td class="org-left">CodeUrl</td>
<td class="org-left">支付二维码链接</td>
<td class="org-left">String(255)</td>
<td class="org-left">Y</td>
<td class="org-left">&#xa0;</td>
</tr>
<tr>
<td class="org-left">OrderType</td>
<td class="org-left">交易类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1 消费 3 撤销 4 退货</td>
</tr>
<tr>
<td class="org-left">PayChannelType</td>
<td class="org-left">用户所选渠道类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">2 微信 3 支付宝 4 银行卡 5 银联二维码</td>
</tr>
<tr>
<td class="org-left">DeviceType</td>
<td class="org-left">设备类型</td>
<td class="org-left">int</td>
<td class="org-left">Y</td>
<td class="org-left">1 刷卡支付</td>
</tr>
<tr>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">2 扫码支付</td>
</tr>
<tr>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">3 公众号支付</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="outline-container-org9055231" class="outline-3">
<h3 id="org9055231"><span class="section-number-3">2.6</span> 撤销交易</h3>
</div>
</div>
<div id="outline-container-orgd9123c6" class="outline-2">
<h2 id="orgd9123c6"><span class="section-number-2">3</span> 响应码表</h2>
<div class="outline-text-2" id="text-3">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-right" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-right">返回码</th>
<th scope="col" class="org-left">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-right">0000</td>
<td class="org-left">交易成功</td>
</tr>
<tr>
<td class="org-right">0003</td>
<td class="org-left">无效商户</td>
</tr>
<tr>
<td class="org-right">0005</td>
<td class="org-left">身份认证失败</td>
</tr>
<tr>
<td class="org-right">0013</td>
<td class="org-left">无效金额</td>
</tr>
<tr>
<td class="org-right">0014</td>
<td class="org-left">无效卡号</td>
</tr>
<tr>
<td class="org-right">0025</td>
<td class="org-left">找不到原始交易</td>
</tr>
<tr>
<td class="org-right">0030</td>
<td class="org-left">报文格式错误</td>
</tr>
<tr>
<td class="org-right">0038</td>
<td class="org-left">密码错误超限</td>
</tr>
<tr>
<td class="org-right">0040</td>
<td class="org-left">请求的功能尚不支持</td>
</tr>
<tr>
<td class="org-right">0051</td>
<td class="org-left">金额不足</td>
</tr>
<tr>
<td class="org-right">0055</td>
<td class="org-left">密码错误</td>
</tr>
<tr>
<td class="org-right">0057</td>
<td class="org-left">不允许该卡进行此交易</td>
</tr>
<tr>
<td class="org-right">0058</td>
<td class="org-left">不允许该终端进行此交易</td>
</tr>
<tr>
<td class="org-right">0061</td>
<td class="org-left">超出金额限制</td>
</tr>
<tr>
<td class="org-right">0064</td>
<td class="org-left">原始金额错误</td>
</tr>
<tr>
<td class="org-right">0090</td>
<td class="org-left">系统正在进行日终处理</td>
</tr>
<tr>
<td class="org-right">0092</td>
<td class="org-left">发卡方线路异常请稍后重试</td>
</tr>
<tr>
<td class="org-right">0094</td>
<td class="org-left">重复交易</td>
</tr>
<tr>
<td class="org-right">0096</td>
<td class="org-left">交易失败</td>
</tr>
<tr>
<td class="org-right">0097</td>
<td class="org-left">终端未登记</td>
</tr>
<tr>
<td class="org-right">0098</td>
<td class="org-left">交易正在处理中</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-orgbfaf7d8" class="outline-2">
<h2 id="orgbfaf7d8"><span class="section-number-2">4</span> 测试数据</h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-orgcba975d" class="outline-3">
<h3 id="orgcba975d"><span class="section-number-3">4.1</span> 刷卡支付</h3>
<div class="outline-text-3" id="text-4-1">
</div>
<div id="outline-container-orgf27db04" class="outline-4">
<h4 id="orgf27db04"><span class="section-number-4">4.1.1</span> 请求数据</h4>
<div class="outline-text-4" id="text-4-1-1">
<div class="org-src-container">
<pre class="src src-JSON">{
"OrderDateTime": "20180119113507",
"OrderName": "浙星门店消费",
"OrderNo": "20180108104821",
"ChannelAuthCode": "135432426010841918",
"OrderType": 1,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org3efb985" class="outline-4">
<h4 id="org3efb985"><span class="section-number-4">4.1.2</span> 返回数据</h4>
<div class="outline-text-4" id="text-4-1-2">
<div class="org-src-container">
<pre class="src src-JSON">{
"OrderType": 1,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "98",
"ResponseMsg": "Please call query API to get transaction status",
"PosTrace": "113507"
}
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org996ccca" class="outline-3">
<h3 id="org996ccca"><span class="section-number-3">4.2</span> 查询</h3>
<div class="outline-text-3" id="text-4-2">
</div>
<div id="outline-container-org230bf6b" class="outline-4">
<h4 id="org230bf6b"><span class="section-number-4">4.2.1</span> 请求数据</h4>
<div class="outline-text-4" id="text-4-2-1">
<div class="org-src-container">
<pre class="src src-JSON">{
"OrderDateTime": "20180119113507",
"OrderName": "浙星门店消费",
"OrderNo": "20180108104821",
"ChannelAuthCode": "135432426010841918",
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org901f7be" class="outline-4">
<h4 id="org901f7be"><span class="section-number-4">4.2.2</span> 返回数据</h4>
<div class="outline-text-4" id="text-4-2-2">
<div class="org-src-container">
<pre class="src src-JSON">{
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "00",
"ResponseMsg": "交易成功",
"PosTrace": "113507",
"PosTrace": "113507",
"OrderDateTime": "20180119113507",
"OrderNo": "20180108104821",
"HostOrderNo": "180119113414030150",
"PlatOrderNo": "",
"OrderAmt": "0.01",
"CurrencyType": "",
"TradeStatus": "0",
"tn": ""
}
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: zhoushang</p>
<p class="date">Created: 2018-01-19 Fri 11:43</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>
* API
#+BEGIN_SRC C++
JNIEXPORT jstring JNICALL Java_com_xingdata_zzdpos_zxpay_jsonpay(JNIEnv *env, jclass jcl, jstring jc);
#+END_SRC
* 交易接口
** 刷卡支付
*** 请求参数
| 参数 | 名称 | 格式 | 必填 | 备注 |
|-----------------+------------------+-------------+------+--------------------------------------------------------|
| OrderType | 商户交易类型 | int | Y | 1 普通消费 2 查询交易 3 撤销交易 4 退货交易 |
| PayChannelType | 用户所选渠道类型 | int | N | 1 现金 2 微信 3 支付宝 4 银行卡 5 银联二维码 8 会员卡 |
| DeviceType | 设备类型 | int | Y | 1 |
| Agent_id | 机构号 | String(8) | N | 由支付平台决定(百富机构接入必填) |
| Mch_id | 商户号 | String(15) | Y | 终端上送 |
| Ter_id | 终端号 | String(8) | Y | 终端上送 |
| OrderNo | 商户订单号 | String(64) | N | 终端上送(百富不需要) |
| PosTrace | 流水号 | String(6) | N | 流水号(没有则使用时间HHMMSS) |
| OrderDateTime | 商户订单交易时间 | String(14) | Y | yyyymmddHHMMSS |
| CurrencyType | 商户订单币种类型 | String(3) | N | 默认: 156 人民币 |
| OrderAmt | 商户订单交易金额 | String(22) | Y | 单位(人民币):分 整数,无小数点 |
| OrderName | 商户商品名称 | String(40) | Y | 终端上送 |
| ChannelAuthCode | 支付授权码 | String(32) | Y | 微信或支付宝授权码 |
| Key | 密钥 | String(32) | Y | |
| NotifyUrl | 异步服务器地址 | String(255) | N | |
*** 返回参数
| 字段Key | 字段名称 | 格式 | 必填 | 备注 |
|----------------+-------------------+-------------+------+----------------------------------|
| OrderType | 用户交易类型 | int | Y | 1 |
| ResponseCode | 响应码 | String(4) | Y | |
| ResponseMsg | 响应信息 | String(100) | Y | |
| TradeStatus | 交易状态 | String(6) | Y | |
| Agent_id | 机构号 | String(8) | N | 由支付平台决定(百富机构接入必填) |
| Mch_id | 商户号 | String(15) | Y | 商户号 |
| Ter_id | 终端号 | String(8) | Y | 终端号 |
| OrderNo | 商户订单号 | String(64) | N | |
|----------------+-------------------+-------------+------+----------------------------------|
| OrderAmt | 商户退款/撤销金额 | String(22) | Y | 单位(人民币):分 整数,无小数点 |
| OrderDateTime | 商户订单交易时间 | String(14) | Y | |
| HostOrderNo | 主机订单号 | String(32) | Y | (PAXPAY)为每笔交易产生的订单号 |
| PlatOrderNo | 支付订单号 | String(32) | N | 支付宝或微信产生的订单号 |
| PayChannelType | 用户所选渠道类型 | int | Y | 2 微信 3 支付宝 |
| paySign | 签名 | String(255) | Y | |
** 扫码支付
*** 请求参数
| 参数 | 名称 | 格式 | 必填 | 备注 |
|-----------------+------------------+-------------+------+--------------------------------------------------------|
| OrderType | 商户交易类型 | int | Y | 1 普通消费 2 查询交易 3 撤销交易 4 退货交易 |
| PayChannelType | 用户所选渠道类型 | int | Y | 1 现金 2 微信 3 支付宝 4 银行卡 5 银联二维码 8 会员卡 |
| DeviceType | 设备类型 | int | Y | 2 |
| Agent_id | 机构号 | String(8) | N | 由支付平台决定(百富机构接入必填) |
| Mch_id | 商户号 | String(15) | Y | 终端上送 |
| Ter_id | 终端号 | String(8) | Y | 终端上送 |
| OrderNo | 商户订单号 | String(64) | N | 终端上送(百富不需要) |
| PosTrace | 流水号 | String(6) | Y | 流水号 |
| OrderDateTime | 商户订单交易时间 | String(14) | Y | yyyymmddHHMMSS |
| CurrencyType | 商户订单币种类型 | String(3) | N | 默认: 156 人民币 |
| OrderAmt | 商户订单交易金额 | String(22) | Y | 单位(人民币):分 整数,无小数点 |
| OrderName | 商户商品名称 | String(40) | Y | 终端上送 |
| ChannelAuthCode | 支付授权码 | String(32) | Y | 微信或支付宝授权码 |
| Key | 密钥 | String(32) | Y | |
| NotifyUrl | 异步服务器地址 | String(255) | Y | |
*** 返回参数
| 参数 | 名称 | 格式 | 必填 | 备注 |
|--------------+----------------+-------------+------+--------|
| OrderType | 用户交易类型 | int | Y | 2 |
| ResponseCode | 响应码 | String(4) | Y | |
| ResponseMsg | 响应信息 | String(100) | Y | |
| TradeStatus | 交易状态 | String(6) | Y | |
| Mch_id | 商户号 | String(15) | Y | 商户号 |
| Ter_id | 终端号 | String(8) | Y | 终端号 |
| OrderNo | 商户订单号 | String(64) | N | |
|--------------+----------------+-------------+------+--------|
| tn | 支付二维码链接 | String(255) | Y | |
| paySign | 签名 | String(255) | Y | |
** 公众号支付
*** 请求参数
| 参数 | 名称 | 格式 | 必填 | 备注 |
| OrderType | 商户交易类型 | int | Y | 1 普通消费 2 查询交易 3 撤销交易 4 退货交易 |
| PayChannelType | 用户所选渠道类型 | int | Y | 1 现金 2 微信 3 支付宝 4 银行卡 5 银联二维码 8 会员卡 |
| DeviceType | 设备类型 | int | Y | 3 |
| Agent_id | 机构号 | String(8) | N | 由支付平台决定(百富机构接入必填) |
| Mch_id | 商户号 | String(15) | Y | 终端上送 |
| Ter_id | 终端号 | String(8) | Y | 终端上送 |
| Open_id | 用户标识 | String(128) | Y | 微信用户公众号appid下唯一标识 |
| OrderDateTime | 商户订单交易时间 | String(14) | Y | yyyymmddHHMMSS |
| CurrencyType | 商户订单币种类型 | String(3) | N | 默认: 156 人民币 |
| OrderAmt | 商户订单交易金额 | String(22) | Y | 单位(人民币):分 整数,无小数点 |
| OrderName | 商户商品名称 | String(1,40) | Y | 终端上送 |
| OrderNo | 商户订单号 | String(64) | Y | 终端上送 |
| PosTrace | 流水号 | String(6) | Y | 流水号 |
| Key | 密钥 | String(32) | Y | |
| NotifyUrl | 异步服务器地址 | String(255) | N | |
*** 返回参数
| 参数 | 名称 | 格式 | 必填 | 备注 |
|--------------+-------------------+-------------+------+-----------------------------------|
| ResponseCode | 响应码 | String(4) | Y | 成功 0000 |
| ResponseMsg | 响应信息 | String(100) | Y | 交易成功 |
| TradeStatus | 交易状态 | String(6) | Y | 正常 000000 |
| Mch_id | 商户号 | String(15) | Y | 商户号 |
| Ter_id | 终端号 | String(8) | Y | 终端号 |
| OrderNo | 商户订单号 | String(64) | Y | 没有就填空 |
| OrderAmt | 商户退款/撤销金额 | String(22) | Y | 单位(人民币):分 整数,无小数点" |
| CodeUrl | 支付二维码链接 | String(255) | Y | |
| payTime | 支付时间 | String(14) | Y | |
** 查询交易
*** 请求参数
| 参数 | 名称 | 格式 | 必填 | 备注 |
| OrderType | 商户交易类型 | int | Y | 2 |
| Agent_id | 机构号 | String(8) | N | 由支付平台决定(百富机构接入必填) |
| Mch_id | 商户号 | String(15) | Y | 终端上送 |
| Ter_id | 终端号 | String(8) | Y | 终端上送 |
| PosTrace | 原流水号 | String(6) | Y | |
| OrderDateTime | 商户订单交易时间 | String(14) | Y | yyyymmddHHMMSS |
| CurrencyType | 商户订单币种类型 | String(3) | N | 默认: 156 人民币 |
| Key | 密钥 | String(32) | Y | |
| NotifyUrl | 异步服务器地址 | String(255) | N | |
*** 返回参数
| 参数 | 名称 | 格式 | 必填 | 备注 |
| ResponseCode | 响应码 | String(4) | Y | 成功 0000 |
| ResponseMsg | 响应信息 | String(100) | Y | 交易成功 |
| TradeStatus | 交易状态 | String(6) | Y | 正常 000000 |
| Agent_id | 机构号 | String(8) | N | 由支付平台决定(百富机构必填) |
| Mch_id | 商户号 | String(15) | Y | 商户号 |
| Ter_id | 终端号 | String(8) | Y | 终端号 |
| PosTrace | 流水号 | String(6) | Y | 流水号 |
| OrderNo | 商户订单号 | String(64) | Y | 没有就填空 |
| OrderAmt | 商户退款/撤销金额 | String(22) | Y | 单位(人民币):分 整数,无小数点" |
| CodeUrl | 支付二维码链接 | String(255) | Y | |
| OrderType | 交易类型 | int | Y | 1 消费 3 撤销 4 退货 |
| PayChannelType | 用户所选渠道类型 | int | Y | 2 微信 3 支付宝 4 银行卡 5 银联二维码 |
| DeviceType | 设备类型 | int | Y | 1 刷卡支付 |
| | | | | 2 扫码支付 |
| | | | | 3 公众号支付 |
** 退货交易
*** 请求参数
| 参数 | 名称 | 格式 | 必填 | 备注 |
| OrderType | 商户交易类型 | int | Y | 2 |
| Agent_id | 机构号 | String(8) | N | 由支付平台决定(百富机构接入必填) |
| Mch_id | 商户号 | String(15) | Y | 终端上送 |
| Ter_id | 终端号 | String(8) | Y | 终端上送 |
| PosTrace | 原流水号 | String(6) | Y | |
| OrderDateTime | 商户订单交易时间 | String(14) | Y | yyyymmddHHMMSS |
| CurrencyType | 商户订单币种类型 | String(3) | N | 默认: 156 人民币 |
| Key | 密钥 | String(32) | Y | |
| NotifyUrl | 异步服务器地址 | String(255) | N | |
*** 返回参数
| 参数 | 名称 | 格式 | 必填 | 备注 |
| ResponseCode | 响应码 | String(4) | Y | 成功 0000 |
| ResponseMsg | 响应信息 | String(100) | Y | 交易成功 |
| TradeStatus | 交易状态 | String(6) | Y | 正常 000000 |
| Agent_id | 机构号 | String(8) | N | 由支付平台决定(百富机构必填) |
| Mch_id | 商户号 | String(15) | Y | 商户号 |
| Ter_id | 终端号 | String(8) | Y | 终端号 |
| PosTrace | 流水号 | String(6) | Y | 流水号 |
| OrderNo | 商户订单号 | String(64) | Y | 没有就填空 |
| OrderAmt | 商户退款/撤销金额 | String(22) | Y | 单位(人民币):分 整数,无小数点" |
| CodeUrl | 支付二维码链接 | String(255) | Y | |
| OrderType | 交易类型 | int | Y | 1 消费 3 撤销 4 退货 |
| PayChannelType | 用户所选渠道类型 | int | Y | 2 微信 3 支付宝 4 银行卡 5 银联二维码 |
| DeviceType | 设备类型 | int | Y | 1 刷卡支付 |
| | | | | 2 扫码支付 |
| | | | | 3 公众号支付 |
** 撤销交易
* 响应码表
| 返回码 | 说明 |
|--------+--------------------------|
| 0000 | 交易成功 |
| 0003 | 无效商户 |
| 0005 | 身份认证失败 |
| 0013 | 无效金额 |
| 0014 | 无效卡号 |
| 0025 | 找不到原始交易 |
| 0030 | 报文格式错误 |
| 0038 | 密码错误超限 |
| 0040 | 请求的功能尚不支持 |
| 0051 | 金额不足 |
| 0055 | 密码错误 |
| 0057 | 不允许该卡进行此交易 |
| 0058 | 不允许该终端进行此交易 |
| 0061 | 超出金额限制 |
| 0064 | 原始金额错误 |
| 0090 | 系统正在进行日终处理 |
| 0092 | 发卡方线路异常请稍后重试 |
| 0094 | 重复交易 |
| 0096 | 交易失败 |
| 0097 | 终端未登记 |
| 0098 | 交易正在处理中 |
* 测试数据
** 刷卡支付
*** 请求数据
#+BEGIN_SRC JSON
{
"OrderDateTime": "20180119113507",
"OrderName": "浙星门店消费",
"OrderNo": "20180108104821",
"ChannelAuthCode": "135432426010841918",
"OrderType": 1,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
#+END_SRC
*** 返回数据
#+BEGIN_SRC JSON
{
"OrderType": 1,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "98",
"ResponseMsg": "Please call query API to get transaction status",
"PosTrace": "113507"
}
#+END_SRC
** 查询
*** 请求数据
#+BEGIN_SRC JSON
{
"OrderDateTime": "20180119113507",
"OrderName": "浙星门店消费",
"OrderNo": "20180108104821",
"ChannelAuthCode": "135432426010841918",
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
#+END_SRC
*** 返回数据
#+BEGIN_SRC JSON
{
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "00",
"ResponseMsg": "交易成功",
"PosTrace": "113507",
"PosTrace": "113507",
"OrderDateTime": "20180119113507",
"OrderNo": "20180108104821",
"HostOrderNo": "180119113414030150",
"PlatOrderNo": "",
"OrderAmt": "0.01",
"CurrencyType": "",
"TradeStatus": "0",
"tn": ""
}
#+END_SRC
** 撤销
*** 请求数据
#+BEGIN_SRC JSON
{
"OrderDateTime": "20180119113507",
"OrderName": "浙星门店消费",
"OrderNo": "113507",
"ChannelAuthCode": "135432426010841918",
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
#+END_SRC
*** 返回数据
{
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "00",
"ResponseMsg": "交易成功",
"PosTrace": "113507",
"OrderDateTime": "20180119113507",
"OrderNo": "113507",
"HostOrderNo": "",
"PlatOrderNo": "",
"OrderAmt": "1",
"CurrencyType": "",
"TradeStatus": "0",
"tn": ""
}
** 扫码支付
*** 请求数据
#+BEGIN_SRC JSON
{
"OrderDateTime": "20180119115923",
"OrderName": "浙星门店消费",
"OrderNo": "113507",
"OrderType": 1,
"PayChannelType": 3,
"DeviceType": 2,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
#+END_SRC
*** 返回数据
#+BEGIN_SRC JSON
{
"OrderType": 1,
"PayChannelType": 3,
"DeviceType": 2,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "00",
"ResponseMsg": "交易成功",
"PosTrace": "115923",
"OrderDateTime": "20180119115923",
"OrderNo": "113507",
"HostOrderNo": "180119115825030210",
"PlatOrderNo": "",
"OrderAmt": "1",
"CurrencyType": "",
"TradeStatus": "0",
"tn": "https://qrpay.paxpay.cn/qr/gateway/qrpay.html?development=true&qrtoken=o6pvw5s1QTE3QjEyNTc2ODc1RDQxMjI2OUVENUQwMjhFODM1OTA="
}
#+END_SRC
#ifndef _TWY_INI_H_
#define _TWY_INI_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define COMMENT '#'
#define INI_ERROR -1
struct record {
char comments[255];
char key[255];
char value[255];
struct record *next;
};
struct section {
struct record * data_first;
struct record * data_last;
unsigned int data_size;
char comments[255];
char name[255];
struct section *next;
};
typedef struct
{
unsigned int section_size;
struct section *first;
struct section *last;
} content;
typedef enum {
REPLACE = 1,
NON_REPLACE = 0
} REPLACE_FLAG;
class TwyINI
{
public:
TwyINI(void);
~TwyINI(void);
private:
content *ini_content;
char szIniFileName[255];
char error_msg[256];
int w_flag;
private:
bool load(const char *filename);
void init_content();
void clear();
void add_section(const char *sec, const char *comment);
void _append(const char *sec, const char *key, const char *value, const char *comment);
int content_size();
int section_size(char *sec);
struct section *get_section(const char *sec);
struct record * get_record(struct section *sec, const char *key);
void trim(char *buffer);
void _print_allrecord(struct record *sec);
public:
bool Open(const char *filename);
char *get_value(const char *sec, const char *key);
void Close();
void print_content();
void print_allrecord(char *sec);
char *get_last_error();
};
#endif
#ifndef _TWY_TRACE_H_
#define _TWY_TRACE_H_
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
// 显示十六进制数据时 每一行打印16个字节的数据
#define TRACE_HEX_COLS 16
class TwyTRACE
{
public:
TwyTRACE();
~TwyTRACE();
public:
void SetTraceLevel(int iLevel);
void SetFileName(char *szFileName);
bool WriteTxtTrace(int iLevel, const char *msg, ...);
bool WriteHexTrace(int iLevel, unsigned char *msg, int iLength);
private:
char *GetCurrentDate();
char *GetCurrentTime();
bool Lock();
bool UnLock();
private:
char szFileName[255];
int iMaxLevel;
char szTimeString[32];
char szDateString[32];
};
#endif
#ifndef BCCCODE_H
#define BCCCODE_H
#include "cJSON.h"
#include "common.h"
int BCC_str_set_val_raw(const char *key, const char *val, char *out, int *len);
int BCC_str_set_val_url(const char *key, const char *val, char *out, int *len);
int BCC_json_set_val(const char *key, const char *val, char *out, int *len);
int BCC_json_get_val(const cJSON *pJson, const char *key, char *out, size_t len);
int BCC_url_decode(const char *str, const int strSize, char *result, int resultSize);
int BCC_url_encode(const char *str, const int strSize, char *result, const int resultSize);
int BCC_code_upper_str(char *str, int len);
#endif /* BCCCODE_H */
/* This file was automatically generated. Do not edit! */
#ifndef BCCMD5_H
#define BCCMD5_H
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void BCC_MD5_gen(unsigned char *in, unsigned char *out);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif /* BCCMD5_H */
/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef cJSON__h
#define cJSON__h
#ifdef __cplusplus
extern "C"
{
#endif
/* project version */
#define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 7
#define CJSON_VERSION_PATCH 0
#include <stddef.h>
/* cJSON Types: */
#define cJSON_Invalid (0)
#define cJSON_False (1 << 0)
#define cJSON_True (1 << 1)
#define cJSON_NULL (1 << 2)
#define cJSON_Number (1 << 3)
#define cJSON_String (1 << 4)
#define cJSON_Array (1 << 5)
#define cJSON_Object (1 << 6)
#define cJSON_Raw (1 << 7) /* raw json */
#define cJSON_IsReference 256
#define cJSON_StringIsConst 512
/* The cJSON structure: */
typedef struct cJSON
{
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *next;
struct cJSON *prev;
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
struct cJSON *child;
/* The type of the item, as above. */
int type;
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
char *valuestring;
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
int valueint;
/* The item's number, if type==cJSON_Number */
double valuedouble;
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
char *string;
} cJSON;
typedef struct cJSON_Hooks
{
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
} cJSON_Hooks;
typedef int cJSON_bool;
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
#define __WINDOWS__
#endif
#ifdef __WINDOWS__
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 2 define options:
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
For *nix builds that support visibility attribute, you can define similar behavior by
setting default visibility to hidden by adding
-fvisibility=hidden (for gcc)
or
-xldscope=hidden (for sun cc)
to CFLAGS
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
*/
/* export symbols by default, this is necessary for copy pasting the C and header file */
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_EXPORT_SYMBOLS
#endif
#if defined(CJSON_HIDE_SYMBOLS)
#define CJSON_PUBLIC(type) type __stdcall
#elif defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllexport) type __stdcall
#elif defined(CJSON_IMPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllimport) type __stdcall
#endif
#else /* !WIN32 */
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
#else
#define CJSON_PUBLIC(type) type
#endif
#endif
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
* This is to prevent stack overflows. */
#ifndef CJSON_NESTING_LIMIT
#define CJSON_NESTING_LIMIT 1000
#endif
/* returns the version of cJSON as a string */
CJSON_PUBLIC(const char*) cJSON_Version(void);
/* Supply malloc, realloc and free functions to cJSON */
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
/* Render a cJSON entity to text for transfer/storage. */
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. */
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
/* Delete a cJSON entity and all subentities. */
CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
/* Get item "string" from object. Case insensitive. */
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
/* Check if the item is a string and return its valuestring */
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item);
/* These functions check the type of an item */
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
/* These calls create a cJSON item of the appropriate type. */
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
/* raw json */
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
/* Create a string where valuestring references a string so
* it will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
/* Create an object/arrray that only references it's elements so
* they will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
/* These utilities create an Array of count items. */
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
/* Append item to the specified array/object. */
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
* writing to `item->string` */
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
/* Update array items. */
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
/* Duplicate a cJSON item */
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
need to be released. With recurse!=0, it will duplicate any children connected to the item.
The item->next and ->prev pointers are always zero on return from Duplicate. */
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
CJSON_PUBLIC(void) cJSON_Minify(char *json);
/* Helper functions for creating and adding items to an object at the same time.
* They return the added item or NULL on failure. */
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
/* helper for the cJSON_SetNumberValue macro */
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
/* Macro for iterating over an array or object */
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
CJSON_PUBLIC(void) cJSON_free(void *object);
#ifdef __cplusplus
}
#endif
#endif
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_xingdata_zzdpos_zxpay */
#ifndef _Included_com_xingdata_zzdpos_zxpay
#define _Included_com_xingdata_zzdpos_zxpay
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_xingdata_zzdpos_zxpay
* Method: jsonpay
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_xingdata_zzdpos_zxpay_jsonpay(JNIEnv *, jclass, jstring);
#ifdef __cplusplus
}
#endif
#endif
#ifndef COMMON_H
#define COMMON_H
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdarg.h>
#include <time.h>
#endif /* COMMON_H */
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef __CURL_CURLVER_H
#define __CURL_CURLVER_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* This header file contains nothing but libcurl version info, generated by
a script at release-time. This was made its own header file in 7.11.2 */
/* This is the global package copyright */
#define LIBCURL_COPYRIGHT "1996 - 2017 Daniel Stenberg, <daniel@haxx.se>."
/* This is the version number of the libcurl package from which this header
file origins: */
#define LIBCURL_VERSION "7.57.0"
/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 7
#define LIBCURL_VERSION_MINOR 57
#define LIBCURL_VERSION_PATCH 0
/* This is the numeric version of the libcurl version number, meant for easier
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
always follow this syntax:
0xXXYYZZ
Where XX, YY and ZZ are the main version, release and patch numbers in
hexadecimal (using 8 bits each). All three numbers are always represented
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
appears as "0x090b07".
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
and it is always a greater number in a more recent release. It makes
comparisons with greater than and less than work.
Note: This define is the full hex number and _does not_ use the
CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number.
*/
#define LIBCURL_VERSION_NUM 0x073900
/*
* This is the date and time when the full source package was created. The
* timestamp is not stored in git, as the timestamp is properly set in the
* tarballs by the maketgz script.
*
* The format of the date follows this template:
*
* "2007-11-23"
*/
#define LIBCURL_TIMESTAMP "2017-11-29"
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z)
#define CURL_AT_LEAST_VERSION(x,y,z) \
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
#endif /* __CURL_CURLVER_H */
#ifndef __CURL_EASY_H
#define __CURL_EASY_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
CURL_EXTERN CURL *curl_easy_init(void);
CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
CURL_EXTERN void curl_easy_cleanup(CURL *curl);
/*
* NAME curl_easy_getinfo()
*
* DESCRIPTION
*
* Request internal information from the curl session with this function. The
* third argument MUST be a pointer to a long, a pointer to a char * or a
* pointer to a double (as the documentation describes elsewhere). The data
* pointed to will be filled in accordingly and can be relied upon only if the
* function returns CURLE_OK. This function is intended to get used *AFTER* a
* performed transfer, all results from this function are undefined until the
* transfer is completed.
*/
CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
/*
* NAME curl_easy_duphandle()
*
* DESCRIPTION
*
* Creates a new curl session handle with the same options set for the handle
* passed in. Duplicating a handle could only be a matter of cloning data and
* options, internal state info and things like persistent connections cannot
* be transferred. It is useful in multithreaded applications when you can run
* curl_easy_duphandle() for each new thread to avoid a series of identical
* curl_easy_setopt() invokes in every thread.
*/
CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
/*
* NAME curl_easy_reset()
*
* DESCRIPTION
*
* Re-initializes a CURL handle to the default values. This puts back the
* handle to the same state as it was in when it was just created.
*
* It does keep: live connections, the Session ID cache, the DNS cache and the
* cookies.
*/
CURL_EXTERN void curl_easy_reset(CURL *curl);
/*
* NAME curl_easy_recv()
*
* DESCRIPTION
*
* Receives data from the connected socket. Use after successful
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
*/
CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
size_t *n);
/*
* NAME curl_easy_send()
*
* DESCRIPTION
*
* Sends data over the connected socket. Use after successful
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
*/
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
size_t buflen, size_t *n);
#ifdef __cplusplus
}
#endif
#endif
#ifndef __CURL_MPRINTF_H
#define __CURL_MPRINTF_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include <stdarg.h>
#include <stdio.h> /* needed for FILE */
#include "curl.h" /* for CURL_EXTERN */
#ifdef __cplusplus
extern "C" {
#endif
CURL_EXTERN int curl_mprintf(const char *format, ...);
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);
CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
const char *format, ...);
CURL_EXTERN int curl_mvprintf(const char *format, va_list args);
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);
CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
const char *format, va_list args);
CURL_EXTERN char *curl_maprintf(const char *format, ...);
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
#ifdef __cplusplus
}
#endif
#endif /* __CURL_MPRINTF_H */
#ifndef __CURL_MULTI_H
#define __CURL_MULTI_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
This is an "external" header file. Don't give away any internals here!
GOALS
o Enable a "pull" interface. The application that uses libcurl decides where
and when to ask libcurl to get/send data.
o Enable multiple simultaneous transfers in the same thread without making it
complicated for the application.
o Enable the application to select() on its own file descriptors and curl's
file descriptors simultaneous easily.
*/
/*
* This header file should not really need to include "curl.h" since curl.h
* itself includes this file and we expect user applications to do #include
* <curl/curl.h> without the need for especially including multi.h.
*
* For some reason we added this include here at one point, and rather than to
* break existing (wrongly written) libcurl applications, we leave it as-is
* but with this warning attached.
*/
#include "curl.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
typedef struct Curl_multi CURLM;
#else
typedef void CURLM;
#endif
typedef enum {
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
curl_multi_socket*() soon */
CURLM_OK,
CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
attempted to get added - again */
CURLM_LAST
} CURLMcode;
/* just to make code nicer when using curl_multi_socket() you can now check
for CURLM_CALL_MULTI_SOCKET too in the same style it works for
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
/* bitmask bits for CURLMOPT_PIPELINING */
#define CURLPIPE_NOTHING 0L
#define CURLPIPE_HTTP1 1L
#define CURLPIPE_MULTIPLEX 2L
typedef enum {
CURLMSG_NONE, /* first, not used */
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
the CURLcode of the transfer */
CURLMSG_LAST /* last, not used */
} CURLMSG;
struct CURLMsg {
CURLMSG msg; /* what this message means */
CURL *easy_handle; /* the handle it concerns */
union {
void *whatever; /* message-specific data */
CURLcode result; /* return code for transfer */
} data;
};
typedef struct CURLMsg CURLMsg;
/* Based on poll(2) structure and values.
* We don't use pollfd and POLL* constants explicitly
* to cover platforms without poll(). */
#define CURL_WAIT_POLLIN 0x0001
#define CURL_WAIT_POLLPRI 0x0002
#define CURL_WAIT_POLLOUT 0x0004
struct curl_waitfd {
curl_socket_t fd;
short events;
short revents; /* not supported yet */
};
/*
* Name: curl_multi_init()
*
* Desc: inititalize multi-style curl usage
*
* Returns: a new CURLM handle to use in all 'curl_multi' functions.
*/
CURL_EXTERN CURLM *curl_multi_init(void);
/*
* Name: curl_multi_add_handle()
*
* Desc: add a standard curl handle to the multi stack
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
CURL *curl_handle);
/*
* Name: curl_multi_remove_handle()
*
* Desc: removes a curl handle from the multi stack again
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
CURL *curl_handle);
/*
* Name: curl_multi_fdset()
*
* Desc: Ask curl for its fd_set sets. The app can use these to select() or
* poll() on. We want curl_multi_perform() called as soon as one of
* them are ready.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
fd_set *read_fd_set,
fd_set *write_fd_set,
fd_set *exc_fd_set,
int *max_fd);
/*
* Name: curl_multi_wait()
*
* Desc: Poll on all fds within a CURLM set as well as any
* additional fds passed to the function.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
struct curl_waitfd extra_fds[],
unsigned int extra_nfds,
int timeout_ms,
int *ret);
/*
* Name: curl_multi_perform()
*
* Desc: When the app thinks there's data available for curl it calls this
* function to read/write whatever there is right now. This returns
* as soon as the reads and writes are done. This function does not
* require that there actually is data available for reading or that
* data can be written, it can be called just in case. It returns
* the number of handles that still transfer data in the second
* argument's integer-pointer.
*
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
* returns errors etc regarding the whole multi stack. There might
* still have occurred problems on invidual transfers even when this
* returns OK.
*/
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
int *running_handles);
/*
* Name: curl_multi_cleanup()
*
* Desc: Cleans up and removes a whole multi stack. It does not free or
* touch any individual easy handles in any way. We need to define
* in what state those handles will be if this function is called
* in the middle of a transfer.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
/*
* Name: curl_multi_info_read()
*
* Desc: Ask the multi handle if there's any messages/informationals from
* the individual transfers. Messages include informationals such as
* error code from the transfer or just the fact that a transfer is
* completed. More details on these should be written down as well.
*
* Repeated calls to this function will return a new struct each
* time, until a special "end of msgs" struct is returned as a signal
* that there is no more to get at this point.
*
* The data the returned pointer points to will not survive calling
* curl_multi_cleanup().
*
* The 'CURLMsg' struct is meant to be very simple and only contain
* very basic information. If more involved information is wanted,
* we will provide the particular "transfer handle" in that struct
* and that should/could/would be used in subsequent
* curl_easy_getinfo() calls (or similar). The point being that we
* must never expose complex structs to applications, as then we'll
* undoubtably get backwards compatibility problems in the future.
*
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
* of structs. It also writes the number of messages left in the
* queue (after this read) in the integer the second argument points
* to.
*/
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
int *msgs_in_queue);
/*
* Name: curl_multi_strerror()
*
* Desc: The curl_multi_strerror function may be used to turn a CURLMcode
* value into the equivalent human readable error string. This is
* useful for printing meaningful error messages.
*
* Returns: A pointer to a zero-terminated error message.
*/
CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
/*
* Name: curl_multi_socket() and
* curl_multi_socket_all()
*
* Desc: An alternative version of curl_multi_perform() that allows the
* application to pass in one of the file descriptors that have been
* detected to have "action" on them and let libcurl perform.
* See man page for details.
*/
#define CURL_POLL_NONE 0
#define CURL_POLL_IN 1
#define CURL_POLL_OUT 2
#define CURL_POLL_INOUT 3
#define CURL_POLL_REMOVE 4
#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
#define CURL_CSELECT_IN 0x01
#define CURL_CSELECT_OUT 0x02
#define CURL_CSELECT_ERR 0x04
typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
curl_socket_t s, /* socket */
int what, /* see above */
void *userp, /* private callback
pointer */
void *socketp); /* private socket
pointer */
/*
* Name: curl_multi_timer_callback
*
* Desc: Called by libcurl whenever the library detects a change in the
* maximum number of milliseconds the app is allowed to wait before
* curl_multi_socket() or curl_multi_perform() must be called
* (to allow libcurl's timed events to take place).
*
* Returns: The callback should return zero.
*/
typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
long timeout_ms, /* see above */
void *userp); /* private callback
pointer */
CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
int *running_handles);
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
curl_socket_t s,
int ev_bitmask,
int *running_handles);
CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
int *running_handles);
#ifndef CURL_ALLOW_OLD_MULTI_SOCKET
/* This macro below was added in 7.16.3 to push users who recompile to use
the new curl_multi_socket_action() instead of the old curl_multi_socket()
*/
#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
#endif
/*
* Name: curl_multi_timeout()
*
* Desc: Returns the maximum number of milliseconds the app is allowed to
* wait before curl_multi_socket() or curl_multi_perform() must be
* called (to allow libcurl's timed events to take place).
*
* Returns: CURLM error code.
*/
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
long *milliseconds);
#undef CINIT /* re-using the same name as in curl.h */
#ifdef CURL_ISOCPP
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
#else
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
#define LONG CURLOPTTYPE_LONG
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
#define OFF_T CURLOPTTYPE_OFF_T
#define CINIT(name,type,number) CURLMOPT_/**/name = type + number
#endif
typedef enum {
/* This is the socket callback function pointer */
CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
/* This is the argument passed to the socket callback */
CINIT(SOCKETDATA, OBJECTPOINT, 2),
/* set to 1 to enable pipelining for this multi handle */
CINIT(PIPELINING, LONG, 3),
/* This is the timer callback function pointer */
CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
/* This is the argument passed to the timer callback */
CINIT(TIMERDATA, OBJECTPOINT, 5),
/* maximum number of entries in the connection cache */
CINIT(MAXCONNECTS, LONG, 6),
/* maximum number of (pipelining) connections to one host */
CINIT(MAX_HOST_CONNECTIONS, LONG, 7),
/* maximum number of requests in a pipeline */
CINIT(MAX_PIPELINE_LENGTH, LONG, 8),
/* a connection with a content-length longer than this
will not be considered for pipelining */
CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9),
/* a connection with a chunk length longer than this
will not be considered for pipelining */
CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10),
/* a list of site names(+port) that are blacklisted from
pipelining */
CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11),
/* a list of server types that are blacklisted from
pipelining */
CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12),
/* maximum number of open connections in total */
CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13),
/* This is the server push callback function pointer */
CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14),
/* This is the argument passed to the server push callback */
CINIT(PUSHDATA, OBJECTPOINT, 15),
CURLMOPT_LASTENTRY /* the last unused */
} CURLMoption;
/*
* Name: curl_multi_setopt()
*
* Desc: Sets options for the multi handle.
*
* Returns: CURLM error code.
*/
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
CURLMoption option, ...);
/*
* Name: curl_multi_assign()
*
* Desc: This function sets an association in the multi handle between the
* given socket and a private pointer of the application. This is
* (only) useful for curl_multi_socket uses.
*
* Returns: CURLM error code.
*/
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
curl_socket_t sockfd, void *sockp);
/*
* Name: curl_push_callback
*
* Desc: This callback gets called when a new stream is being pushed by the
* server. It approves or denies the new stream.
*
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
*/
#define CURL_PUSH_OK 0
#define CURL_PUSH_DENY 1
struct curl_pushheaders; /* forward declaration only */
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
size_t num);
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
const char *name);
typedef int (*curl_push_callback)(CURL *parent,
CURL *easy,
size_t num_headers,
struct curl_pushheaders *headers,
void *userp);
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif
#ifndef __STDC_HEADERS_H
#define __STDC_HEADERS_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include <sys/types.h>
size_t fread(void *, size_t, size_t, FILE *);
size_t fwrite(const void *, size_t, size_t, FILE *);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
#endif /* __STDC_HEADERS_H */
#ifndef __CURL_SYSTEM_H
#define __CURL_SYSTEM_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* Try to keep one section per platform, compiler and architecture, otherwise,
* if an existing section is reused for a different one and later on the
* original is adjusted, probably the piggybacking one can be adversely
* changed.
*
* In order to differentiate between platforms/compilers/architectures use
* only compiler built in predefined preprocessor symbols.
*
* curl_off_t
* ----------
*
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
* wide signed integral data type. The width of this data type must remain
* constant and independent of any possible large file support settings.
*
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
* wide signed integral data type if there is no 64-bit type.
*
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
* only be violated if off_t is the only 64-bit data type available and the
* size of off_t is independent of large file support settings. Keep your
* build on the safe side avoiding an off_t gating. If you have a 64-bit
* off_t then take for sure that another 64-bit data type exists, dig deeper
* and you will find it.
*
*/
#if defined(__DJGPP__) || defined(__GO32__)
# if defined(__DJGPP__) && (__DJGPP__ > 1)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__SALFORDC__)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__BORLANDC__)
# if (__BORLANDC__ < 0x520)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__TURBOC__)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__WATCOMC__)
# if defined(__386__)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__POCC__)
# if (__POCC__ < 280)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# elif defined(_MSC_VER)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__LCC__)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__SYMBIAN32__)
# if defined(__EABI__) /* Treat all ARM compilers equally */
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__CW32__)
# pragma longlong on
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__VC32__)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
#elif defined(__MWERKS__)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(_WIN32_WCE)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__MINGW32__)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_WS2TCPIP_H 1
#elif defined(__VMS)
# if defined(__VAX)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
#elif defined(__OS400__)
# if defined(__ILEC400__)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__MVS__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# elif defined(_LP64)
# endif
# if defined(_LONG_LONG)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(_LP64)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__370__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# elif defined(_LP64)
# endif
# if defined(_LONG_LONG)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(_LP64)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(TPF)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__TINYC__) /* also known as tcc */
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
#elif defined(__SUNPRO_C) /* Oracle Solaris Studio */
# if !defined(__LP64) && (defined(__ILP32) || \
defined(__i386) || defined(__sparcv8))
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__LP64) || \
defined(__amd64) || defined(__sparcv9)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
/* ===================================== */
/* KEEP MSVC THE PENULTIMATE ENTRY */
/* ===================================== */
#elif defined(_MSC_VER)
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
/* ===================================== */
/* KEEP GENERIC GCC THE LAST ENTRY */
/* ===================================== */
#elif defined(__GNUC__)
# if !defined(__LP64__) && \
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
defined(__XTENSA__) || \
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4))
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__LP64__) || \
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
#else
/* generic "safe guess" on old 32 bit style */
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#endif
#ifdef _AIX
/* AIX needs <sys/poll.h> */
#define CURL_PULL_SYS_POLL_H
#endif
/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
/* ws2tcpip.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_WS2TCPIP_H
# include <winsock2.h>
# include <windows.h>
# include <ws2tcpip.h>
#endif
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
/* sys/types.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_TYPES_H
# include <sys/types.h>
#endif
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
/* sys/socket.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_SOCKET_H
# include <sys/socket.h>
#endif
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
/* sys/poll.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_POLL_H
# include <sys/poll.h>
#endif
/* Data type definition of curl_socklen_t. */
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
#endif
/* Data type definition of curl_off_t. */
#ifdef CURL_TYPEOF_CURL_OFF_T
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
#endif
/*
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
* these to be visible and exported by the external libcurl interface API,
* while also making them visible to the library internals, simply including
* curl_setup.h, without actually needing to include curl.h internally.
* If some day this section would grow big enough, all this should be moved
* to its own header file.
*/
/*
* Figure out if we can use the ## preprocessor operator, which is supported
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
* or __cplusplus so we need to carefully check for them too.
*/
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
defined(__ILEC400__)
/* This compiler is believed to have an ISO compatible preprocessor */
#define CURL_ISOCPP
#else
/* This compiler is believed NOT to have an ISO compatible preprocessor */
#undef CURL_ISOCPP
#endif
/*
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
*/
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
# define __CURL_OFF_T_C_HLPR2(x) x
# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
#else
# ifdef CURL_ISOCPP
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
# else
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
# endif
# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
#endif
#endif /* __CURL_SYSTEM_H */
#ifndef __CURL_TYPECHECK_GCC_H
#define __CURL_TYPECHECK_GCC_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* wraps curl_easy_setopt() with typechecking */
/* To add a new kind of warning, add an
* if(_curl_is_sometype_option(_curl_opt))
* if(!_curl_is_sometype(value))
* _curl_easy_setopt_err_sometype();
* block and define _curl_is_sometype_option, _curl_is_sometype and
* _curl_easy_setopt_err_sometype below
*
* NOTE: We use two nested 'if' statements here instead of the && operator, in
* order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
* when compiling with -Wlogical-op.
*
* To add an option that uses the same type as an existing option, you'll just
* need to extend the appropriate _curl_*_option macro
*/
#define curl_easy_setopt(handle, option, value) \
__extension__ ({ \
__typeof__(option) _curl_opt = option; \
if(__builtin_constant_p(_curl_opt)) { \
if(_curl_is_long_option(_curl_opt)) \
if(!_curl_is_long(value)) \
_curl_easy_setopt_err_long(); \
if(_curl_is_off_t_option(_curl_opt)) \
if(!_curl_is_off_t(value)) \
_curl_easy_setopt_err_curl_off_t(); \
if(_curl_is_string_option(_curl_opt)) \
if(!_curl_is_string(value)) \
_curl_easy_setopt_err_string(); \
if(_curl_is_write_cb_option(_curl_opt)) \
if(!_curl_is_write_cb(value)) \
_curl_easy_setopt_err_write_callback(); \
if((_curl_opt) == CURLOPT_READFUNCTION) \
if(!_curl_is_read_cb(value)) \
_curl_easy_setopt_err_read_cb(); \
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
if(!_curl_is_ioctl_cb(value)) \
_curl_easy_setopt_err_ioctl_cb(); \
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
if(!_curl_is_sockopt_cb(value)) \
_curl_easy_setopt_err_sockopt_cb(); \
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
if(!_curl_is_opensocket_cb(value)) \
_curl_easy_setopt_err_opensocket_cb(); \
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
if(!_curl_is_progress_cb(value)) \
_curl_easy_setopt_err_progress_cb(); \
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
if(!_curl_is_debug_cb(value)) \
_curl_easy_setopt_err_debug_cb(); \
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
if(!_curl_is_ssl_ctx_cb(value)) \
_curl_easy_setopt_err_ssl_ctx_cb(); \
if(_curl_is_conv_cb_option(_curl_opt)) \
if(!_curl_is_conv_cb(value)) \
_curl_easy_setopt_err_conv_cb(); \
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
if(!_curl_is_seek_cb(value)) \
_curl_easy_setopt_err_seek_cb(); \
if(_curl_is_cb_data_option(_curl_opt)) \
if(!_curl_is_cb_data(value)) \
_curl_easy_setopt_err_cb_data(); \
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
if(!_curl_is_error_buffer(value)) \
_curl_easy_setopt_err_error_buffer(); \
if((_curl_opt) == CURLOPT_STDERR) \
if(!_curl_is_FILE(value)) \
_curl_easy_setopt_err_FILE(); \
if(_curl_is_postfields_option(_curl_opt)) \
if(!_curl_is_postfields(value)) \
_curl_easy_setopt_err_postfields(); \
if((_curl_opt) == CURLOPT_HTTPPOST) \
if(!_curl_is_arr((value), struct curl_httppost)) \
_curl_easy_setopt_err_curl_httpost(); \
if((_curl_opt) == CURLOPT_MIMEPOST) \
if(!_curl_is_ptr((value), curl_mime)) \
_curl_easy_setopt_err_curl_mimepost(); \
if(_curl_is_slist_option(_curl_opt)) \
if(!_curl_is_arr((value), struct curl_slist)) \
_curl_easy_setopt_err_curl_slist(); \
if((_curl_opt) == CURLOPT_SHARE) \
if(!_curl_is_ptr((value), CURLSH)) \
_curl_easy_setopt_err_CURLSH(); \
} \
curl_easy_setopt(handle, _curl_opt, value); \
})
/* wraps curl_easy_getinfo() with typechecking */
/* FIXME: don't allow const pointers */
#define curl_easy_getinfo(handle, info, arg) \
__extension__ ({ \
__typeof__(info) _curl_info = info; \
if(__builtin_constant_p(_curl_info)) { \
if(_curl_is_string_info(_curl_info)) \
if(!_curl_is_arr((arg), char *)) \
_curl_easy_getinfo_err_string(); \
if(_curl_is_long_info(_curl_info)) \
if(!_curl_is_arr((arg), long)) \
_curl_easy_getinfo_err_long(); \
if(_curl_is_double_info(_curl_info)) \
if(!_curl_is_arr((arg), double)) \
_curl_easy_getinfo_err_double(); \
if(_curl_is_slist_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_slist *)) \
_curl_easy_getinfo_err_curl_slist(); \
if(_curl_is_tlssessioninfo_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_tlssessioninfo *)) \
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
if(_curl_is_certinfo_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_certinfo *)) \
_curl_easy_getinfo_err_curl_certinfo(); \
if(_curl_is_socket_info(_curl_info)) \
if(!_curl_is_arr((arg), curl_socket_t)) \
_curl_easy_getinfo_err_curl_socket(); \
if(_curl_is_off_t_info(_curl_info)) \
if(!_curl_is_arr((arg), curl_off_t)) \
_curl_easy_getinfo_err_curl_off_t(); \
} \
curl_easy_getinfo(handle, _curl_info, arg); \
})
/* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(),
* for now just make sure that the functions are called with three
* arguments
*/
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
/* the actual warnings, triggered by calling the _curl_easy_setopt_err*
* functions */
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
#define _CURL_WARNING(id, message) \
static void __attribute__((__warning__(message))) \
__attribute__((__unused__)) __attribute__((__noinline__)) \
id(void) { __asm__(""); }
_CURL_WARNING(_curl_easy_setopt_err_long,
"curl_easy_setopt expects a long argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_curl_off_t,
"curl_easy_setopt expects a curl_off_t argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_string,
"curl_easy_setopt expects a "
"string ('char *' or char[]) argument for this option"
)
_CURL_WARNING(_curl_easy_setopt_err_write_callback,
"curl_easy_setopt expects a curl_write_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_read_cb,
"curl_easy_setopt expects a curl_read_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,
"curl_easy_setopt expects a "
"curl_opensocket_callback argument for this option"
)
_CURL_WARNING(_curl_easy_setopt_err_progress_cb,
"curl_easy_setopt expects a curl_progress_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_debug_cb,
"curl_easy_setopt expects a curl_debug_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb,
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_conv_cb,
"curl_easy_setopt expects a curl_conv_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_seek_cb,
"curl_easy_setopt expects a curl_seek_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_cb_data,
"curl_easy_setopt expects a "
"private data pointer as argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_error_buffer,
"curl_easy_setopt expects a "
"char buffer of CURL_ERROR_SIZE as argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_FILE,
"curl_easy_setopt expects a 'FILE *' argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_postfields,
"curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_curl_httpost,
"curl_easy_setopt expects a 'struct curl_httppost *' "
"argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_curl_mimepost,
"curl_easy_setopt expects a 'curl_mime *' "
"argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_curl_slist,
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_CURLSH,
"curl_easy_setopt expects a CURLSH* argument for this option")
_CURL_WARNING(_curl_easy_getinfo_err_string,
"curl_easy_getinfo expects a pointer to 'char *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_long,
"curl_easy_getinfo expects a pointer to long for this info")
_CURL_WARNING(_curl_easy_getinfo_err_double,
"curl_easy_getinfo expects a pointer to double for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
"curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
"curl_easy_getinfo expects a pointer to "
"'struct curl_tlssessioninfo *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_certinfo,
"curl_easy_getinfo expects a pointer to "
"'struct curl_certinfo *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_off_t,
"curl_easy_getinfo expects a pointer to curl_off_t for this info")
/* groups of curl_easy_setops options that take the same type of argument */
/* To add a new option to one of the groups, just add
* (option) == CURLOPT_SOMETHING
* to the or-expression. If the option takes a long or curl_off_t, you don't
* have to do anything
*/
/* evaluates to true if option takes a long argument */
#define _curl_is_long_option(option) \
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
#define _curl_is_off_t_option(option) \
((option) > CURLOPTTYPE_OFF_T)
/* evaluates to true if option takes a char* argument */
#define _curl_is_string_option(option) \
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
(option) == CURLOPT_ACCEPT_ENCODING || \
(option) == CURLOPT_CAINFO || \
(option) == CURLOPT_CAPATH || \
(option) == CURLOPT_COOKIE || \
(option) == CURLOPT_COOKIEFILE || \
(option) == CURLOPT_COOKIEJAR || \
(option) == CURLOPT_COOKIELIST || \
(option) == CURLOPT_CRLFILE || \
(option) == CURLOPT_CUSTOMREQUEST || \
(option) == CURLOPT_DEFAULT_PROTOCOL || \
(option) == CURLOPT_DNS_INTERFACE || \
(option) == CURLOPT_DNS_LOCAL_IP4 || \
(option) == CURLOPT_DNS_LOCAL_IP6 || \
(option) == CURLOPT_DNS_SERVERS || \
(option) == CURLOPT_EGDSOCKET || \
(option) == CURLOPT_FTPPORT || \
(option) == CURLOPT_FTP_ACCOUNT || \
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
(option) == CURLOPT_INTERFACE || \
(option) == CURLOPT_ISSUERCERT || \
(option) == CURLOPT_KEYPASSWD || \
(option) == CURLOPT_KRBLEVEL || \
(option) == CURLOPT_LOGIN_OPTIONS || \
(option) == CURLOPT_MAIL_AUTH || \
(option) == CURLOPT_MAIL_FROM || \
(option) == CURLOPT_NETRC_FILE || \
(option) == CURLOPT_NOPROXY || \
(option) == CURLOPT_PASSWORD || \
(option) == CURLOPT_PINNEDPUBLICKEY || \
(option) == CURLOPT_PRE_PROXY || \
(option) == CURLOPT_PROXY || \
(option) == CURLOPT_PROXYPASSWORD || \
(option) == CURLOPT_PROXYUSERNAME || \
(option) == CURLOPT_PROXYUSERPWD || \
(option) == CURLOPT_PROXY_CAINFO || \
(option) == CURLOPT_PROXY_CAPATH || \
(option) == CURLOPT_PROXY_CRLFILE || \
(option) == CURLOPT_PROXY_KEYPASSWD || \
(option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
(option) == CURLOPT_PROXY_SERVICE_NAME || \
(option) == CURLOPT_PROXY_SSLCERT || \
(option) == CURLOPT_PROXY_SSLCERTTYPE || \
(option) == CURLOPT_PROXY_SSLKEY || \
(option) == CURLOPT_PROXY_SSLKEYTYPE || \
(option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
(option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
(option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
(option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
(option) == CURLOPT_RANDOM_FILE || \
(option) == CURLOPT_RANGE || \
(option) == CURLOPT_REFERER || \
(option) == CURLOPT_RTSP_SESSION_ID || \
(option) == CURLOPT_RTSP_STREAM_URI || \
(option) == CURLOPT_RTSP_TRANSPORT || \
(option) == CURLOPT_SERVICE_NAME || \
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
(option) == CURLOPT_SSH_KNOWNHOSTS || \
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
(option) == CURLOPT_SSLCERT || \
(option) == CURLOPT_SSLCERTTYPE || \
(option) == CURLOPT_SSLENGINE || \
(option) == CURLOPT_SSLKEY || \
(option) == CURLOPT_SSLKEYTYPE || \
(option) == CURLOPT_SSL_CIPHER_LIST || \
(option) == CURLOPT_TLSAUTH_PASSWORD || \
(option) == CURLOPT_TLSAUTH_TYPE || \
(option) == CURLOPT_TLSAUTH_USERNAME || \
(option) == CURLOPT_UNIX_SOCKET_PATH || \
(option) == CURLOPT_URL || \
(option) == CURLOPT_USERAGENT || \
(option) == CURLOPT_USERNAME || \
(option) == CURLOPT_USERPWD || \
(option) == CURLOPT_XOAUTH2_BEARER || \
0)
/* evaluates to true if option takes a curl_write_callback argument */
#define _curl_is_write_cb_option(option) \
((option) == CURLOPT_HEADERFUNCTION || \
(option) == CURLOPT_WRITEFUNCTION)
/* evaluates to true if option takes a curl_conv_callback argument */
#define _curl_is_conv_cb_option(option) \
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
/* evaluates to true if option takes a data argument to pass to a callback */
#define _curl_is_cb_data_option(option) \
((option) == CURLOPT_CHUNK_DATA || \
(option) == CURLOPT_CLOSESOCKETDATA || \
(option) == CURLOPT_DEBUGDATA || \
(option) == CURLOPT_FNMATCH_DATA || \
(option) == CURLOPT_HEADERDATA || \
(option) == CURLOPT_INTERLEAVEDATA || \
(option) == CURLOPT_IOCTLDATA || \
(option) == CURLOPT_OPENSOCKETDATA || \
(option) == CURLOPT_PRIVATE || \
(option) == CURLOPT_PROGRESSDATA || \
(option) == CURLOPT_READDATA || \
(option) == CURLOPT_SEEKDATA || \
(option) == CURLOPT_SOCKOPTDATA || \
(option) == CURLOPT_SSH_KEYDATA || \
(option) == CURLOPT_SSL_CTX_DATA || \
(option) == CURLOPT_WRITEDATA || \
0)
/* evaluates to true if option takes a POST data argument (void* or char*) */
#define _curl_is_postfields_option(option) \
((option) == CURLOPT_POSTFIELDS || \
(option) == CURLOPT_COPYPOSTFIELDS || \
0)
/* evaluates to true if option takes a struct curl_slist * argument */
#define _curl_is_slist_option(option) \
((option) == CURLOPT_HTTP200ALIASES || \
(option) == CURLOPT_HTTPHEADER || \
(option) == CURLOPT_MAIL_RCPT || \
(option) == CURLOPT_POSTQUOTE || \
(option) == CURLOPT_PREQUOTE || \
(option) == CURLOPT_PROXYHEADER || \
(option) == CURLOPT_QUOTE || \
(option) == CURLOPT_RESOLVE || \
(option) == CURLOPT_TELNETOPTIONS || \
0)
/* groups of curl_easy_getinfo infos that take the same type of argument */
/* evaluates to true if info expects a pointer to char * argument */
#define _curl_is_string_info(info) \
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)
/* evaluates to true if info expects a pointer to long argument */
#define _curl_is_long_info(info) \
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
/* evaluates to true if info expects a pointer to double argument */
#define _curl_is_double_info(info) \
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
/* true if info expects a pointer to struct curl_slist * argument */
#define _curl_is_slist_info(info) \
(((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
#define _curl_is_tlssessioninfo_info(info) \
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
/* true if info expects a pointer to struct curl_certinfo * argument */
#define _curl_is_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
/* true if info expects a pointer to struct curl_socket_t argument */
#define _curl_is_socket_info(info) \
(CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
/* true if info expects a pointer to curl_off_t argument */
#define _curl_is_off_t_info(info) \
(CURLINFO_OFF_T < (info))
/* typecheck helpers -- check whether given expression has requested type*/
/* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros,
* otherwise define a new macro. Search for __builtin_types_compatible_p
* in the GCC manual.
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
* the actual expression passed to the curl_easy_setopt macro. This
* means that you can only apply the sizeof and __typeof__ operators, no
* == or whatsoever.
*/
/* XXX: should evaluate to true iff expr is a pointer */
#define _curl_is_any_ptr(expr) \
(sizeof(expr) == sizeof(void *))
/* evaluates to true if expr is NULL */
/* XXX: must not evaluate expr, so this check is not accurate */
#define _curl_is_NULL(expr) \
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
/* evaluates to true if expr is type*, const type* or NULL */
#define _curl_is_ptr(expr, type) \
(_curl_is_NULL(expr) || \
__builtin_types_compatible_p(__typeof__(expr), type *) || \
__builtin_types_compatible_p(__typeof__(expr), const type *))
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
#define _curl_is_arr(expr, type) \
(_curl_is_ptr((expr), type) || \
__builtin_types_compatible_p(__typeof__(expr), type []))
/* evaluates to true if expr is a string */
#define _curl_is_string(expr) \
(_curl_is_arr((expr), char) || \
_curl_is_arr((expr), signed char) || \
_curl_is_arr((expr), unsigned char))
/* evaluates to true if expr is a long (no matter the signedness)
* XXX: for now, int is also accepted (and therefore short and char, which
* are promoted to int when passed to a variadic function) */
#define _curl_is_long(expr) \
(__builtin_types_compatible_p(__typeof__(expr), long) || \
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
__builtin_types_compatible_p(__typeof__(expr), int) || \
__builtin_types_compatible_p(__typeof__(expr), signed int) || \
__builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
__builtin_types_compatible_p(__typeof__(expr), short) || \
__builtin_types_compatible_p(__typeof__(expr), signed short) || \
__builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
__builtin_types_compatible_p(__typeof__(expr), char) || \
__builtin_types_compatible_p(__typeof__(expr), signed char) || \
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
/* evaluates to true if expr is of type curl_off_t */
#define _curl_is_off_t(expr) \
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
/* XXX: also check size of an char[] array? */
#define _curl_is_error_buffer(expr) \
(_curl_is_NULL(expr) || \
__builtin_types_compatible_p(__typeof__(expr), char *) || \
__builtin_types_compatible_p(__typeof__(expr), char[]))
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
#if 0
#define _curl_is_cb_data(expr) \
(_curl_is_ptr((expr), void) || \
_curl_is_ptr((expr), FILE))
#else /* be less strict */
#define _curl_is_cb_data(expr) \
_curl_is_any_ptr(expr)
#endif
/* evaluates to true if expr is of type FILE* */
#define _curl_is_FILE(expr) \
(_curl_is_NULL(expr) || \
(__builtin_types_compatible_p(__typeof__(expr), FILE *)))
/* evaluates to true if expr can be passed as POST data (void* or char*) */
#define _curl_is_postfields(expr) \
(_curl_is_ptr((expr), void) || \
_curl_is_arr((expr), char))
/* FIXME: the whole callback checking is messy...
* The idea is to tolerate char vs. void and const vs. not const
* pointers in arguments at least
*/
/* helper: __builtin_types_compatible_p distinguishes between functions and
* function pointers, hide it */
#define _curl_callback_compatible(func, type) \
(__builtin_types_compatible_p(__typeof__(func), type) || \
__builtin_types_compatible_p(__typeof__(func) *, type))
/* evaluates to true if expr is of type curl_read_callback or "similar" */
#define _curl_is_read_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), __typeof__(fread) *) || \
_curl_callback_compatible((expr), curl_read_callback) || \
_curl_callback_compatible((expr), _curl_read_callback1) || \
_curl_callback_compatible((expr), _curl_read_callback2) || \
_curl_callback_compatible((expr), _curl_read_callback3) || \
_curl_callback_compatible((expr), _curl_read_callback4) || \
_curl_callback_compatible((expr), _curl_read_callback5) || \
_curl_callback_compatible((expr), _curl_read_callback6))
typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *);
typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *);
typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *);
/* evaluates to true if expr is of type curl_write_callback or "similar" */
#define _curl_is_write_cb(expr) \
(_curl_is_read_cb(expr) || \
_curl_callback_compatible((expr), __typeof__(fwrite) *) || \
_curl_callback_compatible((expr), curl_write_callback) || \
_curl_callback_compatible((expr), _curl_write_callback1) || \
_curl_callback_compatible((expr), _curl_write_callback2) || \
_curl_callback_compatible((expr), _curl_write_callback3) || \
_curl_callback_compatible((expr), _curl_write_callback4) || \
_curl_callback_compatible((expr), _curl_write_callback5) || \
_curl_callback_compatible((expr), _curl_write_callback6))
typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
const void *);
typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *);
typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *);
typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
const void *);
typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
#define _curl_is_ioctl_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_ioctl_callback) || \
_curl_callback_compatible((expr), _curl_ioctl_callback1) || \
_curl_callback_compatible((expr), _curl_ioctl_callback2) || \
_curl_callback_compatible((expr), _curl_ioctl_callback3) || \
_curl_callback_compatible((expr), _curl_ioctl_callback4))
typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *);
typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *);
typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
#define _curl_is_sockopt_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_sockopt_callback) || \
_curl_callback_compatible((expr), _curl_sockopt_callback1) || \
_curl_callback_compatible((expr), _curl_sockopt_callback2))
typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t,
curlsocktype);
/* evaluates to true if expr is of type curl_opensocket_callback or
"similar" */
#define _curl_is_opensocket_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_opensocket_callback) || \
_curl_callback_compatible((expr), _curl_opensocket_callback1) || \
_curl_callback_compatible((expr), _curl_opensocket_callback2) || \
_curl_callback_compatible((expr), _curl_opensocket_callback3) || \
_curl_callback_compatible((expr), _curl_opensocket_callback4))
typedef curl_socket_t (*_curl_opensocket_callback1)
(void *, curlsocktype, struct curl_sockaddr *);
typedef curl_socket_t (*_curl_opensocket_callback2)
(void *, curlsocktype, const struct curl_sockaddr *);
typedef curl_socket_t (*_curl_opensocket_callback3)
(const void *, curlsocktype, struct curl_sockaddr *);
typedef curl_socket_t (*_curl_opensocket_callback4)
(const void *, curlsocktype, const struct curl_sockaddr *);
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
#define _curl_is_progress_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_progress_callback) || \
_curl_callback_compatible((expr), _curl_progress_callback1) || \
_curl_callback_compatible((expr), _curl_progress_callback2))
typedef int (*_curl_progress_callback1)(void *,
double, double, double, double);
typedef int (*_curl_progress_callback2)(const void *,
double, double, double, double);
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
#define _curl_is_debug_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_debug_callback) || \
_curl_callback_compatible((expr), _curl_debug_callback1) || \
_curl_callback_compatible((expr), _curl_debug_callback2) || \
_curl_callback_compatible((expr), _curl_debug_callback3) || \
_curl_callback_compatible((expr), _curl_debug_callback4) || \
_curl_callback_compatible((expr), _curl_debug_callback5) || \
_curl_callback_compatible((expr), _curl_debug_callback6) || \
_curl_callback_compatible((expr), _curl_debug_callback7) || \
_curl_callback_compatible((expr), _curl_debug_callback8))
typedef int (*_curl_debug_callback1) (CURL *,
curl_infotype, char *, size_t, void *);
typedef int (*_curl_debug_callback2) (CURL *,
curl_infotype, char *, size_t, const void *);
typedef int (*_curl_debug_callback3) (CURL *,
curl_infotype, const char *, size_t, void *);
typedef int (*_curl_debug_callback4) (CURL *,
curl_infotype, const char *, size_t, const void *);
typedef int (*_curl_debug_callback5) (CURL *,
curl_infotype, unsigned char *, size_t, void *);
typedef int (*_curl_debug_callback6) (CURL *,
curl_infotype, unsigned char *, size_t, const void *);
typedef int (*_curl_debug_callback7) (CURL *,
curl_infotype, const unsigned char *, size_t, void *);
typedef int (*_curl_debug_callback8) (CURL *,
curl_infotype, const unsigned char *, size_t, const void *);
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
/* this is getting even messier... */
#define _curl_is_ssl_ctx_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_ssl_ctx_callback) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback8))
typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *,
const void *);
#ifdef HEADER_SSL_H
/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
* this will of course break if we're included before OpenSSL headers...
*/
typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX,
const void *);
#else
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
#endif
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
#define _curl_is_conv_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_conv_callback) || \
_curl_callback_compatible((expr), _curl_conv_callback1) || \
_curl_callback_compatible((expr), _curl_conv_callback2) || \
_curl_callback_compatible((expr), _curl_conv_callback3) || \
_curl_callback_compatible((expr), _curl_conv_callback4))
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
#define _curl_is_seek_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_seek_callback) || \
_curl_callback_compatible((expr), _curl_seek_callback1) || \
_curl_callback_compatible((expr), _curl_seek_callback2))
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
#endif /* __CURL_TYPECHECK_GCC_H */
#ifndef DO_CLIENT_H
#define DO_CLIENT_H
#include <netinet/in.h>
#include <sys/socket.h>
typedef struct _tuobao_tcpclient{
int socket;
int remote_port;
char remote_ip[16];
struct sockaddr_in _addr;
int connected;
} tuobao_tcpclient;
int tuobao_tcpclient_create(tuobao_tcpclient *,const char *host, int port);
int tuobao_tcpclient_conn(tuobao_tcpclient *);
int tuobao_tcpclient_recv(tuobao_tcpclient *,char **lpbuff,int size);
int tuobao_tcpclient_send(tuobao_tcpclient *,char *buff,int size);
int tuobao_tcpclient_close(tuobao_tcpclient *);
#endif
#ifndef DO_LOG_H
#define DO_LOG_H
#include "common.h"
#ifndef LINE_MAX
#define LINE_MAX 1024
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define DEBUGLOG "debug"
#define ERRORLOG "error"
void __debuglog(const char *fmt, ...);
void __errorlog(const char *fmt, ...);
#define debuglog(fmt, ...) \
__debuglog("[%s] %s:%d :", __TIME__, __FILE__, __LINE__); \
__debuglog(fmt, __VA_ARGS__);
#define errorlog(fmt, ...) \
__errorlog("[%s] %s:%d :", __TIME__, __FILE__, __LINE__); \
__errorlog(fmt, __VA_ARGS__);
#ifdef __cplusplus
}
#endif
#endif // DO_LOG_H
#ifndef DO_TRANS_H
#define DO_TRANS_H
#include "cJSON.h"
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif
// data structure (see JSON.txt)
typedef struct {
char OrderType[2 + 1];
char PayChannelType[2 + 1];
char DeviceType[2 + 1];
char Mch_id[15 + 1];
char Ter_id[8 + 1];
char OrderDateTime[14 + 1];
char CurrencyType[3 + 1];
char OrderAmt[12 + 1];
char OrderName[40 + 1];
char ChannelAuthCode[64 + 1];
char ResponseCode[16 + 1];
char ResponseMsg[128 + 1];
char TradeStatus[6 + 1];
char OldOrderNo[40 + 1];
char RefundNo[40 + 1];
char Amount[12 + 1];
char tn[999 + 1];
char appId[100 + 1];
char timeStamp[100 + 1];
char nonceStr[100 + 1];
char package[100 + 1];
char signType[100 + 1];
char paySign[255 + 1];
char key[32 + 1];
char Agent_id[64 + 1];
char method[16 + 1];
char notifyUrl[255 + 1];
char pos_trace[6 + 1];
char OrderNo[40 + 1];
char host_order_no[128 + 1];
char plat_order_no[128 + 1];
char js_info[255 + 1];
char trade_type[64 + 1];
char payTime[14 + 1];
} trans_json_t;
// functions
int do_biz(const trans_json_t *json_in, cJSON *pSend, char *out);
int do_trans_biz_pax(trans_json_t *json_in, trans_json_t *json_out);
int do_trans_biz_comm(cJSON *pSend, char *out);
int do_trans(const char *in, char *out, size_t *len);
#ifdef __cplusplus
}
#endif
#endif /* DO_TRANS_H */
#ifndef DO_TRANS_PAX_H
#define DO_TRANS_PAX_H
#include "do_trans.h"
typedef struct PAXPAY_JSON {
char method[12]; // 交易码
char agent_id[8]; // 机构号
char mch_id[15]; // 商户号
char ter_id[8]; // 终端号
int out_transaction_no; // 流水号
char time_start[14]; // 订单生成时间
char subject[256]; // 订单标题
char body[128]; // 商品描述
char auth_code[32]; // 支付授权码
char currency[3]; // 币种
char total_amount[12]; // 订单金额
char fee_amount[12]; // 小费金额
char reserved[128]; // 商户保留
char exp_time[2]; // 超时等待, 单位:秒
char sign_type[8]; // 签名类型, MD5
char sign[256]; // 签名
} paxpay_json_t;
void FUNC_pax_pay_conv(trans_json_t *json_conv);
int FUNC_pax_recv_micropay(const char *in, trans_json_t *json_out);
int FUNC_pax_send_micropay(const trans_json_t *json_in, cJSON *pSend);
int FUNC_pax_send_qrpay(const trans_json_t *json_in, cJSON *pSend);
int FUNC_pax_recv_qrpay(const char *in, trans_json_t *json_out);
int FUNC_pax_send_jspay(const trans_json_t *json_in, cJSON *pSend);
int FUNC_pax_recv_jspay(const char *in, trans_json_t *json_out);
int FUNC_pax_send_refund(const trans_json_t *json_in, cJSON *pSend);
int FUNC_pax_recv_refund(const char *in, trans_json_t *json_out);
int FUNC_pax_send_cancel(const trans_json_t *json_in, cJSON *pSend);
int FUNC_pax_recv_cancel(const char *in, trans_json_t *json_out);
int FUNC_pax_send_query(const trans_json_t *json_in, cJSON *pSend);
int FUNC_pax_recv_query(const char *in, trans_json_t *json_out);
#endif /* DO_TRANS_PAX_H */
/*File : http.h
*Auth : sjin
*Date : 20141206
*Mail : 413977243@qq.com
*/
#ifndef _MY_HTTP_H
#define _MY_HTTP_H
#include "common.h"
#include "do_log.h"
#define MY_HTTP_DEFAULT_PORT 8888
char * http_get(const char *url);
char * http_post(const char *url,const char * post_str);
#endif
/*
* Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* We used part of Netscape's Java Runtime Interface (JRI) as the starting
* point of our design and implementation.
*/
/******************************************************************************
* Java Runtime Interface
* Copyright (c) 1996 Netscape Communications Corporation. All rights reserved.
*****************************************************************************/
#ifndef _JAVASOFT_JNI_H_
#define _JAVASOFT_JNI_H_
#include <stdio.h>
#include <stdarg.h>
/* jni_md.h contains the machine-dependent typedefs for jbyte, jint
and jlong */
#include "jni_md.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* JNI Types
*/
#ifndef JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H
typedef unsigned char jboolean;
typedef unsigned short jchar;
typedef short jshort;
typedef float jfloat;
typedef double jdouble;
typedef jint jsize;
#ifdef __cplusplus
class _jobject {};
class _jclass : public _jobject {};
class _jthrowable : public _jobject {};
class _jstring : public _jobject {};
class _jarray : public _jobject {};
class _jbooleanArray : public _jarray {};
class _jbyteArray : public _jarray {};
class _jcharArray : public _jarray {};
class _jshortArray : public _jarray {};
class _jintArray : public _jarray {};
class _jlongArray : public _jarray {};
class _jfloatArray : public _jarray {};
class _jdoubleArray : public _jarray {};
class _jobjectArray : public _jarray {};
typedef _jobject *jobject;
typedef _jclass *jclass;
typedef _jthrowable *jthrowable;
typedef _jstring *jstring;
typedef _jarray *jarray;
typedef _jbooleanArray *jbooleanArray;
typedef _jbyteArray *jbyteArray;
typedef _jcharArray *jcharArray;
typedef _jshortArray *jshortArray;
typedef _jintArray *jintArray;
typedef _jlongArray *jlongArray;
typedef _jfloatArray *jfloatArray;
typedef _jdoubleArray *jdoubleArray;
typedef _jobjectArray *jobjectArray;
#else
struct _jobject;
typedef struct _jobject *jobject;
typedef jobject jclass;
typedef jobject jthrowable;
typedef jobject jstring;
typedef jobject jarray;
typedef jarray jbooleanArray;
typedef jarray jbyteArray;
typedef jarray jcharArray;
typedef jarray jshortArray;
typedef jarray jintArray;
typedef jarray jlongArray;
typedef jarray jfloatArray;
typedef jarray jdoubleArray;
typedef jarray jobjectArray;
#endif
typedef jobject jweak;
typedef union jvalue {
jboolean z;
jbyte b;
jchar c;
jshort s;
jint i;
jlong j;
jfloat f;
jdouble d;
jobject l;
} jvalue;
struct _jfieldID;
typedef struct _jfieldID *jfieldID;
struct _jmethodID;
typedef struct _jmethodID *jmethodID;
/* Return values from jobjectRefType */
typedef enum _jobjectType {
JNIInvalidRefType = 0,
JNILocalRefType = 1,
JNIGlobalRefType = 2,
JNIWeakGlobalRefType = 3
} jobjectRefType;
#endif /* JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H */
/*
* jboolean constants
*/
#define JNI_FALSE 0
#define JNI_TRUE 1
/*
* possible return values for JNI functions.
*/
#define JNI_OK 0 /* success */
#define JNI_ERR (-1) /* unknown error */
#define JNI_EDETACHED (-2) /* thread detached from the VM */
#define JNI_EVERSION (-3) /* JNI version error */
#define JNI_ENOMEM (-4) /* not enough memory */
#define JNI_EEXIST (-5) /* VM already created */
#define JNI_EINVAL (-6) /* invalid arguments */
/*
* used in ReleaseScalarArrayElements
*/
#define JNI_COMMIT 1
#define JNI_ABORT 2
/*
* used in RegisterNatives to describe native method name, signature,
* and function pointer.
*/
typedef struct {
char *name;
char *signature;
void *fnPtr;
} JNINativeMethod;
/*
* JNI Native Method Interface.
*/
struct JNINativeInterface_;
struct JNIEnv_;
#ifdef __cplusplus
typedef JNIEnv_ JNIEnv;
#else
typedef const struct JNINativeInterface_ *JNIEnv;
#endif
/*
* JNI Invocation Interface.
*/
struct JNIInvokeInterface_;
struct JavaVM_;
#ifdef __cplusplus
typedef JavaVM_ JavaVM;
#else
typedef const struct JNIInvokeInterface_ *JavaVM;
#endif
struct JNINativeInterface_ {
void *reserved0;
void *reserved1;
void *reserved2;
void *reserved3;
jint (JNICALL *GetVersion)(JNIEnv *env);
jclass (JNICALL *DefineClass)
(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
jsize len);
jclass (JNICALL *FindClass)
(JNIEnv *env, const char *name);
jmethodID (JNICALL *FromReflectedMethod)
(JNIEnv *env, jobject method);
jfieldID (JNICALL *FromReflectedField)
(JNIEnv *env, jobject field);
jobject (JNICALL *ToReflectedMethod)
(JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic);
jclass (JNICALL *GetSuperclass)
(JNIEnv *env, jclass sub);
jboolean (JNICALL *IsAssignableFrom)
(JNIEnv *env, jclass sub, jclass sup);
jobject (JNICALL *ToReflectedField)
(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic);
jint (JNICALL *Throw)
(JNIEnv *env, jthrowable obj);
jint (JNICALL *ThrowNew)
(JNIEnv *env, jclass clazz, const char *msg);
jthrowable (JNICALL *ExceptionOccurred)
(JNIEnv *env);
void (JNICALL *ExceptionDescribe)
(JNIEnv *env);
void (JNICALL *ExceptionClear)
(JNIEnv *env);
void (JNICALL *FatalError)
(JNIEnv *env, const char *msg);
jint (JNICALL *PushLocalFrame)
(JNIEnv *env, jint capacity);
jobject (JNICALL *PopLocalFrame)
(JNIEnv *env, jobject result);
jobject (JNICALL *NewGlobalRef)
(JNIEnv *env, jobject lobj);
void (JNICALL *DeleteGlobalRef)
(JNIEnv *env, jobject gref);
void (JNICALL *DeleteLocalRef)
(JNIEnv *env, jobject obj);
jboolean (JNICALL *IsSameObject)
(JNIEnv *env, jobject obj1, jobject obj2);
jobject (JNICALL *NewLocalRef)
(JNIEnv *env, jobject ref);
jint (JNICALL *EnsureLocalCapacity)
(JNIEnv *env, jint capacity);
jobject (JNICALL *AllocObject)
(JNIEnv *env, jclass clazz);
jobject (JNICALL *NewObject)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jobject (JNICALL *NewObjectV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jobject (JNICALL *NewObjectA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
jclass (JNICALL *GetObjectClass)
(JNIEnv *env, jobject obj);
jboolean (JNICALL *IsInstanceOf)
(JNIEnv *env, jobject obj, jclass clazz);
jmethodID (JNICALL *GetMethodID)
(JNIEnv *env, jclass clazz, const char *name, const char *sig);
jobject (JNICALL *CallObjectMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
jobject (JNICALL *CallObjectMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
jobject (JNICALL *CallObjectMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);
jboolean (JNICALL *CallBooleanMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
jboolean (JNICALL *CallBooleanMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
jboolean (JNICALL *CallBooleanMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);
jbyte (JNICALL *CallByteMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
jbyte (JNICALL *CallByteMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
jbyte (JNICALL *CallByteMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
jchar (JNICALL *CallCharMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
jchar (JNICALL *CallCharMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
jchar (JNICALL *CallCharMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
jshort (JNICALL *CallShortMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
jshort (JNICALL *CallShortMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
jshort (JNICALL *CallShortMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
jint (JNICALL *CallIntMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
jint (JNICALL *CallIntMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
jint (JNICALL *CallIntMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
jlong (JNICALL *CallLongMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
jlong (JNICALL *CallLongMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
jlong (JNICALL *CallLongMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
jfloat (JNICALL *CallFloatMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
jfloat (JNICALL *CallFloatMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
jfloat (JNICALL *CallFloatMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
jdouble (JNICALL *CallDoubleMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
jdouble (JNICALL *CallDoubleMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
jdouble (JNICALL *CallDoubleMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
void (JNICALL *CallVoidMethod)
(JNIEnv *env, jobject obj, jmethodID methodID, ...);
void (JNICALL *CallVoidMethodV)
(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
void (JNICALL *CallVoidMethodA)
(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);
jobject (JNICALL *CallNonvirtualObjectMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
jobject (JNICALL *CallNonvirtualObjectMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
jobject (JNICALL *CallNonvirtualObjectMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue * args);
jboolean (JNICALL *CallNonvirtualBooleanMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
jboolean (JNICALL *CallNonvirtualBooleanMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
jboolean (JNICALL *CallNonvirtualBooleanMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue * args);
jbyte (JNICALL *CallNonvirtualByteMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
jbyte (JNICALL *CallNonvirtualByteMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
jbyte (JNICALL *CallNonvirtualByteMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue *args);
jchar (JNICALL *CallNonvirtualCharMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
jchar (JNICALL *CallNonvirtualCharMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
jchar (JNICALL *CallNonvirtualCharMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue *args);
jshort (JNICALL *CallNonvirtualShortMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
jshort (JNICALL *CallNonvirtualShortMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
jshort (JNICALL *CallNonvirtualShortMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue *args);
jint (JNICALL *CallNonvirtualIntMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
jint (JNICALL *CallNonvirtualIntMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
jint (JNICALL *CallNonvirtualIntMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue *args);
jlong (JNICALL *CallNonvirtualLongMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
jlong (JNICALL *CallNonvirtualLongMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
jlong (JNICALL *CallNonvirtualLongMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue *args);
jfloat (JNICALL *CallNonvirtualFloatMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
jfloat (JNICALL *CallNonvirtualFloatMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
jfloat (JNICALL *CallNonvirtualFloatMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue *args);
jdouble (JNICALL *CallNonvirtualDoubleMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
jdouble (JNICALL *CallNonvirtualDoubleMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
jdouble (JNICALL *CallNonvirtualDoubleMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue *args);
void (JNICALL *CallNonvirtualVoidMethod)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
void (JNICALL *CallNonvirtualVoidMethodV)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
va_list args);
void (JNICALL *CallNonvirtualVoidMethodA)
(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
const jvalue * args);
jfieldID (JNICALL *GetFieldID)
(JNIEnv *env, jclass clazz, const char *name, const char *sig);
jobject (JNICALL *GetObjectField)
(JNIEnv *env, jobject obj, jfieldID fieldID);
jboolean (JNICALL *GetBooleanField)
(JNIEnv *env, jobject obj, jfieldID fieldID);
jbyte (JNICALL *GetByteField)
(JNIEnv *env, jobject obj, jfieldID fieldID);
jchar (JNICALL *GetCharField)
(JNIEnv *env, jobject obj, jfieldID fieldID);
jshort (JNICALL *GetShortField)
(JNIEnv *env, jobject obj, jfieldID fieldID);
jint (JNICALL *GetIntField)
(JNIEnv *env, jobject obj, jfieldID fieldID);
jlong (JNICALL *GetLongField)
(JNIEnv *env, jobject obj, jfieldID fieldID);
jfloat (JNICALL *GetFloatField)
(JNIEnv *env, jobject obj, jfieldID fieldID);
jdouble (JNICALL *GetDoubleField)
(JNIEnv *env, jobject obj, jfieldID fieldID);
void (JNICALL *SetObjectField)
(JNIEnv *env, jobject obj, jfieldID fieldID, jobject val);
void (JNICALL *SetBooleanField)
(JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val);
void (JNICALL *SetByteField)
(JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val);
void (JNICALL *SetCharField)
(JNIEnv *env, jobject obj, jfieldID fieldID, jchar val);
void (JNICALL *SetShortField)
(JNIEnv *env, jobject obj, jfieldID fieldID, jshort val);
void (JNICALL *SetIntField)
(JNIEnv *env, jobject obj, jfieldID fieldID, jint val);
void (JNICALL *SetLongField)
(JNIEnv *env, jobject obj, jfieldID fieldID, jlong val);
void (JNICALL *SetFloatField)
(JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val);
void (JNICALL *SetDoubleField)
(JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val);
jmethodID (JNICALL *GetStaticMethodID)
(JNIEnv *env, jclass clazz, const char *name, const char *sig);
jobject (JNICALL *CallStaticObjectMethod)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jobject (JNICALL *CallStaticObjectMethodV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jobject (JNICALL *CallStaticObjectMethodA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
jboolean (JNICALL *CallStaticBooleanMethod)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jboolean (JNICALL *CallStaticBooleanMethodV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jboolean (JNICALL *CallStaticBooleanMethodA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
jbyte (JNICALL *CallStaticByteMethod)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jbyte (JNICALL *CallStaticByteMethodV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jbyte (JNICALL *CallStaticByteMethodA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
jchar (JNICALL *CallStaticCharMethod)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jchar (JNICALL *CallStaticCharMethodV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jchar (JNICALL *CallStaticCharMethodA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
jshort (JNICALL *CallStaticShortMethod)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jshort (JNICALL *CallStaticShortMethodV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jshort (JNICALL *CallStaticShortMethodA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
jint (JNICALL *CallStaticIntMethod)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jint (JNICALL *CallStaticIntMethodV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jint (JNICALL *CallStaticIntMethodA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
jlong (JNICALL *CallStaticLongMethod)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jlong (JNICALL *CallStaticLongMethodV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jlong (JNICALL *CallStaticLongMethodA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
jfloat (JNICALL *CallStaticFloatMethod)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jfloat (JNICALL *CallStaticFloatMethodV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jfloat (JNICALL *CallStaticFloatMethodA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
jdouble (JNICALL *CallStaticDoubleMethod)
(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
jdouble (JNICALL *CallStaticDoubleMethodV)
(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
jdouble (JNICALL *CallStaticDoubleMethodA)
(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
void (JNICALL *CallStaticVoidMethod)
(JNIEnv *env, jclass cls, jmethodID methodID, ...);
void (JNICALL *CallStaticVoidMethodV)
(JNIEnv *env, jclass cls, jmethodID methodID, va_list args);
void (JNICALL *CallStaticVoidMethodA)
(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue * args);
jfieldID (JNICALL *GetStaticFieldID)
(JNIEnv *env, jclass clazz, const char *name, const char *sig);
jobject (JNICALL *GetStaticObjectField)
(JNIEnv *env, jclass clazz, jfieldID fieldID);
jboolean (JNICALL *GetStaticBooleanField)
(JNIEnv *env, jclass clazz, jfieldID fieldID);
jbyte (JNICALL *GetStaticByteField)
(JNIEnv *env, jclass clazz, jfieldID fieldID);
jchar (JNICALL *GetStaticCharField)
(JNIEnv *env, jclass clazz, jfieldID fieldID);
jshort (JNICALL *GetStaticShortField)
(JNIEnv *env, jclass clazz, jfieldID fieldID);
jint (JNICALL *GetStaticIntField)
(JNIEnv *env, jclass clazz, jfieldID fieldID);
jlong (JNICALL *GetStaticLongField)
(JNIEnv *env, jclass clazz, jfieldID fieldID);
jfloat (JNICALL *GetStaticFloatField)
(JNIEnv *env, jclass clazz, jfieldID fieldID);
jdouble (JNICALL *GetStaticDoubleField)
(JNIEnv *env, jclass clazz, jfieldID fieldID);
void (JNICALL *SetStaticObjectField)
(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value);
void (JNICALL *SetStaticBooleanField)
(JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value);
void (JNICALL *SetStaticByteField)
(JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value);
void (JNICALL *SetStaticCharField)
(JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value);
void (JNICALL *SetStaticShortField)
(JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value);
void (JNICALL *SetStaticIntField)
(JNIEnv *env, jclass clazz, jfieldID fieldID, jint value);
void (JNICALL *SetStaticLongField)
(JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value);
void (JNICALL *SetStaticFloatField)
(JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value);
void (JNICALL *SetStaticDoubleField)
(JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value);
jstring (JNICALL *NewString)
(JNIEnv *env, const jchar *unicode, jsize len);
jsize (JNICALL *GetStringLength)
(JNIEnv *env, jstring str);
const jchar *(JNICALL *GetStringChars)
(JNIEnv *env, jstring str, jboolean *isCopy);
void (JNICALL *ReleaseStringChars)
(JNIEnv *env, jstring str, const jchar *chars);
jstring (JNICALL *NewStringUTF)
(JNIEnv *env, const char *utf);
jsize (JNICALL *GetStringUTFLength)
(JNIEnv *env, jstring str);
const char* (JNICALL *GetStringUTFChars)
(JNIEnv *env, jstring str, jboolean *isCopy);
void (JNICALL *ReleaseStringUTFChars)
(JNIEnv *env, jstring str, const char* chars);
jsize (JNICALL *GetArrayLength)
(JNIEnv *env, jarray array);
jobjectArray (JNICALL *NewObjectArray)
(JNIEnv *env, jsize len, jclass clazz, jobject init);
jobject (JNICALL *GetObjectArrayElement)
(JNIEnv *env, jobjectArray array, jsize index);
void (JNICALL *SetObjectArrayElement)
(JNIEnv *env, jobjectArray array, jsize index, jobject val);
jbooleanArray (JNICALL *NewBooleanArray)
(JNIEnv *env, jsize len);
jbyteArray (JNICALL *NewByteArray)
(JNIEnv *env, jsize len);
jcharArray (JNICALL *NewCharArray)
(JNIEnv *env, jsize len);
jshortArray (JNICALL *NewShortArray)
(JNIEnv *env, jsize len);
jintArray (JNICALL *NewIntArray)
(JNIEnv *env, jsize len);
jlongArray (JNICALL *NewLongArray)
(JNIEnv *env, jsize len);
jfloatArray (JNICALL *NewFloatArray)
(JNIEnv *env, jsize len);
jdoubleArray (JNICALL *NewDoubleArray)
(JNIEnv *env, jsize len);
jboolean * (JNICALL *GetBooleanArrayElements)
(JNIEnv *env, jbooleanArray array, jboolean *isCopy);
jbyte * (JNICALL *GetByteArrayElements)
(JNIEnv *env, jbyteArray array, jboolean *isCopy);
jchar * (JNICALL *GetCharArrayElements)
(JNIEnv *env, jcharArray array, jboolean *isCopy);
jshort * (JNICALL *GetShortArrayElements)
(JNIEnv *env, jshortArray array, jboolean *isCopy);
jint * (JNICALL *GetIntArrayElements)
(JNIEnv *env, jintArray array, jboolean *isCopy);
jlong * (JNICALL *GetLongArrayElements)
(JNIEnv *env, jlongArray array, jboolean *isCopy);
jfloat * (JNICALL *GetFloatArrayElements)
(JNIEnv *env, jfloatArray array, jboolean *isCopy);
jdouble * (JNICALL *GetDoubleArrayElements)
(JNIEnv *env, jdoubleArray array, jboolean *isCopy);
void (JNICALL *ReleaseBooleanArrayElements)
(JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode);
void (JNICALL *ReleaseByteArrayElements)
(JNIEnv *env, jbyteArray array, jbyte *elems, jint mode);
void (JNICALL *ReleaseCharArrayElements)
(JNIEnv *env, jcharArray array, jchar *elems, jint mode);
void (JNICALL *ReleaseShortArrayElements)
(JNIEnv *env, jshortArray array, jshort *elems, jint mode);
void (JNICALL *ReleaseIntArrayElements)
(JNIEnv *env, jintArray array, jint *elems, jint mode);
void (JNICALL *ReleaseLongArrayElements)
(JNIEnv *env, jlongArray array, jlong *elems, jint mode);
void (JNICALL *ReleaseFloatArrayElements)
(JNIEnv *env, jfloatArray array, jfloat *elems, jint mode);
void (JNICALL *ReleaseDoubleArrayElements)
(JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode);
void (JNICALL *GetBooleanArrayRegion)
(JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf);
void (JNICALL *GetByteArrayRegion)
(JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf);
void (JNICALL *GetCharArrayRegion)
(JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf);
void (JNICALL *GetShortArrayRegion)
(JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf);
void (JNICALL *GetIntArrayRegion)
(JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf);
void (JNICALL *GetLongArrayRegion)
(JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf);
void (JNICALL *GetFloatArrayRegion)
(JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf);
void (JNICALL *GetDoubleArrayRegion)
(JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf);
void (JNICALL *SetBooleanArrayRegion)
(JNIEnv *env, jbooleanArray array, jsize start, jsize l, const jboolean *buf);
void (JNICALL *SetByteArrayRegion)
(JNIEnv *env, jbyteArray array, jsize start, jsize len, const jbyte *buf);
void (JNICALL *SetCharArrayRegion)
(JNIEnv *env, jcharArray array, jsize start, jsize len, const jchar *buf);
void (JNICALL *SetShortArrayRegion)
(JNIEnv *env, jshortArray array, jsize start, jsize len, const jshort *buf);
void (JNICALL *SetIntArrayRegion)
(JNIEnv *env, jintArray array, jsize start, jsize len, const jint *buf);
void (JNICALL *SetLongArrayRegion)
(JNIEnv *env, jlongArray array, jsize start, jsize len, const jlong *buf);
void (JNICALL *SetFloatArrayRegion)
(JNIEnv *env, jfloatArray array, jsize start, jsize len, const jfloat *buf);
void (JNICALL *SetDoubleArrayRegion)
(JNIEnv *env, jdoubleArray array, jsize start, jsize len, const jdouble *buf);
jint (JNICALL *RegisterNatives)
(JNIEnv *env, jclass clazz, const JNINativeMethod *methods,
jint nMethods);
jint (JNICALL *UnregisterNatives)
(JNIEnv *env, jclass clazz);
jint (JNICALL *MonitorEnter)
(JNIEnv *env, jobject obj);
jint (JNICALL *MonitorExit)
(JNIEnv *env, jobject obj);
jint (JNICALL *GetJavaVM)
(JNIEnv *env, JavaVM **vm);
void (JNICALL *GetStringRegion)
(JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf);
void (JNICALL *GetStringUTFRegion)
(JNIEnv *env, jstring str, jsize start, jsize len, char *buf);
void * (JNICALL *GetPrimitiveArrayCritical)
(JNIEnv *env, jarray array, jboolean *isCopy);
void (JNICALL *ReleasePrimitiveArrayCritical)
(JNIEnv *env, jarray array, void *carray, jint mode);
const jchar * (JNICALL *GetStringCritical)
(JNIEnv *env, jstring string, jboolean *isCopy);
void (JNICALL *ReleaseStringCritical)
(JNIEnv *env, jstring string, const jchar *cstring);
jweak (JNICALL *NewWeakGlobalRef)
(JNIEnv *env, jobject obj);
void (JNICALL *DeleteWeakGlobalRef)
(JNIEnv *env, jweak ref);
jboolean (JNICALL *ExceptionCheck)
(JNIEnv *env);
jobject (JNICALL *NewDirectByteBuffer)
(JNIEnv* env, void* address, jlong capacity);
void* (JNICALL *GetDirectBufferAddress)
(JNIEnv* env, jobject buf);
jlong (JNICALL *GetDirectBufferCapacity)
(JNIEnv* env, jobject buf);
/* New JNI 1.6 Features */
jobjectRefType (JNICALL *GetObjectRefType)
(JNIEnv* env, jobject obj);
};
/*
* We use inlined functions for C++ so that programmers can write:
*
* env->FindClass("java/lang/String")
*
* in C++ rather than:
*
* (*env)->FindClass(env, "java/lang/String")
*
* in C.
*/
struct JNIEnv_ {
const struct JNINativeInterface_ *functions;
#ifdef __cplusplus
jint GetVersion() {
return functions->GetVersion(this);
}
jclass DefineClass(const char *name, jobject loader, const jbyte *buf,
jsize len) {
return functions->DefineClass(this, name, loader, buf, len);
}
jclass FindClass(const char *name) {
return functions->FindClass(this, name);
}
jmethodID FromReflectedMethod(jobject method) {
return functions->FromReflectedMethod(this,method);
}
jfieldID FromReflectedField(jobject field) {
return functions->FromReflectedField(this,field);
}
jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) {
return functions->ToReflectedMethod(this, cls, methodID, isStatic);
}
jclass GetSuperclass(jclass sub) {
return functions->GetSuperclass(this, sub);
}
jboolean IsAssignableFrom(jclass sub, jclass sup) {
return functions->IsAssignableFrom(this, sub, sup);
}
jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) {
return functions->ToReflectedField(this,cls,fieldID,isStatic);
}
jint Throw(jthrowable obj) {
return functions->Throw(this, obj);
}
jint ThrowNew(jclass clazz, const char *msg) {
return functions->ThrowNew(this, clazz, msg);
}
jthrowable ExceptionOccurred() {
return functions->ExceptionOccurred(this);
}
void ExceptionDescribe() {
functions->ExceptionDescribe(this);
}
void ExceptionClear() {
functions->ExceptionClear(this);
}
void FatalError(const char *msg) {
functions->FatalError(this, msg);
}
jint PushLocalFrame(jint capacity) {
return functions->PushLocalFrame(this,capacity);
}
jobject PopLocalFrame(jobject result) {
return functions->PopLocalFrame(this,result);
}
jobject NewGlobalRef(jobject lobj) {
return functions->NewGlobalRef(this,lobj);
}
void DeleteGlobalRef(jobject gref) {
functions->DeleteGlobalRef(this,gref);
}
void DeleteLocalRef(jobject obj) {
functions->DeleteLocalRef(this, obj);
}
jboolean IsSameObject(jobject obj1, jobject obj2) {
return functions->IsSameObject(this,obj1,obj2);
}
jobject NewLocalRef(jobject ref) {
return functions->NewLocalRef(this,ref);
}
jint EnsureLocalCapacity(jint capacity) {
return functions->EnsureLocalCapacity(this,capacity);
}
jobject AllocObject(jclass clazz) {
return functions->AllocObject(this,clazz);
}
jobject NewObject(jclass clazz, jmethodID methodID, ...) {
va_list args;
jobject result;
va_start(args, methodID);
result = functions->NewObjectV(this,clazz,methodID,args);
va_end(args);
return result;
}
jobject NewObjectV(jclass clazz, jmethodID methodID,
va_list args) {
return functions->NewObjectV(this,clazz,methodID,args);
}
jobject NewObjectA(jclass clazz, jmethodID methodID,
const jvalue *args) {
return functions->NewObjectA(this,clazz,methodID,args);
}
jclass GetObjectClass(jobject obj) {
return functions->GetObjectClass(this,obj);
}
jboolean IsInstanceOf(jobject obj, jclass clazz) {
return functions->IsInstanceOf(this,obj,clazz);
}
jmethodID GetMethodID(jclass clazz, const char *name,
const char *sig) {
return functions->GetMethodID(this,clazz,name,sig);
}
jobject CallObjectMethod(jobject obj, jmethodID methodID, ...) {
va_list args;
jobject result;
va_start(args,methodID);
result = functions->CallObjectMethodV(this,obj,methodID,args);
va_end(args);
return result;
}
jobject CallObjectMethodV(jobject obj, jmethodID methodID,
va_list args) {
return functions->CallObjectMethodV(this,obj,methodID,args);
}
jobject CallObjectMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
return functions->CallObjectMethodA(this,obj,methodID,args);
}
jboolean CallBooleanMethod(jobject obj,
jmethodID methodID, ...) {
va_list args;
jboolean result;
va_start(args,methodID);
result = functions->CallBooleanMethodV(this,obj,methodID,args);
va_end(args);
return result;
}
jboolean CallBooleanMethodV(jobject obj, jmethodID methodID,
va_list args) {
return functions->CallBooleanMethodV(this,obj,methodID,args);
}
jboolean CallBooleanMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
return functions->CallBooleanMethodA(this,obj,methodID, args);
}
jbyte CallByteMethod(jobject obj, jmethodID methodID, ...) {
va_list args;
jbyte result;
va_start(args,methodID);
result = functions->CallByteMethodV(this,obj,methodID,args);
va_end(args);
return result;
}
jbyte CallByteMethodV(jobject obj, jmethodID methodID,
va_list args) {
return functions->CallByteMethodV(this,obj,methodID,args);
}
jbyte CallByteMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
return functions->CallByteMethodA(this,obj,methodID,args);
}
jchar CallCharMethod(jobject obj, jmethodID methodID, ...) {
va_list args;
jchar result;
va_start(args,methodID);
result = functions->CallCharMethodV(this,obj,methodID,args);
va_end(args);
return result;
}
jchar CallCharMethodV(jobject obj, jmethodID methodID,
va_list args) {
return functions->CallCharMethodV(this,obj,methodID,args);
}
jchar CallCharMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
return functions->CallCharMethodA(this,obj,methodID,args);
}
jshort CallShortMethod(jobject obj, jmethodID methodID, ...) {
va_list args;
jshort result;
va_start(args,methodID);
result = functions->CallShortMethodV(this,obj,methodID,args);
va_end(args);
return result;
}
jshort CallShortMethodV(jobject obj, jmethodID methodID,
va_list args) {
return functions->CallShortMethodV(this,obj,methodID,args);
}
jshort CallShortMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
return functions->CallShortMethodA(this,obj,methodID,args);
}
jint CallIntMethod(jobject obj, jmethodID methodID, ...) {
va_list args;
jint result;
va_start(args,methodID);
result = functions->CallIntMethodV(this,obj,methodID,args);
va_end(args);
return result;
}
jint CallIntMethodV(jobject obj, jmethodID methodID,
va_list args) {
return functions->CallIntMethodV(this,obj,methodID,args);
}
jint CallIntMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
return functions->CallIntMethodA(this,obj,methodID,args);
}
jlong CallLongMethod(jobject obj, jmethodID methodID, ...) {
va_list args;
jlong result;
va_start(args,methodID);
result = functions->CallLongMethodV(this,obj,methodID,args);
va_end(args);
return result;
}
jlong CallLongMethodV(jobject obj, jmethodID methodID,
va_list args) {
return functions->CallLongMethodV(this,obj,methodID,args);
}
jlong CallLongMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
return functions->CallLongMethodA(this,obj,methodID,args);
}
jfloat CallFloatMethod(jobject obj, jmethodID methodID, ...) {
va_list args;
jfloat result;
va_start(args,methodID);
result = functions->CallFloatMethodV(this,obj,methodID,args);
va_end(args);
return result;
}
jfloat CallFloatMethodV(jobject obj, jmethodID methodID,
va_list args) {
return functions->CallFloatMethodV(this,obj,methodID,args);
}
jfloat CallFloatMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
return functions->CallFloatMethodA(this,obj,methodID,args);
}
jdouble CallDoubleMethod(jobject obj, jmethodID methodID, ...) {
va_list args;
jdouble result;
va_start(args,methodID);
result = functions->CallDoubleMethodV(this,obj,methodID,args);
va_end(args);
return result;
}
jdouble CallDoubleMethodV(jobject obj, jmethodID methodID,
va_list args) {
return functions->CallDoubleMethodV(this,obj,methodID,args);
}
jdouble CallDoubleMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
return functions->CallDoubleMethodA(this,obj,methodID,args);
}
void CallVoidMethod(jobject obj, jmethodID methodID, ...) {
va_list args;
va_start(args,methodID);
functions->CallVoidMethodV(this,obj,methodID,args);
va_end(args);
}
void CallVoidMethodV(jobject obj, jmethodID methodID,
va_list args) {
functions->CallVoidMethodV(this,obj,methodID,args);
}
void CallVoidMethodA(jobject obj, jmethodID methodID,
const jvalue * args) {
functions->CallVoidMethodA(this,obj,methodID,args);
}
jobject CallNonvirtualObjectMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
jobject result;
va_start(args,methodID);
result = functions->CallNonvirtualObjectMethodV(this,obj,clazz,
methodID,args);
va_end(args);
return result;
}
jobject CallNonvirtualObjectMethodV(jobject obj, jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallNonvirtualObjectMethodV(this,obj,clazz,
methodID,args);
}
jobject CallNonvirtualObjectMethodA(jobject obj, jclass clazz,
jmethodID methodID, const jvalue * args) {
return functions->CallNonvirtualObjectMethodA(this,obj,clazz,
methodID,args);
}
jboolean CallNonvirtualBooleanMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
jboolean result;
va_start(args,methodID);
result = functions->CallNonvirtualBooleanMethodV(this,obj,clazz,
methodID,args);
va_end(args);
return result;
}
jboolean CallNonvirtualBooleanMethodV(jobject obj, jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallNonvirtualBooleanMethodV(this,obj,clazz,
methodID,args);
}
jboolean CallNonvirtualBooleanMethodA(jobject obj, jclass clazz,
jmethodID methodID, const jvalue * args) {
return functions->CallNonvirtualBooleanMethodA(this,obj,clazz,
methodID, args);
}
jbyte CallNonvirtualByteMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
jbyte result;
va_start(args,methodID);
result = functions->CallNonvirtualByteMethodV(this,obj,clazz,
methodID,args);
va_end(args);
return result;
}
jbyte CallNonvirtualByteMethodV(jobject obj, jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallNonvirtualByteMethodV(this,obj,clazz,
methodID,args);
}
jbyte CallNonvirtualByteMethodA(jobject obj, jclass clazz,
jmethodID methodID, const jvalue * args) {
return functions->CallNonvirtualByteMethodA(this,obj,clazz,
methodID,args);
}
jchar CallNonvirtualCharMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
jchar result;
va_start(args,methodID);
result = functions->CallNonvirtualCharMethodV(this,obj,clazz,
methodID,args);
va_end(args);
return result;
}
jchar CallNonvirtualCharMethodV(jobject obj, jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallNonvirtualCharMethodV(this,obj,clazz,
methodID,args);
}
jchar CallNonvirtualCharMethodA(jobject obj, jclass clazz,
jmethodID methodID, const jvalue * args) {
return functions->CallNonvirtualCharMethodA(this,obj,clazz,
methodID,args);
}
jshort CallNonvirtualShortMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
jshort result;
va_start(args,methodID);
result = functions->CallNonvirtualShortMethodV(this,obj,clazz,
methodID,args);
va_end(args);
return result;
}
jshort CallNonvirtualShortMethodV(jobject obj, jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallNonvirtualShortMethodV(this,obj,clazz,
methodID,args);
}
jshort CallNonvirtualShortMethodA(jobject obj, jclass clazz,
jmethodID methodID, const jvalue * args) {
return functions->CallNonvirtualShortMethodA(this,obj,clazz,
methodID,args);
}
jint CallNonvirtualIntMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
jint result;
va_start(args,methodID);
result = functions->CallNonvirtualIntMethodV(this,obj,clazz,
methodID,args);
va_end(args);
return result;
}
jint CallNonvirtualIntMethodV(jobject obj, jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallNonvirtualIntMethodV(this,obj,clazz,
methodID,args);
}
jint CallNonvirtualIntMethodA(jobject obj, jclass clazz,
jmethodID methodID, const jvalue * args) {
return functions->CallNonvirtualIntMethodA(this,obj,clazz,
methodID,args);
}
jlong CallNonvirtualLongMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
jlong result;
va_start(args,methodID);
result = functions->CallNonvirtualLongMethodV(this,obj,clazz,
methodID,args);
va_end(args);
return result;
}
jlong CallNonvirtualLongMethodV(jobject obj, jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallNonvirtualLongMethodV(this,obj,clazz,
methodID,args);
}
jlong CallNonvirtualLongMethodA(jobject obj, jclass clazz,
jmethodID methodID, const jvalue * args) {
return functions->CallNonvirtualLongMethodA(this,obj,clazz,
methodID,args);
}
jfloat CallNonvirtualFloatMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
jfloat result;
va_start(args,methodID);
result = functions->CallNonvirtualFloatMethodV(this,obj,clazz,
methodID,args);
va_end(args);
return result;
}
jfloat CallNonvirtualFloatMethodV(jobject obj, jclass clazz,
jmethodID methodID,
va_list args) {
return functions->CallNonvirtualFloatMethodV(this,obj,clazz,
methodID,args);
}
jfloat CallNonvirtualFloatMethodA(jobject obj, jclass clazz,
jmethodID methodID,
const jvalue * args) {
return functions->CallNonvirtualFloatMethodA(this,obj,clazz,
methodID,args);
}
jdouble CallNonvirtualDoubleMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
jdouble result;
va_start(args,methodID);
result = functions->CallNonvirtualDoubleMethodV(this,obj,clazz,
methodID,args);
va_end(args);
return result;
}
jdouble CallNonvirtualDoubleMethodV(jobject obj, jclass clazz,
jmethodID methodID,
va_list args) {
return functions->CallNonvirtualDoubleMethodV(this,obj,clazz,
methodID,args);
}
jdouble CallNonvirtualDoubleMethodA(jobject obj, jclass clazz,
jmethodID methodID,
const jvalue * args) {
return functions->CallNonvirtualDoubleMethodA(this,obj,clazz,
methodID,args);
}
void CallNonvirtualVoidMethod(jobject obj, jclass clazz,
jmethodID methodID, ...) {
va_list args;
va_start(args,methodID);
functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args);
va_end(args);
}
void CallNonvirtualVoidMethodV(jobject obj, jclass clazz,
jmethodID methodID,
va_list args) {
functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args);
}
void CallNonvirtualVoidMethodA(jobject obj, jclass clazz,
jmethodID methodID,
const jvalue * args) {
functions->CallNonvirtualVoidMethodA(this,obj,clazz,methodID,args);
}
jfieldID GetFieldID(jclass clazz, const char *name,
const char *sig) {
return functions->GetFieldID(this,clazz,name,sig);
}
jobject GetObjectField(jobject obj, jfieldID fieldID) {
return functions->GetObjectField(this,obj,fieldID);
}
jboolean GetBooleanField(jobject obj, jfieldID fieldID) {
return functions->GetBooleanField(this,obj,fieldID);
}
jbyte GetByteField(jobject obj, jfieldID fieldID) {
return functions->GetByteField(this,obj,fieldID);
}
jchar GetCharField(jobject obj, jfieldID fieldID) {
return functions->GetCharField(this,obj,fieldID);
}
jshort GetShortField(jobject obj, jfieldID fieldID) {
return functions->GetShortField(this,obj,fieldID);
}
jint GetIntField(jobject obj, jfieldID fieldID) {
return functions->GetIntField(this,obj,fieldID);
}
jlong GetLongField(jobject obj, jfieldID fieldID) {
return functions->GetLongField(this,obj,fieldID);
}
jfloat GetFloatField(jobject obj, jfieldID fieldID) {
return functions->GetFloatField(this,obj,fieldID);
}
jdouble GetDoubleField(jobject obj, jfieldID fieldID) {
return functions->GetDoubleField(this,obj,fieldID);
}
void SetObjectField(jobject obj, jfieldID fieldID, jobject val) {
functions->SetObjectField(this,obj,fieldID,val);
}
void SetBooleanField(jobject obj, jfieldID fieldID,
jboolean val) {
functions->SetBooleanField(this,obj,fieldID,val);
}
void SetByteField(jobject obj, jfieldID fieldID,
jbyte val) {
functions->SetByteField(this,obj,fieldID,val);
}
void SetCharField(jobject obj, jfieldID fieldID,
jchar val) {
functions->SetCharField(this,obj,fieldID,val);
}
void SetShortField(jobject obj, jfieldID fieldID,
jshort val) {
functions->SetShortField(this,obj,fieldID,val);
}
void SetIntField(jobject obj, jfieldID fieldID,
jint val) {
functions->SetIntField(this,obj,fieldID,val);
}
void SetLongField(jobject obj, jfieldID fieldID,
jlong val) {
functions->SetLongField(this,obj,fieldID,val);
}
void SetFloatField(jobject obj, jfieldID fieldID,
jfloat val) {
functions->SetFloatField(this,obj,fieldID,val);
}
void SetDoubleField(jobject obj, jfieldID fieldID,
jdouble val) {
functions->SetDoubleField(this,obj,fieldID,val);
}
jmethodID GetStaticMethodID(jclass clazz, const char *name,
const char *sig) {
return functions->GetStaticMethodID(this,clazz,name,sig);
}
jobject CallStaticObjectMethod(jclass clazz, jmethodID methodID,
...) {
va_list args;
jobject result;
va_start(args,methodID);
result = functions->CallStaticObjectMethodV(this,clazz,methodID,args);
va_end(args);
return result;
}
jobject CallStaticObjectMethodV(jclass clazz, jmethodID methodID,
va_list args) {
return functions->CallStaticObjectMethodV(this,clazz,methodID,args);
}
jobject CallStaticObjectMethodA(jclass clazz, jmethodID methodID,
const jvalue *args) {
return functions->CallStaticObjectMethodA(this,clazz,methodID,args);
}
jboolean CallStaticBooleanMethod(jclass clazz,
jmethodID methodID, ...) {
va_list args;
jboolean result;
va_start(args,methodID);
result = functions->CallStaticBooleanMethodV(this,clazz,methodID,args);
va_end(args);
return result;
}
jboolean CallStaticBooleanMethodV(jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallStaticBooleanMethodV(this,clazz,methodID,args);
}
jboolean CallStaticBooleanMethodA(jclass clazz,
jmethodID methodID, const jvalue *args) {
return functions->CallStaticBooleanMethodA(this,clazz,methodID,args);
}
jbyte CallStaticByteMethod(jclass clazz,
jmethodID methodID, ...) {
va_list args;
jbyte result;
va_start(args,methodID);
result = functions->CallStaticByteMethodV(this,clazz,methodID,args);
va_end(args);
return result;
}
jbyte CallStaticByteMethodV(jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallStaticByteMethodV(this,clazz,methodID,args);
}
jbyte CallStaticByteMethodA(jclass clazz,
jmethodID methodID, const jvalue *args) {
return functions->CallStaticByteMethodA(this,clazz,methodID,args);
}
jchar CallStaticCharMethod(jclass clazz,
jmethodID methodID, ...) {
va_list args;
jchar result;
va_start(args,methodID);
result = functions->CallStaticCharMethodV(this,clazz,methodID,args);
va_end(args);
return result;
}
jchar CallStaticCharMethodV(jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallStaticCharMethodV(this,clazz,methodID,args);
}
jchar CallStaticCharMethodA(jclass clazz,
jmethodID methodID, const jvalue *args) {
return functions->CallStaticCharMethodA(this,clazz,methodID,args);
}
jshort CallStaticShortMethod(jclass clazz,
jmethodID methodID, ...) {
va_list args;
jshort result;
va_start(args,methodID);
result = functions->CallStaticShortMethodV(this,clazz,methodID,args);
va_end(args);
return result;
}
jshort CallStaticShortMethodV(jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallStaticShortMethodV(this,clazz,methodID,args);
}
jshort CallStaticShortMethodA(jclass clazz,
jmethodID methodID, const jvalue *args) {
return functions->CallStaticShortMethodA(this,clazz,methodID,args);
}
jint CallStaticIntMethod(jclass clazz,
jmethodID methodID, ...) {
va_list args;
jint result;
va_start(args,methodID);
result = functions->CallStaticIntMethodV(this,clazz,methodID,args);
va_end(args);
return result;
}
jint CallStaticIntMethodV(jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallStaticIntMethodV(this,clazz,methodID,args);
}
jint CallStaticIntMethodA(jclass clazz,
jmethodID methodID, const jvalue *args) {
return functions->CallStaticIntMethodA(this,clazz,methodID,args);
}
jlong CallStaticLongMethod(jclass clazz,
jmethodID methodID, ...) {
va_list args;
jlong result;
va_start(args,methodID);
result = functions->CallStaticLongMethodV(this,clazz,methodID,args);
va_end(args);
return result;
}
jlong CallStaticLongMethodV(jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallStaticLongMethodV(this,clazz,methodID,args);
}
jlong CallStaticLongMethodA(jclass clazz,
jmethodID methodID, const jvalue *args) {
return functions->CallStaticLongMethodA(this,clazz,methodID,args);
}
jfloat CallStaticFloatMethod(jclass clazz,
jmethodID methodID, ...) {
va_list args;
jfloat result;
va_start(args,methodID);
result = functions->CallStaticFloatMethodV(this,clazz,methodID,args);
va_end(args);
return result;
}
jfloat CallStaticFloatMethodV(jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallStaticFloatMethodV(this,clazz,methodID,args);
}
jfloat CallStaticFloatMethodA(jclass clazz,
jmethodID methodID, const jvalue *args) {
return functions->CallStaticFloatMethodA(this,clazz,methodID,args);
}
jdouble CallStaticDoubleMethod(jclass clazz,
jmethodID methodID, ...) {
va_list args;
jdouble result;
va_start(args,methodID);
result = functions->CallStaticDoubleMethodV(this,clazz,methodID,args);
va_end(args);
return result;
}
jdouble CallStaticDoubleMethodV(jclass clazz,
jmethodID methodID, va_list args) {
return functions->CallStaticDoubleMethodV(this,clazz,methodID,args);
}
jdouble CallStaticDoubleMethodA(jclass clazz,
jmethodID methodID, const jvalue *args) {
return functions->CallStaticDoubleMethodA(this,clazz,methodID,args);
}
void CallStaticVoidMethod(jclass cls, jmethodID methodID, ...) {
va_list args;
va_start(args,methodID);
functions->CallStaticVoidMethodV(this,cls,methodID,args);
va_end(args);
}
void CallStaticVoidMethodV(jclass cls, jmethodID methodID,
va_list args) {
functions->CallStaticVoidMethodV(this,cls,methodID,args);
}
void CallStaticVoidMethodA(jclass cls, jmethodID methodID,
const jvalue * args) {
functions->CallStaticVoidMethodA(this,cls,methodID,args);
}
jfieldID GetStaticFieldID(jclass clazz, const char *name,
const char *sig) {
return functions->GetStaticFieldID(this,clazz,name,sig);
}
jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) {
return functions->GetStaticObjectField(this,clazz,fieldID);
}
jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) {
return functions->GetStaticBooleanField(this,clazz,fieldID);
}
jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) {
return functions->GetStaticByteField(this,clazz,fieldID);
}
jchar GetStaticCharField(jclass clazz, jfieldID fieldID) {
return functions->GetStaticCharField(this,clazz,fieldID);
}
jshort GetStaticShortField(jclass clazz, jfieldID fieldID) {
return functions->GetStaticShortField(this,clazz,fieldID);
}
jint GetStaticIntField(jclass clazz, jfieldID fieldID) {
return functions->GetStaticIntField(this,clazz,fieldID);
}
jlong GetStaticLongField(jclass clazz, jfieldID fieldID) {
return functions->GetStaticLongField(this,clazz,fieldID);
}
jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) {
return functions->GetStaticFloatField(this,clazz,fieldID);
}
jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) {
return functions->GetStaticDoubleField(this,clazz,fieldID);
}
void SetStaticObjectField(jclass clazz, jfieldID fieldID,
jobject value) {
functions->SetStaticObjectField(this,clazz,fieldID,value);
}
void SetStaticBooleanField(jclass clazz, jfieldID fieldID,
jboolean value) {
functions->SetStaticBooleanField(this,clazz,fieldID,value);
}
void SetStaticByteField(jclass clazz, jfieldID fieldID,
jbyte value) {
functions->SetStaticByteField(this,clazz,fieldID,value);
}
void SetStaticCharField(jclass clazz, jfieldID fieldID,
jchar value) {
functions->SetStaticCharField(this,clazz,fieldID,value);
}
void SetStaticShortField(jclass clazz, jfieldID fieldID,
jshort value) {
functions->SetStaticShortField(this,clazz,fieldID,value);
}
void SetStaticIntField(jclass clazz, jfieldID fieldID,
jint value) {
functions->SetStaticIntField(this,clazz,fieldID,value);
}
void SetStaticLongField(jclass clazz, jfieldID fieldID,
jlong value) {
functions->SetStaticLongField(this,clazz,fieldID,value);
}
void SetStaticFloatField(jclass clazz, jfieldID fieldID,
jfloat value) {
functions->SetStaticFloatField(this,clazz,fieldID,value);
}
void SetStaticDoubleField(jclass clazz, jfieldID fieldID,
jdouble value) {
functions->SetStaticDoubleField(this,clazz,fieldID,value);
}
jstring NewString(const jchar *unicode, jsize len) {
return functions->NewString(this,unicode,len);
}
jsize GetStringLength(jstring str) {
return functions->GetStringLength(this,str);
}
const jchar *GetStringChars(jstring str, jboolean *isCopy) {
return functions->GetStringChars(this,str,isCopy);
}
void ReleaseStringChars(jstring str, const jchar *chars) {
functions->ReleaseStringChars(this,str,chars);
}
jstring NewStringUTF(const char *utf) {
return functions->NewStringUTF(this,utf);
}
jsize GetStringUTFLength(jstring str) {
return functions->GetStringUTFLength(this,str);
}
const char* GetStringUTFChars(jstring str, jboolean *isCopy) {
return functions->GetStringUTFChars(this,str,isCopy);
}
void ReleaseStringUTFChars(jstring str, const char* chars) {
functions->ReleaseStringUTFChars(this,str,chars);
}
jsize GetArrayLength(jarray array) {
return functions->GetArrayLength(this,array);
}
jobjectArray NewObjectArray(jsize len, jclass clazz,
jobject init) {
return functions->NewObjectArray(this,len,clazz,init);
}
jobject GetObjectArrayElement(jobjectArray array, jsize index) {
return functions->GetObjectArrayElement(this,array,index);
}
void SetObjectArrayElement(jobjectArray array, jsize index,
jobject val) {
functions->SetObjectArrayElement(this,array,index,val);
}
jbooleanArray NewBooleanArray(jsize len) {
return functions->NewBooleanArray(this,len);
}
jbyteArray NewByteArray(jsize len) {
return functions->NewByteArray(this,len);
}
jcharArray NewCharArray(jsize len) {
return functions->NewCharArray(this,len);
}
jshortArray NewShortArray(jsize len) {
return functions->NewShortArray(this,len);
}
jintArray NewIntArray(jsize len) {
return functions->NewIntArray(this,len);
}
jlongArray NewLongArray(jsize len) {
return functions->NewLongArray(this,len);
}
jfloatArray NewFloatArray(jsize len) {
return functions->NewFloatArray(this,len);
}
jdoubleArray NewDoubleArray(jsize len) {
return functions->NewDoubleArray(this,len);
}
jboolean * GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy) {
return functions->GetBooleanArrayElements(this,array,isCopy);
}
jbyte * GetByteArrayElements(jbyteArray array, jboolean *isCopy) {
return functions->GetByteArrayElements(this,array,isCopy);
}
jchar * GetCharArrayElements(jcharArray array, jboolean *isCopy) {
return functions->GetCharArrayElements(this,array,isCopy);
}
jshort * GetShortArrayElements(jshortArray array, jboolean *isCopy) {
return functions->GetShortArrayElements(this,array,isCopy);
}
jint * GetIntArrayElements(jintArray array, jboolean *isCopy) {
return functions->GetIntArrayElements(this,array,isCopy);
}
jlong * GetLongArrayElements(jlongArray array, jboolean *isCopy) {
return functions->GetLongArrayElements(this,array,isCopy);
}
jfloat * GetFloatArrayElements(jfloatArray array, jboolean *isCopy) {
return functions->GetFloatArrayElements(this,array,isCopy);
}
jdouble * GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy) {
return functions->GetDoubleArrayElements(this,array,isCopy);
}
void ReleaseBooleanArrayElements(jbooleanArray array,
jboolean *elems,
jint mode) {
functions->ReleaseBooleanArrayElements(this,array,elems,mode);
}
void ReleaseByteArrayElements(jbyteArray array,
jbyte *elems,
jint mode) {
functions->ReleaseByteArrayElements(this,array,elems,mode);
}
void ReleaseCharArrayElements(jcharArray array,
jchar *elems,
jint mode) {
functions->ReleaseCharArrayElements(this,array,elems,mode);
}
void ReleaseShortArrayElements(jshortArray array,
jshort *elems,
jint mode) {
functions->ReleaseShortArrayElements(this,array,elems,mode);
}
void ReleaseIntArrayElements(jintArray array,
jint *elems,
jint mode) {
functions->ReleaseIntArrayElements(this,array,elems,mode);
}
void ReleaseLongArrayElements(jlongArray array,
jlong *elems,
jint mode) {
functions->ReleaseLongArrayElements(this,array,elems,mode);
}
void ReleaseFloatArrayElements(jfloatArray array,
jfloat *elems,
jint mode) {
functions->ReleaseFloatArrayElements(this,array,elems,mode);
}
void ReleaseDoubleArrayElements(jdoubleArray array,
jdouble *elems,
jint mode) {
functions->ReleaseDoubleArrayElements(this,array,elems,mode);
}
void GetBooleanArrayRegion(jbooleanArray array,
jsize start, jsize len, jboolean *buf) {
functions->GetBooleanArrayRegion(this,array,start,len,buf);
}
void GetByteArrayRegion(jbyteArray array,
jsize start, jsize len, jbyte *buf) {
functions->GetByteArrayRegion(this,array,start,len,buf);
}
void GetCharArrayRegion(jcharArray array,
jsize start, jsize len, jchar *buf) {
functions->GetCharArrayRegion(this,array,start,len,buf);
}
void GetShortArrayRegion(jshortArray array,
jsize start, jsize len, jshort *buf) {
functions->GetShortArrayRegion(this,array,start,len,buf);
}
void GetIntArrayRegion(jintArray array,
jsize start, jsize len, jint *buf) {
functions->GetIntArrayRegion(this,array,start,len,buf);
}
void GetLongArrayRegion(jlongArray array,
jsize start, jsize len, jlong *buf) {
functions->GetLongArrayRegion(this,array,start,len,buf);
}
void GetFloatArrayRegion(jfloatArray array,
jsize start, jsize len, jfloat *buf) {
functions->GetFloatArrayRegion(this,array,start,len,buf);
}
void GetDoubleArrayRegion(jdoubleArray array,
jsize start, jsize len, jdouble *buf) {
functions->GetDoubleArrayRegion(this,array,start,len,buf);
}
void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
const jboolean *buf) {
functions->SetBooleanArrayRegion(this,array,start,len,buf);
}
void SetByteArrayRegion(jbyteArray array, jsize start, jsize len,
const jbyte *buf) {
functions->SetByteArrayRegion(this,array,start,len,buf);
}
void SetCharArrayRegion(jcharArray array, jsize start, jsize len,
const jchar *buf) {
functions->SetCharArrayRegion(this,array,start,len,buf);
}
void SetShortArrayRegion(jshortArray array, jsize start, jsize len,
const jshort *buf) {
functions->SetShortArrayRegion(this,array,start,len,buf);
}
void SetIntArrayRegion(jintArray array, jsize start, jsize len,
const jint *buf) {
functions->SetIntArrayRegion(this,array,start,len,buf);
}
void SetLongArrayRegion(jlongArray array, jsize start, jsize len,
const jlong *buf) {
functions->SetLongArrayRegion(this,array,start,len,buf);
}
void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
const jfloat *buf) {
functions->SetFloatArrayRegion(this,array,start,len,buf);
}
void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
const jdouble *buf) {
functions->SetDoubleArrayRegion(this,array,start,len,buf);
}
jint RegisterNatives(jclass clazz, const JNINativeMethod *methods,
jint nMethods) {
return functions->RegisterNatives(this,clazz,methods,nMethods);
}
jint UnregisterNatives(jclass clazz) {
return functions->UnregisterNatives(this,clazz);
}
jint MonitorEnter(jobject obj) {
return functions->MonitorEnter(this,obj);
}
jint MonitorExit(jobject obj) {
return functions->MonitorExit(this,obj);
}
jint GetJavaVM(JavaVM **vm) {
return functions->GetJavaVM(this,vm);
}
void GetStringRegion(jstring str, jsize start, jsize len, jchar *buf) {
functions->GetStringRegion(this,str,start,len,buf);
}
void GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf) {
functions->GetStringUTFRegion(this,str,start,len,buf);
}
void * GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) {
return functions->GetPrimitiveArrayCritical(this,array,isCopy);
}
void ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode) {
functions->ReleasePrimitiveArrayCritical(this,array,carray,mode);
}
const jchar * GetStringCritical(jstring string, jboolean *isCopy) {
return functions->GetStringCritical(this,string,isCopy);
}
void ReleaseStringCritical(jstring string, const jchar *cstring) {
functions->ReleaseStringCritical(this,string,cstring);
}
jweak NewWeakGlobalRef(jobject obj) {
return functions->NewWeakGlobalRef(this,obj);
}
void DeleteWeakGlobalRef(jweak ref) {
functions->DeleteWeakGlobalRef(this,ref);
}
jboolean ExceptionCheck() {
return functions->ExceptionCheck(this);
}
jobject NewDirectByteBuffer(void* address, jlong capacity) {
return functions->NewDirectByteBuffer(this, address, capacity);
}
void* GetDirectBufferAddress(jobject buf) {
return functions->GetDirectBufferAddress(this, buf);
}
jlong GetDirectBufferCapacity(jobject buf) {
return functions->GetDirectBufferCapacity(this, buf);
}
jobjectRefType GetObjectRefType(jobject obj) {
return functions->GetObjectRefType(this, obj);
}
#endif /* __cplusplus */
};
typedef struct JavaVMOption {
char *optionString;
void *extraInfo;
} JavaVMOption;
typedef struct JavaVMInitArgs {
jint version;
jint nOptions;
JavaVMOption *options;
jboolean ignoreUnrecognized;
} JavaVMInitArgs;
typedef struct JavaVMAttachArgs {
jint version;
char *name;
jobject group;
} JavaVMAttachArgs;
/* These will be VM-specific. */
#define JDK1_2
#define JDK1_4
/* End VM-specific. */
struct JNIInvokeInterface_ {
void *reserved0;
void *reserved1;
void *reserved2;
jint (JNICALL *DestroyJavaVM)(JavaVM *vm);
jint (JNICALL *AttachCurrentThread)(JavaVM *vm, void **penv, void *args);
jint (JNICALL *DetachCurrentThread)(JavaVM *vm);
jint (JNICALL *GetEnv)(JavaVM *vm, void **penv, jint version);
jint (JNICALL *AttachCurrentThreadAsDaemon)(JavaVM *vm, void **penv, void *args);
};
struct JavaVM_ {
const struct JNIInvokeInterface_ *functions;
#ifdef __cplusplus
jint DestroyJavaVM() {
return functions->DestroyJavaVM(this);
}
jint AttachCurrentThread(void **penv, void *args) {
return functions->AttachCurrentThread(this, penv, args);
}
jint DetachCurrentThread() {
return functions->DetachCurrentThread(this);
}
jint GetEnv(void **penv, jint version) {
return functions->GetEnv(this, penv, version);
}
jint AttachCurrentThreadAsDaemon(void **penv, void *args) {
return functions->AttachCurrentThreadAsDaemon(this, penv, args);
}
#endif
};
#ifdef _JNI_IMPLEMENTATION_
#define _JNI_IMPORT_OR_EXPORT_ JNIEXPORT
#else
#define _JNI_IMPORT_OR_EXPORT_ JNIIMPORT
#endif
_JNI_IMPORT_OR_EXPORT_ jint JNICALL
JNI_GetDefaultJavaVMInitArgs(void *args);
_JNI_IMPORT_OR_EXPORT_ jint JNICALL
JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args);
_JNI_IMPORT_OR_EXPORT_ jint JNICALL
JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *);
/* Defined by native libraries. */
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved);
JNIEXPORT void JNICALL
JNI_OnUnload(JavaVM *vm, void *reserved);
#define JNI_VERSION_1_1 0x00010001
#define JNI_VERSION_1_2 0x00010002
#define JNI_VERSION_1_4 0x00010004
#define JNI_VERSION_1_6 0x00010006
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* !_JAVASOFT_JNI_H_ */
/*
* Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT
#define JNIIMPORT
#define JNICALL
typedef int jint;
#ifdef _LP64 /* 64-bit Solaris */
typedef long jlong;
#else
typedef long long jlong;
#endif
typedef signed char jbyte;
#endif /* !_JAVASOFT_JNI_MD_H_ */
/*
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#ifndef HEADER_MD5_H
# define HEADER_MD5_H
# include <openssl/opensslconf.h>
# ifndef OPENSSL_NO_MD5
# include <openssl/e_os2.h>
# include <stddef.h>
# ifdef __cplusplus
extern "C" {
# endif
/*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* ! MD5_LONG has to be at least 32 bits wide. !
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
# define MD5_LONG unsigned int
# define MD5_CBLOCK 64
# define MD5_LBLOCK (MD5_CBLOCK/4)
# define MD5_DIGEST_LENGTH 16
typedef struct MD5state_st {
MD5_LONG A, B, C, D;
MD5_LONG Nl, Nh;
MD5_LONG data[MD5_LBLOCK];
unsigned int num;
} MD5_CTX;
int MD5_Init(MD5_CTX *c);
int MD5_Update(MD5_CTX *c, const void *data, size_t len);
int MD5_Final(unsigned char *md, MD5_CTX *c);
unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
void MD5_Transform(MD5_CTX *c, const unsigned char *b);
# ifdef __cplusplus
}
# endif
# endif
#endif
#ifndef _T_LIBBANK_H_
#define _T_LIBBANK_H_
#include <math.h>
#include <errno.h>
#include <fcntl.h> /* File control definitions */
#include <stdio.h>
#include <termios.h> /* POSIX terminal control definitions */
#include <unistd.h>
#include "com_xingdata_zzdpos_zxpay.h"
#include "jni.h"
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#endif
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class zxpay */
#ifndef _Included_zxpay
#define _Included_zxpay
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: zxpay
* Method: jsonpay
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_zxpay_jsonpay
(JNIEnv *, jclass, jstring);
#ifdef __cplusplus
}
#endif
#endif
package com.xingdata.zzdpos;
public class zxpay {
static {
System.loadLibrary("jsonpay");
}
public static native String jsonpay(String inStr);
}
*.a
*.nlm
*.res
config-win32.h
curl
curl_config.h
curl_config.h.in
stamp-h2
tool_hugehelp.c
tool_version.h.dist
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
import os
import ycm_core
# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
# You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM
# source code needs it.
'-DUSE_CLANG_COMPLETER',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>".
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
'-std=c++11',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x',
'c++',
'-isystem',
'../BoostParts',
'-isystem',
# This path will only work on OS X, but extra paths that don't exist are not
# harmful
'/System/Library/Frameworks/Python.framework/Headers',
'-isystem',
'../llvm/include',
'-isystem',
'../llvm/tools/clang/include',
'-I',
'.',
'-I',
'./ClangCompleter',
'-isystem',
'./tests/gmock/gtest',
'-isystem',
'./tests/gmock/gtest/include',
'-isystem',
'./tests/gmock',
'-isystem',
'./tests/gmock/include',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1',
'-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include',
'-I',
'/usr/local/Cellar/llvm/4.0.0_1/include/c++/v1',
'-I',
'/Users/zhoush/include/',
'-I',
'/Users/zhoush/Git/Notes/books/system/APUE/include',
'-I',
'/Users/zhoush/Working/zxpay/app/incl',
'-I',
'/Users/zhoush/Working/zxpay/pts/incl',
'-I',
'/usr/local/opt/openssl/include',
'-I',
'/usr/local/opt/curl/include',
'-I',
'../include'
]
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# You can get CMake to generate this file for you by adding:
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
# to your CMakeLists.txt file.
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''
if os.path.exists(compilation_database_folder):
database = ycm_core.CompilationDatabase(compilation_database_folder)
else:
database = None
SOURCE_EXTENSIONS = ['.cpp', '.cxx', '.cc', '.c', '.m', '.mm']
def DirectoryOfThisScript():
return os.path.dirname(os.path.abspath(__file__))
def MakeRelativePathsInFlagsAbsolute(flags, working_directory):
if not working_directory:
return list(flags)
new_flags = []
make_next_absolute = False
path_flags = ['-isystem', '-I', '-iquote', '--sysroot=']
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith('/'):
new_flag = os.path.join(working_directory, flag)
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith(path_flag):
path = flag[len(path_flag):]
new_flag = path_flag + os.path.join(working_directory, path)
break
if new_flag:
new_flags.append(new_flag)
return new_flags
def IsHeaderFile(filename):
extension = os.path.splitext(filename)[1]
return extension in ['.h', '.hxx', '.hpp', '.hh']
def GetCompilationInfoForFile(filename):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
if IsHeaderFile(filename):
basename = os.path.splitext(filename)[0]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists(replacement_file):
compilation_info = database.GetCompilationInfoForFile(
replacement_file)
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile(filename)
def FlagsForFile(filename, **kwargs):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile(filename)
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_)
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
try:
final_flags.remove('-stdlib=libc++')
except ValueError:
pass
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute(flags, relative_to)
return {'flags': final_flags}
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
TARGET_PLATFORM := all
LOCAL_MODULE := jsonpay
LOCAL_SRC_FILES := bcccode.c bccmd5.c cJSON.c do_log.c do_trans.c do_trans_pax.c native-lib.cpp http.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_CFLAGS := -DTEST
include $(BUILD_SHARED_LIBRARY)
#include "bcccode.h"
/**
* @brief key1=val1&key2=val2&..
*
* 拼接字符串的值不做url编码
*
* @param key 关键字
* val 值
* out 传出字符串
* len 传出字符串长度
* @return 拼接的字符串长度
*/
int BCC_str_set_val_raw(const char *key, const char *val, char *out, int *len)
{
if (val[0] != 0 && strncmp(val, "NULL", 4) != 0) {
sprintf(out + strlen(out), "%s=%s&", key, val);
}
*len = strlen(out);
return *len;
}
/**
* @brief key1=val1&key2=val2&..
*
* 拼接字符串后做url编码
*
* @param key 关键字
* val 值
* out 传出字符串
* len 传出字符串长度
* @return 拼接的字符串长度
*/
int BCC_str_set_val_url(const char *key, const char *val, char *out, int *len)
{
char tmp[BUFSIZ] = {0};
if (val[0] != 0 && strncmp(val, "NULL", 4) != 0) {
BCC_url_encode(val, strlen(val), tmp, sizeof(tmp) - 1);
sprintf(out + strlen(out), "%s=%s&", key, tmp);
}
*len = strlen(out);
return *len;
}
/**
* @brief 获取json要素
*
* 在json包中根据指定的key获取要素值
*
* @param pJson cJSON解析的json对象
* key 指定的 key
* out json中 key 的值
* len 传入的 out 的长度
*
* @return =0, 成功
* -1, 失败
*/
int BCC_json_get_val(const cJSON *pJson, const char *key, char *out, size_t len)
{
int ret = 0;
cJSON *pRet = NULL;
pRet = cJSON_GetObjectItem(pJson, key);
if (pRet != NULL) {
switch (pRet->type) {
case cJSON_String:
if (strlen(pRet->valuestring) > len)
return -1;
else
strcpy(out, pRet->valuestring);
break;
case cJSON_Number:
sprintf(out, "%d", pRet->valueint);
break;
default:
return -1;
}
}
return ret;
}
/**
* @brief 向json字符串中添加key:value值
*
* 向json字符串中添加要素, 并追加逗号, 末尾要素需减去逗号
*
* @param key 关键字
* val 值
* out 传出json字符串
* len 传出json字符串长度
* @return json字符串长度
*/
int BCC_json_set_val(const char *key, const char *val, char *out, int *len)
{
if (val[0] != 0 && strncmp(val, "NULL", 4) != 0) {
sprintf(out + strlen(out), "\"%s\":\"%s\",", key, val);
}
*len = strlen(out);
return *len;
}
/**
* @brief BCC_url_encode 对字符串URL编码
*
* @param str 原字符串
* @param strSize 原字符串长度(不包括最后的\0)
* @param result 结果缓冲区的地址
* @param resultSize 结果缓冲区的大小(包括最后的\0)
*
* @return: >0:resultstring 里实际有效的长度
* 0: 解码失败.
*/
int BCC_url_encode(const char *str, const int strSize, char *result, const int resultSize)
{
int i;
int j = 0; //for result index
char ch;
if ((str == NULL) || (result == NULL) || (strSize <= 0) || (resultSize <= 0)) {
return 0;
}
for (i = 0; (i < strSize) && (j < resultSize); ++i) {
ch = str[i];
if (((ch >= 'A') && (ch <= 'Z')) ||
((ch >= 'a') && (ch <= 'z')) ||
((ch >= '0') && (ch <= '9'))) {
result[j++] = ch;
} else if (ch == ' ') {
result[j++] = '+';
} else if (ch == '.' || ch == '-' || ch == '_' || ch == '*') {
result[j++] = ch;
} else {
if (j + 3 < resultSize) {
sprintf(result + j, "%%%02X", (unsigned char)ch);
j += 3;
} else {
return 0;
}
}
}
result[j] = '\0';
return 0;
}
/**
* @brief BCC_url_decode 对字符串URL解码,编码的逆过程
*
* @param str 原字符串
* strSize 原字符串大小(不包括最后的\0)
* result 结果字符串缓存区
* resultSize 结果地址的缓冲区大小(包括最后的\0)
*
* @return: >0 result 里实际有效的字符串长度
* 0 解码失败
*/
int hex2num(char c)
{
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'z') return c - 'a' + 10; //这里+10的原因是:比如16进制的a值为10
if (c >= 'A' && c <= 'Z') return c - 'A' + 10;
printf("unexpected char: %c", c);
return '0';
}
int BCC_url_decode(const char *str, const int strSize, char *result, int resultSize)
{
char ch, ch1, ch2;
int i;
int j = 0; // record result index
if ((str == NULL) || (result == NULL) || (strSize <= 0) || (resultSize <= 0)) {
return 0;
}
for (i = 0; (i < strSize) && (j < resultSize); ++i) {
ch = str[i];
switch (ch) {
case '+':
result[j++] = ' ';
break;
case '%':
if (i + 2 < strSize) {
ch1 = hex2num(str[i + 1]); //高4位
ch2 = hex2num(str[i + 2]); //低4位
if ((ch1 != '0') && (ch2 != '0'))
result[j++] = (char)((ch1 << 4) | ch2);
i += 2;
break;
} else {
break;
}
default:
result[j++] = ch;
break;
}
}
result[j] = 0;
return j;
}
int BCC_code_upper_str(char *str, int len)
{
int i = 0;
for (i = 0; i < len; ++i) {
str[i] = toupper(str[i]);
}
return i;
}
/*************************************************************************
* 函数名: BCCMD5.C *
* 系统名: BASE CHIP COMPONENTS. SECU kit (BCC-base version 3.0) *
* 日 期:2008 3 29 *
* 描 述:加密MD5、MD5带密钥 函数 *
*************************************************************************/
#include "bccmd5.h"
/* BCC_POINTER defines a generic pointer type */
typedef unsigned char * BCC_POINTER;
/* BCC_UINT2 defines a two byte word */
typedef unsigned short int BCC_UINT2;
/* BCC_UINT4 defines a four byte word */
//typedef unsigned long int BCC_UINT4;
typedef unsigned int BCC_UINT4;
#define MD5_DIGEST_LENGTH 16
#define BCC_DEFINE_PROTO_LIST(list) list
/* MD5 context.*/
typedef struct _BCC_MD5_CTX
{
BCC_UINT4 state[4]; /* state (ABCD) */
BCC_UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} BCC_MD5_CTX;
/* Constants for MD5Transform routine.*/
#define BCC_DEFINE_S11 7
#define BCC_DEFINE_S12 12
#define BCC_DEFINE_S13 17
#define BCC_DEFINE_S14 22
#define BCC_DEFINE_S21 5
#define BCC_DEFINE_S22 9
#define BCC_DEFINE_S23 14
#define BCC_DEFINE_S24 20
#define BCC_DEFINE_S31 4
#define BCC_DEFINE_S32 11
#define BCC_DEFINE_S33 16
#define BCC_DEFINE_S34 23
#define BCC_DEFINE_S41 6
#define BCC_DEFINE_S42 10
#define BCC_DEFINE_S43 15
#define BCC_DEFINE_S44 21
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* F, G, H and I are basic MD5 functions. */
#define BCC_DEFINE_F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define BCC_DEFINE_G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define BCC_DEFINE_H(x, y, z) ((x) ^ (y) ^ (z))
#define BCC_DEFINE_I(x, y, z) ((y) ^ ((x) | (~z)))
/* BCC_DEFINE_ROTATE_LEFT rotates x left n bits.*/
#define BCC_DEFINE_ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* BCC_DEFINE_FF, BCC_DEFINE_GG, BCC_DEFINE_HH, and BCC_DEFINE_II transformations for rounds 1, 2, 3, and 4.Rotation is separate from addition to prevent recomputation.*/
#define BCC_DEFINE_FF(a, b, c, d, x, s, ac) {(a) += BCC_DEFINE_F ((b), (c), (d)) + (x) + (BCC_UINT4)(ac);(a) = BCC_DEFINE_ROTATE_LEFT ((a), (s));(a) += (b);}
#define BCC_DEFINE_GG(a, b, c, d, x, s, ac) {(a) += BCC_DEFINE_G ((b), (c), (d)) + (x) + (BCC_UINT4)(ac);(a) = BCC_DEFINE_ROTATE_LEFT ((a), (s));(a) += (b);}
#define BCC_DEFINE_HH(a, b, c, d, x, s, ac) {(a) += BCC_DEFINE_H ((b), (c), (d)) + (x) + (BCC_UINT4)(ac);(a) = BCC_DEFINE_ROTATE_LEFT ((a), (s));(a) += (b);}
#define BCC_DEFINE_II(a, b, c, d, x, s, ac) {(a) += BCC_DEFINE_I ((b), (c), (d)) + (x) + (BCC_UINT4)(ac);(a) = BCC_DEFINE_ROTATE_LEFT ((a), (s));(a) += (b);}
static void BCC_MD5_Func_Transform BCC_DEFINE_PROTO_LIST ((BCC_UINT4 [4], unsigned char [64]));
static void BCC_MD5_Func_Encode BCC_DEFINE_PROTO_LIST ((unsigned char *, BCC_UINT4 *, unsigned int));
static void BCC_MD5_Func_Decode BCC_DEFINE_PROTO_LIST ((BCC_UINT4 *, unsigned char *, unsigned int));
static void BCC_MD5_Func_memcpy BCC_DEFINE_PROTO_LIST ((BCC_POINTER, BCC_POINTER, unsigned int));
static void BCC_MD5_Func_memset BCC_DEFINE_PROTO_LIST ((BCC_POINTER, int, unsigned int));
static void BCC_MD5_Func_Init BCC_DEFINE_PROTO_LIST ((BCC_MD5_CTX *));
static void BCC_MD5_Func_Update BCC_DEFINE_PROTO_LIST ((BCC_MD5_CTX *, unsigned char *, unsigned int));
static void BCC_MD5_Func_Final BCC_DEFINE_PROTO_LIST ((unsigned char [16], BCC_MD5_CTX *));
//static void BCC_MD5_Func_TimeTrial BCC_DEFINE_PROTO_LIST ((void));
//static void BCC_MD5_Func_Encode BCC_DEFINE_PROTO_LIST ((unsigned char *, BCC_UINT4 *, unsigned int));
//static void BCC_MD5_Func_Decode BCC_DEFINE_PROTO_LIST ((BCC_UINT4 *, unsigned char *, unsigned int));
/* MD5 initialization. Begins an MD5 operation, writing a new context.*/
static void BCC_MD5_Func_Init(BCC_MD5_CTX *context)
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants.*/
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
return;
}
/*MD5 block update operation. Continues an MD5 message-digest operation, processing another message block, and updating the context.*/
static void BCC_MD5_Func_Update(BCC_MD5_CTX *context,unsigned char *input,unsigned int inputLen)
{
unsigned int i, index, partLen;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((BCC_UINT4)inputLen << 3)) < ((BCC_UINT4)inputLen << 3))
{
context->count[1]++;
}
context->count[1] += ((BCC_UINT4)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible. */
if(inputLen >= partLen)
{
BCC_MD5_Func_memcpy ((BCC_POINTER)&context->buffer[index], (BCC_POINTER)input, partLen);
BCC_MD5_Func_Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
{
BCC_MD5_Func_Transform (context->state, &input[i]);
}
index = 0;
}
else
i = 0;
/* Buffer remaining input */
BCC_MD5_Func_memcpy((BCC_POINTER)&context->buffer[index], (BCC_POINTER)&input[i],inputLen-i);
return;
}
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
static void BCC_MD5_Func_Final(unsigned char digest[16],BCC_MD5_CTX *context)
{
unsigned char bits[8];
unsigned int index, padLen;
/* Save number of bits */
BCC_MD5_Func_Encode (bits, context->count, 8);
/* Pad out to 56 mod 64.*/
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
BCC_MD5_Func_Update (context, PADDING, padLen);
/* Append length (before padding) */
BCC_MD5_Func_Update (context, bits, 8);
/* Store state in digest */
BCC_MD5_Func_Encode (digest, context->state, 16);
/* Zeroize sensitive information.*/
BCC_MD5_Func_memset ((BCC_POINTER)context, 0, sizeof (*context));
return;
}
/* MD5 basic transformation. Transforms state based on block.*/
static void BCC_MD5_Func_Transform(BCC_UINT4 state[4],unsigned char block[64])
{
BCC_UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
BCC_MD5_Func_Decode (x, block, 64);
/* Round 1 */
BCC_DEFINE_FF (a, b, c, d, x[ 0], BCC_DEFINE_S11, 0xd76aa478); /* 1 */
BCC_DEFINE_FF (d, a, b, c, x[ 1], BCC_DEFINE_S12, 0xe8c7b756); /* 2 */
BCC_DEFINE_FF (c, d, a, b, x[ 2], BCC_DEFINE_S13, 0x242070db); /* 3 */
BCC_DEFINE_FF (b, c, d, a, x[ 3], BCC_DEFINE_S14, 0xc1bdceee); /* 4 */
BCC_DEFINE_FF (a, b, c, d, x[ 4], BCC_DEFINE_S11, 0xf57c0faf); /* 5 */
BCC_DEFINE_FF (d, a, b, c, x[ 5], BCC_DEFINE_S12, 0x4787c62a); /* 6 */
BCC_DEFINE_FF (c, d, a, b, x[ 6], BCC_DEFINE_S13, 0xa8304613); /* 7 */
BCC_DEFINE_FF (b, c, d, a, x[ 7], BCC_DEFINE_S14, 0xfd469501); /* 8 */
BCC_DEFINE_FF (a, b, c, d, x[ 8], BCC_DEFINE_S11, 0x698098d8); /* 9 */
BCC_DEFINE_FF (d, a, b, c, x[ 9], BCC_DEFINE_S12, 0x8b44f7af); /* 10 */
BCC_DEFINE_FF (c, d, a, b, x[10], BCC_DEFINE_S13, 0xffff5bb1); /* 11 */
BCC_DEFINE_FF (b, c, d, a, x[11], BCC_DEFINE_S14, 0x895cd7be); /* 12 */
BCC_DEFINE_FF (a, b, c, d, x[12], BCC_DEFINE_S11, 0x6b901122); /* 13 */
BCC_DEFINE_FF (d, a, b, c, x[13], BCC_DEFINE_S12, 0xfd987193); /* 14 */
BCC_DEFINE_FF (c, d, a, b, x[14], BCC_DEFINE_S13, 0xa679438e); /* 15 */
BCC_DEFINE_FF (b, c, d, a, x[15], BCC_DEFINE_S14, 0x49b40821); /* 16 */
/* Round 2 */
BCC_DEFINE_GG (a, b, c, d, x[ 1], BCC_DEFINE_S21, 0xf61e2562); /* 17 */
BCC_DEFINE_GG (d, a, b, c, x[ 6], BCC_DEFINE_S22, 0xc040b340); /* 18 */
BCC_DEFINE_GG (c, d, a, b, x[11], BCC_DEFINE_S23, 0x265e5a51); /* 19 */
BCC_DEFINE_GG (b, c, d, a, x[ 0], BCC_DEFINE_S24, 0xe9b6c7aa); /* 20 */
BCC_DEFINE_GG (a, b, c, d, x[ 5], BCC_DEFINE_S21, 0xd62f105d); /* 21 */
BCC_DEFINE_GG (d, a, b, c, x[10], BCC_DEFINE_S22, 0x2441453); /* 22 */
BCC_DEFINE_GG (c, d, a, b, x[15], BCC_DEFINE_S23, 0xd8a1e681); /* 23 */
BCC_DEFINE_GG (b, c, d, a, x[ 4], BCC_DEFINE_S24, 0xe7d3fbc8); /* 24 */
BCC_DEFINE_GG (a, b, c, d, x[ 9], BCC_DEFINE_S21, 0x21e1cde6); /* 25 */
BCC_DEFINE_GG (d, a, b, c, x[14], BCC_DEFINE_S22, 0xc33707d6); /* 26 */
BCC_DEFINE_GG (c, d, a, b, x[ 3], BCC_DEFINE_S23, 0xf4d50d87); /* 27 */
BCC_DEFINE_GG (b, c, d, a, x[ 8], BCC_DEFINE_S24, 0x455a14ed); /* 28 */
BCC_DEFINE_GG (a, b, c, d, x[13], BCC_DEFINE_S21, 0xa9e3e905); /* 29 */
BCC_DEFINE_GG (d, a, b, c, x[ 2], BCC_DEFINE_S22, 0xfcefa3f8); /* 30 */
BCC_DEFINE_GG (c, d, a, b, x[ 7], BCC_DEFINE_S23, 0x676f02d9); /* 31 */
BCC_DEFINE_GG (b, c, d, a, x[12], BCC_DEFINE_S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
BCC_DEFINE_HH (a, b, c, d, x[ 5], BCC_DEFINE_S31, 0xfffa3942); /* 33 */
BCC_DEFINE_HH (d, a, b, c, x[ 8], BCC_DEFINE_S32, 0x8771f681); /* 34 */
BCC_DEFINE_HH (c, d, a, b, x[11], BCC_DEFINE_S33, 0x6d9d6122); /* 35 */
BCC_DEFINE_HH (b, c, d, a, x[14], BCC_DEFINE_S34, 0xfde5380c); /* 36 */
BCC_DEFINE_HH (a, b, c, d, x[ 1], BCC_DEFINE_S31, 0xa4beea44); /* 37 */
BCC_DEFINE_HH (d, a, b, c, x[ 4], BCC_DEFINE_S32, 0x4bdecfa9); /* 38 */
BCC_DEFINE_HH (c, d, a, b, x[ 7], BCC_DEFINE_S33, 0xf6bb4b60); /* 39 */
BCC_DEFINE_HH (b, c, d, a, x[10], BCC_DEFINE_S34, 0xbebfbc70); /* 40 */
BCC_DEFINE_HH (a, b, c, d, x[13], BCC_DEFINE_S31, 0x289b7ec6); /* 41 */
BCC_DEFINE_HH (d, a, b, c, x[ 0], BCC_DEFINE_S32, 0xeaa127fa); /* 42 */
BCC_DEFINE_HH (c, d, a, b, x[ 3], BCC_DEFINE_S33, 0xd4ef3085); /* 43 */
BCC_DEFINE_HH (b, c, d, a, x[ 6], BCC_DEFINE_S34, 0x4881d05); /* 44 */
BCC_DEFINE_HH (a, b, c, d, x[ 9], BCC_DEFINE_S31, 0xd9d4d039); /* 45 */
BCC_DEFINE_HH (d, a, b, c, x[12], BCC_DEFINE_S32, 0xe6db99e5); /* 46 */
BCC_DEFINE_HH (c, d, a, b, x[15], BCC_DEFINE_S33, 0x1fa27cf8); /* 47 */
BCC_DEFINE_HH (b, c, d, a, x[ 2], BCC_DEFINE_S34, 0xc4ac5665); /* 48 */
/* Round 4 */
BCC_DEFINE_II (a, b, c, d, x[ 0], BCC_DEFINE_S41, 0xf4292244); /* 49 */
BCC_DEFINE_II (d, a, b, c, x[ 7], BCC_DEFINE_S42, 0x432aff97); /* 50 */
BCC_DEFINE_II (c, d, a, b, x[14], BCC_DEFINE_S43, 0xab9423a7); /* 51 */
BCC_DEFINE_II (b, c, d, a, x[ 5], BCC_DEFINE_S44, 0xfc93a039); /* 52 */
BCC_DEFINE_II (a, b, c, d, x[12], BCC_DEFINE_S41, 0x655b59c3); /* 53 */
BCC_DEFINE_II (d, a, b, c, x[ 3], BCC_DEFINE_S42, 0x8f0ccc92); /* 54 */
BCC_DEFINE_II (c, d, a, b, x[10], BCC_DEFINE_S43, 0xffeff47d); /* 55 */
BCC_DEFINE_II (b, c, d, a, x[ 1], BCC_DEFINE_S44, 0x85845dd1); /* 56 */
BCC_DEFINE_II (a, b, c, d, x[ 8], BCC_DEFINE_S41, 0x6fa87e4f); /* 57 */
BCC_DEFINE_II (d, a, b, c, x[15], BCC_DEFINE_S42, 0xfe2ce6e0); /* 58 */
BCC_DEFINE_II (c, d, a, b, x[ 6], BCC_DEFINE_S43, 0xa3014314); /* 59 */
BCC_DEFINE_II (b, c, d, a, x[13], BCC_DEFINE_S44, 0x4e0811a1); /* 60 */
BCC_DEFINE_II (a, b, c, d, x[ 4], BCC_DEFINE_S41, 0xf7537e82); /* 61 */
BCC_DEFINE_II (d, a, b, c, x[11], BCC_DEFINE_S42, 0xbd3af235); /* 62 */
BCC_DEFINE_II (c, d, a, b, x[ 2], BCC_DEFINE_S43, 0x2ad7d2bb); /* 63 */
BCC_DEFINE_II (b, c, d, a, x[ 9], BCC_DEFINE_S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information.*/
BCC_MD5_Func_memset((BCC_POINTER)x, 0, sizeof (x));
return;
}
/* Encodes input (BCC_UINT4) into output (unsigned char). Assumes len is a multiple of 4.*/
static void BCC_MD5_Func_Encode(unsigned char *output,BCC_UINT4 *input,unsigned int len)
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
{
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
}
return;
}
/* Decodes input (unsigned char) into output (BCC_UINT4). Assumes len is a multiple of 4.*/
static void BCC_MD5_Func_Decode(BCC_UINT4 *output,unsigned char *input,unsigned int len)
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((BCC_UINT4)input[j]) | (((BCC_UINT4)input[j+1]) << 8) | (((BCC_UINT4)input[j+2]) << 16) | (((BCC_UINT4)input[j+3]) << 24);
return;
}
/* Note: Replace "for loop" with standard memcpy if possible.*/
static void BCC_MD5_Func_memcpy(BCC_POINTER output,BCC_POINTER input,unsigned int len)
{
unsigned int i;
for (i = 0; i < len; i++)
output[i] = input[i];
return;
}
/* Note: Replace "for loop" with standard memset if possible.*/
static void BCC_MD5_Func_memset(BCC_POINTER output,int value,unsigned int len)
{
unsigned int i;
for (i = 0; i < len; i++)
((char *)output)[i] = (char)value;
return;
}
/* Digests a string and prints the result.*/
char *str2md5(unsigned char *str, int length) {
int n;
BCC_MD5_CTX c;
unsigned char digest[16];
char *out = (char*)malloc(33);
BCC_MD5_Func_Init(&c);
while (length > 0) {
if (length > 512) {
BCC_MD5_Func_Update(&c, str, 512);
} else {
BCC_MD5_Func_Update(&c, str, length);
}
length -= 512;
str += 512;
}
BCC_MD5_Func_Final(digest, &c);
for (n = 0; n < 16; ++n) {
snprintf(&(out[n*2]), 16*2, "%02x", (unsigned int)digest[n]);
}
return out;
}
void BCC_MD5_gen(unsigned char *in, unsigned char *out)
{
BCC_MD5_CTX c;
unsigned char digest[MD5_DIGEST_LENGTH];
int i = 0;
BCC_MD5_Func_Init(&c);
BCC_MD5_Func_Update(&c, (unsigned char *)in, strlen((const char *)in));
BCC_MD5_Func_Final(digest, &c);
for (i = 0; i < MD5_DIGEST_LENGTH; ++i) {
sprintf((char*)&out[2 * i], "%02x", digest[i]);
}
return;
}
/************************************************************************
* caddr_t out_digest; * caller digest to be filled in *
* unsigned char* text; * pointer to data stream *
* int text_len; * length of data stream *
* unsigned char* key; * pointer to authentication key *
* int key_len; * length of authentication key *
************************************************************************/
void BCC_MD5_gen_encrypt(unsigned char *text, int text_len, unsigned char *key, int key_len, unsigned char *out_digest32)
{
BCC_MD5_CTX context;
unsigned char k_ipad[65]; /* inner padding - * key XORd with ipad */
unsigned char k_opad[65]; /* outer padding - * key XORd with opad */
unsigned char tk[17], out_digest[100];
int i;
// memset(out_digest, 0, sizeof(out_digest));
// memset(out_digest32, 0, sizeof(out_digest32));
/* if key is longer than 64 bytes reset it to key=MD5(key) */
if (key_len > 64) {
memset(tk, 0, sizeof(tk));
BCC_MD5_gen(key, tk);
memcpy(key, tk, 16);
key_len = 16;
}
/* start out by storing key in pads */
memset(k_ipad, '\0', 64);
memset(k_opad, '\0', 64);
memcpy(k_ipad, key, key_len);
memcpy(k_opad, key, key_len);
/* XOR key with ipad and opad values */
for (i = 0; i < 64; i++) {
k_ipad[i] ^= 0x36;
k_opad[i] ^= 0x5c;
}
/* perform inner MD5 */
BCC_MD5_Func_Init(&context);
BCC_MD5_Func_Update(&context, k_ipad, 64);
BCC_MD5_Func_Update(&context, text, text_len);
BCC_MD5_Func_Final(out_digest, &context);
/* perform outer MD5 */
BCC_MD5_Func_Init(&context);
BCC_MD5_Func_Update(&context, k_opad, 64);
BCC_MD5_Func_Update(&context, out_digest, 16);
BCC_MD5_Func_Final(out_digest, &context);
for (i = 0; i < 16; i++)
sprintf((char*)&out_digest32[2 * i], "%02X", out_digest[i]);
return;
}
/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* cJSON */
/* JSON parser in C. */
/* disable warnings about old C89 functions in MSVC */
#if !defined(_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
#define _CRT_SECURE_NO_DEPRECATE
#endif
#ifdef __GNUC__
#pragma GCC visibility push(default)
#endif
#if defined(_MSC_VER)
#pragma warning (push)
/* disable warning about single line comments in system headers */
#pragma warning (disable : 4001)
#endif
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <float.h>
#include <limits.h>
#include <ctype.h>
#ifdef ENABLE_LOCALES
#include <locale.h>
#endif
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#ifdef __GNUC__
#pragma GCC visibility pop
#endif
#include "cJSON.h"
/* define our own boolean type */
#define true ((cJSON_bool)1)
#define false ((cJSON_bool)0)
typedef struct {
const unsigned char *json;
size_t position;
} error;
static error global_error = { NULL, 0 };
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
{
return (const char*) (global_error.json + global_error.position);
}
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) {
if (!cJSON_IsString(item)) {
return NULL;
}
return item->valuestring;
}
/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 0)
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
#endif
CJSON_PUBLIC(const char*) cJSON_Version(void)
{
static char version[15];
sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
return version;
}
/* Case insensitive string comparison, doesn't consider two NULL pointers equal though */
static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2)
{
if ((string1 == NULL) || (string2 == NULL))
{
return 1;
}
if (string1 == string2)
{
return 0;
}
for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
{
if (*string1 == '\0')
{
return 0;
}
}
return tolower(*string1) - tolower(*string2);
}
typedef struct internal_hooks
{
void *(*allocate)(size_t size);
void (*deallocate)(void *pointer);
void *(*reallocate)(void *pointer, size_t size);
} internal_hooks;
#if defined(_MSC_VER)
/* work around MSVC error C2322: '...' address of dillimport '...' is not static */
static void *internal_malloc(size_t size)
{
return malloc(size);
}
static void internal_free(void *pointer)
{
free(pointer);
}
static void *internal_realloc(void *pointer, size_t size)
{
return realloc(pointer, size);
}
#else
#define internal_malloc malloc
#define internal_free free
#define internal_realloc realloc
#endif
static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc };
static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks)
{
size_t length = 0;
unsigned char *copy = NULL;
if (string == NULL)
{
return NULL;
}
length = strlen((const char*)string) + sizeof("");
copy = (unsigned char*)hooks->allocate(length);
if (copy == NULL)
{
return NULL;
}
memcpy(copy, string, length);
return copy;
}
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
{
if (hooks == NULL)
{
/* Reset hooks */
global_hooks.allocate = malloc;
global_hooks.deallocate = free;
global_hooks.reallocate = realloc;
return;
}
global_hooks.allocate = malloc;
if (hooks->malloc_fn != NULL)
{
global_hooks.allocate = hooks->malloc_fn;
}
global_hooks.deallocate = free;
if (hooks->free_fn != NULL)
{
global_hooks.deallocate = hooks->free_fn;
}
/* use realloc only if both free and malloc are used */
global_hooks.reallocate = NULL;
if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free))
{
global_hooks.reallocate = realloc;
}
}
/* Internal constructor. */
static cJSON *cJSON_New_Item(const internal_hooks * const hooks)
{
cJSON* node = (cJSON*)hooks->allocate(sizeof(cJSON));
if (node)
{
memset(node, '\0', sizeof(cJSON));
}
return node;
}
/* Delete a cJSON structure. */
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item)
{
cJSON *next = NULL;
while (item != NULL)
{
next = item->next;
if (!(item->type & cJSON_IsReference) && (item->child != NULL))
{
cJSON_Delete(item->child);
}
if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL))
{
global_hooks.deallocate(item->valuestring);
}
if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
{
global_hooks.deallocate(item->string);
}
global_hooks.deallocate(item);
item = next;
}
}
/* get the decimal point character of the current locale */
static unsigned char get_decimal_point(void)
{
#ifdef ENABLE_LOCALES
struct lconv *lconv = localeconv();
return (unsigned char) lconv->decimal_point[0];
#else
return '.';
#endif
}
typedef struct
{
const unsigned char *content;
size_t length;
size_t offset;
size_t depth; /* How deeply nested (in arrays/objects) is the input at the current offset. */
internal_hooks hooks;
} parse_buffer;
/* check if the given size is left to read in a given parse buffer (starting with 1) */
#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
/* check if the buffer can be accessed at the given index (starting with 0) */
#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
/* get a pointer to the buffer at the position */
#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
/* Parse the input text to generate a number, and populate the result into item. */
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
double number = 0;
unsigned char *after_end = NULL;
unsigned char number_c_string[64];
unsigned char decimal_point = get_decimal_point();
size_t i = 0;
if ((input_buffer == NULL) || (input_buffer->content == NULL))
{
return false;
}
/* copy the number into a temporary buffer and replace '.' with the decimal point
* of the current locale (for strtod)
* This also takes care of '\0' not necessarily being available for marking the end of the input */
for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++)
{
switch (buffer_at_offset(input_buffer)[i])
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '+':
case '-':
case 'e':
case 'E':
number_c_string[i] = buffer_at_offset(input_buffer)[i];
break;
case '.':
number_c_string[i] = decimal_point;
break;
default:
goto loop_end;
}
}
loop_end:
number_c_string[i] = '\0';
number = strtod((const char*)number_c_string, (char**)&after_end);
if (number_c_string == after_end)
{
return false; /* parse_error */
}
item->valuedouble = number;
/* use saturation in case of overflow */
if (number >= INT_MAX)
{
item->valueint = INT_MAX;
}
else if (number <= INT_MIN)
{
item->valueint = INT_MIN;
}
else
{
item->valueint = (int)number;
}
item->type = cJSON_Number;
input_buffer->offset += (size_t)(after_end - number_c_string);
return true;
}
/* don't ask me, but the original cJSON_SetNumberValue returns an integer or double */
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number)
{
if (number >= INT_MAX)
{
object->valueint = INT_MAX;
}
else if (number <= INT_MIN)
{
object->valueint = INT_MIN;
}
else
{
object->valueint = (int)number;
}
return object->valuedouble = number;
}
typedef struct
{
unsigned char *buffer;
size_t length;
size_t offset;
size_t depth; /* current nesting depth (for formatted printing) */
cJSON_bool noalloc;
cJSON_bool format; /* is this print a formatted print */
internal_hooks hooks;
} printbuffer;
/* realloc printbuffer if necessary to have at least "needed" bytes more */
static unsigned char* ensure(printbuffer * const p, size_t needed)
{
unsigned char *newbuffer = NULL;
size_t newsize = 0;
if ((p == NULL) || (p->buffer == NULL))
{
return NULL;
}
if ((p->length > 0) && (p->offset >= p->length))
{
/* make sure that offset is valid */
return NULL;
}
if (needed > INT_MAX)
{
/* sizes bigger than INT_MAX are currently not supported */
return NULL;
}
needed += p->offset + 1;
if (needed <= p->length)
{
return p->buffer + p->offset;
}
if (p->noalloc) {
return NULL;
}
/* calculate new buffer size */
if (needed > (INT_MAX / 2))
{
/* overflow of int, use INT_MAX if possible */
if (needed <= INT_MAX)
{
newsize = INT_MAX;
}
else
{
return NULL;
}
}
else
{
newsize = needed * 2;
}
if (p->hooks.reallocate != NULL)
{
/* reallocate with realloc if available */
newbuffer = (unsigned char*)p->hooks.reallocate(p->buffer, newsize);
if (newbuffer == NULL)
{
p->hooks.deallocate(p->buffer);
p->length = 0;
p->buffer = NULL;
return NULL;
}
}
else
{
/* otherwise reallocate manually */
newbuffer = (unsigned char*)p->hooks.allocate(newsize);
if (!newbuffer)
{
p->hooks.deallocate(p->buffer);
p->length = 0;
p->buffer = NULL;
return NULL;
}
if (newbuffer)
{
memcpy(newbuffer, p->buffer, p->offset + 1);
}
p->hooks.deallocate(p->buffer);
}
p->length = newsize;
p->buffer = newbuffer;
return newbuffer + p->offset;
}
/* calculate the new length of the string in a printbuffer and update the offset */
static void update_offset(printbuffer * const buffer)
{
const unsigned char *buffer_pointer = NULL;
if ((buffer == NULL) || (buffer->buffer == NULL))
{
return;
}
buffer_pointer = buffer->buffer + buffer->offset;
buffer->offset += strlen((const char*)buffer_pointer);
}
/* Render the number nicely from the given item into a string. */
static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer)
{
unsigned char *output_pointer = NULL;
double d = item->valuedouble;
int length = 0;
size_t i = 0;
unsigned char number_buffer[26]; /* temporary buffer to print the number into */
unsigned char decimal_point = get_decimal_point();
double test;
if (output_buffer == NULL)
{
return false;
}
/* This checks for NaN and Infinity */
if ((d * 0) != 0)
{
length = sprintf((char*)number_buffer, "null");
}
else
{
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */
length = sprintf((char*)number_buffer, "%1.15g", d);
/* Check whether the original double can be recovered */
if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || ((double)test != d))
{
/* If not, print with 17 decimal places of precision */
length = sprintf((char*)number_buffer, "%1.17g", d);
}
}
/* sprintf failed or buffer overrun occured */
if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1)))
{
return false;
}
/* reserve appropriate space in the output */
output_pointer = ensure(output_buffer, (size_t)length);
if (output_pointer == NULL)
{
return false;
}
/* copy the printed number to the output and replace locale
* dependent decimal point with '.' */
for (i = 0; i < ((size_t)length); i++)
{
if (number_buffer[i] == decimal_point)
{
output_pointer[i] = '.';
continue;
}
output_pointer[i] = number_buffer[i];
}
output_pointer[i] = '\0';
output_buffer->offset += (size_t)length;
return true;
}
/* parse 4 digit hexadecimal number */
static unsigned parse_hex4(const unsigned char * const input)
{
unsigned int h = 0;
size_t i = 0;
for (i = 0; i < 4; i++)
{
/* parse digit */
if ((input[i] >= '0') && (input[i] <= '9'))
{
h += (unsigned int) input[i] - '0';
}
else if ((input[i] >= 'A') && (input[i] <= 'F'))
{
h += (unsigned int) 10 + input[i] - 'A';
}
else if ((input[i] >= 'a') && (input[i] <= 'f'))
{
h += (unsigned int) 10 + input[i] - 'a';
}
else /* invalid */
{
return 0;
}
if (i < 3)
{
/* shift left to make place for the next nibble */
h = h << 4;
}
}
return h;
}
/* converts a UTF-16 literal to UTF-8
* A literal can be one or two sequences of the form \uXXXX */
static unsigned char utf16_literal_to_utf8(const unsigned char * const input_pointer, const unsigned char * const input_end, unsigned char **output_pointer)
{
long unsigned int codepoint = 0;
unsigned int first_code = 0;
const unsigned char *first_sequence = input_pointer;
unsigned char utf8_length = 0;
unsigned char utf8_position = 0;
unsigned char sequence_length = 0;
unsigned char first_byte_mark = 0;
if ((input_end - first_sequence) < 6)
{
/* input ends unexpectedly */
goto fail;
}
/* get the first utf16 sequence */
first_code = parse_hex4(first_sequence + 2);
/* check that the code is valid */
if (((first_code >= 0xDC00) && (first_code <= 0xDFFF)))
{
goto fail;
}
/* UTF16 surrogate pair */
if ((first_code >= 0xD800) && (first_code <= 0xDBFF))
{
const unsigned char *second_sequence = first_sequence + 6;
unsigned int second_code = 0;
sequence_length = 12; /* \uXXXX\uXXXX */
if ((input_end - second_sequence) < 6)
{
/* input ends unexpectedly */
goto fail;
}
if ((second_sequence[0] != '\\') || (second_sequence[1] != 'u'))
{
/* missing second half of the surrogate pair */
goto fail;
}
/* get the second utf16 sequence */
second_code = parse_hex4(second_sequence + 2);
/* check that the code is valid */
if ((second_code < 0xDC00) || (second_code > 0xDFFF))
{
/* invalid second half of the surrogate pair */
goto fail;
}
/* calculate the unicode codepoint from the surrogate pair */
codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF));
}
else
{
sequence_length = 6; /* \uXXXX */
codepoint = first_code;
}
/* encode as UTF-8
* takes at maximum 4 bytes to encode:
* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
if (codepoint < 0x80)
{
/* normal ascii, encoding 0xxxxxxx */
utf8_length = 1;
}
else if (codepoint < 0x800)
{
/* two bytes, encoding 110xxxxx 10xxxxxx */
utf8_length = 2;
first_byte_mark = 0xC0; /* 11000000 */
}
else if (codepoint < 0x10000)
{
/* three bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx */
utf8_length = 3;
first_byte_mark = 0xE0; /* 11100000 */
}
else if (codepoint <= 0x10FFFF)
{
/* four bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx 10xxxxxx */
utf8_length = 4;
first_byte_mark = 0xF0; /* 11110000 */
}
else
{
/* invalid unicode codepoint */
goto fail;
}
/* encode as utf8 */
for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--)
{
/* 10xxxxxx */
(*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF);
codepoint >>= 6;
}
/* encode first byte */
if (utf8_length > 1)
{
(*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF);
}
else
{
(*output_pointer)[0] = (unsigned char)(codepoint & 0x7F);
}
*output_pointer += utf8_length;
return sequence_length;
fail:
return 0;
}
/* Parse the input text into an unescaped cinput, and populate item. */
static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer)
{
const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1;
const unsigned char *input_end = buffer_at_offset(input_buffer) + 1;
unsigned char *output_pointer = NULL;
unsigned char *output = NULL;
/* not a string */
if (buffer_at_offset(input_buffer)[0] != '\"')
{
goto fail;
}
{
/* calculate approximate size of the output (overestimate) */
size_t allocation_length = 0;
size_t skipped_bytes = 0;
while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"'))
{
/* is escape sequence */
if (input_end[0] == '\\')
{
if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length)
{
/* prevent buffer overflow when last input character is a backslash */
goto fail;
}
skipped_bytes++;
input_end++;
}
input_end++;
}
if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"'))
{
goto fail; /* string ended unexpectedly */
}
/* This is at most how much we need for the output */
allocation_length = (size_t) (input_end - buffer_at_offset(input_buffer)) - skipped_bytes;
output = (unsigned char*)input_buffer->hooks.allocate(allocation_length + sizeof(""));
if (output == NULL)
{
goto fail; /* allocation failure */
}
}
output_pointer = output;
/* loop through the string literal */
while (input_pointer < input_end)
{
if (*input_pointer != '\\')
{
*output_pointer++ = *input_pointer++;
}
/* escape sequence */
else
{
unsigned char sequence_length = 2;
if ((input_end - input_pointer) < 1)
{
goto fail;
}
switch (input_pointer[1])
{
case 'b':
*output_pointer++ = '\b';
break;
case 'f':
*output_pointer++ = '\f';
break;
case 'n':
*output_pointer++ = '\n';
break;
case 'r':
*output_pointer++ = '\r';
break;
case 't':
*output_pointer++ = '\t';
break;
case '\"':
case '\\':
case '/':
*output_pointer++ = input_pointer[1];
break;
/* UTF-16 literal */
case 'u':
sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer);
if (sequence_length == 0)
{
/* failed to convert UTF16-literal to UTF-8 */
goto fail;
}
break;
default:
goto fail;
}
input_pointer += sequence_length;
}
}
/* zero terminate the output */
*output_pointer = '\0';
item->type = cJSON_String;
item->valuestring = (char*)output;
input_buffer->offset = (size_t) (input_end - input_buffer->content);
input_buffer->offset++;
return true;
fail:
if (output != NULL)
{
input_buffer->hooks.deallocate(output);
}
if (input_pointer != NULL)
{
input_buffer->offset = (size_t)(input_pointer - input_buffer->content);
}
return false;
}
/* Render the cstring provided to an escaped version that can be printed. */
static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffer * const output_buffer)
{
const unsigned char *input_pointer = NULL;
unsigned char *output = NULL;
unsigned char *output_pointer = NULL;
size_t output_length = 0;
/* numbers of additional characters needed for escaping */
size_t escape_characters = 0;
if (output_buffer == NULL)
{
return false;
}
/* empty string */
if (input == NULL)
{
output = ensure(output_buffer, sizeof("\"\""));
if (output == NULL)
{
return false;
}
strcpy((char*)output, "\"\"");
return true;
}
/* set "flag" to 1 if something needs to be escaped */
for (input_pointer = input; *input_pointer; input_pointer++)
{
switch (*input_pointer)
{
case '\"':
case '\\':
case '\b':
case '\f':
case '\n':
case '\r':
case '\t':
/* one character escape sequence */
escape_characters++;
break;
default:
if (*input_pointer < 32)
{
/* UTF-16 escape sequence uXXXX */
escape_characters += 5;
}
break;
}
}
output_length = (size_t)(input_pointer - input) + escape_characters;
output = ensure(output_buffer, output_length + sizeof("\"\""));
if (output == NULL)
{
return false;
}
/* no characters have to be escaped */
if (escape_characters == 0)
{
output[0] = '\"';
memcpy(output + 1, input, output_length);
output[output_length + 1] = '\"';
output[output_length + 2] = '\0';
return true;
}
output[0] = '\"';
output_pointer = output + 1;
/* copy the string */
for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++)
{
if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\'))
{
/* normal character, copy */
*output_pointer = *input_pointer;
}
else
{
/* character needs to be escaped */
*output_pointer++ = '\\';
switch (*input_pointer)
{
case '\\':
*output_pointer = '\\';
break;
case '\"':
*output_pointer = '\"';
break;
case '\b':
*output_pointer = 'b';
break;
case '\f':
*output_pointer = 'f';
break;
case '\n':
*output_pointer = 'n';
break;
case '\r':
*output_pointer = 'r';
break;
case '\t':
*output_pointer = 't';
break;
default:
/* escape and print as unicode codepoint */
sprintf((char*)output_pointer, "u%04x", *input_pointer);
output_pointer += 4;
break;
}
}
}
output[output_length + 1] = '\"';
output[output_length + 2] = '\0';
return true;
}
/* Invoke print_string_ptr (which is useful) on an item. */
static cJSON_bool print_string(const cJSON * const item, printbuffer * const p)
{
return print_string_ptr((unsigned char*)item->valuestring, p);
}
/* Predeclare these prototypes. */
static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer);
static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer);
static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer);
static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer);
static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer);
static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer);
/* Utility to jump whitespace and cr/lf */
static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer)
{
if ((buffer == NULL) || (buffer->content == NULL))
{
return NULL;
}
while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32))
{
buffer->offset++;
}
if (buffer->offset == buffer->length)
{
buffer->offset--;
}
return buffer;
}
/* skip the UTF-8 BOM (byte order mark) if it is at the beginning of a buffer */
static parse_buffer *skip_utf8_bom(parse_buffer * const buffer)
{
if ((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0))
{
return NULL;
}
if (can_access_at_index(buffer, 4) && (strncmp((const char*)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0))
{
buffer->offset += 3;
}
return buffer;
}
/* Parse an object - create a new root, and populate. */
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated)
{
parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
cJSON *item = NULL;
/* reset error position */
global_error.json = NULL;
global_error.position = 0;
if (value == NULL)
{
goto fail;
}
buffer.content = (const unsigned char*)value;
buffer.length = strlen((const char*)value) + sizeof("");
buffer.offset = 0;
buffer.hooks = global_hooks;
item = cJSON_New_Item(&global_hooks);
if (item == NULL) /* memory fail */
{
goto fail;
}
if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer))))
{
/* parse failure. ep is set. */
goto fail;
}
/* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
if (require_null_terminated)
{
buffer_skip_whitespace(&buffer);
if ((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0')
{
goto fail;
}
}
if (return_parse_end)
{
*return_parse_end = (const char*)buffer_at_offset(&buffer);
}
return item;
fail:
if (item != NULL)
{
cJSON_Delete(item);
}
if (value != NULL)
{
error local_error;
local_error.json = (const unsigned char*)value;
local_error.position = 0;
if (buffer.offset < buffer.length)
{
local_error.position = buffer.offset;
}
else if (buffer.length > 0)
{
local_error.position = buffer.length - 1;
}
if (return_parse_end != NULL)
{
*return_parse_end = (const char*)local_error.json + local_error.position;
}
global_error = local_error;
}
return NULL;
}
/* Default options for cJSON_Parse */
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)
{
return cJSON_ParseWithOpts(value, 0, 0);
}
#define cjson_min(a, b) ((a < b) ? a : b)
static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
{
printbuffer buffer[1];
unsigned char *printed = NULL;
memset(buffer, 0, sizeof(buffer));
/* create buffer */
buffer->buffer = (unsigned char*) hooks->allocate(256);
buffer->format = format;
buffer->hooks = *hooks;
if (buffer->buffer == NULL)
{
goto fail;
}
/* print the value */
if (!print_value(item, buffer))
{
goto fail;
}
update_offset(buffer);
/* check if reallocate is available */
if (hooks->reallocate != NULL)
{
printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->length);
buffer->buffer = NULL;
if (printed == NULL) {
goto fail;
}
}
else /* otherwise copy the JSON over to a new buffer */
{
printed = (unsigned char*) hooks->allocate(buffer->offset + 1);
if (printed == NULL)
{
goto fail;
}
memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1));
printed[buffer->offset] = '\0'; /* just to be sure */
/* free the buffer */
hooks->deallocate(buffer->buffer);
}
return printed;
fail:
if (buffer->buffer != NULL)
{
hooks->deallocate(buffer->buffer);
}
if (printed != NULL)
{
hooks->deallocate(printed);
}
return NULL;
}
/* Render a cJSON item/entity/structure to text. */
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item)
{
return (char*)print(item, true, &global_hooks);
}
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item)
{
return (char*)print(item, false, &global_hooks);
}
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)
{
printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
if (prebuffer < 0)
{
return NULL;
}
p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer);
if (!p.buffer)
{
return NULL;
}
p.length = (size_t)prebuffer;
p.offset = 0;
p.noalloc = false;
p.format = fmt;
p.hooks = global_hooks;
if (!print_value(item, &p))
{
global_hooks.deallocate(p.buffer);
return NULL;
}
return (char*)p.buffer;
}
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt)
{
printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
if ((len < 0) || (buf == NULL))
{
return false;
}
p.buffer = (unsigned char*)buf;
p.length = (size_t)len;
p.offset = 0;
p.noalloc = true;
p.format = fmt;
p.hooks = global_hooks;
return print_value(item, &p);
}
/* Parser core - when encountering text, process appropriately. */
static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer)
{
if ((input_buffer == NULL) || (input_buffer->content == NULL))
{
return false; /* no input */
}
/* parse the different types of values */
/* null */
if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "null", 4) == 0))
{
item->type = cJSON_NULL;
input_buffer->offset += 4;
return true;
}
/* false */
if (can_read(input_buffer, 5) && (strncmp((const char*)buffer_at_offset(input_buffer), "false", 5) == 0))
{
item->type = cJSON_False;
input_buffer->offset += 5;
return true;
}
/* true */
if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "true", 4) == 0))
{
item->type = cJSON_True;
item->valueint = 1;
input_buffer->offset += 4;
return true;
}
/* string */
if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"'))
{
return parse_string(item, input_buffer);
}
/* number */
if (can_access_at_index(input_buffer, 0) && ((buffer_at_offset(input_buffer)[0] == '-') || ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9'))))
{
return parse_number(item, input_buffer);
}
/* array */
if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '['))
{
return parse_array(item, input_buffer);
}
/* object */
if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{'))
{
return parse_object(item, input_buffer);
}
return false;
}
/* Render a value to text. */
static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer)
{
unsigned char *output = NULL;
if ((item == NULL) || (output_buffer == NULL))
{
return false;
}
switch ((item->type) & 0xFF)
{
case cJSON_NULL:
output = ensure(output_buffer, 5);
if (output == NULL)
{
return false;
}
strcpy((char*)output, "null");
return true;
case cJSON_False:
output = ensure(output_buffer, 6);
if (output == NULL)
{
return false;
}
strcpy((char*)output, "false");
return true;
case cJSON_True:
output = ensure(output_buffer, 5);
if (output == NULL)
{
return false;
}
strcpy((char*)output, "true");
return true;
case cJSON_Number:
return print_number(item, output_buffer);
case cJSON_Raw:
{
size_t raw_length = 0;
if (item->valuestring == NULL)
{
if (!output_buffer->noalloc)
{
output_buffer->hooks.deallocate(output_buffer->buffer);
}
return false;
}
raw_length = strlen(item->valuestring) + sizeof("");
output = ensure(output_buffer, raw_length);
if (output == NULL)
{
return false;
}
memcpy(output, item->valuestring, raw_length);
return true;
}
case cJSON_String:
return print_string(item, output_buffer);
case cJSON_Array:
return print_array(item, output_buffer);
case cJSON_Object:
return print_object(item, output_buffer);
default:
return false;
}
}
/* Build an array from input text. */
static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer)
{
cJSON *head = NULL; /* head of the linked list */
cJSON *current_item = NULL;
if (input_buffer->depth >= CJSON_NESTING_LIMIT)
{
return false; /* to deeply nested */
}
input_buffer->depth++;
if (buffer_at_offset(input_buffer)[0] != '[')
{
/* not an array */
goto fail;
}
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']'))
{
/* empty array */
goto success;
}
/* check if we skipped to the end of the buffer */
if (cannot_access_at_index(input_buffer, 0))
{
input_buffer->offset--;
goto fail;
}
/* step back to character in front of the first element */
input_buffer->offset--;
/* loop through the comma separated array elements */
do
{
/* allocate next item */
cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks));
if (new_item == NULL)
{
goto fail; /* allocation failure */
}
/* attach next item to list */
if (head == NULL)
{
/* start the linked list */
current_item = head = new_item;
}
else
{
/* add to the end and advance */
current_item->next = new_item;
new_item->prev = current_item;
current_item = new_item;
}
/* parse next value */
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
if (!parse_value(current_item, input_buffer))
{
goto fail; /* failed to parse value */
}
buffer_skip_whitespace(input_buffer);
}
while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']')
{
goto fail; /* expected end of array */
}
success:
input_buffer->depth--;
item->type = cJSON_Array;
item->child = head;
input_buffer->offset++;
return true;
fail:
if (head != NULL)
{
cJSON_Delete(head);
}
return false;
}
/* Render an array to text */
static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer)
{
unsigned char *output_pointer = NULL;
size_t length = 0;
cJSON *current_element = item->child;
if (output_buffer == NULL)
{
return false;
}
/* Compose the output array. */
/* opening square bracket */
output_pointer = ensure(output_buffer, 1);
if (output_pointer == NULL)
{
return false;
}
*output_pointer = '[';
output_buffer->offset++;
output_buffer->depth++;
while (current_element != NULL)
{
if (!print_value(current_element, output_buffer))
{
return false;
}
update_offset(output_buffer);
if (current_element->next)
{
length = (size_t) (output_buffer->format ? 2 : 1);
output_pointer = ensure(output_buffer, length + 1);
if (output_pointer == NULL)
{
return false;
}
*output_pointer++ = ',';
if(output_buffer->format)
{
*output_pointer++ = ' ';
}
*output_pointer = '\0';
output_buffer->offset += length;
}
current_element = current_element->next;
}
output_pointer = ensure(output_buffer, 2);
if (output_pointer == NULL)
{
return false;
}
*output_pointer++ = ']';
*output_pointer = '\0';
output_buffer->depth--;
return true;
}
/* Build an object from the text. */
static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer)
{
cJSON *head = NULL; /* linked list head */
cJSON *current_item = NULL;
if (input_buffer->depth >= CJSON_NESTING_LIMIT)
{
return false; /* to deeply nested */
}
input_buffer->depth++;
if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{'))
{
goto fail; /* not an object */
}
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}'))
{
goto success; /* empty object */
}
/* check if we skipped to the end of the buffer */
if (cannot_access_at_index(input_buffer, 0))
{
input_buffer->offset--;
goto fail;
}
/* step back to character in front of the first element */
input_buffer->offset--;
/* loop through the comma separated array elements */
do
{
/* allocate next item */
cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks));
if (new_item == NULL)
{
goto fail; /* allocation failure */
}
/* attach next item to list */
if (head == NULL)
{
/* start the linked list */
current_item = head = new_item;
}
else
{
/* add to the end and advance */
current_item->next = new_item;
new_item->prev = current_item;
current_item = new_item;
}
/* parse the name of the child */
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
if (!parse_string(current_item, input_buffer))
{
goto fail; /* faile to parse name */
}
buffer_skip_whitespace(input_buffer);
/* swap valuestring and string, because we parsed the name */
current_item->string = current_item->valuestring;
current_item->valuestring = NULL;
if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':'))
{
goto fail; /* invalid object */
}
/* parse the value */
input_buffer->offset++;
buffer_skip_whitespace(input_buffer);
if (!parse_value(current_item, input_buffer))
{
goto fail; /* failed to parse value */
}
buffer_skip_whitespace(input_buffer);
}
while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}'))
{
goto fail; /* expected end of object */
}
success:
input_buffer->depth--;
item->type = cJSON_Object;
item->child = head;
input_buffer->offset++;
return true;
fail:
if (head != NULL)
{
cJSON_Delete(head);
}
return false;
}
/* Render an object to text. */
static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer)
{
unsigned char *output_pointer = NULL;
size_t length = 0;
cJSON *current_item = item->child;
if (output_buffer == NULL)
{
return false;
}
/* Compose the output: */
length = (size_t) (output_buffer->format ? 2 : 1); /* fmt: {\n */
output_pointer = ensure(output_buffer, length + 1);
if (output_pointer == NULL)
{
return false;
}
*output_pointer++ = '{';
output_buffer->depth++;
if (output_buffer->format)
{
*output_pointer++ = '\n';
}
output_buffer->offset += length;
while (current_item)
{
if (output_buffer->format)
{
size_t i;
output_pointer = ensure(output_buffer, output_buffer->depth);
if (output_pointer == NULL)
{
return false;
}
for (i = 0; i < output_buffer->depth; i++)
{
*output_pointer++ = '\t';
}
output_buffer->offset += output_buffer->depth;
}
/* print key */
if (!print_string_ptr((unsigned char*)current_item->string, output_buffer))
{
return false;
}
update_offset(output_buffer);
length = (size_t) (output_buffer->format ? 2 : 1);
output_pointer = ensure(output_buffer, length);
if (output_pointer == NULL)
{
return false;
}
*output_pointer++ = ':';
if (output_buffer->format)
{
*output_pointer++ = '\t';
}
output_buffer->offset += length;
/* print value */
if (!print_value(current_item, output_buffer))
{
return false;
}
update_offset(output_buffer);
/* print comma if not last */
length = (size_t) ((output_buffer->format ? 1 : 0) + (current_item->next ? 1 : 0));
output_pointer = ensure(output_buffer, length + 1);
if (output_pointer == NULL)
{
return false;
}
if (current_item->next)
{
*output_pointer++ = ',';
}
if (output_buffer->format)
{
*output_pointer++ = '\n';
}
*output_pointer = '\0';
output_buffer->offset += length;
current_item = current_item->next;
}
output_pointer = ensure(output_buffer, output_buffer->format ? (output_buffer->depth + 1) : 2);
if (output_pointer == NULL)
{
return false;
}
if (output_buffer->format)
{
size_t i;
for (i = 0; i < (output_buffer->depth - 1); i++)
{
*output_pointer++ = '\t';
}
}
*output_pointer++ = '}';
*output_pointer = '\0';
output_buffer->depth--;
return true;
}
/* Get Array size/item / object item. */
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
{
cJSON *child = NULL;
size_t size = 0;
if (array == NULL)
{
return 0;
}
child = array->child;
while(child != NULL)
{
size++;
child = child->next;
}
/* FIXME: Can overflow here. Cannot be fixed without breaking the API */
return (int)size;
}
static cJSON* get_array_item(const cJSON *array, size_t index)
{
cJSON *current_child = NULL;
if (array == NULL)
{
return NULL;
}
current_child = array->child;
while ((current_child != NULL) && (index > 0))
{
index--;
current_child = current_child->next;
}
return current_child;
}
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index)
{
if (index < 0)
{
return NULL;
}
return get_array_item(array, (size_t)index);
}
static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive)
{
cJSON *current_element = NULL;
if ((object == NULL) || (name == NULL))
{
return NULL;
}
current_element = object->child;
if (case_sensitive)
{
while ((current_element != NULL) && (strcmp(name, current_element->string) != 0))
{
current_element = current_element->next;
}
}
else
{
while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0))
{
current_element = current_element->next;
}
}
return current_element;
}
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string)
{
return get_object_item(object, string, false);
}
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string)
{
return get_object_item(object, string, true);
}
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string)
{
return cJSON_GetObjectItem(object, string) ? 1 : 0;
}
/* Utility for array list handling. */
static void suffix_object(cJSON *prev, cJSON *item)
{
prev->next = item;
item->prev = prev;
}
/* Utility for handling references. */
static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks)
{
cJSON *reference = NULL;
if (item == NULL)
{
return NULL;
}
reference = cJSON_New_Item(hooks);
if (reference == NULL)
{
return NULL;
}
memcpy(reference, item, sizeof(cJSON));
reference->string = NULL;
reference->type |= cJSON_IsReference;
reference->next = reference->prev = NULL;
return reference;
}
static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
{
cJSON *child = NULL;
if ((item == NULL) || (array == NULL))
{
return false;
}
child = array->child;
if (child == NULL)
{
/* list is empty, start new one */
array->child = item;
}
else
{
/* append to the end */
while (child->next)
{
child = child->next;
}
suffix_object(child, item);
}
return true;
}
/* Add item to array/object. */
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item)
{
add_item_to_array(array, item);
}
#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
#pragma GCC diagnostic push
#endif
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wcast-qual"
#endif
/* helper function to cast away const */
static void* cast_away_const(const void* string)
{
return (void*)string;
}
#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
#pragma GCC diagnostic pop
#endif
static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_bool constant_key)
{
if ((object == NULL) || (string == NULL) || (item == NULL))
{
return false;
}
if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
{
hooks->deallocate(item->string);
}
if (constant_key)
{
item->string = (char*)cast_away_const(string);
item->type |= cJSON_StringIsConst;
}
else
{
char *key = (char*)cJSON_strdup((const unsigned char*)string, hooks);
if (key == NULL)
{
return false;
}
item->string = key;
item->type &= ~cJSON_StringIsConst;
}
return add_item_to_array(object, item);
}
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
{
add_item_to_object(object, string, item, &global_hooks, false);
}
/* Add an item to an object with constant string as key */
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
{
add_item_to_object(object, string, item, &global_hooks, true);
}
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
{
if (array == NULL)
{
return;
}
add_item_to_array(array, create_reference(item, &global_hooks));
}
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
{
if ((object == NULL) || (string == NULL))
{
return;
}
add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false);
}
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name)
{
cJSON *null = cJSON_CreateNull();
if (add_item_to_object(object, name, null, &global_hooks, false))
{
return null;
}
cJSON_Delete(null);
return NULL;
}
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name)
{
cJSON *true_item = cJSON_CreateTrue();
if (add_item_to_object(object, name, true_item, &global_hooks, false))
{
return true_item;
}
cJSON_Delete(true_item);
return NULL;
}
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name)
{
cJSON *false_item = cJSON_CreateFalse();
if (add_item_to_object(object, name, false_item, &global_hooks, false))
{
return false_item;
}
cJSON_Delete(false_item);
return NULL;
}
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean)
{
cJSON *bool_item = cJSON_CreateBool(boolean);
if (add_item_to_object(object, name, bool_item, &global_hooks, false))
{
return bool_item;
}
cJSON_Delete(bool_item);
return NULL;
}
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number)
{
cJSON *number_item = cJSON_CreateNumber(number);
if (add_item_to_object(object, name, number_item, &global_hooks, false))
{
return number_item;
}
cJSON_Delete(number_item);
return NULL;
}
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string)
{
cJSON *string_item = cJSON_CreateString(string);
if (add_item_to_object(object, name, string_item, &global_hooks, false))
{
return string_item;
}
cJSON_Delete(string_item);
return NULL;
}
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw)
{
cJSON *raw_item = cJSON_CreateRaw(raw);
if (add_item_to_object(object, name, raw_item, &global_hooks, false))
{
return raw_item;
}
cJSON_Delete(raw_item);
return NULL;
}
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name)
{
cJSON *object_item = cJSON_CreateObject();
if (add_item_to_object(object, name, object_item, &global_hooks, false))
{
return object_item;
}
cJSON_Delete(object_item);
return NULL;
}
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name)
{
cJSON *array = cJSON_CreateArray();
if (add_item_to_object(object, name, array, &global_hooks, false))
{
return array;
}
cJSON_Delete(array);
return NULL;
}
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item)
{
if ((parent == NULL) || (item == NULL))
{
return NULL;
}
if (item->prev != NULL)
{
/* not the first element */
item->prev->next = item->next;
}
if (item->next != NULL)
{
/* not the last element */
item->next->prev = item->prev;
}
if (item == parent->child)
{
/* first element */
parent->child = item->next;
}
/* make sure the detached item doesn't point anywhere anymore */
item->prev = NULL;
item->next = NULL;
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which)
{
if (which < 0)
{
return NULL;
}
return cJSON_DetachItemViaPointer(array, get_array_item(array, (size_t)which));
}
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which)
{
cJSON_Delete(cJSON_DetachItemFromArray(array, which));
}
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string)
{
cJSON *to_detach = cJSON_GetObjectItem(object, string);
return cJSON_DetachItemViaPointer(object, to_detach);
}
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string)
{
cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string);
return cJSON_DetachItemViaPointer(object, to_detach);
}
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string)
{
cJSON_Delete(cJSON_DetachItemFromObject(object, string));
}
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string)
{
cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string));
}
/* Replace array/object items with new ones. */
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
{
cJSON *after_inserted = NULL;
if (which < 0)
{
return;
}
after_inserted = get_array_item(array, (size_t)which);
if (after_inserted == NULL)
{
add_item_to_array(array, newitem);
return;
}
newitem->next = after_inserted;
newitem->prev = after_inserted->prev;
after_inserted->prev = newitem;
if (after_inserted == array->child)
{
array->child = newitem;
}
else
{
newitem->prev->next = newitem;
}
}
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
{
if ((parent == NULL) || (replacement == NULL) || (item == NULL))
{
return false;
}
if (replacement == item)
{
return true;
}
replacement->next = item->next;
replacement->prev = item->prev;
if (replacement->next != NULL)
{
replacement->next->prev = replacement;
}
if (replacement->prev != NULL)
{
replacement->prev->next = replacement;
}
if (parent->child == item)
{
parent->child = replacement;
}
item->next = NULL;
item->prev = NULL;
cJSON_Delete(item);
return true;
}
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
{
if (which < 0)
{
return;
}
cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem);
}
static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
{
if ((replacement == NULL) || (string == NULL))
{
return false;
}
/* replace the name in the replacement */
if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL))
{
cJSON_free(replacement->string);
}
replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
replacement->type &= ~cJSON_StringIsConst;
cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
return true;
}
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
{
replace_item_in_object(object, string, newitem, false);
}
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem)
{
replace_item_in_object(object, string, newitem, true);
}
/* Create basic types: */
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
{
item->type = cJSON_NULL;
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
{
item->type = cJSON_True;
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
{
item->type = cJSON_False;
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool b)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
{
item->type = b ? cJSON_True : cJSON_False;
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
{
item->type = cJSON_Number;
item->valuedouble = num;
/* use saturation in case of overflow */
if (num >= INT_MAX)
{
item->valueint = INT_MAX;
}
else if (num <= INT_MIN)
{
item->valueint = INT_MIN;
}
else
{
item->valueint = (int)num;
}
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
{
item->type = cJSON_String;
item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
if(!item->valuestring)
{
cJSON_Delete(item);
return NULL;
}
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if (item != NULL)
{
item->type = cJSON_String | cJSON_IsReference;
item->valuestring = (char*)cast_away_const(string);
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if (item != NULL) {
item->type = cJSON_Object | cJSON_IsReference;
item->child = (cJSON*)cast_away_const(child);
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) {
cJSON *item = cJSON_New_Item(&global_hooks);
if (item != NULL) {
item->type = cJSON_Array | cJSON_IsReference;
item->child = (cJSON*)cast_away_const(child);
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
{
item->type = cJSON_Raw;
item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks);
if(!item->valuestring)
{
cJSON_Delete(item);
return NULL;
}
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
{
item->type=cJSON_Array;
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if (item)
{
item->type = cJSON_Object;
}
return item;
}
/* Create Arrays: */
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
{
size_t i = 0;
cJSON *n = NULL;
cJSON *p = NULL;
cJSON *a = NULL;
if ((count < 0) || (numbers == NULL))
{
return NULL;
}
a = cJSON_CreateArray();
for(i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber(numbers[i]);
if (!n)
{
cJSON_Delete(a);
return NULL;
}
if(!i)
{
a->child = n;
}
else
{
suffix_object(p, n);
}
p = n;
}
return a;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
{
size_t i = 0;
cJSON *n = NULL;
cJSON *p = NULL;
cJSON *a = NULL;
if ((count < 0) || (numbers == NULL))
{
return NULL;
}
a = cJSON_CreateArray();
for(i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber((double)numbers[i]);
if(!n)
{
cJSON_Delete(a);
return NULL;
}
if(!i)
{
a->child = n;
}
else
{
suffix_object(p, n);
}
p = n;
}
return a;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
{
size_t i = 0;
cJSON *n = NULL;
cJSON *p = NULL;
cJSON *a = NULL;
if ((count < 0) || (numbers == NULL))
{
return NULL;
}
a = cJSON_CreateArray();
for(i = 0;a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber(numbers[i]);
if(!n)
{
cJSON_Delete(a);
return NULL;
}
if(!i)
{
a->child = n;
}
else
{
suffix_object(p, n);
}
p = n;
}
return a;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count)
{
size_t i = 0;
cJSON *n = NULL;
cJSON *p = NULL;
cJSON *a = NULL;
if ((count < 0) || (strings == NULL))
{
return NULL;
}
a = cJSON_CreateArray();
for (i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateString(strings[i]);
if(!n)
{
cJSON_Delete(a);
return NULL;
}
if(!i)
{
a->child = n;
}
else
{
suffix_object(p,n);
}
p = n;
}
return a;
}
/* Duplication */
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)
{
cJSON *newitem = NULL;
cJSON *child = NULL;
cJSON *next = NULL;
cJSON *newchild = NULL;
/* Bail on bad ptr */
if (!item)
{
goto fail;
}
/* Create new item */
newitem = cJSON_New_Item(&global_hooks);
if (!newitem)
{
goto fail;
}
/* Copy over all vars */
newitem->type = item->type & (~cJSON_IsReference);
newitem->valueint = item->valueint;
newitem->valuedouble = item->valuedouble;
if (item->valuestring)
{
newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks);
if (!newitem->valuestring)
{
goto fail;
}
}
if (item->string)
{
newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned char*)item->string, &global_hooks);
if (!newitem->string)
{
goto fail;
}
}
/* If non-recursive, then we're done! */
if (!recurse)
{
return newitem;
}
/* Walk the ->next chain for the child. */
child = item->child;
while (child != NULL)
{
newchild = cJSON_Duplicate(child, true); /* Duplicate (with recurse) each item in the ->next chain */
if (!newchild)
{
goto fail;
}
if (next != NULL)
{
/* If newitem->child already set, then crosswire ->prev and ->next and move on */
next->next = newchild;
newchild->prev = next;
next = newchild;
}
else
{
/* Set newitem->child and move to it */
newitem->child = newchild;
next = newchild;
}
child = child->next;
}
return newitem;
fail:
if (newitem != NULL)
{
cJSON_Delete(newitem);
}
return NULL;
}
CJSON_PUBLIC(void) cJSON_Minify(char *json)
{
unsigned char *into = (unsigned char*)json;
if (json == NULL)
{
return;
}
while (*json)
{
if (*json == ' ')
{
json++;
}
else if (*json == '\t')
{
/* Whitespace characters. */
json++;
}
else if (*json == '\r')
{
json++;
}
else if (*json=='\n')
{
json++;
}
else if ((*json == '/') && (json[1] == '/'))
{
/* double-slash comments, to end of line. */
while (*json && (*json != '\n'))
{
json++;
}
}
else if ((*json == '/') && (json[1] == '*'))
{
/* multiline comments. */
while (*json && !((*json == '*') && (json[1] == '/')))
{
json++;
}
json += 2;
}
else if (*json == '\"')
{
/* string literals, which are \" sensitive. */
*into++ = (unsigned char)*json++;
while (*json && (*json != '\"'))
{
if (*json == '\\')
{
*into++ = (unsigned char)*json++;
}
*into++ = (unsigned char)*json++;
}
*into++ = (unsigned char)*json++;
}
else
{
/* All other characters. */
*into++ = (unsigned char)*json++;
}
}
/* and null-terminate. */
*into = '\0';
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & 0xFF) == cJSON_Invalid;
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & 0xFF) == cJSON_False;
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & 0xff) == cJSON_True;
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & (cJSON_True | cJSON_False)) != 0;
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & 0xFF) == cJSON_NULL;
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & 0xFF) == cJSON_Number;
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & 0xFF) == cJSON_String;
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & 0xFF) == cJSON_Array;
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & 0xFF) == cJSON_Object;
}
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item)
{
if (item == NULL)
{
return false;
}
return (item->type & 0xFF) == cJSON_Raw;
}
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive)
{
if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a))
{
return false;
}
/* check if type is valid */
switch (a->type & 0xFF)
{
case cJSON_False:
case cJSON_True:
case cJSON_NULL:
case cJSON_Number:
case cJSON_String:
case cJSON_Raw:
case cJSON_Array:
case cJSON_Object:
break;
default:
return false;
}
/* identical objects are equal */
if (a == b)
{
return true;
}
switch (a->type & 0xFF)
{
/* in these cases and equal type is enough */
case cJSON_False:
case cJSON_True:
case cJSON_NULL:
return true;
case cJSON_Number:
if (a->valuedouble == b->valuedouble)
{
return true;
}
return false;
case cJSON_String:
case cJSON_Raw:
if ((a->valuestring == NULL) || (b->valuestring == NULL))
{
return false;
}
if (strcmp(a->valuestring, b->valuestring) == 0)
{
return true;
}
return false;
case cJSON_Array:
{
cJSON *a_element = a->child;
cJSON *b_element = b->child;
for (; (a_element != NULL) && (b_element != NULL);)
{
if (!cJSON_Compare(a_element, b_element, case_sensitive))
{
return false;
}
a_element = a_element->next;
b_element = b_element->next;
}
/* one of the arrays is longer than the other */
if (a_element != b_element) {
return false;
}
return true;
}
case cJSON_Object:
{
cJSON *a_element = NULL;
cJSON *b_element = NULL;
cJSON_ArrayForEach(a_element, a)
{
/* TODO This has O(n^2) runtime, which is horrible! */
b_element = get_object_item(b, a_element->string, case_sensitive);
if (b_element == NULL)
{
return false;
}
if (!cJSON_Compare(a_element, b_element, case_sensitive))
{
return false;
}
}
/* doing this twice, once on a and b to prevent true comparison if a subset of b
* TODO: Do this the proper way, this is just a fix for now */
cJSON_ArrayForEach(b_element, b)
{
a_element = get_object_item(a, b_element->string, case_sensitive);
if (a_element == NULL)
{
return false;
}
if (!cJSON_Compare(b_element, a_element, case_sensitive))
{
return false;
}
}
return true;
}
default:
return false;
}
}
CJSON_PUBLIC(void *) cJSON_malloc(size_t size)
{
return global_hooks.allocate(size);
}
CJSON_PUBLIC(void) cJSON_free(void *object)
{
global_hooks.deallocate(object);
}
[11:30:07] do_trans.c:392 :{
"ChannelAuthCode": "6928126730080",
"CurrencyType": "156",
"DeviceType": "02",
"Key": "Key",
"Mch_id": "11",
"NotifyUrl": "setNotifyUrl",
"OldOrderNo": "10000005201801172253040699",
"OrderAmt": "900",
"OrderDateTime": "20185317220169",
"OrderName": "测试",
"OrderNo": "10000005201801172253040699",
"OrderType": "02",
"PayChannelType": "2",
"Ter_id": "00000011"
}
[11:30:07] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "11",
"method": "query",
"out_transaction_no": 220169,
"sign_type": "MD5",
"ter_id": "00000011",
"time_start": "20185317220169",
"sign": "AD378098FAB15901CC3DDD5ED3AF6F31"
}
[11:30:07] do_trans.c:210 :recvbuf:
{
"method": "query",
"agent_id": "88888881",
"mch_id": "11",
"ter_id": "00000011",
"code": "INVALIDTERNO",
"msg": "Mer Id do not have access privilege",
"sign_type": "MD5",
"sign": "AD378098FAB15901CC3DDD5ED3AF6F31"
}
[11:30:07] do_trans.c:413 :{
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 2,
"Agent_id": "88888881",
"Mch_id": "11",
"Ter_id": "00000011",
"ResponseCode": "96",
"ResponseMsg": "Mer Id do not have access privilege",
"PosTrace": "220169"
}[11:30:07] do_trans.c:392 :{
"ChannelAuthCode": "6928126730080",
"CurrencyType": "156",
"DeviceType": "02",
"Key": "Abcdef1234567890",
"Mch_id": "888888888888881",
"NotifyUrl": "setNotifyUrl",
"OldOrderNo": "10000005201801172253040699",
"OrderAmt": "900",
"OrderDateTime": "20185317220169",
"OrderName": "测试",
"OrderNo": "10000005201801172253040699",
"OrderType": "02",
"PayChannelType": "2",
"Ter_id": "00000001"
}
[11:30:07] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "888888888888881",
"method": "query",
"out_transaction_no": 220169,
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20185317220169",
"sign": "7D3E0C0BCEFD8451C46798DE71259A70"
}
[11:30:07] do_trans.c:210 :recvbuf:
{
"agent_id": "88888881",
"code": "TRANSNOTEXIST",
"mch_id": "888888888888881",
"method": "query",
"msg": "The original transaction record not exist",
"sign_type": "MD5",
"ter_id": "00000001",
"sign": "C54E1CBDF86819D0BF27FF28C43E6B24"
}
[11:30:07] do_trans.c:413 :{
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 2,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "25",
"ResponseMsg": "The original transaction record not exist",
"PosTrace": "220169"
}[11:31:50] do_trans.c:392 :{
"ChannelAuthCode": "6928126730080",
"CurrencyType": "156",
"DeviceType": "02",
"Key": "Abcdef1234567890",
"Mch_id": "888888888888881",
"NotifyUrl": "setNotifyUrl",
"OldOrderNo": "10000005201801172253040699",
"OrderAmt": "1",
"OrderDateTime": "20180119113130",
"OrderName": "测试",
"OrderNo": "10000005201801172253040699",
"OrderType": "02",
"PayChannelType": "2",
"Ter_id": "00000001"
}
[11:31:50] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "888888888888881",
"method": "query",
"out_transaction_no": 113130,
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119113130",
"sign": "30C1AE4E9AB65DBC6FFBA2430B64BDFA"
}
[11:31:50] do_trans.c:210 :recvbuf:
{
"agent_id": "88888881",
"code": "TRANSNOTEXIST",
"mch_id": "888888888888881",
"method": "query",
"msg": "The original transaction record not exist",
"sign_type": "MD5",
"ter_id": "00000001",
"sign": "C54E1CBDF86819D0BF27FF28C43E6B24"
}
[11:31:50] do_trans.c:413 :{
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 2,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "25",
"ResponseMsg": "The original transaction record not exist",
"PosTrace": "113130"
}[11:31:50] do_trans.c:392 :{
"OrderDateTime": "20180119113507",
"OrderName": "浙星门店消费",
"OrderNo": "20180108104821",
"ChannelAuthCode": "135432426010841918",
"OrderType": 1,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
[11:31:50] do_trans_pax.c:100 :sign_buf: agent_id=88888881&auth_code=135432426010841918&mch_id=888888888888881&method=micropay&notify_url=http://114.241.215.67:8888/pax&out_transaction_no=113507&sign_type=MD5&ter_id=00000001&time_start=20180119113507&total_amount=0.01&key=Abcdef1234567890
[11:31:50] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"auth_code": "135432426010841918",
"mch_id": "888888888888881",
"method": "micropay",
"notify_url": "http://114.241.215.67:8888/pax",
"out_transaction_no": 113507,
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119113507",
"total_amount": "0.01",
"sign": "26F5F680337955F8BC46D31FBF5E1913"
}
[11:31:50] do_trans.c:210 :recvbuf:
{
"agent_id": "88888881",
"code": "USINGPAY",
"mch_id": "888888888888881",
"method": "micropay",
"msg": "Please call query API to get transaction status",
"sign_type": "MD5",
"ter_id": "00000001",
"sign": "A8AF67EA4C5DB5D029CF432FC904BBA5"
}
[11:31:50] do_trans.c:413 :{
"OrderType": 1,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "98",
"ResponseMsg": "Please call query API to get transaction status",
"PosTrace": "113507"
}[11:35:49] do_trans.c:392 :{
"OrderDateTime": "20180119113507",
"OrderName": "浙星门店消费",
"OrderNo": "20180108104821",
"ChannelAuthCode": "135432426010841918",
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
[11:35:49] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "888888888888881",
"method": "query",
"out_transaction_no": 113507,
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119113507",
"sign": "8681CA2C3C9C12DAC214A8A834BCD28A"
}
[11:35:49] do_trans.c:210 :recvbuf:
{
"agent_id": "88888881",
"code": "SUCCESS",
"currency": "CNY",
"mch_id": "888888888888881",
"method": "query",
"msg": "Transaction OK",
"out_trade_no": "4200000075201801196852955959",
"out_transaction_no": "113507",
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119113507",
"total_amount": "0.01",
"trade_time": "20180119113536",
"trade_type": "pay.weixin.micropay",
"transaction_no": "180119113414030150",
"sign": "1B0D75BA063FC8EBE464B81C971CC971"
}
[11:35:49] do_trans.c:413 :{
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "00",
"ResponseMsg": "交易成功",
"PosTrace": "113507",
"PosTrace": "113507",
"OrderDateTime": "20180119113507",
"OrderNo": "20180108104821",
"HostOrderNo": "180119113414030150",
"PlatOrderNo": "",
"OrderAmt": "0.01",
"CurrencyType": "",
"TradeStatus": "0",
"tn": ""
}[11:35:49] do_trans.c:392 :{
"OrderDateTime": "20180119113940",
"OrderName": "浙星门店消费",
"OldOrderNo": "20180119113507",
"ChannelAuthCode": "135432426010841918",
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
[11:35:49] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "888888888888881",
"method": "cancel",
"out_transaction_no": 113940,
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119113940",
"sign": "785FBA44D882117160225AF3876D1218"
}
[11:35:49] do_trans.c:210 :recvbuf:
{
"agent_id": "88888881",
"code": "TRANSNOTEXIST",
"mch_id": "888888888888881",
"method": "cancel",
"msg": "The original transaction record not exist",
"sign_type": "MD5",
"ter_id": "00000001",
"sign": "6E0487C69599237F7478571FED2F337E"
}
[11:35:49] do_trans.c:413 :{
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "25",
"ResponseMsg": "The original transaction record not exist",
"PosTrace": "113940"
}[11:50:09] do_trans.c:392 :{
"OrderDateTime": "20180119113940",
"OrderName": "浙星门店消费",
"OrderNo": "113507",
"ChannelAuthCode": "135432426010841918",
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
[11:50:09] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "888888888888881",
"method": "cancel",
"out_transaction_no": 113940,
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119113940",
"sign": "785FBA44D882117160225AF3876D1218"
}
[11:50:09] do_trans.c:210 :recvbuf:
{
"agent_id": "88888881",
"code": "TRANSNOTEXIST",
"mch_id": "888888888888881",
"method": "cancel",
"msg": "The original transaction record not exist",
"sign_type": "MD5",
"ter_id": "00000001",
"sign": "6E0487C69599237F7478571FED2F337E"
}
[11:50:09] do_trans.c:413 :{
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "25",
"ResponseMsg": "The original transaction record not exist",
"PosTrace": "113940"
}[11:50:09] do_trans.c:392 :{
"OrderDateTime": "113507",
"OrderName": "浙星门店消费",
"OrderNo": "113507",
"ChannelAuthCode": "135432426010841918",
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
[11:50:09] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "888888888888881",
"method": "cancel",
"out_transaction_no": 113507,
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "113507",
"sign": "A07E0DCA835BC5DE0F99F9E69F887946"
}
[11:50:09] do_trans.c:210 :recvbuf:
{
"agent_id": "88888881",
"code": "TRANSNOTEXIST",
"mch_id": "888888888888881",
"method": "cancel",
"msg": "The original transaction record not exist",
"sign_type": "MD5",
"ter_id": "00000001",
"sign": "6E0487C69599237F7478571FED2F337E"
}
[11:50:09] do_trans.c:413 :{
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "25",
"ResponseMsg": "The original transaction record not exist",
"PosTrace": "113507"
}[11:50:09] do_trans.c:392 :{
"OrderDateTime": "20180119113507",
"OrderName": "浙星门店消费",
"OrderNo": "113507",
"ChannelAuthCode": "135432426010841918",
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
[11:50:09] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "888888888888881",
"method": "cancel",
"out_transaction_no": 113507,
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119113507",
"sign": "269AA4C611CA7D08938DBD62CDFE6076"
}
[11:50:09] do_trans.c:210 :recvbuf:
{
"agent_id": "88888881",
"code": "SUCCESS",
"mch_id": "888888888888881",
"method": "cancel",
"msg": "Transaction OK",
"out_transaction_no": "113507",
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119113507",
"sign": "0C63116425EB7E5820B0F5118CED28A4"
}
[11:50:09] do_trans.c:413 :{
"OrderType": 3,
"PayChannelType": 2,
"DeviceType": 1,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "00",
"ResponseMsg": "交易成功",
"PosTrace": "113507",
"PosTrace": "113507",
"OrderDateTime": "20180119113507",
"OrderNo": "113507",
"HostOrderNo": "",
"PlatOrderNo": "",
"OrderAmt": "1",
"CurrencyType": "",
"TradeStatus": "0",
"tn": ""
}[11:58:23] do_trans.c:391 :<---------------------------
[11:58:23] do_trans.c:392 :{
"OrderDateTime": "20180119115923",
"OrderName": "浙星门店消费",
"OrderNo": "113507",
"OrderType": 1,
"PayChannelType": 3,
"DeviceType": 2,
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"OrderAmt": "1",
"Agent_id": "88888881",
"Key": "Abcdef1234567890"
}
[11:58:23] do_trans.c:206 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "888888888888881",
"method": "qrpay",
"notify_url": "http://114.241.215.67:8888/pax",
"out_transaction_no": 115923,
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119115923",
"total_amount": "0.01",
"trade_type": "3",
"sign": "92CF602EE056A46AAE342BF44DCF14E9"
}
[11:58:23] do_trans.c:209 :recvbuf:
{
"agent_id": "88888881",
"code": "SUCCESS",
"code_url": "https://qrpay.paxpay.cn/qr/gateway/qrpay.html?development=true&qrtoken=o6pvw5s1QTE3QjEyNTc2ODc1RDQxMjI2OUVENUQwMjhFODM1OTA=",
"mch_id": "888888888888881",
"method": "qrpay",
"msg": "Transaction OK",
"out_transaction_no": "115923",
"sign_type": "MD5",
"ter_id": "00000001",
"time_start": "20180119115923",
"transaction_no": "180119115825030210",
"sign": "B655FC1AA6F69092859B3F71A8F535DC"
}
[11:58:23] do_trans.c:413 :{
"OrderType": 1,
"PayChannelType": 3,
"DeviceType": 2,
"Agent_id": "88888881",
"Mch_id": "888888888888881",
"Ter_id": "00000001",
"ResponseCode": "00",
"ResponseMsg": "交易成功",
"PosTrace": "115923",
"OrderDateTime": "20180119115923",
"OrderNo": "113507",
"HostOrderNo": "180119115825030210",
"PlatOrderNo": "",
"OrderAmt": "1",
"CurrencyType": "",
"TradeStatus": "0",
"tn": "https://qrpay.paxpay.cn/qr/gateway/qrpay.html?development=true&qrtoken=o6pvw5s1QTE3QjEyNTc2ODc1RDQxMjI2OUVENUQwMjhFODM1OTA="
}
[11:58:23] do_trans.c:414 :--------------------------->
#include "do_log.h"
static void do_log(const char *errfile, const char *fmt, va_list va)
{
char buf[LINE_MAX] = {0};
vsnprintf(buf, LINE_MAX - 1, fmt, va);
/* strcat(buf, "\n"); */
va_end(va);
char s[16] = {0};
time_t t = time(0);
strftime(s, sizeof(s), "%Y%m%d", localtime(&t));
char filename[FILENAME_MAX]= {0};
sprintf(filename, "%s_%s.log", errfile, s);
FILE *fp = fopen(filename, "a+");
strcat(buf, "\n");
fwrite(buf, strlen(buf), 1, fp);
fclose(fp);
fp = NULL;
}
void __debuglog(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
do_log(DEBUGLOG, fmt, va);
va_end(va);
}
void __errorlog(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
do_log(ERRORLOG, fmt, va);
}
#include "do_trans.h"
#include "bcccode.h"
#include "cJSON.h"
#include "common.h"
#include "do_trans_pax.h"
#include "do_log.h"
#include <curl/curl.h>
#include <curl/easy.h>
#include "http.h"
#ifdef PAXPAY
extern int do_trans_pax(const trans_json_t *json_in, trans_json_t *json_out);
#endif
#define CONTENT_TYPE_PAX "Content-Type: application/json"
#define HOST_URL_SLF "http://127.0.0.1:8181/pax"
#define PORT 8888
struct mem_curl_st {
unsigned char *memory;
size_t size;
};
int do_send_analy(const char *in, trans_json_t *json_st)
{
int ret = 0;
cJSON *pJson = NULL;
pJson = cJSON_Parse(in);
ret = BCC_json_get_val(pJson, "OrderType", json_st->OrderType, sizeof(json_st->OrderType) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "PayChannelType", json_st->PayChannelType, sizeof(json_st->PayChannelType) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "DeviceType", json_st->DeviceType, sizeof(json_st->DeviceType) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "Mch_id", json_st->Mch_id, sizeof(json_st->Mch_id) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "Ter_id", json_st->Ter_id, sizeof(json_st->Ter_id) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "OrderDateTime", json_st->OrderDateTime, sizeof(json_st->OrderDateTime) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "CurrencyType", json_st->CurrencyType, sizeof(json_st->CurrencyType) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "OrderAmt", json_st->OrderAmt, sizeof(json_st->OrderAmt) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "OrderName", json_st->OrderName, sizeof(json_st->OrderName) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "OrderNo", json_st->OrderNo, sizeof(json_st->OrderNo) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "OldOrderNo", json_st->OldOrderNo, sizeof(json_st->OldOrderNo) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "ChannelAuthCode", json_st->ChannelAuthCode, sizeof(json_st->ChannelAuthCode) - 1);
if (ret < 0) {
goto end;
}
ret = BCC_json_get_val(pJson, "PosTrace", json_st->pos_trace, sizeof(json_st->pos_trace) - 1);
if (!json_st->pos_trace[0]) {
strcpy(json_st->pos_trace, json_st->OrderDateTime + strlen(json_st->OrderDateTime) - 6);
}
ret = BCC_json_get_val(pJson, "Agent_id", json_st->Agent_id, sizeof(json_st->Agent_id));
if (!json_st->Agent_id[0]) {
strcpy(json_st->Agent_id, "88888881");
}
ret = BCC_json_get_val(pJson, "key", json_st->key, sizeof(json_st->key));
if (!json_st->key[0]) {
strcpy(json_st->key, "Abcdef1234567890");
}
#ifdef TEST
strcpy(json_st->notifyUrl, "http://114.241.215.67:8888/pax");
#endif
cJSON_Delete(pJson);
end:
errorlog("BCC_json_get_val FAIL: %d", ret);
return ret;
}
int do_recv_analy(trans_json_t *json_in, char *out)
{
int ret = 0;
char * res = NULL;
cJSON * pOut = NULL;
{
strcpy(json_in->TradeStatus, "-1");
if (strcmp(json_in->ResponseCode, "SUCCESS") == 0) {
strcpy(json_in->ResponseCode, "00");
strcpy(json_in->ResponseMsg, "交易成功");
strcpy(json_in->TradeStatus, "0");
} else if (strcmp(json_in->ResponseCode, "FAIL") == 0) {
strcpy(json_in->ResponseCode, "96");
/* strcpy(json_in->ResponseMsg, "交易失败"); */
} else if (strcmp(json_in->ResponseCode, "USINGPAY") == 0) {
strcpy(json_in->ResponseCode, "98");
/* strcpy(json_in->ResponseMsg, ""); */
} else if (strcmp(json_in->ResponseCode, "UNKNOWN") == 0) {
strcpy(json_in->ResponseCode, "98");
/* strcpy(json_in->ResponseMsg, "未知状态"); */
} else if (strcmp(json_in->ResponseCode, "AMOUNTEXCEED") == 0) {
strcpy(json_in->ResponseCode, "61");
/* strcpy(json_in->ResponseMsg, "超出金额限制"); */
} else if (strcmp(json_in->ResponseCode, "TRANSCLOSE") == 0) {
strcpy(json_in->ResponseCode, "96");
/* strcpy(json_in->ResponseMsg, "交易关闭"); */
} else if (strcmp(json_in->ResponseCode, "TRANSNOTEXIST") == 0) {
strcpy(json_in->ResponseCode, "25");
/* strcpy(json_in->ResponseMsg, "找不到原交易"); */
} else {
strcpy(json_in->ResponseCode, "96");
/* strcpy(json_in->ResponseMsg, "交易失败"); */
}
}
{
pOut = cJSON_CreateObject();
if (pOut == NULL) {
ret = -2;
goto end;
}
cJSON_AddNumberToObject(pOut , "OrderType" , atoi(json_in->OrderType ));
cJSON_AddNumberToObject(pOut , "PayChannelType" , atoi(json_in->PayChannelType));
cJSON_AddNumberToObject(pOut , "DeviceType" , atoi(json_in->DeviceType ));
cJSON_AddStringToObject(pOut , "Agent_id" , json_in->Agent_id );
cJSON_AddStringToObject(pOut , "Mch_id" , json_in->Mch_id );
cJSON_AddStringToObject(pOut , "Ter_id" , json_in->Ter_id );
cJSON_AddStringToObject(pOut , "ResponseCode" , json_in->ResponseCode );
cJSON_AddStringToObject(pOut , "ResponseMsg" , json_in->ResponseMsg );
cJSON_AddStringToObject(pOut , "PosTrace" , json_in->pos_trace );
if (strcasecmp(json_in->ResponseCode, "00") == 0) {
cJSON_AddStringToObject(pOut , "OrderDateTime" , json_in->OrderDateTime );
cJSON_AddStringToObject(pOut , "OrderNo" , json_in->OrderNo );
cJSON_AddStringToObject(pOut , "HostOrderNo" , json_in->host_order_no );
cJSON_AddStringToObject(pOut , "PlatOrderNo" , json_in->plat_order_no );
cJSON_AddStringToObject(pOut , "OrderAmt" , json_in->OrderAmt );
cJSON_AddStringToObject(pOut , "CurrencyType" , json_in->CurrencyType );
cJSON_AddStringToObject(pOut , "TradeStatus" , json_in->TradeStatus );
cJSON_AddStringToObject(pOut , "tn" , json_in->tn );
}
res = cJSON_Print(pOut);
if (res != NULL) {
strcpy(out, res);
} else {
ret = -1;
goto end;
}
cJSON_Delete(pOut);
}
end:
return ret;
}
int do_trans_biz_comm(cJSON *pSend, char *out)
{
char sendbuf[BUFSIZ] = {0};
char * recvbuf = {0};
size_t sendlen = 0;
if ((recvbuf = cJSON_Print(pSend)) != NULL) {
strcpy(sendbuf, recvbuf);
} else {
strcpy(sendbuf, "");
errorlog("%s\n", "cJOSN_Print FAIL");
return -1;
}
sendlen = strlen(sendbuf);
debuglog("sendbuf: \n%s\n", sendbuf);
/* BCC_HTTP_send_recv_data(NULL, NULL, 30, 3, sendbuf, strlen(sendbuf), recvbuf, &recvlen); */
recvbuf = http_post("http://114.55.31.38:8008/tps/api/instrans", sendbuf);
debuglog("recvbuf: \n%s\n", recvbuf);
strcpy(out, recvbuf);
free(recvbuf);
recvbuf = NULL;
return 0;
}
int do_trans_biz_pax(trans_json_t *json_in, trans_json_t *json_out)
{
int ret = 0;
cJSON *pSend = NULL;
char tmp[BUFSIZ] = {0};
pSend = cJSON_CreateObject();
switch (atoi(json_in->OrderType)) {
case 1: {
switch (atoi(json_in->PayChannelType)) {
case 2: {
strcpy(json_in->trade_type, "pay.weixin.native");
switch (atoi(json_in->DeviceType)) {
case 1: {
/* wechat micropay */
strcpy(json_in->method, "micropay");
FUNC_pax_send_micropay(json_in, pSend);
ret = do_trans_biz_comm(pSend, tmp);
FUNC_pax_recv_micropay(tmp, json_out);
break;
}
case 2: {
/* wechat qrpay */
strcpy(json_in->method, "qrpay");
FUNC_pax_send_qrpay(json_in, pSend);
ret = do_trans_biz_comm(pSend, tmp);
FUNC_pax_recv_qrpay(tmp, json_out);
break;
}
case 3: {
/* wechat jspay */
strcpy(json_in->method, "jspay");
FUNC_pax_send_jspay(json_in, pSend);
ret = do_trans_biz_comm(pSend, tmp);
FUNC_pax_recv_jspay(tmp, json_out);
break;
}
default: {
break;
}
}
break;
}
case 3: {
strcpy(json_in->trade_type, "pay.alipay.native");
switch (atoi(json_in->DeviceType)) {
case 1: {
/* ali micropay */
strcpy(json_in->method, "micropay");
FUNC_pax_send_micropay(json_in, pSend);
ret = do_trans_biz_comm(pSend, tmp);
FUNC_pax_recv_micropay(tmp, json_out);
break;
}
case 2: {
/* ali qrpay */
strcpy(json_in->method, "qrpay");
FUNC_pax_send_qrpay(json_in, pSend);
ret = do_trans_biz_comm(pSend, tmp);
FUNC_pax_recv_qrpay(tmp, json_out);
break;
}
case 3: {
/* Ali jspay */
strcpy(json_in->method, "jspay");
FUNC_pax_send_jspay(json_in, pSend);
ret = do_trans_biz_comm(pSend, tmp);
FUNC_pax_recv_jspay(tmp, json_out);
break;
}
}
break;
}
default:
break;
}
break;
}
case 2: {
/* query trans */
strcpy(json_in->method, "query");
FUNC_pax_send_query(json_in, pSend);
ret = do_trans_biz_comm(pSend, tmp);
FUNC_pax_recv_query(tmp, json_out);
break;
}
case 3: {
/* cancel transaction */
strcpy(json_in->method, "cancel");
FUNC_pax_send_cancel(json_in, pSend);
ret = do_trans_biz_comm(pSend, tmp);
FUNC_pax_recv_cancel(tmp, json_out);
break;
}
case 4: {
/* refund */
strcpy(json_in->method, "refund");
FUNC_pax_send_refund(json_in, pSend);
ret = do_trans_biz_comm(pSend, tmp);
FUNC_pax_recv_refund(tmp, json_out);
break;
}
default:
break;
}
FUNC_pax_pay_conv(json_out);
cJSON_Delete(pSend);
return ret;
}
int do_trans(const char *in, char *out, size_t *len)
{
int ret = 0;
trans_json_t json_in;
trans_json_t json_out;
memset(&json_in, 0, sizeof(trans_json_t));
memset(&json_out, 0, sizeof(trans_json_t));
debuglog("%s", "<---------------------------\n");
debuglog("%s\n", in);
{
/* do analy */
do_send_analy(in, &json_in);
memcpy(&json_out, &json_in, sizeof(trans_json_t));
}
{
do_trans_biz_pax(&json_in, &json_out);
}
{
ret = do_recv_analy(&json_out, out);
if (ret != 0) {
errorlog("%s\n", "do_recv_analy error: %d", ret);
goto fail;
}
}
debuglog ("%s\n", out);
debuglog("%s", "--------------------------->\n");
return 0;
fail:
return ret;
}
#include "do_trans_pax.h"
#include "bcccode.h"
#include "bccmd5.h"
#include "cJSON.h"
#include "do_trans.h"
#include "do_log.h"
void FUNC_pax_pay_conv(trans_json_t *json_conv)
{
char *method = NULL;
char *trade_type = NULL;
method = json_conv->method;
trade_type = json_conv->trade_type;
if (strstr(method, "pay")) {
strcpy(json_conv->OrderType, "1");
if (strcmp(method, "micropaypay") == 0) {
strcpy(json_conv->DeviceType, "1");
} else if (strcmp(method, "qrpay") == 0) {
strcpy(json_conv->DeviceType, "2");
} else if (strcmp(method, "jspay") == 0) {
strcpy(json_conv->DeviceType, "3");
}
} else if (strcmp(method, "query") == 0) {
strcpy(json_conv->OrderType, "2");
} else if (strcmp(method, "cancel") == 0) {
strcpy(json_conv->OrderType, "3");
} else if (strcmp(method, "refund") == 0) {
strcpy(json_conv->OrderType, "4");
}
if (strstr(trade_type, "weixin")) {
strcpy(json_conv->PayChannelType, "2");
} else if (strstr(trade_type, "alipay")) {
strcpy(json_conv->PayChannelType, "3");
}
}
int FUNC_pax_send_micropay(const trans_json_t *json_in, cJSON *pOut)
{
/* string */
unsigned char emd5_buf[BUFSIZ] = {0};
char val[BUFSIZ] = {0};
char sign_buf[BUFSIZ] = {0};
const char * ptr = NULL;
size_t sign_len = strlen(sign_buf);
int pos_trace;
{
ptr = json_in->Agent_id;
BCC_str_set_val_raw("agent_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "agent_id", ptr);
ptr = json_in->ChannelAuthCode;
BCC_str_set_val_raw("auth_code", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "auth_code", ptr);
ptr = json_in->Mch_id;
BCC_str_set_val_raw("mch_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "mch_id", ptr);
ptr = json_in->method;
BCC_str_set_val_raw("method", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "method", ptr);
ptr = json_in->notifyUrl;
BCC_str_set_val_raw("notify_url", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "notify_url", ptr);
ptr = val;
pos_trace = atoi(json_in->pos_trace);
sprintf(val, "%d", pos_trace);
BCC_str_set_val_raw("out_transaction_no", ptr, sign_buf, &sign_len);
cJSON_AddNumberToObject(pOut, "out_transaction_no", pos_trace);
BCC_str_set_val_raw("sign_type", "MD5", sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "sign_type", "MD5");
ptr = json_in->Ter_id;
BCC_str_set_val_raw("ter_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "ter_id", ptr);
ptr = json_in->OrderDateTime;
BCC_str_set_val_raw("time_start", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "time_start", ptr);
sprintf(val, "%0.2f", atof(json_in->OrderAmt) / 100);
ptr = val;
BCC_str_set_val_raw("total_amount", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "total_amount", ptr);
sign_buf[sign_len - 1] = 0;
}
{
sprintf(sign_buf + strlen(sign_buf), "&key=%s", json_in->key);
debuglog("sign_buf: %s\n", sign_buf);
BCC_MD5_gen((unsigned char *)sign_buf, emd5_buf);
BCC_code_upper_str(emd5_buf, strlen((char *)emd5_buf));
cJSON_AddStringToObject(pOut, "sign", emd5_buf);
}
return 0;
}
int FUNC_pax_recv_micropay(const char *in, trans_json_t *json_out)
{
int ret = 0;
/* char code[16] = {0}; */
/* char msg[128] = {0}; */
/* char * trade_type = NULL; */
cJSON *pIn = NULL;
pIn = cJSON_Parse(in);
ret = BCC_json_get_val(pIn , "code" , json_out->ResponseCode , sizeof(json_out->ResponseCode ) - 1 );
ret = BCC_json_get_val(pIn , "msg" , json_out->ResponseMsg , sizeof(json_out->ResponseMsg ) - 1 );
ret = BCC_json_get_val(pIn , "method" , json_out->method , sizeof(json_out->method ) - 1 );
ret = BCC_json_get_val(pIn , "agent_id" , json_out->Agent_id , sizeof(json_out->Agent_id ) - 1 );
ret = BCC_json_get_val(pIn , "mch_id" , json_out->Mch_id , sizeof(json_out->Mch_id ) - 1 );
ret = BCC_json_get_val(pIn , "ter_id" , json_out->Ter_id , sizeof(json_out->Ter_id ) - 1 );
if (strcmp(json_out->ResponseCode, "SUCCESS") == 0) {
BCC_json_get_val(pIn , "out_transaction_no" , json_out->pos_trace , sizeof(json_out->pos_trace ) - 1 );
BCC_json_get_val(pIn , "time_start" , json_out->OrderDateTime , sizeof(json_out->OrderDateTime ) - 1 );
BCC_json_get_val(pIn , "transaction_no" , json_out->host_order_no , sizeof(json_out->host_order_no ) - 1 );
BCC_json_get_val(pIn , "out_trade_no" , json_out->plat_order_no , sizeof(json_out->plat_order_no ) - 1 );
BCC_json_get_val(pIn , "trade_type" , json_out->trade_type , sizeof(json_out->trade_type ) - 1 );
BCC_json_get_val(pIn , "total_amount" , json_out->OrderAmt , sizeof(json_out->OrderAmt ) - 1 );
BCC_json_get_val(pIn , "trade_time" , json_out->payTime , sizeof(json_out->payTime ) - 1 );
BCC_json_get_val(pIn , "sign" , json_out->paySign , sizeof(json_out->paySign ) - 1 );
}
return ret;
}
int FUNC_pax_send_qrpay(const trans_json_t *json_in, cJSON *pOut)
{
/* string */
char emd5_buf[BUFSIZ] = {0};
char val[BUFSIZ] = {0};
char sign_buf[BUFSIZ] = {0};
const char *ptr = NULL;
int sign_len = strlen(sign_buf);
int pos_trace;
{
ptr = json_in->Agent_id;
BCC_str_set_val_raw("agent_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "agent_id", ptr);
ptr = json_in->Mch_id;
BCC_str_set_val_raw("mch_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "mch_id", ptr);
ptr = json_in->method;
BCC_str_set_val_raw("method", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "method", ptr);
ptr = json_in->notifyUrl;
BCC_str_set_val_raw("notify_url", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "notify_url", ptr);
ptr = val;
pos_trace = atoi(json_in->pos_trace);
sprintf(val, "%d", pos_trace);
BCC_str_set_val_raw("out_transaction_no", ptr, sign_buf, &sign_len);
cJSON_AddNumberToObject(pOut, "out_transaction_no", pos_trace);
BCC_str_set_val_raw("sign_type", "MD5", sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "sign_type", "MD5");
ptr = json_in->Ter_id;
BCC_str_set_val_raw("ter_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "ter_id", ptr);
ptr = json_in->OrderDateTime;
BCC_str_set_val_raw("time_start", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "time_start", ptr);
sprintf(val, "%0.2f", atof(json_in->OrderAmt) / 100);
ptr = val;
BCC_str_set_val_raw("total_amount", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "total_amount", ptr);
ptr = json_in->PayChannelType;
BCC_str_set_val_raw("trade_type", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "trade_type", ptr);
sign_buf[sign_len - 1] = 0;
}
{
sprintf(sign_buf + strlen(sign_buf), "&key=%s", json_in->key);
BCC_MD5_gen(sign_buf, emd5_buf);
BCC_code_upper_str(emd5_buf, strlen(emd5_buf));
cJSON_AddStringToObject(pOut, "sign", emd5_buf);
}
return 0;
}
int FUNC_pax_recv_qrpay(const char *in, trans_json_t *json_out)
{
int ret = 0;
cJSON *pIn = NULL;
pIn = cJSON_Parse(in);
if (pIn == NULL) {
errorlog("%s\n", "cJSON_Parse FAIL!\n");
}
ret = BCC_json_get_val(pIn , "code" , json_out->ResponseCode , sizeof(json_out->ResponseCode ) - 1 );
ret = BCC_json_get_val(pIn , "msg" , json_out->ResponseMsg , sizeof(json_out->ResponseMsg ) - 1 );
ret = BCC_json_get_val(pIn , "method" , json_out->method , sizeof(json_out->method ) - 1 );
ret = BCC_json_get_val(pIn , "agent_id" , json_out->Agent_id , sizeof(json_out->Agent_id ) - 1 );
ret = BCC_json_get_val(pIn , "mch_id" , json_out->Mch_id , sizeof(json_out->Mch_id ) - 1 );
ret = BCC_json_get_val(pIn , "ter_id" , json_out->Ter_id , sizeof(json_out->Ter_id ) - 1 );
if (strcmp(json_out->ResponseCode, "SUCCESS") == 0) {
BCC_json_get_val(pIn , "out_transaction_no" , json_out->pos_trace , sizeof(json_out->pos_trace ) - 1 );
BCC_json_get_val(pIn , "time_start" , json_out->OrderDateTime , sizeof(json_out->OrderDateTime ) - 1 );
BCC_json_get_val(pIn , "transaction_no" , json_out->host_order_no , sizeof(json_out->host_order_no ) - 1 );
BCC_json_get_val(pIn , "code_url" , json_out->tn , sizeof(json_out->tn ) - 1 );
BCC_json_get_val(pIn , "sign" , json_out->paySign , sizeof(json_out->paySign ) - 1 );
}
return ret;
}
int FUNC_pax_send_jspay(const trans_json_t *json_in, cJSON *pOut)
{
char emd5_buf[BUFSIZ] = {0};
char val[BUFSIZ] = {0};
char sign_buf[BUFSIZ] = {0};
const char *ptr = NULL;
int sign_len = strlen(sign_buf);
int pos_trace;
{
ptr = json_in->Agent_id;
BCC_str_set_val_raw("agent_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "agent_id", ptr);
ptr = json_in->Mch_id;
BCC_str_set_val_raw("mch_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "mch_id", ptr);
ptr = json_in->method;
BCC_str_set_val_raw("method", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "method", ptr);
ptr = json_in->notifyUrl;
BCC_str_set_val_raw("notify_url", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "notify_url", ptr);
ptr = "0710eyts123mtp0cUMrs1Omwts10eytN";
BCC_str_set_val_raw("open_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "open_id", ptr);
ptr = val;
pos_trace = atoi(json_in->pos_trace);
sprintf(val, "%d", pos_trace);
BCC_str_set_val_raw("out_transaction_no", ptr, sign_buf, &sign_len);
cJSON_AddNumberToObject(pOut, "out_transaction_no", pos_trace);
BCC_str_set_val_raw("sign_type", "MD5", sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "sign_type", "MD5");
ptr = json_in->Ter_id;
BCC_str_set_val_raw("ter_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "ter_id", ptr);
ptr = json_in->OrderDateTime;
BCC_str_set_val_raw("time_start", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "time_start", ptr);
sprintf(val, "%0.2f", atof(json_in->OrderAmt) / 100);
ptr = val;
BCC_str_set_val_raw("total_amount", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "total_amount", ptr);
sign_buf[sign_len - 1] = 0;
}
{
sprintf(sign_buf + strlen(sign_buf), "&key=%s", json_in->key);
BCC_MD5_gen(sign_buf, emd5_buf);
BCC_code_upper_str(emd5_buf, strlen(emd5_buf));
cJSON_AddStringToObject(pOut, "sign", emd5_buf);
}
return 0;
}
int FUNC_pax_recv_jspay(const char *in, trans_json_t *json_out)
{
int ret = 0;
/* char code[16] = {0}; */
/* char msg[128] = {0}; */
/* char * trade_type = NULL; */
cJSON *pIn = NULL;
pIn = cJSON_Parse(in);
ret = BCC_json_get_val(pIn, "code", json_out->ResponseCode, sizeof(json_out->ResponseCode) - 1);
ret = BCC_json_get_val(pIn, "msg", json_out->ResponseMsg, sizeof(json_out->ResponseMsg) - 1);
ret = BCC_json_get_val(pIn, "method", json_out->method, sizeof(json_out->method) - 1);
ret = BCC_json_get_val(pIn, "agent_id", json_out->Agent_id, sizeof(json_out->Agent_id) - 1);
ret = BCC_json_get_val(pIn, "mch_id", json_out->Mch_id, sizeof(json_out->Mch_id) - 1);
ret = BCC_json_get_val(pIn, "ter_id", json_out->Ter_id, sizeof(json_out->Ter_id) - 1);
if (strcmp(json_out->ResponseCode, "SUCCESS") == 0) {
BCC_json_get_val(pIn, "out_transaction_no", json_out->pos_trace, sizeof(json_out->pos_trace) - 1);
BCC_json_get_val(pIn, "time_start", json_out->OrderDateTime, sizeof(json_out->OrderDateTime) - 1);
BCC_json_get_val(pIn, "transaction_no", json_out->host_order_no, sizeof(json_out->host_order_no) - 1);
BCC_json_get_val(pIn, "js_info", json_out->js_info, sizeof(json_out->js_info) - 1);
BCC_json_get_val(pIn, "sign", json_out->paySign, sizeof(json_out->paySign) - 1);
}
return ret;
}
int FUNC_pax_send_refund(const trans_json_t *json_in, cJSON *pOut)
{
/* string */
char emd5_buf[BUFSIZ] = {0};
char val[BUFSIZ] = {0};
char sign_buf[BUFSIZ] = {0};
const char *ptr = NULL;
int sign_len = strlen(sign_buf);
int pos_trace;
{
ptr = json_in->Agent_id;
BCC_str_set_val_raw("agent_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "agent_id", ptr);
ptr = json_in->Mch_id;
BCC_str_set_val_raw("mch_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "mch_id", ptr);
ptr = json_in->method;
BCC_str_set_val_raw("method", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "method", ptr);
ptr = json_in->OldOrderNo;
BCC_str_set_val_raw("ori_transaction_no", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "ori_transaction_no", ptr);
ptr = val;
pos_trace = atoi(json_in->pos_trace);
sprintf(val, "%d", pos_trace);
BCC_str_set_val_raw("out_transaction_no", ptr, sign_buf, &sign_len);
cJSON_AddNumberToObject(pOut, "out_transaction_no", pos_trace);
BCC_str_set_val_raw("sign_type", "MD5", sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "sign_type", "MD5");
ptr = json_in->Ter_id;
BCC_str_set_val_raw("ter_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "ter_id", ptr);
ptr = json_in->OrderDateTime;
BCC_str_set_val_raw("time_start", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "time_start", ptr);
sprintf(val, "%0.2f", atof(json_in->OrderAmt) / 100);
ptr = val;
BCC_str_set_val_raw("total_amount", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "total_amount", ptr);
sign_buf[sign_len - 1] = 0;
}
{
sprintf(sign_buf + strlen(sign_buf), "&key=%s", json_in->key);
BCC_MD5_gen(sign_buf, emd5_buf);
BCC_code_upper_str(emd5_buf, strlen(emd5_buf));
cJSON_AddStringToObject(pOut, "sign", emd5_buf);
}
return 0;
}
int FUNC_pax_recv_refund(const char *in, trans_json_t *json_out)
{
int ret = 0;
/* char code[16] = {0}; */
/* char msg[128] = {0}; */
/* char * trade_type = NULL; */
cJSON *pIn = NULL;
pIn = cJSON_Parse(in);
ret = BCC_json_get_val(pIn, "code", json_out->ResponseCode, sizeof(json_out->ResponseCode) - 1);
ret = BCC_json_get_val(pIn, "msg", json_out->ResponseMsg, sizeof(json_out->ResponseMsg) - 1);
ret = BCC_json_get_val(pIn, "method", json_out->method, sizeof(json_out->method) - 1);
ret = BCC_json_get_val(pIn, "agent_id", json_out->Agent_id, sizeof(json_out->Agent_id) - 1);
ret = BCC_json_get_val(pIn, "mch_id", json_out->Mch_id, sizeof(json_out->Mch_id) - 1);
ret = BCC_json_get_val(pIn, "ter_id", json_out->Ter_id, sizeof(json_out->Ter_id) - 1);
if (strcmp(json_out->ResponseCode, "SUCCESS") == 0) {
BCC_json_get_val(pIn, "out_transaction_no", json_out->pos_trace, sizeof(json_out->pos_trace) - 1);
BCC_json_get_val(pIn, "time_start", json_out->OrderDateTime, sizeof(json_out->OrderDateTime) - 1);
BCC_json_get_val(pIn, "transaction_no", json_out->host_order_no, sizeof(json_out->host_order_no) - 1);
BCC_json_get_val(pIn, "trade_type", json_out->trade_type, sizeof(json_out->trade_type) - 1);
BCC_json_get_val(pIn, "total_amount", json_out->OrderAmt, sizeof(json_out->OrderAmt) - 1);
BCC_json_get_val(pIn, "trade_time", json_out->payTime, sizeof(json_out->payTime) - 1);
BCC_json_get_val(pIn, "sign", json_out->paySign, sizeof(json_out->paySign) - 1);
}
return ret;
}
int FUNC_pax_send_cancel(const trans_json_t *json_in, cJSON *pOut)
{
/* string */
char emd5_buf[BUFSIZ] = {0};
char sign_buf[BUFSIZ] = {0};
char val[BUFSIZ] = {0};
const char *ptr = NULL;
int sign_len = strlen(sign_buf);
int pos_trace;
{
ptr = json_in->Agent_id;
BCC_str_set_val_raw("agent_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "agent_id", ptr);
ptr = json_in->Mch_id;
BCC_str_set_val_raw("mch_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "mch_id", ptr);
ptr = json_in->method;
BCC_str_set_val_raw("method", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "method", ptr);
ptr = val;
pos_trace = atoi(json_in->pos_trace);
sprintf(val, "%d", pos_trace);
BCC_str_set_val_raw("out_transaction_no", ptr, sign_buf, &sign_len);
cJSON_AddNumberToObject(pOut, "out_transaction_no", pos_trace);
BCC_str_set_val_raw("sign_type", "MD5", sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "sign_type", "MD5");
ptr = json_in->Ter_id;
BCC_str_set_val_raw("ter_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "ter_id", ptr);
ptr = json_in->OrderDateTime;
BCC_str_set_val_raw("time_start", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "time_start", ptr);
sign_buf[sign_len - 1] = 0;
}
{
sprintf(sign_buf + strlen(sign_buf), "&key=%s", json_in->key);
BCC_MD5_gen(sign_buf, emd5_buf);
BCC_code_upper_str(emd5_buf, strlen(emd5_buf));
cJSON_AddStringToObject(pOut, "sign", emd5_buf);
}
return 0;
}
int FUNC_pax_recv_cancel(const char *in, trans_json_t *json_out)
{
int ret = 0;
/* char code[16] = {0}; */
/* char msg[128] = {0}; */
/* char * trade_type = NULL; */
cJSON *pIn = NULL;
pIn = cJSON_Parse(in);
ret = BCC_json_get_val(pIn, "code", json_out->ResponseCode, sizeof(json_out->ResponseCode) - 1);
ret = BCC_json_get_val(pIn, "msg", json_out->ResponseMsg, sizeof(json_out->ResponseMsg) - 1);
ret = BCC_json_get_val(pIn, "method", json_out->method, sizeof(json_out->method) - 1);
ret = BCC_json_get_val(pIn, "agent_id", json_out->Agent_id, sizeof(json_out->Agent_id) - 1);
ret = BCC_json_get_val(pIn, "mch_id", json_out->Mch_id, sizeof(json_out->Mch_id) - 1);
ret = BCC_json_get_val(pIn, "ter_id", json_out->Ter_id, sizeof(json_out->Ter_id) - 1);
if (strcmp(json_out->ResponseCode, "SUCCESS") == 0) {
BCC_json_get_val(pIn, "out_transaction_no", json_out->pos_trace, sizeof(json_out->pos_trace) - 1);
BCC_json_get_val(pIn, "time_start", json_out->OrderDateTime, sizeof(json_out->OrderDateTime) - 1);
BCC_json_get_val(pIn, "transaction_no", json_out->host_order_no, sizeof(json_out->host_order_no) - 1);
BCC_json_get_val(pIn, "trade_type", json_out->trade_type, sizeof(json_out->trade_type) - 1);
BCC_json_get_val(pIn, "total_amount", json_out->OrderAmt, sizeof(json_out->OrderAmt) - 1);
BCC_json_get_val(pIn, "trade_time", json_out->payTime, sizeof(json_out->payTime) - 1);
BCC_json_get_val(pIn, "sign", json_out->paySign, sizeof(json_out->paySign) - 1);
}
return ret;
}
int FUNC_pax_send_query(const trans_json_t *json_in, cJSON *pOut)
{
/* string */
char emd5_buf[BUFSIZ] = {0};
char sign_buf[BUFSIZ] = {0};
char val[BUFSIZ] = {0};
const char *ptr = NULL;
int sign_len = strlen(sign_buf);
int pos_trace;
{
ptr = json_in->Agent_id;
BCC_str_set_val_raw("agent_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "agent_id", ptr);
ptr = json_in->Mch_id;
BCC_str_set_val_raw("mch_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "mch_id", ptr);
ptr = json_in->method;
BCC_str_set_val_raw("method", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "method", ptr);
ptr = val;
pos_trace = atoi(json_in->pos_trace);
sprintf(val, "%d", pos_trace);
BCC_str_set_val_raw("out_transaction_no", ptr, sign_buf, &sign_len);
cJSON_AddNumberToObject(pOut, "out_transaction_no", pos_trace);
BCC_str_set_val_raw("sign_type", "MD5", sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "sign_type", "MD5");
ptr = json_in->Ter_id;
BCC_str_set_val_raw("ter_id", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "ter_id", ptr);
ptr = json_in->OrderDateTime;
BCC_str_set_val_raw("time_start", ptr, sign_buf, &sign_len);
cJSON_AddStringToObject(pOut, "time_start", ptr);
sign_buf[sign_len - 1] = 0;
}
{
sprintf(sign_buf + strlen(sign_buf), "&key=%s", json_in->key);
BCC_MD5_gen(sign_buf, emd5_buf);
BCC_code_upper_str(emd5_buf, strlen(emd5_buf));
cJSON_AddStringToObject(pOut, "sign", emd5_buf);
}
return 0;
}
int FUNC_pax_recv_query(const char *in, trans_json_t *json_out)
{
int ret = 0;
/* char code[16] = {0}; */
/* char msg[128] = {0}; */
/* char * trade_type = NULL; */
cJSON *pIn = NULL;
pIn = cJSON_Parse(in);
ret = BCC_json_get_val(pIn, "code", json_out->ResponseCode, sizeof(json_out->ResponseCode) - 1);
ret = BCC_json_get_val(pIn, "msg", json_out->ResponseMsg, sizeof(json_out->ResponseMsg) - 1);
ret = BCC_json_get_val(pIn, "method", json_out->method, sizeof(json_out->method) - 1);
ret = BCC_json_get_val(pIn, "agent_id", json_out->Agent_id, sizeof(json_out->Agent_id) - 1);
ret = BCC_json_get_val(pIn, "mch_id", json_out->Mch_id, sizeof(json_out->Mch_id) - 1);
ret = BCC_json_get_val(pIn, "ter_id", json_out->Ter_id, sizeof(json_out->Ter_id) - 1);
if (strcmp(json_out->ResponseCode, "SUCCESS") == 0) {
BCC_json_get_val(pIn, "out_transaction_no", json_out->pos_trace, sizeof(json_out->pos_trace) - 1);
BCC_json_get_val(pIn, "time_start", json_out->OrderDateTime, sizeof(json_out->OrderDateTime) - 1);
BCC_json_get_val(pIn, "transaction_no", json_out->host_order_no, sizeof(json_out->host_order_no) - 1);
BCC_json_get_val(pIn, "trade_type", json_out->trade_type, sizeof(json_out->trade_type) - 1);
BCC_json_get_val(pIn, "total_amount", json_out->OrderAmt, sizeof(json_out->OrderAmt) - 1);
BCC_json_get_val(pIn, "trade_time", json_out->payTime, sizeof(json_out->payTime) - 1);
BCC_json_get_val(pIn, "sign", json_out->paySign, sizeof(json_out->paySign) - 1);
}
return ret;
}
[11:28:03] do_trans.c:392 :{
"ChannelAuthCode": "6928126730080",
"CurrencyType": "156",
"DeviceType": "02",
"Key": "Key",
"Mch_id": "11",
"NotifyUrl": "setNotifyUrl",
"OldOrderNo": "10000005201801172253040699",
"OrderAmt": "900",
"OrderDateTime": "20185317220169",
"OrderName": "测试",
"OrderNo": "10000005201801172253040699",
"OrderType": "02",
"PayChannelType": "2",
"Ter_id": "00000011"
}
[11:28:03] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:28:03] do_trans.c:207 :sendbuf:
{
"agent_id": "88888881",
"mch_id": "11",
"method": "query",
"out_transaction_no": 220169,
"sign_type": "MD5",
"ter_id": "00000011",
"time_start": "20185317220169",
"sign": "AD378098FAB15901CC3DDD5ED3AF6F31"
}
[11:28:03] do_trans.c:210 :recvbuf:
{
"code": "PACKETTYPEERROR",
"msg": "Unknown packet types, set the HTTP header Content-Type type"
}
[11:28:03] do_trans.c:413 :{
"OrderType": 2,
"PayChannelType": 2,
"DeviceType": 2,
"Agent_id": "88888881",
"Mch_id": "11",
"Ter_id": "00000011",
"ResponseCode": "96",
"ResponseMsg": "Unknown packet types, set the HTTP header Content-Type type",
"PosTrace": "220169"
}[11:30:07] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:30:07] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:31:50] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:31:50] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:35:49] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:35:49] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:50:09] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:50:09] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:50:09] do_trans.c:103 :BCC_json_get_val FAIL: 0[11:58:23] do_trans.c:103 :BCC_json_get_val FAIL: 0
\ No newline at end of file
/*File : http.c
*Auth : sjin
*Date : 20141206
*Mail : 413977243@qq.com
*/
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "http.h"
#define BUFFER_SIZE 1024
#define HTTP_POST \
"POST /%s HTTP/1.1\r\nHOST: %s:%d\r\nAccept: */*\r\n" \
"Content-Type: application/json\r\nContent-Length: %lu\r\n\r\n%s"
#define HTTP_GET "GET /%s HTTP/1.1\r\nHOST: %s:%d\r\nAccept: */*\r\n\r\n"
int http_tcpclient_create(const char *host, int port)
{
struct hostent * he;
struct sockaddr_in server_addr;
int socket_fd;
if ((he = gethostbyname(host)) == NULL) {
goto fail;
}
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port);
server_addr.sin_addr = *((struct in_addr *)he->h_addr);
if ((socket_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
goto fail;
}
if (connect(socket_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1) {
goto fail;
}
return socket_fd;
fail:
errorlog("%s", strerror(errno));
return -1;
}
static void http_tcpclient_close(int socket)
{
close(socket);
}
static int http_parse_url(const char *url, char *host, char *file, int *port)
{
char *ptr1 = NULL, *ptr2 = NULL;
int len = 0;
if (!url || !host || !file || !port) {
return -1;
}
ptr1 = (char *)url;
if (!strncmp(ptr1, "http://", strlen("http://"))) {
ptr1 += strlen("http://");
} else {
/* return -1; */
}
ptr2 = strchr(ptr1, '/');
if (ptr2) {
len = strlen(ptr1) - strlen(ptr2);
memcpy(host, ptr1, len);
host[len] = '\0';
if (*(ptr2 + 1)) {
memcpy(file, ptr2 + 1, strlen(ptr2) - 1);
file[strlen(ptr2) - 1] = '\0';
}
} else {
memcpy(host, ptr1, strlen(ptr1));
host[strlen(ptr1)] = '\0';
}
//get host and ip
ptr1 = strchr(host, ':');
if (ptr1) {
*ptr1++ = '\0';
*port = atoi(ptr1);
} else {
*port = MY_HTTP_DEFAULT_PORT;
}
return 0;
}
static int http_tcpclient_recv(int socket, char *lpbuff)
{
int recvnum = 0;
recvnum = recv(socket, lpbuff, BUFFER_SIZE * 4, 0);
return recvnum;
}
static int http_tcpclient_send(int socket, char *buff, int size)
{
int sent = 0, tmpres = 0;
while (sent < size) {
tmpres = send(socket, buff + sent, size - sent, 0);
if (tmpres == -1) {
return -1;
}
sent += tmpres;
}
return sent;
}
static char *http_parse_result(const char *lpbuf)
{
char *ptmp = NULL;
char *response = NULL;
ptmp = (char *)strstr(lpbuf, "HTTP/1.1");
if (!ptmp) {
errorlog("%s", "http/1.1 not faind\n");
return NULL;
}
if (atoi(ptmp + 9) != 200) {
errorlog("%s", "result:\n%s\n", lpbuf);
return NULL;
}
ptmp = (char *)strstr(lpbuf, "\r\n\r\n");
if (!ptmp) {
errorlog("%s", "ptmp is NULL\n");
return NULL;
}
response = (char *)malloc(strlen(ptmp) + 1);
if (!response) {
errorlog("%s", strerror(errno));
return NULL;
}
strcpy(response, ptmp + 4);
return response;
}
char *http_post(const char *url, const char *post_str)
{
int socket_fd = -1;
char lpbuf[BUFFER_SIZE * 4] = {'\0'};
char host_addr[BUFFER_SIZE] = {'\0'};
char file[BUFFER_SIZE] = {'\0'};
int port = 0;
if (!url || !post_str) {
printf(" failed!\n");
return NULL;
}
if (http_parse_url(url, host_addr, file, &port)) {
printf("http_parse_url failed!\n");
return NULL;
}
//printf("host_addr : %s\tfile:%s\t,%d\n",host_addr,file,port);
socket_fd = http_tcpclient_create(host_addr, port);
if (socket_fd < 0) {
printf("http_tcpclient_create failed\n");
return NULL;
}
sprintf(lpbuf, HTTP_POST, file, host_addr, port, strlen(post_str), post_str);
if (http_tcpclient_send(socket_fd, lpbuf, strlen(lpbuf)) < 0) {
printf("http_tcpclient_send failed..\n");
return NULL;
}
//printf("发送请求:\n%s\n",lpbuf);
memset(lpbuf, 0, sizeof(lpbuf));
/*it's time to recv from server*/
if (http_tcpclient_recv(socket_fd, lpbuf) <= 0) {
printf("http_tcpclient_recv failed\n");
return NULL;
}
http_tcpclient_close(socket_fd);
return http_parse_result(lpbuf);
}
char *http_get(const char *url)
{
int socket_fd = -1;
char lpbuf[BUFFER_SIZE * 4] = {'\0'};
char host_addr[BUFFER_SIZE] = {'\0'};
char file[BUFFER_SIZE] = {'\0'};
int port = 0;
if (!url) {
printf(" failed!\n");
return NULL;
}
if (http_parse_url(url, host_addr, file, &port)) {
printf("http_parse_url failed!\n");
return NULL;
}
//printf("host_addr : %s\tfile:%s\t,%d\n",host_addr,file,port);
socket_fd = http_tcpclient_create(host_addr, port);
if (socket_fd < 0) {
printf("http_tcpclient_create failed\n");
return NULL;
}
sprintf(lpbuf, HTTP_GET, file, host_addr, port);
if (http_tcpclient_send(socket_fd, lpbuf, strlen(lpbuf)) < 0) {
printf("http_tcpclient_send failed..\n");
return NULL;
}
// printf("发送请求:\n%s\n",lpbuf);
if (http_tcpclient_recv(socket_fd, lpbuf) <= 0) {
printf("http_tcpclient_recv failed\n");
return NULL;
}
http_tcpclient_close(socket_fd);
return http_parse_result(lpbuf);
}
#if 0
int main()
{
char buf[BUFFER_SIZE] = {0};
FILE *fp = fopen("/tmp/test.json", "r");
if (!fp) {
errorlog("fopen: %s", strerror(errno));
}
while (!feof(fp)) {
fread(buf + strlen(buf), BUFFER_SIZE - strlen(buf), 1, fp);
}
char *tmp = http_post("localhost:8888", buf);
if (!tmp) {
errorlog("http_post: %s\n", strerror(errno));
}
printf("%s\n", tmp);
free(tmp);
}
#endif
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <jni.h>
#include "native-lib.h"
#include "do_log.h"
#include "do_trans.h"
#include "cJSON.h"
//Json To struct
int JsonToStruct_trans(char *pMsg, trans_json_t *trans_json)
{
cJSON *pJson;
cJSON *pSub;
//char * p;
//char TransSN[10];
//char out2[1024*5];
//char out1[1024*5]={0};
if (NULL == pMsg) {
return -1;
}
pJson = cJSON_Parse(pMsg);
if (NULL == pJson) {
return -2;
}
{
pSub = cJSON_GetObjectItem(pJson, "OrderType");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->OrderType, pSub->valuestring);
// printf("TransSN: %s\n",TransSN);
pSub = cJSON_GetObjectItem(pJson, "PayChannelType");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->PayChannelType, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "DeviceType");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->DeviceType, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "Mch_id");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->Mch_id, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "Ter_id");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->Ter_id, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "OrderDateTime");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->OrderDateTime, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "CurrencyType");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->CurrencyType, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "OrderAmt");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->OrderAmt, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "OrderName");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->OrderName, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "OrderNo");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->OrderNo, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "OldOrderNo");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->OldOrderNo, pSub->valuestring);
pSub = cJSON_GetObjectItem(pJson, "ChannelAuthCode");
if (NULL == pSub) {
cJSON_Delete(pJson);
return -1;
}
strcpy(trans_json->ChannelAuthCode, pSub->valuestring);
}
cJSON_Delete(pJson);
return 0;
}
//jstring to char*
char *jstringTostring(JNIEnv *env, jstring jstr)
{
char * rtn = NULL;
jclass clsstring = env->FindClass("java/lang/String");
jstring strencode = env->NewStringUTF("utf-8");
jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B");
jbyteArray barr = (jbyteArray)env->CallObjectMethod(jstr, mid, strencode);
jsize alen = env->GetArrayLength(barr);
jbyte * ba = env->GetByteArrayElements(barr, JNI_FALSE);
if (alen > 0) {
rtn = (char *)malloc(alen + 1);
memcpy(rtn, ba, alen);
rtn[alen] = 0;
}
env->ReleaseByteArrayElements(barr, ba, 0);
return rtn;
}
//char* to jstring
jstring stoJstring(JNIEnv *env, const char *pat)
{
jclass strClass = env->FindClass("Ljava/lang/String;");
jmethodID ctorID = env->GetMethodID(strClass, "<init>", "([BLjava/lang/String;)V");
jbyteArray bytes = env->NewByteArray(strlen(pat));
env->SetByteArrayRegion(bytes, 0, strlen(pat), (jbyte *)pat);
jstring encoding = env->NewStringUTF("utf-8");
return (jstring)env->NewObject(strClass, ctorID, bytes, encoding);
}
jstring pcharToJstring(JNIEnv *env, const char *pat)
{
jclass gStringClass = env->FindClass("java/lang/String");
jmethodID gmidStringInit = env->GetMethodID(gStringClass, "<init>", "([BLjava/lang/String;)V");
jstring jencoding = env->NewStringUTF("utf-8");
jbyteArray bytes = env->NewByteArray(strlen(pat));
env->SetByteArrayRegion(bytes, 0, strlen(pat), (jbyte *)pat);
return (jstring)env->NewObject(gStringClass, gmidStringInit, bytes, jencoding);
}
int jstringToPchar(JNIEnv *env, jstring jstr, char *outbuf, int jstrlen)
{
int ret;
char * rtn = NULL;
jclass gStringClass = env->FindClass("java/lang/String");
jmethodID gmidStringGetBytes = env->GetMethodID(gStringClass, "getBytes", "(Ljava/lang/String;)[B");
jstring jencoding = env->NewStringUTF("utf-8");
jbyteArray barr = (jbyteArray)env->CallObjectMethod(jstr, gmidStringGetBytes, jencoding);
jsize alen = env->GetArrayLength(barr);
jbyte * ba = env->GetByteArrayElements(barr, JNI_FALSE);
if (alen > 0) {
if (jstrlen == 0) {
rtn = outbuf;
ret = 0;
} else if (jstrlen < alen) {
ret = -1;
} else {
rtn = outbuf;
memcpy(rtn, ba, alen);
rtn[alen] = 0;
ret = alen;
}
}
env->ReleaseByteArrayElements(barr, ba, 0);
return ret;
}
#ifdef __cplusplus
extern "C" { // 即使这是一个C++程序,下列这个函数的实现也要以C约定的风格来搞!
#endif
#ifdef __cplusplus
}
#endif
//----------------------------------------------------------
// 功能:调用主函数入口
//----------------------------------------------------------
//业务函数
//----------------------------------------------------------
JNIEXPORT jstring JNICALL Java_com_xingdata_zzdpos_zxpay_jsonpay(JNIEnv *env, jclass jcl, jstring jc)
{
int ret;
char * inJson;
char inputStr[BUFSIZ];
char outputStr[BUFSIZ];
size_t outlen;
jint insize;
trans_json_t trans_json;
debuglog("entry: %s\n", "1111111");
//trans_json_t trans_json={"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"};
memset(inputStr, 0x00, sizeof(inputStr));
memset(outputStr, 0x00, sizeof(outputStr));
//memset(&trans_json , 0x00 , sizeof(trans_json_t ) );
memset(trans_json.OrderType, 0x00, sizeof(trans_json.OrderType));
memset(trans_json.PayChannelType, 0x00, sizeof(trans_json.PayChannelType));
memset(trans_json.DeviceType, 0x00, sizeof(trans_json.DeviceType));
memset(trans_json.Mch_id, 0x00, sizeof(trans_json.Mch_id));
memset(trans_json.Ter_id, 0x00, sizeof(trans_json.Ter_id));
memset(trans_json.OrderDateTime, 0x00, sizeof(trans_json.OrderDateTime));
memset(trans_json.CurrencyType, 0x00, sizeof(trans_json.CurrencyType));
memset(trans_json.OrderAmt, 0x00, sizeof(trans_json.OrderAmt));
memset(trans_json.OrderName, 0x00, sizeof(trans_json.OrderName));
memset(trans_json.OrderNo, 0x00, sizeof(trans_json.OrderNo));
memset(trans_json.ChannelAuthCode, 0x00, sizeof(trans_json.ChannelAuthCode));
memset(trans_json.ResponseCode, 0x00, sizeof(trans_json.ResponseCode));
memset(trans_json.ResponseMsg, 0x00, sizeof(trans_json.ResponseMsg));
memset(trans_json.TradeStatus, 0x00, sizeof(trans_json.TradeStatus));
memset(trans_json.OldOrderNo, 0x00, sizeof(trans_json.OldOrderNo));
memset(trans_json.RefundNo, 0x00, sizeof(trans_json.RefundNo));
memset(trans_json.Amount, 0x00, sizeof(trans_json.Amount));
memset(trans_json.tn, 0x00, sizeof(trans_json.tn));
ret = 0;
insize = env->GetStringUTFLength(jc);
ret = jstringToPchar(env, jc, inputStr, insize);
if (ret <= 0) {
sprintf(outputStr, "{\"ResponseCode\":\"0001\",\"ResponseMsg\":\"jstring字符转换失败\",\"TradeStatus\":\"000000\",\"Mch_id\":\"100000000000001\",\"Ter_id\":\"10000001\",\"OrderNo\":\"00000000000000000001\",\"RefundNo\":\"00000000000000000001\",\"amount\":\"000000000000\",\"tn\":\"\"}");
return pcharToJstring(env, outputStr);
}
inJson = inputStr;
// JsonToStruct_trans(inJson, &trans_json);
// usec(&trans_json);
do_trans(inputStr, outputStr, &outlen);
// sprintf(outputStr, "{\"ResponseCode\":\"%s\",\"ResponseMsg\":\"%s\",\"TradeStatus\":\"%s\",\"Mch_id\":\"%s\",\"Ter_id\":\"%s\",\"OrderNo\":\"%s\",\"RefundNo\":\"%s\",\"amount\":\"%s\",\"tn\":\"%s\",\"appId\":\"%s\",\"timeStamp\":\"%s\",\"nonceStr\":\"%s\",\"package\":\"%s\",\"signType\":\"%s\",\"paySign\":\"%s\"}", trans_json.ResponseCode, trans_json.ResponseMsg, trans_json.TradeStatus, trans_json.Mch_id, trans_json.Ter_id, trans_json.OrderNo, trans_json.OldOrderNo, trans_json.Amount, trans_json.tn, trans_json.appId, trans_json.timeStamp, trans_json.nonceStr, trans_json.package, trans_json.signType, trans_json.paySign);
return pcharToJstring(env, outputStr);
}
#include "apue.h"
#include "do_trans.h"
#include <dlfcn.h>
int main()
{
void *dp = dlopen("libjsonpay.so", RTLD_LAZY);
if (dp == NULL) {
fprintf(stderr, "%s\n", dlerror());
return -1;
}
dlerror();
typedef int (*func_t)(const char *, char *, size_t *);
func_t pdf = (func_t)dlsym(dp, "do_trans");
if (pdf == NULL) {
fprintf(stderr, "%s\n", dlerror());
return -1;
}
char buf[BUFSIZ] = {0};
FILE *fp = fopen("/tmp/test.json", "r");
while (!feof(fp)) {
fread(buf + strlen(buf), BUFSIZ - strlen(buf), 1, fp);
}
char out[BUFSIZ]= {0};
size_t l = 0;
do_trans(buf, out, &l);
printf("%s\n", out);
dlclose(dp);
}
./obj/local/arm64-v8a/objs/jsonpay/bcccode.o: jni/bcccode.c \
jni/../include/bcccode.h jni/../include/cJSON.h \
jni/../include/common.h
jni/../include/bcccode.h:
jni/../include/cJSON.h:
jni/../include/common.h:
./obj/local/arm64-v8a/objs/jsonpay/bccmd5.o: jni/bccmd5.c \
jni/../include/bccmd5.h jni/../include/common.h
jni/../include/bccmd5.h:
jni/../include/common.h:
./obj/local/arm64-v8a/objs/jsonpay/cJSON.o: jni/cJSON.c \
jni/../include/cJSON.h
jni/../include/cJSON.h:
./obj/local/arm64-v8a/objs/jsonpay/do_log.o: jni/do_log.c \
jni/../include/do_log.h jni/../include/common.h
jni/../include/do_log.h:
jni/../include/common.h:
./obj/local/arm64-v8a/objs/jsonpay/do_trans.o: jni/do_trans.c \
jni/../include/do_trans.h jni/../include/cJSON.h \
jni/../include/common.h jni/../include/bcccode.h \
jni/../include/do_trans_pax.h jni/../include/do_log.h \
jni/../include/curl/curl.h jni/../include/curl/curlver.h \
jni/../include/curl/system.h jni/../include/curl/easy.h \
jni/../include/curl/multi.h jni/../include/http.h
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/do_trans_pax.h:
jni/../include/do_log.h:
jni/../include/curl/curl.h:
jni/../include/curl/curlver.h:
jni/../include/curl/system.h:
jni/../include/curl/easy.h:
jni/../include/curl/multi.h:
jni/../include/http.h:
./obj/local/arm64-v8a/objs/jsonpay/do_trans_pax.o: jni/do_trans_pax.c \
jni/../include/do_trans_pax.h jni/../include/do_trans.h \
jni/../include/cJSON.h jni/../include/common.h \
jni/../include/bcccode.h jni/../include/bccmd5.h \
jni/../include/do_log.h
jni/../include/do_trans_pax.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/bccmd5.h:
jni/../include/do_log.h:
./obj/local/arm64-v8a/objs/jsonpay/http.o: jni/http.c \
jni/../include/http.h jni/../include/common.h jni/../include/do_log.h
jni/../include/http.h:
jni/../include/common.h:
jni/../include/do_log.h:
./obj/local/arm64-v8a/objs/jsonpay/native-lib.o: jni/native-lib.cpp \
jni/../include/jni.h jni/../include/jni_md.h \
jni/../include/native-lib.h jni/../include/com_xingdata_zzdpos_zxpay.h \
jni/../include/do_log.h jni/../include/common.h \
jni/../include/do_trans.h jni/../include/cJSON.h
jni/../include/jni.h:
jni/../include/jni_md.h:
jni/../include/native-lib.h:
jni/../include/com_xingdata_zzdpos_zxpay.h:
jni/../include/do_log.h:
jni/../include/common.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
./obj/local/armeabi-v7a/objs/jsonpay/bcccode.o: jni/bcccode.c \
jni/../include/bcccode.h jni/../include/cJSON.h \
jni/../include/common.h
jni/../include/bcccode.h:
jni/../include/cJSON.h:
jni/../include/common.h:
./obj/local/armeabi-v7a/objs/jsonpay/bccmd5.o: jni/bccmd5.c \
jni/../include/bccmd5.h jni/../include/common.h
jni/../include/bccmd5.h:
jni/../include/common.h:
./obj/local/armeabi-v7a/objs/jsonpay/cJSON.o: jni/cJSON.c \
jni/../include/cJSON.h
jni/../include/cJSON.h:
./obj/local/armeabi-v7a/objs/jsonpay/do_log.o: jni/do_log.c \
jni/../include/do_log.h jni/../include/common.h
jni/../include/do_log.h:
jni/../include/common.h:
./obj/local/armeabi-v7a/objs/jsonpay/do_trans.o: jni/do_trans.c \
jni/../include/do_trans.h jni/../include/cJSON.h \
jni/../include/common.h jni/../include/bcccode.h \
jni/../include/do_trans_pax.h jni/../include/do_log.h \
jni/../include/curl/curl.h jni/../include/curl/curlver.h \
jni/../include/curl/system.h jni/../include/curl/easy.h \
jni/../include/curl/multi.h jni/../include/http.h
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/do_trans_pax.h:
jni/../include/do_log.h:
jni/../include/curl/curl.h:
jni/../include/curl/curlver.h:
jni/../include/curl/system.h:
jni/../include/curl/easy.h:
jni/../include/curl/multi.h:
jni/../include/http.h:
./obj/local/armeabi-v7a/objs/jsonpay/do_trans_pax.o: jni/do_trans_pax.c \
jni/../include/do_trans_pax.h jni/../include/do_trans.h \
jni/../include/cJSON.h jni/../include/common.h \
jni/../include/bcccode.h jni/../include/bccmd5.h \
jni/../include/do_log.h
jni/../include/do_trans_pax.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/bccmd5.h:
jni/../include/do_log.h:
./obj/local/armeabi-v7a/objs/jsonpay/http.o: jni/http.c \
jni/../include/http.h jni/../include/common.h jni/../include/do_log.h
jni/../include/http.h:
jni/../include/common.h:
jni/../include/do_log.h:
./obj/local/armeabi-v7a/objs/jsonpay/native-lib.o: jni/native-lib.cpp \
jni/../include/jni.h jni/../include/jni_md.h \
jni/../include/native-lib.h jni/../include/com_xingdata_zzdpos_zxpay.h \
jni/../include/do_log.h jni/../include/common.h \
jni/../include/do_trans.h jni/../include/cJSON.h
jni/../include/jni.h:
jni/../include/jni_md.h:
jni/../include/native-lib.h:
jni/../include/com_xingdata_zzdpos_zxpay.h:
jni/../include/do_log.h:
jni/../include/common.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
./obj/local/armeabi/objs/jsonpay/bcccode.o: jni/bcccode.c \
jni/../include/bcccode.h jni/../include/cJSON.h \
jni/../include/common.h
jni/../include/bcccode.h:
jni/../include/cJSON.h:
jni/../include/common.h:
./obj/local/armeabi/objs/jsonpay/bccmd5.o: jni/bccmd5.c \
jni/../include/bccmd5.h jni/../include/common.h
jni/../include/bccmd5.h:
jni/../include/common.h:
./obj/local/armeabi/objs/jsonpay/cJSON.o: jni/cJSON.c \
jni/../include/cJSON.h
jni/../include/cJSON.h:
./obj/local/armeabi/objs/jsonpay/do_log.o: jni/do_log.c \
jni/../include/do_log.h jni/../include/common.h
jni/../include/do_log.h:
jni/../include/common.h:
./obj/local/armeabi/objs/jsonpay/do_trans.o: jni/do_trans.c \
jni/../include/do_trans.h jni/../include/cJSON.h \
jni/../include/common.h jni/../include/bcccode.h \
jni/../include/do_trans_pax.h jni/../include/do_log.h \
jni/../include/curl/curl.h jni/../include/curl/curlver.h \
jni/../include/curl/system.h jni/../include/curl/easy.h \
jni/../include/curl/multi.h jni/../include/http.h
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/do_trans_pax.h:
jni/../include/do_log.h:
jni/../include/curl/curl.h:
jni/../include/curl/curlver.h:
jni/../include/curl/system.h:
jni/../include/curl/easy.h:
jni/../include/curl/multi.h:
jni/../include/http.h:
./obj/local/armeabi/objs/jsonpay/do_trans_pax.o: jni/do_trans_pax.c \
jni/../include/do_trans_pax.h jni/../include/do_trans.h \
jni/../include/cJSON.h jni/../include/common.h \
jni/../include/bcccode.h jni/../include/bccmd5.h \
jni/../include/do_log.h
jni/../include/do_trans_pax.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/bccmd5.h:
jni/../include/do_log.h:
./obj/local/armeabi/objs/jsonpay/http.o: jni/http.c jni/../include/http.h \
jni/../include/common.h jni/../include/do_log.h
jni/../include/http.h:
jni/../include/common.h:
jni/../include/do_log.h:
./obj/local/armeabi/objs/jsonpay/native-lib.o: jni/native-lib.cpp \
jni/../include/jni.h jni/../include/jni_md.h \
jni/../include/native-lib.h jni/../include/com_xingdata_zzdpos_zxpay.h \
jni/../include/do_log.h jni/../include/common.h \
jni/../include/do_trans.h jni/../include/cJSON.h
jni/../include/jni.h:
jni/../include/jni_md.h:
jni/../include/native-lib.h:
jni/../include/com_xingdata_zzdpos_zxpay.h:
jni/../include/do_log.h:
jni/../include/common.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
./obj/local/mips/objs/jsonpay/bcccode.o: jni/bcccode.c \
jni/../include/bcccode.h jni/../include/cJSON.h \
jni/../include/common.h
jni/../include/bcccode.h:
jni/../include/cJSON.h:
jni/../include/common.h:
./obj/local/mips/objs/jsonpay/bccmd5.o: jni/bccmd5.c \
jni/../include/bccmd5.h jni/../include/common.h
jni/../include/bccmd5.h:
jni/../include/common.h:
./obj/local/mips/objs/jsonpay/cJSON.o: jni/cJSON.c jni/../include/cJSON.h
jni/../include/cJSON.h:
./obj/local/mips/objs/jsonpay/do_log.o: jni/do_log.c \
jni/../include/do_log.h jni/../include/common.h
jni/../include/do_log.h:
jni/../include/common.h:
./obj/local/mips/objs/jsonpay/do_trans.o: jni/do_trans.c \
jni/../include/do_trans.h jni/../include/cJSON.h \
jni/../include/common.h jni/../include/bcccode.h \
jni/../include/do_trans_pax.h jni/../include/do_log.h \
jni/../include/curl/curl.h jni/../include/curl/curlver.h \
jni/../include/curl/system.h jni/../include/curl/easy.h \
jni/../include/curl/multi.h jni/../include/http.h
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/do_trans_pax.h:
jni/../include/do_log.h:
jni/../include/curl/curl.h:
jni/../include/curl/curlver.h:
jni/../include/curl/system.h:
jni/../include/curl/easy.h:
jni/../include/curl/multi.h:
jni/../include/http.h:
./obj/local/mips/objs/jsonpay/do_trans_pax.o: jni/do_trans_pax.c \
jni/../include/do_trans_pax.h jni/../include/do_trans.h \
jni/../include/cJSON.h jni/../include/common.h \
jni/../include/bcccode.h jni/../include/bccmd5.h \
jni/../include/do_log.h
jni/../include/do_trans_pax.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/bccmd5.h:
jni/../include/do_log.h:
./obj/local/mips/objs/jsonpay/http.o: jni/http.c jni/../include/http.h \
jni/../include/common.h jni/../include/do_log.h
jni/../include/http.h:
jni/../include/common.h:
jni/../include/do_log.h:
./obj/local/mips/objs/jsonpay/native-lib.o: jni/native-lib.cpp \
jni/../include/jni.h jni/../include/jni_md.h \
jni/../include/native-lib.h jni/../include/com_xingdata_zzdpos_zxpay.h \
jni/../include/do_log.h jni/../include/common.h \
jni/../include/do_trans.h jni/../include/cJSON.h
jni/../include/jni.h:
jni/../include/jni_md.h:
jni/../include/native-lib.h:
jni/../include/com_xingdata_zzdpos_zxpay.h:
jni/../include/do_log.h:
jni/../include/common.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
./obj/local/mips64/objs/jsonpay/bcccode.o: jni/bcccode.c \
jni/../include/bcccode.h jni/../include/cJSON.h \
jni/../include/common.h
jni/../include/bcccode.h:
jni/../include/cJSON.h:
jni/../include/common.h:
./obj/local/mips64/objs/jsonpay/bccmd5.o: jni/bccmd5.c \
jni/../include/bccmd5.h jni/../include/common.h
jni/../include/bccmd5.h:
jni/../include/common.h:
./obj/local/mips64/objs/jsonpay/cJSON.o: jni/cJSON.c \
jni/../include/cJSON.h
jni/../include/cJSON.h:
./obj/local/mips64/objs/jsonpay/do_log.o: jni/do_log.c \
jni/../include/do_log.h jni/../include/common.h
jni/../include/do_log.h:
jni/../include/common.h:
./obj/local/mips64/objs/jsonpay/do_trans.o: jni/do_trans.c \
jni/../include/do_trans.h jni/../include/cJSON.h \
jni/../include/common.h jni/../include/bcccode.h \
jni/../include/do_trans_pax.h jni/../include/do_log.h \
jni/../include/curl/curl.h jni/../include/curl/curlver.h \
jni/../include/curl/system.h jni/../include/curl/easy.h \
jni/../include/curl/multi.h jni/../include/http.h
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/do_trans_pax.h:
jni/../include/do_log.h:
jni/../include/curl/curl.h:
jni/../include/curl/curlver.h:
jni/../include/curl/system.h:
jni/../include/curl/easy.h:
jni/../include/curl/multi.h:
jni/../include/http.h:
./obj/local/mips64/objs/jsonpay/do_trans_pax.o: jni/do_trans_pax.c \
jni/../include/do_trans_pax.h jni/../include/do_trans.h \
jni/../include/cJSON.h jni/../include/common.h \
jni/../include/bcccode.h jni/../include/bccmd5.h \
jni/../include/do_log.h
jni/../include/do_trans_pax.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/bccmd5.h:
jni/../include/do_log.h:
./obj/local/mips64/objs/jsonpay/http.o: jni/http.c jni/../include/http.h \
jni/../include/common.h jni/../include/do_log.h
jni/../include/http.h:
jni/../include/common.h:
jni/../include/do_log.h:
./obj/local/mips64/objs/jsonpay/native-lib.o: jni/native-lib.cpp \
jni/../include/jni.h jni/../include/jni_md.h \
jni/../include/native-lib.h jni/../include/com_xingdata_zzdpos_zxpay.h \
jni/../include/do_log.h jni/../include/common.h \
jni/../include/do_trans.h jni/../include/cJSON.h
jni/../include/jni.h:
jni/../include/jni_md.h:
jni/../include/native-lib.h:
jni/../include/com_xingdata_zzdpos_zxpay.h:
jni/../include/do_log.h:
jni/../include/common.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
./obj/local/x86/objs/jsonpay/bcccode.o: jni/bcccode.c \
jni/../include/bcccode.h jni/../include/cJSON.h \
jni/../include/common.h
jni/../include/bcccode.h:
jni/../include/cJSON.h:
jni/../include/common.h:
./obj/local/x86/objs/jsonpay/bccmd5.o: jni/bccmd5.c \
jni/../include/bccmd5.h jni/../include/common.h
jni/../include/bccmd5.h:
jni/../include/common.h:
./obj/local/x86/objs/jsonpay/cJSON.o: jni/cJSON.c jni/../include/cJSON.h
jni/../include/cJSON.h:
./obj/local/x86/objs/jsonpay/do_log.o: jni/do_log.c \
jni/../include/do_log.h jni/../include/common.h
jni/../include/do_log.h:
jni/../include/common.h:
./obj/local/x86/objs/jsonpay/do_trans.o: jni/do_trans.c \
jni/../include/do_trans.h jni/../include/cJSON.h \
jni/../include/common.h jni/../include/bcccode.h \
jni/../include/do_trans_pax.h jni/../include/do_log.h \
jni/../include/curl/curl.h jni/../include/curl/curlver.h \
jni/../include/curl/system.h jni/../include/curl/easy.h \
jni/../include/curl/multi.h jni/../include/http.h
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/do_trans_pax.h:
jni/../include/do_log.h:
jni/../include/curl/curl.h:
jni/../include/curl/curlver.h:
jni/../include/curl/system.h:
jni/../include/curl/easy.h:
jni/../include/curl/multi.h:
jni/../include/http.h:
./obj/local/x86/objs/jsonpay/do_trans_pax.o: jni/do_trans_pax.c \
jni/../include/do_trans_pax.h jni/../include/do_trans.h \
jni/../include/cJSON.h jni/../include/common.h \
jni/../include/bcccode.h jni/../include/bccmd5.h \
jni/../include/do_log.h
jni/../include/do_trans_pax.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/bccmd5.h:
jni/../include/do_log.h:
./obj/local/x86/objs/jsonpay/http.o: jni/http.c jni/../include/http.h \
jni/../include/common.h jni/../include/do_log.h
jni/../include/http.h:
jni/../include/common.h:
jni/../include/do_log.h:
./obj/local/x86/objs/jsonpay/native-lib.o: jni/native-lib.cpp \
jni/../include/jni.h jni/../include/jni_md.h \
jni/../include/native-lib.h jni/../include/com_xingdata_zzdpos_zxpay.h \
jni/../include/do_log.h jni/../include/common.h \
jni/../include/do_trans.h jni/../include/cJSON.h
jni/../include/jni.h:
jni/../include/jni_md.h:
jni/../include/native-lib.h:
jni/../include/com_xingdata_zzdpos_zxpay.h:
jni/../include/do_log.h:
jni/../include/common.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
./obj/local/x86_64/objs/jsonpay/bcccode.o: jni/bcccode.c \
jni/../include/bcccode.h jni/../include/cJSON.h \
jni/../include/common.h
jni/../include/bcccode.h:
jni/../include/cJSON.h:
jni/../include/common.h:
./obj/local/x86_64/objs/jsonpay/bccmd5.o: jni/bccmd5.c \
jni/../include/bccmd5.h jni/../include/common.h
jni/../include/bccmd5.h:
jni/../include/common.h:
./obj/local/x86_64/objs/jsonpay/cJSON.o: jni/cJSON.c \
jni/../include/cJSON.h
jni/../include/cJSON.h:
./obj/local/x86_64/objs/jsonpay/do_log.o: jni/do_log.c \
jni/../include/do_log.h jni/../include/common.h
jni/../include/do_log.h:
jni/../include/common.h:
./obj/local/x86_64/objs/jsonpay/do_trans.o: jni/do_trans.c \
jni/../include/do_trans.h jni/../include/cJSON.h \
jni/../include/common.h jni/../include/bcccode.h \
jni/../include/do_trans_pax.h jni/../include/do_log.h \
jni/../include/curl/curl.h jni/../include/curl/curlver.h \
jni/../include/curl/system.h jni/../include/curl/easy.h \
jni/../include/curl/multi.h jni/../include/http.h
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/do_trans_pax.h:
jni/../include/do_log.h:
jni/../include/curl/curl.h:
jni/../include/curl/curlver.h:
jni/../include/curl/system.h:
jni/../include/curl/easy.h:
jni/../include/curl/multi.h:
jni/../include/http.h:
./obj/local/x86_64/objs/jsonpay/do_trans_pax.o: jni/do_trans_pax.c \
jni/../include/do_trans_pax.h jni/../include/do_trans.h \
jni/../include/cJSON.h jni/../include/common.h \
jni/../include/bcccode.h jni/../include/bccmd5.h \
jni/../include/do_log.h
jni/../include/do_trans_pax.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
jni/../include/common.h:
jni/../include/bcccode.h:
jni/../include/bccmd5.h:
jni/../include/do_log.h:
./obj/local/x86_64/objs/jsonpay/http.o: jni/http.c jni/../include/http.h \
jni/../include/common.h jni/../include/do_log.h
jni/../include/http.h:
jni/../include/common.h:
jni/../include/do_log.h:
./obj/local/x86_64/objs/jsonpay/native-lib.o: jni/native-lib.cpp \
jni/../include/jni.h jni/../include/jni_md.h \
jni/../include/native-lib.h jni/../include/com_xingdata_zzdpos_zxpay.h \
jni/../include/do_log.h jni/../include/common.h \
jni/../include/do_trans.h jni/../include/cJSON.h
jni/../include/jni.h:
jni/../include/jni_md.h:
jni/../include/native-lib.h:
jni/../include/com_xingdata_zzdpos_zxpay.h:
jni/../include/do_log.h:
jni/../include/common.h:
jni/../include/do_trans.h:
jni/../include/cJSON.h:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
<resources>
<string name="app_name">zxpay</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
package com.xingdata.zxpay;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Thu Jan 18 21:07:24 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
include ':app'
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