mirror of
https://github.com/corda/corda.git
synced 2025-04-24 21:09:50 +00:00
Merged in aslemmer-sgx (pull request #22)
SGX work Approved-by: Chris Rankin <chris.rankin@r3.com>
This commit is contained in:
commit
08518cd5e0
8
.gitignore
vendored
8
.gitignore
vendored
@ -85,4 +85,10 @@ node/config/currentView
|
||||
# Files you may find useful to have in your working directory.
|
||||
PLAN
|
||||
NOTES
|
||||
TODO
|
||||
TODO
|
||||
|
||||
# SGX
|
||||
/sgx-jvm/jdk8u/
|
||||
/sgx-jvm/avian/
|
||||
/sgx-jvm/linux-sgx/
|
||||
/sgx-jvm/jvm-enclave/proguard.jar
|
@ -5,6 +5,7 @@ import net.corda.core.contracts.CommandData
|
||||
import net.corda.core.contracts.ContractState
|
||||
import net.corda.core.contracts.TransactionForContract
|
||||
import net.corda.core.utilities.loggerFor
|
||||
import org.slf4j.Logger
|
||||
|
||||
/**
|
||||
* A clause of a contract, containing a chunk of verification logic. That logic may be delegated to other clauses, or
|
||||
@ -18,7 +19,7 @@ import net.corda.core.utilities.loggerFor
|
||||
*/
|
||||
abstract class Clause<in S : ContractState, C : CommandData, in K : Any> {
|
||||
companion object {
|
||||
val log = loggerFor<Clause<*, *, *>>()
|
||||
val log: Logger by lazy { loggerFor<Clause<*, *, *>>() }
|
||||
}
|
||||
|
||||
/** Determine whether this clause runs or not */
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.corda.core.crypto
|
||||
|
||||
import net.corda.core.utilities.SgxSupport
|
||||
import java.security.*
|
||||
|
||||
/**
|
||||
@ -89,6 +90,36 @@ fun safeRandomBytes(numOfBytes: Int): ByteArray {
|
||||
return newSecureRandom().generateSeed(numOfBytes)
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a hack added because during deserialisation when no-param constructors are called sometimes default values
|
||||
* generate random numbers, which fail in SGX.
|
||||
* TODO remove this once deserialisation is figured out.
|
||||
*/
|
||||
private class DummySecureRandomSpi : SecureRandomSpi() {
|
||||
override fun engineSetSeed(bytes: ByteArray?) {
|
||||
Exception("DummySecureRandomSpi.engineSetSeed called").printStackTrace(System.out)
|
||||
}
|
||||
|
||||
override fun engineNextBytes(bytes: ByteArray?) {
|
||||
Exception("DummySecureRandomSpi.engineNextBytes called").printStackTrace(System.out)
|
||||
bytes?.fill(0)
|
||||
}
|
||||
|
||||
override fun engineGenerateSeed(numberOfBytes: Int): ByteArray {
|
||||
Exception("DummySecureRandomSpi.engineGenerateSeed called").printStackTrace(System.out)
|
||||
return ByteArray(numberOfBytes)
|
||||
}
|
||||
}
|
||||
object DummySecureRandom : SecureRandom(DummySecureRandomSpi(), null)
|
||||
|
||||
private val _newSecureRandom: () -> SecureRandom by lazy {
|
||||
when {
|
||||
SgxSupport.isInsideEnclave -> { { DummySecureRandom } }
|
||||
System.getProperty("os.name") == "Linux" -> { { SecureRandom.getInstance("NativePRNGNonBlocking") } }
|
||||
else -> { { SecureRandom.getInstanceStrong() } }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of [SecureRandom] to avoid blocking, due to waiting for additional entropy, when possible.
|
||||
* In this version, the NativePRNGNonBlocking is exclusively used on Linux OS to utilize dev/urandom because in high traffic
|
||||
@ -108,10 +139,4 @@ fun safeRandomBytes(numOfBytes: Int): ByteArray {
|
||||
* which should never happen and suggests an unusual JVM or non-standard Java library.
|
||||
*/
|
||||
@Throws(NoSuchAlgorithmException::class)
|
||||
fun newSecureRandom(): SecureRandom {
|
||||
if (System.getProperty("os.name") == "Linux") {
|
||||
return SecureRandom.getInstance("NativePRNGNonBlocking")
|
||||
} else {
|
||||
return SecureRandom.getInstanceStrong()
|
||||
}
|
||||
}
|
||||
fun newSecureRandom() = _newSecureRandom()
|
||||
|
@ -26,10 +26,6 @@ fun makeNoWhitelistClassResolver(): ClassResolver {
|
||||
}
|
||||
|
||||
class CordaClassResolver(val whitelist: ClassWhitelist) : DefaultClassResolver() {
|
||||
companion object {
|
||||
private val logger = loggerFor<CordaClassResolver>()
|
||||
}
|
||||
|
||||
/** Returns the registration for the specified class, or null if the class is not registered. */
|
||||
override fun getRegistration(type: Class<*>): Registration? {
|
||||
return super.getRegistration(type) ?: checkClass(type)
|
||||
|
@ -12,6 +12,7 @@ import net.corda.core.crypto.*
|
||||
import net.corda.core.node.AttachmentsClassLoader
|
||||
import net.corda.core.node.services.AttachmentStorage
|
||||
import net.corda.core.transactions.WireTransaction
|
||||
import net.corda.core.utilities.SgxSupport
|
||||
import net.i2p.crypto.eddsa.EdDSAPrivateKey
|
||||
import net.i2p.crypto.eddsa.EdDSAPublicKey
|
||||
import net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec
|
||||
@ -148,13 +149,16 @@ fun <T : Any> T.serialize(kryo: Kryo, internalOnly: Boolean = false): Serialized
|
||||
* set via the constructor and the class is immutable.
|
||||
*/
|
||||
class ImmutableClassSerializer<T : Any>(val klass: KClass<T>) : Serializer<T>() {
|
||||
val props = klass.memberProperties.sortedBy { it.name }
|
||||
val propsByName = props.associateBy { it.name }
|
||||
val constructor = klass.primaryConstructor!!
|
||||
val props by lazy { klass.memberProperties.sortedBy { it.name } }
|
||||
val propsByName by lazy { props.associateBy { it.name } }
|
||||
val constructor by lazy { klass.primaryConstructor!! }
|
||||
|
||||
init {
|
||||
// Verify that this class is immutable (all properties are final)
|
||||
assert(props.none { it is KMutableProperty<*> })
|
||||
// Verify that this class is immutable (all properties are final).
|
||||
// We disable this check inside SGX as the reflection blows up.
|
||||
if (!SgxSupport.isInsideEnclave) {
|
||||
assert(props.none { it is KMutableProperty<*> })
|
||||
}
|
||||
}
|
||||
|
||||
// Just a utility to help us catch cases where nodes are running out of sync versions.
|
||||
|
@ -0,0 +1,7 @@
|
||||
package net.corda.core.utilities
|
||||
|
||||
object SgxSupport {
|
||||
val isInsideEnclave: Boolean by lazy {
|
||||
System.getProperty("os.name") == "Linux" && (System.getProperty("java.vm.name") == "Avian")
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import net.corda.core.schemas.MappedSchema
|
||||
import net.corda.core.schemas.PersistentState
|
||||
import net.corda.core.schemas.QueryableState
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.serialization.OpaqueBytes
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.utilities.Emoji
|
||||
import net.corda.schemas.CashSchemaV1
|
||||
|
@ -30,3 +30,4 @@ include 'samples:simm-valuation-demo'
|
||||
include 'samples:raft-notary-demo'
|
||||
include 'samples:bank-of-corda-demo'
|
||||
include 'doorman'
|
||||
include 'verify-enclave'
|
||||
|
46
sgx-jvm/Makefile
Normal file
46
sgx-jvm/Makefile
Normal file
@ -0,0 +1,46 @@
|
||||
MAKEFILE_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
ROOT=$(MAKEFILE_DIR)/dependencies/root
|
||||
SHELL=/bin/bash
|
||||
# JAVA_HOME=$(ROOT)/usr/lib/jvm/java-8-openjdk-amd64
|
||||
|
||||
.PHONY: all
|
||||
all: jvm-enclave/standalone/build/standalone_sgx_verify
|
||||
|
||||
# The final binary
|
||||
jvm-enclave/standalone/build/standalone_sgx_verify: avian linux-sgx/build/linux/aesm_service
|
||||
JAVA_HOME=$(JAVA_HOME) $(MAKE) -C jvm-enclave
|
||||
|
||||
# Avian with SGX support
|
||||
AVIAN_EXTRA_CFLAGS="-I$(ROOT)/usr/include -I$(ROOT)/usr/include/x86_64-linux-gnu"
|
||||
AVIAN_EXTRA_LDFLAGS="-L$(ROOT)/usr/lib -L$(ROOT)/usr/lib/x86_64-linux-gnu -ldl -lpthread -lz"
|
||||
.PHONY: avian
|
||||
avian: | jdk8u/hotspot
|
||||
PATH=$(ROOT)/usr/bin:$(PATH) $(MAKE) -C avian build-lflags=$(AVIAN_EXTRA_LDFLAGS) extra-lflags=$(AVIAN_EXTRA_LDFLAGS) extra-build-cflags+=$(AVIAN_EXTRA_CFLAGS) extra-cflags+=$(AVIAN_EXTRA_CFLAGS) mode=debug openjdk=$(JAVA_HOME) openjdk-src=../jdk8u/jdk/src system=sgx
|
||||
|
||||
# The SGX SDK
|
||||
LINUX_SGX_SOURCES=$(shell find linux-sgx \( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.edl' \) ! \( -name '*_u.?' -o -name '*_t.?' -o -name '*.pb.h' -o -path 'linux-sgx/sdk/cpprt/linux/libunwind/*' -o -path 'linux-sgx/external/rdrand/src/config.h' \)) # Poor man's up-to-date check (they don't have one in the SDK??)
|
||||
linux-sgx/build/linux/aesm_service: $(LINUX_SGX_SOURCES) linux-sgx/external/ippcp_internal/inc
|
||||
LD_LIBRARY_PATH=$(ROOT)/usr/lib/x86_64-linux-gnu:$(ROOT)/lib/x86_64-linux-gnu LIBRARY_PATH=$(ROOT)/usr/lib/x86_64-linux-gnu PATH=$(ROOT)/usr/bin:$(PATH) ACLOCAL_PATH=$(ROOT)/usr/share/aclocal $(MAKE) -C linux-sgx EXTRA_CXXFLAGS+="-isystem $(ROOT)/usr/include -isystem $(ROOT)/usr/include/x86_64-linux-gnu -L$(ROOT)/usr/lib/x86_64-linux-gnu" DEBUG=1
|
||||
|
||||
jdk8u:
|
||||
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u
|
||||
|
||||
jdk8u/hotspot: | jdk8u
|
||||
cd jdk8u && $(SHELL) ./get_source.sh
|
||||
|
||||
linux-sgx/external/ippcp_internal/inc:
|
||||
cd linux-sgx && $(SHELL) ./download_prebuilt.sh
|
||||
|
||||
build:
|
||||
mkdir -p $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(MAKE) -C jvm-enclave clean
|
||||
$(MAKE) -C linux-sgx clean
|
||||
$(MAKE) -C avian clean
|
||||
|
||||
.PHONY: distclean
|
||||
distclean: clean
|
||||
rm -rf jdk8u
|
||||
rm -rf linux-sgx/external/{ippcp_internal,libirc,libm}
|
88
sgx-jvm/README.md
Normal file
88
sgx-jvm/README.md
Normal file
@ -0,0 +1,88 @@
|
||||
The build
|
||||
=========
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
* Install mercurial, gcc/g++, autoconf, automake, libtool, ocaml, protobuf, libprotobuf, libcurl, libopenssl, cmake, zlib headers, libunwind headers, libcurl headers, libprotobuf headers
|
||||
* Install proguard and symlink the proguard.jar by `ln -s <LOCATION OF proguard.jar> sgx-jvm/jvm-enclave/proguard.jar`
|
||||
* If your hardware supports SGX and you want to use it directly you need to install and load the sgx kernel module (verify by running `lsmod | grep isgx`) and have the sgx service running (on a systemd setup verify by running `systemctl status aesmd`). Note that this is only required for actually running the binary, the build should work fine without.
|
||||
* The SGX SDK has a simulation mode that doesn't require hardware support. To use this edit `sgx-jvm/jvm-enclave/CMakeLists.txt` and change `set(SGX_USE_HARDWARE TRUE)` to `FALSE`
|
||||
|
||||
Troubles with libprotobuf
|
||||
-------------------------
|
||||
|
||||
Unless your distro is very old you will possibly encounter protobuf linker errors when building the SGX SDK. The current version assumes libprotobuf.so.8. If your distro supports downgrades try that, the library version of 2.5.0-4 should work. We may have to include the .so in the repo, or potentially create a pre-setup docker image or something to avoid all this fuss.
|
||||
|
||||
Toplevel Makefile targets
|
||||
-------------------------
|
||||
|
||||
* `make` will download all other dependencies and build the sgx\_experiments binary, residing at `sgx-jvm/jvm-enclave/build/sgx\_experiments`.
|
||||
* `make clean` will clean all build targets.
|
||||
* `make distclean` will clean all build targets and downloaded dependencies. Ordinarily you shouldn't need to run this.
|
||||
|
||||
Each project has its own build that may be run individually (check the toplevel Makefile to see how to invoke these)
|
||||
|
||||
At this point I suggest running `make` before reading further, it takes a while to download all dependencies.
|
||||
|
||||
Some reading
|
||||
============
|
||||
|
||||
Before delving into the code it's strongly recommended to read up on SGX. Some links:
|
||||
|
||||
* Short high-level paper on the attestation design: https://software.intel.com/sites/default/files/article/413939/hasp-2013-innovative-technology-for-attestation-and-sealing.pdf
|
||||
* Medium length description of an example attestation protocol: https://software.intel.com/en-us/articles/intel-software-guard-extensions-remote-attestation-end-to-end-example
|
||||
* Lengthy programmer's reference including description of SGX specific instructions: https://software.intel.com/sites/default/files/managed/48/88/329298-002.pdf
|
||||
* Lengthy low-level paper disecting the SGX design, going into hardware details: https://eprint.iacr.org/2016/086.pdf
|
||||
* Lengthy SDK reference: https://download.01.org/intel-sgx/linux-1.7/docs/Intel_SGX_SDK_Developer_Reference_Linux_1.7_Open_Source.pdf
|
||||
|
||||
|
||||
Corda SGX
|
||||
=========
|
||||
|
||||
The high level goal of the SGX work in Corda is to provide a secure way of verifying transactions. In order to do this we need to be able to run a JVM inside an enclave capable of running contract code. The design decision that contract verification code is without side-effects is imperative here.
|
||||
|
||||
The dream is to have a functioning JVM running inside SGX with as few limitations as possible. Clients would then be able to connect to the enclave, the TCB would attest that it is running the JVM image on secure hardware, after which the client can safely submit signed JARs for execution.
|
||||
|
||||
Corda would then be able to use this to submit contract code and transactions to run the contract code on.
|
||||
|
||||
This is the first iteration of the work, with a lot of limitations. The current JVM is based on Avian which can produce a standalone statically linked binary. The build statically links the enclavelet JAR into the static enclave binary (`sgx-jvm/jvm-enclave/build/enclave/cordaenclave.so`) which is then loaded and run by `jvm/jvm-enclave/build/sgx\_experiments`.
|
||||
|
||||
Breakdown of the build
|
||||
======================
|
||||
|
||||
The current SGX work in Corda is based on 4 semi-distinct projects:
|
||||
|
||||
* The Avian JVM (in the `sgx-jvm/avian` subtree. Note this is our own fork)
|
||||
* The SGX linux sdk (in the `sgx-jvm/linux-sgx` subtree. Note this is our own fork)
|
||||
* The JVM enclave code itself, residing in `sgx-jvm/jvm-enclave`. This includes the untrusted and trusted part of the SGXified JVM, mostly C++.
|
||||
* Finally the Corda enclavelet. This is the JAR that will be loaded and run inside the enclave. (built by `./gradlew verify-enclave:jar`
|
||||
|
||||
Avian
|
||||
-----
|
||||
|
||||
Avian has a code layout perfectly suited for SGX hacking. Each target platform (originally `posix` or `windows`) needs to implement a fairly straight-forward `System` interface providing OS-specific functionality like threading/synchronisation/memory/filesystem primitives. Check `sgx-jvm/avian/src/system` for code. We use this to implement an SGX "platform", which is basically a stripped down OS environment. Some additional #ifndef-ing was needed to strip some non-os-specific avian functionality that assumed the existence of a filesystem or networking. This work is maintained in a private fork, it is instructive to read through the diff, see https://bitbucket.org/R3-CEV/avian-sgx/.
|
||||
|
||||
SGX SDK
|
||||
-------
|
||||
|
||||
There are some modifications in the upstream SGX SDK that we require to run the JVM. An example would be the ability to make the heap executable for JIT compilation, or exposing hooks into malloc to detect OOM conditions. All of these should be mergeable, but we maintain a fork to speed up development on our side.
|
||||
|
||||
Corda Enclavelet
|
||||
----------------
|
||||
|
||||
This is the JAR that will be run inside the enclave. Check `verify-enclave/src/../Enclavelet.kt` for the code.
|
||||
|
||||
Currently the JAR is not loaded at runtime, but is rather embedded statically into the enclave itself using Avian's binaryToObject utility. This basically does an objcopy and lets the linker do the embedding later. This will later be changed to dynamic loading of signed JARs.
|
||||
|
||||
The JVM enclave
|
||||
---------------
|
||||
|
||||
This consists of two parts: the untrusted code that loads the enclave and provides the OCALLs (see `sgx-jvm/jvm-enclave/main.cpp`), and the trusted enclave that constructs the JVM using JNI and runs the enclavelet class. (see `sgx-jvm/jvm-enclave/enclave/enclave.cpp`).
|
||||
|
||||
Dynamic loading, linkage
|
||||
------------------------
|
||||
|
||||
Avian by default loads some JVM specific code dynamically, and looks up these symbols at runtime. We link these symbols statically and provide a simple binary search lookup at runtime to find the symbols corresponding to symbol name strings. To see how this is done check `sgx-jvm/jvm-enclave/enclave/gen_dispatch_table.py`.
|
||||
|
||||
Avian also statically links against system libraries providing usual OS functionality. We deal with this by stubbing all of the undefined symbols and implementing/mocking them as needed. The stub generation simply greps for undefined symbols when running make, check `sgx-jvm/jvm-enclave/enclave/gen-stubsyms.sh` for this. The implemented/mocked OS functions reside in `sgx-jvm/jvm-enclave/enclave/os_support.cpp`
|
@ -491,7 +491,7 @@ ifneq (,$(filter i386 x86_64,$(arch)))
|
||||
endif
|
||||
|
||||
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
|
||||
"-I$(JAVA_HOME)/include/linux" -I$(src) -pthread
|
||||
"-I$(JAVA_HOME)/include/linux" $(extra-build-cflags) -I$(src) -pthread
|
||||
|
||||
converter-cflags = -D__STDC_CONSTANT_MACROS -std=c++0x -Iinclude/ -Isrc/ \
|
||||
-fno-rtti -fno-exceptions \
|
||||
|
29
sgx-jvm/dependencies/README.md
Normal file
29
sgx-jvm/dependencies/README.md
Normal file
@ -0,0 +1,29 @@
|
||||
SGX build dependencies
|
||||
===
|
||||
|
||||
The aim of this folder is to pin some build dependencies of the SGX work that would otherwise cause reproducibility problems.
|
||||
|
||||
Normally you shouldn't care about this folder, everything should work as long as you use the Makefile in the parent folder.
|
||||
|
||||
The pinned dependencies reside in `root/`.
|
||||
|
||||
If dependencies need to be changed/upgraded
|
||||
---
|
||||
|
||||
There are two dockerfiles, one in `docker-full` specifying all build dependencies, and one in `docker-minimal`, specifying the minimal system we assume developers have.
|
||||
|
||||
Once we build `docker-full` we can extract the relevant parts of the filesystem using `extract_dependencies.sh`:
|
||||
|
||||
```bash
|
||||
$ docker build -t full docker-full # builds a Docker image using docker-full/
|
||||
$ bash extract_dependencies.sh full # Extracts some of the filesystem in the `full` image using the list in `extracted_files` into `root/`
|
||||
```
|
||||
|
||||
The SGX build is setup so it refers to the `root/` folder instead of using files coming from system packages.
|
||||
|
||||
Some dependencies are still required to be installed, these are specified in `docker-minimal`. We can use `build_in_docker.sh` to test whether the build works in a minimal dev environment:
|
||||
|
||||
```bash
|
||||
$ docker build -t minimal docker-minimal # builds a Docker image using docker-minimal/
|
||||
$ bash build_in_image.sh minimal # Runs the build inside the `minimal` image
|
||||
```
|
12
sgx-jvm/dependencies/build_in_image.sh
Normal file
12
sgx-jvm/dependencies/build_in_image.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: build_in_image.sh <DOCKER_IMAGE>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGE=$1
|
||||
DOCKER_BUILD_DIR=/tmp/corda-sgx-build
|
||||
|
||||
exec docker run -v $PWD/../..:$DOCKER_BUILD_DIR $IMAGE make -C $DOCKER_BUILD_DIR/sgx-jvm
|
13
sgx-jvm/dependencies/docker-full/Dockerfile
Normal file
13
sgx-jvm/dependencies/docker-full/Dockerfile
Normal file
@ -0,0 +1,13 @@
|
||||
FROM ubuntu:xenial
|
||||
|
||||
RUN apt-get -y update
|
||||
RUN apt-get install -y software-properties-common
|
||||
RUN add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty main restricted"
|
||||
RUN add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty universe"
|
||||
RUN apt-get -y update
|
||||
|
||||
RUN apt-get install -y gcc libprotobuf8 ocaml autoconf libcurl3 openssl cmake libunwind8 proguard g++ zlib1g-dev openjdk-8-jdk patch libtool libunwind8 python2.7 libcurl4-openssl-dev libssl-dev
|
||||
RUN apt-get install -y -t trusty protobuf-compiler libprotobuf-dev
|
||||
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
|
||||
# We re-link libcrypto as it's a global path by default
|
||||
RUN ln -fs ../../../lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/x86_64-linux-gnu/libcrypto.so
|
5
sgx-jvm/dependencies/docker-minimal/Dockerfile
Normal file
5
sgx-jvm/dependencies/docker-minimal/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
||||
FROM ubuntu:xenial
|
||||
|
||||
RUN apt-get update -y
|
||||
RUN apt-get install -y make gcc autoconf cmake g++ openjdk-8-jdk libtool ocaml python2.7
|
||||
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
|
16
sgx-jvm/dependencies/extract_dependencies.sh
Normal file
16
sgx-jvm/dependencies/extract_dependencies.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: extract_dependencies.sh <DOCKER_IMAGE>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGE=$1
|
||||
FILES=$(<extracted_files)
|
||||
HOST_ROOT=$PWD/root
|
||||
|
||||
rm -rf $HOST_ROOT
|
||||
mkdir -p $HOST_ROOT
|
||||
|
||||
exec docker run -v $PWD:/tmp/host $IMAGE bash /tmp/host/indocker_copy_dependencies.sh $FILES
|
64
sgx-jvm/dependencies/extracted_files
Normal file
64
sgx-jvm/dependencies/extracted_files
Normal file
@ -0,0 +1,64 @@
|
||||
/lib/x86_64-linux-gnu/libcom_err.so.2
|
||||
/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
|
||||
/lib/x86_64-linux-gnu/libcrypt.so.1
|
||||
/lib/x86_64-linux-gnu/libkeyutils.so.1
|
||||
/lib/x86_64-linux-gnu/libresolv.so.2
|
||||
/lib/x86_64-linux-gnu/libssl.so.1.0.0
|
||||
/usr/bin/curl-config
|
||||
/usr/bin/patch
|
||||
/usr/bin/protoc
|
||||
/usr/include/curl
|
||||
/usr/include/google
|
||||
/usr/include/openssl
|
||||
/usr/include/x86_64-linux-gnu/openssl
|
||||
/usr/include/x86_64-linux-gnu/zconf.h
|
||||
/usr/include/zlib.h
|
||||
/usr/lib/x86_64-linux-gnu/libasn1.so.8
|
||||
/usr/lib/x86_64-linux-gnu/libasn1.so.8.0.0
|
||||
/usr/lib/x86_64-linux-gnu/libcrypto.so
|
||||
/usr/lib/x86_64-linux-gnu/libcurl.so
|
||||
/usr/lib/x86_64-linux-gnu/libcurl.so.4.4.0
|
||||
/usr/lib/x86_64-linux-gnu/libffi.so.6
|
||||
/usr/lib/x86_64-linux-gnu/libgmp.so.10
|
||||
/usr/lib/x86_64-linux-gnu/libgnutls.so.30
|
||||
/usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2
|
||||
/usr/lib/x86_64-linux-gnu/libgssapi.so.3
|
||||
/usr/lib/x86_64-linux-gnu/libgssapi.so.3.0.0
|
||||
/usr/lib/x86_64-linux-gnu/libhcrypto.so.4
|
||||
/usr/lib/x86_64-linux-gnu/libhcrypto.so.4.1.0
|
||||
/usr/lib/x86_64-linux-gnu/libheimbase.so.1
|
||||
/usr/lib/x86_64-linux-gnu/libheimbase.so.1.0.0
|
||||
/usr/lib/x86_64-linux-gnu/libheimntlm.so.0
|
||||
/usr/lib/x86_64-linux-gnu/libheimntlm.so.0.1.0
|
||||
/usr/lib/x86_64-linux-gnu/libhogweed.so.4
|
||||
/usr/lib/x86_64-linux-gnu/libhx509.so.5
|
||||
/usr/lib/x86_64-linux-gnu/libhx509.so.5.0.0
|
||||
/usr/lib/x86_64-linux-gnu/libidn.so.11
|
||||
/usr/lib/x86_64-linux-gnu/libk5crypto.so.3
|
||||
/usr/lib/x86_64-linux-gnu/libkrb5.so.26
|
||||
/usr/lib/x86_64-linux-gnu/libkrb5.so.26.0.0
|
||||
/usr/lib/x86_64-linux-gnu/libkrb5.so.3
|
||||
/usr/lib/x86_64-linux-gnu/libkrb5support.so.0
|
||||
/usr/lib/x86_64-linux-gnu/liblber-2.4.so.2
|
||||
/usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.5
|
||||
/usr/lib/x86_64-linux-gnu/libldap-2.4.so.2
|
||||
/usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
|
||||
/usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.5
|
||||
/usr/lib/x86_64-linux-gnu/libnettle.so.6
|
||||
/usr/lib/x86_64-linux-gnu/libp11-kit.so.0
|
||||
/usr/lib/x86_64-linux-gnu/libprotobuf.so
|
||||
/usr/lib/x86_64-linux-gnu/libprotobuf.so.8
|
||||
/usr/lib/x86_64-linux-gnu/libprotobuf.so.8.0.0
|
||||
/usr/lib/x86_64-linux-gnu/libprotoc.so.8
|
||||
/usr/lib/x86_64-linux-gnu/libprotoc.so.8.0.0
|
||||
/usr/lib/x86_64-linux-gnu/libroken.so.18
|
||||
/usr/lib/x86_64-linux-gnu/libroken.so.18.1.0
|
||||
/usr/lib/x86_64-linux-gnu/librtmp.so.1
|
||||
/usr/lib/x86_64-linux-gnu/libsasl2.so.2
|
||||
/usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
|
||||
/usr/lib/x86_64-linux-gnu/libsqlite3.so.0
|
||||
/usr/lib/x86_64-linux-gnu/libtasn1.so.6
|
||||
/usr/lib/x86_64-linux-gnu/libwind.so.0
|
||||
/usr/lib/x86_64-linux-gnu/libwind.so.0.0.0
|
||||
/usr/lib/x86_64-linux-gnu/libz.so
|
||||
/usr/share/java/proguard.jar
|
5
sgx-jvm/dependencies/indocker_copy_dependencies.sh
Normal file
5
sgx-jvm/dependencies/indocker_copy_dependencies.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -xeuo pipefail
|
||||
|
||||
cp -r --parents $@ /tmp/host/root
|
1
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libcom_err.so.2
Symbolic link
1
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libcom_err.so.2
Symbolic link
@ -0,0 +1 @@
|
||||
libcom_err.so.2.1
|
1
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libcrypt.so.1
Symbolic link
1
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libcrypt.so.1
Symbolic link
@ -0,0 +1 @@
|
||||
libcrypt-2.23.so
|
Binary file not shown.
1
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libkeyutils.so.1
Symbolic link
1
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libkeyutils.so.1
Symbolic link
@ -0,0 +1 @@
|
||||
libkeyutils.so.1.5
|
1
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libresolv.so.2
Symbolic link
1
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libresolv.so.2
Symbolic link
@ -0,0 +1 @@
|
||||
libresolv-2.23.so
|
BIN
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libssl.so.1.0.0
Normal file
BIN
sgx-jvm/dependencies/root/lib/x86_64-linux-gnu/libssl.so.1.0.0
Normal file
Binary file not shown.
178
sgx-jvm/dependencies/root/usr/bin/curl-config
Executable file
178
sgx-jvm/dependencies/root/usr/bin/curl-config
Executable file
@ -0,0 +1,178 @@
|
||||
#! /bin/sh
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 2001 - 2012, 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 http://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.
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
prefix=/usr
|
||||
exec_prefix=${prefix}
|
||||
includedir=${prefix}/include
|
||||
cppflag_curl_staticlib=
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: curl-config [OPTION]
|
||||
|
||||
Available values for OPTION include:
|
||||
|
||||
--built-shared says 'yes' if libcurl was built shared
|
||||
--ca ca bundle install path
|
||||
--cc compiler
|
||||
--cflags pre-processor and compiler flags
|
||||
--checkfor [version] check for (lib)curl of the specified version
|
||||
--configure the arguments given to configure when building curl
|
||||
--features newline separated list of enabled features
|
||||
--help display this help and exit
|
||||
--libs library linking information
|
||||
--prefix curl install prefix
|
||||
--protocols newline separated list of enabled protocols
|
||||
--static-libs static libcurl library linking information
|
||||
--version output version information
|
||||
--vernum output the version information as a number (hexadecimal)
|
||||
EOF
|
||||
|
||||
exit $1
|
||||
}
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage 1
|
||||
fi
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
# this deals with options in the style
|
||||
# --option=value and extracts the value part
|
||||
# [not currently used]
|
||||
-*=*) value=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
*) value= ;;
|
||||
esac
|
||||
|
||||
case "$1" in
|
||||
--built-shared)
|
||||
echo yes
|
||||
;;
|
||||
|
||||
--ca)
|
||||
echo "/etc/ssl/certs/ca-certificates.crt"
|
||||
;;
|
||||
|
||||
--cc)
|
||||
echo "gcc"
|
||||
;;
|
||||
|
||||
--prefix)
|
||||
echo "$prefix"
|
||||
;;
|
||||
|
||||
--feature|--features)
|
||||
for feature in SSL IPv6 UnixSockets libz AsynchDNS IDN GSS-API SPNEGO Kerberos NTLM NTLM_WB TLS-SRP ""; do
|
||||
test -n "$feature" && echo "$feature"
|
||||
done
|
||||
;;
|
||||
|
||||
--protocols)
|
||||
for protocol in DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTMP RTSP SMB SMBS SMTP SMTPS TELNET TFTP; do
|
||||
echo "$protocol"
|
||||
done
|
||||
;;
|
||||
|
||||
--version)
|
||||
echo libcurl 7.47.0
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--checkfor)
|
||||
checkfor=$2
|
||||
cmajor=`echo $checkfor | cut -d. -f1`
|
||||
cminor=`echo $checkfor | cut -d. -f2`
|
||||
# when extracting the patch part we strip off everything after a
|
||||
# dash as that's used for things like version 1.2.3-CVS
|
||||
cpatch=`echo $checkfor | cut -d. -f3 | cut -d- -f1`
|
||||
checknum=`echo "$cmajor*256*256 + $cminor*256 + ${cpatch:-0}" | bc`
|
||||
numuppercase=`echo 072f00 | tr 'a-f' 'A-F'`
|
||||
nownum=`echo "obase=10; ibase=16; $numuppercase" | bc`
|
||||
|
||||
if test "$nownum" -ge "$checknum"; then
|
||||
# silent success
|
||||
exit 0
|
||||
else
|
||||
echo "requested version $checkfor is newer than existing 7.47.0"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
--vernum)
|
||||
echo 072f00
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--help)
|
||||
usage 0
|
||||
;;
|
||||
|
||||
--cflags)
|
||||
if test "X$cppflag_curl_staticlib" = "X-DCURL_STATICLIB"; then
|
||||
CPPFLAG_CURL_STATICLIB="-DCURL_STATICLIB "
|
||||
else
|
||||
CPPFLAG_CURL_STATICLIB=""
|
||||
fi
|
||||
if test "X${prefix}/include" = "X/usr/include"; then
|
||||
echo "$CPPFLAG_CURL_STATICLIB"
|
||||
else
|
||||
echo "${CPPFLAG_CURL_STATICLIB}-I${prefix}/include"
|
||||
fi
|
||||
;;
|
||||
|
||||
--libs)
|
||||
if test "X${prefix}/lib/x86_64-linux-gnu" != "X/usr/lib" -a "X${prefix}/lib/x86_64-linux-gnu" != "X/usr/lib64"; then
|
||||
CURLLIBDIR="-L${prefix}/lib/x86_64-linux-gnu "
|
||||
else
|
||||
CURLLIBDIR=""
|
||||
fi
|
||||
if test "Xno" = "Xyes"; then
|
||||
echo ${CURLLIBDIR}-lcurl -lidn -lrtmp -lssl -lcrypto -lssl -lcrypto -L/usr/lib/x86_64-linux-gnu/mit-krb5 -Wl,-Bsymbolic-functions -Wl,-z,relro -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -llber -llber -lldap -lz
|
||||
else
|
||||
echo ${CURLLIBDIR}-lcurl
|
||||
fi
|
||||
;;
|
||||
|
||||
--static-libs)
|
||||
if test "Xyes" != "Xno" ; then
|
||||
echo ${prefix}/lib/x86_64-linux-gnu/libcurl.a -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -lidn -lrtmp -lssl -lcrypto -lssl -lcrypto -L/usr/lib/x86_64-linux-gnu/mit-krb5 -Wl,-Bsymbolic-functions -Wl,-z,relro -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -llber -llber -lldap -lz
|
||||
else
|
||||
echo "curl was built with static libraries disabled" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
--configure)
|
||||
echo " '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--disable-maintainer-mode' '--disable-dependency-tracking' '--disable-symbol-hiding' '--enable-versioned-symbols' '--enable-threaded-resolver' '--with-lber-lib=lber' '--with-gssapi=/usr' '--with-zsh-functions-dir=/usr/share/zsh/vendor-completions' '--with-ca-path=/etc/ssl/certs' '--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security' 'LDFLAGS=-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "unknown option: $1"
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exit 0
|
BIN
sgx-jvm/dependencies/root/usr/bin/patch
Executable file
BIN
sgx-jvm/dependencies/root/usr/bin/patch
Executable file
Binary file not shown.
BIN
sgx-jvm/dependencies/root/usr/bin/protoc
Executable file
BIN
sgx-jvm/dependencies/root/usr/bin/protoc
Executable file
Binary file not shown.
2415
sgx-jvm/dependencies/root/usr/include/curl/curl.h
Normal file
2415
sgx-jvm/dependencies/root/usr/include/curl/curl.h
Normal file
File diff suppressed because it is too large
Load Diff
198
sgx-jvm/dependencies/root/usr/include/curl/curlbuild.h
Normal file
198
sgx-jvm/dependencies/root/usr/include/curl/curlbuild.h
Normal file
@ -0,0 +1,198 @@
|
||||
/* include/curl/curlbuild.h. Generated from curlbuild.h.in by configure. */
|
||||
#ifndef __CURL_CURLBUILD_H
|
||||
#define __CURL_CURLBUILD_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, 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 http://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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* ================================================================ */
|
||||
/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
* NOTE 1:
|
||||
* -------
|
||||
*
|
||||
* Nothing in this file is intended to be modified or adjusted by the
|
||||
* curl library user nor by the curl library builder.
|
||||
*
|
||||
* If you think that something actually needs to be changed, adjusted
|
||||
* or fixed in this file, then, report it on the libcurl development
|
||||
* mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/
|
||||
*
|
||||
* This header file shall only export symbols which are 'curl' or 'CURL'
|
||||
* prefixed, otherwise public name space would be polluted.
|
||||
*
|
||||
* NOTE 2:
|
||||
* -------
|
||||
*
|
||||
* Right now you might be staring at file include/curl/curlbuild.h.in or
|
||||
* at file include/curl/curlbuild.h, this is due to the following reason:
|
||||
*
|
||||
* On systems capable of running the configure script, the configure process
|
||||
* will overwrite the distributed include/curl/curlbuild.h file with one that
|
||||
* is suitable and specific to the library being configured and built, which
|
||||
* is generated from the include/curl/curlbuild.h.in template file.
|
||||
*
|
||||
*/
|
||||
|
||||
/* ================================================================ */
|
||||
/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
|
||||
/* ================================================================ */
|
||||
|
||||
#ifdef CURL_SIZEOF_LONG
|
||||
#error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
#error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_SIZEOF_CURL_SOCKLEN_T
|
||||
#error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_TYPEOF_CURL_OFF_T
|
||||
#error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_FORMAT_CURL_OFF_T
|
||||
#error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_FORMAT_CURL_OFF_TU
|
||||
#error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_FORMAT_OFF_T
|
||||
#error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_SIZEOF_CURL_OFF_T
|
||||
#error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_SUFFIX_CURL_OFF_T
|
||||
#error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_SUFFIX_CURL_OFF_TU
|
||||
#error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined
|
||||
#endif
|
||||
|
||||
/* ================================================================ */
|
||||
/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
|
||||
/* ================================================================ */
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file ws2tcpip.h must be included by the external interface. */
|
||||
/* #undef CURL_PULL_WS2TCPIP_H */
|
||||
#ifdef CURL_PULL_WS2TCPIP_H
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file sys/types.h must be included by the external interface. */
|
||||
#define CURL_PULL_SYS_TYPES_H 1
|
||||
#ifdef CURL_PULL_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file stdint.h must be included by the external interface. */
|
||||
/* #undef CURL_PULL_STDINT_H */
|
||||
#ifdef CURL_PULL_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file inttypes.h must be included by the external interface. */
|
||||
/* #undef CURL_PULL_INTTYPES_H */
|
||||
#ifdef CURL_PULL_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file sys/socket.h must be included by the external interface. */
|
||||
#define CURL_PULL_SYS_SOCKET_H 1
|
||||
#ifdef CURL_PULL_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file sys/poll.h must be included by the external interface. */
|
||||
/* #undef CURL_PULL_SYS_POLL_H */
|
||||
#ifdef CURL_PULL_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define CURL_SIZEOF_LONG 8
|
||||
|
||||
/* Integral data type used for curl_socklen_t. */
|
||||
#define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
|
||||
/* The size of `curl_socklen_t', as computed by sizeof. */
|
||||
#define CURL_SIZEOF_CURL_SOCKLEN_T 4
|
||||
|
||||
/* Data type definition of curl_socklen_t. */
|
||||
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
|
||||
|
||||
/* Signed integral data type used for curl_off_t. */
|
||||
#define CURL_TYPEOF_CURL_OFF_T long
|
||||
|
||||
/* Data type definition of curl_off_t. */
|
||||
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
|
||||
|
||||
/* curl_off_t formatting string directive without "%" conversion specifier. */
|
||||
#define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
|
||||
/* unsigned curl_off_t formatting string without "%" conversion specifier. */
|
||||
#define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
|
||||
/* curl_off_t formatting string directive with "%" conversion specifier. */
|
||||
#define CURL_FORMAT_OFF_T "%ld"
|
||||
|
||||
/* The size of `curl_off_t', as computed by sizeof. */
|
||||
#define CURL_SIZEOF_CURL_OFF_T 8
|
||||
|
||||
/* curl_off_t constant suffix. */
|
||||
#define CURL_SUFFIX_CURL_OFF_T L
|
||||
|
||||
/* unsigned curl_off_t constant suffix. */
|
||||
#define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
|
||||
#endif /* __CURL_CURLBUILD_H */
|
262
sgx-jvm/dependencies/root/usr/include/curl/curlrules.h
Normal file
262
sgx-jvm/dependencies/root/usr/include/curl/curlrules.h
Normal file
@ -0,0 +1,262 @@
|
||||
#ifndef __CURL_CURLRULES_H
|
||||
#define __CURL_CURLRULES_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, 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 http://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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* ================================================================ */
|
||||
/* COMPILE TIME SANITY CHECKS */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
* NOTE 1:
|
||||
* -------
|
||||
*
|
||||
* All checks done in this file are intentionally placed in a public
|
||||
* header file which is pulled by curl/curl.h when an application is
|
||||
* being built using an already built libcurl library. Additionally
|
||||
* this file is also included and used when building the library.
|
||||
*
|
||||
* If compilation fails on this file it is certainly sure that the
|
||||
* problem is elsewhere. It could be a problem in the curlbuild.h
|
||||
* header file, or simply that you are using different compilation
|
||||
* settings than those used to build the library.
|
||||
*
|
||||
* Nothing in this file is intended to be modified or adjusted by the
|
||||
* curl library user nor by the curl library builder.
|
||||
*
|
||||
* Do not deactivate any check, these are done to make sure that the
|
||||
* library is properly built and used.
|
||||
*
|
||||
* You can find further help on the libcurl development mailing list:
|
||||
* http://cool.haxx.se/mailman/listinfo/curl-library/
|
||||
*
|
||||
* NOTE 2
|
||||
* ------
|
||||
*
|
||||
* Some of the following compile time checks are based on the fact
|
||||
* that the dimension of a constant array can not be a negative one.
|
||||
* In this way if the compile time verification fails, the compilation
|
||||
* will fail issuing an error. The error description wording is compiler
|
||||
* dependent but it will be quite similar to one of the following:
|
||||
*
|
||||
* "negative subscript or subscript is too large"
|
||||
* "array must have at least one element"
|
||||
* "-1 is an illegal array size"
|
||||
* "size of array is negative"
|
||||
*
|
||||
* If you are building an application which tries to use an already
|
||||
* built libcurl library and you are getting this kind of errors on
|
||||
* this file, it is a clear indication that there is a mismatch between
|
||||
* how the library was built and how you are trying to use it for your
|
||||
* application. Your already compiled or binary library provider is the
|
||||
* only one who can give you the details you need to properly use it.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Verify that some macros are actually defined.
|
||||
*/
|
||||
|
||||
#ifndef CURL_SIZEOF_LONG
|
||||
# error "CURL_SIZEOF_LONG definition is missing!"
|
||||
Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
# error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!"
|
||||
Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CURL_SIZEOF_CURL_SOCKLEN_T
|
||||
# error "CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!"
|
||||
Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CURL_TYPEOF_CURL_OFF_T
|
||||
# error "CURL_TYPEOF_CURL_OFF_T definition is missing!"
|
||||
Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CURL_FORMAT_CURL_OFF_T
|
||||
# error "CURL_FORMAT_CURL_OFF_T definition is missing!"
|
||||
Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CURL_FORMAT_CURL_OFF_TU
|
||||
# error "CURL_FORMAT_CURL_OFF_TU definition is missing!"
|
||||
Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CURL_FORMAT_OFF_T
|
||||
# error "CURL_FORMAT_OFF_T definition is missing!"
|
||||
Error Compilation_aborted_CURL_FORMAT_OFF_T_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CURL_SIZEOF_CURL_OFF_T
|
||||
# error "CURL_SIZEOF_CURL_OFF_T definition is missing!"
|
||||
Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CURL_SUFFIX_CURL_OFF_T
|
||||
# error "CURL_SUFFIX_CURL_OFF_T definition is missing!"
|
||||
Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CURL_SUFFIX_CURL_OFF_TU
|
||||
# error "CURL_SUFFIX_CURL_OFF_TU definition is missing!"
|
||||
Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros private to this header file.
|
||||
*/
|
||||
|
||||
#define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
|
||||
|
||||
#define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
|
||||
|
||||
/*
|
||||
* Verify that the size previously defined and expected for long
|
||||
* is the same as the one reported by sizeof() at compile time.
|
||||
*/
|
||||
|
||||
typedef char
|
||||
__curl_rule_01__
|
||||
[CurlchkszEQ(long, CURL_SIZEOF_LONG)];
|
||||
|
||||
/*
|
||||
* Verify that the size previously defined and expected for
|
||||
* curl_off_t is actually the the same as the one reported
|
||||
* by sizeof() at compile time.
|
||||
*/
|
||||
|
||||
typedef char
|
||||
__curl_rule_02__
|
||||
[CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];
|
||||
|
||||
/*
|
||||
* Verify at compile time that the size of curl_off_t as reported
|
||||
* by sizeof() is greater or equal than the one reported for long
|
||||
* for the current compilation.
|
||||
*/
|
||||
|
||||
typedef char
|
||||
__curl_rule_03__
|
||||
[CurlchkszGE(curl_off_t, long)];
|
||||
|
||||
/*
|
||||
* Verify that the size previously defined and expected for
|
||||
* curl_socklen_t is actually the the same as the one reported
|
||||
* by sizeof() at compile time.
|
||||
*/
|
||||
|
||||
typedef char
|
||||
__curl_rule_04__
|
||||
[CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)];
|
||||
|
||||
/*
|
||||
* Verify at compile time that the size of curl_socklen_t as reported
|
||||
* by sizeof() is greater or equal than the one reported for int for
|
||||
* the current compilation.
|
||||
*/
|
||||
|
||||
typedef char
|
||||
__curl_rule_05__
|
||||
[CurlchkszGE(curl_socklen_t, int)];
|
||||
|
||||
/* ================================================================ */
|
||||
/* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
||||
/*
|
||||
* Get rid of macros private to this header file.
|
||||
*/
|
||||
|
||||
#undef CurlchkszEQ
|
||||
#undef CurlchkszGE
|
||||
|
||||
/*
|
||||
* Get rid of macros not intended to exist beyond this point.
|
||||
*/
|
||||
|
||||
#undef CURL_PULL_WS2TCPIP_H
|
||||
#undef CURL_PULL_SYS_TYPES_H
|
||||
#undef CURL_PULL_SYS_SOCKET_H
|
||||
#undef CURL_PULL_SYS_POLL_H
|
||||
#undef CURL_PULL_STDINT_H
|
||||
#undef CURL_PULL_INTTYPES_H
|
||||
|
||||
#undef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
#undef CURL_TYPEOF_CURL_OFF_T
|
||||
|
||||
#ifdef CURL_NO_OLDIES
|
||||
#undef CURL_FORMAT_OFF_T /* not required since 7.19.0 - obsoleted in 7.20.0 */
|
||||
#endif
|
||||
|
||||
#endif /* __CURL_CURLRULES_H */
|
77
sgx-jvm/dependencies/root/usr/include/curl/curlver.h
Normal file
77
sgx-jvm/dependencies/root/usr/include/curl/curlver.h
Normal file
@ -0,0 +1,77 @@
|
||||
#ifndef __CURL_CURLVER_H
|
||||
#define __CURL_CURLVER_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2015, 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 http://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 - 2015 Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "7.47.0"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 7
|
||||
#define LIBCURL_VERSION_MINOR 47
|
||||
#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 0x072f00
|
||||
|
||||
/*
|
||||
* 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 should follow this template:
|
||||
*
|
||||
* "Mon Feb 12 11:35:33 UTC 2007"
|
||||
*/
|
||||
#define LIBCURL_TIMESTAMP "Wed Jan 27 07:32:44 UTC 2016"
|
||||
|
||||
#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 */
|
102
sgx-jvm/dependencies/root/usr/include/curl/easy.h
Normal file
102
sgx-jvm/dependencies/root/usr/include/curl/easy.h
Normal file
@ -0,0 +1,102 @@
|
||||
#ifndef __CURL_EASY_H
|
||||
#define __CURL_EASY_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2008, 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 http://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
|
74
sgx-jvm/dependencies/root/usr/include/curl/mprintf.h
Normal file
74
sgx-jvm/dependencies/root/usr/include/curl/mprintf.h
Normal file
@ -0,0 +1,74 @@
|
||||
#ifndef __CURL_MPRINTF_H
|
||||
#define __CURL_MPRINTF_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2015, 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 http://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"
|
||||
|
||||
#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 _MPRINTF_REPLACE
|
||||
# undef printf
|
||||
# undef fprintf
|
||||
# undef sprintf
|
||||
# undef vsprintf
|
||||
# undef snprintf
|
||||
# undef vprintf
|
||||
# undef vfprintf
|
||||
# undef vsnprintf
|
||||
# undef aprintf
|
||||
# undef vaprintf
|
||||
# define printf curl_mprintf
|
||||
# define fprintf curl_mfprintf
|
||||
# define sprintf curl_msprintf
|
||||
# define vsprintf curl_mvsprintf
|
||||
# define snprintf curl_msnprintf
|
||||
# define vprintf curl_mvprintf
|
||||
# define vfprintf curl_mvfprintf
|
||||
# define vsnprintf curl_mvsnprintf
|
||||
# define aprintf curl_maprintf
|
||||
# define vaprintf curl_mvaprintf
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CURL_MPRINTF_H */
|
435
sgx-jvm/dependencies/root/usr/include/curl/multi.h
Normal file
435
sgx-jvm/dependencies/root/usr/include/curl/multi.h
Normal file
@ -0,0 +1,435 @@
|
||||
#ifndef __CURL_MULTI_H
|
||||
#define __CURL_MULTI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2015, 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 http://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
|
||||
|
||||
typedef void CURLM;
|
||||
|
||||
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 informations. 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
|
33
sgx-jvm/dependencies/root/usr/include/curl/stdcheaders.h
Normal file
33
sgx-jvm/dependencies/root/usr/include/curl/stdcheaders.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef __STDC_HEADERS_H
|
||||
#define __STDC_HEADERS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2010, 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 http://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 */
|
622
sgx-jvm/dependencies/root/usr/include/curl/typecheck-gcc.h
Normal file
622
sgx-jvm/dependencies/root/usr/include/curl/typecheck-gcc.h
Normal file
@ -0,0 +1,622 @@
|
||||
#ifndef __CURL_TYPECHECK_GCC_H
|
||||
#define __CURL_TYPECHECK_GCC_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2015, 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 http://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_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(); \
|
||||
} \
|
||||
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_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")
|
||||
|
||||
/* 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_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_PROXY || \
|
||||
(option) == CURLOPT_PROXYPASSWORD || \
|
||||
(option) == CURLOPT_PROXYUSERNAME || \
|
||||
(option) == CURLOPT_PROXYUSERPWD || \
|
||||
(option) == CURLOPT_PROXY_SERVICE_NAME || \
|
||||
(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) \
|
||||
(CURLINFO_SLIST < (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) \
|
||||
(__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) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) || \
|
||||
__builtin_types_compatible_p(__typeof__(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) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) || \
|
||||
__builtin_types_compatible_p(__typeof__(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) || \
|
||||
__builtin_types_compatible_p(__typeof__(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) || \
|
||||
__builtin_types_compatible_p(__typeof__(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) || \
|
||||
__builtin_types_compatible_p(__typeof__(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) || \
|
||||
__builtin_types_compatible_p(__typeof__(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) || \
|
||||
__builtin_types_compatible_p(__typeof__(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) || \
|
||||
__builtin_types_compatible_p(__typeof__(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) || \
|
||||
__builtin_types_compatible_p(__typeof__(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) || \
|
||||
__builtin_types_compatible_p(__typeof__(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 */
|
1521
sgx-jvm/dependencies/root/usr/include/google/protobuf/descriptor.h
Normal file
1521
sgx-jvm/dependencies/root/usr/include/google/protobuf/descriptor.h
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,620 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// The messages in this file describe the definitions found in .proto files.
|
||||
// A valid .proto file can be translated directly to a FileDescriptorProto
|
||||
// without any other information (e.g. without reading its imports).
|
||||
|
||||
|
||||
|
||||
package google.protobuf;
|
||||
option java_package = "com.google.protobuf";
|
||||
option java_outer_classname = "DescriptorProtos";
|
||||
|
||||
// descriptor.proto must be optimized for speed because reflection-based
|
||||
// algorithms don't work during bootstrapping.
|
||||
option optimize_for = SPEED;
|
||||
|
||||
// The protocol compiler can output a FileDescriptorSet containing the .proto
|
||||
// files it parses.
|
||||
message FileDescriptorSet {
|
||||
repeated FileDescriptorProto file = 1;
|
||||
}
|
||||
|
||||
// Describes a complete .proto file.
|
||||
message FileDescriptorProto {
|
||||
optional string name = 1; // file name, relative to root of source tree
|
||||
optional string package = 2; // e.g. "foo", "foo.bar", etc.
|
||||
|
||||
// Names of files imported by this file.
|
||||
repeated string dependency = 3;
|
||||
// Indexes of the public imported files in the dependency list above.
|
||||
repeated int32 public_dependency = 10;
|
||||
// Indexes of the weak imported files in the dependency list.
|
||||
// For Google-internal migration only. Do not use.
|
||||
repeated int32 weak_dependency = 11;
|
||||
|
||||
// All top-level definitions in this file.
|
||||
repeated DescriptorProto message_type = 4;
|
||||
repeated EnumDescriptorProto enum_type = 5;
|
||||
repeated ServiceDescriptorProto service = 6;
|
||||
repeated FieldDescriptorProto extension = 7;
|
||||
|
||||
optional FileOptions options = 8;
|
||||
|
||||
// This field contains optional information about the original source code.
|
||||
// You may safely remove this entire field whithout harming runtime
|
||||
// functionality of the descriptors -- the information is needed only by
|
||||
// development tools.
|
||||
optional SourceCodeInfo source_code_info = 9;
|
||||
}
|
||||
|
||||
// Describes a message type.
|
||||
message DescriptorProto {
|
||||
optional string name = 1;
|
||||
|
||||
repeated FieldDescriptorProto field = 2;
|
||||
repeated FieldDescriptorProto extension = 6;
|
||||
|
||||
repeated DescriptorProto nested_type = 3;
|
||||
repeated EnumDescriptorProto enum_type = 4;
|
||||
|
||||
message ExtensionRange {
|
||||
optional int32 start = 1;
|
||||
optional int32 end = 2;
|
||||
}
|
||||
repeated ExtensionRange extension_range = 5;
|
||||
|
||||
optional MessageOptions options = 7;
|
||||
}
|
||||
|
||||
// Describes a field within a message.
|
||||
message FieldDescriptorProto {
|
||||
enum Type {
|
||||
// 0 is reserved for errors.
|
||||
// Order is weird for historical reasons.
|
||||
TYPE_DOUBLE = 1;
|
||||
TYPE_FLOAT = 2;
|
||||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
|
||||
// negative values are likely.
|
||||
TYPE_INT64 = 3;
|
||||
TYPE_UINT64 = 4;
|
||||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
|
||||
// negative values are likely.
|
||||
TYPE_INT32 = 5;
|
||||
TYPE_FIXED64 = 6;
|
||||
TYPE_FIXED32 = 7;
|
||||
TYPE_BOOL = 8;
|
||||
TYPE_STRING = 9;
|
||||
TYPE_GROUP = 10; // Tag-delimited aggregate.
|
||||
TYPE_MESSAGE = 11; // Length-delimited aggregate.
|
||||
|
||||
// New in version 2.
|
||||
TYPE_BYTES = 12;
|
||||
TYPE_UINT32 = 13;
|
||||
TYPE_ENUM = 14;
|
||||
TYPE_SFIXED32 = 15;
|
||||
TYPE_SFIXED64 = 16;
|
||||
TYPE_SINT32 = 17; // Uses ZigZag encoding.
|
||||
TYPE_SINT64 = 18; // Uses ZigZag encoding.
|
||||
};
|
||||
|
||||
enum Label {
|
||||
// 0 is reserved for errors
|
||||
LABEL_OPTIONAL = 1;
|
||||
LABEL_REQUIRED = 2;
|
||||
LABEL_REPEATED = 3;
|
||||
// TODO(sanjay): Should we add LABEL_MAP?
|
||||
};
|
||||
|
||||
optional string name = 1;
|
||||
optional int32 number = 3;
|
||||
optional Label label = 4;
|
||||
|
||||
// If type_name is set, this need not be set. If both this and type_name
|
||||
// are set, this must be either TYPE_ENUM or TYPE_MESSAGE.
|
||||
optional Type type = 5;
|
||||
|
||||
// For message and enum types, this is the name of the type. If the name
|
||||
// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
|
||||
// rules are used to find the type (i.e. first the nested types within this
|
||||
// message are searched, then within the parent, on up to the root
|
||||
// namespace).
|
||||
optional string type_name = 6;
|
||||
|
||||
// For extensions, this is the name of the type being extended. It is
|
||||
// resolved in the same manner as type_name.
|
||||
optional string extendee = 2;
|
||||
|
||||
// For numeric types, contains the original text representation of the value.
|
||||
// For booleans, "true" or "false".
|
||||
// For strings, contains the default text contents (not escaped in any way).
|
||||
// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
|
||||
// TODO(kenton): Base-64 encode?
|
||||
optional string default_value = 7;
|
||||
|
||||
optional FieldOptions options = 8;
|
||||
}
|
||||
|
||||
// Describes an enum type.
|
||||
message EnumDescriptorProto {
|
||||
optional string name = 1;
|
||||
|
||||
repeated EnumValueDescriptorProto value = 2;
|
||||
|
||||
optional EnumOptions options = 3;
|
||||
}
|
||||
|
||||
// Describes a value within an enum.
|
||||
message EnumValueDescriptorProto {
|
||||
optional string name = 1;
|
||||
optional int32 number = 2;
|
||||
|
||||
optional EnumValueOptions options = 3;
|
||||
}
|
||||
|
||||
// Describes a service.
|
||||
message ServiceDescriptorProto {
|
||||
optional string name = 1;
|
||||
repeated MethodDescriptorProto method = 2;
|
||||
|
||||
optional ServiceOptions options = 3;
|
||||
}
|
||||
|
||||
// Describes a method of a service.
|
||||
message MethodDescriptorProto {
|
||||
optional string name = 1;
|
||||
|
||||
// Input and output type names. These are resolved in the same way as
|
||||
// FieldDescriptorProto.type_name, but must refer to a message type.
|
||||
optional string input_type = 2;
|
||||
optional string output_type = 3;
|
||||
|
||||
optional MethodOptions options = 4;
|
||||
}
|
||||
|
||||
|
||||
// ===================================================================
|
||||
// Options
|
||||
|
||||
// Each of the definitions above may have "options" attached. These are
|
||||
// just annotations which may cause code to be generated slightly differently
|
||||
// or may contain hints for code that manipulates protocol messages.
|
||||
//
|
||||
// Clients may define custom options as extensions of the *Options messages.
|
||||
// These extensions may not yet be known at parsing time, so the parser cannot
|
||||
// store the values in them. Instead it stores them in a field in the *Options
|
||||
// message called uninterpreted_option. This field must have the same name
|
||||
// across all *Options messages. We then use this field to populate the
|
||||
// extensions when we build a descriptor, at which point all protos have been
|
||||
// parsed and so all extensions are known.
|
||||
//
|
||||
// Extension numbers for custom options may be chosen as follows:
|
||||
// * For options which will only be used within a single application or
|
||||
// organization, or for experimental options, use field numbers 50000
|
||||
// through 99999. It is up to you to ensure that you do not use the
|
||||
// same number for multiple options.
|
||||
// * For options which will be published and used publicly by multiple
|
||||
// independent entities, e-mail protobuf-global-extension-registry@google.com
|
||||
// to reserve extension numbers. Simply provide your project name (e.g.
|
||||
// Object-C plugin) and your porject website (if available) -- there's no need
|
||||
// to explain how you intend to use them. Usually you only need one extension
|
||||
// number. You can declare multiple options with only one extension number by
|
||||
// putting them in a sub-message. See the Custom Options section of the docs
|
||||
// for examples:
|
||||
// http://code.google.com/apis/protocolbuffers/docs/proto.html#options
|
||||
// If this turns out to be popular, a web service will be set up
|
||||
// to automatically assign option numbers.
|
||||
|
||||
|
||||
message FileOptions {
|
||||
|
||||
// Sets the Java package where classes generated from this .proto will be
|
||||
// placed. By default, the proto package is used, but this is often
|
||||
// inappropriate because proto packages do not normally start with backwards
|
||||
// domain names.
|
||||
optional string java_package = 1;
|
||||
|
||||
|
||||
// If set, all the classes from the .proto file are wrapped in a single
|
||||
// outer class with the given name. This applies to both Proto1
|
||||
// (equivalent to the old "--one_java_file" option) and Proto2 (where
|
||||
// a .proto always translates to a single class, but you may want to
|
||||
// explicitly choose the class name).
|
||||
optional string java_outer_classname = 8;
|
||||
|
||||
// If set true, then the Java code generator will generate a separate .java
|
||||
// file for each top-level message, enum, and service defined in the .proto
|
||||
// file. Thus, these types will *not* be nested inside the outer class
|
||||
// named by java_outer_classname. However, the outer class will still be
|
||||
// generated to contain the file's getDescriptor() method as well as any
|
||||
// top-level extensions defined in the file.
|
||||
optional bool java_multiple_files = 10 [default=false];
|
||||
|
||||
// If set true, then the Java code generator will generate equals() and
|
||||
// hashCode() methods for all messages defined in the .proto file. This is
|
||||
// purely a speed optimization, as the AbstractMessage base class includes
|
||||
// reflection-based implementations of these methods.
|
||||
optional bool java_generate_equals_and_hash = 20 [default=false];
|
||||
|
||||
// Generated classes can be optimized for speed or code size.
|
||||
enum OptimizeMode {
|
||||
SPEED = 1; // Generate complete code for parsing, serialization,
|
||||
// etc.
|
||||
CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
|
||||
LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
|
||||
}
|
||||
optional OptimizeMode optimize_for = 9 [default=SPEED];
|
||||
|
||||
// Sets the Go package where structs generated from this .proto will be
|
||||
// placed. There is no default.
|
||||
optional string go_package = 11;
|
||||
|
||||
|
||||
|
||||
// Should generic services be generated in each language? "Generic" services
|
||||
// are not specific to any particular RPC system. They are generated by the
|
||||
// main code generators in each language (without additional plugins).
|
||||
// Generic services were the only kind of service generation supported by
|
||||
// early versions of proto2.
|
||||
//
|
||||
// Generic services are now considered deprecated in favor of using plugins
|
||||
// that generate code specific to your particular RPC system. Therefore,
|
||||
// these default to false. Old code which depends on generic services should
|
||||
// explicitly set them to true.
|
||||
optional bool cc_generic_services = 16 [default=false];
|
||||
optional bool java_generic_services = 17 [default=false];
|
||||
optional bool py_generic_services = 18 [default=false];
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message MessageOptions {
|
||||
// Set true to use the old proto1 MessageSet wire format for extensions.
|
||||
// This is provided for backwards-compatibility with the MessageSet wire
|
||||
// format. You should not use this for any other reason: It's less
|
||||
// efficient, has fewer features, and is more complicated.
|
||||
//
|
||||
// The message must be defined exactly as follows:
|
||||
// message Foo {
|
||||
// option message_set_wire_format = true;
|
||||
// extensions 4 to max;
|
||||
// }
|
||||
// Note that the message cannot have any defined fields; MessageSets only
|
||||
// have extensions.
|
||||
//
|
||||
// All extensions of your type must be singular messages; e.g. they cannot
|
||||
// be int32s, enums, or repeated messages.
|
||||
//
|
||||
// Because this is an option, the above two restrictions are not enforced by
|
||||
// the protocol compiler.
|
||||
optional bool message_set_wire_format = 1 [default=false];
|
||||
|
||||
// Disables the generation of the standard "descriptor()" accessor, which can
|
||||
// conflict with a field of the same name. This is meant to make migration
|
||||
// from proto1 easier; new code should avoid fields named "descriptor".
|
||||
optional bool no_standard_descriptor_accessor = 2 [default=false];
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message FieldOptions {
|
||||
// The ctype option instructs the C++ code generator to use a different
|
||||
// representation of the field than it normally would. See the specific
|
||||
// options below. This option is not yet implemented in the open source
|
||||
// release -- sorry, we'll try to include it in a future version!
|
||||
optional CType ctype = 1 [default = STRING];
|
||||
enum CType {
|
||||
// Default mode.
|
||||
STRING = 0;
|
||||
|
||||
CORD = 1;
|
||||
|
||||
STRING_PIECE = 2;
|
||||
}
|
||||
// The packed option can be enabled for repeated primitive fields to enable
|
||||
// a more efficient representation on the wire. Rather than repeatedly
|
||||
// writing the tag and type for each element, the entire array is encoded as
|
||||
// a single length-delimited blob.
|
||||
optional bool packed = 2;
|
||||
|
||||
|
||||
|
||||
// Should this field be parsed lazily? Lazy applies only to message-type
|
||||
// fields. It means that when the outer message is initially parsed, the
|
||||
// inner message's contents will not be parsed but instead stored in encoded
|
||||
// form. The inner message will actually be parsed when it is first accessed.
|
||||
//
|
||||
// This is only a hint. Implementations are free to choose whether to use
|
||||
// eager or lazy parsing regardless of the value of this option. However,
|
||||
// setting this option true suggests that the protocol author believes that
|
||||
// using lazy parsing on this field is worth the additional bookkeeping
|
||||
// overhead typically needed to implement it.
|
||||
//
|
||||
// This option does not affect the public interface of any generated code;
|
||||
// all method signatures remain the same. Furthermore, thread-safety of the
|
||||
// interface is not affected by this option; const methods remain safe to
|
||||
// call from multiple threads concurrently, while non-const methods continue
|
||||
// to require exclusive access.
|
||||
//
|
||||
//
|
||||
// Note that implementations may choose not to check required fields within
|
||||
// a lazy sub-message. That is, calling IsInitialized() on the outher message
|
||||
// may return true even if the inner message has missing required fields.
|
||||
// This is necessary because otherwise the inner message would have to be
|
||||
// parsed in order to perform the check, defeating the purpose of lazy
|
||||
// parsing. An implementation which chooses not to check required fields
|
||||
// must be consistent about it. That is, for any particular sub-message, the
|
||||
// implementation must either *always* check its required fields, or *never*
|
||||
// check its required fields, regardless of whether or not the message has
|
||||
// been parsed.
|
||||
optional bool lazy = 5 [default=false];
|
||||
|
||||
// Is this field deprecated?
|
||||
// Depending on the target platform, this can emit Deprecated annotations
|
||||
// for accessors, or it will be completely ignored; in the very least, this
|
||||
// is a formalization for deprecating fields.
|
||||
optional bool deprecated = 3 [default=false];
|
||||
|
||||
// EXPERIMENTAL. DO NOT USE.
|
||||
// For "map" fields, the name of the field in the enclosed type that
|
||||
// is the key for this map. For example, suppose we have:
|
||||
// message Item {
|
||||
// required string name = 1;
|
||||
// required string value = 2;
|
||||
// }
|
||||
// message Config {
|
||||
// repeated Item items = 1 [experimental_map_key="name"];
|
||||
// }
|
||||
// In this situation, the map key for Item will be set to "name".
|
||||
// TODO: Fully-implement this, then remove the "experimental_" prefix.
|
||||
optional string experimental_map_key = 9;
|
||||
|
||||
// For Google-internal migration only. Do not use.
|
||||
optional bool weak = 10 [default=false];
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message EnumOptions {
|
||||
|
||||
// Set this option to false to disallow mapping different tag names to a same
|
||||
// value.
|
||||
optional bool allow_alias = 2 [default=true];
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message EnumValueOptions {
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message ServiceOptions {
|
||||
|
||||
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
|
||||
// framework. We apologize for hoarding these numbers to ourselves, but
|
||||
// we were already using them long before we decided to release Protocol
|
||||
// Buffers.
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message MethodOptions {
|
||||
|
||||
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
|
||||
// framework. We apologize for hoarding these numbers to ourselves, but
|
||||
// we were already using them long before we decided to release Protocol
|
||||
// Buffers.
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
|
||||
// A message representing a option the parser does not recognize. This only
|
||||
// appears in options protos created by the compiler::Parser class.
|
||||
// DescriptorPool resolves these when building Descriptor objects. Therefore,
|
||||
// options protos in descriptor objects (e.g. returned by Descriptor::options(),
|
||||
// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
|
||||
// in them.
|
||||
message UninterpretedOption {
|
||||
// The name of the uninterpreted option. Each string represents a segment in
|
||||
// a dot-separated name. is_extension is true iff a segment represents an
|
||||
// extension (denoted with parentheses in options specs in .proto files).
|
||||
// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
|
||||
// "foo.(bar.baz).qux".
|
||||
message NamePart {
|
||||
required string name_part = 1;
|
||||
required bool is_extension = 2;
|
||||
}
|
||||
repeated NamePart name = 2;
|
||||
|
||||
// The value of the uninterpreted option, in whatever type the tokenizer
|
||||
// identified it as during parsing. Exactly one of these should be set.
|
||||
optional string identifier_value = 3;
|
||||
optional uint64 positive_int_value = 4;
|
||||
optional int64 negative_int_value = 5;
|
||||
optional double double_value = 6;
|
||||
optional bytes string_value = 7;
|
||||
optional string aggregate_value = 8;
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// Optional source code info
|
||||
|
||||
// Encapsulates information about the original source file from which a
|
||||
// FileDescriptorProto was generated.
|
||||
message SourceCodeInfo {
|
||||
// A Location identifies a piece of source code in a .proto file which
|
||||
// corresponds to a particular definition. This information is intended
|
||||
// to be useful to IDEs, code indexers, documentation generators, and similar
|
||||
// tools.
|
||||
//
|
||||
// For example, say we have a file like:
|
||||
// message Foo {
|
||||
// optional string foo = 1;
|
||||
// }
|
||||
// Let's look at just the field definition:
|
||||
// optional string foo = 1;
|
||||
// ^ ^^ ^^ ^ ^^^
|
||||
// a bc de f ghi
|
||||
// We have the following locations:
|
||||
// span path represents
|
||||
// [a,i) [ 4, 0, 2, 0 ] The whole field definition.
|
||||
// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
|
||||
// [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
|
||||
// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
|
||||
// [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
|
||||
//
|
||||
// Notes:
|
||||
// - A location may refer to a repeated field itself (i.e. not to any
|
||||
// particular index within it). This is used whenever a set of elements are
|
||||
// logically enclosed in a single code segment. For example, an entire
|
||||
// extend block (possibly containing multiple extension definitions) will
|
||||
// have an outer location whose path refers to the "extensions" repeated
|
||||
// field without an index.
|
||||
// - Multiple locations may have the same path. This happens when a single
|
||||
// logical declaration is spread out across multiple places. The most
|
||||
// obvious example is the "extend" block again -- there may be multiple
|
||||
// extend blocks in the same scope, each of which will have the same path.
|
||||
// - A location's span is not always a subset of its parent's span. For
|
||||
// example, the "extendee" of an extension declaration appears at the
|
||||
// beginning of the "extend" block and is shared by all extensions within
|
||||
// the block.
|
||||
// - Just because a location's span is a subset of some other location's span
|
||||
// does not mean that it is a descendent. For example, a "group" defines
|
||||
// both a type and a field in a single declaration. Thus, the locations
|
||||
// corresponding to the type and field and their components will overlap.
|
||||
// - Code which tries to interpret locations should probably be designed to
|
||||
// ignore those that it doesn't understand, as more types of locations could
|
||||
// be recorded in the future.
|
||||
repeated Location location = 1;
|
||||
message Location {
|
||||
// Identifies which part of the FileDescriptorProto was defined at this
|
||||
// location.
|
||||
//
|
||||
// Each element is a field number or an index. They form a path from
|
||||
// the root FileDescriptorProto to the place where the definition. For
|
||||
// example, this path:
|
||||
// [ 4, 3, 2, 7, 1 ]
|
||||
// refers to:
|
||||
// file.message_type(3) // 4, 3
|
||||
// .field(7) // 2, 7
|
||||
// .name() // 1
|
||||
// This is because FileDescriptorProto.message_type has field number 4:
|
||||
// repeated DescriptorProto message_type = 4;
|
||||
// and DescriptorProto.field has field number 2:
|
||||
// repeated FieldDescriptorProto field = 2;
|
||||
// and FieldDescriptorProto.name has field number 1:
|
||||
// optional string name = 1;
|
||||
//
|
||||
// Thus, the above path gives the location of a field name. If we removed
|
||||
// the last element:
|
||||
// [ 4, 3, 2, 7 ]
|
||||
// this path refers to the whole field declaration (from the beginning
|
||||
// of the label to the terminating semicolon).
|
||||
repeated int32 path = 1 [packed=true];
|
||||
|
||||
// Always has exactly three or four elements: start line, start column,
|
||||
// end line (optional, otherwise assumed same as start line), end column.
|
||||
// These are packed into a single field for efficiency. Note that line
|
||||
// and column numbers are zero-based -- typically you will want to add
|
||||
// 1 to each before displaying to a user.
|
||||
repeated int32 span = 2 [packed=true];
|
||||
|
||||
// If this SourceCodeInfo represents a complete declaration, these are any
|
||||
// comments appearing before and after the declaration which appear to be
|
||||
// attached to the declaration.
|
||||
//
|
||||
// A series of line comments appearing on consecutive lines, with no other
|
||||
// tokens appearing on those lines, will be treated as a single comment.
|
||||
//
|
||||
// Only the comment content is provided; comment markers (e.g. //) are
|
||||
// stripped out. For block comments, leading whitespace and an asterisk
|
||||
// will be stripped from the beginning of each line other than the first.
|
||||
// Newlines are included in the output.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// optional int32 foo = 1; // Comment attached to foo.
|
||||
// // Comment attached to bar.
|
||||
// optional int32 bar = 2;
|
||||
//
|
||||
// optional string baz = 3;
|
||||
// // Comment attached to baz.
|
||||
// // Another line attached to baz.
|
||||
//
|
||||
// // Comment attached to qux.
|
||||
// //
|
||||
// // Another line attached to qux.
|
||||
// optional double qux = 4;
|
||||
//
|
||||
// optional string corge = 5;
|
||||
// /* Block comment attached
|
||||
// * to corge. Leading asterisks
|
||||
// * will be removed. */
|
||||
// /* Block comment attached to
|
||||
// * grault. */
|
||||
// optional int32 grault = 6;
|
||||
optional string leading_comments = 3;
|
||||
optional string trailing_comments = 4;
|
||||
}
|
||||
}
|
@ -0,0 +1,367 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// Interface for manipulating databases of descriptors.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__
|
||||
#define GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
// Defined in this file.
|
||||
class DescriptorDatabase;
|
||||
class SimpleDescriptorDatabase;
|
||||
class EncodedDescriptorDatabase;
|
||||
class DescriptorPoolDatabase;
|
||||
class MergedDescriptorDatabase;
|
||||
|
||||
// Abstract interface for a database of descriptors.
|
||||
//
|
||||
// This is useful if you want to create a DescriptorPool which loads
|
||||
// descriptors on-demand from some sort of large database. If the database
|
||||
// is large, it may be inefficient to enumerate every .proto file inside it
|
||||
// calling DescriptorPool::BuildFile() for each one. Instead, a DescriptorPool
|
||||
// can be created which wraps a DescriptorDatabase and only builds particular
|
||||
// descriptors when they are needed.
|
||||
class LIBPROTOBUF_EXPORT DescriptorDatabase {
|
||||
public:
|
||||
inline DescriptorDatabase() {}
|
||||
virtual ~DescriptorDatabase();
|
||||
|
||||
// Find a file by file name. Fills in in *output and returns true if found.
|
||||
// Otherwise, returns false, leaving the contents of *output undefined.
|
||||
virtual bool FindFileByName(const string& filename,
|
||||
FileDescriptorProto* output) = 0;
|
||||
|
||||
// Find the file that declares the given fully-qualified symbol name.
|
||||
// If found, fills in *output and returns true, otherwise returns false
|
||||
// and leaves *output undefined.
|
||||
virtual bool FindFileContainingSymbol(const string& symbol_name,
|
||||
FileDescriptorProto* output) = 0;
|
||||
|
||||
// Find the file which defines an extension extending the given message type
|
||||
// with the given field number. If found, fills in *output and returns true,
|
||||
// otherwise returns false and leaves *output undefined. containing_type
|
||||
// must be a fully-qualified type name.
|
||||
virtual bool FindFileContainingExtension(const string& containing_type,
|
||||
int field_number,
|
||||
FileDescriptorProto* output) = 0;
|
||||
|
||||
// Finds the tag numbers used by all known extensions of
|
||||
// extendee_type, and appends them to output in an undefined
|
||||
// order. This method is best-effort: it's not guaranteed that the
|
||||
// database will find all extensions, and it's not guaranteed that
|
||||
// FindFileContainingExtension will return true on all of the found
|
||||
// numbers. Returns true if the search was successful, otherwise
|
||||
// returns false and leaves output unchanged.
|
||||
//
|
||||
// This method has a default implementation that always returns
|
||||
// false.
|
||||
virtual bool FindAllExtensionNumbers(const string& extendee_type,
|
||||
vector<int>* output) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorDatabase);
|
||||
};
|
||||
|
||||
// A DescriptorDatabase into which you can insert files manually.
|
||||
//
|
||||
// FindFileContainingSymbol() is fully-implemented. When you add a file, its
|
||||
// symbols will be indexed for this purpose. Note that the implementation
|
||||
// may return false positives, but only if it isn't possible for the symbol
|
||||
// to be defined in any other file. In particular, if a file defines a symbol
|
||||
// "Foo", then searching for "Foo.[anything]" will match that file. This way,
|
||||
// the database does not need to aggressively index all children of a symbol.
|
||||
//
|
||||
// FindFileContainingExtension() is mostly-implemented. It works if and only
|
||||
// if the original FieldDescriptorProto defining the extension has a
|
||||
// fully-qualified type name in its "extendee" field (i.e. starts with a '.').
|
||||
// If the extendee is a relative name, SimpleDescriptorDatabase will not
|
||||
// attempt to resolve the type, so it will not know what type the extension is
|
||||
// extending. Therefore, calling FindFileContainingExtension() with the
|
||||
// extension's containing type will never actually find that extension. Note
|
||||
// that this is an unlikely problem, as all FileDescriptorProtos created by the
|
||||
// protocol compiler (as well as ones created by calling
|
||||
// FileDescriptor::CopyTo()) will always use fully-qualified names for all
|
||||
// types. You only need to worry if you are constructing FileDescriptorProtos
|
||||
// yourself, or are calling compiler::Parser directly.
|
||||
class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
|
||||
public:
|
||||
SimpleDescriptorDatabase();
|
||||
~SimpleDescriptorDatabase();
|
||||
|
||||
// Adds the FileDescriptorProto to the database, making a copy. The object
|
||||
// can be deleted after Add() returns. Returns false if the file conflicted
|
||||
// with a file already in the database, in which case an error will have
|
||||
// been written to GOOGLE_LOG(ERROR).
|
||||
bool Add(const FileDescriptorProto& file);
|
||||
|
||||
// Adds the FileDescriptorProto to the database and takes ownership of it.
|
||||
bool AddAndOwn(const FileDescriptorProto* file);
|
||||
|
||||
// implements DescriptorDatabase -----------------------------------
|
||||
bool FindFileByName(const string& filename,
|
||||
FileDescriptorProto* output);
|
||||
bool FindFileContainingSymbol(const string& symbol_name,
|
||||
FileDescriptorProto* output);
|
||||
bool FindFileContainingExtension(const string& containing_type,
|
||||
int field_number,
|
||||
FileDescriptorProto* output);
|
||||
bool FindAllExtensionNumbers(const string& extendee_type,
|
||||
vector<int>* output);
|
||||
|
||||
private:
|
||||
// So that it can use DescriptorIndex.
|
||||
friend class EncodedDescriptorDatabase;
|
||||
|
||||
// An index mapping file names, symbol names, and extension numbers to
|
||||
// some sort of values.
|
||||
template <typename Value>
|
||||
class DescriptorIndex {
|
||||
public:
|
||||
// Helpers to recursively add particular descriptors and all their contents
|
||||
// to the index.
|
||||
bool AddFile(const FileDescriptorProto& file,
|
||||
Value value);
|
||||
bool AddSymbol(const string& name, Value value);
|
||||
bool AddNestedExtensions(const DescriptorProto& message_type,
|
||||
Value value);
|
||||
bool AddExtension(const FieldDescriptorProto& field,
|
||||
Value value);
|
||||
|
||||
Value FindFile(const string& filename);
|
||||
Value FindSymbol(const string& name);
|
||||
Value FindExtension(const string& containing_type, int field_number);
|
||||
bool FindAllExtensionNumbers(const string& containing_type,
|
||||
vector<int>* output);
|
||||
|
||||
private:
|
||||
map<string, Value> by_name_;
|
||||
map<string, Value> by_symbol_;
|
||||
map<pair<string, int>, Value> by_extension_;
|
||||
|
||||
// Invariant: The by_symbol_ map does not contain any symbols which are
|
||||
// prefixes of other symbols in the map. For example, "foo.bar" is a
|
||||
// prefix of "foo.bar.baz" (but is not a prefix of "foo.barbaz").
|
||||
//
|
||||
// This invariant is important because it means that given a symbol name,
|
||||
// we can find a key in the map which is a prefix of the symbol in O(lg n)
|
||||
// time, and we know that there is at most one such key.
|
||||
//
|
||||
// The prefix lookup algorithm works like so:
|
||||
// 1) Find the last key in the map which is less than or equal to the
|
||||
// search key.
|
||||
// 2) If the found key is a prefix of the search key, then return it.
|
||||
// Otherwise, there is no match.
|
||||
//
|
||||
// I am sure this algorithm has been described elsewhere, but since I
|
||||
// wasn't able to find it quickly I will instead prove that it works
|
||||
// myself. The key to the algorithm is that if a match exists, step (1)
|
||||
// will find it. Proof:
|
||||
// 1) Define the "search key" to be the key we are looking for, the "found
|
||||
// key" to be the key found in step (1), and the "match key" to be the
|
||||
// key which actually matches the serach key (i.e. the key we're trying
|
||||
// to find).
|
||||
// 2) The found key must be less than or equal to the search key by
|
||||
// definition.
|
||||
// 3) The match key must also be less than or equal to the search key
|
||||
// (because it is a prefix).
|
||||
// 4) The match key cannot be greater than the found key, because if it
|
||||
// were, then step (1) of the algorithm would have returned the match
|
||||
// key instead (since it finds the *greatest* key which is less than or
|
||||
// equal to the search key).
|
||||
// 5) Therefore, the found key must be between the match key and the search
|
||||
// key, inclusive.
|
||||
// 6) Since the search key must be a sub-symbol of the match key, if it is
|
||||
// not equal to the match key, then search_key[match_key.size()] must
|
||||
// be '.'.
|
||||
// 7) Since '.' sorts before any other character that is valid in a symbol
|
||||
// name, then if the found key is not equal to the match key, then
|
||||
// found_key[match_key.size()] must also be '.', because any other value
|
||||
// would make it sort after the search key.
|
||||
// 8) Therefore, if the found key is not equal to the match key, then the
|
||||
// found key must be a sub-symbol of the match key. However, this would
|
||||
// contradict our map invariant which says that no symbol in the map is
|
||||
// a sub-symbol of any other.
|
||||
// 9) Therefore, the found key must match the match key.
|
||||
//
|
||||
// The above proof assumes the match key exists. In the case that the
|
||||
// match key does not exist, then step (1) will return some other symbol.
|
||||
// That symbol cannot be a super-symbol of the search key since if it were,
|
||||
// then it would be a match, and we're assuming the match key doesn't exist.
|
||||
// Therefore, step 2 will correctly return no match.
|
||||
|
||||
// Find the last entry in the by_symbol_ map whose key is less than or
|
||||
// equal to the given name.
|
||||
typename map<string, Value>::iterator FindLastLessOrEqual(
|
||||
const string& name);
|
||||
|
||||
// True if either the arguments are equal or super_symbol identifies a
|
||||
// parent symbol of sub_symbol (e.g. "foo.bar" is a parent of
|
||||
// "foo.bar.baz", but not a parent of "foo.barbaz").
|
||||
bool IsSubSymbol(const string& sub_symbol, const string& super_symbol);
|
||||
|
||||
// Returns true if and only if all characters in the name are alphanumerics,
|
||||
// underscores, or periods.
|
||||
bool ValidateSymbolName(const string& name);
|
||||
};
|
||||
|
||||
|
||||
DescriptorIndex<const FileDescriptorProto*> index_;
|
||||
vector<const FileDescriptorProto*> files_to_delete_;
|
||||
|
||||
// If file is non-NULL, copy it into *output and return true, otherwise
|
||||
// return false.
|
||||
bool MaybeCopy(const FileDescriptorProto* file,
|
||||
FileDescriptorProto* output);
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SimpleDescriptorDatabase);
|
||||
};
|
||||
|
||||
// Very similar to SimpleDescriptorDatabase, but stores all the descriptors
|
||||
// as raw bytes and generally tries to use as little memory as possible.
|
||||
//
|
||||
// The same caveats regarding FindFileContainingExtension() apply as with
|
||||
// SimpleDescriptorDatabase.
|
||||
class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
|
||||
public:
|
||||
EncodedDescriptorDatabase();
|
||||
~EncodedDescriptorDatabase();
|
||||
|
||||
// Adds the FileDescriptorProto to the database. The descriptor is provided
|
||||
// in encoded form. The database does not make a copy of the bytes, nor
|
||||
// does it take ownership; it's up to the caller to make sure the bytes
|
||||
// remain valid for the life of the database. Returns false and logs an error
|
||||
// if the bytes are not a valid FileDescriptorProto or if the file conflicted
|
||||
// with a file already in the database.
|
||||
bool Add(const void* encoded_file_descriptor, int size);
|
||||
|
||||
// Like Add(), but makes a copy of the data, so that the caller does not
|
||||
// need to keep it around.
|
||||
bool AddCopy(const void* encoded_file_descriptor, int size);
|
||||
|
||||
// Like FindFileContainingSymbol but returns only the name of the file.
|
||||
bool FindNameOfFileContainingSymbol(const string& symbol_name,
|
||||
string* output);
|
||||
|
||||
// implements DescriptorDatabase -----------------------------------
|
||||
bool FindFileByName(const string& filename,
|
||||
FileDescriptorProto* output);
|
||||
bool FindFileContainingSymbol(const string& symbol_name,
|
||||
FileDescriptorProto* output);
|
||||
bool FindFileContainingExtension(const string& containing_type,
|
||||
int field_number,
|
||||
FileDescriptorProto* output);
|
||||
bool FindAllExtensionNumbers(const string& extendee_type,
|
||||
vector<int>* output);
|
||||
|
||||
private:
|
||||
SimpleDescriptorDatabase::DescriptorIndex<pair<const void*, int> > index_;
|
||||
vector<void*> files_to_delete_;
|
||||
|
||||
// If encoded_file.first is non-NULL, parse the data into *output and return
|
||||
// true, otherwise return false.
|
||||
bool MaybeParse(pair<const void*, int> encoded_file,
|
||||
FileDescriptorProto* output);
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase);
|
||||
};
|
||||
|
||||
// A DescriptorDatabase that fetches files from a given pool.
|
||||
class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {
|
||||
public:
|
||||
DescriptorPoolDatabase(const DescriptorPool& pool);
|
||||
~DescriptorPoolDatabase();
|
||||
|
||||
// implements DescriptorDatabase -----------------------------------
|
||||
bool FindFileByName(const string& filename,
|
||||
FileDescriptorProto* output);
|
||||
bool FindFileContainingSymbol(const string& symbol_name,
|
||||
FileDescriptorProto* output);
|
||||
bool FindFileContainingExtension(const string& containing_type,
|
||||
int field_number,
|
||||
FileDescriptorProto* output);
|
||||
bool FindAllExtensionNumbers(const string& extendee_type,
|
||||
vector<int>* output);
|
||||
|
||||
private:
|
||||
const DescriptorPool& pool_;
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPoolDatabase);
|
||||
};
|
||||
|
||||
// A DescriptorDatabase that wraps two or more others. It first searches the
|
||||
// first database and, if that fails, tries the second, and so on.
|
||||
class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
|
||||
public:
|
||||
// Merge just two databases. The sources remain property of the caller.
|
||||
MergedDescriptorDatabase(DescriptorDatabase* source1,
|
||||
DescriptorDatabase* source2);
|
||||
// Merge more than two databases. The sources remain property of the caller.
|
||||
// The vector may be deleted after the constructor returns but the
|
||||
// DescriptorDatabases need to stick around.
|
||||
MergedDescriptorDatabase(const vector<DescriptorDatabase*>& sources);
|
||||
~MergedDescriptorDatabase();
|
||||
|
||||
// implements DescriptorDatabase -----------------------------------
|
||||
bool FindFileByName(const string& filename,
|
||||
FileDescriptorProto* output);
|
||||
bool FindFileContainingSymbol(const string& symbol_name,
|
||||
FileDescriptorProto* output);
|
||||
bool FindFileContainingExtension(const string& containing_type,
|
||||
int field_number,
|
||||
FileDescriptorProto* output);
|
||||
// Merges the results of calling all databases. Returns true iff any
|
||||
// of the databases returned true.
|
||||
bool FindAllExtensionNumbers(const string& extendee_type,
|
||||
vector<int>* output);
|
||||
|
||||
private:
|
||||
vector<DescriptorDatabase*> sources_;
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase);
|
||||
};
|
||||
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__
|
@ -0,0 +1,136 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// Defines an implementation of Message which can emulate types which are not
|
||||
// known at compile-time.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
|
||||
#define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
|
||||
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
// Defined in other files.
|
||||
class Descriptor; // descriptor.h
|
||||
class DescriptorPool; // descriptor.h
|
||||
|
||||
// Constructs implementations of Message which can emulate types which are not
|
||||
// known at compile-time.
|
||||
//
|
||||
// Sometimes you want to be able to manipulate protocol types that you don't
|
||||
// know about at compile time. It would be nice to be able to construct
|
||||
// a Message object which implements the message type given by any arbitrary
|
||||
// Descriptor. DynamicMessage provides this.
|
||||
//
|
||||
// As it turns out, a DynamicMessage needs to construct extra
|
||||
// information about its type in order to operate. Most of this information
|
||||
// can be shared between all DynamicMessages of the same type. But, caching
|
||||
// this information in some sort of global map would be a bad idea, since
|
||||
// the cached information for a particular descriptor could outlive the
|
||||
// descriptor itself. To avoid this problem, DynamicMessageFactory
|
||||
// encapsulates this "cache". All DynamicMessages of the same type created
|
||||
// from the same factory will share the same support data. Any Descriptors
|
||||
// used with a particular factory must outlive the factory.
|
||||
class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
|
||||
public:
|
||||
// Construct a DynamicMessageFactory that will search for extensions in
|
||||
// the DescriptorPool in which the extendee is defined.
|
||||
DynamicMessageFactory();
|
||||
|
||||
// Construct a DynamicMessageFactory that will search for extensions in
|
||||
// the given DescriptorPool.
|
||||
//
|
||||
// DEPRECATED: Use CodedInputStream::SetExtensionRegistry() to tell the
|
||||
// parser to look for extensions in an alternate pool. However, note that
|
||||
// this is almost never what you want to do. Almost all users should use
|
||||
// the zero-arg constructor.
|
||||
DynamicMessageFactory(const DescriptorPool* pool);
|
||||
|
||||
~DynamicMessageFactory();
|
||||
|
||||
// Call this to tell the DynamicMessageFactory that if it is given a
|
||||
// Descriptor d for which:
|
||||
// d->file()->pool() == DescriptorPool::generated_pool(),
|
||||
// then it should delegate to MessageFactory::generated_factory() instead
|
||||
// of constructing a dynamic implementation of the message. In theory there
|
||||
// is no down side to doing this, so it may become the default in the future.
|
||||
void SetDelegateToGeneratedFactory(bool enable) {
|
||||
delegate_to_generated_factory_ = enable;
|
||||
}
|
||||
|
||||
// implements MessageFactory ---------------------------------------
|
||||
|
||||
// Given a Descriptor, constructs the default (prototype) Message of that
|
||||
// type. You can then call that message's New() method to construct a
|
||||
// mutable message of that type.
|
||||
//
|
||||
// Calling this method twice with the same Descriptor returns the same
|
||||
// object. The returned object remains property of the factory and will
|
||||
// be destroyed when the factory is destroyed. Also, any objects created
|
||||
// by calling the prototype's New() method share some data with the
|
||||
// prototype, so these must be destroyed before the DynamicMessageFactory
|
||||
// is destroyed.
|
||||
//
|
||||
// The given descriptor must outlive the returned message, and hence must
|
||||
// outlive the DynamicMessageFactory.
|
||||
//
|
||||
// The method is thread-safe.
|
||||
const Message* GetPrototype(const Descriptor* type);
|
||||
|
||||
private:
|
||||
const DescriptorPool* pool_;
|
||||
bool delegate_to_generated_factory_;
|
||||
|
||||
// This struct just contains a hash_map. We can't #include <google/protobuf/stubs/hash.h> from
|
||||
// this header due to hacks needed for hash_map portability in the open source
|
||||
// release. Namely, stubs/hash.h, which defines hash_map portably, is not a
|
||||
// public header (for good reason), but dynamic_message.h is, and public
|
||||
// headers may only #include other public headers.
|
||||
struct PrototypeMap;
|
||||
scoped_ptr<PrototypeMap> prototypes_;
|
||||
mutable Mutex prototypes_mutex_;
|
||||
|
||||
friend class DynamicMessage;
|
||||
const Message* GetPrototypeNoLock(const Descriptor* type);
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory);
|
||||
};
|
||||
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,85 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: jasonh@google.com (Jason Hsueh)
|
||||
//
|
||||
// This header is logically internal, but is made public because it is used
|
||||
// from protocol-compiler-generated code, which may reside in other components.
|
||||
// It provides reflection support for generated enums, and is included in
|
||||
// generated .pb.h files and should have minimal dependencies. The methods are
|
||||
// implemented in generated_message_reflection.cc.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
|
||||
#define GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
class EnumDescriptor;
|
||||
} // namespace protobuf
|
||||
|
||||
namespace protobuf {
|
||||
|
||||
// Returns the EnumDescriptor for enum type E, which must be a
|
||||
// proto-declared enum type. Code generated by the protocol compiler
|
||||
// will include specializations of this template for each enum type declared.
|
||||
template <typename E>
|
||||
const EnumDescriptor* GetEnumDescriptor();
|
||||
|
||||
namespace internal {
|
||||
|
||||
// Helper for EnumType_Parse functions: try to parse the string 'name' as an
|
||||
// enum name of the given type, returning true and filling in value on success,
|
||||
// or returning false and leaving value unchanged on failure.
|
||||
LIBPROTOBUF_EXPORT bool ParseNamedEnum(const EnumDescriptor* descriptor,
|
||||
const string& name,
|
||||
int* value);
|
||||
|
||||
template<typename EnumType>
|
||||
bool ParseNamedEnum(const EnumDescriptor* descriptor,
|
||||
const string& name,
|
||||
EnumType* value) {
|
||||
int tmp;
|
||||
if (!ParseNamedEnum(descriptor, name, &tmp)) return false;
|
||||
*value = static_cast<EnumType>(tmp);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Just a wrapper around printing the name of a value. The main point of this
|
||||
// function is not to be inlined, so that you can do this without including
|
||||
// descriptor.h.
|
||||
LIBPROTOBUF_EXPORT const string& NameOfEnum(const EnumDescriptor* descriptor, int value);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
|
@ -0,0 +1,419 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// This header is logically internal, but is made public because it is used
|
||||
// from protocol-compiler-generated code, which may reside in other components.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__
|
||||
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
// TODO(jasonh): Remove this once the compiler change to directly include this
|
||||
// is released to components.
|
||||
#include <google/protobuf/generated_enum_reflection.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/unknown_field_set.h>
|
||||
|
||||
|
||||
namespace google {
|
||||
namespace upb {
|
||||
namespace google_opensource {
|
||||
class GMR_Handlers;
|
||||
} // namespace google_opensource
|
||||
} // namespace upb
|
||||
|
||||
namespace protobuf {
|
||||
class DescriptorPool;
|
||||
}
|
||||
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
// Defined in this file.
|
||||
class GeneratedMessageReflection;
|
||||
|
||||
// Defined in other files.
|
||||
class ExtensionSet; // extension_set.h
|
||||
|
||||
// THIS CLASS IS NOT INTENDED FOR DIRECT USE. It is intended for use
|
||||
// by generated code. This class is just a big hack that reduces code
|
||||
// size.
|
||||
//
|
||||
// A GeneratedMessageReflection is an implementation of Reflection
|
||||
// which expects all fields to be backed by simple variables located in
|
||||
// memory. The locations are given using a base pointer and a set of
|
||||
// offsets.
|
||||
//
|
||||
// It is required that the user represents fields of each type in a standard
|
||||
// way, so that GeneratedMessageReflection can cast the void* pointer to
|
||||
// the appropriate type. For primitive fields and string fields, each field
|
||||
// should be represented using the obvious C++ primitive type. Enums and
|
||||
// Messages are different:
|
||||
// - Singular Message fields are stored as a pointer to a Message. These
|
||||
// should start out NULL, except for in the default instance where they
|
||||
// should start out pointing to other default instances.
|
||||
// - Enum fields are stored as an int. This int must always contain
|
||||
// a valid value, such that EnumDescriptor::FindValueByNumber() would
|
||||
// not return NULL.
|
||||
// - Repeated fields are stored as RepeatedFields or RepeatedPtrFields
|
||||
// of whatever type the individual field would be. Strings and
|
||||
// Messages use RepeatedPtrFields while everything else uses
|
||||
// RepeatedFields.
|
||||
class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
|
||||
public:
|
||||
// Constructs a GeneratedMessageReflection.
|
||||
// Parameters:
|
||||
// descriptor: The descriptor for the message type being implemented.
|
||||
// default_instance: The default instance of the message. This is only
|
||||
// used to obtain pointers to default instances of embedded
|
||||
// messages, which GetMessage() will return if the particular
|
||||
// sub-message has not been initialized yet. (Thus, all
|
||||
// embedded message fields *must* have non-NULL pointers
|
||||
// in the default instance.)
|
||||
// offsets: An array of ints giving the byte offsets, relative to
|
||||
// the start of the message object, of each field. These can
|
||||
// be computed at compile time using the
|
||||
// GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro, defined
|
||||
// below.
|
||||
// has_bits_offset: Offset in the message of an array of uint32s of size
|
||||
// descriptor->field_count()/32, rounded up. This is a
|
||||
// bitfield where each bit indicates whether or not the
|
||||
// corresponding field of the message has been initialized.
|
||||
// The bit for field index i is obtained by the expression:
|
||||
// has_bits[i / 32] & (1 << (i % 32))
|
||||
// unknown_fields_offset: Offset in the message of the UnknownFieldSet for
|
||||
// the message.
|
||||
// extensions_offset: Offset in the message of the ExtensionSet for the
|
||||
// message, or -1 if the message type has no extension
|
||||
// ranges.
|
||||
// pool: DescriptorPool to search for extension definitions. Only
|
||||
// used by FindKnownExtensionByName() and
|
||||
// FindKnownExtensionByNumber().
|
||||
// factory: MessageFactory to use to construct extension messages.
|
||||
// object_size: The size of a message object of this type, as measured
|
||||
// by sizeof().
|
||||
GeneratedMessageReflection(const Descriptor* descriptor,
|
||||
const Message* default_instance,
|
||||
const int offsets[],
|
||||
int has_bits_offset,
|
||||
int unknown_fields_offset,
|
||||
int extensions_offset,
|
||||
const DescriptorPool* pool,
|
||||
MessageFactory* factory,
|
||||
int object_size);
|
||||
~GeneratedMessageReflection();
|
||||
|
||||
// implements Reflection -------------------------------------------
|
||||
|
||||
const UnknownFieldSet& GetUnknownFields(const Message& message) const;
|
||||
UnknownFieldSet* MutableUnknownFields(Message* message) const;
|
||||
|
||||
int SpaceUsed(const Message& message) const;
|
||||
|
||||
bool HasField(const Message& message, const FieldDescriptor* field) const;
|
||||
int FieldSize(const Message& message, const FieldDescriptor* field) const;
|
||||
void ClearField(Message* message, const FieldDescriptor* field) const;
|
||||
void RemoveLast(Message* message, const FieldDescriptor* field) const;
|
||||
Message* ReleaseLast(Message* message, const FieldDescriptor* field) const;
|
||||
void Swap(Message* message1, Message* message2) const;
|
||||
void SwapElements(Message* message, const FieldDescriptor* field,
|
||||
int index1, int index2) const;
|
||||
void ListFields(const Message& message,
|
||||
vector<const FieldDescriptor*>* output) const;
|
||||
|
||||
int32 GetInt32 (const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
int64 GetInt64 (const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
uint32 GetUInt32(const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
uint64 GetUInt64(const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
float GetFloat (const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
double GetDouble(const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
bool GetBool (const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
string GetString(const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
const string& GetStringReference(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
string* scratch) const;
|
||||
const EnumValueDescriptor* GetEnum(const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
const Message& GetMessage(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
MessageFactory* factory = NULL) const;
|
||||
|
||||
void SetInt32 (Message* message,
|
||||
const FieldDescriptor* field, int32 value) const;
|
||||
void SetInt64 (Message* message,
|
||||
const FieldDescriptor* field, int64 value) const;
|
||||
void SetUInt32(Message* message,
|
||||
const FieldDescriptor* field, uint32 value) const;
|
||||
void SetUInt64(Message* message,
|
||||
const FieldDescriptor* field, uint64 value) const;
|
||||
void SetFloat (Message* message,
|
||||
const FieldDescriptor* field, float value) const;
|
||||
void SetDouble(Message* message,
|
||||
const FieldDescriptor* field, double value) const;
|
||||
void SetBool (Message* message,
|
||||
const FieldDescriptor* field, bool value) const;
|
||||
void SetString(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
const string& value) const;
|
||||
void SetEnum (Message* message, const FieldDescriptor* field,
|
||||
const EnumValueDescriptor* value) const;
|
||||
Message* MutableMessage(Message* message, const FieldDescriptor* field,
|
||||
MessageFactory* factory = NULL) const;
|
||||
Message* ReleaseMessage(Message* message, const FieldDescriptor* field,
|
||||
MessageFactory* factory = NULL) const;
|
||||
|
||||
int32 GetRepeatedInt32 (const Message& message,
|
||||
const FieldDescriptor* field, int index) const;
|
||||
int64 GetRepeatedInt64 (const Message& message,
|
||||
const FieldDescriptor* field, int index) const;
|
||||
uint32 GetRepeatedUInt32(const Message& message,
|
||||
const FieldDescriptor* field, int index) const;
|
||||
uint64 GetRepeatedUInt64(const Message& message,
|
||||
const FieldDescriptor* field, int index) const;
|
||||
float GetRepeatedFloat (const Message& message,
|
||||
const FieldDescriptor* field, int index) const;
|
||||
double GetRepeatedDouble(const Message& message,
|
||||
const FieldDescriptor* field, int index) const;
|
||||
bool GetRepeatedBool (const Message& message,
|
||||
const FieldDescriptor* field, int index) const;
|
||||
string GetRepeatedString(const Message& message,
|
||||
const FieldDescriptor* field, int index) const;
|
||||
const string& GetRepeatedStringReference(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index, string* scratch) const;
|
||||
const EnumValueDescriptor* GetRepeatedEnum(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const;
|
||||
const Message& GetRepeatedMessage(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const;
|
||||
|
||||
// Set the value of a field.
|
||||
void SetRepeatedInt32 (Message* message,
|
||||
const FieldDescriptor* field, int index, int32 value) const;
|
||||
void SetRepeatedInt64 (Message* message,
|
||||
const FieldDescriptor* field, int index, int64 value) const;
|
||||
void SetRepeatedUInt32(Message* message,
|
||||
const FieldDescriptor* field, int index, uint32 value) const;
|
||||
void SetRepeatedUInt64(Message* message,
|
||||
const FieldDescriptor* field, int index, uint64 value) const;
|
||||
void SetRepeatedFloat (Message* message,
|
||||
const FieldDescriptor* field, int index, float value) const;
|
||||
void SetRepeatedDouble(Message* message,
|
||||
const FieldDescriptor* field, int index, double value) const;
|
||||
void SetRepeatedBool (Message* message,
|
||||
const FieldDescriptor* field, int index, bool value) const;
|
||||
void SetRepeatedString(Message* message,
|
||||
const FieldDescriptor* field, int index,
|
||||
const string& value) const;
|
||||
void SetRepeatedEnum(Message* message, const FieldDescriptor* field,
|
||||
int index, const EnumValueDescriptor* value) const;
|
||||
// Get a mutable pointer to a field with a message type.
|
||||
Message* MutableRepeatedMessage(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const;
|
||||
|
||||
void AddInt32 (Message* message,
|
||||
const FieldDescriptor* field, int32 value) const;
|
||||
void AddInt64 (Message* message,
|
||||
const FieldDescriptor* field, int64 value) const;
|
||||
void AddUInt32(Message* message,
|
||||
const FieldDescriptor* field, uint32 value) const;
|
||||
void AddUInt64(Message* message,
|
||||
const FieldDescriptor* field, uint64 value) const;
|
||||
void AddFloat (Message* message,
|
||||
const FieldDescriptor* field, float value) const;
|
||||
void AddDouble(Message* message,
|
||||
const FieldDescriptor* field, double value) const;
|
||||
void AddBool (Message* message,
|
||||
const FieldDescriptor* field, bool value) const;
|
||||
void AddString(Message* message,
|
||||
const FieldDescriptor* field, const string& value) const;
|
||||
void AddEnum(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
const EnumValueDescriptor* value) const;
|
||||
Message* AddMessage(Message* message, const FieldDescriptor* field,
|
||||
MessageFactory* factory = NULL) const;
|
||||
|
||||
const FieldDescriptor* FindKnownExtensionByName(const string& name) const;
|
||||
const FieldDescriptor* FindKnownExtensionByNumber(int number) const;
|
||||
|
||||
protected:
|
||||
virtual void* MutableRawRepeatedField(
|
||||
Message* message, const FieldDescriptor* field, FieldDescriptor::CppType,
|
||||
int ctype, const Descriptor* desc) const;
|
||||
|
||||
private:
|
||||
friend class GeneratedMessage;
|
||||
|
||||
// To parse directly into a proto2 generated class, the class GMR_Handlers
|
||||
// needs access to member offsets and hasbits.
|
||||
friend class LIBPROTOBUF_EXPORT upb::google_opensource::GMR_Handlers;
|
||||
|
||||
const Descriptor* descriptor_;
|
||||
const Message* default_instance_;
|
||||
const int* offsets_;
|
||||
|
||||
int has_bits_offset_;
|
||||
int unknown_fields_offset_;
|
||||
int extensions_offset_;
|
||||
int object_size_;
|
||||
|
||||
const DescriptorPool* descriptor_pool_;
|
||||
MessageFactory* message_factory_;
|
||||
|
||||
template <typename Type>
|
||||
inline const Type& GetRaw(const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
template <typename Type>
|
||||
inline Type* MutableRaw(Message* message,
|
||||
const FieldDescriptor* field) const;
|
||||
template <typename Type>
|
||||
inline const Type& DefaultRaw(const FieldDescriptor* field) const;
|
||||
|
||||
inline const uint32* GetHasBits(const Message& message) const;
|
||||
inline uint32* MutableHasBits(Message* message) const;
|
||||
inline const ExtensionSet& GetExtensionSet(const Message& message) const;
|
||||
inline ExtensionSet* MutableExtensionSet(Message* message) const;
|
||||
|
||||
inline bool HasBit(const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
inline void SetBit(Message* message,
|
||||
const FieldDescriptor* field) const;
|
||||
inline void ClearBit(Message* message,
|
||||
const FieldDescriptor* field) const;
|
||||
|
||||
template <typename Type>
|
||||
inline const Type& GetField(const Message& message,
|
||||
const FieldDescriptor* field) const;
|
||||
template <typename Type>
|
||||
inline void SetField(Message* message,
|
||||
const FieldDescriptor* field, const Type& value) const;
|
||||
template <typename Type>
|
||||
inline Type* MutableField(Message* message,
|
||||
const FieldDescriptor* field) const;
|
||||
template <typename Type>
|
||||
inline const Type& GetRepeatedField(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const;
|
||||
template <typename Type>
|
||||
inline const Type& GetRepeatedPtrField(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const;
|
||||
template <typename Type>
|
||||
inline void SetRepeatedField(Message* message,
|
||||
const FieldDescriptor* field, int index,
|
||||
Type value) const;
|
||||
template <typename Type>
|
||||
inline Type* MutableRepeatedField(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const;
|
||||
template <typename Type>
|
||||
inline void AddField(Message* message,
|
||||
const FieldDescriptor* field, const Type& value) const;
|
||||
template <typename Type>
|
||||
inline Type* AddField(Message* message,
|
||||
const FieldDescriptor* field) const;
|
||||
|
||||
int GetExtensionNumberOrDie(const Descriptor* type) const;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratedMessageReflection);
|
||||
};
|
||||
|
||||
// Returns the offset of the given field within the given aggregate type.
|
||||
// This is equivalent to the ANSI C offsetof() macro. However, according
|
||||
// to the C++ standard, offsetof() only works on POD types, and GCC
|
||||
// enforces this requirement with a warning. In practice, this rule is
|
||||
// unnecessarily strict; there is probably no compiler or platform on
|
||||
// which the offsets of the direct fields of a class are non-constant.
|
||||
// Fields inherited from superclasses *can* have non-constant offsets,
|
||||
// but that's not what this macro will be used for.
|
||||
//
|
||||
// Note that we calculate relative to the pointer value 16 here since if we
|
||||
// just use zero, GCC complains about dereferencing a NULL pointer. We
|
||||
// choose 16 rather than some other number just in case the compiler would
|
||||
// be confused by an unaligned pointer.
|
||||
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
|
||||
static_cast<int>( \
|
||||
reinterpret_cast<const char*>( \
|
||||
&reinterpret_cast<const TYPE*>(16)->FIELD) - \
|
||||
reinterpret_cast<const char*>(16))
|
||||
|
||||
// There are some places in proto2 where dynamic_cast would be useful as an
|
||||
// optimization. For example, take Message::MergeFrom(const Message& other).
|
||||
// For a given generated message FooMessage, we generate these two methods:
|
||||
// void MergeFrom(const FooMessage& other);
|
||||
// void MergeFrom(const Message& other);
|
||||
// The former method can be implemented directly in terms of FooMessage's
|
||||
// inline accessors, but the latter method must work with the reflection
|
||||
// interface. However, if the parameter to the latter method is actually of
|
||||
// type FooMessage, then we'd like to be able to just call the other method
|
||||
// as an optimization. So, we use dynamic_cast to check this.
|
||||
//
|
||||
// That said, dynamic_cast requires RTTI, which many people like to disable
|
||||
// for performance and code size reasons. When RTTI is not available, we
|
||||
// still need to produce correct results. So, in this case we have to fall
|
||||
// back to using reflection, which is what we would have done anyway if the
|
||||
// objects were not of the exact same class.
|
||||
//
|
||||
// dynamic_cast_if_available() implements this logic. If RTTI is
|
||||
// enabled, it does a dynamic_cast. If RTTI is disabled, it just returns
|
||||
// NULL.
|
||||
//
|
||||
// If you need to compile without RTTI, simply #define GOOGLE_PROTOBUF_NO_RTTI.
|
||||
// On MSVC, this should be detected automatically.
|
||||
template<typename To, typename From>
|
||||
inline To dynamic_cast_if_available(From from) {
|
||||
#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI))
|
||||
return NULL;
|
||||
#else
|
||||
return dynamic_cast<To>(from);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__
|
@ -0,0 +1,77 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// This file contains miscellaneous helper code used by generated code --
|
||||
// including lite types -- but which should not be used directly by users.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__
|
||||
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
// Annotation for the compiler to emit a deprecation message if a field marked
|
||||
// with option 'deprecated=true' is used in the code, or for other things in
|
||||
// generated code which are deprecated.
|
||||
//
|
||||
// For internal use in the pb.cc files, deprecation warnings are suppressed
|
||||
// there.
|
||||
#undef DEPRECATED_PROTOBUF_FIELD
|
||||
#define PROTOBUF_DEPRECATED
|
||||
|
||||
|
||||
// Constants for special floating point values.
|
||||
LIBPROTOBUF_EXPORT double Infinity();
|
||||
LIBPROTOBUF_EXPORT double NaN();
|
||||
|
||||
// Constant used for empty default strings.
|
||||
LIBPROTOBUF_EXPORT extern const ::std::string kEmptyString;
|
||||
|
||||
// Defined in generated_message_reflection.cc -- not actually part of the lite
|
||||
// library.
|
||||
//
|
||||
// TODO(jasonh): The various callers get this declaration from a variety of
|
||||
// places: probably in most cases repeated_field.h. Clean these up so they all
|
||||
// get the declaration from this file.
|
||||
LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,209 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: brianolson@google.com (Brian Olson)
|
||||
//
|
||||
// This file contains the definition for classes GzipInputStream and
|
||||
// GzipOutputStream.
|
||||
//
|
||||
// GzipInputStream decompresses data from an underlying
|
||||
// ZeroCopyInputStream and provides the decompressed data as a
|
||||
// ZeroCopyInputStream.
|
||||
//
|
||||
// GzipOutputStream is an ZeroCopyOutputStream that compresses data to
|
||||
// an underlying ZeroCopyOutputStream.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
|
||||
#define GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/io/zero_copy_stream.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
|
||||
// A ZeroCopyInputStream that reads compressed data through zlib
|
||||
class LIBPROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {
|
||||
public:
|
||||
// Format key for constructor
|
||||
enum Format {
|
||||
// zlib will autodetect gzip header or deflate stream
|
||||
AUTO = 0,
|
||||
|
||||
// GZIP streams have some extra header data for file attributes.
|
||||
GZIP = 1,
|
||||
|
||||
// Simpler zlib stream format.
|
||||
ZLIB = 2,
|
||||
};
|
||||
|
||||
// buffer_size and format may be -1 for default of 64kB and GZIP format
|
||||
explicit GzipInputStream(
|
||||
ZeroCopyInputStream* sub_stream,
|
||||
Format format = AUTO,
|
||||
int buffer_size = -1);
|
||||
virtual ~GzipInputStream();
|
||||
|
||||
// Return last error message or NULL if no error.
|
||||
inline const char* ZlibErrorMessage() const {
|
||||
return zcontext_.msg;
|
||||
}
|
||||
inline int ZlibErrorCode() const {
|
||||
return zerror_;
|
||||
}
|
||||
|
||||
// implements ZeroCopyInputStream ----------------------------------
|
||||
bool Next(const void** data, int* size);
|
||||
void BackUp(int count);
|
||||
bool Skip(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
Format format_;
|
||||
|
||||
ZeroCopyInputStream* sub_stream_;
|
||||
|
||||
z_stream zcontext_;
|
||||
int zerror_;
|
||||
|
||||
void* output_buffer_;
|
||||
void* output_position_;
|
||||
size_t output_buffer_length_;
|
||||
|
||||
int Inflate(int flush);
|
||||
void DoNextOutput(const void** data, int* size);
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream);
|
||||
};
|
||||
|
||||
|
||||
class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
|
||||
public:
|
||||
// Format key for constructor
|
||||
enum Format {
|
||||
// GZIP streams have some extra header data for file attributes.
|
||||
GZIP = 1,
|
||||
|
||||
// Simpler zlib stream format.
|
||||
ZLIB = 2,
|
||||
};
|
||||
|
||||
struct LIBPROTOBUF_EXPORT Options {
|
||||
// Defaults to GZIP.
|
||||
Format format;
|
||||
|
||||
// What size buffer to use internally. Defaults to 64kB.
|
||||
int buffer_size;
|
||||
|
||||
// A number between 0 and 9, where 0 is no compression and 9 is best
|
||||
// compression. Defaults to Z_DEFAULT_COMPRESSION (see zlib.h).
|
||||
int compression_level;
|
||||
|
||||
// Defaults to Z_DEFAULT_STRATEGY. Can also be set to Z_FILTERED,
|
||||
// Z_HUFFMAN_ONLY, or Z_RLE. See the documentation for deflateInit2 in
|
||||
// zlib.h for definitions of these constants.
|
||||
int compression_strategy;
|
||||
|
||||
Options(); // Initializes with default values.
|
||||
};
|
||||
|
||||
// Create a GzipOutputStream with default options.
|
||||
explicit GzipOutputStream(ZeroCopyOutputStream* sub_stream);
|
||||
|
||||
// Create a GzipOutputStream with the given options.
|
||||
GzipOutputStream(
|
||||
ZeroCopyOutputStream* sub_stream,
|
||||
const Options& options);
|
||||
|
||||
virtual ~GzipOutputStream();
|
||||
|
||||
// Return last error message or NULL if no error.
|
||||
inline const char* ZlibErrorMessage() const {
|
||||
return zcontext_.msg;
|
||||
}
|
||||
inline int ZlibErrorCode() const {
|
||||
return zerror_;
|
||||
}
|
||||
|
||||
// Flushes data written so far to zipped data in the underlying stream.
|
||||
// It is the caller's responsibility to flush the underlying stream if
|
||||
// necessary.
|
||||
// Compression may be less efficient stopping and starting around flushes.
|
||||
// Returns true if no error.
|
||||
//
|
||||
// Please ensure that block size is > 6. Here is an excerpt from the zlib
|
||||
// doc that explains why:
|
||||
//
|
||||
// In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out
|
||||
// is greater than six to avoid repeated flush markers due to
|
||||
// avail_out == 0 on return.
|
||||
bool Flush();
|
||||
|
||||
// Writes out all data and closes the gzip stream.
|
||||
// It is the caller's responsibility to close the underlying stream if
|
||||
// necessary.
|
||||
// Returns true if no error.
|
||||
bool Close();
|
||||
|
||||
// implements ZeroCopyOutputStream ---------------------------------
|
||||
bool Next(void** data, int* size);
|
||||
void BackUp(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
ZeroCopyOutputStream* sub_stream_;
|
||||
// Result from calling Next() on sub_stream_
|
||||
void* sub_data_;
|
||||
int sub_data_size_;
|
||||
|
||||
z_stream zcontext_;
|
||||
int zerror_;
|
||||
void* input_buffer_;
|
||||
size_t input_buffer_length_;
|
||||
|
||||
// Shared constructor code.
|
||||
void Init(ZeroCopyOutputStream* sub_stream, const Options& options);
|
||||
|
||||
// Do some compression.
|
||||
// Takes zlib flush mode.
|
||||
// Returns zlib error code.
|
||||
int Deflate(int flush);
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipOutputStream);
|
||||
};
|
||||
|
||||
} // namespace io
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
|
@ -0,0 +1,136 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// Utility class for writing text to a ZeroCopyOutputStream.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_IO_PRINTER_H__
|
||||
#define GOOGLE_PROTOBUF_IO_PRINTER_H__
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
|
||||
class ZeroCopyOutputStream; // zero_copy_stream.h
|
||||
|
||||
// This simple utility class assists in code generation. It basically
|
||||
// allows the caller to define a set of variables and then output some
|
||||
// text with variable substitutions. Example usage:
|
||||
//
|
||||
// Printer printer(output, '$');
|
||||
// map<string, string> vars;
|
||||
// vars["name"] = "Bob";
|
||||
// printer.Print(vars, "My name is $name$.");
|
||||
//
|
||||
// The above writes "My name is Bob." to the output stream.
|
||||
//
|
||||
// Printer aggressively enforces correct usage, crashing (with assert failures)
|
||||
// in the case of undefined variables in debug builds. This helps greatly in
|
||||
// debugging code which uses it.
|
||||
class LIBPROTOBUF_EXPORT Printer {
|
||||
public:
|
||||
// Create a printer that writes text to the given output stream. Use the
|
||||
// given character as the delimiter for variables.
|
||||
Printer(ZeroCopyOutputStream* output, char variable_delimiter);
|
||||
~Printer();
|
||||
|
||||
// Print some text after applying variable substitutions. If a particular
|
||||
// variable in the text is not defined, this will crash. Variables to be
|
||||
// substituted are identified by their names surrounded by delimiter
|
||||
// characters (as given to the constructor). The variable bindings are
|
||||
// defined by the given map.
|
||||
void Print(const map<string, string>& variables, const char* text);
|
||||
|
||||
// Like the first Print(), except the substitutions are given as parameters.
|
||||
void Print(const char* text);
|
||||
// Like the first Print(), except the substitutions are given as parameters.
|
||||
void Print(const char* text, const char* variable, const string& value);
|
||||
// Like the first Print(), except the substitutions are given as parameters.
|
||||
void Print(const char* text, const char* variable1, const string& value1,
|
||||
const char* variable2, const string& value2);
|
||||
// Like the first Print(), except the substitutions are given as parameters.
|
||||
void Print(const char* text, const char* variable1, const string& value1,
|
||||
const char* variable2, const string& value2,
|
||||
const char* variable3, const string& value3);
|
||||
// TODO(kenton): Overloaded versions with more variables? Three seems
|
||||
// to be enough.
|
||||
|
||||
// Indent text by two spaces. After calling Indent(), two spaces will be
|
||||
// inserted at the beginning of each line of text. Indent() may be called
|
||||
// multiple times to produce deeper indents.
|
||||
void Indent();
|
||||
|
||||
// Reduces the current indent level by two spaces, or crashes if the indent
|
||||
// level is zero.
|
||||
void Outdent();
|
||||
|
||||
// Write a string to the output buffer.
|
||||
// This method does not look for newlines to add indentation.
|
||||
void PrintRaw(const string& data);
|
||||
|
||||
// Write a zero-delimited string to output buffer.
|
||||
// This method does not look for newlines to add indentation.
|
||||
void PrintRaw(const char* data);
|
||||
|
||||
// Write some bytes to the output buffer.
|
||||
// This method does not look for newlines to add indentation.
|
||||
void WriteRaw(const char* data, int size);
|
||||
|
||||
// True if any write to the underlying stream failed. (We don't just
|
||||
// crash in this case because this is an I/O failure, not a programming
|
||||
// error.)
|
||||
bool failed() const { return failed_; }
|
||||
|
||||
private:
|
||||
const char variable_delimiter_;
|
||||
|
||||
ZeroCopyOutputStream* const output_;
|
||||
char* buffer_;
|
||||
int buffer_size_;
|
||||
|
||||
string indent_;
|
||||
bool at_start_of_line_;
|
||||
bool failed_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Printer);
|
||||
};
|
||||
|
||||
} // namespace io
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_IO_PRINTER_H__
|
@ -0,0 +1,384 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// Class for parsing tokenized text from a ZeroCopyInputStream.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_IO_TOKENIZER_H__
|
||||
#define GOOGLE_PROTOBUF_IO_TOKENIZER_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
|
||||
class ZeroCopyInputStream; // zero_copy_stream.h
|
||||
|
||||
// Defined in this file.
|
||||
class ErrorCollector;
|
||||
class Tokenizer;
|
||||
|
||||
// Abstract interface for an object which collects the errors that occur
|
||||
// during parsing. A typical implementation might simply print the errors
|
||||
// to stdout.
|
||||
class LIBPROTOBUF_EXPORT ErrorCollector {
|
||||
public:
|
||||
inline ErrorCollector() {}
|
||||
virtual ~ErrorCollector();
|
||||
|
||||
// Indicates that there was an error in the input at the given line and
|
||||
// column numbers. The numbers are zero-based, so you may want to add
|
||||
// 1 to each before printing them.
|
||||
virtual void AddError(int line, int column, const string& message) = 0;
|
||||
|
||||
// Indicates that there was a warning in the input at the given line and
|
||||
// column numbers. The numbers are zero-based, so you may want to add
|
||||
// 1 to each before printing them.
|
||||
virtual void AddWarning(int line, int column, const string& message) { }
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector);
|
||||
};
|
||||
|
||||
// This class converts a stream of raw text into a stream of tokens for
|
||||
// the protocol definition parser to parse. The tokens recognized are
|
||||
// similar to those that make up the C language; see the TokenType enum for
|
||||
// precise descriptions. Whitespace and comments are skipped. By default,
|
||||
// C- and C++-style comments are recognized, but other styles can be used by
|
||||
// calling set_comment_style().
|
||||
class LIBPROTOBUF_EXPORT Tokenizer {
|
||||
public:
|
||||
// Construct a Tokenizer that reads and tokenizes text from the given
|
||||
// input stream and writes errors to the given error_collector.
|
||||
// The caller keeps ownership of input and error_collector.
|
||||
Tokenizer(ZeroCopyInputStream* input, ErrorCollector* error_collector);
|
||||
~Tokenizer();
|
||||
|
||||
enum TokenType {
|
||||
TYPE_START, // Next() has not yet been called.
|
||||
TYPE_END, // End of input reached. "text" is empty.
|
||||
|
||||
TYPE_IDENTIFIER, // A sequence of letters, digits, and underscores, not
|
||||
// starting with a digit. It is an error for a number
|
||||
// to be followed by an identifier with no space in
|
||||
// between.
|
||||
TYPE_INTEGER, // A sequence of digits representing an integer. Normally
|
||||
// the digits are decimal, but a prefix of "0x" indicates
|
||||
// a hex number and a leading zero indicates octal, just
|
||||
// like with C numeric literals. A leading negative sign
|
||||
// is NOT included in the token; it's up to the parser to
|
||||
// interpret the unary minus operator on its own.
|
||||
TYPE_FLOAT, // A floating point literal, with a fractional part and/or
|
||||
// an exponent. Always in decimal. Again, never
|
||||
// negative.
|
||||
TYPE_STRING, // A quoted sequence of escaped characters. Either single
|
||||
// or double quotes can be used, but they must match.
|
||||
// A string literal cannot cross a line break.
|
||||
TYPE_SYMBOL, // Any other printable character, like '!' or '+'.
|
||||
// Symbols are always a single character, so "!+$%" is
|
||||
// four tokens.
|
||||
};
|
||||
|
||||
// Structure representing a token read from the token stream.
|
||||
struct Token {
|
||||
TokenType type;
|
||||
string text; // The exact text of the token as it appeared in
|
||||
// the input. e.g. tokens of TYPE_STRING will still
|
||||
// be escaped and in quotes.
|
||||
|
||||
// "line" and "column" specify the position of the first character of
|
||||
// the token within the input stream. They are zero-based.
|
||||
int line;
|
||||
int column;
|
||||
int end_column;
|
||||
};
|
||||
|
||||
// Get the current token. This is updated when Next() is called. Before
|
||||
// the first call to Next(), current() has type TYPE_START and no contents.
|
||||
const Token& current();
|
||||
|
||||
// Return the previous token -- i.e. what current() returned before the
|
||||
// previous call to Next().
|
||||
const Token& previous();
|
||||
|
||||
// Advance to the next token. Returns false if the end of the input is
|
||||
// reached.
|
||||
bool Next();
|
||||
|
||||
// Like Next(), but also collects comments which appear between the previous
|
||||
// and next tokens.
|
||||
//
|
||||
// Comments which appear to be attached to the previous token are stored
|
||||
// in *prev_tailing_comments. Comments which appear to be attached to the
|
||||
// next token are stored in *next_leading_comments. Comments appearing in
|
||||
// between which do not appear to be attached to either will be added to
|
||||
// detached_comments. Any of these parameters can be NULL to simply discard
|
||||
// the comments.
|
||||
//
|
||||
// A series of line comments appearing on consecutive lines, with no other
|
||||
// tokens appearing on those lines, will be treated as a single comment.
|
||||
//
|
||||
// Only the comment content is returned; comment markers (e.g. //) are
|
||||
// stripped out. For block comments, leading whitespace and an asterisk will
|
||||
// be stripped from the beginning of each line other than the first. Newlines
|
||||
// are included in the output.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// optional int32 foo = 1; // Comment attached to foo.
|
||||
// // Comment attached to bar.
|
||||
// optional int32 bar = 2;
|
||||
//
|
||||
// optional string baz = 3;
|
||||
// // Comment attached to baz.
|
||||
// // Another line attached to baz.
|
||||
//
|
||||
// // Comment attached to qux.
|
||||
// //
|
||||
// // Another line attached to qux.
|
||||
// optional double qux = 4;
|
||||
//
|
||||
// // Detached comment. This is not attached to qux or corge
|
||||
// // because there are blank lines separating it from both.
|
||||
//
|
||||
// optional string corge = 5;
|
||||
// /* Block comment attached
|
||||
// * to corge. Leading asterisks
|
||||
// * will be removed. */
|
||||
// /* Block comment attached to
|
||||
// * grault. */
|
||||
// optional int32 grault = 6;
|
||||
bool NextWithComments(string* prev_trailing_comments,
|
||||
vector<string>* detached_comments,
|
||||
string* next_leading_comments);
|
||||
|
||||
// Parse helpers ---------------------------------------------------
|
||||
|
||||
// Parses a TYPE_FLOAT token. This never fails, so long as the text actually
|
||||
// comes from a TYPE_FLOAT token parsed by Tokenizer. If it doesn't, the
|
||||
// result is undefined (possibly an assert failure).
|
||||
static double ParseFloat(const string& text);
|
||||
|
||||
// Parses a TYPE_STRING token. This never fails, so long as the text actually
|
||||
// comes from a TYPE_STRING token parsed by Tokenizer. If it doesn't, the
|
||||
// result is undefined (possibly an assert failure).
|
||||
static void ParseString(const string& text, string* output);
|
||||
|
||||
// Identical to ParseString, but appends to output.
|
||||
static void ParseStringAppend(const string& text, string* output);
|
||||
|
||||
// Parses a TYPE_INTEGER token. Returns false if the result would be
|
||||
// greater than max_value. Otherwise, returns true and sets *output to the
|
||||
// result. If the text is not from a Token of type TYPE_INTEGER originally
|
||||
// parsed by a Tokenizer, the result is undefined (possibly an assert
|
||||
// failure).
|
||||
static bool ParseInteger(const string& text, uint64 max_value,
|
||||
uint64* output);
|
||||
|
||||
// Options ---------------------------------------------------------
|
||||
|
||||
// Set true to allow floats to be suffixed with the letter 'f'. Tokens
|
||||
// which would otherwise be integers but which have the 'f' suffix will be
|
||||
// forced to be interpreted as floats. For all other purposes, the 'f' is
|
||||
// ignored.
|
||||
void set_allow_f_after_float(bool value) { allow_f_after_float_ = value; }
|
||||
|
||||
// Valid values for set_comment_style().
|
||||
enum CommentStyle {
|
||||
// Line comments begin with "//", block comments are delimited by "/*" and
|
||||
// "*/".
|
||||
CPP_COMMENT_STYLE,
|
||||
// Line comments begin with "#". No way to write block comments.
|
||||
SH_COMMENT_STYLE
|
||||
};
|
||||
|
||||
// Sets the comment style.
|
||||
void set_comment_style(CommentStyle style) { comment_style_ = style; }
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Tokenizer);
|
||||
|
||||
Token current_; // Returned by current().
|
||||
Token previous_; // Returned by previous().
|
||||
|
||||
ZeroCopyInputStream* input_;
|
||||
ErrorCollector* error_collector_;
|
||||
|
||||
char current_char_; // == buffer_[buffer_pos_], updated by NextChar().
|
||||
const char* buffer_; // Current buffer returned from input_.
|
||||
int buffer_size_; // Size of buffer_.
|
||||
int buffer_pos_; // Current position within the buffer.
|
||||
bool read_error_; // Did we previously encounter a read error?
|
||||
|
||||
// Line and column number of current_char_ within the whole input stream.
|
||||
int line_;
|
||||
int column_;
|
||||
|
||||
// String to which text should be appended as we advance through it.
|
||||
// Call RecordTo(&str) to start recording and StopRecording() to stop.
|
||||
// E.g. StartToken() calls RecordTo(¤t_.text). record_start_ is the
|
||||
// position within the current buffer where recording started.
|
||||
string* record_target_;
|
||||
int record_start_;
|
||||
|
||||
// Options.
|
||||
bool allow_f_after_float_;
|
||||
CommentStyle comment_style_;
|
||||
|
||||
// Since we count columns we need to interpret tabs somehow. We'll take
|
||||
// the standard 8-character definition for lack of any way to do better.
|
||||
static const int kTabWidth = 8;
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Helper methods.
|
||||
|
||||
// Consume this character and advance to the next one.
|
||||
void NextChar();
|
||||
|
||||
// Read a new buffer from the input.
|
||||
void Refresh();
|
||||
|
||||
inline void RecordTo(string* target);
|
||||
inline void StopRecording();
|
||||
|
||||
// Called when the current character is the first character of a new
|
||||
// token (not including whitespace or comments).
|
||||
inline void StartToken();
|
||||
// Called when the current character is the first character after the
|
||||
// end of the last token. After this returns, current_.text will
|
||||
// contain all text consumed since StartToken() was called.
|
||||
inline void EndToken();
|
||||
|
||||
// Convenience method to add an error at the current line and column.
|
||||
void AddError(const string& message) {
|
||||
error_collector_->AddError(line_, column_, message);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// The following four methods are used to consume tokens of specific
|
||||
// types. They are actually used to consume all characters *after*
|
||||
// the first, since the calling function consumes the first character
|
||||
// in order to decide what kind of token is being read.
|
||||
|
||||
// Read and consume a string, ending when the given delimiter is
|
||||
// consumed.
|
||||
void ConsumeString(char delimiter);
|
||||
|
||||
// Read and consume a number, returning TYPE_FLOAT or TYPE_INTEGER
|
||||
// depending on what was read. This needs to know if the first
|
||||
// character was a zero in order to correctly recognize hex and octal
|
||||
// numbers.
|
||||
// It also needs to know if the first characted was a . to parse floating
|
||||
// point correctly.
|
||||
TokenType ConsumeNumber(bool started_with_zero, bool started_with_dot);
|
||||
|
||||
// Consume the rest of a line.
|
||||
void ConsumeLineComment(string* content);
|
||||
// Consume until "*/".
|
||||
void ConsumeBlockComment(string* content);
|
||||
|
||||
enum NextCommentStatus {
|
||||
// Started a line comment.
|
||||
LINE_COMMENT,
|
||||
|
||||
// Started a block comment.
|
||||
BLOCK_COMMENT,
|
||||
|
||||
// Consumed a slash, then realized it wasn't a comment. current_ has
|
||||
// been filled in with a slash token. The caller should return it.
|
||||
SLASH_NOT_COMMENT,
|
||||
|
||||
// We do not appear to be starting a comment here.
|
||||
NO_COMMENT
|
||||
};
|
||||
|
||||
// If we're at the start of a new comment, consume it and return what kind
|
||||
// of comment it is.
|
||||
NextCommentStatus TryConsumeCommentStart();
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// These helper methods make the parsing code more readable. The
|
||||
// "character classes" refered to are defined at the top of the .cc file.
|
||||
// Basically it is a C++ class with one method:
|
||||
// static bool InClass(char c);
|
||||
// The method returns true if c is a member of this "class", like "Letter"
|
||||
// or "Digit".
|
||||
|
||||
// Returns true if the current character is of the given character
|
||||
// class, but does not consume anything.
|
||||
template<typename CharacterClass>
|
||||
inline bool LookingAt();
|
||||
|
||||
// If the current character is in the given class, consume it and return
|
||||
// true. Otherwise return false.
|
||||
// e.g. TryConsumeOne<Letter>()
|
||||
template<typename CharacterClass>
|
||||
inline bool TryConsumeOne();
|
||||
|
||||
// Like above, but try to consume the specific character indicated.
|
||||
inline bool TryConsume(char c);
|
||||
|
||||
// Consume zero or more of the given character class.
|
||||
template<typename CharacterClass>
|
||||
inline void ConsumeZeroOrMore();
|
||||
|
||||
// Consume one or more of the given character class or log the given
|
||||
// error message.
|
||||
// e.g. ConsumeOneOrMore<Digit>("Expected digits.");
|
||||
template<typename CharacterClass>
|
||||
inline void ConsumeOneOrMore(const char* error);
|
||||
};
|
||||
|
||||
// inline methods ====================================================
|
||||
inline const Tokenizer::Token& Tokenizer::current() {
|
||||
return current_;
|
||||
}
|
||||
|
||||
inline const Tokenizer::Token& Tokenizer::previous() {
|
||||
return previous_;
|
||||
}
|
||||
|
||||
inline void Tokenizer::ParseString(const string& text, string* output) {
|
||||
output->clear();
|
||||
ParseStringAppend(text, output);
|
||||
}
|
||||
|
||||
} // namespace io
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_IO_TOKENIZER_H__
|
@ -0,0 +1,238 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// This file contains the ZeroCopyInputStream and ZeroCopyOutputStream
|
||||
// interfaces, which represent abstract I/O streams to and from which
|
||||
// protocol buffers can be read and written. For a few simple
|
||||
// implementations of these interfaces, see zero_copy_stream_impl.h.
|
||||
//
|
||||
// These interfaces are different from classic I/O streams in that they
|
||||
// try to minimize the amount of data copying that needs to be done.
|
||||
// To accomplish this, responsibility for allocating buffers is moved to
|
||||
// the stream object, rather than being the responsibility of the caller.
|
||||
// So, the stream can return a buffer which actually points directly into
|
||||
// the final data structure where the bytes are to be stored, and the caller
|
||||
// can interact directly with that buffer, eliminating an intermediate copy
|
||||
// operation.
|
||||
//
|
||||
// As an example, consider the common case in which you are reading bytes
|
||||
// from an array that is already in memory (or perhaps an mmap()ed file).
|
||||
// With classic I/O streams, you would do something like:
|
||||
// char buffer[BUFFER_SIZE];
|
||||
// input->Read(buffer, BUFFER_SIZE);
|
||||
// DoSomething(buffer, BUFFER_SIZE);
|
||||
// Then, the stream basically just calls memcpy() to copy the data from
|
||||
// the array into your buffer. With a ZeroCopyInputStream, you would do
|
||||
// this instead:
|
||||
// const void* buffer;
|
||||
// int size;
|
||||
// input->Next(&buffer, &size);
|
||||
// DoSomething(buffer, size);
|
||||
// Here, no copy is performed. The input stream returns a pointer directly
|
||||
// into the backing array, and the caller ends up reading directly from it.
|
||||
//
|
||||
// If you want to be able to read the old-fashion way, you can create
|
||||
// a CodedInputStream or CodedOutputStream wrapping these objects and use
|
||||
// their ReadRaw()/WriteRaw() methods. These will, of course, add a copy
|
||||
// step, but Coded*Stream will handle buffering so at least it will be
|
||||
// reasonably efficient.
|
||||
//
|
||||
// ZeroCopyInputStream example:
|
||||
// // Read in a file and print its contents to stdout.
|
||||
// int fd = open("myfile", O_RDONLY);
|
||||
// ZeroCopyInputStream* input = new FileInputStream(fd);
|
||||
//
|
||||
// const void* buffer;
|
||||
// int size;
|
||||
// while (input->Next(&buffer, &size)) {
|
||||
// cout.write(buffer, size);
|
||||
// }
|
||||
//
|
||||
// delete input;
|
||||
// close(fd);
|
||||
//
|
||||
// ZeroCopyOutputStream example:
|
||||
// // Copy the contents of "infile" to "outfile", using plain read() for
|
||||
// // "infile" but a ZeroCopyOutputStream for "outfile".
|
||||
// int infd = open("infile", O_RDONLY);
|
||||
// int outfd = open("outfile", O_WRONLY);
|
||||
// ZeroCopyOutputStream* output = new FileOutputStream(outfd);
|
||||
//
|
||||
// void* buffer;
|
||||
// int size;
|
||||
// while (output->Next(&buffer, &size)) {
|
||||
// int bytes = read(infd, buffer, size);
|
||||
// if (bytes < size) {
|
||||
// // Reached EOF.
|
||||
// output->BackUp(size - bytes);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// delete output;
|
||||
// close(infd);
|
||||
// close(outfd);
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
|
||||
#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
|
||||
|
||||
#include <string>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
namespace google {
|
||||
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
|
||||
// Defined in this file.
|
||||
class ZeroCopyInputStream;
|
||||
class ZeroCopyOutputStream;
|
||||
|
||||
// Abstract interface similar to an input stream but designed to minimize
|
||||
// copying.
|
||||
class LIBPROTOBUF_EXPORT ZeroCopyInputStream {
|
||||
public:
|
||||
inline ZeroCopyInputStream() {}
|
||||
virtual ~ZeroCopyInputStream();
|
||||
|
||||
// Obtains a chunk of data from the stream.
|
||||
//
|
||||
// Preconditions:
|
||||
// * "size" and "data" are not NULL.
|
||||
//
|
||||
// Postconditions:
|
||||
// * If the returned value is false, there is no more data to return or
|
||||
// an error occurred. All errors are permanent.
|
||||
// * Otherwise, "size" points to the actual number of bytes read and "data"
|
||||
// points to a pointer to a buffer containing these bytes.
|
||||
// * Ownership of this buffer remains with the stream, and the buffer
|
||||
// remains valid only until some other method of the stream is called
|
||||
// or the stream is destroyed.
|
||||
// * It is legal for the returned buffer to have zero size, as long
|
||||
// as repeatedly calling Next() eventually yields a buffer with non-zero
|
||||
// size.
|
||||
virtual bool Next(const void** data, int* size) = 0;
|
||||
|
||||
// Backs up a number of bytes, so that the next call to Next() returns
|
||||
// data again that was already returned by the last call to Next(). This
|
||||
// is useful when writing procedures that are only supposed to read up
|
||||
// to a certain point in the input, then return. If Next() returns a
|
||||
// buffer that goes beyond what you wanted to read, you can use BackUp()
|
||||
// to return to the point where you intended to finish.
|
||||
//
|
||||
// Preconditions:
|
||||
// * The last method called must have been Next().
|
||||
// * count must be less than or equal to the size of the last buffer
|
||||
// returned by Next().
|
||||
//
|
||||
// Postconditions:
|
||||
// * The last "count" bytes of the last buffer returned by Next() will be
|
||||
// pushed back into the stream. Subsequent calls to Next() will return
|
||||
// the same data again before producing new data.
|
||||
virtual void BackUp(int count) = 0;
|
||||
|
||||
// Skips a number of bytes. Returns false if the end of the stream is
|
||||
// reached or some input error occurred. In the end-of-stream case, the
|
||||
// stream is advanced to the end of the stream (so ByteCount() will return
|
||||
// the total size of the stream).
|
||||
virtual bool Skip(int count) = 0;
|
||||
|
||||
// Returns the total number of bytes read since this object was created.
|
||||
virtual int64 ByteCount() const = 0;
|
||||
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyInputStream);
|
||||
};
|
||||
|
||||
// Abstract interface similar to an output stream but designed to minimize
|
||||
// copying.
|
||||
class LIBPROTOBUF_EXPORT ZeroCopyOutputStream {
|
||||
public:
|
||||
inline ZeroCopyOutputStream() {}
|
||||
virtual ~ZeroCopyOutputStream();
|
||||
|
||||
// Obtains a buffer into which data can be written. Any data written
|
||||
// into this buffer will eventually (maybe instantly, maybe later on)
|
||||
// be written to the output.
|
||||
//
|
||||
// Preconditions:
|
||||
// * "size" and "data" are not NULL.
|
||||
//
|
||||
// Postconditions:
|
||||
// * If the returned value is false, an error occurred. All errors are
|
||||
// permanent.
|
||||
// * Otherwise, "size" points to the actual number of bytes in the buffer
|
||||
// and "data" points to the buffer.
|
||||
// * Ownership of this buffer remains with the stream, and the buffer
|
||||
// remains valid only until some other method of the stream is called
|
||||
// or the stream is destroyed.
|
||||
// * Any data which the caller stores in this buffer will eventually be
|
||||
// written to the output (unless BackUp() is called).
|
||||
// * It is legal for the returned buffer to have zero size, as long
|
||||
// as repeatedly calling Next() eventually yields a buffer with non-zero
|
||||
// size.
|
||||
virtual bool Next(void** data, int* size) = 0;
|
||||
|
||||
// Backs up a number of bytes, so that the end of the last buffer returned
|
||||
// by Next() is not actually written. This is needed when you finish
|
||||
// writing all the data you want to write, but the last buffer was bigger
|
||||
// than you needed. You don't want to write a bunch of garbage after the
|
||||
// end of your data, so you use BackUp() to back up.
|
||||
//
|
||||
// Preconditions:
|
||||
// * The last method called must have been Next().
|
||||
// * count must be less than or equal to the size of the last buffer
|
||||
// returned by Next().
|
||||
// * The caller must not have written anything to the last "count" bytes
|
||||
// of that buffer.
|
||||
//
|
||||
// Postconditions:
|
||||
// * The last "count" bytes of the last buffer returned by Next() will be
|
||||
// ignored.
|
||||
virtual void BackUp(int count) = 0;
|
||||
|
||||
// Returns the total number of bytes written since this object was created.
|
||||
virtual int64 ByteCount() const = 0;
|
||||
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyOutputStream);
|
||||
};
|
||||
|
||||
} // namespace io
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
|
@ -0,0 +1,357 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// This file contains common implementations of the interfaces defined in
|
||||
// zero_copy_stream.h which are only included in the full (non-lite)
|
||||
// protobuf library. These implementations include Unix file descriptors
|
||||
// and C++ iostreams. See also: zero_copy_stream_impl_lite.h
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
|
||||
#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
|
||||
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <google/protobuf/io/zero_copy_stream.h>
|
||||
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A ZeroCopyInputStream which reads from a file descriptor.
|
||||
//
|
||||
// FileInputStream is preferred over using an ifstream with IstreamInputStream.
|
||||
// The latter will introduce an extra layer of buffering, harming performance.
|
||||
// Also, it's conceivable that FileInputStream could someday be enhanced
|
||||
// to use zero-copy file descriptors on OSs which support them.
|
||||
class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
|
||||
public:
|
||||
// Creates a stream that reads from the given Unix file descriptor.
|
||||
// If a block_size is given, it specifies the number of bytes that
|
||||
// should be read and returned with each call to Next(). Otherwise,
|
||||
// a reasonable default is used.
|
||||
explicit FileInputStream(int file_descriptor, int block_size = -1);
|
||||
~FileInputStream();
|
||||
|
||||
// Flushes any buffers and closes the underlying file. Returns false if
|
||||
// an error occurs during the process; use GetErrno() to examine the error.
|
||||
// Even if an error occurs, the file descriptor is closed when this returns.
|
||||
bool Close();
|
||||
|
||||
// By default, the file descriptor is not closed when the stream is
|
||||
// destroyed. Call SetCloseOnDelete(true) to change that. WARNING:
|
||||
// This leaves no way for the caller to detect if close() fails. If
|
||||
// detecting close() errors is important to you, you should arrange
|
||||
// to close the descriptor yourself.
|
||||
void SetCloseOnDelete(bool value) { copying_input_.SetCloseOnDelete(value); }
|
||||
|
||||
// If an I/O error has occurred on this file descriptor, this is the
|
||||
// errno from that error. Otherwise, this is zero. Once an error
|
||||
// occurs, the stream is broken and all subsequent operations will
|
||||
// fail.
|
||||
int GetErrno() { return copying_input_.GetErrno(); }
|
||||
|
||||
// implements ZeroCopyInputStream ----------------------------------
|
||||
bool Next(const void** data, int* size);
|
||||
void BackUp(int count);
|
||||
bool Skip(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
class LIBPROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream {
|
||||
public:
|
||||
CopyingFileInputStream(int file_descriptor);
|
||||
~CopyingFileInputStream();
|
||||
|
||||
bool Close();
|
||||
void SetCloseOnDelete(bool value) { close_on_delete_ = value; }
|
||||
int GetErrno() { return errno_; }
|
||||
|
||||
// implements CopyingInputStream ---------------------------------
|
||||
int Read(void* buffer, int size);
|
||||
int Skip(int count);
|
||||
|
||||
private:
|
||||
// The file descriptor.
|
||||
const int file_;
|
||||
bool close_on_delete_;
|
||||
bool is_closed_;
|
||||
|
||||
// The errno of the I/O error, if one has occurred. Otherwise, zero.
|
||||
int errno_;
|
||||
|
||||
// Did we try to seek once and fail? If so, we assume this file descriptor
|
||||
// doesn't support seeking and won't try again.
|
||||
bool previous_seek_failed_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileInputStream);
|
||||
};
|
||||
|
||||
CopyingFileInputStream copying_input_;
|
||||
CopyingInputStreamAdaptor impl_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileInputStream);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A ZeroCopyOutputStream which writes to a file descriptor.
|
||||
//
|
||||
// FileOutputStream is preferred over using an ofstream with
|
||||
// OstreamOutputStream. The latter will introduce an extra layer of buffering,
|
||||
// harming performance. Also, it's conceivable that FileOutputStream could
|
||||
// someday be enhanced to use zero-copy file descriptors on OSs which
|
||||
// support them.
|
||||
class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
|
||||
public:
|
||||
// Creates a stream that writes to the given Unix file descriptor.
|
||||
// If a block_size is given, it specifies the size of the buffers
|
||||
// that should be returned by Next(). Otherwise, a reasonable default
|
||||
// is used.
|
||||
explicit FileOutputStream(int file_descriptor, int block_size = -1);
|
||||
~FileOutputStream();
|
||||
|
||||
// Flushes any buffers and closes the underlying file. Returns false if
|
||||
// an error occurs during the process; use GetErrno() to examine the error.
|
||||
// Even if an error occurs, the file descriptor is closed when this returns.
|
||||
bool Close();
|
||||
|
||||
// Flushes FileOutputStream's buffers but does not close the
|
||||
// underlying file. No special measures are taken to ensure that
|
||||
// underlying operating system file object is synchronized to disk.
|
||||
bool Flush();
|
||||
|
||||
// By default, the file descriptor is not closed when the stream is
|
||||
// destroyed. Call SetCloseOnDelete(true) to change that. WARNING:
|
||||
// This leaves no way for the caller to detect if close() fails. If
|
||||
// detecting close() errors is important to you, you should arrange
|
||||
// to close the descriptor yourself.
|
||||
void SetCloseOnDelete(bool value) { copying_output_.SetCloseOnDelete(value); }
|
||||
|
||||
// If an I/O error has occurred on this file descriptor, this is the
|
||||
// errno from that error. Otherwise, this is zero. Once an error
|
||||
// occurs, the stream is broken and all subsequent operations will
|
||||
// fail.
|
||||
int GetErrno() { return copying_output_.GetErrno(); }
|
||||
|
||||
// implements ZeroCopyOutputStream ---------------------------------
|
||||
bool Next(void** data, int* size);
|
||||
void BackUp(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
class LIBPROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream {
|
||||
public:
|
||||
CopyingFileOutputStream(int file_descriptor);
|
||||
~CopyingFileOutputStream();
|
||||
|
||||
bool Close();
|
||||
void SetCloseOnDelete(bool value) { close_on_delete_ = value; }
|
||||
int GetErrno() { return errno_; }
|
||||
|
||||
// implements CopyingOutputStream --------------------------------
|
||||
bool Write(const void* buffer, int size);
|
||||
|
||||
private:
|
||||
// The file descriptor.
|
||||
const int file_;
|
||||
bool close_on_delete_;
|
||||
bool is_closed_;
|
||||
|
||||
// The errno of the I/O error, if one has occurred. Otherwise, zero.
|
||||
int errno_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileOutputStream);
|
||||
};
|
||||
|
||||
CopyingFileOutputStream copying_output_;
|
||||
CopyingOutputStreamAdaptor impl_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileOutputStream);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A ZeroCopyInputStream which reads from a C++ istream.
|
||||
//
|
||||
// Note that for reading files (or anything represented by a file descriptor),
|
||||
// FileInputStream is more efficient.
|
||||
class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
|
||||
public:
|
||||
// Creates a stream that reads from the given C++ istream.
|
||||
// If a block_size is given, it specifies the number of bytes that
|
||||
// should be read and returned with each call to Next(). Otherwise,
|
||||
// a reasonable default is used.
|
||||
explicit IstreamInputStream(istream* stream, int block_size = -1);
|
||||
~IstreamInputStream();
|
||||
|
||||
// implements ZeroCopyInputStream ----------------------------------
|
||||
bool Next(const void** data, int* size);
|
||||
void BackUp(int count);
|
||||
bool Skip(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
class LIBPROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream {
|
||||
public:
|
||||
CopyingIstreamInputStream(istream* input);
|
||||
~CopyingIstreamInputStream();
|
||||
|
||||
// implements CopyingInputStream ---------------------------------
|
||||
int Read(void* buffer, int size);
|
||||
// (We use the default implementation of Skip().)
|
||||
|
||||
private:
|
||||
// The stream.
|
||||
istream* input_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingIstreamInputStream);
|
||||
};
|
||||
|
||||
CopyingIstreamInputStream copying_input_;
|
||||
CopyingInputStreamAdaptor impl_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(IstreamInputStream);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A ZeroCopyOutputStream which writes to a C++ ostream.
|
||||
//
|
||||
// Note that for writing files (or anything represented by a file descriptor),
|
||||
// FileOutputStream is more efficient.
|
||||
class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
|
||||
public:
|
||||
// Creates a stream that writes to the given C++ ostream.
|
||||
// If a block_size is given, it specifies the size of the buffers
|
||||
// that should be returned by Next(). Otherwise, a reasonable default
|
||||
// is used.
|
||||
explicit OstreamOutputStream(ostream* stream, int block_size = -1);
|
||||
~OstreamOutputStream();
|
||||
|
||||
// implements ZeroCopyOutputStream ---------------------------------
|
||||
bool Next(void** data, int* size);
|
||||
void BackUp(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
class LIBPROTOBUF_EXPORT CopyingOstreamOutputStream : public CopyingOutputStream {
|
||||
public:
|
||||
CopyingOstreamOutputStream(ostream* output);
|
||||
~CopyingOstreamOutputStream();
|
||||
|
||||
// implements CopyingOutputStream --------------------------------
|
||||
bool Write(const void* buffer, int size);
|
||||
|
||||
private:
|
||||
// The stream.
|
||||
ostream* output_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOstreamOutputStream);
|
||||
};
|
||||
|
||||
CopyingOstreamOutputStream copying_output_;
|
||||
CopyingOutputStreamAdaptor impl_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OstreamOutputStream);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A ZeroCopyInputStream which reads from several other streams in sequence.
|
||||
// ConcatenatingInputStream is unable to distinguish between end-of-stream
|
||||
// and read errors in the underlying streams, so it assumes any errors mean
|
||||
// end-of-stream. So, if the underlying streams fail for any other reason,
|
||||
// ConcatenatingInputStream may do odd things. It is suggested that you do
|
||||
// not use ConcatenatingInputStream on streams that might produce read errors
|
||||
// other than end-of-stream.
|
||||
class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
|
||||
public:
|
||||
// All streams passed in as well as the array itself must remain valid
|
||||
// until the ConcatenatingInputStream is destroyed.
|
||||
ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count);
|
||||
~ConcatenatingInputStream();
|
||||
|
||||
// implements ZeroCopyInputStream ----------------------------------
|
||||
bool Next(const void** data, int* size);
|
||||
void BackUp(int count);
|
||||
bool Skip(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
|
||||
private:
|
||||
// As streams are retired, streams_ is incremented and count_ is
|
||||
// decremented.
|
||||
ZeroCopyInputStream* const* streams_;
|
||||
int stream_count_;
|
||||
int64 bytes_retired_; // Bytes read from previous streams.
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ConcatenatingInputStream);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A ZeroCopyInputStream which wraps some other stream and limits it to
|
||||
// a particular byte count.
|
||||
class LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {
|
||||
public:
|
||||
LimitingInputStream(ZeroCopyInputStream* input, int64 limit);
|
||||
~LimitingInputStream();
|
||||
|
||||
// implements ZeroCopyInputStream ----------------------------------
|
||||
bool Next(const void** data, int* size);
|
||||
void BackUp(int count);
|
||||
bool Skip(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
|
||||
private:
|
||||
ZeroCopyInputStream* input_;
|
||||
int64 limit_; // Decreases as we go, becomes negative if we overshoot.
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LimitingInputStream);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
} // namespace io
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
|
@ -0,0 +1,340 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// This file contains common implementations of the interfaces defined in
|
||||
// zero_copy_stream.h which are included in the "lite" protobuf library.
|
||||
// These implementations cover I/O on raw arrays and strings, as well as
|
||||
// adaptors which make it easy to implement streams based on traditional
|
||||
// streams. Of course, many users will probably want to write their own
|
||||
// implementations of these interfaces specific to the particular I/O
|
||||
// abstractions they prefer to use, but these should cover the most common
|
||||
// cases.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
|
||||
#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
|
||||
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <google/protobuf/io/zero_copy_stream.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A ZeroCopyInputStream backed by an in-memory array of bytes.
|
||||
class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
|
||||
public:
|
||||
// Create an InputStream that returns the bytes pointed to by "data".
|
||||
// "data" remains the property of the caller but must remain valid until
|
||||
// the stream is destroyed. If a block_size is given, calls to Next()
|
||||
// will return data blocks no larger than the given size. Otherwise, the
|
||||
// first call to Next() returns the entire array. block_size is mainly
|
||||
// useful for testing; in production you would probably never want to set
|
||||
// it.
|
||||
ArrayInputStream(const void* data, int size, int block_size = -1);
|
||||
~ArrayInputStream();
|
||||
|
||||
// implements ZeroCopyInputStream ----------------------------------
|
||||
bool Next(const void** data, int* size);
|
||||
void BackUp(int count);
|
||||
bool Skip(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
|
||||
private:
|
||||
const uint8* const data_; // The byte array.
|
||||
const int size_; // Total size of the array.
|
||||
const int block_size_; // How many bytes to return at a time.
|
||||
|
||||
int position_;
|
||||
int last_returned_size_; // How many bytes we returned last time Next()
|
||||
// was called (used for error checking only).
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayInputStream);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A ZeroCopyOutputStream backed by an in-memory array of bytes.
|
||||
class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
|
||||
public:
|
||||
// Create an OutputStream that writes to the bytes pointed to by "data".
|
||||
// "data" remains the property of the caller but must remain valid until
|
||||
// the stream is destroyed. If a block_size is given, calls to Next()
|
||||
// will return data blocks no larger than the given size. Otherwise, the
|
||||
// first call to Next() returns the entire array. block_size is mainly
|
||||
// useful for testing; in production you would probably never want to set
|
||||
// it.
|
||||
ArrayOutputStream(void* data, int size, int block_size = -1);
|
||||
~ArrayOutputStream();
|
||||
|
||||
// implements ZeroCopyOutputStream ---------------------------------
|
||||
bool Next(void** data, int* size);
|
||||
void BackUp(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
uint8* const data_; // The byte array.
|
||||
const int size_; // Total size of the array.
|
||||
const int block_size_; // How many bytes to return at a time.
|
||||
|
||||
int position_;
|
||||
int last_returned_size_; // How many bytes we returned last time Next()
|
||||
// was called (used for error checking only).
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayOutputStream);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A ZeroCopyOutputStream which appends bytes to a string.
|
||||
class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
|
||||
public:
|
||||
// Create a StringOutputStream which appends bytes to the given string.
|
||||
// The string remains property of the caller, but it MUST NOT be accessed
|
||||
// in any way until the stream is destroyed.
|
||||
//
|
||||
// Hint: If you call target->reserve(n) before creating the stream,
|
||||
// the first call to Next() will return at least n bytes of buffer
|
||||
// space.
|
||||
explicit StringOutputStream(string* target);
|
||||
~StringOutputStream();
|
||||
|
||||
// implements ZeroCopyOutputStream ---------------------------------
|
||||
bool Next(void** data, int* size);
|
||||
void BackUp(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
static const int kMinimumSize = 16;
|
||||
|
||||
string* target_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);
|
||||
};
|
||||
|
||||
// Note: There is no StringInputStream. Instead, just create an
|
||||
// ArrayInputStream as follows:
|
||||
// ArrayInputStream input(str.data(), str.size());
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A generic traditional input stream interface.
|
||||
//
|
||||
// Lots of traditional input streams (e.g. file descriptors, C stdio
|
||||
// streams, and C++ iostreams) expose an interface where every read
|
||||
// involves copying bytes into a buffer. If you want to take such an
|
||||
// interface and make a ZeroCopyInputStream based on it, simply implement
|
||||
// CopyingInputStream and then use CopyingInputStreamAdaptor.
|
||||
//
|
||||
// CopyingInputStream implementations should avoid buffering if possible.
|
||||
// CopyingInputStreamAdaptor does its own buffering and will read data
|
||||
// in large blocks.
|
||||
class LIBPROTOBUF_EXPORT CopyingInputStream {
|
||||
public:
|
||||
virtual ~CopyingInputStream();
|
||||
|
||||
// Reads up to "size" bytes into the given buffer. Returns the number of
|
||||
// bytes read. Read() waits until at least one byte is available, or
|
||||
// returns zero if no bytes will ever become available (EOF), or -1 if a
|
||||
// permanent read error occurred.
|
||||
virtual int Read(void* buffer, int size) = 0;
|
||||
|
||||
// Skips the next "count" bytes of input. Returns the number of bytes
|
||||
// actually skipped. This will always be exactly equal to "count" unless
|
||||
// EOF was reached or a permanent read error occurred.
|
||||
//
|
||||
// The default implementation just repeatedly calls Read() into a scratch
|
||||
// buffer.
|
||||
virtual int Skip(int count);
|
||||
};
|
||||
|
||||
// A ZeroCopyInputStream which reads from a CopyingInputStream. This is
|
||||
// useful for implementing ZeroCopyInputStreams that read from traditional
|
||||
// streams. Note that this class is not really zero-copy.
|
||||
//
|
||||
// If you want to read from file descriptors or C++ istreams, this is
|
||||
// already implemented for you: use FileInputStream or IstreamInputStream
|
||||
// respectively.
|
||||
class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {
|
||||
public:
|
||||
// Creates a stream that reads from the given CopyingInputStream.
|
||||
// If a block_size is given, it specifies the number of bytes that
|
||||
// should be read and returned with each call to Next(). Otherwise,
|
||||
// a reasonable default is used. The caller retains ownership of
|
||||
// copying_stream unless SetOwnsCopyingStream(true) is called.
|
||||
explicit CopyingInputStreamAdaptor(CopyingInputStream* copying_stream,
|
||||
int block_size = -1);
|
||||
~CopyingInputStreamAdaptor();
|
||||
|
||||
// Call SetOwnsCopyingStream(true) to tell the CopyingInputStreamAdaptor to
|
||||
// delete the underlying CopyingInputStream when it is destroyed.
|
||||
void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }
|
||||
|
||||
// implements ZeroCopyInputStream ----------------------------------
|
||||
bool Next(const void** data, int* size);
|
||||
void BackUp(int count);
|
||||
bool Skip(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
// Insures that buffer_ is not NULL.
|
||||
void AllocateBufferIfNeeded();
|
||||
// Frees the buffer and resets buffer_used_.
|
||||
void FreeBuffer();
|
||||
|
||||
// The underlying copying stream.
|
||||
CopyingInputStream* copying_stream_;
|
||||
bool owns_copying_stream_;
|
||||
|
||||
// True if we have seen a permenant error from the underlying stream.
|
||||
bool failed_;
|
||||
|
||||
// The current position of copying_stream_, relative to the point where
|
||||
// we started reading.
|
||||
int64 position_;
|
||||
|
||||
// Data is read into this buffer. It may be NULL if no buffer is currently
|
||||
// in use. Otherwise, it points to an array of size buffer_size_.
|
||||
scoped_array<uint8> buffer_;
|
||||
const int buffer_size_;
|
||||
|
||||
// Number of valid bytes currently in the buffer (i.e. the size last
|
||||
// returned by Next()). 0 <= buffer_used_ <= buffer_size_.
|
||||
int buffer_used_;
|
||||
|
||||
// Number of bytes in the buffer which were backed up over by a call to
|
||||
// BackUp(). These need to be returned again.
|
||||
// 0 <= backup_bytes_ <= buffer_used_
|
||||
int backup_bytes_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingInputStreamAdaptor);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// A generic traditional output stream interface.
|
||||
//
|
||||
// Lots of traditional output streams (e.g. file descriptors, C stdio
|
||||
// streams, and C++ iostreams) expose an interface where every write
|
||||
// involves copying bytes from a buffer. If you want to take such an
|
||||
// interface and make a ZeroCopyOutputStream based on it, simply implement
|
||||
// CopyingOutputStream and then use CopyingOutputStreamAdaptor.
|
||||
//
|
||||
// CopyingOutputStream implementations should avoid buffering if possible.
|
||||
// CopyingOutputStreamAdaptor does its own buffering and will write data
|
||||
// in large blocks.
|
||||
class LIBPROTOBUF_EXPORT CopyingOutputStream {
|
||||
public:
|
||||
virtual ~CopyingOutputStream();
|
||||
|
||||
// Writes "size" bytes from the given buffer to the output. Returns true
|
||||
// if successful, false on a write error.
|
||||
virtual bool Write(const void* buffer, int size) = 0;
|
||||
};
|
||||
|
||||
// A ZeroCopyOutputStream which writes to a CopyingOutputStream. This is
|
||||
// useful for implementing ZeroCopyOutputStreams that write to traditional
|
||||
// streams. Note that this class is not really zero-copy.
|
||||
//
|
||||
// If you want to write to file descriptors or C++ ostreams, this is
|
||||
// already implemented for you: use FileOutputStream or OstreamOutputStream
|
||||
// respectively.
|
||||
class LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
|
||||
public:
|
||||
// Creates a stream that writes to the given Unix file descriptor.
|
||||
// If a block_size is given, it specifies the size of the buffers
|
||||
// that should be returned by Next(). Otherwise, a reasonable default
|
||||
// is used.
|
||||
explicit CopyingOutputStreamAdaptor(CopyingOutputStream* copying_stream,
|
||||
int block_size = -1);
|
||||
~CopyingOutputStreamAdaptor();
|
||||
|
||||
// Writes all pending data to the underlying stream. Returns false if a
|
||||
// write error occurred on the underlying stream. (The underlying
|
||||
// stream itself is not necessarily flushed.)
|
||||
bool Flush();
|
||||
|
||||
// Call SetOwnsCopyingStream(true) to tell the CopyingOutputStreamAdaptor to
|
||||
// delete the underlying CopyingOutputStream when it is destroyed.
|
||||
void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }
|
||||
|
||||
// implements ZeroCopyOutputStream ---------------------------------
|
||||
bool Next(void** data, int* size);
|
||||
void BackUp(int count);
|
||||
int64 ByteCount() const;
|
||||
|
||||
private:
|
||||
// Write the current buffer, if it is present.
|
||||
bool WriteBuffer();
|
||||
// Insures that buffer_ is not NULL.
|
||||
void AllocateBufferIfNeeded();
|
||||
// Frees the buffer.
|
||||
void FreeBuffer();
|
||||
|
||||
// The underlying copying stream.
|
||||
CopyingOutputStream* copying_stream_;
|
||||
bool owns_copying_stream_;
|
||||
|
||||
// True if we have seen a permenant error from the underlying stream.
|
||||
bool failed_;
|
||||
|
||||
// The current position of copying_stream_, relative to the point where
|
||||
// we started writing.
|
||||
int64 position_;
|
||||
|
||||
// Data is written from this buffer. It may be NULL if no buffer is
|
||||
// currently in use. Otherwise, it points to an array of size buffer_size_.
|
||||
scoped_array<uint8> buffer_;
|
||||
const int buffer_size_;
|
||||
|
||||
// Number of valid bytes currently in the buffer (i.e. the size last
|
||||
// returned by Next()). When BackUp() is called, we just reduce this.
|
||||
// 0 <= buffer_used_ <= buffer_size_.
|
||||
int buffer_used_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOutputStreamAdaptor);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
|
||||
} // namespace io
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
|
837
sgx-jvm/dependencies/root/usr/include/google/protobuf/message.h
Normal file
837
sgx-jvm/dependencies/root/usr/include/google/protobuf/message.h
Normal file
@ -0,0 +1,837 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// Defines Message, the abstract interface implemented by non-lite
|
||||
// protocol message objects. Although it's possible to implement this
|
||||
// interface manually, most users will use the protocol compiler to
|
||||
// generate implementations.
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// Say you have a message defined as:
|
||||
//
|
||||
// message Foo {
|
||||
// optional string text = 1;
|
||||
// repeated int32 numbers = 2;
|
||||
// }
|
||||
//
|
||||
// Then, if you used the protocol compiler to generate a class from the above
|
||||
// definition, you could use it like so:
|
||||
//
|
||||
// string data; // Will store a serialized version of the message.
|
||||
//
|
||||
// {
|
||||
// // Create a message and serialize it.
|
||||
// Foo foo;
|
||||
// foo.set_text("Hello World!");
|
||||
// foo.add_numbers(1);
|
||||
// foo.add_numbers(5);
|
||||
// foo.add_numbers(42);
|
||||
//
|
||||
// foo.SerializeToString(&data);
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// // Parse the serialized message and check that it contains the
|
||||
// // correct data.
|
||||
// Foo foo;
|
||||
// foo.ParseFromString(data);
|
||||
//
|
||||
// assert(foo.text() == "Hello World!");
|
||||
// assert(foo.numbers_size() == 3);
|
||||
// assert(foo.numbers(0) == 1);
|
||||
// assert(foo.numbers(1) == 5);
|
||||
// assert(foo.numbers(2) == 42);
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// // Same as the last block, but do it dynamically via the Message
|
||||
// // reflection interface.
|
||||
// Message* foo = new Foo;
|
||||
// const Descriptor* descriptor = foo->GetDescriptor();
|
||||
//
|
||||
// // Get the descriptors for the fields we're interested in and verify
|
||||
// // their types.
|
||||
// const FieldDescriptor* text_field = descriptor->FindFieldByName("text");
|
||||
// assert(text_field != NULL);
|
||||
// assert(text_field->type() == FieldDescriptor::TYPE_STRING);
|
||||
// assert(text_field->label() == FieldDescriptor::LABEL_OPTIONAL);
|
||||
// const FieldDescriptor* numbers_field = descriptor->
|
||||
// FindFieldByName("numbers");
|
||||
// assert(numbers_field != NULL);
|
||||
// assert(numbers_field->type() == FieldDescriptor::TYPE_INT32);
|
||||
// assert(numbers_field->label() == FieldDescriptor::LABEL_REPEATED);
|
||||
//
|
||||
// // Parse the message.
|
||||
// foo->ParseFromString(data);
|
||||
//
|
||||
// // Use the reflection interface to examine the contents.
|
||||
// const Reflection* reflection = foo->GetReflection();
|
||||
// assert(reflection->GetString(foo, text_field) == "Hello World!");
|
||||
// assert(reflection->FieldSize(foo, numbers_field) == 3);
|
||||
// assert(reflection->GetRepeatedInt32(foo, numbers_field, 0) == 1);
|
||||
// assert(reflection->GetRepeatedInt32(foo, numbers_field, 1) == 5);
|
||||
// assert(reflection->GetRepeatedInt32(foo, numbers_field, 2) == 42);
|
||||
//
|
||||
// delete foo;
|
||||
// }
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_MESSAGE_H__
|
||||
#define GOOGLE_PROTOBUF_MESSAGE_H__
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#ifdef __DECCXX
|
||||
// HP C++'s iosfwd doesn't work.
|
||||
#include <iostream>
|
||||
#else
|
||||
#include <iosfwd>
|
||||
#endif
|
||||
|
||||
#include <google/protobuf/message_lite.h>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
// Defined in this file.
|
||||
class Message;
|
||||
class Reflection;
|
||||
class MessageFactory;
|
||||
|
||||
// Defined in other files.
|
||||
class UnknownFieldSet; // unknown_field_set.h
|
||||
namespace io {
|
||||
class ZeroCopyInputStream; // zero_copy_stream.h
|
||||
class ZeroCopyOutputStream; // zero_copy_stream.h
|
||||
class CodedInputStream; // coded_stream.h
|
||||
class CodedOutputStream; // coded_stream.h
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
class RepeatedField; // repeated_field.h
|
||||
|
||||
template<typename T>
|
||||
class RepeatedPtrField; // repeated_field.h
|
||||
|
||||
// A container to hold message metadata.
|
||||
struct Metadata {
|
||||
const Descriptor* descriptor;
|
||||
const Reflection* reflection;
|
||||
};
|
||||
|
||||
// Abstract interface for protocol messages.
|
||||
//
|
||||
// See also MessageLite, which contains most every-day operations. Message
|
||||
// adds descriptors and reflection on top of that.
|
||||
//
|
||||
// The methods of this class that are virtual but not pure-virtual have
|
||||
// default implementations based on reflection. Message classes which are
|
||||
// optimized for speed will want to override these with faster implementations,
|
||||
// but classes optimized for code size may be happy with keeping them. See
|
||||
// the optimize_for option in descriptor.proto.
|
||||
class LIBPROTOBUF_EXPORT Message : public MessageLite {
|
||||
public:
|
||||
inline Message() {}
|
||||
virtual ~Message();
|
||||
|
||||
// Basic Operations ------------------------------------------------
|
||||
|
||||
// Construct a new instance of the same type. Ownership is passed to the
|
||||
// caller. (This is also defined in MessageLite, but is defined again here
|
||||
// for return-type covariance.)
|
||||
virtual Message* New() const = 0;
|
||||
|
||||
// Make this message into a copy of the given message. The given message
|
||||
// must have the same descriptor, but need not necessarily be the same class.
|
||||
// By default this is just implemented as "Clear(); MergeFrom(from);".
|
||||
virtual void CopyFrom(const Message& from);
|
||||
|
||||
// Merge the fields from the given message into this message. Singular
|
||||
// fields will be overwritten, except for embedded messages which will
|
||||
// be merged. Repeated fields will be concatenated. The given message
|
||||
// must be of the same type as this message (i.e. the exact same class).
|
||||
virtual void MergeFrom(const Message& from);
|
||||
|
||||
// Verifies that IsInitialized() returns true. GOOGLE_CHECK-fails otherwise, with
|
||||
// a nice error message.
|
||||
void CheckInitialized() const;
|
||||
|
||||
// Slowly build a list of all required fields that are not set.
|
||||
// This is much, much slower than IsInitialized() as it is implemented
|
||||
// purely via reflection. Generally, you should not call this unless you
|
||||
// have already determined that an error exists by calling IsInitialized().
|
||||
void FindInitializationErrors(vector<string>* errors) const;
|
||||
|
||||
// Like FindInitializationErrors, but joins all the strings, delimited by
|
||||
// commas, and returns them.
|
||||
string InitializationErrorString() const;
|
||||
|
||||
// Clears all unknown fields from this message and all embedded messages.
|
||||
// Normally, if unknown tag numbers are encountered when parsing a message,
|
||||
// the tag and value are stored in the message's UnknownFieldSet and
|
||||
// then written back out when the message is serialized. This allows servers
|
||||
// which simply route messages to other servers to pass through messages
|
||||
// that have new field definitions which they don't yet know about. However,
|
||||
// this behavior can have security implications. To avoid it, call this
|
||||
// method after parsing.
|
||||
//
|
||||
// See Reflection::GetUnknownFields() for more on unknown fields.
|
||||
virtual void DiscardUnknownFields();
|
||||
|
||||
// Computes (an estimate of) the total number of bytes currently used for
|
||||
// storing the message in memory. The default implementation calls the
|
||||
// Reflection object's SpaceUsed() method.
|
||||
virtual int SpaceUsed() const;
|
||||
|
||||
// Debugging & Testing----------------------------------------------
|
||||
|
||||
// Generates a human readable form of this message, useful for debugging
|
||||
// and other purposes.
|
||||
string DebugString() const;
|
||||
// Like DebugString(), but with less whitespace.
|
||||
string ShortDebugString() const;
|
||||
// Like DebugString(), but do not escape UTF-8 byte sequences.
|
||||
string Utf8DebugString() const;
|
||||
// Convenience function useful in GDB. Prints DebugString() to stdout.
|
||||
void PrintDebugString() const;
|
||||
|
||||
// Heavy I/O -------------------------------------------------------
|
||||
// Additional parsing and serialization methods not implemented by
|
||||
// MessageLite because they are not supported by the lite library.
|
||||
|
||||
// Parse a protocol buffer from a file descriptor. If successful, the entire
|
||||
// input will be consumed.
|
||||
bool ParseFromFileDescriptor(int file_descriptor);
|
||||
// Like ParseFromFileDescriptor(), but accepts messages that are missing
|
||||
// required fields.
|
||||
bool ParsePartialFromFileDescriptor(int file_descriptor);
|
||||
// Parse a protocol buffer from a C++ istream. If successful, the entire
|
||||
// input will be consumed.
|
||||
bool ParseFromIstream(istream* input);
|
||||
// Like ParseFromIstream(), but accepts messages that are missing
|
||||
// required fields.
|
||||
bool ParsePartialFromIstream(istream* input);
|
||||
|
||||
// Serialize the message and write it to the given file descriptor. All
|
||||
// required fields must be set.
|
||||
bool SerializeToFileDescriptor(int file_descriptor) const;
|
||||
// Like SerializeToFileDescriptor(), but allows missing required fields.
|
||||
bool SerializePartialToFileDescriptor(int file_descriptor) const;
|
||||
// Serialize the message and write it to the given C++ ostream. All
|
||||
// required fields must be set.
|
||||
bool SerializeToOstream(ostream* output) const;
|
||||
// Like SerializeToOstream(), but allows missing required fields.
|
||||
bool SerializePartialToOstream(ostream* output) const;
|
||||
|
||||
|
||||
// Reflection-based methods ----------------------------------------
|
||||
// These methods are pure-virtual in MessageLite, but Message provides
|
||||
// reflection-based default implementations.
|
||||
|
||||
virtual string GetTypeName() const;
|
||||
virtual void Clear();
|
||||
virtual bool IsInitialized() const;
|
||||
virtual void CheckTypeAndMergeFrom(const MessageLite& other);
|
||||
virtual bool MergePartialFromCodedStream(io::CodedInputStream* input);
|
||||
virtual int ByteSize() const;
|
||||
virtual void SerializeWithCachedSizes(io::CodedOutputStream* output) const;
|
||||
|
||||
private:
|
||||
// This is called only by the default implementation of ByteSize(), to
|
||||
// update the cached size. If you override ByteSize(), you do not need
|
||||
// to override this. If you do not override ByteSize(), you MUST override
|
||||
// this; the default implementation will crash.
|
||||
//
|
||||
// The method is private because subclasses should never call it; only
|
||||
// override it. Yes, C++ lets you do that. Crazy, huh?
|
||||
virtual void SetCachedSize(int size) const;
|
||||
|
||||
public:
|
||||
|
||||
// Introspection ---------------------------------------------------
|
||||
|
||||
// Typedef for backwards-compatibility.
|
||||
typedef google::protobuf::Reflection Reflection;
|
||||
|
||||
// Get a Descriptor for this message's type. This describes what
|
||||
// fields the message contains, the types of those fields, etc.
|
||||
const Descriptor* GetDescriptor() const { return GetMetadata().descriptor; }
|
||||
|
||||
// Get the Reflection interface for this Message, which can be used to
|
||||
// read and modify the fields of the Message dynamically (in other words,
|
||||
// without knowing the message type at compile time). This object remains
|
||||
// property of the Message.
|
||||
//
|
||||
// This method remains virtual in case a subclass does not implement
|
||||
// reflection and wants to override the default behavior.
|
||||
virtual const Reflection* GetReflection() const {
|
||||
return GetMetadata().reflection;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Get a struct containing the metadata for the Message. Most subclasses only
|
||||
// need to implement this method, rather than the GetDescriptor() and
|
||||
// GetReflection() wrappers.
|
||||
virtual Metadata GetMetadata() const = 0;
|
||||
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Message);
|
||||
};
|
||||
|
||||
// This interface contains methods that can be used to dynamically access
|
||||
// and modify the fields of a protocol message. Their semantics are
|
||||
// similar to the accessors the protocol compiler generates.
|
||||
//
|
||||
// To get the Reflection for a given Message, call Message::GetReflection().
|
||||
//
|
||||
// This interface is separate from Message only for efficiency reasons;
|
||||
// the vast majority of implementations of Message will share the same
|
||||
// implementation of Reflection (GeneratedMessageReflection,
|
||||
// defined in generated_message.h), and all Messages of a particular class
|
||||
// should share the same Reflection object (though you should not rely on
|
||||
// the latter fact).
|
||||
//
|
||||
// There are several ways that these methods can be used incorrectly. For
|
||||
// example, any of the following conditions will lead to undefined
|
||||
// results (probably assertion failures):
|
||||
// - The FieldDescriptor is not a field of this message type.
|
||||
// - The method called is not appropriate for the field's type. For
|
||||
// each field type in FieldDescriptor::TYPE_*, there is only one
|
||||
// Get*() method, one Set*() method, and one Add*() method that is
|
||||
// valid for that type. It should be obvious which (except maybe
|
||||
// for TYPE_BYTES, which are represented using strings in C++).
|
||||
// - A Get*() or Set*() method for singular fields is called on a repeated
|
||||
// field.
|
||||
// - GetRepeated*(), SetRepeated*(), or Add*() is called on a non-repeated
|
||||
// field.
|
||||
// - The Message object passed to any method is not of the right type for
|
||||
// this Reflection object (i.e. message.GetReflection() != reflection).
|
||||
//
|
||||
// You might wonder why there is not any abstract representation for a field
|
||||
// of arbitrary type. E.g., why isn't there just a "GetField()" method that
|
||||
// returns "const Field&", where "Field" is some class with accessors like
|
||||
// "GetInt32Value()". The problem is that someone would have to deal with
|
||||
// allocating these Field objects. For generated message classes, having to
|
||||
// allocate space for an additional object to wrap every field would at least
|
||||
// double the message's memory footprint, probably worse. Allocating the
|
||||
// objects on-demand, on the other hand, would be expensive and prone to
|
||||
// memory leaks. So, instead we ended up with this flat interface.
|
||||
//
|
||||
// TODO(kenton): Create a utility class which callers can use to read and
|
||||
// write fields from a Reflection without paying attention to the type.
|
||||
class LIBPROTOBUF_EXPORT Reflection {
|
||||
public:
|
||||
inline Reflection() {}
|
||||
virtual ~Reflection();
|
||||
|
||||
// Get the UnknownFieldSet for the message. This contains fields which
|
||||
// were seen when the Message was parsed but were not recognized according
|
||||
// to the Message's definition.
|
||||
virtual const UnknownFieldSet& GetUnknownFields(
|
||||
const Message& message) const = 0;
|
||||
// Get a mutable pointer to the UnknownFieldSet for the message. This
|
||||
// contains fields which were seen when the Message was parsed but were not
|
||||
// recognized according to the Message's definition.
|
||||
virtual UnknownFieldSet* MutableUnknownFields(Message* message) const = 0;
|
||||
|
||||
// Estimate the amount of memory used by the message object.
|
||||
virtual int SpaceUsed(const Message& message) const = 0;
|
||||
|
||||
// Check if the given non-repeated field is set.
|
||||
virtual bool HasField(const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
|
||||
// Get the number of elements of a repeated field.
|
||||
virtual int FieldSize(const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
|
||||
// Clear the value of a field, so that HasField() returns false or
|
||||
// FieldSize() returns zero.
|
||||
virtual void ClearField(Message* message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
|
||||
// Removes the last element of a repeated field.
|
||||
// We don't provide a way to remove any element other than the last
|
||||
// because it invites inefficient use, such as O(n^2) filtering loops
|
||||
// that should have been O(n). If you want to remove an element other
|
||||
// than the last, the best way to do it is to re-arrange the elements
|
||||
// (using Swap()) so that the one you want removed is at the end, then
|
||||
// call RemoveLast().
|
||||
virtual void RemoveLast(Message* message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
// Removes the last element of a repeated message field, and returns the
|
||||
// pointer to the caller. Caller takes ownership of the returned pointer.
|
||||
virtual Message* ReleaseLast(Message* message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
|
||||
// Swap the complete contents of two messages.
|
||||
virtual void Swap(Message* message1, Message* message2) const = 0;
|
||||
|
||||
// Swap two elements of a repeated field.
|
||||
virtual void SwapElements(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index1,
|
||||
int index2) const = 0;
|
||||
|
||||
// List all fields of the message which are currently set. This includes
|
||||
// extensions. Singular fields will only be listed if HasField(field) would
|
||||
// return true and repeated fields will only be listed if FieldSize(field)
|
||||
// would return non-zero. Fields (both normal fields and extension fields)
|
||||
// will be listed ordered by field number.
|
||||
virtual void ListFields(const Message& message,
|
||||
vector<const FieldDescriptor*>* output) const = 0;
|
||||
|
||||
// Singular field getters ------------------------------------------
|
||||
// These get the value of a non-repeated field. They return the default
|
||||
// value for fields that aren't set.
|
||||
|
||||
virtual int32 GetInt32 (const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
virtual int64 GetInt64 (const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
virtual uint32 GetUInt32(const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
virtual uint64 GetUInt64(const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
virtual float GetFloat (const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
virtual double GetDouble(const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
virtual bool GetBool (const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
virtual string GetString(const Message& message,
|
||||
const FieldDescriptor* field) const = 0;
|
||||
virtual const EnumValueDescriptor* GetEnum(
|
||||
const Message& message, const FieldDescriptor* field) const = 0;
|
||||
// See MutableMessage() for the meaning of the "factory" parameter.
|
||||
virtual const Message& GetMessage(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
MessageFactory* factory = NULL) const = 0;
|
||||
|
||||
// Get a string value without copying, if possible.
|
||||
//
|
||||
// GetString() necessarily returns a copy of the string. This can be
|
||||
// inefficient when the string is already stored in a string object in the
|
||||
// underlying message. GetStringReference() will return a reference to the
|
||||
// underlying string in this case. Otherwise, it will copy the string into
|
||||
// *scratch and return that.
|
||||
//
|
||||
// Note: It is perfectly reasonable and useful to write code like:
|
||||
// str = reflection->GetStringReference(field, &str);
|
||||
// This line would ensure that only one copy of the string is made
|
||||
// regardless of the field's underlying representation. When initializing
|
||||
// a newly-constructed string, though, it's just as fast and more readable
|
||||
// to use code like:
|
||||
// string str = reflection->GetString(field);
|
||||
virtual const string& GetStringReference(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
string* scratch) const = 0;
|
||||
|
||||
|
||||
// Singular field mutators -----------------------------------------
|
||||
// These mutate the value of a non-repeated field.
|
||||
|
||||
virtual void SetInt32 (Message* message,
|
||||
const FieldDescriptor* field, int32 value) const = 0;
|
||||
virtual void SetInt64 (Message* message,
|
||||
const FieldDescriptor* field, int64 value) const = 0;
|
||||
virtual void SetUInt32(Message* message,
|
||||
const FieldDescriptor* field, uint32 value) const = 0;
|
||||
virtual void SetUInt64(Message* message,
|
||||
const FieldDescriptor* field, uint64 value) const = 0;
|
||||
virtual void SetFloat (Message* message,
|
||||
const FieldDescriptor* field, float value) const = 0;
|
||||
virtual void SetDouble(Message* message,
|
||||
const FieldDescriptor* field, double value) const = 0;
|
||||
virtual void SetBool (Message* message,
|
||||
const FieldDescriptor* field, bool value) const = 0;
|
||||
virtual void SetString(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
const string& value) const = 0;
|
||||
virtual void SetEnum (Message* message,
|
||||
const FieldDescriptor* field,
|
||||
const EnumValueDescriptor* value) const = 0;
|
||||
// Get a mutable pointer to a field with a message type. If a MessageFactory
|
||||
// is provided, it will be used to construct instances of the sub-message;
|
||||
// otherwise, the default factory is used. If the field is an extension that
|
||||
// does not live in the same pool as the containing message's descriptor (e.g.
|
||||
// it lives in an overlay pool), then a MessageFactory must be provided.
|
||||
// If you have no idea what that meant, then you probably don't need to worry
|
||||
// about it (don't provide a MessageFactory). WARNING: If the
|
||||
// FieldDescriptor is for a compiled-in extension, then
|
||||
// factory->GetPrototype(field->message_type() MUST return an instance of the
|
||||
// compiled-in class for this type, NOT DynamicMessage.
|
||||
virtual Message* MutableMessage(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
MessageFactory* factory = NULL) const = 0;
|
||||
// Releases the message specified by 'field' and returns the pointer,
|
||||
// ReleaseMessage() will return the message the message object if it exists.
|
||||
// Otherwise, it may or may not return NULL. In any case, if the return value
|
||||
// is non-NULL, the caller takes ownership of the pointer.
|
||||
// If the field existed (HasField() is true), then the returned pointer will
|
||||
// be the same as the pointer returned by MutableMessage().
|
||||
// This function has the same effect as ClearField().
|
||||
virtual Message* ReleaseMessage(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
MessageFactory* factory = NULL) const = 0;
|
||||
|
||||
|
||||
// Repeated field getters ------------------------------------------
|
||||
// These get the value of one element of a repeated field.
|
||||
|
||||
virtual int32 GetRepeatedInt32 (const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const = 0;
|
||||
virtual int64 GetRepeatedInt64 (const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const = 0;
|
||||
virtual uint32 GetRepeatedUInt32(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const = 0;
|
||||
virtual uint64 GetRepeatedUInt64(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const = 0;
|
||||
virtual float GetRepeatedFloat (const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const = 0;
|
||||
virtual double GetRepeatedDouble(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const = 0;
|
||||
virtual bool GetRepeatedBool (const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const = 0;
|
||||
virtual string GetRepeatedString(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index) const = 0;
|
||||
virtual const EnumValueDescriptor* GetRepeatedEnum(
|
||||
const Message& message,
|
||||
const FieldDescriptor* field, int index) const = 0;
|
||||
virtual const Message& GetRepeatedMessage(
|
||||
const Message& message,
|
||||
const FieldDescriptor* field, int index) const = 0;
|
||||
|
||||
// See GetStringReference(), above.
|
||||
virtual const string& GetRepeatedStringReference(
|
||||
const Message& message, const FieldDescriptor* field,
|
||||
int index, string* scratch) const = 0;
|
||||
|
||||
|
||||
// Repeated field mutators -----------------------------------------
|
||||
// These mutate the value of one element of a repeated field.
|
||||
|
||||
virtual void SetRepeatedInt32 (Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index, int32 value) const = 0;
|
||||
virtual void SetRepeatedInt64 (Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index, int64 value) const = 0;
|
||||
virtual void SetRepeatedUInt32(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index, uint32 value) const = 0;
|
||||
virtual void SetRepeatedUInt64(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index, uint64 value) const = 0;
|
||||
virtual void SetRepeatedFloat (Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index, float value) const = 0;
|
||||
virtual void SetRepeatedDouble(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index, double value) const = 0;
|
||||
virtual void SetRepeatedBool (Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index, bool value) const = 0;
|
||||
virtual void SetRepeatedString(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
int index, const string& value) const = 0;
|
||||
virtual void SetRepeatedEnum(Message* message,
|
||||
const FieldDescriptor* field, int index,
|
||||
const EnumValueDescriptor* value) const = 0;
|
||||
// Get a mutable pointer to an element of a repeated field with a message
|
||||
// type.
|
||||
virtual Message* MutableRepeatedMessage(
|
||||
Message* message, const FieldDescriptor* field, int index) const = 0;
|
||||
|
||||
|
||||
// Repeated field adders -------------------------------------------
|
||||
// These add an element to a repeated field.
|
||||
|
||||
virtual void AddInt32 (Message* message,
|
||||
const FieldDescriptor* field, int32 value) const = 0;
|
||||
virtual void AddInt64 (Message* message,
|
||||
const FieldDescriptor* field, int64 value) const = 0;
|
||||
virtual void AddUInt32(Message* message,
|
||||
const FieldDescriptor* field, uint32 value) const = 0;
|
||||
virtual void AddUInt64(Message* message,
|
||||
const FieldDescriptor* field, uint64 value) const = 0;
|
||||
virtual void AddFloat (Message* message,
|
||||
const FieldDescriptor* field, float value) const = 0;
|
||||
virtual void AddDouble(Message* message,
|
||||
const FieldDescriptor* field, double value) const = 0;
|
||||
virtual void AddBool (Message* message,
|
||||
const FieldDescriptor* field, bool value) const = 0;
|
||||
virtual void AddString(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
const string& value) const = 0;
|
||||
virtual void AddEnum (Message* message,
|
||||
const FieldDescriptor* field,
|
||||
const EnumValueDescriptor* value) const = 0;
|
||||
// See MutableMessage() for comments on the "factory" parameter.
|
||||
virtual Message* AddMessage(Message* message,
|
||||
const FieldDescriptor* field,
|
||||
MessageFactory* factory = NULL) const = 0;
|
||||
|
||||
|
||||
// Repeated field accessors -------------------------------------------------
|
||||
// The methods above, e.g. GetRepeatedInt32(msg, fd, index), provide singular
|
||||
// access to the data in a RepeatedField. The methods below provide aggregate
|
||||
// access by exposing the RepeatedField object itself with the Message.
|
||||
// Applying these templates to inappropriate types will lead to an undefined
|
||||
// reference at link time (e.g. GetRepeatedField<***double>), or possibly a
|
||||
// template matching error at compile time (e.g. GetRepeatedPtrField<File>).
|
||||
//
|
||||
// Usage example: my_doubs = refl->GetRepeatedField<double>(msg, fd);
|
||||
|
||||
// for T = Cord and all protobuf scalar types except enums.
|
||||
template<typename T>
|
||||
const RepeatedField<T>& GetRepeatedField(
|
||||
const Message&, const FieldDescriptor*) const;
|
||||
|
||||
// for T = Cord and all protobuf scalar types except enums.
|
||||
template<typename T>
|
||||
RepeatedField<T>* MutableRepeatedField(
|
||||
Message*, const FieldDescriptor*) const;
|
||||
|
||||
// for T = string, google::protobuf::internal::StringPieceField
|
||||
// google::protobuf::Message & descendants.
|
||||
template<typename T>
|
||||
const RepeatedPtrField<T>& GetRepeatedPtrField(
|
||||
const Message&, const FieldDescriptor*) const;
|
||||
|
||||
// for T = string, google::protobuf::internal::StringPieceField
|
||||
// google::protobuf::Message & descendants.
|
||||
template<typename T>
|
||||
RepeatedPtrField<T>* MutableRepeatedPtrField(
|
||||
Message*, const FieldDescriptor*) const;
|
||||
|
||||
// Extensions ----------------------------------------------------------------
|
||||
|
||||
// Try to find an extension of this message type by fully-qualified field
|
||||
// name. Returns NULL if no extension is known for this name or number.
|
||||
virtual const FieldDescriptor* FindKnownExtensionByName(
|
||||
const string& name) const = 0;
|
||||
|
||||
// Try to find an extension of this message type by field number.
|
||||
// Returns NULL if no extension is known for this name or number.
|
||||
virtual const FieldDescriptor* FindKnownExtensionByNumber(
|
||||
int number) const = 0;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
protected:
|
||||
// Obtain a pointer to a Repeated Field Structure and do some type checking:
|
||||
// on field->cpp_type(),
|
||||
// on field->field_option().ctype() (if ctype >= 0)
|
||||
// of field->message_type() (if message_type != NULL).
|
||||
// We use 1 routine rather than 4 (const vs mutable) x (scalar vs pointer).
|
||||
virtual void* MutableRawRepeatedField(
|
||||
Message* message, const FieldDescriptor* field, FieldDescriptor::CppType,
|
||||
int ctype, const Descriptor* message_type) const = 0;
|
||||
|
||||
private:
|
||||
// Special version for specialized implementations of string. We can't call
|
||||
// MutableRawRepeatedField directly here because we don't have access to
|
||||
// FieldOptions::* which are defined in descriptor.pb.h. Including that
|
||||
// file here is not possible because it would cause a circular include cycle.
|
||||
void* MutableRawRepeatedString(
|
||||
Message* message, const FieldDescriptor* field, bool is_string) const;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reflection);
|
||||
};
|
||||
|
||||
// Abstract interface for a factory for message objects.
|
||||
class LIBPROTOBUF_EXPORT MessageFactory {
|
||||
public:
|
||||
inline MessageFactory() {}
|
||||
virtual ~MessageFactory();
|
||||
|
||||
// Given a Descriptor, gets or constructs the default (prototype) Message
|
||||
// of that type. You can then call that message's New() method to construct
|
||||
// a mutable message of that type.
|
||||
//
|
||||
// Calling this method twice with the same Descriptor returns the same
|
||||
// object. The returned object remains property of the factory. Also, any
|
||||
// objects created by calling the prototype's New() method share some data
|
||||
// with the prototype, so these must be destoyed before the MessageFactory
|
||||
// is destroyed.
|
||||
//
|
||||
// The given descriptor must outlive the returned message, and hence must
|
||||
// outlive the MessageFactory.
|
||||
//
|
||||
// Some implementations do not support all types. GetPrototype() will
|
||||
// return NULL if the descriptor passed in is not supported.
|
||||
//
|
||||
// This method may or may not be thread-safe depending on the implementation.
|
||||
// Each implementation should document its own degree thread-safety.
|
||||
virtual const Message* GetPrototype(const Descriptor* type) = 0;
|
||||
|
||||
// Gets a MessageFactory which supports all generated, compiled-in messages.
|
||||
// In other words, for any compiled-in type FooMessage, the following is true:
|
||||
// MessageFactory::generated_factory()->GetPrototype(
|
||||
// FooMessage::descriptor()) == FooMessage::default_instance()
|
||||
// This factory supports all types which are found in
|
||||
// DescriptorPool::generated_pool(). If given a descriptor from any other
|
||||
// pool, GetPrototype() will return NULL. (You can also check if a
|
||||
// descriptor is for a generated message by checking if
|
||||
// descriptor->file()->pool() == DescriptorPool::generated_pool().)
|
||||
//
|
||||
// This factory is 100% thread-safe; calling GetPrototype() does not modify
|
||||
// any shared data.
|
||||
//
|
||||
// This factory is a singleton. The caller must not delete the object.
|
||||
static MessageFactory* generated_factory();
|
||||
|
||||
// For internal use only: Registers a .proto file at static initialization
|
||||
// time, to be placed in generated_factory. The first time GetPrototype()
|
||||
// is called with a descriptor from this file, |register_messages| will be
|
||||
// called, with the file name as the parameter. It must call
|
||||
// InternalRegisterGeneratedMessage() (below) to register each message type
|
||||
// in the file. This strange mechanism is necessary because descriptors are
|
||||
// built lazily, so we can't register types by their descriptor until we
|
||||
// know that the descriptor exists. |filename| must be a permanent string.
|
||||
static void InternalRegisterGeneratedFile(
|
||||
const char* filename, void (*register_messages)(const string&));
|
||||
|
||||
// For internal use only: Registers a message type. Called only by the
|
||||
// functions which are registered with InternalRegisterGeneratedFile(),
|
||||
// above.
|
||||
static void InternalRegisterGeneratedMessage(const Descriptor* descriptor,
|
||||
const Message* prototype);
|
||||
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFactory);
|
||||
};
|
||||
|
||||
#define DECLARE_GET_REPEATED_FIELD(TYPE) \
|
||||
template<> \
|
||||
LIBPROTOBUF_EXPORT \
|
||||
const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \
|
||||
const Message& message, const FieldDescriptor* field) const; \
|
||||
\
|
||||
template<> \
|
||||
LIBPROTOBUF_EXPORT \
|
||||
RepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>( \
|
||||
Message* message, const FieldDescriptor* field) const;
|
||||
|
||||
DECLARE_GET_REPEATED_FIELD(int32)
|
||||
DECLARE_GET_REPEATED_FIELD(int64)
|
||||
DECLARE_GET_REPEATED_FIELD(uint32)
|
||||
DECLARE_GET_REPEATED_FIELD(uint64)
|
||||
DECLARE_GET_REPEATED_FIELD(float)
|
||||
DECLARE_GET_REPEATED_FIELD(double)
|
||||
DECLARE_GET_REPEATED_FIELD(bool)
|
||||
|
||||
#undef DECLARE_GET_REPEATED_FIELD
|
||||
|
||||
// =============================================================================
|
||||
// Implementation details for {Get,Mutable}RawRepeatedPtrField. We provide
|
||||
// specializations for <string>, <StringPieceField> and <Message> and handle
|
||||
// everything else with the default template which will match any type having
|
||||
// a method with signature "static const google::protobuf::Descriptor* descriptor()".
|
||||
// Such a type presumably is a descendant of google::protobuf::Message.
|
||||
|
||||
template<>
|
||||
inline const RepeatedPtrField<string>& Reflection::GetRepeatedPtrField<string>(
|
||||
const Message& message, const FieldDescriptor* field) const {
|
||||
return *static_cast<RepeatedPtrField<string>* >(
|
||||
MutableRawRepeatedString(const_cast<Message*>(&message), field, true));
|
||||
}
|
||||
|
||||
template<>
|
||||
inline RepeatedPtrField<string>* Reflection::MutableRepeatedPtrField<string>(
|
||||
Message* message, const FieldDescriptor* field) const {
|
||||
return static_cast<RepeatedPtrField<string>* >(
|
||||
MutableRawRepeatedString(message, field, true));
|
||||
}
|
||||
|
||||
|
||||
// -----
|
||||
|
||||
template<>
|
||||
inline const RepeatedPtrField<Message>& Reflection::GetRepeatedPtrField(
|
||||
const Message& message, const FieldDescriptor* field) const {
|
||||
return *static_cast<RepeatedPtrField<Message>* >(
|
||||
MutableRawRepeatedField(const_cast<Message*>(&message), field,
|
||||
FieldDescriptor::CPPTYPE_MESSAGE, -1,
|
||||
NULL));
|
||||
}
|
||||
|
||||
template<>
|
||||
inline RepeatedPtrField<Message>* Reflection::MutableRepeatedPtrField(
|
||||
Message* message, const FieldDescriptor* field) const {
|
||||
return static_cast<RepeatedPtrField<Message>* >(
|
||||
MutableRawRepeatedField(message, field,
|
||||
FieldDescriptor::CPPTYPE_MESSAGE, -1,
|
||||
NULL));
|
||||
}
|
||||
|
||||
template<typename PB>
|
||||
inline const RepeatedPtrField<PB>& Reflection::GetRepeatedPtrField(
|
||||
const Message& message, const FieldDescriptor* field) const {
|
||||
return *static_cast<RepeatedPtrField<PB>* >(
|
||||
MutableRawRepeatedField(const_cast<Message*>(&message), field,
|
||||
FieldDescriptor::CPPTYPE_MESSAGE, -1,
|
||||
PB::default_instance().GetDescriptor()));
|
||||
}
|
||||
|
||||
template<typename PB>
|
||||
inline RepeatedPtrField<PB>* Reflection::MutableRepeatedPtrField(
|
||||
Message* message, const FieldDescriptor* field) const {
|
||||
return static_cast<RepeatedPtrField<PB>* >(
|
||||
MutableRawRepeatedField(message, field,
|
||||
FieldDescriptor::CPPTYPE_MESSAGE, -1,
|
||||
PB::default_instance().GetDescriptor()));
|
||||
}
|
||||
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_MESSAGE_H__
|
@ -0,0 +1,246 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Authors: wink@google.com (Wink Saville),
|
||||
// kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// Defines MessageLite, the abstract interface implemented by all (lite
|
||||
// and non-lite) protocol message objects.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__
|
||||
#define GOOGLE_PROTOBUF_MESSAGE_LITE_H__
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
namespace io {
|
||||
class CodedInputStream;
|
||||
class CodedOutputStream;
|
||||
class ZeroCopyInputStream;
|
||||
class ZeroCopyOutputStream;
|
||||
}
|
||||
|
||||
// Interface to light weight protocol messages.
|
||||
//
|
||||
// This interface is implemented by all protocol message objects. Non-lite
|
||||
// messages additionally implement the Message interface, which is a
|
||||
// subclass of MessageLite. Use MessageLite instead when you only need
|
||||
// the subset of features which it supports -- namely, nothing that uses
|
||||
// descriptors or reflection. You can instruct the protocol compiler
|
||||
// to generate classes which implement only MessageLite, not the full
|
||||
// Message interface, by adding the following line to the .proto file:
|
||||
//
|
||||
// option optimize_for = LITE_RUNTIME;
|
||||
//
|
||||
// This is particularly useful on resource-constrained systems where
|
||||
// the full protocol buffers runtime library is too big.
|
||||
//
|
||||
// Note that on non-constrained systems (e.g. servers) when you need
|
||||
// to link in lots of protocol definitions, a better way to reduce
|
||||
// total code footprint is to use optimize_for = CODE_SIZE. This
|
||||
// will make the generated code smaller while still supporting all the
|
||||
// same features (at the expense of speed). optimize_for = LITE_RUNTIME
|
||||
// is best when you only have a small number of message types linked
|
||||
// into your binary, in which case the size of the protocol buffers
|
||||
// runtime itself is the biggest problem.
|
||||
class LIBPROTOBUF_EXPORT MessageLite {
|
||||
public:
|
||||
inline MessageLite() {}
|
||||
virtual ~MessageLite();
|
||||
|
||||
// Basic Operations ------------------------------------------------
|
||||
|
||||
// Get the name of this message type, e.g. "foo.bar.BazProto".
|
||||
virtual string GetTypeName() const = 0;
|
||||
|
||||
// Construct a new instance of the same type. Ownership is passed to the
|
||||
// caller.
|
||||
virtual MessageLite* New() const = 0;
|
||||
|
||||
// Clear all fields of the message and set them to their default values.
|
||||
// Clear() avoids freeing memory, assuming that any memory allocated
|
||||
// to hold parts of the message will be needed again to hold the next
|
||||
// message. If you actually want to free the memory used by a Message,
|
||||
// you must delete it.
|
||||
virtual void Clear() = 0;
|
||||
|
||||
// Quickly check if all required fields have values set.
|
||||
virtual bool IsInitialized() const = 0;
|
||||
|
||||
// This is not implemented for Lite messages -- it just returns "(cannot
|
||||
// determine missing fields for lite message)". However, it is implemented
|
||||
// for full messages. See message.h.
|
||||
virtual string InitializationErrorString() const;
|
||||
|
||||
// If |other| is the exact same class as this, calls MergeFrom(). Otherwise,
|
||||
// results are undefined (probably crash).
|
||||
virtual void CheckTypeAndMergeFrom(const MessageLite& other) = 0;
|
||||
|
||||
// Parsing ---------------------------------------------------------
|
||||
// Methods for parsing in protocol buffer format. Most of these are
|
||||
// just simple wrappers around MergeFromCodedStream().
|
||||
|
||||
// Fill the message with a protocol buffer parsed from the given input
|
||||
// stream. Returns false on a read error or if the input is in the
|
||||
// wrong format.
|
||||
bool ParseFromCodedStream(io::CodedInputStream* input);
|
||||
// Like ParseFromCodedStream(), but accepts messages that are missing
|
||||
// required fields.
|
||||
bool ParsePartialFromCodedStream(io::CodedInputStream* input);
|
||||
// Read a protocol buffer from the given zero-copy input stream. If
|
||||
// successful, the entire input will be consumed.
|
||||
bool ParseFromZeroCopyStream(io::ZeroCopyInputStream* input);
|
||||
// Like ParseFromZeroCopyStream(), but accepts messages that are missing
|
||||
// required fields.
|
||||
bool ParsePartialFromZeroCopyStream(io::ZeroCopyInputStream* input);
|
||||
// Read a protocol buffer from the given zero-copy input stream, expecting
|
||||
// the message to be exactly "size" bytes long. If successful, exactly
|
||||
// this many bytes will have been consumed from the input.
|
||||
bool ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input, int size);
|
||||
// Like ParseFromBoundedZeroCopyStream(), but accepts messages that are
|
||||
// missing required fields.
|
||||
bool ParsePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input,
|
||||
int size);
|
||||
// Parse a protocol buffer contained in a string.
|
||||
bool ParseFromString(const string& data);
|
||||
// Like ParseFromString(), but accepts messages that are missing
|
||||
// required fields.
|
||||
bool ParsePartialFromString(const string& data);
|
||||
// Parse a protocol buffer contained in an array of bytes.
|
||||
bool ParseFromArray(const void* data, int size);
|
||||
// Like ParseFromArray(), but accepts messages that are missing
|
||||
// required fields.
|
||||
bool ParsePartialFromArray(const void* data, int size);
|
||||
|
||||
|
||||
// Reads a protocol buffer from the stream and merges it into this
|
||||
// Message. Singular fields read from the input overwrite what is
|
||||
// already in the Message and repeated fields are appended to those
|
||||
// already present.
|
||||
//
|
||||
// It is the responsibility of the caller to call input->LastTagWas()
|
||||
// (for groups) or input->ConsumedEntireMessage() (for non-groups) after
|
||||
// this returns to verify that the message's end was delimited correctly.
|
||||
//
|
||||
// ParsefromCodedStream() is implemented as Clear() followed by
|
||||
// MergeFromCodedStream().
|
||||
bool MergeFromCodedStream(io::CodedInputStream* input);
|
||||
|
||||
// Like MergeFromCodedStream(), but succeeds even if required fields are
|
||||
// missing in the input.
|
||||
//
|
||||
// MergeFromCodedStream() is just implemented as MergePartialFromCodedStream()
|
||||
// followed by IsInitialized().
|
||||
virtual bool MergePartialFromCodedStream(io::CodedInputStream* input) = 0;
|
||||
|
||||
|
||||
// Serialization ---------------------------------------------------
|
||||
// Methods for serializing in protocol buffer format. Most of these
|
||||
// are just simple wrappers around ByteSize() and SerializeWithCachedSizes().
|
||||
|
||||
// Write a protocol buffer of this message to the given output. Returns
|
||||
// false on a write error. If the message is missing required fields,
|
||||
// this may GOOGLE_CHECK-fail.
|
||||
bool SerializeToCodedStream(io::CodedOutputStream* output) const;
|
||||
// Like SerializeToCodedStream(), but allows missing required fields.
|
||||
bool SerializePartialToCodedStream(io::CodedOutputStream* output) const;
|
||||
// Write the message to the given zero-copy output stream. All required
|
||||
// fields must be set.
|
||||
bool SerializeToZeroCopyStream(io::ZeroCopyOutputStream* output) const;
|
||||
// Like SerializeToZeroCopyStream(), but allows missing required fields.
|
||||
bool SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream* output) const;
|
||||
// Serialize the message and store it in the given string. All required
|
||||
// fields must be set.
|
||||
bool SerializeToString(string* output) const;
|
||||
// Like SerializeToString(), but allows missing required fields.
|
||||
bool SerializePartialToString(string* output) const;
|
||||
// Serialize the message and store it in the given byte array. All required
|
||||
// fields must be set.
|
||||
bool SerializeToArray(void* data, int size) const;
|
||||
// Like SerializeToArray(), but allows missing required fields.
|
||||
bool SerializePartialToArray(void* data, int size) const;
|
||||
|
||||
// Make a string encoding the message. Is equivalent to calling
|
||||
// SerializeToString() on a string and using that. Returns the empty
|
||||
// string if SerializeToString() would have returned an error.
|
||||
// Note: If you intend to generate many such strings, you may
|
||||
// reduce heap fragmentation by instead re-using the same string
|
||||
// object with calls to SerializeToString().
|
||||
string SerializeAsString() const;
|
||||
// Like SerializeAsString(), but allows missing required fields.
|
||||
string SerializePartialAsString() const;
|
||||
|
||||
// Like SerializeToString(), but appends to the data to the string's existing
|
||||
// contents. All required fields must be set.
|
||||
bool AppendToString(string* output) const;
|
||||
// Like AppendToString(), but allows missing required fields.
|
||||
bool AppendPartialToString(string* output) const;
|
||||
|
||||
// Computes the serialized size of the message. This recursively calls
|
||||
// ByteSize() on all embedded messages. If a subclass does not override
|
||||
// this, it MUST override SetCachedSize().
|
||||
virtual int ByteSize() const = 0;
|
||||
|
||||
// Serializes the message without recomputing the size. The message must
|
||||
// not have changed since the last call to ByteSize(); if it has, the results
|
||||
// are undefined.
|
||||
virtual void SerializeWithCachedSizes(
|
||||
io::CodedOutputStream* output) const = 0;
|
||||
|
||||
// Like SerializeWithCachedSizes, but writes directly to *target, returning
|
||||
// a pointer to the byte immediately after the last byte written. "target"
|
||||
// must point at a byte array of at least ByteSize() bytes.
|
||||
virtual uint8* SerializeWithCachedSizesToArray(uint8* target) const;
|
||||
|
||||
// Returns the result of the last call to ByteSize(). An embedded message's
|
||||
// size is needed both to serialize it (because embedded messages are
|
||||
// length-delimited) and to compute the outer message's size. Caching
|
||||
// the size avoids computing it multiple times.
|
||||
//
|
||||
// ByteSize() does not automatically use the cached size when available
|
||||
// because this would require invalidating it every time the message was
|
||||
// modified, which would be too hard and expensive. (E.g. if a deeply-nested
|
||||
// sub-message is changed, all of its parents' cached sizes would need to be
|
||||
// invalidated, which is too much work for an otherwise inlined setter
|
||||
// method.)
|
||||
virtual int GetCachedSize() const = 0;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite);
|
||||
};
|
||||
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_MESSAGE_LITE_H__
|
@ -0,0 +1,81 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// This header is logically internal, but is made public because it is used
|
||||
// from protocol-compiler-generated code, which may reside in other components.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_REFLECTION_OPS_H__
|
||||
#define GOOGLE_PROTOBUF_REFLECTION_OPS_H__
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/message.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
// Basic operations that can be performed using reflection.
|
||||
// These can be used as a cheap way to implement the corresponding
|
||||
// methods of the Message interface, though they are likely to be
|
||||
// slower than implementations tailored for the specific message type.
|
||||
//
|
||||
// This class should stay limited to operations needed to implement
|
||||
// the Message interface.
|
||||
//
|
||||
// This class is really a namespace that contains only static methods.
|
||||
class LIBPROTOBUF_EXPORT ReflectionOps {
|
||||
public:
|
||||
static void Copy(const Message& from, Message* to);
|
||||
static void Merge(const Message& from, Message* to);
|
||||
static void Clear(Message* message);
|
||||
static bool IsInitialized(const Message& message);
|
||||
static void DiscardUnknownFields(Message* message);
|
||||
|
||||
// Finds all unset required fields in the message and adds their full
|
||||
// paths (e.g. "foo.bar[5].baz") to *names. "prefix" will be attached to
|
||||
// the front of each name.
|
||||
static void FindInitializationErrors(const Message& message,
|
||||
const string& prefix,
|
||||
vector<string>* errors);
|
||||
|
||||
private:
|
||||
// All methods are static. No need to construct.
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionOps);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_REFLECTION_OPS_H__
|
File diff suppressed because it is too large
Load Diff
291
sgx-jvm/dependencies/root/usr/include/google/protobuf/service.h
Normal file
291
sgx-jvm/dependencies/root/usr/include/google/protobuf/service.h
Normal file
@ -0,0 +1,291 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// DEPRECATED: This module declares the abstract interfaces underlying proto2
|
||||
// RPC services. These are intented to be independent of any particular RPC
|
||||
// implementation, so that proto2 services can be used on top of a variety
|
||||
// of implementations. Starting with version 2.3.0, RPC implementations should
|
||||
// not try to build on these, but should instead provide code generator plugins
|
||||
// which generate code specific to the particular RPC implementation. This way
|
||||
// the generated code can be more appropriate for the implementation in use
|
||||
// and can avoid unnecessary layers of indirection.
|
||||
//
|
||||
//
|
||||
// When you use the protocol compiler to compile a service definition, it
|
||||
// generates two classes: An abstract interface for the service (with
|
||||
// methods matching the service definition) and a "stub" implementation.
|
||||
// A stub is just a type-safe wrapper around an RpcChannel which emulates a
|
||||
// local implementation of the service.
|
||||
//
|
||||
// For example, the service definition:
|
||||
// service MyService {
|
||||
// rpc Foo(MyRequest) returns(MyResponse);
|
||||
// }
|
||||
// will generate abstract interface "MyService" and class "MyService::Stub".
|
||||
// You could implement a MyService as follows:
|
||||
// class MyServiceImpl : public MyService {
|
||||
// public:
|
||||
// MyServiceImpl() {}
|
||||
// ~MyServiceImpl() {}
|
||||
//
|
||||
// // implements MyService ---------------------------------------
|
||||
//
|
||||
// void Foo(google::protobuf::RpcController* controller,
|
||||
// const MyRequest* request,
|
||||
// MyResponse* response,
|
||||
// Closure* done) {
|
||||
// // ... read request and fill in response ...
|
||||
// done->Run();
|
||||
// }
|
||||
// };
|
||||
// You would then register an instance of MyServiceImpl with your RPC server
|
||||
// implementation. (How to do that depends on the implementation.)
|
||||
//
|
||||
// To call a remote MyServiceImpl, first you need an RpcChannel connected to it.
|
||||
// How to construct a channel depends, again, on your RPC implementation.
|
||||
// Here we use a hypothentical "MyRpcChannel" as an example:
|
||||
// MyRpcChannel channel("rpc:hostname:1234/myservice");
|
||||
// MyRpcController controller;
|
||||
// MyServiceImpl::Stub stub(&channel);
|
||||
// FooRequest request;
|
||||
// FooRespnose response;
|
||||
//
|
||||
// // ... fill in request ...
|
||||
//
|
||||
// stub.Foo(&controller, request, &response, NewCallback(HandleResponse));
|
||||
//
|
||||
// On Thread-Safety:
|
||||
//
|
||||
// Different RPC implementations may make different guarantees about what
|
||||
// threads they may run callbacks on, and what threads the application is
|
||||
// allowed to use to call the RPC system. Portable software should be ready
|
||||
// for callbacks to be called on any thread, but should not try to call the
|
||||
// RPC system from any thread except for the ones on which it received the
|
||||
// callbacks. Realistically, though, simple software will probably want to
|
||||
// use a single-threaded RPC system while high-end software will want to
|
||||
// use multiple threads. RPC implementations should provide multiple
|
||||
// choices.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_SERVICE_H__
|
||||
#define GOOGLE_PROTOBUF_SERVICE_H__
|
||||
|
||||
#include <string>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
// Defined in this file.
|
||||
class Service;
|
||||
class RpcController;
|
||||
class RpcChannel;
|
||||
|
||||
// Defined in other files.
|
||||
class Descriptor; // descriptor.h
|
||||
class ServiceDescriptor; // descriptor.h
|
||||
class MethodDescriptor; // descriptor.h
|
||||
class Message; // message.h
|
||||
|
||||
// Abstract base interface for protocol-buffer-based RPC services. Services
|
||||
// themselves are abstract interfaces (implemented either by servers or as
|
||||
// stubs), but they subclass this base interface. The methods of this
|
||||
// interface can be used to call the methods of the Service without knowing
|
||||
// its exact type at compile time (analogous to Reflection).
|
||||
class LIBPROTOBUF_EXPORT Service {
|
||||
public:
|
||||
inline Service() {}
|
||||
virtual ~Service();
|
||||
|
||||
// When constructing a stub, you may pass STUB_OWNS_CHANNEL as the second
|
||||
// parameter to the constructor to tell it to delete its RpcChannel when
|
||||
// destroyed.
|
||||
enum ChannelOwnership {
|
||||
STUB_OWNS_CHANNEL,
|
||||
STUB_DOESNT_OWN_CHANNEL
|
||||
};
|
||||
|
||||
// Get the ServiceDescriptor describing this service and its methods.
|
||||
virtual const ServiceDescriptor* GetDescriptor() = 0;
|
||||
|
||||
// Call a method of the service specified by MethodDescriptor. This is
|
||||
// normally implemented as a simple switch() that calls the standard
|
||||
// definitions of the service's methods.
|
||||
//
|
||||
// Preconditions:
|
||||
// * method->service() == GetDescriptor()
|
||||
// * request and response are of the exact same classes as the objects
|
||||
// returned by GetRequestPrototype(method) and
|
||||
// GetResponsePrototype(method).
|
||||
// * After the call has started, the request must not be modified and the
|
||||
// response must not be accessed at all until "done" is called.
|
||||
// * "controller" is of the correct type for the RPC implementation being
|
||||
// used by this Service. For stubs, the "correct type" depends on the
|
||||
// RpcChannel which the stub is using. Server-side Service
|
||||
// implementations are expected to accept whatever type of RpcController
|
||||
// the server-side RPC implementation uses.
|
||||
//
|
||||
// Postconditions:
|
||||
// * "done" will be called when the method is complete. This may be
|
||||
// before CallMethod() returns or it may be at some point in the future.
|
||||
// * If the RPC succeeded, "response" contains the response returned by
|
||||
// the server.
|
||||
// * If the RPC failed, "response"'s contents are undefined. The
|
||||
// RpcController can be queried to determine if an error occurred and
|
||||
// possibly to get more information about the error.
|
||||
virtual void CallMethod(const MethodDescriptor* method,
|
||||
RpcController* controller,
|
||||
const Message* request,
|
||||
Message* response,
|
||||
Closure* done) = 0;
|
||||
|
||||
// CallMethod() requires that the request and response passed in are of a
|
||||
// particular subclass of Message. GetRequestPrototype() and
|
||||
// GetResponsePrototype() get the default instances of these required types.
|
||||
// You can then call Message::New() on these instances to construct mutable
|
||||
// objects which you can then pass to CallMethod().
|
||||
//
|
||||
// Example:
|
||||
// const MethodDescriptor* method =
|
||||
// service->GetDescriptor()->FindMethodByName("Foo");
|
||||
// Message* request = stub->GetRequestPrototype (method)->New();
|
||||
// Message* response = stub->GetResponsePrototype(method)->New();
|
||||
// request->ParseFromString(input);
|
||||
// service->CallMethod(method, *request, response, callback);
|
||||
virtual const Message& GetRequestPrototype(
|
||||
const MethodDescriptor* method) const = 0;
|
||||
virtual const Message& GetResponsePrototype(
|
||||
const MethodDescriptor* method) const = 0;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Service);
|
||||
};
|
||||
|
||||
// An RpcController mediates a single method call. The primary purpose of
|
||||
// the controller is to provide a way to manipulate settings specific to the
|
||||
// RPC implementation and to find out about RPC-level errors.
|
||||
//
|
||||
// The methods provided by the RpcController interface are intended to be a
|
||||
// "least common denominator" set of features which we expect all
|
||||
// implementations to support. Specific implementations may provide more
|
||||
// advanced features (e.g. deadline propagation).
|
||||
class LIBPROTOBUF_EXPORT RpcController {
|
||||
public:
|
||||
inline RpcController() {}
|
||||
virtual ~RpcController();
|
||||
|
||||
// Client-side methods ---------------------------------------------
|
||||
// These calls may be made from the client side only. Their results
|
||||
// are undefined on the server side (may crash).
|
||||
|
||||
// Resets the RpcController to its initial state so that it may be reused in
|
||||
// a new call. Must not be called while an RPC is in progress.
|
||||
virtual void Reset() = 0;
|
||||
|
||||
// After a call has finished, returns true if the call failed. The possible
|
||||
// reasons for failure depend on the RPC implementation. Failed() must not
|
||||
// be called before a call has finished. If Failed() returns true, the
|
||||
// contents of the response message are undefined.
|
||||
virtual bool Failed() const = 0;
|
||||
|
||||
// If Failed() is true, returns a human-readable description of the error.
|
||||
virtual string ErrorText() const = 0;
|
||||
|
||||
// Advises the RPC system that the caller desires that the RPC call be
|
||||
// canceled. The RPC system may cancel it immediately, may wait awhile and
|
||||
// then cancel it, or may not even cancel the call at all. If the call is
|
||||
// canceled, the "done" callback will still be called and the RpcController
|
||||
// will indicate that the call failed at that time.
|
||||
virtual void StartCancel() = 0;
|
||||
|
||||
// Server-side methods ---------------------------------------------
|
||||
// These calls may be made from the server side only. Their results
|
||||
// are undefined on the client side (may crash).
|
||||
|
||||
// Causes Failed() to return true on the client side. "reason" will be
|
||||
// incorporated into the message returned by ErrorText(). If you find
|
||||
// you need to return machine-readable information about failures, you
|
||||
// should incorporate it into your response protocol buffer and should
|
||||
// NOT call SetFailed().
|
||||
virtual void SetFailed(const string& reason) = 0;
|
||||
|
||||
// If true, indicates that the client canceled the RPC, so the server may
|
||||
// as well give up on replying to it. The server should still call the
|
||||
// final "done" callback.
|
||||
virtual bool IsCanceled() const = 0;
|
||||
|
||||
// Asks that the given callback be called when the RPC is canceled. The
|
||||
// callback will always be called exactly once. If the RPC completes without
|
||||
// being canceled, the callback will be called after completion. If the RPC
|
||||
// has already been canceled when NotifyOnCancel() is called, the callback
|
||||
// will be called immediately.
|
||||
//
|
||||
// NotifyOnCancel() must be called no more than once per request.
|
||||
virtual void NotifyOnCancel(Closure* callback) = 0;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RpcController);
|
||||
};
|
||||
|
||||
// Abstract interface for an RPC channel. An RpcChannel represents a
|
||||
// communication line to a Service which can be used to call that Service's
|
||||
// methods. The Service may be running on another machine. Normally, you
|
||||
// should not call an RpcChannel directly, but instead construct a stub Service
|
||||
// wrapping it. Example:
|
||||
// RpcChannel* channel = new MyRpcChannel("remotehost.example.com:1234");
|
||||
// MyService* service = new MyService::Stub(channel);
|
||||
// service->MyMethod(request, &response, callback);
|
||||
class LIBPROTOBUF_EXPORT RpcChannel {
|
||||
public:
|
||||
inline RpcChannel() {}
|
||||
virtual ~RpcChannel();
|
||||
|
||||
// Call the given method of the remote service. The signature of this
|
||||
// procedure looks the same as Service::CallMethod(), but the requirements
|
||||
// are less strict in one important way: the request and response objects
|
||||
// need not be of any specific class as long as their descriptors are
|
||||
// method->input_type() and method->output_type().
|
||||
virtual void CallMethod(const MethodDescriptor* method,
|
||||
RpcController* controller,
|
||||
const Message* request,
|
||||
Message* response,
|
||||
Closure* done) = 0;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RpcChannel);
|
||||
};
|
||||
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_SERVICE_H__
|
@ -0,0 +1,206 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// The routines exported by this module are subtle. If you use them, even if
|
||||
// you get the code right, it will depend on careful reasoning about atomicity
|
||||
// and memory ordering; it will be less readable, and harder to maintain. If
|
||||
// you plan to use these routines, you should have a good reason, such as solid
|
||||
// evidence that performance would otherwise suffer, or there being no
|
||||
// alternative. You should assume only properties explicitly guaranteed by the
|
||||
// specifications in this file. You are almost certainly _not_ writing code
|
||||
// just for the x86; if you assume x86 semantics, x86 hardware bugs and
|
||||
// implementations on other archtectures will cause your code to break. If you
|
||||
// do not know what you are doing, avoid these routines, and use a Mutex.
|
||||
//
|
||||
// It is incorrect to make direct assignments to/from an atomic variable.
|
||||
// You should use one of the Load or Store routines. The NoBarrier
|
||||
// versions are provided when no barriers are needed:
|
||||
// NoBarrier_Store()
|
||||
// NoBarrier_Load()
|
||||
// Although there are currently no compiler enforcement, you are encouraged
|
||||
// to use these.
|
||||
|
||||
// This header and the implementations for each platform (located in
|
||||
// atomicops_internals_*) must be kept in sync with the upstream code (V8).
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_H_
|
||||
|
||||
// Don't include this file for people not concerned about thread safety.
|
||||
#ifndef GOOGLE_PROTOBUF_NO_THREAD_SAFETY
|
||||
|
||||
#include <google/protobuf/stubs/platform_macros.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
typedef int32 Atomic32;
|
||||
#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT
|
||||
// We need to be able to go between Atomic64 and AtomicWord implicitly. This
|
||||
// means Atomic64 and AtomicWord should be the same type on 64-bit.
|
||||
#if defined(GOOGLE_PROTOBUF_OS_NACL)
|
||||
// NaCl's intptr_t is not actually 64-bits on 64-bit!
|
||||
// http://code.google.com/p/nativeclient/issues/detail?id=1162
|
||||
typedef int64 Atomic64;
|
||||
#else
|
||||
typedef intptr_t Atomic64;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
|
||||
// Atomic64 routines below, depending on your architecture.
|
||||
typedef intptr_t AtomicWord;
|
||||
|
||||
// Atomically execute:
|
||||
// result = *ptr;
|
||||
// if (*ptr == old_value)
|
||||
// *ptr = new_value;
|
||||
// return result;
|
||||
//
|
||||
// I.e., replace "*ptr" with "new_value" if "*ptr" used to be "old_value".
|
||||
// Always return the old value of "*ptr"
|
||||
//
|
||||
// This routine implies no memory barriers.
|
||||
Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value);
|
||||
|
||||
// Atomically store new_value into *ptr, returning the previous value held in
|
||||
// *ptr. This routine implies no memory barriers.
|
||||
Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value);
|
||||
|
||||
// Atomically increment *ptr by "increment". Returns the new value of
|
||||
// *ptr with the increment applied. This routine implies no memory barriers.
|
||||
Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment);
|
||||
|
||||
Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment);
|
||||
|
||||
// These following lower-level operations are typically useful only to people
|
||||
// implementing higher-level synchronization operations like spinlocks,
|
||||
// mutexes, and condition-variables. They combine CompareAndSwap(), a load, or
|
||||
// a store with appropriate memory-ordering instructions. "Acquire" operations
|
||||
// ensure that no later memory access can be reordered ahead of the operation.
|
||||
// "Release" operations ensure that no previous memory access can be reordered
|
||||
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
||||
// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
|
||||
// access.
|
||||
Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value);
|
||||
Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value);
|
||||
|
||||
void MemoryBarrier();
|
||||
void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value);
|
||||
void Acquire_Store(volatile Atomic32* ptr, Atomic32 value);
|
||||
void Release_Store(volatile Atomic32* ptr, Atomic32 value);
|
||||
|
||||
Atomic32 NoBarrier_Load(volatile const Atomic32* ptr);
|
||||
Atomic32 Acquire_Load(volatile const Atomic32* ptr);
|
||||
Atomic32 Release_Load(volatile const Atomic32* ptr);
|
||||
|
||||
// 64-bit atomic operations (only available on 64-bit processors).
|
||||
#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT
|
||||
Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value);
|
||||
Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value);
|
||||
Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment);
|
||||
Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment);
|
||||
|
||||
Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value);
|
||||
Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value);
|
||||
void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value);
|
||||
void Acquire_Store(volatile Atomic64* ptr, Atomic64 value);
|
||||
void Release_Store(volatile Atomic64* ptr, Atomic64 value);
|
||||
Atomic64 NoBarrier_Load(volatile const Atomic64* ptr);
|
||||
Atomic64 Acquire_Load(volatile const Atomic64* ptr);
|
||||
Atomic64 Release_Load(volatile const Atomic64* ptr);
|
||||
#endif // GOOGLE_PROTOBUF_ARCH_64_BIT
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
// Include our platform specific implementation.
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_ERROR \
|
||||
#error "Atomic operations are not supported on your platform"
|
||||
|
||||
// MSVC.
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
|
||||
#include <google/protobuf/stubs/atomicops_internals_x86_msvc.h>
|
||||
#else
|
||||
GOOGLE_PROTOBUF_ATOMICOPS_ERROR
|
||||
#endif
|
||||
|
||||
// Apple.
|
||||
#elif defined(GOOGLE_PROTOBUF_OS_APPLE)
|
||||
#include <google/protobuf/stubs/atomicops_internals_macosx.h>
|
||||
|
||||
// GCC.
|
||||
#elif defined(__GNUC__)
|
||||
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
|
||||
#include <google/protobuf/stubs/atomicops_internals_x86_gcc.h>
|
||||
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM)
|
||||
#include <google/protobuf/stubs/atomicops_internals_arm_gcc.h>
|
||||
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX)
|
||||
#include <google/protobuf/stubs/atomicops_internals_arm_qnx.h>
|
||||
#elif defined(GOOGLE_PROTOBUF_ARCH_MIPS)
|
||||
#include <google/protobuf/stubs/atomicops_internals_mips_gcc.h>
|
||||
#elif defined(__pnacl__)
|
||||
#include <google/protobuf/stubs/atomicops_internals_pnacl.h>
|
||||
#else
|
||||
#include <google/protobuf/stubs/atomicops_internals_generic_gcc.h>
|
||||
#endif
|
||||
|
||||
// Unknown.
|
||||
#else
|
||||
GOOGLE_PROTOBUF_ATOMICOPS_ERROR
|
||||
#endif
|
||||
|
||||
// On some platforms we need additional declarations to make AtomicWord
|
||||
// compatible with our other Atomic* types.
|
||||
#if defined(GOOGLE_PROTOBUF_OS_APPLE)
|
||||
#include <google/protobuf/stubs/atomicops_internals_atomicword_compat.h>
|
||||
#endif
|
||||
|
||||
#undef GOOGLE_PROTOBUF_ATOMICOPS_ERROR
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_H_
|
@ -0,0 +1,151 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||
//
|
||||
// LinuxKernelCmpxchg and Barrier_AtomicIncrement are from Google Gears.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_GCC_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_GCC_H_
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
// 0xffff0fc0 is the hard coded address of a function provided by
|
||||
// the kernel which implements an atomic compare-exchange. On older
|
||||
// ARM architecture revisions (pre-v6) this may be implemented using
|
||||
// a syscall. This address is stable, and in active use (hard coded)
|
||||
// by at least glibc-2.7 and the Android C library.
|
||||
typedef Atomic32 (*LinuxKernelCmpxchgFunc)(Atomic32 old_value,
|
||||
Atomic32 new_value,
|
||||
volatile Atomic32* ptr);
|
||||
LinuxKernelCmpxchgFunc pLinuxKernelCmpxchg __attribute__((weak)) =
|
||||
(LinuxKernelCmpxchgFunc) 0xffff0fc0;
|
||||
|
||||
typedef void (*LinuxKernelMemoryBarrierFunc)(void);
|
||||
LinuxKernelMemoryBarrierFunc pLinuxKernelMemoryBarrier __attribute__((weak)) =
|
||||
(LinuxKernelMemoryBarrierFunc) 0xffff0fa0;
|
||||
|
||||
|
||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 prev_value = *ptr;
|
||||
do {
|
||||
if (!pLinuxKernelCmpxchg(old_value, new_value,
|
||||
const_cast<Atomic32*>(ptr))) {
|
||||
return old_value;
|
||||
}
|
||||
prev_value = *ptr;
|
||||
} while (prev_value == old_value);
|
||||
return prev_value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 old_value;
|
||||
do {
|
||||
old_value = *ptr;
|
||||
} while (pLinuxKernelCmpxchg(old_value, new_value,
|
||||
const_cast<Atomic32*>(ptr)));
|
||||
return old_value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
return Barrier_AtomicIncrement(ptr, increment);
|
||||
}
|
||||
|
||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
for (;;) {
|
||||
// Atomic exchange the old value with an incremented one.
|
||||
Atomic32 old_value = *ptr;
|
||||
Atomic32 new_value = old_value + increment;
|
||||
if (pLinuxKernelCmpxchg(old_value, new_value,
|
||||
const_cast<Atomic32*>(ptr)) == 0) {
|
||||
// The exchange took place as expected.
|
||||
return new_value;
|
||||
}
|
||||
// Otherwise, *ptr changed mid-loop and we need to retry.
|
||||
}
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline void MemoryBarrier() {
|
||||
pLinuxKernelMemoryBarrier();
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
MemoryBarrier();
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||
Atomic32 value = *ptr;
|
||||
MemoryBarrier();
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_GCC_H_
|
@ -0,0 +1,146 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_QNX_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_QNX_H_
|
||||
|
||||
// For _smp_cmpxchg()
|
||||
#include <pthread.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
inline Atomic32 QNXCmpxchg(Atomic32 old_value,
|
||||
Atomic32 new_value,
|
||||
volatile Atomic32* ptr) {
|
||||
return static_cast<Atomic32>(
|
||||
_smp_cmpxchg((volatile unsigned *)ptr,
|
||||
(unsigned)old_value,
|
||||
(unsigned)new_value));
|
||||
}
|
||||
|
||||
|
||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 prev_value = *ptr;
|
||||
do {
|
||||
if (!QNXCmpxchg(old_value, new_value,
|
||||
const_cast<Atomic32*>(ptr))) {
|
||||
return old_value;
|
||||
}
|
||||
prev_value = *ptr;
|
||||
} while (prev_value == old_value);
|
||||
return prev_value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 old_value;
|
||||
do {
|
||||
old_value = *ptr;
|
||||
} while (QNXCmpxchg(old_value, new_value,
|
||||
const_cast<Atomic32*>(ptr)));
|
||||
return old_value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
return Barrier_AtomicIncrement(ptr, increment);
|
||||
}
|
||||
|
||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
for (;;) {
|
||||
// Atomic exchange the old value with an incremented one.
|
||||
Atomic32 old_value = *ptr;
|
||||
Atomic32 new_value = old_value + increment;
|
||||
if (QNXCmpxchg(old_value, new_value,
|
||||
const_cast<Atomic32*>(ptr)) == 0) {
|
||||
// The exchange took place as expected.
|
||||
return new_value;
|
||||
}
|
||||
// Otherwise, *ptr changed mid-loop and we need to retry.
|
||||
}
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline void MemoryBarrier() {
|
||||
__sync_synchronize();
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
MemoryBarrier();
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||
Atomic32 value = *ptr;
|
||||
MemoryBarrier();
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_QNX_H_
|
@ -0,0 +1,122 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
|
||||
|
||||
// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32,
|
||||
// which in turn means int. On some LP32 platforms, intptr_t is an int, but
|
||||
// on others, it's a long. When AtomicWord and Atomic32 are based on different
|
||||
// fundamental types, their pointers are incompatible.
|
||||
//
|
||||
// This file defines function overloads to allow both AtomicWord and Atomic32
|
||||
// data to be used with this interface.
|
||||
//
|
||||
// On LP64 platforms, AtomicWord and Atomic64 are both always long,
|
||||
// so this problem doesn't occur.
|
||||
|
||||
#if !defined(GOOGLE_PROTOBUF_ARCH_64_BIT)
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr,
|
||||
AtomicWord old_value,
|
||||
AtomicWord new_value) {
|
||||
return NoBarrier_CompareAndSwap(
|
||||
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
||||
}
|
||||
|
||||
inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr,
|
||||
AtomicWord new_value) {
|
||||
return NoBarrier_AtomicExchange(
|
||||
reinterpret_cast<volatile Atomic32*>(ptr), new_value);
|
||||
}
|
||||
|
||||
inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr,
|
||||
AtomicWord increment) {
|
||||
return NoBarrier_AtomicIncrement(
|
||||
reinterpret_cast<volatile Atomic32*>(ptr), increment);
|
||||
}
|
||||
|
||||
inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr,
|
||||
AtomicWord increment) {
|
||||
return Barrier_AtomicIncrement(
|
||||
reinterpret_cast<volatile Atomic32*>(ptr), increment);
|
||||
}
|
||||
|
||||
inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr,
|
||||
AtomicWord old_value,
|
||||
AtomicWord new_value) {
|
||||
return Acquire_CompareAndSwap(
|
||||
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
||||
}
|
||||
|
||||
inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr,
|
||||
AtomicWord old_value,
|
||||
AtomicWord new_value) {
|
||||
return Release_CompareAndSwap(
|
||||
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) {
|
||||
NoBarrier_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) {
|
||||
return Acquire_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) {
|
||||
return Release_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);
|
||||
}
|
||||
|
||||
inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) {
|
||||
return NoBarrier_Load(reinterpret_cast<volatile const Atomic32*>(ptr));
|
||||
}
|
||||
|
||||
inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) {
|
||||
return Acquire_Load(reinterpret_cast<volatile const Atomic32*>(ptr));
|
||||
}
|
||||
|
||||
inline AtomicWord Release_Load(volatile const AtomicWord* ptr) {
|
||||
return Release_Load(reinterpret_cast<volatile const Atomic32*>(ptr));
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // !defined(GOOGLE_PROTOBUF_ARCH_64_BIT)
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
|
@ -0,0 +1,139 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2013 Red Hat Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Red Hat Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_GCC_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_GCC_H_
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
__atomic_compare_exchange_n(ptr, &old_value, new_value, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||
Atomic32 new_value) {
|
||||
return __atomic_exchange_n(ptr, new_value, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
return __atomic_add_fetch(ptr, increment, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
return __atomic_add_fetch(ptr, increment, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
__atomic_compare_exchange(ptr, &old_value, &new_value, true,
|
||||
__ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
__atomic_compare_exchange_n(ptr, &old_value, new_value, true,
|
||||
__ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
__atomic_store_n(ptr, value, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
inline void MemoryBarrier() {
|
||||
__sync_synchronize();
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
__atomic_store_n(ptr, value, __ATOMIC_ACQUIRE);
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
__atomic_store_n(ptr, value, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||
return __atomic_load_n(ptr, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||
return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);
|
||||
}
|
||||
|
||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||
return __atomic_load_n(ptr, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
#ifdef __LP64__
|
||||
|
||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
__atomic_store_n(ptr, value, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
||||
return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);
|
||||
}
|
||||
|
||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
__atomic_compare_exchange_n(ptr, &old_value, new_value, true,
|
||||
__ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
__atomic_compare_exchange_n(ptr, &old_value, new_value, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
#endif // defined(__LP64__)
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_GCC_H_
|
@ -0,0 +1,225 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_
|
||||
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 prev_value;
|
||||
do {
|
||||
if (OSAtomicCompareAndSwap32(old_value, new_value,
|
||||
const_cast<Atomic32*>(ptr))) {
|
||||
return old_value;
|
||||
}
|
||||
prev_value = *ptr;
|
||||
} while (prev_value == old_value);
|
||||
return prev_value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 old_value;
|
||||
do {
|
||||
old_value = *ptr;
|
||||
} while (!OSAtomicCompareAndSwap32(old_value, new_value,
|
||||
const_cast<Atomic32*>(ptr)));
|
||||
return old_value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
return OSAtomicAdd32(increment, const_cast<Atomic32*>(ptr));
|
||||
}
|
||||
|
||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
return OSAtomicAdd32Barrier(increment, const_cast<Atomic32*>(ptr));
|
||||
}
|
||||
|
||||
inline void MemoryBarrier() {
|
||||
OSMemoryBarrier();
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 prev_value;
|
||||
do {
|
||||
if (OSAtomicCompareAndSwap32Barrier(old_value, new_value,
|
||||
const_cast<Atomic32*>(ptr))) {
|
||||
return old_value;
|
||||
}
|
||||
prev_value = *ptr;
|
||||
} while (prev_value == old_value);
|
||||
return prev_value;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
MemoryBarrier();
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||
Atomic32 value = *ptr;
|
||||
MemoryBarrier();
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
#ifdef __LP64__
|
||||
|
||||
// 64-bit implementation on 64-bit platform
|
||||
|
||||
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
Atomic64 prev_value;
|
||||
do {
|
||||
if (OSAtomicCompareAndSwap64(old_value, new_value,
|
||||
reinterpret_cast<volatile int64_t*>(ptr))) {
|
||||
return old_value;
|
||||
}
|
||||
prev_value = *ptr;
|
||||
} while (prev_value == old_value);
|
||||
return prev_value;
|
||||
}
|
||||
|
||||
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
|
||||
Atomic64 new_value) {
|
||||
Atomic64 old_value;
|
||||
do {
|
||||
old_value = *ptr;
|
||||
} while (!OSAtomicCompareAndSwap64(old_value, new_value,
|
||||
reinterpret_cast<volatile int64_t*>(ptr)));
|
||||
return old_value;
|
||||
}
|
||||
|
||||
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||
Atomic64 increment) {
|
||||
return OSAtomicAdd64(increment, reinterpret_cast<volatile int64_t*>(ptr));
|
||||
}
|
||||
|
||||
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||
Atomic64 increment) {
|
||||
return OSAtomicAdd64Barrier(increment,
|
||||
reinterpret_cast<volatile int64_t*>(ptr));
|
||||
}
|
||||
|
||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
Atomic64 prev_value;
|
||||
do {
|
||||
if (OSAtomicCompareAndSwap64Barrier(
|
||||
old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {
|
||||
return old_value;
|
||||
}
|
||||
prev_value = *ptr;
|
||||
} while (prev_value == old_value);
|
||||
return prev_value;
|
||||
}
|
||||
|
||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
// The lib kern interface does not distinguish between
|
||||
// Acquire and Release memory barriers; they are equivalent.
|
||||
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
*ptr = value;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
MemoryBarrier();
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
||||
Atomic64 value = *ptr;
|
||||
MemoryBarrier();
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
#endif // defined(__LP64__)
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_
|
@ -0,0 +1,187 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MIPS_GCC_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MIPS_GCC_H_
|
||||
|
||||
#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory")
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
// Atomically execute:
|
||||
// result = *ptr;
|
||||
// if (*ptr == old_value)
|
||||
// *ptr = new_value;
|
||||
// return result;
|
||||
//
|
||||
// I.e., replace "*ptr" with "new_value" if "*ptr" used to be "old_value".
|
||||
// Always return the old value of "*ptr"
|
||||
//
|
||||
// This routine implies no memory barriers.
|
||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 prev, tmp;
|
||||
__asm__ __volatile__(".set push\n"
|
||||
".set noreorder\n"
|
||||
"1:\n"
|
||||
"ll %0, %5\n" // prev = *ptr
|
||||
"bne %0, %3, 2f\n" // if (prev != old_value) goto 2
|
||||
"move %2, %4\n" // tmp = new_value
|
||||
"sc %2, %1\n" // *ptr = tmp (with atomic check)
|
||||
"beqz %2, 1b\n" // start again on atomic error
|
||||
"nop\n" // delay slot nop
|
||||
"2:\n"
|
||||
".set pop\n"
|
||||
: "=&r" (prev), "=m" (*ptr), "=&r" (tmp)
|
||||
: "Ir" (old_value), "r" (new_value), "m" (*ptr)
|
||||
: "memory");
|
||||
return prev;
|
||||
}
|
||||
|
||||
// Atomically store new_value into *ptr, returning the previous value held in
|
||||
// *ptr. This routine implies no memory barriers.
|
||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 temp, old;
|
||||
__asm__ __volatile__(".set push\n"
|
||||
".set noreorder\n"
|
||||
"1:\n"
|
||||
"ll %1, %2\n" // old = *ptr
|
||||
"move %0, %3\n" // temp = new_value
|
||||
"sc %0, %2\n" // *ptr = temp (with atomic check)
|
||||
"beqz %0, 1b\n" // start again on atomic error
|
||||
"nop\n" // delay slot nop
|
||||
".set pop\n"
|
||||
: "=&r" (temp), "=&r" (old), "=m" (*ptr)
|
||||
: "r" (new_value), "m" (*ptr)
|
||||
: "memory");
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
// Atomically increment *ptr by "increment". Returns the new value of
|
||||
// *ptr with the increment applied. This routine implies no memory barriers.
|
||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
Atomic32 temp, temp2;
|
||||
|
||||
__asm__ __volatile__(".set push\n"
|
||||
".set noreorder\n"
|
||||
"1:\n"
|
||||
"ll %0, %2\n" // temp = *ptr
|
||||
"addu %1, %0, %3\n" // temp2 = temp + increment
|
||||
"sc %1, %2\n" // *ptr = temp2 (with atomic check)
|
||||
"beqz %1, 1b\n" // start again on atomic error
|
||||
"addu %1, %0, %3\n" // temp2 = temp + increment
|
||||
".set pop\n"
|
||||
: "=&r" (temp), "=&r" (temp2), "=m" (*ptr)
|
||||
: "Ir" (increment), "m" (*ptr)
|
||||
: "memory");
|
||||
// temp2 now holds the final value.
|
||||
return temp2;
|
||||
}
|
||||
|
||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment);
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
return res;
|
||||
}
|
||||
|
||||
// "Acquire" operations
|
||||
// ensure that no later memory access can be reordered ahead of the operation.
|
||||
// "Release" operations ensure that no previous memory access can be reordered
|
||||
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
||||
// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
|
||||
// access.
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
return res;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
return res;
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline void MemoryBarrier() {
|
||||
__asm__ __volatile__("sync" : : : "memory");
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
MemoryBarrier();
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||
Atomic32 value = *ptr;
|
||||
MemoryBarrier();
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#undef ATOMICOPS_COMPILER_BARRIER
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MIPS_GCC_H_
|
@ -0,0 +1,73 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
return __sync_val_compare_and_swap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline void MemoryBarrier() {
|
||||
__sync_synchronize();
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
MemoryBarrier();
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
MemoryBarrier();
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||
Atomic32 value = *ptr;
|
||||
MemoryBarrier();
|
||||
return value;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_
|
@ -0,0 +1,293 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
// This struct is not part of the public API of this module; clients may not
|
||||
// use it.
|
||||
// Features of this x86. Values may not be correct before main() is run,
|
||||
// but are set conservatively.
|
||||
struct AtomicOps_x86CPUFeatureStruct {
|
||||
bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence
|
||||
// after acquire compare-and-swap.
|
||||
bool has_sse2; // Processor has SSE2.
|
||||
};
|
||||
extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures;
|
||||
|
||||
#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory")
|
||||
|
||||
// 32-bit low-level operations on any platform.
|
||||
|
||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 prev;
|
||||
__asm__ __volatile__("lock; cmpxchgl %1,%2"
|
||||
: "=a" (prev)
|
||||
: "q" (new_value), "m" (*ptr), "0" (old_value)
|
||||
: "memory");
|
||||
return prev;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||
Atomic32 new_value) {
|
||||
__asm__ __volatile__("xchgl %1,%0" // The lock prefix is implicit for xchg.
|
||||
: "=r" (new_value)
|
||||
: "m" (*ptr), "0" (new_value)
|
||||
: "memory");
|
||||
return new_value; // Now it's the previous value.
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
Atomic32 temp = increment;
|
||||
__asm__ __volatile__("lock; xaddl %0,%1"
|
||||
: "+r" (temp), "+m" (*ptr)
|
||||
: : "memory");
|
||||
// temp now holds the old value of *ptr
|
||||
return temp + increment;
|
||||
}
|
||||
|
||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
Atomic32 temp = increment;
|
||||
__asm__ __volatile__("lock; xaddl %0,%1"
|
||||
: "+r" (temp), "+m" (*ptr)
|
||||
: : "memory");
|
||||
// temp now holds the old value of *ptr
|
||||
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
||||
__asm__ __volatile__("lfence" : : : "memory");
|
||||
}
|
||||
return temp + increment;
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
||||
__asm__ __volatile__("lfence" : : : "memory");
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
#if defined(__x86_64__)
|
||||
|
||||
// 64-bit implementations of memory barrier can be simpler, because it
|
||||
// "mfence" is guaranteed to exist.
|
||||
inline void MemoryBarrier() {
|
||||
__asm__ __volatile__("mfence" : : : "memory");
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline void MemoryBarrier() {
|
||||
if (AtomicOps_Internalx86CPUFeatures.has_sse2) {
|
||||
__asm__ __volatile__("mfence" : : : "memory");
|
||||
} else { // mfence is faster but not present on PIII
|
||||
Atomic32 x = 0;
|
||||
NoBarrier_AtomicExchange(&x, 0); // acts as a barrier on PIII
|
||||
}
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
if (AtomicOps_Internalx86CPUFeatures.has_sse2) {
|
||||
*ptr = value;
|
||||
__asm__ __volatile__("mfence" : : : "memory");
|
||||
} else {
|
||||
NoBarrier_AtomicExchange(ptr, value);
|
||||
// acts as a barrier on PIII
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
*ptr = value; // An x86 store acts as a release barrier.
|
||||
// See comments in Atomic64 version of Release_Store(), below.
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||
Atomic32 value = *ptr; // An x86 load acts as a acquire barrier.
|
||||
// See comments in Atomic64 version of Release_Store(), below.
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
#if defined(__x86_64__)
|
||||
|
||||
// 64-bit low-level operations on 64-bit platform.
|
||||
|
||||
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
Atomic64 prev;
|
||||
__asm__ __volatile__("lock; cmpxchgq %1,%2"
|
||||
: "=a" (prev)
|
||||
: "q" (new_value), "m" (*ptr), "0" (old_value)
|
||||
: "memory");
|
||||
return prev;
|
||||
}
|
||||
|
||||
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
|
||||
Atomic64 new_value) {
|
||||
__asm__ __volatile__("xchgq %1,%0" // The lock prefix is implicit for xchg.
|
||||
: "=r" (new_value)
|
||||
: "m" (*ptr), "0" (new_value)
|
||||
: "memory");
|
||||
return new_value; // Now it's the previous value.
|
||||
}
|
||||
|
||||
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||
Atomic64 increment) {
|
||||
Atomic64 temp = increment;
|
||||
__asm__ __volatile__("lock; xaddq %0,%1"
|
||||
: "+r" (temp), "+m" (*ptr)
|
||||
: : "memory");
|
||||
// temp now contains the previous value of *ptr
|
||||
return temp + increment;
|
||||
}
|
||||
|
||||
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||
Atomic64 increment) {
|
||||
Atomic64 temp = increment;
|
||||
__asm__ __volatile__("lock; xaddq %0,%1"
|
||||
: "+r" (temp), "+m" (*ptr)
|
||||
: : "memory");
|
||||
// temp now contains the previous value of *ptr
|
||||
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
||||
__asm__ __volatile__("lfence" : : : "memory");
|
||||
}
|
||||
return temp + increment;
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
*ptr = value;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
|
||||
*ptr = value; // An x86 store acts as a release barrier
|
||||
// for current AMD/Intel chips as of Jan 2008.
|
||||
// See also Acquire_Load(), below.
|
||||
|
||||
// When new chips come out, check:
|
||||
// IA-32 Intel Architecture Software Developer's Manual, Volume 3:
|
||||
// System Programming Guide, Chatper 7: Multiple-processor management,
|
||||
// Section 7.2, Memory Ordering.
|
||||
// Last seen at:
|
||||
// http://developer.intel.com/design/pentium4/manuals/index_new.htm
|
||||
//
|
||||
// x86 stores/loads fail to act as barriers for a few instructions (clflush
|
||||
// maskmovdqu maskmovq movntdq movnti movntpd movntps movntq) but these are
|
||||
// not generated by the compiler, and are rare. Users of these instructions
|
||||
// need to know about cache behaviour in any case since all of these involve
|
||||
// either flushing cache lines or non-temporal cache hints.
|
||||
}
|
||||
|
||||
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
||||
Atomic64 value = *ptr; // An x86 load acts as a acquire barrier,
|
||||
// for current AMD/Intel chips as of Jan 2008.
|
||||
// See also Release_Store(), above.
|
||||
ATOMICOPS_COMPILER_BARRIER();
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
Atomic64 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
||||
__asm__ __volatile__("lfence" : : : "memory");
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
#endif // defined(__x86_64__)
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#undef ATOMICOPS_COMPILER_BARRIER
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_
|
@ -0,0 +1,150 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_
|
||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
return Barrier_AtomicIncrement(ptr, increment);
|
||||
}
|
||||
|
||||
#if !(defined(_MSC_VER) && _MSC_VER >= 1400)
|
||||
#error "We require at least vs2005 for MemoryBarrier"
|
||||
#endif
|
||||
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
NoBarrier_AtomicExchange(ptr, value);
|
||||
// acts as a barrier in this implementation
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
|
||||
// See comments in Atomic64 version of Release_Store() below.
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||
Atomic32 value = *ptr;
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
#if defined(_WIN64)
|
||||
|
||||
// 64-bit low-level operations on 64-bit platform.
|
||||
|
||||
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||
Atomic64 increment) {
|
||||
return Barrier_AtomicIncrement(ptr, increment);
|
||||
}
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
NoBarrier_AtomicExchange(ptr, value);
|
||||
// acts as a barrier in this implementation
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
|
||||
|
||||
// When new chips come out, check:
|
||||
// IA-32 Intel Architecture Software Developer's Manual, Volume 3:
|
||||
// System Programming Guide, Chatper 7: Multiple-processor management,
|
||||
// Section 7.2, Memory Ordering.
|
||||
// Last seen at:
|
||||
// http://developer.intel.com/design/pentium4/manuals/index_new.htm
|
||||
}
|
||||
|
||||
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
||||
Atomic64 value = *ptr;
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||
Atomic64 old_value,
|
||||
Atomic64 new_value) {
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
#endif // defined(_WIN64)
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_
|
1223
sgx-jvm/dependencies/root/usr/include/google/protobuf/stubs/common.h
Normal file
1223
sgx-jvm/dependencies/root/usr/include/google/protobuf/stubs/common.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,148 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
//
|
||||
// emulates google3/base/once.h
|
||||
//
|
||||
// This header is intended to be included only by internal .cc files and
|
||||
// generated .pb.cc files. Users should not use this directly.
|
||||
//
|
||||
// This is basically a portable version of pthread_once().
|
||||
//
|
||||
// This header declares:
|
||||
// * A type called ProtobufOnceType.
|
||||
// * A macro GOOGLE_PROTOBUF_DECLARE_ONCE() which declares a variable of type
|
||||
// ProtobufOnceType. This is the only legal way to declare such a variable.
|
||||
// The macro may only be used at the global scope (you cannot create local or
|
||||
// class member variables of this type).
|
||||
// * A function GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()).
|
||||
// This function, when invoked multiple times given the same ProtobufOnceType
|
||||
// object, will invoke init_func on the first call only, and will make sure
|
||||
// none of the calls return before that first call to init_func has finished.
|
||||
// * The user can provide a parameter which GoogleOnceInit() forwards to the
|
||||
// user-provided function when it is called. Usage example:
|
||||
// int a = 10;
|
||||
// GoogleOnceInit(&my_once, &MyFunctionExpectingIntArgument, &a);
|
||||
// * This implementation guarantees that ProtobufOnceType is a POD (i.e. no
|
||||
// static initializer generated).
|
||||
//
|
||||
// This implements a way to perform lazy initialization. It's more efficient
|
||||
// than using mutexes as no lock is needed if initialization has already
|
||||
// happened.
|
||||
//
|
||||
// Example usage:
|
||||
// void Init();
|
||||
// GOOGLE_PROTOBUF_DECLARE_ONCE(once_init);
|
||||
//
|
||||
// // Calls Init() exactly once.
|
||||
// void InitOnce() {
|
||||
// GoogleOnceInit(&once_init, &Init);
|
||||
// }
|
||||
//
|
||||
// Note that if GoogleOnceInit() is called before main() has begun, it must
|
||||
// only be called by the thread that will eventually call main() -- that is,
|
||||
// the thread that performs dynamic initialization. In general this is a safe
|
||||
// assumption since people don't usually construct threads before main() starts,
|
||||
// but it is technically not guaranteed. Unfortunately, Win32 provides no way
|
||||
// whatsoever to statically-initialize its synchronization primitives, so our
|
||||
// only choice is to assume that dynamic initialization is single-threaded.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_STUBS_ONCE_H__
|
||||
#define GOOGLE_PROTOBUF_STUBS_ONCE_H__
|
||||
|
||||
#include <google/protobuf/stubs/atomicops.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
#ifdef GOOGLE_PROTOBUF_NO_THREAD_SAFETY
|
||||
|
||||
typedef bool ProtobufOnceType;
|
||||
|
||||
#define GOOGLE_PROTOBUF_ONCE_INIT false
|
||||
|
||||
inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()) {
|
||||
if (!*once) {
|
||||
*once = true;
|
||||
init_func();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)(Arg),
|
||||
Arg arg) {
|
||||
if (!*once) {
|
||||
*once = true;
|
||||
init_func(arg);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
enum {
|
||||
ONCE_STATE_UNINITIALIZED = 0,
|
||||
ONCE_STATE_EXECUTING_CLOSURE = 1,
|
||||
ONCE_STATE_DONE = 2
|
||||
};
|
||||
|
||||
typedef internal::AtomicWord ProtobufOnceType;
|
||||
|
||||
#define GOOGLE_PROTOBUF_ONCE_INIT ::google::protobuf::ONCE_STATE_UNINITIALIZED
|
||||
|
||||
LIBPROTOBUF_EXPORT
|
||||
void GoogleOnceInitImpl(ProtobufOnceType* once, Closure* closure);
|
||||
|
||||
inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()) {
|
||||
if (internal::Acquire_Load(once) != ONCE_STATE_DONE) {
|
||||
internal::FunctionClosure0 func(init_func, false);
|
||||
GoogleOnceInitImpl(once, &func);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)(Arg*),
|
||||
Arg* arg) {
|
||||
if (internal::Acquire_Load(once) != ONCE_STATE_DONE) {
|
||||
internal::FunctionClosure1<Arg*> func(init_func, false, arg);
|
||||
GoogleOnceInitImpl(once, &func);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY
|
||||
|
||||
#define GOOGLE_PROTOBUF_DECLARE_ONCE(NAME) \
|
||||
::google::protobuf::ProtobufOnceType NAME = GOOGLE_PROTOBUF_ONCE_INIT
|
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_STUBS_ONCE_H__
|
@ -0,0 +1,62 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_PLATFORM_MACROS_H_
|
||||
#define GOOGLE_PROTOBUF_PLATFORM_MACROS_H_
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
// Processor architecture detection. For more info on what's defined, see:
|
||||
// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
|
||||
// http://www.agner.org/optimize/calling_conventions.pdf
|
||||
// or with gcc, run: "echo | gcc -E -dM -"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# if __LP64__
|
||||
# define GOOGLE_PROTOBUF_ARCH_64_BIT 1
|
||||
# else
|
||||
# define GOOGLE_PROTOBUF_ARCH_32_BIT 1
|
||||
# endif
|
||||
#else
|
||||
# error Host architecture was not detected as supported by protobuf
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__)
|
||||
# define GOOGLE_PROTOBUF_ARCH_X64 1
|
||||
#elif defined(__i386__)
|
||||
# define GOOGLE_PROTOBUF_ARCH_IA32 1
|
||||
#elif defined(__ARMEL__)
|
||||
# define GOOGLE_PROTOBUF_ARCH_ARM 1
|
||||
#elif defined(__mips__) || defined(__MIPSEL__)
|
||||
# define GOOGLE_PROTOBUF_ARCH_MIPS 1
|
||||
/* Else we fallback to generic GCC implementation in atomicops.h */
|
||||
#endif
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_
|
@ -0,0 +1,138 @@
|
||||
// Copyright 2005 Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// ----
|
||||
// Author: lar@google.com (Laramie Leavitt)
|
||||
//
|
||||
// Template metaprogramming utility functions.
|
||||
//
|
||||
// This code is compiled directly on many platforms, including client
|
||||
// platforms like Windows, Mac, and embedded systems. Before making
|
||||
// any changes here, make sure that you're not breaking any platforms.
|
||||
//
|
||||
//
|
||||
// The names choosen here reflect those used in tr1 and the boost::mpl
|
||||
// library, there are similar operations used in the Loki library as
|
||||
// well. I prefer the boost names for 2 reasons:
|
||||
// 1. I think that portions of the Boost libraries are more likely to
|
||||
// be included in the c++ standard.
|
||||
// 2. It is not impossible that some of the boost libraries will be
|
||||
// included in our own build in the future.
|
||||
// Both of these outcomes means that we may be able to directly replace
|
||||
// some of these with boost equivalents.
|
||||
//
|
||||
#ifndef GOOGLE_PROTOBUF_TEMPLATE_UTIL_H_
|
||||
#define GOOGLE_PROTOBUF_TEMPLATE_UTIL_H_
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
// Types small_ and big_ are guaranteed such that sizeof(small_) <
|
||||
// sizeof(big_)
|
||||
typedef char small_;
|
||||
|
||||
struct big_ {
|
||||
char dummy[2];
|
||||
};
|
||||
|
||||
// Identity metafunction.
|
||||
template <class T>
|
||||
struct identity_ {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// integral_constant, defined in tr1, is a wrapper for an integer
|
||||
// value. We don't really need this generality; we could get away
|
||||
// with hardcoding the integer type to bool. We use the fully
|
||||
// general integer_constant for compatibility with tr1.
|
||||
|
||||
template<class T, T v>
|
||||
struct integral_constant {
|
||||
static const T value = v;
|
||||
typedef T value_type;
|
||||
typedef integral_constant<T, v> type;
|
||||
};
|
||||
|
||||
template <class T, T v> const T integral_constant<T, v>::value;
|
||||
|
||||
|
||||
// Abbreviations: true_type and false_type are structs that represent boolean
|
||||
// true and false values. Also define the boost::mpl versions of those names,
|
||||
// true_ and false_.
|
||||
typedef integral_constant<bool, true> true_type;
|
||||
typedef integral_constant<bool, false> false_type;
|
||||
typedef true_type true_;
|
||||
typedef false_type false_;
|
||||
|
||||
// if_ is a templatized conditional statement.
|
||||
// if_<cond, A, B> is a compile time evaluation of cond.
|
||||
// if_<>::type contains A if cond is true, B otherwise.
|
||||
template<bool cond, typename A, typename B>
|
||||
struct if_{
|
||||
typedef A type;
|
||||
};
|
||||
|
||||
template<typename A, typename B>
|
||||
struct if_<false, A, B> {
|
||||
typedef B type;
|
||||
};
|
||||
|
||||
|
||||
// type_equals_ is a template type comparator, similar to Loki IsSameType.
|
||||
// type_equals_<A, B>::value is true iff "A" is the same type as "B".
|
||||
//
|
||||
// New code should prefer base::is_same, defined in base/type_traits.h.
|
||||
// It is functionally identical, but is_same is the standard spelling.
|
||||
template<typename A, typename B>
|
||||
struct type_equals_ : public false_ {
|
||||
};
|
||||
|
||||
template<typename A>
|
||||
struct type_equals_<A, A> : public true_ {
|
||||
};
|
||||
|
||||
// and_ is a template && operator.
|
||||
// and_<A, B>::value evaluates "A::value && B::value".
|
||||
template<typename A, typename B>
|
||||
struct and_ : public integral_constant<bool, (A::value && B::value)> {
|
||||
};
|
||||
|
||||
// or_ is a template || operator.
|
||||
// or_<A, B>::value evaluates "A::value || B::value".
|
||||
template<typename A, typename B>
|
||||
struct or_ : public integral_constant<bool, (A::value || B::value)> {
|
||||
};
|
||||
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_TEMPLATE_UTIL_H_
|
@ -0,0 +1,336 @@
|
||||
// Copyright (c) 2006, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// ----
|
||||
// Author: Matt Austern
|
||||
//
|
||||
// This code is compiled directly on many platforms, including client
|
||||
// platforms like Windows, Mac, and embedded systems. Before making
|
||||
// any changes here, make sure that you're not breaking any platforms.
|
||||
//
|
||||
// Define a small subset of tr1 type traits. The traits we define are:
|
||||
// is_integral
|
||||
// is_floating_point
|
||||
// is_pointer
|
||||
// is_enum
|
||||
// is_reference
|
||||
// is_pod
|
||||
// has_trivial_constructor
|
||||
// has_trivial_copy
|
||||
// has_trivial_assign
|
||||
// has_trivial_destructor
|
||||
// remove_const
|
||||
// remove_volatile
|
||||
// remove_cv
|
||||
// remove_reference
|
||||
// add_reference
|
||||
// remove_pointer
|
||||
// is_same
|
||||
// is_convertible
|
||||
// We can add more type traits as required.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_TYPE_TRAITS_H_
|
||||
#define GOOGLE_PROTOBUF_TYPE_TRAITS_H_
|
||||
|
||||
#include <utility> // For pair
|
||||
|
||||
#include <google/protobuf/stubs/template_util.h> // For true_type and false_type
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
template <class T> struct is_integral;
|
||||
template <class T> struct is_floating_point;
|
||||
template <class T> struct is_pointer;
|
||||
// MSVC can't compile this correctly, and neither can gcc 3.3.5 (at least)
|
||||
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
|
||||
// is_enum uses is_convertible, which is not available on MSVC.
|
||||
template <class T> struct is_enum;
|
||||
#endif
|
||||
template <class T> struct is_reference;
|
||||
template <class T> struct is_pod;
|
||||
template <class T> struct has_trivial_constructor;
|
||||
template <class T> struct has_trivial_copy;
|
||||
template <class T> struct has_trivial_assign;
|
||||
template <class T> struct has_trivial_destructor;
|
||||
template <class T> struct remove_const;
|
||||
template <class T> struct remove_volatile;
|
||||
template <class T> struct remove_cv;
|
||||
template <class T> struct remove_reference;
|
||||
template <class T> struct add_reference;
|
||||
template <class T> struct remove_pointer;
|
||||
template <class T, class U> struct is_same;
|
||||
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
|
||||
template <class From, class To> struct is_convertible;
|
||||
#endif
|
||||
|
||||
// is_integral is false except for the built-in integer types. A
|
||||
// cv-qualified type is integral if and only if the underlying type is.
|
||||
template <class T> struct is_integral : false_type { };
|
||||
template<> struct is_integral<bool> : true_type { };
|
||||
template<> struct is_integral<char> : true_type { };
|
||||
template<> struct is_integral<unsigned char> : true_type { };
|
||||
template<> struct is_integral<signed char> : true_type { };
|
||||
#if defined(_MSC_VER)
|
||||
// wchar_t is not by default a distinct type from unsigned short in
|
||||
// Microsoft C.
|
||||
// See http://msdn2.microsoft.com/en-us/library/dh8che7s(VS.80).aspx
|
||||
template<> struct is_integral<__wchar_t> : true_type { };
|
||||
#else
|
||||
template<> struct is_integral<wchar_t> : true_type { };
|
||||
#endif
|
||||
template<> struct is_integral<short> : true_type { };
|
||||
template<> struct is_integral<unsigned short> : true_type { };
|
||||
template<> struct is_integral<int> : true_type { };
|
||||
template<> struct is_integral<unsigned int> : true_type { };
|
||||
template<> struct is_integral<long> : true_type { };
|
||||
template<> struct is_integral<unsigned long> : true_type { };
|
||||
#ifdef HAVE_LONG_LONG
|
||||
template<> struct is_integral<long long> : true_type { };
|
||||
template<> struct is_integral<unsigned long long> : true_type { };
|
||||
#endif
|
||||
template <class T> struct is_integral<const T> : is_integral<T> { };
|
||||
template <class T> struct is_integral<volatile T> : is_integral<T> { };
|
||||
template <class T> struct is_integral<const volatile T> : is_integral<T> { };
|
||||
|
||||
// is_floating_point is false except for the built-in floating-point types.
|
||||
// A cv-qualified type is integral if and only if the underlying type is.
|
||||
template <class T> struct is_floating_point : false_type { };
|
||||
template<> struct is_floating_point<float> : true_type { };
|
||||
template<> struct is_floating_point<double> : true_type { };
|
||||
template<> struct is_floating_point<long double> : true_type { };
|
||||
template <class T> struct is_floating_point<const T>
|
||||
: is_floating_point<T> { };
|
||||
template <class T> struct is_floating_point<volatile T>
|
||||
: is_floating_point<T> { };
|
||||
template <class T> struct is_floating_point<const volatile T>
|
||||
: is_floating_point<T> { };
|
||||
|
||||
// is_pointer is false except for pointer types. A cv-qualified type (e.g.
|
||||
// "int* const", as opposed to "int const*") is cv-qualified if and only if
|
||||
// the underlying type is.
|
||||
template <class T> struct is_pointer : false_type { };
|
||||
template <class T> struct is_pointer<T*> : true_type { };
|
||||
template <class T> struct is_pointer<const T> : is_pointer<T> { };
|
||||
template <class T> struct is_pointer<volatile T> : is_pointer<T> { };
|
||||
template <class T> struct is_pointer<const volatile T> : is_pointer<T> { };
|
||||
|
||||
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <class T> struct is_class_or_union {
|
||||
template <class U> static small_ tester(void (U::*)());
|
||||
template <class U> static big_ tester(...);
|
||||
static const bool value = sizeof(tester<T>(0)) == sizeof(small_);
|
||||
};
|
||||
|
||||
// is_convertible chokes if the first argument is an array. That's why
|
||||
// we use add_reference here.
|
||||
template <bool NotUnum, class T> struct is_enum_impl
|
||||
: is_convertible<typename add_reference<T>::type, int> { };
|
||||
|
||||
template <class T> struct is_enum_impl<true, T> : false_type { };
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Specified by TR1 [4.5.1] primary type categories.
|
||||
|
||||
// Implementation note:
|
||||
//
|
||||
// Each type is either void, integral, floating point, array, pointer,
|
||||
// reference, member object pointer, member function pointer, enum,
|
||||
// union or class. Out of these, only integral, floating point, reference,
|
||||
// class and enum types are potentially convertible to int. Therefore,
|
||||
// if a type is not a reference, integral, floating point or class and
|
||||
// is convertible to int, it's a enum. Adding cv-qualification to a type
|
||||
// does not change whether it's an enum.
|
||||
//
|
||||
// Is-convertible-to-int check is done only if all other checks pass,
|
||||
// because it can't be used with some types (e.g. void or classes with
|
||||
// inaccessible conversion operators).
|
||||
template <class T> struct is_enum
|
||||
: internal::is_enum_impl<
|
||||
is_same<T, void>::value ||
|
||||
is_integral<T>::value ||
|
||||
is_floating_point<T>::value ||
|
||||
is_reference<T>::value ||
|
||||
internal::is_class_or_union<T>::value,
|
||||
T> { };
|
||||
|
||||
template <class T> struct is_enum<const T> : is_enum<T> { };
|
||||
template <class T> struct is_enum<volatile T> : is_enum<T> { };
|
||||
template <class T> struct is_enum<const volatile T> : is_enum<T> { };
|
||||
|
||||
#endif
|
||||
|
||||
// is_reference is false except for reference types.
|
||||
template<typename T> struct is_reference : false_type {};
|
||||
template<typename T> struct is_reference<T&> : true_type {};
|
||||
|
||||
|
||||
// We can't get is_pod right without compiler help, so fail conservatively.
|
||||
// We will assume it's false except for arithmetic types, enumerations,
|
||||
// pointers and cv-qualified versions thereof. Note that std::pair<T,U>
|
||||
// is not a POD even if T and U are PODs.
|
||||
template <class T> struct is_pod
|
||||
: integral_constant<bool, (is_integral<T>::value ||
|
||||
is_floating_point<T>::value ||
|
||||
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
|
||||
// is_enum is not available on MSVC.
|
||||
is_enum<T>::value ||
|
||||
#endif
|
||||
is_pointer<T>::value)> { };
|
||||
template <class T> struct is_pod<const T> : is_pod<T> { };
|
||||
template <class T> struct is_pod<volatile T> : is_pod<T> { };
|
||||
template <class T> struct is_pod<const volatile T> : is_pod<T> { };
|
||||
|
||||
|
||||
// We can't get has_trivial_constructor right without compiler help, so
|
||||
// fail conservatively. We will assume it's false except for: (1) types
|
||||
// for which is_pod is true. (2) std::pair of types with trivial
|
||||
// constructors. (3) array of a type with a trivial constructor.
|
||||
// (4) const versions thereof.
|
||||
template <class T> struct has_trivial_constructor : is_pod<T> { };
|
||||
template <class T, class U> struct has_trivial_constructor<std::pair<T, U> >
|
||||
: integral_constant<bool,
|
||||
(has_trivial_constructor<T>::value &&
|
||||
has_trivial_constructor<U>::value)> { };
|
||||
template <class A, int N> struct has_trivial_constructor<A[N]>
|
||||
: has_trivial_constructor<A> { };
|
||||
template <class T> struct has_trivial_constructor<const T>
|
||||
: has_trivial_constructor<T> { };
|
||||
|
||||
// We can't get has_trivial_copy right without compiler help, so fail
|
||||
// conservatively. We will assume it's false except for: (1) types
|
||||
// for which is_pod is true. (2) std::pair of types with trivial copy
|
||||
// constructors. (3) array of a type with a trivial copy constructor.
|
||||
// (4) const versions thereof.
|
||||
template <class T> struct has_trivial_copy : is_pod<T> { };
|
||||
template <class T, class U> struct has_trivial_copy<std::pair<T, U> >
|
||||
: integral_constant<bool,
|
||||
(has_trivial_copy<T>::value &&
|
||||
has_trivial_copy<U>::value)> { };
|
||||
template <class A, int N> struct has_trivial_copy<A[N]>
|
||||
: has_trivial_copy<A> { };
|
||||
template <class T> struct has_trivial_copy<const T> : has_trivial_copy<T> { };
|
||||
|
||||
// We can't get has_trivial_assign right without compiler help, so fail
|
||||
// conservatively. We will assume it's false except for: (1) types
|
||||
// for which is_pod is true. (2) std::pair of types with trivial copy
|
||||
// constructors. (3) array of a type with a trivial assign constructor.
|
||||
template <class T> struct has_trivial_assign : is_pod<T> { };
|
||||
template <class T, class U> struct has_trivial_assign<std::pair<T, U> >
|
||||
: integral_constant<bool,
|
||||
(has_trivial_assign<T>::value &&
|
||||
has_trivial_assign<U>::value)> { };
|
||||
template <class A, int N> struct has_trivial_assign<A[N]>
|
||||
: has_trivial_assign<A> { };
|
||||
|
||||
// We can't get has_trivial_destructor right without compiler help, so
|
||||
// fail conservatively. We will assume it's false except for: (1) types
|
||||
// for which is_pod is true. (2) std::pair of types with trivial
|
||||
// destructors. (3) array of a type with a trivial destructor.
|
||||
// (4) const versions thereof.
|
||||
template <class T> struct has_trivial_destructor : is_pod<T> { };
|
||||
template <class T, class U> struct has_trivial_destructor<std::pair<T, U> >
|
||||
: integral_constant<bool,
|
||||
(has_trivial_destructor<T>::value &&
|
||||
has_trivial_destructor<U>::value)> { };
|
||||
template <class A, int N> struct has_trivial_destructor<A[N]>
|
||||
: has_trivial_destructor<A> { };
|
||||
template <class T> struct has_trivial_destructor<const T>
|
||||
: has_trivial_destructor<T> { };
|
||||
|
||||
// Specified by TR1 [4.7.1]
|
||||
template<typename T> struct remove_const { typedef T type; };
|
||||
template<typename T> struct remove_const<T const> { typedef T type; };
|
||||
template<typename T> struct remove_volatile { typedef T type; };
|
||||
template<typename T> struct remove_volatile<T volatile> { typedef T type; };
|
||||
template<typename T> struct remove_cv {
|
||||
typedef typename remove_const<typename remove_volatile<T>::type>::type type;
|
||||
};
|
||||
|
||||
|
||||
// Specified by TR1 [4.7.2] Reference modifications.
|
||||
template<typename T> struct remove_reference { typedef T type; };
|
||||
template<typename T> struct remove_reference<T&> { typedef T type; };
|
||||
|
||||
template <typename T> struct add_reference { typedef T& type; };
|
||||
template <typename T> struct add_reference<T&> { typedef T& type; };
|
||||
|
||||
// Specified by TR1 [4.7.4] Pointer modifications.
|
||||
template<typename T> struct remove_pointer { typedef T type; };
|
||||
template<typename T> struct remove_pointer<T*> { typedef T type; };
|
||||
template<typename T> struct remove_pointer<T* const> { typedef T type; };
|
||||
template<typename T> struct remove_pointer<T* volatile> { typedef T type; };
|
||||
template<typename T> struct remove_pointer<T* const volatile> {
|
||||
typedef T type; };
|
||||
|
||||
// Specified by TR1 [4.6] Relationships between types
|
||||
template<typename T, typename U> struct is_same : public false_type { };
|
||||
template<typename T> struct is_same<T, T> : public true_type { };
|
||||
|
||||
// Specified by TR1 [4.6] Relationships between types
|
||||
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
|
||||
namespace internal {
|
||||
|
||||
// This class is an implementation detail for is_convertible, and you
|
||||
// don't need to know how it works to use is_convertible. For those
|
||||
// who care: we declare two different functions, one whose argument is
|
||||
// of type To and one with a variadic argument list. We give them
|
||||
// return types of different size, so we can use sizeof to trick the
|
||||
// compiler into telling us which function it would have chosen if we
|
||||
// had called it with an argument of type From. See Alexandrescu's
|
||||
// _Modern C++ Design_ for more details on this sort of trick.
|
||||
|
||||
template <typename From, typename To>
|
||||
struct ConvertHelper {
|
||||
static small_ Test(To);
|
||||
static big_ Test(...);
|
||||
static From Create();
|
||||
};
|
||||
} // namespace internal
|
||||
|
||||
// Inherits from true_type if From is convertible to To, false_type otherwise.
|
||||
template <typename From, typename To>
|
||||
struct is_convertible
|
||||
: integral_constant<bool,
|
||||
sizeof(internal::ConvertHelper<From, To>::Test(
|
||||
internal::ConvertHelper<From, To>::Create()))
|
||||
== sizeof(small_)> {
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_TYPE_TRAITS_H_
|
@ -0,0 +1,369 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: jschorr@google.com (Joseph Schorr)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// Utilities for printing and parsing protocol messages in a human-readable,
|
||||
// text-based format.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_TEXT_FORMAT_H__
|
||||
#define GOOGLE_PROTOBUF_TEXT_FORMAT_H__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
namespace io {
|
||||
class ErrorCollector; // tokenizer.h
|
||||
}
|
||||
|
||||
// This class implements protocol buffer text format. Printing and parsing
|
||||
// protocol messages in text format is useful for debugging and human editing
|
||||
// of messages.
|
||||
//
|
||||
// This class is really a namespace that contains only static methods.
|
||||
class LIBPROTOBUF_EXPORT TextFormat {
|
||||
public:
|
||||
// Outputs a textual representation of the given message to the given
|
||||
// output stream.
|
||||
static bool Print(const Message& message, io::ZeroCopyOutputStream* output);
|
||||
|
||||
// Print the fields in an UnknownFieldSet. They are printed by tag number
|
||||
// only. Embedded messages are heuristically identified by attempting to
|
||||
// parse them.
|
||||
static bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
|
||||
io::ZeroCopyOutputStream* output);
|
||||
|
||||
// Like Print(), but outputs directly to a string.
|
||||
static bool PrintToString(const Message& message, string* output);
|
||||
|
||||
// Like PrintUnknownFields(), but outputs directly to a string.
|
||||
static bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
|
||||
string* output);
|
||||
|
||||
// Outputs a textual representation of the value of the field supplied on
|
||||
// the message supplied. For non-repeated fields, an index of -1 must
|
||||
// be supplied. Note that this method will print the default value for a
|
||||
// field if it is not set.
|
||||
static void PrintFieldValueToString(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index,
|
||||
string* output);
|
||||
|
||||
// Class for those users which require more fine-grained control over how
|
||||
// a protobuffer message is printed out.
|
||||
class LIBPROTOBUF_EXPORT Printer {
|
||||
public:
|
||||
Printer();
|
||||
~Printer();
|
||||
|
||||
// Like TextFormat::Print
|
||||
bool Print(const Message& message, io::ZeroCopyOutputStream* output) const;
|
||||
// Like TextFormat::PrintUnknownFields
|
||||
bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
|
||||
io::ZeroCopyOutputStream* output) const;
|
||||
// Like TextFormat::PrintToString
|
||||
bool PrintToString(const Message& message, string* output) const;
|
||||
// Like TextFormat::PrintUnknownFieldsToString
|
||||
bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
|
||||
string* output) const;
|
||||
// Like TextFormat::PrintFieldValueToString
|
||||
void PrintFieldValueToString(const Message& message,
|
||||
const FieldDescriptor* field,
|
||||
int index,
|
||||
string* output) const;
|
||||
|
||||
// Adjust the initial indent level of all output. Each indent level is
|
||||
// equal to two spaces.
|
||||
void SetInitialIndentLevel(int indent_level) {
|
||||
initial_indent_level_ = indent_level;
|
||||
}
|
||||
|
||||
// If printing in single line mode, then the entire message will be output
|
||||
// on a single line with no line breaks.
|
||||
void SetSingleLineMode(bool single_line_mode) {
|
||||
single_line_mode_ = single_line_mode;
|
||||
}
|
||||
|
||||
// Set true to print repeated primitives in a format like:
|
||||
// field_name: [1, 2, 3, 4]
|
||||
// instead of printing each value on its own line. Short format applies
|
||||
// only to primitive values -- i.e. everything except strings and
|
||||
// sub-messages/groups.
|
||||
void SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives) {
|
||||
use_short_repeated_primitives_ = use_short_repeated_primitives;
|
||||
}
|
||||
|
||||
// Set true to output UTF-8 instead of ASCII. The only difference
|
||||
// is that bytes >= 0x80 in string fields will not be escaped,
|
||||
// because they are assumed to be part of UTF-8 multi-byte
|
||||
// sequences.
|
||||
void SetUseUtf8StringEscaping(bool as_utf8) {
|
||||
utf8_string_escaping_ = as_utf8;
|
||||
}
|
||||
|
||||
private:
|
||||
// Forward declaration of an internal class used to print the text
|
||||
// output to the OutputStream (see text_format.cc for implementation).
|
||||
class TextGenerator;
|
||||
|
||||
// Internal Print method, used for writing to the OutputStream via
|
||||
// the TextGenerator class.
|
||||
void Print(const Message& message,
|
||||
TextGenerator& generator) const;
|
||||
|
||||
// Print a single field.
|
||||
void PrintField(const Message& message,
|
||||
const Reflection* reflection,
|
||||
const FieldDescriptor* field,
|
||||
TextGenerator& generator) const;
|
||||
|
||||
// Print a repeated primitive field in short form.
|
||||
void PrintShortRepeatedField(const Message& message,
|
||||
const Reflection* reflection,
|
||||
const FieldDescriptor* field,
|
||||
TextGenerator& generator) const;
|
||||
|
||||
// Print the name of a field -- i.e. everything that comes before the
|
||||
// ':' for a single name/value pair.
|
||||
void PrintFieldName(const Message& message,
|
||||
const Reflection* reflection,
|
||||
const FieldDescriptor* field,
|
||||
TextGenerator& generator) const;
|
||||
|
||||
// Outputs a textual representation of the value of the field supplied on
|
||||
// the message supplied or the default value if not set.
|
||||
void PrintFieldValue(const Message& message,
|
||||
const Reflection* reflection,
|
||||
const FieldDescriptor* field,
|
||||
int index,
|
||||
TextGenerator& generator) const;
|
||||
|
||||
// Print the fields in an UnknownFieldSet. They are printed by tag number
|
||||
// only. Embedded messages are heuristically identified by attempting to
|
||||
// parse them.
|
||||
void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
|
||||
TextGenerator& generator) const;
|
||||
|
||||
int initial_indent_level_;
|
||||
|
||||
bool single_line_mode_;
|
||||
|
||||
bool use_short_repeated_primitives_;
|
||||
|
||||
bool utf8_string_escaping_;
|
||||
};
|
||||
|
||||
// Parses a text-format protocol message from the given input stream to
|
||||
// the given message object. This function parses the format written
|
||||
// by Print().
|
||||
static bool Parse(io::ZeroCopyInputStream* input, Message* output);
|
||||
// Like Parse(), but reads directly from a string.
|
||||
static bool ParseFromString(const string& input, Message* output);
|
||||
|
||||
// Like Parse(), but the data is merged into the given message, as if
|
||||
// using Message::MergeFrom().
|
||||
static bool Merge(io::ZeroCopyInputStream* input, Message* output);
|
||||
// Like Merge(), but reads directly from a string.
|
||||
static bool MergeFromString(const string& input, Message* output);
|
||||
|
||||
// Parse the given text as a single field value and store it into the
|
||||
// given field of the given message. If the field is a repeated field,
|
||||
// the new value will be added to the end
|
||||
static bool ParseFieldValueFromString(const string& input,
|
||||
const FieldDescriptor* field,
|
||||
Message* message);
|
||||
|
||||
// Interface that TextFormat::Parser can use to find extensions.
|
||||
// This class may be extended in the future to find more information
|
||||
// like fields, etc.
|
||||
class LIBPROTOBUF_EXPORT Finder {
|
||||
public:
|
||||
virtual ~Finder();
|
||||
|
||||
// Try to find an extension of *message by fully-qualified field
|
||||
// name. Returns NULL if no extension is known for this name or number.
|
||||
virtual const FieldDescriptor* FindExtension(
|
||||
Message* message,
|
||||
const string& name) const = 0;
|
||||
};
|
||||
|
||||
// A location in the parsed text.
|
||||
struct ParseLocation {
|
||||
int line;
|
||||
int column;
|
||||
|
||||
ParseLocation() : line(-1), column(-1) {}
|
||||
ParseLocation(int line_param, int column_param)
|
||||
: line(line_param), column(column_param) {}
|
||||
};
|
||||
|
||||
// Data structure which is populated with the locations of each field
|
||||
// value parsed from the text.
|
||||
class LIBPROTOBUF_EXPORT ParseInfoTree {
|
||||
public:
|
||||
ParseInfoTree();
|
||||
~ParseInfoTree();
|
||||
|
||||
// Returns the parse location for index-th value of the field in the parsed
|
||||
// text. If none exists, returns a location with line = -1. Index should be
|
||||
// -1 for not-repeated fields.
|
||||
ParseLocation GetLocation(const FieldDescriptor* field, int index) const;
|
||||
|
||||
// Returns the parse info tree for the given field, which must be a message
|
||||
// type. The nested information tree is owned by the root tree and will be
|
||||
// deleted when it is deleted.
|
||||
ParseInfoTree* GetTreeForNested(const FieldDescriptor* field,
|
||||
int index) const;
|
||||
|
||||
private:
|
||||
// Allow the text format parser to record information into the tree.
|
||||
friend class TextFormat;
|
||||
|
||||
// Records the starting location of a single value for a field.
|
||||
void RecordLocation(const FieldDescriptor* field, ParseLocation location);
|
||||
|
||||
// Create and records a nested tree for a nested message field.
|
||||
ParseInfoTree* CreateNested(const FieldDescriptor* field);
|
||||
|
||||
// Defines the map from the index-th field descriptor to its parse location.
|
||||
typedef map<const FieldDescriptor*, vector<ParseLocation> > LocationMap;
|
||||
|
||||
// Defines the map from the index-th field descriptor to the nested parse
|
||||
// info tree.
|
||||
typedef map<const FieldDescriptor*, vector<ParseInfoTree*> > NestedMap;
|
||||
|
||||
LocationMap locations_;
|
||||
NestedMap nested_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParseInfoTree);
|
||||
};
|
||||
|
||||
// For more control over parsing, use this class.
|
||||
class LIBPROTOBUF_EXPORT Parser {
|
||||
public:
|
||||
Parser();
|
||||
~Parser();
|
||||
|
||||
// Like TextFormat::Parse().
|
||||
bool Parse(io::ZeroCopyInputStream* input, Message* output);
|
||||
// Like TextFormat::ParseFromString().
|
||||
bool ParseFromString(const string& input, Message* output);
|
||||
// Like TextFormat::Merge().
|
||||
bool Merge(io::ZeroCopyInputStream* input, Message* output);
|
||||
// Like TextFormat::MergeFromString().
|
||||
bool MergeFromString(const string& input, Message* output);
|
||||
|
||||
// Set where to report parse errors. If NULL (the default), errors will
|
||||
// be printed to stderr.
|
||||
void RecordErrorsTo(io::ErrorCollector* error_collector) {
|
||||
error_collector_ = error_collector;
|
||||
}
|
||||
|
||||
// Set how parser finds extensions. If NULL (the default), the
|
||||
// parser will use the standard Reflection object associated with
|
||||
// the message being parsed.
|
||||
void SetFinder(Finder* finder) {
|
||||
finder_ = finder;
|
||||
}
|
||||
|
||||
// Sets where location information about the parse will be written. If NULL
|
||||
// (the default), then no location will be written.
|
||||
void WriteLocationsTo(ParseInfoTree* tree) {
|
||||
parse_info_tree_ = tree;
|
||||
}
|
||||
|
||||
// Normally parsing fails if, after parsing, output->IsInitialized()
|
||||
// returns false. Call AllowPartialMessage(true) to skip this check.
|
||||
void AllowPartialMessage(bool allow) {
|
||||
allow_partial_ = allow;
|
||||
}
|
||||
|
||||
// Like TextFormat::ParseFieldValueFromString
|
||||
bool ParseFieldValueFromString(const string& input,
|
||||
const FieldDescriptor* field,
|
||||
Message* output);
|
||||
|
||||
|
||||
private:
|
||||
// Forward declaration of an internal class used to parse text
|
||||
// representations (see text_format.cc for implementation).
|
||||
class ParserImpl;
|
||||
|
||||
// Like TextFormat::Merge(). The provided implementation is used
|
||||
// to do the parsing.
|
||||
bool MergeUsingImpl(io::ZeroCopyInputStream* input,
|
||||
Message* output,
|
||||
ParserImpl* parser_impl);
|
||||
|
||||
io::ErrorCollector* error_collector_;
|
||||
Finder* finder_;
|
||||
ParseInfoTree* parse_info_tree_;
|
||||
bool allow_partial_;
|
||||
bool allow_unknown_field_;
|
||||
};
|
||||
|
||||
private:
|
||||
// Hack: ParseInfoTree declares TextFormat as a friend which should extend
|
||||
// the friendship to TextFormat::Parser::ParserImpl, but unfortunately some
|
||||
// old compilers (e.g. GCC 3.4.6) don't implement this correctly. We provide
|
||||
// helpers for ParserImpl to call methods of ParseInfoTree.
|
||||
static inline void RecordLocation(ParseInfoTree* info_tree,
|
||||
const FieldDescriptor* field,
|
||||
ParseLocation location);
|
||||
static inline ParseInfoTree* CreateNested(ParseInfoTree* info_tree,
|
||||
const FieldDescriptor* field);
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat);
|
||||
};
|
||||
|
||||
inline void TextFormat::RecordLocation(ParseInfoTree* info_tree,
|
||||
const FieldDescriptor* field,
|
||||
ParseLocation location) {
|
||||
info_tree->RecordLocation(field, location);
|
||||
}
|
||||
|
||||
inline TextFormat::ParseInfoTree* TextFormat::CreateNested(
|
||||
ParseInfoTree* info_tree, const FieldDescriptor* field) {
|
||||
return info_tree->CreateNested(field);
|
||||
}
|
||||
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_TEXT_FORMAT_H__
|
@ -0,0 +1,311 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// Contains classes used to keep track of unrecognized fields seen while
|
||||
// parsing a protocol message.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
|
||||
#define GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
|
||||
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
// TODO(jasonh): some people seem to rely on protobufs to include this for them!
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
class CodedInputStream; // coded_stream.h
|
||||
class CodedOutputStream; // coded_stream.h
|
||||
class ZeroCopyInputStream; // zero_copy_stream.h
|
||||
}
|
||||
namespace internal {
|
||||
class WireFormat; // wire_format.h
|
||||
class UnknownFieldSetFieldSkipperUsingCord;
|
||||
// extension_set_heavy.cc
|
||||
}
|
||||
|
||||
class Message; // message.h
|
||||
class UnknownField; // below
|
||||
|
||||
// An UnknownFieldSet contains fields that were encountered while parsing a
|
||||
// message but were not defined by its type. Keeping track of these can be
|
||||
// useful, especially in that they may be written if the message is serialized
|
||||
// again without being cleared in between. This means that software which
|
||||
// simply receives messages and forwards them to other servers does not need
|
||||
// to be updated every time a new field is added to the message definition.
|
||||
//
|
||||
// To get the UnknownFieldSet attached to any message, call
|
||||
// Reflection::GetUnknownFields().
|
||||
//
|
||||
// This class is necessarily tied to the protocol buffer wire format, unlike
|
||||
// the Reflection interface which is independent of any serialization scheme.
|
||||
class LIBPROTOBUF_EXPORT UnknownFieldSet {
|
||||
public:
|
||||
UnknownFieldSet();
|
||||
~UnknownFieldSet();
|
||||
|
||||
// Remove all fields.
|
||||
inline void Clear();
|
||||
|
||||
// Remove all fields and deallocate internal data objects
|
||||
void ClearAndFreeMemory();
|
||||
|
||||
// Is this set empty?
|
||||
inline bool empty() const;
|
||||
|
||||
// Merge the contents of some other UnknownFieldSet with this one.
|
||||
void MergeFrom(const UnknownFieldSet& other);
|
||||
|
||||
// Swaps the contents of some other UnknownFieldSet with this one.
|
||||
inline void Swap(UnknownFieldSet* x);
|
||||
|
||||
// Computes (an estimate of) the total number of bytes currently used for
|
||||
// storing the unknown fields in memory. Does NOT include
|
||||
// sizeof(*this) in the calculation.
|
||||
int SpaceUsedExcludingSelf() const;
|
||||
|
||||
// Version of SpaceUsed() including sizeof(*this).
|
||||
int SpaceUsed() const;
|
||||
|
||||
// Returns the number of fields present in the UnknownFieldSet.
|
||||
inline int field_count() const;
|
||||
// Get a field in the set, where 0 <= index < field_count(). The fields
|
||||
// appear in the order in which they were added.
|
||||
inline const UnknownField& field(int index) const;
|
||||
// Get a mutable pointer to a field in the set, where
|
||||
// 0 <= index < field_count(). The fields appear in the order in which
|
||||
// they were added.
|
||||
inline UnknownField* mutable_field(int index);
|
||||
|
||||
// Adding fields ---------------------------------------------------
|
||||
|
||||
void AddVarint(int number, uint64 value);
|
||||
void AddFixed32(int number, uint32 value);
|
||||
void AddFixed64(int number, uint64 value);
|
||||
void AddLengthDelimited(int number, const string& value);
|
||||
string* AddLengthDelimited(int number);
|
||||
UnknownFieldSet* AddGroup(int number);
|
||||
|
||||
// Adds an unknown field from another set.
|
||||
void AddField(const UnknownField& field);
|
||||
|
||||
// Delete fields with indices in the range [start .. start+num-1].
|
||||
// Caution: implementation moves all fields with indices [start+num .. ].
|
||||
void DeleteSubrange(int start, int num);
|
||||
|
||||
// Delete all fields with a specific field number. The order of left fields
|
||||
// is preserved.
|
||||
// Caution: implementation moves all fields after the first deleted field.
|
||||
void DeleteByNumber(int number);
|
||||
|
||||
// Parsing helpers -------------------------------------------------
|
||||
// These work exactly like the similarly-named methods of Message.
|
||||
|
||||
bool MergeFromCodedStream(io::CodedInputStream* input);
|
||||
bool ParseFromCodedStream(io::CodedInputStream* input);
|
||||
bool ParseFromZeroCopyStream(io::ZeroCopyInputStream* input);
|
||||
bool ParseFromArray(const void* data, int size);
|
||||
inline bool ParseFromString(const string& data) {
|
||||
return ParseFromArray(data.data(), data.size());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void ClearFallback();
|
||||
|
||||
vector<UnknownField>* fields_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UnknownFieldSet);
|
||||
};
|
||||
|
||||
// Represents one field in an UnknownFieldSet.
|
||||
class LIBPROTOBUF_EXPORT UnknownField {
|
||||
public:
|
||||
enum Type {
|
||||
TYPE_VARINT,
|
||||
TYPE_FIXED32,
|
||||
TYPE_FIXED64,
|
||||
TYPE_LENGTH_DELIMITED,
|
||||
TYPE_GROUP
|
||||
};
|
||||
|
||||
// The field's tag number, as seen on the wire.
|
||||
inline int number() const;
|
||||
|
||||
// The field type.
|
||||
inline Type type() const;
|
||||
|
||||
// Accessors -------------------------------------------------------
|
||||
// Each method works only for UnknownFields of the corresponding type.
|
||||
|
||||
inline uint64 varint() const;
|
||||
inline uint32 fixed32() const;
|
||||
inline uint64 fixed64() const;
|
||||
inline const string& length_delimited() const;
|
||||
inline const UnknownFieldSet& group() const;
|
||||
|
||||
inline void set_varint(uint64 value);
|
||||
inline void set_fixed32(uint32 value);
|
||||
inline void set_fixed64(uint64 value);
|
||||
inline void set_length_delimited(const string& value);
|
||||
inline string* mutable_length_delimited();
|
||||
inline UnknownFieldSet* mutable_group();
|
||||
|
||||
// Serialization API.
|
||||
// These methods can take advantage of the underlying implementation and may
|
||||
// archieve a better performance than using getters to retrieve the data and
|
||||
// do the serialization yourself.
|
||||
void SerializeLengthDelimitedNoTag(io::CodedOutputStream* output) const;
|
||||
uint8* SerializeLengthDelimitedNoTagToArray(uint8* target) const;
|
||||
|
||||
inline int GetLengthDelimitedSize() const;
|
||||
|
||||
private:
|
||||
friend class UnknownFieldSet;
|
||||
|
||||
// If this UnknownField contains a pointer, delete it.
|
||||
void Delete();
|
||||
|
||||
// Make a deep copy of any pointers in this UnknownField.
|
||||
void DeepCopy();
|
||||
|
||||
|
||||
unsigned int number_ : 29;
|
||||
unsigned int type_ : 3;
|
||||
union {
|
||||
uint64 varint_;
|
||||
uint32 fixed32_;
|
||||
uint64 fixed64_;
|
||||
mutable union {
|
||||
string* string_value_;
|
||||
} length_delimited_;
|
||||
UnknownFieldSet* group_;
|
||||
};
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
// inline implementations
|
||||
|
||||
inline void UnknownFieldSet::Clear() {
|
||||
if (fields_ != NULL) {
|
||||
ClearFallback();
|
||||
}
|
||||
}
|
||||
|
||||
inline bool UnknownFieldSet::empty() const {
|
||||
return fields_ == NULL || fields_->empty();
|
||||
}
|
||||
|
||||
inline void UnknownFieldSet::Swap(UnknownFieldSet* x) {
|
||||
std::swap(fields_, x->fields_);
|
||||
}
|
||||
|
||||
inline int UnknownFieldSet::field_count() const {
|
||||
return (fields_ == NULL) ? 0 : fields_->size();
|
||||
}
|
||||
inline const UnknownField& UnknownFieldSet::field(int index) const {
|
||||
return (*fields_)[index];
|
||||
}
|
||||
inline UnknownField* UnknownFieldSet::mutable_field(int index) {
|
||||
return &(*fields_)[index];
|
||||
}
|
||||
|
||||
inline void UnknownFieldSet::AddLengthDelimited(
|
||||
int number, const string& value) {
|
||||
AddLengthDelimited(number)->assign(value);
|
||||
}
|
||||
|
||||
|
||||
inline int UnknownField::number() const { return number_; }
|
||||
inline UnknownField::Type UnknownField::type() const {
|
||||
return static_cast<Type>(type_);
|
||||
}
|
||||
|
||||
inline uint64 UnknownField::varint () const {
|
||||
assert(type_ == TYPE_VARINT);
|
||||
return varint_;
|
||||
}
|
||||
inline uint32 UnknownField::fixed32() const {
|
||||
assert(type_ == TYPE_FIXED32);
|
||||
return fixed32_;
|
||||
}
|
||||
inline uint64 UnknownField::fixed64() const {
|
||||
assert(type_ == TYPE_FIXED64);
|
||||
return fixed64_;
|
||||
}
|
||||
inline const string& UnknownField::length_delimited() const {
|
||||
assert(type_ == TYPE_LENGTH_DELIMITED);
|
||||
return *length_delimited_.string_value_;
|
||||
}
|
||||
inline const UnknownFieldSet& UnknownField::group() const {
|
||||
assert(type_ == TYPE_GROUP);
|
||||
return *group_;
|
||||
}
|
||||
|
||||
inline void UnknownField::set_varint(uint64 value) {
|
||||
assert(type_ == TYPE_VARINT);
|
||||
varint_ = value;
|
||||
}
|
||||
inline void UnknownField::set_fixed32(uint32 value) {
|
||||
assert(type_ == TYPE_FIXED32);
|
||||
fixed32_ = value;
|
||||
}
|
||||
inline void UnknownField::set_fixed64(uint64 value) {
|
||||
assert(type_ == TYPE_FIXED64);
|
||||
fixed64_ = value;
|
||||
}
|
||||
inline void UnknownField::set_length_delimited(const string& value) {
|
||||
assert(type_ == TYPE_LENGTH_DELIMITED);
|
||||
length_delimited_.string_value_->assign(value);
|
||||
}
|
||||
inline string* UnknownField::mutable_length_delimited() {
|
||||
assert(type_ == TYPE_LENGTH_DELIMITED);
|
||||
return length_delimited_.string_value_;
|
||||
}
|
||||
inline UnknownFieldSet* UnknownField::mutable_group() {
|
||||
assert(type_ == TYPE_GROUP);
|
||||
return group_;
|
||||
}
|
||||
|
||||
inline int UnknownField::GetLengthDelimitedSize() const {
|
||||
GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type_);
|
||||
return length_delimited_.string_value_->size();
|
||||
}
|
||||
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
|
@ -0,0 +1,308 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// atenasio@google.com (Chris Atenasio) (ZigZag transform)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// This header is logically internal, but is made public because it is used
|
||||
// from protocol-compiler-generated code, which may reside in other components.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_H__
|
||||
#define GOOGLE_PROTOBUF_WIRE_FORMAT_H__
|
||||
|
||||
#include <string>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/wire_format_lite.h>
|
||||
|
||||
// Do UTF-8 validation on string type in Debug build only
|
||||
#ifndef NDEBUG
|
||||
#define GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
|
||||
#endif
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
class CodedInputStream; // coded_stream.h
|
||||
class CodedOutputStream; // coded_stream.h
|
||||
}
|
||||
class UnknownFieldSet; // unknown_field_set.h
|
||||
}
|
||||
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
// This class is for internal use by the protocol buffer library and by
|
||||
// protocol-complier-generated message classes. It must not be called
|
||||
// directly by clients.
|
||||
//
|
||||
// This class contains code for implementing the binary protocol buffer
|
||||
// wire format via reflection. The WireFormatLite class implements the
|
||||
// non-reflection based routines.
|
||||
//
|
||||
// This class is really a namespace that contains only static methods
|
||||
class LIBPROTOBUF_EXPORT WireFormat {
|
||||
public:
|
||||
|
||||
// Given a field return its WireType
|
||||
static inline WireFormatLite::WireType WireTypeForField(
|
||||
const FieldDescriptor* field);
|
||||
|
||||
// Given a FieldSescriptor::Type return its WireType
|
||||
static inline WireFormatLite::WireType WireTypeForFieldType(
|
||||
FieldDescriptor::Type type);
|
||||
|
||||
// Compute the byte size of a tag. For groups, this includes both the start
|
||||
// and end tags.
|
||||
static inline int TagSize(int field_number, FieldDescriptor::Type type);
|
||||
|
||||
// These procedures can be used to implement the methods of Message which
|
||||
// handle parsing and serialization of the protocol buffer wire format
|
||||
// using only the Reflection interface. When you ask the protocol
|
||||
// compiler to optimize for code size rather than speed, it will implement
|
||||
// those methods in terms of these procedures. Of course, these are much
|
||||
// slower than the specialized implementations which the protocol compiler
|
||||
// generates when told to optimize for speed.
|
||||
|
||||
// Read a message in protocol buffer wire format.
|
||||
//
|
||||
// This procedure reads either to the end of the input stream or through
|
||||
// a WIRETYPE_END_GROUP tag ending the message, whichever comes first.
|
||||
// It returns false if the input is invalid.
|
||||
//
|
||||
// Required fields are NOT checked by this method. You must call
|
||||
// IsInitialized() on the resulting message yourself.
|
||||
static bool ParseAndMergePartial(io::CodedInputStream* input,
|
||||
Message* message);
|
||||
|
||||
// Serialize a message in protocol buffer wire format.
|
||||
//
|
||||
// Any embedded messages within the message must have their correct sizes
|
||||
// cached. However, the top-level message need not; its size is passed as
|
||||
// a parameter to this procedure.
|
||||
//
|
||||
// These return false iff the underlying stream returns a write error.
|
||||
static void SerializeWithCachedSizes(
|
||||
const Message& message,
|
||||
int size, io::CodedOutputStream* output);
|
||||
|
||||
// Implements Message::ByteSize() via reflection. WARNING: The result
|
||||
// of this method is *not* cached anywhere. However, all embedded messages
|
||||
// will have their ByteSize() methods called, so their sizes will be cached.
|
||||
// Therefore, calling this method is sufficient to allow you to call
|
||||
// WireFormat::SerializeWithCachedSizes() on the same object.
|
||||
static int ByteSize(const Message& message);
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Helpers for dealing with unknown fields
|
||||
|
||||
// Skips a field value of the given WireType. The input should start
|
||||
// positioned immediately after the tag. If unknown_fields is non-NULL,
|
||||
// the contents of the field will be added to it.
|
||||
static bool SkipField(io::CodedInputStream* input, uint32 tag,
|
||||
UnknownFieldSet* unknown_fields);
|
||||
|
||||
// Reads and ignores a message from the input. If unknown_fields is non-NULL,
|
||||
// the contents will be added to it.
|
||||
static bool SkipMessage(io::CodedInputStream* input,
|
||||
UnknownFieldSet* unknown_fields);
|
||||
|
||||
// Write the contents of an UnknownFieldSet to the output.
|
||||
static void SerializeUnknownFields(const UnknownFieldSet& unknown_fields,
|
||||
io::CodedOutputStream* output);
|
||||
// Same as above, except writing directly to the provided buffer.
|
||||
// Requires that the buffer have sufficient capacity for
|
||||
// ComputeUnknownFieldsSize(unknown_fields).
|
||||
//
|
||||
// Returns a pointer past the last written byte.
|
||||
static uint8* SerializeUnknownFieldsToArray(
|
||||
const UnknownFieldSet& unknown_fields,
|
||||
uint8* target);
|
||||
|
||||
// Same thing except for messages that have the message_set_wire_format
|
||||
// option.
|
||||
static void SerializeUnknownMessageSetItems(
|
||||
const UnknownFieldSet& unknown_fields,
|
||||
io::CodedOutputStream* output);
|
||||
// Same as above, except writing directly to the provided buffer.
|
||||
// Requires that the buffer have sufficient capacity for
|
||||
// ComputeUnknownMessageSetItemsSize(unknown_fields).
|
||||
//
|
||||
// Returns a pointer past the last written byte.
|
||||
static uint8* SerializeUnknownMessageSetItemsToArray(
|
||||
const UnknownFieldSet& unknown_fields,
|
||||
uint8* target);
|
||||
|
||||
// Compute the size of the UnknownFieldSet on the wire.
|
||||
static int ComputeUnknownFieldsSize(const UnknownFieldSet& unknown_fields);
|
||||
|
||||
// Same thing except for messages that have the message_set_wire_format
|
||||
// option.
|
||||
static int ComputeUnknownMessageSetItemsSize(
|
||||
const UnknownFieldSet& unknown_fields);
|
||||
|
||||
|
||||
// Helper functions for encoding and decoding tags. (Inlined below and in
|
||||
// _inl.h)
|
||||
//
|
||||
// This is different from MakeTag(field->number(), field->type()) in the case
|
||||
// of packed repeated fields.
|
||||
static uint32 MakeTag(const FieldDescriptor* field);
|
||||
|
||||
// Parse a single field. The input should start out positioned immidately
|
||||
// after the tag.
|
||||
static bool ParseAndMergeField(
|
||||
uint32 tag,
|
||||
const FieldDescriptor* field, // May be NULL for unknown
|
||||
Message* message,
|
||||
io::CodedInputStream* input);
|
||||
|
||||
// Serialize a single field.
|
||||
static void SerializeFieldWithCachedSizes(
|
||||
const FieldDescriptor* field, // Cannot be NULL
|
||||
const Message& message,
|
||||
io::CodedOutputStream* output);
|
||||
|
||||
// Compute size of a single field. If the field is a message type, this
|
||||
// will call ByteSize() for the embedded message, insuring that it caches
|
||||
// its size.
|
||||
static int FieldByteSize(
|
||||
const FieldDescriptor* field, // Cannot be NULL
|
||||
const Message& message);
|
||||
|
||||
// Parse/serialize a MessageSet::Item group. Used with messages that use
|
||||
// opion message_set_wire_format = true.
|
||||
static bool ParseAndMergeMessageSetItem(
|
||||
io::CodedInputStream* input,
|
||||
Message* message);
|
||||
static void SerializeMessageSetItemWithCachedSizes(
|
||||
const FieldDescriptor* field,
|
||||
const Message& message,
|
||||
io::CodedOutputStream* output);
|
||||
static int MessageSetItemByteSize(
|
||||
const FieldDescriptor* field,
|
||||
const Message& message);
|
||||
|
||||
// Computes the byte size of a field, excluding tags. For packed fields, it
|
||||
// only includes the size of the raw data, and not the size of the total
|
||||
// length, but for other length-delimited types, the size of the length is
|
||||
// included.
|
||||
static int FieldDataOnlyByteSize(
|
||||
const FieldDescriptor* field, // Cannot be NULL
|
||||
const Message& message);
|
||||
|
||||
enum Operation {
|
||||
PARSE,
|
||||
SERIALIZE,
|
||||
};
|
||||
|
||||
// Verifies that a string field is valid UTF8, logging an error if not.
|
||||
static void VerifyUTF8String(const char* data, int size, Operation op);
|
||||
|
||||
private:
|
||||
// Verifies that a string field is valid UTF8, logging an error if not.
|
||||
static void VerifyUTF8StringFallback(
|
||||
const char* data,
|
||||
int size,
|
||||
Operation op);
|
||||
|
||||
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormat);
|
||||
};
|
||||
|
||||
// Subclass of FieldSkipper which saves skipped fields to an UnknownFieldSet.
|
||||
class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper {
|
||||
public:
|
||||
UnknownFieldSetFieldSkipper(UnknownFieldSet* unknown_fields)
|
||||
: unknown_fields_(unknown_fields) {}
|
||||
virtual ~UnknownFieldSetFieldSkipper() {}
|
||||
|
||||
// implements FieldSkipper -----------------------------------------
|
||||
virtual bool SkipField(io::CodedInputStream* input, uint32 tag);
|
||||
virtual bool SkipMessage(io::CodedInputStream* input);
|
||||
virtual void SkipUnknownEnum(int field_number, int value);
|
||||
|
||||
protected:
|
||||
UnknownFieldSet* unknown_fields_;
|
||||
};
|
||||
|
||||
// inline methods ====================================================
|
||||
|
||||
inline WireFormatLite::WireType WireFormat::WireTypeForField(
|
||||
const FieldDescriptor* field) {
|
||||
if (field->options().packed()) {
|
||||
return WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
|
||||
} else {
|
||||
return WireTypeForFieldType(field->type());
|
||||
}
|
||||
}
|
||||
|
||||
inline WireFormatLite::WireType WireFormat::WireTypeForFieldType(
|
||||
FieldDescriptor::Type type) {
|
||||
// Some compilers don't like enum -> enum casts, so we implicit_cast to
|
||||
// int first.
|
||||
return WireFormatLite::WireTypeForFieldType(
|
||||
static_cast<WireFormatLite::FieldType>(
|
||||
implicit_cast<int>(type)));
|
||||
}
|
||||
|
||||
inline uint32 WireFormat::MakeTag(const FieldDescriptor* field) {
|
||||
return WireFormatLite::MakeTag(field->number(), WireTypeForField(field));
|
||||
}
|
||||
|
||||
inline int WireFormat::TagSize(int field_number, FieldDescriptor::Type type) {
|
||||
// Some compilers don't like enum -> enum casts, so we implicit_cast to
|
||||
// int first.
|
||||
return WireFormatLite::TagSize(field_number,
|
||||
static_cast<WireFormatLite::FieldType>(
|
||||
implicit_cast<int>(type)));
|
||||
}
|
||||
|
||||
inline void WireFormat::VerifyUTF8String(const char* data, int size,
|
||||
WireFormat::Operation op) {
|
||||
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
|
||||
WireFormat::VerifyUTF8StringFallback(data, size, op);
|
||||
#else
|
||||
// Avoid the compiler warning about unsued variables.
|
||||
(void)data; (void)size; (void)op;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_H__
|
@ -0,0 +1,626 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// atenasio@google.com (Chris Atenasio) (ZigZag transform)
|
||||
// wink@google.com (Wink Saville) (refactored from wire_format.h)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// This header is logically internal, but is made public because it is used
|
||||
// from protocol-compiler-generated code, which may reside in other components.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
|
||||
#define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
|
||||
|
||||
#include <string>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/message_lite.h>
|
||||
#include <google/protobuf/io/coded_stream.h> // for CodedOutputStream::Varint32Size
|
||||
|
||||
namespace google {
|
||||
|
||||
namespace protobuf {
|
||||
template <typename T> class RepeatedField; // repeated_field.h
|
||||
}
|
||||
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
class StringPieceField;
|
||||
|
||||
// This class is for internal use by the protocol buffer library and by
|
||||
// protocol-complier-generated message classes. It must not be called
|
||||
// directly by clients.
|
||||
//
|
||||
// This class contains helpers for implementing the binary protocol buffer
|
||||
// wire format without the need for reflection. Use WireFormat when using
|
||||
// reflection.
|
||||
//
|
||||
// This class is really a namespace that contains only static methods.
|
||||
class LIBPROTOBUF_EXPORT WireFormatLite {
|
||||
public:
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Helper constants and functions related to the format. These are
|
||||
// mostly meant for internal and generated code to use.
|
||||
|
||||
// The wire format is composed of a sequence of tag/value pairs, each
|
||||
// of which contains the value of one field (or one element of a repeated
|
||||
// field). Each tag is encoded as a varint. The lower bits of the tag
|
||||
// identify its wire type, which specifies the format of the data to follow.
|
||||
// The rest of the bits contain the field number. Each type of field (as
|
||||
// declared by FieldDescriptor::Type, in descriptor.h) maps to one of
|
||||
// these wire types. Immediately following each tag is the field's value,
|
||||
// encoded in the format specified by the wire type. Because the tag
|
||||
// identifies the encoding of this data, it is possible to skip
|
||||
// unrecognized fields for forwards compatibility.
|
||||
|
||||
enum WireType {
|
||||
WIRETYPE_VARINT = 0,
|
||||
WIRETYPE_FIXED64 = 1,
|
||||
WIRETYPE_LENGTH_DELIMITED = 2,
|
||||
WIRETYPE_START_GROUP = 3,
|
||||
WIRETYPE_END_GROUP = 4,
|
||||
WIRETYPE_FIXED32 = 5,
|
||||
};
|
||||
|
||||
// Lite alternative to FieldDescriptor::Type. Must be kept in sync.
|
||||
enum FieldType {
|
||||
TYPE_DOUBLE = 1,
|
||||
TYPE_FLOAT = 2,
|
||||
TYPE_INT64 = 3,
|
||||
TYPE_UINT64 = 4,
|
||||
TYPE_INT32 = 5,
|
||||
TYPE_FIXED64 = 6,
|
||||
TYPE_FIXED32 = 7,
|
||||
TYPE_BOOL = 8,
|
||||
TYPE_STRING = 9,
|
||||
TYPE_GROUP = 10,
|
||||
TYPE_MESSAGE = 11,
|
||||
TYPE_BYTES = 12,
|
||||
TYPE_UINT32 = 13,
|
||||
TYPE_ENUM = 14,
|
||||
TYPE_SFIXED32 = 15,
|
||||
TYPE_SFIXED64 = 16,
|
||||
TYPE_SINT32 = 17,
|
||||
TYPE_SINT64 = 18,
|
||||
MAX_FIELD_TYPE = 18,
|
||||
};
|
||||
|
||||
// Lite alternative to FieldDescriptor::CppType. Must be kept in sync.
|
||||
enum CppType {
|
||||
CPPTYPE_INT32 = 1,
|
||||
CPPTYPE_INT64 = 2,
|
||||
CPPTYPE_UINT32 = 3,
|
||||
CPPTYPE_UINT64 = 4,
|
||||
CPPTYPE_DOUBLE = 5,
|
||||
CPPTYPE_FLOAT = 6,
|
||||
CPPTYPE_BOOL = 7,
|
||||
CPPTYPE_ENUM = 8,
|
||||
CPPTYPE_STRING = 9,
|
||||
CPPTYPE_MESSAGE = 10,
|
||||
MAX_CPPTYPE = 10,
|
||||
};
|
||||
|
||||
// Helper method to get the CppType for a particular Type.
|
||||
static CppType FieldTypeToCppType(FieldType type);
|
||||
|
||||
// Given a FieldSescriptor::Type return its WireType
|
||||
static inline WireFormatLite::WireType WireTypeForFieldType(
|
||||
WireFormatLite::FieldType type) {
|
||||
return kWireTypeForFieldType[type];
|
||||
}
|
||||
|
||||
// Number of bits in a tag which identify the wire type.
|
||||
static const int kTagTypeBits = 3;
|
||||
// Mask for those bits.
|
||||
static const uint32 kTagTypeMask = (1 << kTagTypeBits) - 1;
|
||||
|
||||
// Helper functions for encoding and decoding tags. (Inlined below and in
|
||||
// _inl.h)
|
||||
//
|
||||
// This is different from MakeTag(field->number(), field->type()) in the case
|
||||
// of packed repeated fields.
|
||||
static uint32 MakeTag(int field_number, WireType type);
|
||||
static WireType GetTagWireType(uint32 tag);
|
||||
static int GetTagFieldNumber(uint32 tag);
|
||||
|
||||
// Compute the byte size of a tag. For groups, this includes both the start
|
||||
// and end tags.
|
||||
static inline int TagSize(int field_number, WireFormatLite::FieldType type);
|
||||
|
||||
// Skips a field value with the given tag. The input should start
|
||||
// positioned immediately after the tag. Skipped values are simply discarded,
|
||||
// not recorded anywhere. See WireFormat::SkipField() for a version that
|
||||
// records to an UnknownFieldSet.
|
||||
static bool SkipField(io::CodedInputStream* input, uint32 tag);
|
||||
|
||||
// Reads and ignores a message from the input. Skipped values are simply
|
||||
// discarded, not recorded anywhere. See WireFormat::SkipMessage() for a
|
||||
// version that records to an UnknownFieldSet.
|
||||
static bool SkipMessage(io::CodedInputStream* input);
|
||||
|
||||
// This macro does the same thing as WireFormatLite::MakeTag(), but the
|
||||
// result is usable as a compile-time constant, which makes it usable
|
||||
// as a switch case or a template input. WireFormatLite::MakeTag() is more
|
||||
// type-safe, though, so prefer it if possible.
|
||||
#define GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(FIELD_NUMBER, TYPE) \
|
||||
static_cast<uint32>( \
|
||||
((FIELD_NUMBER) << ::google::protobuf::internal::WireFormatLite::kTagTypeBits) \
|
||||
| (TYPE))
|
||||
|
||||
// These are the tags for the old MessageSet format, which was defined as:
|
||||
// message MessageSet {
|
||||
// repeated group Item = 1 {
|
||||
// required int32 type_id = 2;
|
||||
// required string message = 3;
|
||||
// }
|
||||
// }
|
||||
static const int kMessageSetItemNumber = 1;
|
||||
static const int kMessageSetTypeIdNumber = 2;
|
||||
static const int kMessageSetMessageNumber = 3;
|
||||
static const int kMessageSetItemStartTag =
|
||||
GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetItemNumber,
|
||||
WireFormatLite::WIRETYPE_START_GROUP);
|
||||
static const int kMessageSetItemEndTag =
|
||||
GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetItemNumber,
|
||||
WireFormatLite::WIRETYPE_END_GROUP);
|
||||
static const int kMessageSetTypeIdTag =
|
||||
GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetTypeIdNumber,
|
||||
WireFormatLite::WIRETYPE_VARINT);
|
||||
static const int kMessageSetMessageTag =
|
||||
GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetMessageNumber,
|
||||
WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
|
||||
|
||||
// Byte size of all tags of a MessageSet::Item combined.
|
||||
static const int kMessageSetItemTagsSize;
|
||||
|
||||
// Helper functions for converting between floats/doubles and IEEE-754
|
||||
// uint32s/uint64s so that they can be written. (Assumes your platform
|
||||
// uses IEEE-754 floats.)
|
||||
static uint32 EncodeFloat(float value);
|
||||
static float DecodeFloat(uint32 value);
|
||||
static uint64 EncodeDouble(double value);
|
||||
static double DecodeDouble(uint64 value);
|
||||
|
||||
// Helper functions for mapping signed integers to unsigned integers in
|
||||
// such a way that numbers with small magnitudes will encode to smaller
|
||||
// varints. If you simply static_cast a negative number to an unsigned
|
||||
// number and varint-encode it, it will always take 10 bytes, defeating
|
||||
// the purpose of varint. So, for the "sint32" and "sint64" field types,
|
||||
// we ZigZag-encode the values.
|
||||
static uint32 ZigZagEncode32(int32 n);
|
||||
static int32 ZigZagDecode32(uint32 n);
|
||||
static uint64 ZigZagEncode64(int64 n);
|
||||
static int64 ZigZagDecode64(uint64 n)
|
||||
#ifdef __arm__
|
||||
__attribute__((__optimize__(0)))
|
||||
#endif
|
||||
;
|
||||
|
||||
// =================================================================
|
||||
// Methods for reading/writing individual field. The implementations
|
||||
// of these methods are defined in wire_format_lite_inl.h; you must #include
|
||||
// that file to use these.
|
||||
|
||||
// Avoid ugly line wrapping
|
||||
#define input io::CodedInputStream* input
|
||||
#define output io::CodedOutputStream* output
|
||||
#define field_number int field_number
|
||||
#define INL GOOGLE_ATTRIBUTE_ALWAYS_INLINE
|
||||
|
||||
// Read fields, not including tags. The assumption is that you already
|
||||
// read the tag to determine what field to read.
|
||||
|
||||
// For primitive fields, we just use a templatized routine parameterized by
|
||||
// the represented type and the FieldType. These are specialized with the
|
||||
// appropriate definition for each declared type.
|
||||
template <typename CType, enum FieldType DeclaredType>
|
||||
static inline bool ReadPrimitive(input, CType* value) INL;
|
||||
|
||||
// Reads repeated primitive values, with optimizations for repeats.
|
||||
// tag_size and tag should both be compile-time constants provided by the
|
||||
// protocol compiler.
|
||||
template <typename CType, enum FieldType DeclaredType>
|
||||
static inline bool ReadRepeatedPrimitive(int tag_size,
|
||||
uint32 tag,
|
||||
input,
|
||||
RepeatedField<CType>* value) INL;
|
||||
|
||||
// Identical to ReadRepeatedPrimitive, except will not inline the
|
||||
// implementation.
|
||||
template <typename CType, enum FieldType DeclaredType>
|
||||
static bool ReadRepeatedPrimitiveNoInline(int tag_size,
|
||||
uint32 tag,
|
||||
input,
|
||||
RepeatedField<CType>* value);
|
||||
|
||||
// Reads a primitive value directly from the provided buffer. It returns a
|
||||
// pointer past the segment of data that was read.
|
||||
//
|
||||
// This is only implemented for the types with fixed wire size, e.g.
|
||||
// float, double, and the (s)fixed* types.
|
||||
template <typename CType, enum FieldType DeclaredType>
|
||||
static inline const uint8* ReadPrimitiveFromArray(const uint8* buffer,
|
||||
CType* value) INL;
|
||||
|
||||
// Reads a primitive packed field.
|
||||
//
|
||||
// This is only implemented for packable types.
|
||||
template <typename CType, enum FieldType DeclaredType>
|
||||
static inline bool ReadPackedPrimitive(input,
|
||||
RepeatedField<CType>* value) INL;
|
||||
|
||||
// Identical to ReadPackedPrimitive, except will not inline the
|
||||
// implementation.
|
||||
template <typename CType, enum FieldType DeclaredType>
|
||||
static bool ReadPackedPrimitiveNoInline(input, RepeatedField<CType>* value);
|
||||
|
||||
// Read a packed enum field. Values for which is_valid() returns false are
|
||||
// dropped.
|
||||
static bool ReadPackedEnumNoInline(input,
|
||||
bool (*is_valid)(int),
|
||||
RepeatedField<int>* value);
|
||||
|
||||
static bool ReadString(input, string* value);
|
||||
static bool ReadBytes (input, string* value);
|
||||
|
||||
static inline bool ReadGroup (field_number, input, MessageLite* value);
|
||||
static inline bool ReadMessage(input, MessageLite* value);
|
||||
|
||||
// Like above, but de-virtualize the call to MergePartialFromCodedStream().
|
||||
// The pointer must point at an instance of MessageType, *not* a subclass (or
|
||||
// the subclass must not override MergePartialFromCodedStream()).
|
||||
template<typename MessageType>
|
||||
static inline bool ReadGroupNoVirtual(field_number, input,
|
||||
MessageType* value);
|
||||
template<typename MessageType>
|
||||
static inline bool ReadMessageNoVirtual(input, MessageType* value);
|
||||
|
||||
// Write a tag. The Write*() functions typically include the tag, so
|
||||
// normally there's no need to call this unless using the Write*NoTag()
|
||||
// variants.
|
||||
static inline void WriteTag(field_number, WireType type, output) INL;
|
||||
|
||||
// Write fields, without tags.
|
||||
static inline void WriteInt32NoTag (int32 value, output) INL;
|
||||
static inline void WriteInt64NoTag (int64 value, output) INL;
|
||||
static inline void WriteUInt32NoTag (uint32 value, output) INL;
|
||||
static inline void WriteUInt64NoTag (uint64 value, output) INL;
|
||||
static inline void WriteSInt32NoTag (int32 value, output) INL;
|
||||
static inline void WriteSInt64NoTag (int64 value, output) INL;
|
||||
static inline void WriteFixed32NoTag (uint32 value, output) INL;
|
||||
static inline void WriteFixed64NoTag (uint64 value, output) INL;
|
||||
static inline void WriteSFixed32NoTag(int32 value, output) INL;
|
||||
static inline void WriteSFixed64NoTag(int64 value, output) INL;
|
||||
static inline void WriteFloatNoTag (float value, output) INL;
|
||||
static inline void WriteDoubleNoTag (double value, output) INL;
|
||||
static inline void WriteBoolNoTag (bool value, output) INL;
|
||||
static inline void WriteEnumNoTag (int value, output) INL;
|
||||
|
||||
// Write fields, including tags.
|
||||
static void WriteInt32 (field_number, int32 value, output);
|
||||
static void WriteInt64 (field_number, int64 value, output);
|
||||
static void WriteUInt32 (field_number, uint32 value, output);
|
||||
static void WriteUInt64 (field_number, uint64 value, output);
|
||||
static void WriteSInt32 (field_number, int32 value, output);
|
||||
static void WriteSInt64 (field_number, int64 value, output);
|
||||
static void WriteFixed32 (field_number, uint32 value, output);
|
||||
static void WriteFixed64 (field_number, uint64 value, output);
|
||||
static void WriteSFixed32(field_number, int32 value, output);
|
||||
static void WriteSFixed64(field_number, int64 value, output);
|
||||
static void WriteFloat (field_number, float value, output);
|
||||
static void WriteDouble (field_number, double value, output);
|
||||
static void WriteBool (field_number, bool value, output);
|
||||
static void WriteEnum (field_number, int value, output);
|
||||
|
||||
static void WriteString(field_number, const string& value, output);
|
||||
static void WriteBytes (field_number, const string& value, output);
|
||||
|
||||
static void WriteGroup(
|
||||
field_number, const MessageLite& value, output);
|
||||
static void WriteMessage(
|
||||
field_number, const MessageLite& value, output);
|
||||
// Like above, but these will check if the output stream has enough
|
||||
// space to write directly to a flat array.
|
||||
static void WriteGroupMaybeToArray(
|
||||
field_number, const MessageLite& value, output);
|
||||
static void WriteMessageMaybeToArray(
|
||||
field_number, const MessageLite& value, output);
|
||||
|
||||
// Like above, but de-virtualize the call to SerializeWithCachedSizes(). The
|
||||
// pointer must point at an instance of MessageType, *not* a subclass (or
|
||||
// the subclass must not override SerializeWithCachedSizes()).
|
||||
template<typename MessageType>
|
||||
static inline void WriteGroupNoVirtual(
|
||||
field_number, const MessageType& value, output);
|
||||
template<typename MessageType>
|
||||
static inline void WriteMessageNoVirtual(
|
||||
field_number, const MessageType& value, output);
|
||||
|
||||
#undef output
|
||||
#define output uint8* target
|
||||
|
||||
// Like above, but use only *ToArray methods of CodedOutputStream.
|
||||
static inline uint8* WriteTagToArray(field_number, WireType type, output) INL;
|
||||
|
||||
// Write fields, without tags.
|
||||
static inline uint8* WriteInt32NoTagToArray (int32 value, output) INL;
|
||||
static inline uint8* WriteInt64NoTagToArray (int64 value, output) INL;
|
||||
static inline uint8* WriteUInt32NoTagToArray (uint32 value, output) INL;
|
||||
static inline uint8* WriteUInt64NoTagToArray (uint64 value, output) INL;
|
||||
static inline uint8* WriteSInt32NoTagToArray (int32 value, output) INL;
|
||||
static inline uint8* WriteSInt64NoTagToArray (int64 value, output) INL;
|
||||
static inline uint8* WriteFixed32NoTagToArray (uint32 value, output) INL;
|
||||
static inline uint8* WriteFixed64NoTagToArray (uint64 value, output) INL;
|
||||
static inline uint8* WriteSFixed32NoTagToArray(int32 value, output) INL;
|
||||
static inline uint8* WriteSFixed64NoTagToArray(int64 value, output) INL;
|
||||
static inline uint8* WriteFloatNoTagToArray (float value, output) INL;
|
||||
static inline uint8* WriteDoubleNoTagToArray (double value, output) INL;
|
||||
static inline uint8* WriteBoolNoTagToArray (bool value, output) INL;
|
||||
static inline uint8* WriteEnumNoTagToArray (int value, output) INL;
|
||||
|
||||
// Write fields, including tags.
|
||||
static inline uint8* WriteInt32ToArray(
|
||||
field_number, int32 value, output) INL;
|
||||
static inline uint8* WriteInt64ToArray(
|
||||
field_number, int64 value, output) INL;
|
||||
static inline uint8* WriteUInt32ToArray(
|
||||
field_number, uint32 value, output) INL;
|
||||
static inline uint8* WriteUInt64ToArray(
|
||||
field_number, uint64 value, output) INL;
|
||||
static inline uint8* WriteSInt32ToArray(
|
||||
field_number, int32 value, output) INL;
|
||||
static inline uint8* WriteSInt64ToArray(
|
||||
field_number, int64 value, output) INL;
|
||||
static inline uint8* WriteFixed32ToArray(
|
||||
field_number, uint32 value, output) INL;
|
||||
static inline uint8* WriteFixed64ToArray(
|
||||
field_number, uint64 value, output) INL;
|
||||
static inline uint8* WriteSFixed32ToArray(
|
||||
field_number, int32 value, output) INL;
|
||||
static inline uint8* WriteSFixed64ToArray(
|
||||
field_number, int64 value, output) INL;
|
||||
static inline uint8* WriteFloatToArray(
|
||||
field_number, float value, output) INL;
|
||||
static inline uint8* WriteDoubleToArray(
|
||||
field_number, double value, output) INL;
|
||||
static inline uint8* WriteBoolToArray(
|
||||
field_number, bool value, output) INL;
|
||||
static inline uint8* WriteEnumToArray(
|
||||
field_number, int value, output) INL;
|
||||
|
||||
static inline uint8* WriteStringToArray(
|
||||
field_number, const string& value, output) INL;
|
||||
static inline uint8* WriteBytesToArray(
|
||||
field_number, const string& value, output) INL;
|
||||
|
||||
static inline uint8* WriteGroupToArray(
|
||||
field_number, const MessageLite& value, output) INL;
|
||||
static inline uint8* WriteMessageToArray(
|
||||
field_number, const MessageLite& value, output) INL;
|
||||
|
||||
// Like above, but de-virtualize the call to SerializeWithCachedSizes(). The
|
||||
// pointer must point at an instance of MessageType, *not* a subclass (or
|
||||
// the subclass must not override SerializeWithCachedSizes()).
|
||||
template<typename MessageType>
|
||||
static inline uint8* WriteGroupNoVirtualToArray(
|
||||
field_number, const MessageType& value, output) INL;
|
||||
template<typename MessageType>
|
||||
static inline uint8* WriteMessageNoVirtualToArray(
|
||||
field_number, const MessageType& value, output) INL;
|
||||
|
||||
#undef output
|
||||
#undef input
|
||||
#undef INL
|
||||
|
||||
#undef field_number
|
||||
|
||||
// Compute the byte size of a field. The XxSize() functions do NOT include
|
||||
// the tag, so you must also call TagSize(). (This is because, for repeated
|
||||
// fields, you should only call TagSize() once and multiply it by the element
|
||||
// count, but you may have to call XxSize() for each individual element.)
|
||||
static inline int Int32Size ( int32 value);
|
||||
static inline int Int64Size ( int64 value);
|
||||
static inline int UInt32Size (uint32 value);
|
||||
static inline int UInt64Size (uint64 value);
|
||||
static inline int SInt32Size ( int32 value);
|
||||
static inline int SInt64Size ( int64 value);
|
||||
static inline int EnumSize ( int value);
|
||||
|
||||
// These types always have the same size.
|
||||
static const int kFixed32Size = 4;
|
||||
static const int kFixed64Size = 8;
|
||||
static const int kSFixed32Size = 4;
|
||||
static const int kSFixed64Size = 8;
|
||||
static const int kFloatSize = 4;
|
||||
static const int kDoubleSize = 8;
|
||||
static const int kBoolSize = 1;
|
||||
|
||||
static inline int StringSize(const string& value);
|
||||
static inline int BytesSize (const string& value);
|
||||
|
||||
static inline int GroupSize (const MessageLite& value);
|
||||
static inline int MessageSize(const MessageLite& value);
|
||||
|
||||
// Like above, but de-virtualize the call to ByteSize(). The
|
||||
// pointer must point at an instance of MessageType, *not* a subclass (or
|
||||
// the subclass must not override ByteSize()).
|
||||
template<typename MessageType>
|
||||
static inline int GroupSizeNoVirtual (const MessageType& value);
|
||||
template<typename MessageType>
|
||||
static inline int MessageSizeNoVirtual(const MessageType& value);
|
||||
|
||||
// Given the length of data, calculate the byte size of the data on the
|
||||
// wire if we encode the data as a length delimited field.
|
||||
static inline int LengthDelimitedSize(int length);
|
||||
|
||||
private:
|
||||
// A helper method for the repeated primitive reader. This method has
|
||||
// optimizations for primitive types that have fixed size on the wire, and
|
||||
// can be read using potentially faster paths.
|
||||
template <typename CType, enum FieldType DeclaredType>
|
||||
static inline bool ReadRepeatedFixedSizePrimitive(
|
||||
int tag_size,
|
||||
uint32 tag,
|
||||
google::protobuf::io::CodedInputStream* input,
|
||||
RepeatedField<CType>* value) GOOGLE_ATTRIBUTE_ALWAYS_INLINE;
|
||||
|
||||
static const CppType kFieldTypeToCppTypeMap[];
|
||||
static const WireFormatLite::WireType kWireTypeForFieldType[];
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormatLite);
|
||||
};
|
||||
|
||||
// A class which deals with unknown values. The default implementation just
|
||||
// discards them. WireFormat defines a subclass which writes to an
|
||||
// UnknownFieldSet. This class is used by ExtensionSet::ParseField(), since
|
||||
// ExtensionSet is part of the lite library but UnknownFieldSet is not.
|
||||
class LIBPROTOBUF_EXPORT FieldSkipper {
|
||||
public:
|
||||
FieldSkipper() {}
|
||||
virtual ~FieldSkipper() {}
|
||||
|
||||
// Skip a field whose tag has already been consumed.
|
||||
virtual bool SkipField(io::CodedInputStream* input, uint32 tag);
|
||||
|
||||
// Skip an entire message or group, up to an end-group tag (which is consumed)
|
||||
// or end-of-stream.
|
||||
virtual bool SkipMessage(io::CodedInputStream* input);
|
||||
|
||||
// Deal with an already-parsed unrecognized enum value. The default
|
||||
// implementation does nothing, but the UnknownFieldSet-based implementation
|
||||
// saves it as an unknown varint.
|
||||
virtual void SkipUnknownEnum(int field_number, int value);
|
||||
};
|
||||
|
||||
// inline methods ====================================================
|
||||
|
||||
inline WireFormatLite::CppType
|
||||
WireFormatLite::FieldTypeToCppType(FieldType type) {
|
||||
return kFieldTypeToCppTypeMap[type];
|
||||
}
|
||||
|
||||
inline uint32 WireFormatLite::MakeTag(int field_number, WireType type) {
|
||||
return GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(field_number, type);
|
||||
}
|
||||
|
||||
inline WireFormatLite::WireType WireFormatLite::GetTagWireType(uint32 tag) {
|
||||
return static_cast<WireType>(tag & kTagTypeMask);
|
||||
}
|
||||
|
||||
inline int WireFormatLite::GetTagFieldNumber(uint32 tag) {
|
||||
return static_cast<int>(tag >> kTagTypeBits);
|
||||
}
|
||||
|
||||
inline int WireFormatLite::TagSize(int field_number,
|
||||
WireFormatLite::FieldType type) {
|
||||
int result = io::CodedOutputStream::VarintSize32(
|
||||
field_number << kTagTypeBits);
|
||||
if (type == TYPE_GROUP) {
|
||||
// Groups have both a start and an end tag.
|
||||
return result * 2;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
inline uint32 WireFormatLite::EncodeFloat(float value) {
|
||||
union {float f; uint32 i;};
|
||||
f = value;
|
||||
return i;
|
||||
}
|
||||
|
||||
inline float WireFormatLite::DecodeFloat(uint32 value) {
|
||||
union {float f; uint32 i;};
|
||||
i = value;
|
||||
return f;
|
||||
}
|
||||
|
||||
inline uint64 WireFormatLite::EncodeDouble(double value) {
|
||||
union {double f; uint64 i;};
|
||||
f = value;
|
||||
return i;
|
||||
}
|
||||
|
||||
inline double WireFormatLite::DecodeDouble(uint64 value) {
|
||||
union {double f; uint64 i;};
|
||||
i = value;
|
||||
return f;
|
||||
}
|
||||
|
||||
// ZigZag Transform: Encodes signed integers so that they can be
|
||||
// effectively used with varint encoding.
|
||||
//
|
||||
// varint operates on unsigned integers, encoding smaller numbers into
|
||||
// fewer bytes. If you try to use it on a signed integer, it will treat
|
||||
// this number as a very large unsigned integer, which means that even
|
||||
// small signed numbers like -1 will take the maximum number of bytes
|
||||
// (10) to encode. ZigZagEncode() maps signed integers to unsigned
|
||||
// in such a way that those with a small absolute value will have smaller
|
||||
// encoded values, making them appropriate for encoding using varint.
|
||||
//
|
||||
// int32 -> uint32
|
||||
// -------------------------
|
||||
// 0 -> 0
|
||||
// -1 -> 1
|
||||
// 1 -> 2
|
||||
// -2 -> 3
|
||||
// ... -> ...
|
||||
// 2147483647 -> 4294967294
|
||||
// -2147483648 -> 4294967295
|
||||
//
|
||||
// >> encode >>
|
||||
// << decode <<
|
||||
|
||||
inline uint32 WireFormatLite::ZigZagEncode32(int32 n) {
|
||||
// Note: the right-shift must be arithmetic
|
||||
return (n << 1) ^ (n >> 31);
|
||||
}
|
||||
|
||||
inline int32 WireFormatLite::ZigZagDecode32(uint32 n) {
|
||||
return (n >> 1) ^ -static_cast<int32>(n & 1);
|
||||
}
|
||||
|
||||
inline uint64 WireFormatLite::ZigZagEncode64(int64 n) {
|
||||
// Note: the right-shift must be arithmetic
|
||||
return (n << 1) ^ (n >> 63);
|
||||
}
|
||||
|
||||
inline int64 WireFormatLite::ZigZagDecode64(uint64 n) {
|
||||
return (n >> 1) ^ -static_cast<int64>(n & 1);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
|
@ -0,0 +1,776 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/protobuf/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// wink@google.com (Wink Saville) (refactored from wire_format.h)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__
|
||||
#define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__
|
||||
|
||||
#include <string>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/message_lite.h>
|
||||
#include <google/protobuf/repeated_field.h>
|
||||
#include <google/protobuf/wire_format_lite.h>
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
// Implementation details of ReadPrimitive.
|
||||
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<int32, WireFormatLite::TYPE_INT32>(
|
||||
io::CodedInputStream* input,
|
||||
int32* value) {
|
||||
uint32 temp;
|
||||
if (!input->ReadVarint32(&temp)) return false;
|
||||
*value = static_cast<int32>(temp);
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<int64, WireFormatLite::TYPE_INT64>(
|
||||
io::CodedInputStream* input,
|
||||
int64* value) {
|
||||
uint64 temp;
|
||||
if (!input->ReadVarint64(&temp)) return false;
|
||||
*value = static_cast<int64>(temp);
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<uint32, WireFormatLite::TYPE_UINT32>(
|
||||
io::CodedInputStream* input,
|
||||
uint32* value) {
|
||||
return input->ReadVarint32(value);
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<uint64, WireFormatLite::TYPE_UINT64>(
|
||||
io::CodedInputStream* input,
|
||||
uint64* value) {
|
||||
return input->ReadVarint64(value);
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<int32, WireFormatLite::TYPE_SINT32>(
|
||||
io::CodedInputStream* input,
|
||||
int32* value) {
|
||||
uint32 temp;
|
||||
if (!input->ReadVarint32(&temp)) return false;
|
||||
*value = ZigZagDecode32(temp);
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<int64, WireFormatLite::TYPE_SINT64>(
|
||||
io::CodedInputStream* input,
|
||||
int64* value) {
|
||||
uint64 temp;
|
||||
if (!input->ReadVarint64(&temp)) return false;
|
||||
*value = ZigZagDecode64(temp);
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<uint32, WireFormatLite::TYPE_FIXED32>(
|
||||
io::CodedInputStream* input,
|
||||
uint32* value) {
|
||||
return input->ReadLittleEndian32(value);
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<uint64, WireFormatLite::TYPE_FIXED64>(
|
||||
io::CodedInputStream* input,
|
||||
uint64* value) {
|
||||
return input->ReadLittleEndian64(value);
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<int32, WireFormatLite::TYPE_SFIXED32>(
|
||||
io::CodedInputStream* input,
|
||||
int32* value) {
|
||||
uint32 temp;
|
||||
if (!input->ReadLittleEndian32(&temp)) return false;
|
||||
*value = static_cast<int32>(temp);
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<int64, WireFormatLite::TYPE_SFIXED64>(
|
||||
io::CodedInputStream* input,
|
||||
int64* value) {
|
||||
uint64 temp;
|
||||
if (!input->ReadLittleEndian64(&temp)) return false;
|
||||
*value = static_cast<int64>(temp);
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<float, WireFormatLite::TYPE_FLOAT>(
|
||||
io::CodedInputStream* input,
|
||||
float* value) {
|
||||
uint32 temp;
|
||||
if (!input->ReadLittleEndian32(&temp)) return false;
|
||||
*value = DecodeFloat(temp);
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<double, WireFormatLite::TYPE_DOUBLE>(
|
||||
io::CodedInputStream* input,
|
||||
double* value) {
|
||||
uint64 temp;
|
||||
if (!input->ReadLittleEndian64(&temp)) return false;
|
||||
*value = DecodeDouble(temp);
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<bool, WireFormatLite::TYPE_BOOL>(
|
||||
io::CodedInputStream* input,
|
||||
bool* value) {
|
||||
uint32 temp;
|
||||
if (!input->ReadVarint32(&temp)) return false;
|
||||
*value = temp != 0;
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
inline bool WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
|
||||
io::CodedInputStream* input,
|
||||
int* value) {
|
||||
uint32 temp;
|
||||
if (!input->ReadVarint32(&temp)) return false;
|
||||
*value = static_cast<int>(temp);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const uint8* WireFormatLite::ReadPrimitiveFromArray<
|
||||
uint32, WireFormatLite::TYPE_FIXED32>(
|
||||
const uint8* buffer,
|
||||
uint32* value) {
|
||||
return io::CodedInputStream::ReadLittleEndian32FromArray(buffer, value);
|
||||
}
|
||||
template <>
|
||||
inline const uint8* WireFormatLite::ReadPrimitiveFromArray<
|
||||
uint64, WireFormatLite::TYPE_FIXED64>(
|
||||
const uint8* buffer,
|
||||
uint64* value) {
|
||||
return io::CodedInputStream::ReadLittleEndian64FromArray(buffer, value);
|
||||
}
|
||||
template <>
|
||||
inline const uint8* WireFormatLite::ReadPrimitiveFromArray<
|
||||
int32, WireFormatLite::TYPE_SFIXED32>(
|
||||
const uint8* buffer,
|
||||
int32* value) {
|
||||
uint32 temp;
|
||||
buffer = io::CodedInputStream::ReadLittleEndian32FromArray(buffer, &temp);
|
||||
*value = static_cast<int32>(temp);
|
||||
return buffer;
|
||||
}
|
||||
template <>
|
||||
inline const uint8* WireFormatLite::ReadPrimitiveFromArray<
|
||||
int64, WireFormatLite::TYPE_SFIXED64>(
|
||||
const uint8* buffer,
|
||||
int64* value) {
|
||||
uint64 temp;
|
||||
buffer = io::CodedInputStream::ReadLittleEndian64FromArray(buffer, &temp);
|
||||
*value = static_cast<int64>(temp);
|
||||
return buffer;
|
||||
}
|
||||
template <>
|
||||
inline const uint8* WireFormatLite::ReadPrimitiveFromArray<
|
||||
float, WireFormatLite::TYPE_FLOAT>(
|
||||
const uint8* buffer,
|
||||
float* value) {
|
||||
uint32 temp;
|
||||
buffer = io::CodedInputStream::ReadLittleEndian32FromArray(buffer, &temp);
|
||||
*value = DecodeFloat(temp);
|
||||
return buffer;
|
||||
}
|
||||
template <>
|
||||
inline const uint8* WireFormatLite::ReadPrimitiveFromArray<
|
||||
double, WireFormatLite::TYPE_DOUBLE>(
|
||||
const uint8* buffer,
|
||||
double* value) {
|
||||
uint64 temp;
|
||||
buffer = io::CodedInputStream::ReadLittleEndian64FromArray(buffer, &temp);
|
||||
*value = DecodeDouble(temp);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
template <typename CType, enum WireFormatLite::FieldType DeclaredType>
|
||||
inline bool WireFormatLite::ReadRepeatedPrimitive(int, // tag_size, unused.
|
||||
uint32 tag,
|
||||
io::CodedInputStream* input,
|
||||
RepeatedField<CType>* values) {
|
||||
CType value;
|
||||
if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
|
||||
values->Add(value);
|
||||
int elements_already_reserved = values->Capacity() - values->size();
|
||||
while (elements_already_reserved > 0 && input->ExpectTag(tag)) {
|
||||
if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
|
||||
values->AddAlreadyReserved(value);
|
||||
elements_already_reserved--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename CType, enum WireFormatLite::FieldType DeclaredType>
|
||||
inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive(
|
||||
int tag_size,
|
||||
uint32 tag,
|
||||
io::CodedInputStream* input,
|
||||
RepeatedField<CType>* values) {
|
||||
GOOGLE_DCHECK_EQ(UInt32Size(tag), tag_size);
|
||||
CType value;
|
||||
if (!ReadPrimitive<CType, DeclaredType>(input, &value))
|
||||
return false;
|
||||
values->Add(value);
|
||||
|
||||
// For fixed size values, repeated values can be read more quickly by
|
||||
// reading directly from a raw array.
|
||||
//
|
||||
// We can get a tight loop by only reading as many elements as can be
|
||||
// added to the RepeatedField without having to do any resizing. Additionally,
|
||||
// we only try to read as many elements as are available from the current
|
||||
// buffer space. Doing so avoids having to perform boundary checks when
|
||||
// reading the value: the maximum number of elements that can be read is
|
||||
// known outside of the loop.
|
||||
const void* void_pointer;
|
||||
int size;
|
||||
input->GetDirectBufferPointerInline(&void_pointer, &size);
|
||||
if (size > 0) {
|
||||
const uint8* buffer = reinterpret_cast<const uint8*>(void_pointer);
|
||||
// The number of bytes each type occupies on the wire.
|
||||
const int per_value_size = tag_size + sizeof(value);
|
||||
|
||||
int elements_available = min(values->Capacity() - values->size(),
|
||||
size / per_value_size);
|
||||
int num_read = 0;
|
||||
while (num_read < elements_available &&
|
||||
(buffer = io::CodedInputStream::ExpectTagFromArray(
|
||||
buffer, tag)) != NULL) {
|
||||
buffer = ReadPrimitiveFromArray<CType, DeclaredType>(buffer, &value);
|
||||
values->AddAlreadyReserved(value);
|
||||
++num_read;
|
||||
}
|
||||
const int read_bytes = num_read * per_value_size;
|
||||
if (read_bytes > 0) {
|
||||
input->Skip(read_bytes);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Specializations of ReadRepeatedPrimitive for the fixed size types, which use
|
||||
// the optimized code path.
|
||||
#define READ_REPEATED_FIXED_SIZE_PRIMITIVE(CPPTYPE, DECLARED_TYPE) \
|
||||
template <> \
|
||||
inline bool WireFormatLite::ReadRepeatedPrimitive< \
|
||||
CPPTYPE, WireFormatLite::DECLARED_TYPE>( \
|
||||
int tag_size, \
|
||||
uint32 tag, \
|
||||
io::CodedInputStream* input, \
|
||||
RepeatedField<CPPTYPE>* values) { \
|
||||
return ReadRepeatedFixedSizePrimitive< \
|
||||
CPPTYPE, WireFormatLite::DECLARED_TYPE>( \
|
||||
tag_size, tag, input, values); \
|
||||
}
|
||||
|
||||
READ_REPEATED_FIXED_SIZE_PRIMITIVE(uint32, TYPE_FIXED32)
|
||||
READ_REPEATED_FIXED_SIZE_PRIMITIVE(uint64, TYPE_FIXED64)
|
||||
READ_REPEATED_FIXED_SIZE_PRIMITIVE(int32, TYPE_SFIXED32)
|
||||
READ_REPEATED_FIXED_SIZE_PRIMITIVE(int64, TYPE_SFIXED64)
|
||||
READ_REPEATED_FIXED_SIZE_PRIMITIVE(float, TYPE_FLOAT)
|
||||
READ_REPEATED_FIXED_SIZE_PRIMITIVE(double, TYPE_DOUBLE)
|
||||
|
||||
#undef READ_REPEATED_FIXED_SIZE_PRIMITIVE
|
||||
|
||||
template <typename CType, enum WireFormatLite::FieldType DeclaredType>
|
||||
bool WireFormatLite::ReadRepeatedPrimitiveNoInline(
|
||||
int tag_size,
|
||||
uint32 tag,
|
||||
io::CodedInputStream* input,
|
||||
RepeatedField<CType>* value) {
|
||||
return ReadRepeatedPrimitive<CType, DeclaredType>(
|
||||
tag_size, tag, input, value);
|
||||
}
|
||||
|
||||
template <typename CType, enum WireFormatLite::FieldType DeclaredType>
|
||||
inline bool WireFormatLite::ReadPackedPrimitive(io::CodedInputStream* input,
|
||||
RepeatedField<CType>* values) {
|
||||
uint32 length;
|
||||
if (!input->ReadVarint32(&length)) return false;
|
||||
io::CodedInputStream::Limit limit = input->PushLimit(length);
|
||||
while (input->BytesUntilLimit() > 0) {
|
||||
CType value;
|
||||
if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
|
||||
values->Add(value);
|
||||
}
|
||||
input->PopLimit(limit);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename CType, enum WireFormatLite::FieldType DeclaredType>
|
||||
bool WireFormatLite::ReadPackedPrimitiveNoInline(io::CodedInputStream* input,
|
||||
RepeatedField<CType>* values) {
|
||||
return ReadPackedPrimitive<CType, DeclaredType>(input, values);
|
||||
}
|
||||
|
||||
|
||||
inline bool WireFormatLite::ReadGroup(int field_number,
|
||||
io::CodedInputStream* input,
|
||||
MessageLite* value) {
|
||||
if (!input->IncrementRecursionDepth()) return false;
|
||||
if (!value->MergePartialFromCodedStream(input)) return false;
|
||||
input->DecrementRecursionDepth();
|
||||
// Make sure the last thing read was an end tag for this group.
|
||||
if (!input->LastTagWas(MakeTag(field_number, WIRETYPE_END_GROUP))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
inline bool WireFormatLite::ReadMessage(io::CodedInputStream* input,
|
||||
MessageLite* value) {
|
||||
uint32 length;
|
||||
if (!input->ReadVarint32(&length)) return false;
|
||||
if (!input->IncrementRecursionDepth()) return false;
|
||||
io::CodedInputStream::Limit limit = input->PushLimit(length);
|
||||
if (!value->MergePartialFromCodedStream(input)) return false;
|
||||
// Make sure that parsing stopped when the limit was hit, not at an endgroup
|
||||
// tag.
|
||||
if (!input->ConsumedEntireMessage()) return false;
|
||||
input->PopLimit(limit);
|
||||
input->DecrementRecursionDepth();
|
||||
return true;
|
||||
}
|
||||
|
||||
// We name the template parameter something long and extremely unlikely to occur
|
||||
// elsewhere because a *qualified* member access expression designed to avoid
|
||||
// virtual dispatch, C++03 [basic.lookup.classref] 3.4.5/4 requires that the
|
||||
// name of the qualifying class to be looked up both in the context of the full
|
||||
// expression (finding the template parameter) and in the context of the object
|
||||
// whose member we are accessing. This could potentially find a nested type
|
||||
// within that object. The standard goes on to require these names to refer to
|
||||
// the same entity, which this collision would violate. The lack of a safe way
|
||||
// to avoid this collision appears to be a defect in the standard, but until it
|
||||
// is corrected, we choose the name to avoid accidental collisions.
|
||||
template<typename MessageType_WorkAroundCppLookupDefect>
|
||||
inline bool WireFormatLite::ReadGroupNoVirtual(
|
||||
int field_number, io::CodedInputStream* input,
|
||||
MessageType_WorkAroundCppLookupDefect* value) {
|
||||
if (!input->IncrementRecursionDepth()) return false;
|
||||
if (!value->
|
||||
MessageType_WorkAroundCppLookupDefect::MergePartialFromCodedStream(input))
|
||||
return false;
|
||||
input->DecrementRecursionDepth();
|
||||
// Make sure the last thing read was an end tag for this group.
|
||||
if (!input->LastTagWas(MakeTag(field_number, WIRETYPE_END_GROUP))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template<typename MessageType_WorkAroundCppLookupDefect>
|
||||
inline bool WireFormatLite::ReadMessageNoVirtual(
|
||||
io::CodedInputStream* input, MessageType_WorkAroundCppLookupDefect* value) {
|
||||
uint32 length;
|
||||
if (!input->ReadVarint32(&length)) return false;
|
||||
if (!input->IncrementRecursionDepth()) return false;
|
||||
io::CodedInputStream::Limit limit = input->PushLimit(length);
|
||||
if (!value->
|
||||
MessageType_WorkAroundCppLookupDefect::MergePartialFromCodedStream(input))
|
||||
return false;
|
||||
// Make sure that parsing stopped when the limit was hit, not at an endgroup
|
||||
// tag.
|
||||
if (!input->ConsumedEntireMessage()) return false;
|
||||
input->PopLimit(limit);
|
||||
input->DecrementRecursionDepth();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
inline void WireFormatLite::WriteTag(int field_number, WireType type,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteTag(MakeTag(field_number, type));
|
||||
}
|
||||
|
||||
inline void WireFormatLite::WriteInt32NoTag(int32 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteVarint32SignExtended(value);
|
||||
}
|
||||
inline void WireFormatLite::WriteInt64NoTag(int64 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteVarint64(static_cast<uint64>(value));
|
||||
}
|
||||
inline void WireFormatLite::WriteUInt32NoTag(uint32 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteVarint32(value);
|
||||
}
|
||||
inline void WireFormatLite::WriteUInt64NoTag(uint64 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteVarint64(value);
|
||||
}
|
||||
inline void WireFormatLite::WriteSInt32NoTag(int32 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteVarint32(ZigZagEncode32(value));
|
||||
}
|
||||
inline void WireFormatLite::WriteSInt64NoTag(int64 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteVarint64(ZigZagEncode64(value));
|
||||
}
|
||||
inline void WireFormatLite::WriteFixed32NoTag(uint32 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteLittleEndian32(value);
|
||||
}
|
||||
inline void WireFormatLite::WriteFixed64NoTag(uint64 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteLittleEndian64(value);
|
||||
}
|
||||
inline void WireFormatLite::WriteSFixed32NoTag(int32 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteLittleEndian32(static_cast<uint32>(value));
|
||||
}
|
||||
inline void WireFormatLite::WriteSFixed64NoTag(int64 value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteLittleEndian64(static_cast<uint64>(value));
|
||||
}
|
||||
inline void WireFormatLite::WriteFloatNoTag(float value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteLittleEndian32(EncodeFloat(value));
|
||||
}
|
||||
inline void WireFormatLite::WriteDoubleNoTag(double value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteLittleEndian64(EncodeDouble(value));
|
||||
}
|
||||
inline void WireFormatLite::WriteBoolNoTag(bool value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteVarint32(value ? 1 : 0);
|
||||
}
|
||||
inline void WireFormatLite::WriteEnumNoTag(int value,
|
||||
io::CodedOutputStream* output) {
|
||||
output->WriteVarint32SignExtended(value);
|
||||
}
|
||||
|
||||
// See comment on ReadGroupNoVirtual to understand the need for this template
|
||||
// parameter name.
|
||||
template<typename MessageType_WorkAroundCppLookupDefect>
|
||||
inline void WireFormatLite::WriteGroupNoVirtual(
|
||||
int field_number, const MessageType_WorkAroundCppLookupDefect& value,
|
||||
io::CodedOutputStream* output) {
|
||||
WriteTag(field_number, WIRETYPE_START_GROUP, output);
|
||||
value.MessageType_WorkAroundCppLookupDefect::SerializeWithCachedSizes(output);
|
||||
WriteTag(field_number, WIRETYPE_END_GROUP, output);
|
||||
}
|
||||
template<typename MessageType_WorkAroundCppLookupDefect>
|
||||
inline void WireFormatLite::WriteMessageNoVirtual(
|
||||
int field_number, const MessageType_WorkAroundCppLookupDefect& value,
|
||||
io::CodedOutputStream* output) {
|
||||
WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
|
||||
output->WriteVarint32(
|
||||
value.MessageType_WorkAroundCppLookupDefect::GetCachedSize());
|
||||
value.MessageType_WorkAroundCppLookupDefect::SerializeWithCachedSizes(output);
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
inline uint8* WireFormatLite::WriteTagToArray(int field_number,
|
||||
WireType type,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteTagToArray(MakeTag(field_number, type),
|
||||
target);
|
||||
}
|
||||
|
||||
inline uint8* WireFormatLite::WriteInt32NoTagToArray(int32 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteVarint32SignExtendedToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteInt64NoTagToArray(int64 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteVarint64ToArray(
|
||||
static_cast<uint64>(value), target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteUInt32NoTagToArray(uint32 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteVarint32ToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteUInt64NoTagToArray(uint64 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteVarint64ToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteSInt32NoTagToArray(int32 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteVarint32ToArray(ZigZagEncode32(value),
|
||||
target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteSInt64NoTagToArray(int64 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteVarint64ToArray(ZigZagEncode64(value),
|
||||
target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteFixed32NoTagToArray(uint32 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteLittleEndian32ToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteFixed64NoTagToArray(uint64 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteLittleEndian64ToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteSFixed32NoTagToArray(int32 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteLittleEndian32ToArray(
|
||||
static_cast<uint32>(value), target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteSFixed64NoTagToArray(int64 value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteLittleEndian64ToArray(
|
||||
static_cast<uint64>(value), target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteFloatNoTagToArray(float value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteLittleEndian32ToArray(EncodeFloat(value),
|
||||
target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteDoubleNoTagToArray(double value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteLittleEndian64ToArray(EncodeDouble(value),
|
||||
target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteBoolNoTagToArray(bool value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteVarint32ToArray(value ? 1 : 0, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteEnumNoTagToArray(int value,
|
||||
uint8* target) {
|
||||
return io::CodedOutputStream::WriteVarint32SignExtendedToArray(value, target);
|
||||
}
|
||||
|
||||
inline uint8* WireFormatLite::WriteInt32ToArray(int field_number,
|
||||
int32 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
|
||||
return WriteInt32NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteInt64ToArray(int field_number,
|
||||
int64 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
|
||||
return WriteInt64NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteUInt32ToArray(int field_number,
|
||||
uint32 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
|
||||
return WriteUInt32NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteUInt64ToArray(int field_number,
|
||||
uint64 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
|
||||
return WriteUInt64NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteSInt32ToArray(int field_number,
|
||||
int32 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
|
||||
return WriteSInt32NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteSInt64ToArray(int field_number,
|
||||
int64 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
|
||||
return WriteSInt64NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteFixed32ToArray(int field_number,
|
||||
uint32 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target);
|
||||
return WriteFixed32NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteFixed64ToArray(int field_number,
|
||||
uint64 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target);
|
||||
return WriteFixed64NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteSFixed32ToArray(int field_number,
|
||||
int32 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target);
|
||||
return WriteSFixed32NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteSFixed64ToArray(int field_number,
|
||||
int64 value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target);
|
||||
return WriteSFixed64NoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteFloatToArray(int field_number,
|
||||
float value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target);
|
||||
return WriteFloatNoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteDoubleToArray(int field_number,
|
||||
double value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target);
|
||||
return WriteDoubleNoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteBoolToArray(int field_number,
|
||||
bool value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
|
||||
return WriteBoolNoTagToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteEnumToArray(int field_number,
|
||||
int value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
|
||||
return WriteEnumNoTagToArray(value, target);
|
||||
}
|
||||
|
||||
inline uint8* WireFormatLite::WriteStringToArray(int field_number,
|
||||
const string& value,
|
||||
uint8* target) {
|
||||
// String is for UTF-8 text only
|
||||
// WARNING: In wire_format.cc, both strings and bytes are handled by
|
||||
// WriteString() to avoid code duplication. If the implementations become
|
||||
// different, you will need to update that usage.
|
||||
target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
|
||||
target = io::CodedOutputStream::WriteVarint32ToArray(value.size(), target);
|
||||
return io::CodedOutputStream::WriteStringToArray(value, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteBytesToArray(int field_number,
|
||||
const string& value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
|
||||
target = io::CodedOutputStream::WriteVarint32ToArray(value.size(), target);
|
||||
return io::CodedOutputStream::WriteStringToArray(value, target);
|
||||
}
|
||||
|
||||
|
||||
inline uint8* WireFormatLite::WriteGroupToArray(int field_number,
|
||||
const MessageLite& value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target);
|
||||
target = value.SerializeWithCachedSizesToArray(target);
|
||||
return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target);
|
||||
}
|
||||
inline uint8* WireFormatLite::WriteMessageToArray(int field_number,
|
||||
const MessageLite& value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
|
||||
target = io::CodedOutputStream::WriteVarint32ToArray(
|
||||
value.GetCachedSize(), target);
|
||||
return value.SerializeWithCachedSizesToArray(target);
|
||||
}
|
||||
|
||||
// See comment on ReadGroupNoVirtual to understand the need for this template
|
||||
// parameter name.
|
||||
template<typename MessageType_WorkAroundCppLookupDefect>
|
||||
inline uint8* WireFormatLite::WriteGroupNoVirtualToArray(
|
||||
int field_number, const MessageType_WorkAroundCppLookupDefect& value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target);
|
||||
target = value.MessageType_WorkAroundCppLookupDefect
|
||||
::SerializeWithCachedSizesToArray(target);
|
||||
return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target);
|
||||
}
|
||||
template<typename MessageType_WorkAroundCppLookupDefect>
|
||||
inline uint8* WireFormatLite::WriteMessageNoVirtualToArray(
|
||||
int field_number, const MessageType_WorkAroundCppLookupDefect& value,
|
||||
uint8* target) {
|
||||
target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
|
||||
target = io::CodedOutputStream::WriteVarint32ToArray(
|
||||
value.MessageType_WorkAroundCppLookupDefect::GetCachedSize(), target);
|
||||
return value.MessageType_WorkAroundCppLookupDefect
|
||||
::SerializeWithCachedSizesToArray(target);
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
inline int WireFormatLite::Int32Size(int32 value) {
|
||||
return io::CodedOutputStream::VarintSize32SignExtended(value);
|
||||
}
|
||||
inline int WireFormatLite::Int64Size(int64 value) {
|
||||
return io::CodedOutputStream::VarintSize64(static_cast<uint64>(value));
|
||||
}
|
||||
inline int WireFormatLite::UInt32Size(uint32 value) {
|
||||
return io::CodedOutputStream::VarintSize32(value);
|
||||
}
|
||||
inline int WireFormatLite::UInt64Size(uint64 value) {
|
||||
return io::CodedOutputStream::VarintSize64(value);
|
||||
}
|
||||
inline int WireFormatLite::SInt32Size(int32 value) {
|
||||
return io::CodedOutputStream::VarintSize32(ZigZagEncode32(value));
|
||||
}
|
||||
inline int WireFormatLite::SInt64Size(int64 value) {
|
||||
return io::CodedOutputStream::VarintSize64(ZigZagEncode64(value));
|
||||
}
|
||||
inline int WireFormatLite::EnumSize(int value) {
|
||||
return io::CodedOutputStream::VarintSize32SignExtended(value);
|
||||
}
|
||||
|
||||
inline int WireFormatLite::StringSize(const string& value) {
|
||||
return io::CodedOutputStream::VarintSize32(value.size()) +
|
||||
value.size();
|
||||
}
|
||||
inline int WireFormatLite::BytesSize(const string& value) {
|
||||
return io::CodedOutputStream::VarintSize32(value.size()) +
|
||||
value.size();
|
||||
}
|
||||
|
||||
|
||||
inline int WireFormatLite::GroupSize(const MessageLite& value) {
|
||||
return value.ByteSize();
|
||||
}
|
||||
inline int WireFormatLite::MessageSize(const MessageLite& value) {
|
||||
return LengthDelimitedSize(value.ByteSize());
|
||||
}
|
||||
|
||||
// See comment on ReadGroupNoVirtual to understand the need for this template
|
||||
// parameter name.
|
||||
template<typename MessageType_WorkAroundCppLookupDefect>
|
||||
inline int WireFormatLite::GroupSizeNoVirtual(
|
||||
const MessageType_WorkAroundCppLookupDefect& value) {
|
||||
return value.MessageType_WorkAroundCppLookupDefect::ByteSize();
|
||||
}
|
||||
template<typename MessageType_WorkAroundCppLookupDefect>
|
||||
inline int WireFormatLite::MessageSizeNoVirtual(
|
||||
const MessageType_WorkAroundCppLookupDefect& value) {
|
||||
return LengthDelimitedSize(
|
||||
value.MessageType_WorkAroundCppLookupDefect::ByteSize());
|
||||
}
|
||||
|
||||
inline int WireFormatLite::LengthDelimitedSize(int length) {
|
||||
return io::CodedOutputStream::VarintSize32(length) + length;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__
|
149
sgx-jvm/dependencies/root/usr/include/openssl/aes.h
Normal file
149
sgx-jvm/dependencies/root/usr/include/openssl/aes.h
Normal file
@ -0,0 +1,149 @@
|
||||
/* crypto/aes/aes.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_AES_H
|
||||
# define HEADER_AES_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifdef OPENSSL_NO_AES
|
||||
# error AES is disabled.
|
||||
# endif
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
# define AES_ENCRYPT 1
|
||||
# define AES_DECRYPT 0
|
||||
|
||||
/*
|
||||
* Because array size can't be a const in C, the following two are macros.
|
||||
* Both sizes are in bytes.
|
||||
*/
|
||||
# define AES_MAXNR 14
|
||||
# define AES_BLOCK_SIZE 16
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This should be a hidden type, but EVP requires that the size be known */
|
||||
struct aes_key_st {
|
||||
# ifdef AES_LONG
|
||||
unsigned long rd_key[4 * (AES_MAXNR + 1)];
|
||||
# else
|
||||
unsigned int rd_key[4 * (AES_MAXNR + 1)];
|
||||
# endif
|
||||
int rounds;
|
||||
};
|
||||
typedef struct aes_key_st AES_KEY;
|
||||
|
||||
const char *AES_options(void);
|
||||
|
||||
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
|
||||
int private_AES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
int private_AES_set_decrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
|
||||
void AES_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
void AES_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
|
||||
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key, const int enc);
|
||||
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num);
|
||||
void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char ivec[AES_BLOCK_SIZE],
|
||||
unsigned char ecount_buf[AES_BLOCK_SIZE],
|
||||
unsigned int *num);
|
||||
/* NB: the IV is _two_ blocks long */
|
||||
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
/* NB: the IV is _four_ blocks long */
|
||||
void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
const AES_KEY *key2, const unsigned char *ivec,
|
||||
const int enc);
|
||||
|
||||
int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
|
||||
unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen);
|
||||
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
|
||||
unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !HEADER_AES_H */
|
1427
sgx-jvm/dependencies/root/usr/include/openssl/asn1.h
Normal file
1427
sgx-jvm/dependencies/root/usr/include/openssl/asn1.h
Normal file
File diff suppressed because it is too large
Load Diff
579
sgx-jvm/dependencies/root/usr/include/openssl/asn1_mac.h
Normal file
579
sgx-jvm/dependencies/root/usr/include/openssl/asn1_mac.h
Normal file
@ -0,0 +1,579 @@
|
||||
/* crypto/asn1/asn1_mac.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_ASN1_MAC_H
|
||||
# define HEADER_ASN1_MAC_H
|
||||
|
||||
# include <openssl/asn1.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# ifndef ASN1_MAC_ERR_LIB
|
||||
# define ASN1_MAC_ERR_LIB ERR_LIB_ASN1
|
||||
# endif
|
||||
|
||||
# define ASN1_MAC_H_err(f,r,line) \
|
||||
ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))
|
||||
|
||||
# define M_ASN1_D2I_vars(a,type,func) \
|
||||
ASN1_const_CTX c; \
|
||||
type ret=NULL; \
|
||||
\
|
||||
c.pp=(const unsigned char **)pp; \
|
||||
c.q= *(const unsigned char **)pp; \
|
||||
c.error=ERR_R_NESTED_ASN1_ERROR; \
|
||||
if ((a == NULL) || ((*a) == NULL)) \
|
||||
{ if ((ret=(type)func()) == NULL) \
|
||||
{ c.line=__LINE__; goto err; } } \
|
||||
else ret=(*a);
|
||||
|
||||
# define M_ASN1_D2I_Init() \
|
||||
c.p= *(const unsigned char **)pp; \
|
||||
c.max=(length == 0)?0:(c.p+length);
|
||||
|
||||
# define M_ASN1_D2I_Finish_2(a) \
|
||||
if (!asn1_const_Finish(&c)) \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
*(const unsigned char **)pp=c.p; \
|
||||
if (a != NULL) (*a)=ret; \
|
||||
return(ret);
|
||||
|
||||
# define M_ASN1_D2I_Finish(a,func,e) \
|
||||
M_ASN1_D2I_Finish_2(a); \
|
||||
err:\
|
||||
ASN1_MAC_H_err((e),c.error,c.line); \
|
||||
asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \
|
||||
if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
|
||||
return(NULL)
|
||||
|
||||
# define M_ASN1_D2I_start_sequence() \
|
||||
if (!asn1_GetSequence(&c,&length)) \
|
||||
{ c.line=__LINE__; goto err; }
|
||||
/* Begin reading ASN1 without a surrounding sequence */
|
||||
# define M_ASN1_D2I_begin() \
|
||||
c.slen = length;
|
||||
|
||||
/* End reading ASN1 with no check on length */
|
||||
# define M_ASN1_D2I_Finish_nolen(a, func, e) \
|
||||
*pp=c.p; \
|
||||
if (a != NULL) (*a)=ret; \
|
||||
return(ret); \
|
||||
err:\
|
||||
ASN1_MAC_H_err((e),c.error,c.line); \
|
||||
asn1_add_error(*pp,(int)(c.q- *pp)); \
|
||||
if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
|
||||
return(NULL)
|
||||
|
||||
# define M_ASN1_D2I_end_sequence() \
|
||||
(((c.inf&1) == 0)?(c.slen <= 0): \
|
||||
(c.eos=ASN1_const_check_infinite_end(&c.p,c.slen)))
|
||||
|
||||
/* Don't use this with d2i_ASN1_BOOLEAN() */
|
||||
# define M_ASN1_D2I_get(b, func) \
|
||||
c.q=c.p; \
|
||||
if (func(&(b),&c.p,c.slen) == NULL) \
|
||||
{c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
/* Don't use this with d2i_ASN1_BOOLEAN() */
|
||||
# define M_ASN1_D2I_get_x(type,b,func) \
|
||||
c.q=c.p; \
|
||||
if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \
|
||||
{c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
/* use this instead () */
|
||||
# define M_ASN1_D2I_get_int(b,func) \
|
||||
c.q=c.p; \
|
||||
if (func(&(b),&c.p,c.slen) < 0) \
|
||||
{c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
# define M_ASN1_D2I_get_opt(b,func,type) \
|
||||
if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \
|
||||
== (V_ASN1_UNIVERSAL|(type)))) \
|
||||
{ \
|
||||
M_ASN1_D2I_get(b,func); \
|
||||
}
|
||||
|
||||
# define M_ASN1_D2I_get_int_opt(b,func,type) \
|
||||
if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \
|
||||
== (V_ASN1_UNIVERSAL|(type)))) \
|
||||
{ \
|
||||
M_ASN1_D2I_get_int(b,func); \
|
||||
}
|
||||
|
||||
# define M_ASN1_D2I_get_imp(b,func, type) \
|
||||
M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \
|
||||
c.q=c.p; \
|
||||
if (func(&(b),&c.p,c.slen) == NULL) \
|
||||
{c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \
|
||||
c.slen-=(c.p-c.q);\
|
||||
M_ASN1_next_prev=_tmp;
|
||||
|
||||
# define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \
|
||||
if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \
|
||||
(V_ASN1_CONTEXT_SPECIFIC|(tag)))) \
|
||||
{ \
|
||||
unsigned char _tmp = M_ASN1_next; \
|
||||
M_ASN1_D2I_get_imp(b,func, type);\
|
||||
}
|
||||
|
||||
# define M_ASN1_D2I_get_set(r,func,free_func) \
|
||||
M_ASN1_D2I_get_imp_set(r,func,free_func, \
|
||||
V_ASN1_SET,V_ASN1_UNIVERSAL);
|
||||
|
||||
# define M_ASN1_D2I_get_set_type(type,r,func,free_func) \
|
||||
M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \
|
||||
V_ASN1_SET,V_ASN1_UNIVERSAL);
|
||||
|
||||
# define M_ASN1_D2I_get_set_opt(r,func,free_func) \
|
||||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
|
||||
V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
|
||||
{ M_ASN1_D2I_get_set(r,func,free_func); }
|
||||
|
||||
# define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \
|
||||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
|
||||
V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
|
||||
{ M_ASN1_D2I_get_set_type(type,r,func,free_func); }
|
||||
|
||||
# define M_ASN1_I2D_len_SET_opt(a,f) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
M_ASN1_I2D_len_SET(a,f);
|
||||
|
||||
# define M_ASN1_I2D_put_SET_opt(a,f) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
M_ASN1_I2D_put_SET(a,f);
|
||||
|
||||
# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
M_ASN1_I2D_put_SEQUENCE(a,f);
|
||||
|
||||
# define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \
|
||||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \
|
||||
M_ASN1_I2D_put_SEQUENCE_type(type,a,f);
|
||||
|
||||
# define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \
|
||||
if ((c.slen != 0) && \
|
||||
(M_ASN1_next == \
|
||||
(V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\
|
||||
{ \
|
||||
M_ASN1_D2I_get_imp_set(b,func,free_func,\
|
||||
tag,V_ASN1_CONTEXT_SPECIFIC); \
|
||||
}
|
||||
|
||||
# define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \
|
||||
if ((c.slen != 0) && \
|
||||
(M_ASN1_next == \
|
||||
(V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\
|
||||
{ \
|
||||
M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\
|
||||
tag,V_ASN1_CONTEXT_SPECIFIC); \
|
||||
}
|
||||
|
||||
# define M_ASN1_D2I_get_seq(r,func,free_func) \
|
||||
M_ASN1_D2I_get_imp_set(r,func,free_func,\
|
||||
V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
|
||||
|
||||
# define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \
|
||||
M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\
|
||||
V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)
|
||||
|
||||
# define M_ASN1_D2I_get_seq_opt(r,func,free_func) \
|
||||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
|
||||
V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\
|
||||
{ M_ASN1_D2I_get_seq(r,func,free_func); }
|
||||
|
||||
# define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \
|
||||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
|
||||
V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\
|
||||
{ M_ASN1_D2I_get_seq_type(type,r,func,free_func); }
|
||||
|
||||
# define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \
|
||||
M_ASN1_D2I_get_imp_set(r,func,free_func,\
|
||||
x,V_ASN1_CONTEXT_SPECIFIC);
|
||||
|
||||
# define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \
|
||||
M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\
|
||||
x,V_ASN1_CONTEXT_SPECIFIC);
|
||||
|
||||
# define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \
|
||||
c.q=c.p; \
|
||||
if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\
|
||||
(void (*)())free_func,a,b) == NULL) \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
# define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \
|
||||
c.q=c.p; \
|
||||
if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\
|
||||
free_func,a,b) == NULL) \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
# define M_ASN1_D2I_get_set_strings(r,func,a,b) \
|
||||
c.q=c.p; \
|
||||
if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
# define M_ASN1_D2I_get_EXP_opt(r,func,tag) \
|
||||
if ((c.slen != 0L) && (M_ASN1_next == \
|
||||
(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
|
||||
{ \
|
||||
int Tinf,Ttag,Tclass; \
|
||||
long Tlen; \
|
||||
\
|
||||
c.q=c.p; \
|
||||
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
|
||||
if (Tinf & 0x80) \
|
||||
{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
|
||||
c.line=__LINE__; goto err; } \
|
||||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
|
||||
Tlen = c.slen - (c.p - c.q) - 2; \
|
||||
if (func(&(r),&c.p,Tlen) == NULL) \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
|
||||
Tlen = c.slen - (c.p - c.q); \
|
||||
if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \
|
||||
{ c.error=ERR_R_MISSING_ASN1_EOS; \
|
||||
c.line=__LINE__; goto err; } \
|
||||
}\
|
||||
c.slen-=(c.p-c.q); \
|
||||
}
|
||||
|
||||
# define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \
|
||||
if ((c.slen != 0) && (M_ASN1_next == \
|
||||
(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
|
||||
{ \
|
||||
int Tinf,Ttag,Tclass; \
|
||||
long Tlen; \
|
||||
\
|
||||
c.q=c.p; \
|
||||
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
|
||||
if (Tinf & 0x80) \
|
||||
{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
|
||||
c.line=__LINE__; goto err; } \
|
||||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
|
||||
Tlen = c.slen - (c.p - c.q) - 2; \
|
||||
if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \
|
||||
(void (*)())free_func, \
|
||||
b,V_ASN1_UNIVERSAL) == NULL) \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
|
||||
Tlen = c.slen - (c.p - c.q); \
|
||||
if(!ASN1_check_infinite_end(&c.p, Tlen)) \
|
||||
{ c.error=ERR_R_MISSING_ASN1_EOS; \
|
||||
c.line=__LINE__; goto err; } \
|
||||
}\
|
||||
c.slen-=(c.p-c.q); \
|
||||
}
|
||||
|
||||
# define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \
|
||||
if ((c.slen != 0) && (M_ASN1_next == \
|
||||
(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
|
||||
{ \
|
||||
int Tinf,Ttag,Tclass; \
|
||||
long Tlen; \
|
||||
\
|
||||
c.q=c.p; \
|
||||
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
|
||||
if (Tinf & 0x80) \
|
||||
{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
|
||||
c.line=__LINE__; goto err; } \
|
||||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
|
||||
Tlen = c.slen - (c.p - c.q) - 2; \
|
||||
if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \
|
||||
free_func,b,V_ASN1_UNIVERSAL) == NULL) \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
|
||||
Tlen = c.slen - (c.p - c.q); \
|
||||
if(!ASN1_check_infinite_end(&c.p, Tlen)) \
|
||||
{ c.error=ERR_R_MISSING_ASN1_EOS; \
|
||||
c.line=__LINE__; goto err; } \
|
||||
}\
|
||||
c.slen-=(c.p-c.q); \
|
||||
}
|
||||
|
||||
/* New macros */
|
||||
# define M_ASN1_New_Malloc(ret,type) \
|
||||
if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \
|
||||
{ c.line=__LINE__; goto err2; }
|
||||
|
||||
# define M_ASN1_New(arg,func) \
|
||||
if (((arg)=func()) == NULL) return(NULL)
|
||||
|
||||
# define M_ASN1_New_Error(a) \
|
||||
/*- err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \
|
||||
return(NULL);*/ \
|
||||
err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \
|
||||
return(NULL)
|
||||
|
||||
/*
|
||||
* BIG UGLY WARNING! This is so damn ugly I wanna puke. Unfortunately, some
|
||||
* macros that use ASN1_const_CTX still insist on writing in the input
|
||||
* stream. ARGH! ARGH! ARGH! Let's get rid of this macro package. Please? --
|
||||
* Richard Levitte
|
||||
*/
|
||||
# define M_ASN1_next (*((unsigned char *)(c.p)))
|
||||
# define M_ASN1_next_prev (*((unsigned char *)(c.q)))
|
||||
|
||||
/*************************************************/
|
||||
|
||||
# define M_ASN1_I2D_vars(a) int r=0,ret=0; \
|
||||
unsigned char *p; \
|
||||
if (a == NULL) return(0)
|
||||
|
||||
/* Length Macros */
|
||||
# define M_ASN1_I2D_len(a,f) ret+=f(a,NULL)
|
||||
# define M_ASN1_I2D_len_IMP_opt(a,f) if (a != NULL) M_ASN1_I2D_len(a,f)
|
||||
|
||||
# define M_ASN1_I2D_len_SET(a,f) \
|
||||
ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);
|
||||
|
||||
# define M_ASN1_I2D_len_SET_type(type,a,f) \
|
||||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \
|
||||
V_ASN1_UNIVERSAL,IS_SET);
|
||||
|
||||
# define M_ASN1_I2D_len_SEQUENCE(a,f) \
|
||||
ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \
|
||||
IS_SEQUENCE);
|
||||
|
||||
# define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \
|
||||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \
|
||||
V_ASN1_UNIVERSAL,IS_SEQUENCE)
|
||||
|
||||
# define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
M_ASN1_I2D_len_SEQUENCE(a,f);
|
||||
|
||||
# define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \
|
||||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \
|
||||
M_ASN1_I2D_len_SEQUENCE_type(type,a,f);
|
||||
|
||||
# define M_ASN1_I2D_len_IMP_SET(a,f,x) \
|
||||
ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET);
|
||||
|
||||
# define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \
|
||||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
|
||||
V_ASN1_CONTEXT_SPECIFIC,IS_SET);
|
||||
|
||||
# define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
|
||||
IS_SET);
|
||||
|
||||
# define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \
|
||||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \
|
||||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
|
||||
V_ASN1_CONTEXT_SPECIFIC,IS_SET);
|
||||
|
||||
# define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \
|
||||
ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
|
||||
IS_SEQUENCE);
|
||||
|
||||
# define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
|
||||
IS_SEQUENCE);
|
||||
|
||||
# define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \
|
||||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \
|
||||
ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
|
||||
V_ASN1_CONTEXT_SPECIFIC, \
|
||||
IS_SEQUENCE);
|
||||
|
||||
# define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \
|
||||
if (a != NULL)\
|
||||
{ \
|
||||
v=f(a,NULL); \
|
||||
ret+=ASN1_object_size(1,v,mtag); \
|
||||
}
|
||||
|
||||
# define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \
|
||||
if ((a != NULL) && (sk_num(a) != 0))\
|
||||
{ \
|
||||
v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \
|
||||
ret+=ASN1_object_size(1,v,mtag); \
|
||||
}
|
||||
|
||||
# define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \
|
||||
if ((a != NULL) && (sk_num(a) != 0))\
|
||||
{ \
|
||||
v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \
|
||||
IS_SEQUENCE); \
|
||||
ret+=ASN1_object_size(1,v,mtag); \
|
||||
}
|
||||
|
||||
# define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \
|
||||
if ((a != NULL) && (sk_##type##_num(a) != 0))\
|
||||
{ \
|
||||
v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \
|
||||
V_ASN1_UNIVERSAL, \
|
||||
IS_SEQUENCE); \
|
||||
ret+=ASN1_object_size(1,v,mtag); \
|
||||
}
|
||||
|
||||
/* Put Macros */
|
||||
# define M_ASN1_I2D_put(a,f) f(a,&p)
|
||||
|
||||
# define M_ASN1_I2D_put_IMP_opt(a,f,t) \
|
||||
if (a != NULL) \
|
||||
{ \
|
||||
unsigned char *q=p; \
|
||||
f(a,&p); \
|
||||
*q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\
|
||||
}
|
||||
|
||||
# define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\
|
||||
V_ASN1_UNIVERSAL,IS_SET)
|
||||
# define M_ASN1_I2D_put_SET_type(type,a,f) \
|
||||
i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET)
|
||||
# define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\
|
||||
V_ASN1_CONTEXT_SPECIFIC,IS_SET)
|
||||
# define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \
|
||||
i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET)
|
||||
# define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\
|
||||
V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE)
|
||||
|
||||
# define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\
|
||||
V_ASN1_UNIVERSAL,IS_SEQUENCE)
|
||||
|
||||
# define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \
|
||||
i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \
|
||||
IS_SEQUENCE)
|
||||
|
||||
# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
M_ASN1_I2D_put_SEQUENCE(a,f);
|
||||
|
||||
# define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
{ i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \
|
||||
IS_SET); }
|
||||
|
||||
# define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \
|
||||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \
|
||||
{ i2d_ASN1_SET_OF_##type(a,&p,f,x, \
|
||||
V_ASN1_CONTEXT_SPECIFIC, \
|
||||
IS_SET); }
|
||||
|
||||
# define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
{ i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \
|
||||
IS_SEQUENCE); }
|
||||
|
||||
# define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \
|
||||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \
|
||||
{ i2d_ASN1_SET_OF_##type(a,&p,f,x, \
|
||||
V_ASN1_CONTEXT_SPECIFIC, \
|
||||
IS_SEQUENCE); }
|
||||
|
||||
# define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \
|
||||
if (a != NULL) \
|
||||
{ \
|
||||
ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \
|
||||
f(a,&p); \
|
||||
}
|
||||
|
||||
# define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
{ \
|
||||
ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
|
||||
i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \
|
||||
}
|
||||
|
||||
# define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
{ \
|
||||
ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
|
||||
i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \
|
||||
}
|
||||
|
||||
# define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \
|
||||
if ((a != NULL) && (sk_##type##_num(a) != 0)) \
|
||||
{ \
|
||||
ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
|
||||
i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \
|
||||
IS_SEQUENCE); \
|
||||
}
|
||||
|
||||
# define M_ASN1_I2D_seq_total() \
|
||||
r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \
|
||||
if (pp == NULL) return(r); \
|
||||
p= *pp; \
|
||||
ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)
|
||||
|
||||
# define M_ASN1_I2D_INF_seq_start(tag,ctx) \
|
||||
*(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \
|
||||
*(p++)=0x80
|
||||
|
||||
# define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00
|
||||
|
||||
# define M_ASN1_I2D_finish() *pp=p; \
|
||||
return(r);
|
||||
|
||||
int asn1_GetSequence(ASN1_const_CTX *c, long *length);
|
||||
void asn1_add_error(const unsigned char *address, int offset);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
973
sgx-jvm/dependencies/root/usr/include/openssl/asn1t.h
Normal file
973
sgx-jvm/dependencies/root/usr/include/openssl/asn1t.h
Normal file
@ -0,0 +1,973 @@
|
||||
/* asn1t.h */
|
||||
/*
|
||||
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
#ifndef HEADER_ASN1T_H
|
||||
# define HEADER_ASN1T_H
|
||||
|
||||
# include <stddef.h>
|
||||
# include <openssl/e_os2.h>
|
||||
# include <openssl/asn1.h>
|
||||
|
||||
# ifdef OPENSSL_BUILD_SHLIBCRYPTO
|
||||
# undef OPENSSL_EXTERN
|
||||
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||
# endif
|
||||
|
||||
/* ASN1 template defines, structures and functions */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
|
||||
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
|
||||
# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
|
||||
|
||||
/* Macros for start and end of ASN1_ITEM definition */
|
||||
|
||||
# define ASN1_ITEM_start(itname) \
|
||||
OPENSSL_GLOBAL const ASN1_ITEM itname##_it = {
|
||||
|
||||
# define ASN1_ITEM_end(itname) \
|
||||
};
|
||||
|
||||
# else
|
||||
|
||||
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
|
||||
# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr()))
|
||||
|
||||
/* Macros for start and end of ASN1_ITEM definition */
|
||||
|
||||
# define ASN1_ITEM_start(itname) \
|
||||
const ASN1_ITEM * itname##_it(void) \
|
||||
{ \
|
||||
static const ASN1_ITEM local_it = {
|
||||
|
||||
# define ASN1_ITEM_end(itname) \
|
||||
}; \
|
||||
return &local_it; \
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
/* Macros to aid ASN1 template writing */
|
||||
|
||||
# define ASN1_ITEM_TEMPLATE(tname) \
|
||||
static const ASN1_TEMPLATE tname##_item_tt
|
||||
|
||||
# define ASN1_ITEM_TEMPLATE_END(tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_PRIMITIVE,\
|
||||
-1,\
|
||||
&tname##_item_tt,\
|
||||
0,\
|
||||
NULL,\
|
||||
0,\
|
||||
#tname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
/* This is a ASN1 type which just embeds a template */
|
||||
|
||||
/*-
|
||||
* This pair helps declare a SEQUENCE. We can do:
|
||||
*
|
||||
* ASN1_SEQUENCE(stname) = {
|
||||
* ... SEQUENCE components ...
|
||||
* } ASN1_SEQUENCE_END(stname)
|
||||
*
|
||||
* This will produce an ASN1_ITEM called stname_it
|
||||
* for a structure called stname.
|
||||
*
|
||||
* If you want the same structure but a different
|
||||
* name then use:
|
||||
*
|
||||
* ASN1_SEQUENCE(itname) = {
|
||||
* ... SEQUENCE components ...
|
||||
* } ASN1_SEQUENCE_END_name(stname, itname)
|
||||
*
|
||||
* This will create an item called itname_it using
|
||||
* a structure called stname.
|
||||
*/
|
||||
|
||||
# define ASN1_SEQUENCE(tname) \
|
||||
static const ASN1_TEMPLATE tname##_seq_tt[]
|
||||
|
||||
# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
|
||||
|
||||
# define ASN1_SEQUENCE_END_name(stname, tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
NULL,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define ASN1_NDEF_SEQUENCE(tname) \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
|
||||
ASN1_SEQUENCE_cb(tname, cb)
|
||||
|
||||
# define ASN1_SEQUENCE_cb(tname, cb) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_BROKEN_SEQUENCE(tname) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_SEQUENCE_ref(tname, cb, lck) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_SEQUENCE_enc(tname, enc, cb) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_NDEF_SEQUENCE_END(tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_NDEF_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
NULL,\
|
||||
sizeof(tname),\
|
||||
#tname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
|
||||
|
||||
# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
|
||||
|
||||
# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
|
||||
|
||||
# define ASN1_SEQUENCE_END_ref(stname, tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
&tname##_aux,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_NDEF_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
&tname##_aux,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
/*-
|
||||
* This pair helps declare a CHOICE type. We can do:
|
||||
*
|
||||
* ASN1_CHOICE(chname) = {
|
||||
* ... CHOICE options ...
|
||||
* ASN1_CHOICE_END(chname)
|
||||
*
|
||||
* This will produce an ASN1_ITEM called chname_it
|
||||
* for a structure called chname. The structure
|
||||
* definition must look like this:
|
||||
* typedef struct {
|
||||
* int type;
|
||||
* union {
|
||||
* ASN1_SOMETHING *opt1;
|
||||
* ASN1_SOMEOTHER *opt2;
|
||||
* } value;
|
||||
* } chname;
|
||||
*
|
||||
* the name of the selector must be 'type'.
|
||||
* to use an alternative selector name use the
|
||||
* ASN1_CHOICE_END_selector() version.
|
||||
*/
|
||||
|
||||
# define ASN1_CHOICE(tname) \
|
||||
static const ASN1_TEMPLATE tname##_ch_tt[]
|
||||
|
||||
# define ASN1_CHOICE_cb(tname, cb) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
|
||||
ASN1_CHOICE(tname)
|
||||
|
||||
# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
|
||||
|
||||
# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
|
||||
|
||||
# define ASN1_CHOICE_END_selector(stname, tname, selname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_CHOICE,\
|
||||
offsetof(stname,selname) ,\
|
||||
tname##_ch_tt,\
|
||||
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
NULL,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define ASN1_CHOICE_END_cb(stname, tname, selname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_CHOICE,\
|
||||
offsetof(stname,selname) ,\
|
||||
tname##_ch_tt,\
|
||||
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
&tname##_aux,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
/* This helps with the template wrapper form of ASN1_ITEM */
|
||||
|
||||
# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
|
||||
(flags), (tag), 0,\
|
||||
#name, ASN1_ITEM_ref(type) }
|
||||
|
||||
/* These help with SEQUENCE or CHOICE components */
|
||||
|
||||
/* used to declare other types */
|
||||
|
||||
# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
|
||||
(flags), (tag), offsetof(stname, field),\
|
||||
#field, ASN1_ITEM_ref(type) }
|
||||
|
||||
/* used when the structure is combined with the parent */
|
||||
|
||||
# define ASN1_EX_COMBINE(flags, tag, type) { \
|
||||
(flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) }
|
||||
|
||||
/* implicit and explicit helper macros */
|
||||
|
||||
# define ASN1_IMP_EX(stname, field, type, tag, ex) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)
|
||||
|
||||
# define ASN1_EXP_EX(stname, field, type, tag, ex) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)
|
||||
|
||||
/* Any defined by macros: the field used is in the table itself */
|
||||
|
||||
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
|
||||
# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
|
||||
# else
|
||||
# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
|
||||
# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }
|
||||
# endif
|
||||
/* Plain simple type */
|
||||
# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
|
||||
|
||||
/* OPTIONAL simple type */
|
||||
# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
||||
|
||||
/* IMPLICIT tagged simple type */
|
||||
# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
|
||||
|
||||
/* IMPLICIT tagged OPTIONAL simple type */
|
||||
# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
|
||||
|
||||
/* Same as above but EXPLICIT */
|
||||
|
||||
# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
|
||||
# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
|
||||
|
||||
/* SEQUENCE OF type */
|
||||
# define ASN1_SEQUENCE_OF(stname, field, type) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
|
||||
|
||||
/* OPTIONAL SEQUENCE OF */
|
||||
# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
||||
|
||||
/* Same as above but for SET OF */
|
||||
|
||||
# define ASN1_SET_OF(stname, field, type) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
|
||||
|
||||
# define ASN1_SET_OF_OPT(stname, field, type) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
||||
|
||||
/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
|
||||
|
||||
# define ASN1_IMP_SET_OF(stname, field, type, tag) \
|
||||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
|
||||
|
||||
# define ASN1_EXP_SET_OF(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
|
||||
|
||||
# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
|
||||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
|
||||
|
||||
# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
|
||||
|
||||
# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
|
||||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
|
||||
|
||||
# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
|
||||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
|
||||
|
||||
# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
|
||||
|
||||
# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
|
||||
|
||||
/* EXPLICIT using indefinite length constructed form */
|
||||
# define ASN1_NDEF_EXP(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
|
||||
|
||||
/* EXPLICIT OPTIONAL using indefinite length constructed form */
|
||||
# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
|
||||
|
||||
/* Macros for the ASN1_ADB structure */
|
||||
|
||||
# define ASN1_ADB(name) \
|
||||
static const ASN1_ADB_TABLE name##_adbtbl[]
|
||||
|
||||
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
|
||||
# define ASN1_ADB_END(name, flags, field, app_table, def, none) \
|
||||
;\
|
||||
static const ASN1_ADB name##_adb = {\
|
||||
flags,\
|
||||
offsetof(name, field),\
|
||||
app_table,\
|
||||
name##_adbtbl,\
|
||||
sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
|
||||
def,\
|
||||
none\
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
# define ASN1_ADB_END(name, flags, field, app_table, def, none) \
|
||||
;\
|
||||
static const ASN1_ITEM *name##_adb(void) \
|
||||
{ \
|
||||
static const ASN1_ADB internal_adb = \
|
||||
{\
|
||||
flags,\
|
||||
offsetof(name, field),\
|
||||
app_table,\
|
||||
name##_adbtbl,\
|
||||
sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
|
||||
def,\
|
||||
none\
|
||||
}; \
|
||||
return (const ASN1_ITEM *) &internal_adb; \
|
||||
} \
|
||||
void dummy_function(void)
|
||||
|
||||
# endif
|
||||
|
||||
# define ADB_ENTRY(val, template) {val, template}
|
||||
|
||||
# define ASN1_ADB_TEMPLATE(name) \
|
||||
static const ASN1_TEMPLATE name##_tt
|
||||
|
||||
/*
|
||||
* This is the ASN1 template structure that defines a wrapper round the
|
||||
* actual type. It determines the actual position of the field in the value
|
||||
* structure, various flags such as OPTIONAL and the field name.
|
||||
*/
|
||||
|
||||
struct ASN1_TEMPLATE_st {
|
||||
unsigned long flags; /* Various flags */
|
||||
long tag; /* tag, not used if no tagging */
|
||||
unsigned long offset; /* Offset of this field in structure */
|
||||
# ifndef NO_ASN1_FIELD_NAMES
|
||||
const char *field_name; /* Field name */
|
||||
# endif
|
||||
ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */
|
||||
};
|
||||
|
||||
/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
|
||||
|
||||
# define ASN1_TEMPLATE_item(t) (t->item_ptr)
|
||||
# define ASN1_TEMPLATE_adb(t) (t->item_ptr)
|
||||
|
||||
typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
|
||||
typedef struct ASN1_ADB_st ASN1_ADB;
|
||||
|
||||
struct ASN1_ADB_st {
|
||||
unsigned long flags; /* Various flags */
|
||||
unsigned long offset; /* Offset of selector field */
|
||||
STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */
|
||||
const ASN1_ADB_TABLE *tbl; /* Table of possible types */
|
||||
long tblcount; /* Number of entries in tbl */
|
||||
const ASN1_TEMPLATE *default_tt; /* Type to use if no match */
|
||||
const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */
|
||||
};
|
||||
|
||||
struct ASN1_ADB_TABLE_st {
|
||||
long value; /* NID for an object or value for an int */
|
||||
const ASN1_TEMPLATE tt; /* item for this value */
|
||||
};
|
||||
|
||||
/* template flags */
|
||||
|
||||
/* Field is optional */
|
||||
# define ASN1_TFLG_OPTIONAL (0x1)
|
||||
|
||||
/* Field is a SET OF */
|
||||
# define ASN1_TFLG_SET_OF (0x1 << 1)
|
||||
|
||||
/* Field is a SEQUENCE OF */
|
||||
# define ASN1_TFLG_SEQUENCE_OF (0x2 << 1)
|
||||
|
||||
/*
|
||||
* Special case: this refers to a SET OF that will be sorted into DER order
|
||||
* when encoded *and* the corresponding STACK will be modified to match the
|
||||
* new order.
|
||||
*/
|
||||
# define ASN1_TFLG_SET_ORDER (0x3 << 1)
|
||||
|
||||
/* Mask for SET OF or SEQUENCE OF */
|
||||
# define ASN1_TFLG_SK_MASK (0x3 << 1)
|
||||
|
||||
/*
|
||||
* These flags mean the tag should be taken from the tag field. If EXPLICIT
|
||||
* then the underlying type is used for the inner tag.
|
||||
*/
|
||||
|
||||
/* IMPLICIT tagging */
|
||||
# define ASN1_TFLG_IMPTAG (0x1 << 3)
|
||||
|
||||
/* EXPLICIT tagging, inner tag from underlying type */
|
||||
# define ASN1_TFLG_EXPTAG (0x2 << 3)
|
||||
|
||||
# define ASN1_TFLG_TAG_MASK (0x3 << 3)
|
||||
|
||||
/* context specific IMPLICIT */
|
||||
# define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT
|
||||
|
||||
/* context specific EXPLICIT */
|
||||
# define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT
|
||||
|
||||
/*
|
||||
* If tagging is in force these determine the type of tag to use. Otherwise
|
||||
* the tag is determined by the underlying type. These values reflect the
|
||||
* actual octet format.
|
||||
*/
|
||||
|
||||
/* Universal tag */
|
||||
# define ASN1_TFLG_UNIVERSAL (0x0<<6)
|
||||
/* Application tag */
|
||||
# define ASN1_TFLG_APPLICATION (0x1<<6)
|
||||
/* Context specific tag */
|
||||
# define ASN1_TFLG_CONTEXT (0x2<<6)
|
||||
/* Private tag */
|
||||
# define ASN1_TFLG_PRIVATE (0x3<<6)
|
||||
|
||||
# define ASN1_TFLG_TAG_CLASS (0x3<<6)
|
||||
|
||||
/*
|
||||
* These are for ANY DEFINED BY type. In this case the 'item' field points to
|
||||
* an ASN1_ADB structure which contains a table of values to decode the
|
||||
* relevant type
|
||||
*/
|
||||
|
||||
# define ASN1_TFLG_ADB_MASK (0x3<<8)
|
||||
|
||||
# define ASN1_TFLG_ADB_OID (0x1<<8)
|
||||
|
||||
# define ASN1_TFLG_ADB_INT (0x1<<9)
|
||||
|
||||
/*
|
||||
* This flag means a parent structure is passed instead of the field: this is
|
||||
* useful is a SEQUENCE is being combined with a CHOICE for example. Since
|
||||
* this means the structure and item name will differ we need to use the
|
||||
* ASN1_CHOICE_END_name() macro for example.
|
||||
*/
|
||||
|
||||
# define ASN1_TFLG_COMBINE (0x1<<10)
|
||||
|
||||
/*
|
||||
* This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes
|
||||
* indefinite length constructed encoding to be used if required.
|
||||
*/
|
||||
|
||||
# define ASN1_TFLG_NDEF (0x1<<11)
|
||||
|
||||
/* This is the actual ASN1 item itself */
|
||||
|
||||
struct ASN1_ITEM_st {
|
||||
char itype; /* The item type, primitive, SEQUENCE, CHOICE
|
||||
* or extern */
|
||||
long utype; /* underlying type */
|
||||
const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains
|
||||
* the contents */
|
||||
long tcount; /* Number of templates if SEQUENCE or CHOICE */
|
||||
const void *funcs; /* functions that handle this type */
|
||||
long size; /* Structure size (usually) */
|
||||
# ifndef NO_ASN1_FIELD_NAMES
|
||||
const char *sname; /* Structure name */
|
||||
# endif
|
||||
};
|
||||
|
||||
/*-
|
||||
* These are values for the itype field and
|
||||
* determine how the type is interpreted.
|
||||
*
|
||||
* For PRIMITIVE types the underlying type
|
||||
* determines the behaviour if items is NULL.
|
||||
*
|
||||
* Otherwise templates must contain a single
|
||||
* template and the type is treated in the
|
||||
* same way as the type specified in the template.
|
||||
*
|
||||
* For SEQUENCE types the templates field points
|
||||
* to the members, the size field is the
|
||||
* structure size.
|
||||
*
|
||||
* For CHOICE types the templates field points
|
||||
* to each possible member (typically a union)
|
||||
* and the 'size' field is the offset of the
|
||||
* selector.
|
||||
*
|
||||
* The 'funcs' field is used for application
|
||||
* specific functions.
|
||||
*
|
||||
* For COMPAT types the funcs field gives a
|
||||
* set of functions that handle this type, this
|
||||
* supports the old d2i, i2d convention.
|
||||
*
|
||||
* The EXTERN type uses a new style d2i/i2d.
|
||||
* The new style should be used where possible
|
||||
* because it avoids things like the d2i IMPLICIT
|
||||
* hack.
|
||||
*
|
||||
* MSTRING is a multiple string type, it is used
|
||||
* for a CHOICE of character strings where the
|
||||
* actual strings all occupy an ASN1_STRING
|
||||
* structure. In this case the 'utype' field
|
||||
* has a special meaning, it is used as a mask
|
||||
* of acceptable types using the B_ASN1 constants.
|
||||
*
|
||||
* NDEF_SEQUENCE is the same as SEQUENCE except
|
||||
* that it will use indefinite length constructed
|
||||
* encoding if requested.
|
||||
*
|
||||
*/
|
||||
|
||||
# define ASN1_ITYPE_PRIMITIVE 0x0
|
||||
|
||||
# define ASN1_ITYPE_SEQUENCE 0x1
|
||||
|
||||
# define ASN1_ITYPE_CHOICE 0x2
|
||||
|
||||
# define ASN1_ITYPE_COMPAT 0x3
|
||||
|
||||
# define ASN1_ITYPE_EXTERN 0x4
|
||||
|
||||
# define ASN1_ITYPE_MSTRING 0x5
|
||||
|
||||
# define ASN1_ITYPE_NDEF_SEQUENCE 0x6
|
||||
|
||||
/*
|
||||
* Cache for ASN1 tag and length, so we don't keep re-reading it for things
|
||||
* like CHOICE
|
||||
*/
|
||||
|
||||
struct ASN1_TLC_st {
|
||||
char valid; /* Values below are valid */
|
||||
int ret; /* return value */
|
||||
long plen; /* length */
|
||||
int ptag; /* class value */
|
||||
int pclass; /* class value */
|
||||
int hdrlen; /* header length */
|
||||
};
|
||||
|
||||
/* Typedefs for ASN1 function pointers */
|
||||
|
||||
typedef ASN1_VALUE *ASN1_new_func(void);
|
||||
typedef void ASN1_free_func(ASN1_VALUE *a);
|
||||
typedef ASN1_VALUE *ASN1_d2i_func(ASN1_VALUE **a, const unsigned char **in,
|
||||
long length);
|
||||
typedef int ASN1_i2d_func(ASN1_VALUE *a, unsigned char **in);
|
||||
|
||||
typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
const ASN1_ITEM *it, int tag, int aclass, char opt,
|
||||
ASN1_TLC *ctx);
|
||||
|
||||
typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass);
|
||||
typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
|
||||
typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,
|
||||
int indent, const char *fname,
|
||||
const ASN1_PCTX *pctx);
|
||||
|
||||
typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,
|
||||
int *putype, const ASN1_ITEM *it);
|
||||
typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,
|
||||
int len, int utype, char *free_cont,
|
||||
const ASN1_ITEM *it);
|
||||
typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it, int indent,
|
||||
const ASN1_PCTX *pctx);
|
||||
|
||||
typedef struct ASN1_COMPAT_FUNCS_st {
|
||||
ASN1_new_func *asn1_new;
|
||||
ASN1_free_func *asn1_free;
|
||||
ASN1_d2i_func *asn1_d2i;
|
||||
ASN1_i2d_func *asn1_i2d;
|
||||
} ASN1_COMPAT_FUNCS;
|
||||
|
||||
typedef struct ASN1_EXTERN_FUNCS_st {
|
||||
void *app_data;
|
||||
ASN1_ex_new_func *asn1_ex_new;
|
||||
ASN1_ex_free_func *asn1_ex_free;
|
||||
ASN1_ex_free_func *asn1_ex_clear;
|
||||
ASN1_ex_d2i *asn1_ex_d2i;
|
||||
ASN1_ex_i2d *asn1_ex_i2d;
|
||||
ASN1_ex_print_func *asn1_ex_print;
|
||||
} ASN1_EXTERN_FUNCS;
|
||||
|
||||
typedef struct ASN1_PRIMITIVE_FUNCS_st {
|
||||
void *app_data;
|
||||
unsigned long flags;
|
||||
ASN1_ex_new_func *prim_new;
|
||||
ASN1_ex_free_func *prim_free;
|
||||
ASN1_ex_free_func *prim_clear;
|
||||
ASN1_primitive_c2i *prim_c2i;
|
||||
ASN1_primitive_i2c *prim_i2c;
|
||||
ASN1_primitive_print *prim_print;
|
||||
} ASN1_PRIMITIVE_FUNCS;
|
||||
|
||||
/*
|
||||
* This is the ASN1_AUX structure: it handles various miscellaneous
|
||||
* requirements. For example the use of reference counts and an informational
|
||||
* callback. The "informational callback" is called at various points during
|
||||
* the ASN1 encoding and decoding. It can be used to provide minor
|
||||
* customisation of the structures used. This is most useful where the
|
||||
* supplied routines *almost* do the right thing but need some extra help at
|
||||
* a few points. If the callback returns zero then it is assumed a fatal
|
||||
* error has occurred and the main operation should be abandoned. If major
|
||||
* changes in the default behaviour are required then an external type is
|
||||
* more appropriate.
|
||||
*/
|
||||
|
||||
typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
|
||||
void *exarg);
|
||||
|
||||
typedef struct ASN1_AUX_st {
|
||||
void *app_data;
|
||||
int flags;
|
||||
int ref_offset; /* Offset of reference value */
|
||||
int ref_lock; /* Lock type to use */
|
||||
ASN1_aux_cb *asn1_cb;
|
||||
int enc_offset; /* Offset of ASN1_ENCODING structure */
|
||||
} ASN1_AUX;
|
||||
|
||||
/* For print related callbacks exarg points to this structure */
|
||||
typedef struct ASN1_PRINT_ARG_st {
|
||||
BIO *out;
|
||||
int indent;
|
||||
const ASN1_PCTX *pctx;
|
||||
} ASN1_PRINT_ARG;
|
||||
|
||||
/* For streaming related callbacks exarg points to this structure */
|
||||
typedef struct ASN1_STREAM_ARG_st {
|
||||
/* BIO to stream through */
|
||||
BIO *out;
|
||||
/* BIO with filters appended */
|
||||
BIO *ndef_bio;
|
||||
/* Streaming I/O boundary */
|
||||
unsigned char **boundary;
|
||||
} ASN1_STREAM_ARG;
|
||||
|
||||
/* Flags in ASN1_AUX */
|
||||
|
||||
/* Use a reference count */
|
||||
# define ASN1_AFLG_REFCOUNT 1
|
||||
/* Save the encoding of structure (useful for signatures) */
|
||||
# define ASN1_AFLG_ENCODING 2
|
||||
/* The Sequence length is invalid */
|
||||
# define ASN1_AFLG_BROKEN 4
|
||||
|
||||
/* operation values for asn1_cb */
|
||||
|
||||
# define ASN1_OP_NEW_PRE 0
|
||||
# define ASN1_OP_NEW_POST 1
|
||||
# define ASN1_OP_FREE_PRE 2
|
||||
# define ASN1_OP_FREE_POST 3
|
||||
# define ASN1_OP_D2I_PRE 4
|
||||
# define ASN1_OP_D2I_POST 5
|
||||
# define ASN1_OP_I2D_PRE 6
|
||||
# define ASN1_OP_I2D_POST 7
|
||||
# define ASN1_OP_PRINT_PRE 8
|
||||
# define ASN1_OP_PRINT_POST 9
|
||||
# define ASN1_OP_STREAM_PRE 10
|
||||
# define ASN1_OP_STREAM_POST 11
|
||||
# define ASN1_OP_DETACHED_PRE 12
|
||||
# define ASN1_OP_DETACHED_POST 13
|
||||
|
||||
/* Macro to implement a primitive type */
|
||||
# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
|
||||
# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
|
||||
ASN1_ITEM_start(itname) \
|
||||
ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
|
||||
ASN1_ITEM_end(itname)
|
||||
|
||||
/* Macro to implement a multi string type */
|
||||
# define IMPLEMENT_ASN1_MSTRING(itname, mask) \
|
||||
ASN1_ITEM_start(itname) \
|
||||
ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
|
||||
ASN1_ITEM_end(itname)
|
||||
|
||||
/* Macro to implement an ASN1_ITEM in terms of old style funcs */
|
||||
|
||||
# define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)
|
||||
|
||||
# define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \
|
||||
static const ASN1_COMPAT_FUNCS sname##_ff = { \
|
||||
(ASN1_new_func *)sname##_new, \
|
||||
(ASN1_free_func *)sname##_free, \
|
||||
(ASN1_d2i_func *)d2i_##sname, \
|
||||
(ASN1_i2d_func *)i2d_##sname, \
|
||||
}; \
|
||||
ASN1_ITEM_start(sname) \
|
||||
ASN1_ITYPE_COMPAT, \
|
||||
tag, \
|
||||
NULL, \
|
||||
0, \
|
||||
&sname##_ff, \
|
||||
0, \
|
||||
#sname \
|
||||
ASN1_ITEM_end(sname)
|
||||
|
||||
# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
|
||||
ASN1_ITEM_start(sname) \
|
||||
ASN1_ITYPE_EXTERN, \
|
||||
tag, \
|
||||
NULL, \
|
||||
0, \
|
||||
&fptrs, \
|
||||
0, \
|
||||
#sname \
|
||||
ASN1_ITEM_end(sname)
|
||||
|
||||
/* Macro to implement standard functions in terms of ASN1_ITEM structures */
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
|
||||
IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
|
||||
|
||||
# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
|
||||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)
|
||||
|
||||
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
|
||||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
|
||||
|
||||
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
|
||||
pre stname *fname##_new(void) \
|
||||
{ \
|
||||
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
|
||||
} \
|
||||
pre void fname##_free(stname *a) \
|
||||
{ \
|
||||
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
|
||||
stname *fname##_new(void) \
|
||||
{ \
|
||||
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
|
||||
} \
|
||||
void fname##_free(stname *a) \
|
||||
{ \
|
||||
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
|
||||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
|
||||
|
||||
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
|
||||
stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
|
||||
{ \
|
||||
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
|
||||
} \
|
||||
int i2d_##fname(stname *a, unsigned char **out) \
|
||||
{ \
|
||||
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
|
||||
int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
|
||||
{ \
|
||||
return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
|
||||
}
|
||||
|
||||
/*
|
||||
* This includes evil casts to remove const: they will go away when full ASN1
|
||||
* constification is done.
|
||||
*/
|
||||
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
|
||||
stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
|
||||
{ \
|
||||
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
|
||||
} \
|
||||
int i2d_##fname(const stname *a, unsigned char **out) \
|
||||
{ \
|
||||
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
|
||||
stname * stname##_dup(stname *x) \
|
||||
{ \
|
||||
return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
|
||||
IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)
|
||||
|
||||
# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
|
||||
int fname##_print_ctx(BIO *out, stname *x, int indent, \
|
||||
const ASN1_PCTX *pctx) \
|
||||
{ \
|
||||
return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \
|
||||
ASN1_ITEM_rptr(itname), pctx); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
|
||||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
|
||||
|
||||
/* external definitions for primitive types */
|
||||
|
||||
DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
|
||||
DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
|
||||
DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
|
||||
DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
|
||||
DECLARE_ASN1_ITEM(CBIGNUM)
|
||||
DECLARE_ASN1_ITEM(BIGNUM)
|
||||
DECLARE_ASN1_ITEM(LONG)
|
||||
DECLARE_ASN1_ITEM(ZLONG)
|
||||
|
||||
DECLARE_STACK_OF(ASN1_VALUE)
|
||||
|
||||
/* Functions used internally by the ASN1 code */
|
||||
|
||||
int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
|
||||
int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
|
||||
void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
|
||||
int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
const ASN1_TEMPLATE *tt);
|
||||
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
const ASN1_ITEM *it, int tag, int aclass, char opt,
|
||||
ASN1_TLC *ctx);
|
||||
|
||||
int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass);
|
||||
int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_TEMPLATE *tt);
|
||||
void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
|
||||
int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it);
|
||||
int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it);
|
||||
|
||||
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
|
||||
const ASN1_ITEM *it);
|
||||
|
||||
ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
|
||||
|
||||
const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
int nullerr);
|
||||
|
||||
int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);
|
||||
|
||||
void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it);
|
||||
int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
|
||||
const ASN1_ITEM *it);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
883
sgx-jvm/dependencies/root/usr/include/openssl/bio.h
Normal file
883
sgx-jvm/dependencies/root/usr/include/openssl/bio.h
Normal file
@ -0,0 +1,883 @@
|
||||
/* crypto/bio/bio.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BIO_H
|
||||
# define HEADER_BIO_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
# include <stdarg.h>
|
||||
|
||||
# include <openssl/crypto.h>
|
||||
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
# ifndef OPENSSL_SYS_VMS
|
||||
# include <stdint.h>
|
||||
# else
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* These are the 'types' of BIOs */
|
||||
# define BIO_TYPE_NONE 0
|
||||
# define BIO_TYPE_MEM (1|0x0400)
|
||||
# define BIO_TYPE_FILE (2|0x0400)
|
||||
|
||||
# define BIO_TYPE_FD (4|0x0400|0x0100)
|
||||
# define BIO_TYPE_SOCKET (5|0x0400|0x0100)
|
||||
# define BIO_TYPE_NULL (6|0x0400)
|
||||
# define BIO_TYPE_SSL (7|0x0200)
|
||||
# define BIO_TYPE_MD (8|0x0200)/* passive filter */
|
||||
# define BIO_TYPE_BUFFER (9|0x0200)/* filter */
|
||||
# define BIO_TYPE_CIPHER (10|0x0200)/* filter */
|
||||
# define BIO_TYPE_BASE64 (11|0x0200)/* filter */
|
||||
# define BIO_TYPE_CONNECT (12|0x0400|0x0100)/* socket - connect */
|
||||
# define BIO_TYPE_ACCEPT (13|0x0400|0x0100)/* socket for accept */
|
||||
# define BIO_TYPE_PROXY_CLIENT (14|0x0200)/* client proxy BIO */
|
||||
# define BIO_TYPE_PROXY_SERVER (15|0x0200)/* server proxy BIO */
|
||||
# define BIO_TYPE_NBIO_TEST (16|0x0200)/* server proxy BIO */
|
||||
# define BIO_TYPE_NULL_FILTER (17|0x0200)
|
||||
# define BIO_TYPE_BER (18|0x0200)/* BER -> bin filter */
|
||||
# define BIO_TYPE_BIO (19|0x0400)/* (half a) BIO pair */
|
||||
# define BIO_TYPE_LINEBUFFER (20|0x0200)/* filter */
|
||||
# define BIO_TYPE_DGRAM (21|0x0400|0x0100)
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
# define BIO_TYPE_DGRAM_SCTP (24|0x0400|0x0100)
|
||||
# endif
|
||||
# define BIO_TYPE_ASN1 (22|0x0200)/* filter */
|
||||
# define BIO_TYPE_COMP (23|0x0200)/* filter */
|
||||
|
||||
# define BIO_TYPE_DESCRIPTOR 0x0100/* socket, fd, connect or accept */
|
||||
# define BIO_TYPE_FILTER 0x0200
|
||||
# define BIO_TYPE_SOURCE_SINK 0x0400
|
||||
|
||||
/*
|
||||
* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
|
||||
* BIO_set_fp(in,stdin,BIO_NOCLOSE);
|
||||
*/
|
||||
# define BIO_NOCLOSE 0x00
|
||||
# define BIO_CLOSE 0x01
|
||||
|
||||
/*
|
||||
* These are used in the following macros and are passed to BIO_ctrl()
|
||||
*/
|
||||
# define BIO_CTRL_RESET 1/* opt - rewind/zero etc */
|
||||
# define BIO_CTRL_EOF 2/* opt - are we at the eof */
|
||||
# define BIO_CTRL_INFO 3/* opt - extra tit-bits */
|
||||
# define BIO_CTRL_SET 4/* man - set the 'IO' type */
|
||||
# define BIO_CTRL_GET 5/* man - get the 'IO' type */
|
||||
# define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */
|
||||
# define BIO_CTRL_POP 7/* opt - internal, used to signify change */
|
||||
# define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */
|
||||
# define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */
|
||||
# define BIO_CTRL_PENDING 10/* opt - is their more data buffered */
|
||||
# define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */
|
||||
# define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */
|
||||
# define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */
|
||||
/* callback is int cb(BIO *bio,state,ret); */
|
||||
# define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */
|
||||
# define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */
|
||||
|
||||
# define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */
|
||||
|
||||
/* dgram BIO stuff */
|
||||
# define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */
|
||||
# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected
|
||||
* socket to be passed in */
|
||||
# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */
|
||||
# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */
|
||||
# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */
|
||||
# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */
|
||||
|
||||
# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */
|
||||
# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */
|
||||
|
||||
/* #ifdef IP_MTU_DISCOVER */
|
||||
# define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */
|
||||
/* #endif */
|
||||
|
||||
# define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */
|
||||
# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47
|
||||
# define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */
|
||||
# define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU.
|
||||
* want to use this if asking
|
||||
* the kernel fails */
|
||||
|
||||
# define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was
|
||||
* exceed in the previous write
|
||||
* operation */
|
||||
|
||||
# define BIO_CTRL_DGRAM_GET_PEER 46
|
||||
# define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */
|
||||
|
||||
# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout
|
||||
* to adjust socket timeouts */
|
||||
# define BIO_CTRL_DGRAM_SET_DONT_FRAG 48
|
||||
|
||||
# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49
|
||||
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
/* SCTP stuff */
|
||||
# define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50
|
||||
# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51
|
||||
# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52
|
||||
# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53
|
||||
# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60
|
||||
# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61
|
||||
# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62
|
||||
# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63
|
||||
# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64
|
||||
# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65
|
||||
# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70
|
||||
# endif
|
||||
|
||||
/* modifiers */
|
||||
# define BIO_FP_READ 0x02
|
||||
# define BIO_FP_WRITE 0x04
|
||||
# define BIO_FP_APPEND 0x08
|
||||
# define BIO_FP_TEXT 0x10
|
||||
|
||||
# define BIO_FLAGS_READ 0x01
|
||||
# define BIO_FLAGS_WRITE 0x02
|
||||
# define BIO_FLAGS_IO_SPECIAL 0x04
|
||||
# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
|
||||
# define BIO_FLAGS_SHOULD_RETRY 0x08
|
||||
# ifndef BIO_FLAGS_UPLINK
|
||||
/*
|
||||
* "UPLINK" flag denotes file descriptors provided by application. It
|
||||
* defaults to 0, as most platforms don't require UPLINK interface.
|
||||
*/
|
||||
# define BIO_FLAGS_UPLINK 0
|
||||
# endif
|
||||
|
||||
/* Used in BIO_gethostbyname() */
|
||||
# define BIO_GHBN_CTRL_HITS 1
|
||||
# define BIO_GHBN_CTRL_MISSES 2
|
||||
# define BIO_GHBN_CTRL_CACHE_SIZE 3
|
||||
# define BIO_GHBN_CTRL_GET_ENTRY 4
|
||||
# define BIO_GHBN_CTRL_FLUSH 5
|
||||
|
||||
/* Mostly used in the SSL BIO */
|
||||
/*-
|
||||
* Not used anymore
|
||||
* #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10
|
||||
* #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20
|
||||
* #define BIO_FLAGS_PROTOCOL_STARTUP 0x40
|
||||
*/
|
||||
|
||||
# define BIO_FLAGS_BASE64_NO_NL 0x100
|
||||
|
||||
/*
|
||||
* This is used with memory BIOs: it means we shouldn't free up or change the
|
||||
* data in any way.
|
||||
*/
|
||||
# define BIO_FLAGS_MEM_RDONLY 0x200
|
||||
|
||||
typedef struct bio_st BIO;
|
||||
|
||||
void BIO_set_flags(BIO *b, int flags);
|
||||
int BIO_test_flags(const BIO *b, int flags);
|
||||
void BIO_clear_flags(BIO *b, int flags);
|
||||
|
||||
# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
|
||||
# define BIO_set_retry_special(b) \
|
||||
BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
|
||||
# define BIO_set_retry_read(b) \
|
||||
BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
|
||||
# define BIO_set_retry_write(b) \
|
||||
BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
|
||||
|
||||
/* These are normally used internally in BIOs */
|
||||
# define BIO_clear_retry_flags(b) \
|
||||
BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
# define BIO_get_retry_flags(b) \
|
||||
BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
|
||||
/* These should be used by the application to tell why we should retry */
|
||||
# define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ)
|
||||
# define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE)
|
||||
# define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
|
||||
# define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS)
|
||||
# define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
|
||||
|
||||
/*
|
||||
* The next three are used in conjunction with the BIO_should_io_special()
|
||||
* condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int
|
||||
* *reason); will walk the BIO stack and return the 'reason' for the special
|
||||
* and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return
|
||||
* the code.
|
||||
*/
|
||||
/*
|
||||
* Returned from the SSL bio when the certificate retrieval code had an error
|
||||
*/
|
||||
# define BIO_RR_SSL_X509_LOOKUP 0x01
|
||||
/* Returned from the connect BIO when a connect would have blocked */
|
||||
# define BIO_RR_CONNECT 0x02
|
||||
/* Returned from the accept BIO when an accept would have blocked */
|
||||
# define BIO_RR_ACCEPT 0x03
|
||||
|
||||
/* These are passed by the BIO callback */
|
||||
# define BIO_CB_FREE 0x01
|
||||
# define BIO_CB_READ 0x02
|
||||
# define BIO_CB_WRITE 0x03
|
||||
# define BIO_CB_PUTS 0x04
|
||||
# define BIO_CB_GETS 0x05
|
||||
# define BIO_CB_CTRL 0x06
|
||||
|
||||
/*
|
||||
* The callback is called before and after the underling operation, The
|
||||
* BIO_CB_RETURN flag indicates if it is after the call
|
||||
*/
|
||||
# define BIO_CB_RETURN 0x80
|
||||
# define BIO_CB_return(a) ((a)|BIO_CB_RETURN)
|
||||
# define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN))
|
||||
# define BIO_cb_post(a) ((a)&BIO_CB_RETURN)
|
||||
|
||||
long (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *,
|
||||
int, long, long);
|
||||
void BIO_set_callback(BIO *b,
|
||||
long (*callback) (struct bio_st *, int, const char *,
|
||||
int, long, long));
|
||||
char *BIO_get_callback_arg(const BIO *b);
|
||||
void BIO_set_callback_arg(BIO *b, char *arg);
|
||||
|
||||
const char *BIO_method_name(const BIO *b);
|
||||
int BIO_method_type(const BIO *b);
|
||||
|
||||
typedef void bio_info_cb (struct bio_st *, int, const char *, int, long,
|
||||
long);
|
||||
|
||||
typedef struct bio_method_st {
|
||||
int type;
|
||||
const char *name;
|
||||
int (*bwrite) (BIO *, const char *, int);
|
||||
int (*bread) (BIO *, char *, int);
|
||||
int (*bputs) (BIO *, const char *);
|
||||
int (*bgets) (BIO *, char *, int);
|
||||
long (*ctrl) (BIO *, int, long, void *);
|
||||
int (*create) (BIO *);
|
||||
int (*destroy) (BIO *);
|
||||
long (*callback_ctrl) (BIO *, int, bio_info_cb *);
|
||||
} BIO_METHOD;
|
||||
|
||||
struct bio_st {
|
||||
BIO_METHOD *method;
|
||||
/* bio, mode, argp, argi, argl, ret */
|
||||
long (*callback) (struct bio_st *, int, const char *, int, long, long);
|
||||
char *cb_arg; /* first argument for the callback */
|
||||
int init;
|
||||
int shutdown;
|
||||
int flags; /* extra storage */
|
||||
int retry_reason;
|
||||
int num;
|
||||
void *ptr;
|
||||
struct bio_st *next_bio; /* used by filter BIOs */
|
||||
struct bio_st *prev_bio; /* used by filter BIOs */
|
||||
int references;
|
||||
unsigned long num_read;
|
||||
unsigned long num_write;
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
};
|
||||
|
||||
DECLARE_STACK_OF(BIO)
|
||||
|
||||
typedef struct bio_f_buffer_ctx_struct {
|
||||
/*-
|
||||
* Buffers are setup like this:
|
||||
*
|
||||
* <---------------------- size ----------------------->
|
||||
* +---------------------------------------------------+
|
||||
* | consumed | remaining | free space |
|
||||
* +---------------------------------------------------+
|
||||
* <-- off --><------- len ------->
|
||||
*/
|
||||
/*- BIO *bio; *//*
|
||||
* this is now in the BIO struct
|
||||
*/
|
||||
int ibuf_size; /* how big is the input buffer */
|
||||
int obuf_size; /* how big is the output buffer */
|
||||
char *ibuf; /* the char array */
|
||||
int ibuf_len; /* how many bytes are in it */
|
||||
int ibuf_off; /* write/read offset */
|
||||
char *obuf; /* the char array */
|
||||
int obuf_len; /* how many bytes are in it */
|
||||
int obuf_off; /* write/read offset */
|
||||
} BIO_F_BUFFER_CTX;
|
||||
|
||||
/* Prefix and suffix callback in ASN1 BIO */
|
||||
typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,
|
||||
void *parg);
|
||||
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
/* SCTP parameter structs */
|
||||
struct bio_dgram_sctp_sndinfo {
|
||||
uint16_t snd_sid;
|
||||
uint16_t snd_flags;
|
||||
uint32_t snd_ppid;
|
||||
uint32_t snd_context;
|
||||
};
|
||||
|
||||
struct bio_dgram_sctp_rcvinfo {
|
||||
uint16_t rcv_sid;
|
||||
uint16_t rcv_ssn;
|
||||
uint16_t rcv_flags;
|
||||
uint32_t rcv_ppid;
|
||||
uint32_t rcv_tsn;
|
||||
uint32_t rcv_cumtsn;
|
||||
uint32_t rcv_context;
|
||||
};
|
||||
|
||||
struct bio_dgram_sctp_prinfo {
|
||||
uint16_t pr_policy;
|
||||
uint32_t pr_value;
|
||||
};
|
||||
# endif
|
||||
|
||||
/* connect BIO stuff */
|
||||
# define BIO_CONN_S_BEFORE 1
|
||||
# define BIO_CONN_S_GET_IP 2
|
||||
# define BIO_CONN_S_GET_PORT 3
|
||||
# define BIO_CONN_S_CREATE_SOCKET 4
|
||||
# define BIO_CONN_S_CONNECT 5
|
||||
# define BIO_CONN_S_OK 6
|
||||
# define BIO_CONN_S_BLOCKED_CONNECT 7
|
||||
# define BIO_CONN_S_NBIO 8
|
||||
/*
|
||||
* #define BIO_CONN_get_param_hostname BIO_ctrl
|
||||
*/
|
||||
|
||||
# define BIO_C_SET_CONNECT 100
|
||||
# define BIO_C_DO_STATE_MACHINE 101
|
||||
# define BIO_C_SET_NBIO 102
|
||||
# define BIO_C_SET_PROXY_PARAM 103
|
||||
# define BIO_C_SET_FD 104
|
||||
# define BIO_C_GET_FD 105
|
||||
# define BIO_C_SET_FILE_PTR 106
|
||||
# define BIO_C_GET_FILE_PTR 107
|
||||
# define BIO_C_SET_FILENAME 108
|
||||
# define BIO_C_SET_SSL 109
|
||||
# define BIO_C_GET_SSL 110
|
||||
# define BIO_C_SET_MD 111
|
||||
# define BIO_C_GET_MD 112
|
||||
# define BIO_C_GET_CIPHER_STATUS 113
|
||||
# define BIO_C_SET_BUF_MEM 114
|
||||
# define BIO_C_GET_BUF_MEM_PTR 115
|
||||
# define BIO_C_GET_BUFF_NUM_LINES 116
|
||||
# define BIO_C_SET_BUFF_SIZE 117
|
||||
# define BIO_C_SET_ACCEPT 118
|
||||
# define BIO_C_SSL_MODE 119
|
||||
# define BIO_C_GET_MD_CTX 120
|
||||
# define BIO_C_GET_PROXY_PARAM 121
|
||||
# define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */
|
||||
# define BIO_C_GET_CONNECT 123
|
||||
# define BIO_C_GET_ACCEPT 124
|
||||
# define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125
|
||||
# define BIO_C_GET_SSL_NUM_RENEGOTIATES 126
|
||||
# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127
|
||||
# define BIO_C_FILE_SEEK 128
|
||||
# define BIO_C_GET_CIPHER_CTX 129
|
||||
# define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input
|
||||
* value */
|
||||
# define BIO_C_SET_BIND_MODE 131
|
||||
# define BIO_C_GET_BIND_MODE 132
|
||||
# define BIO_C_FILE_TELL 133
|
||||
# define BIO_C_GET_SOCKS 134
|
||||
# define BIO_C_SET_SOCKS 135
|
||||
|
||||
# define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */
|
||||
# define BIO_C_GET_WRITE_BUF_SIZE 137
|
||||
# define BIO_C_MAKE_BIO_PAIR 138
|
||||
# define BIO_C_DESTROY_BIO_PAIR 139
|
||||
# define BIO_C_GET_WRITE_GUARANTEE 140
|
||||
# define BIO_C_GET_READ_REQUEST 141
|
||||
# define BIO_C_SHUTDOWN_WR 142
|
||||
# define BIO_C_NREAD0 143
|
||||
# define BIO_C_NREAD 144
|
||||
# define BIO_C_NWRITE0 145
|
||||
# define BIO_C_NWRITE 146
|
||||
# define BIO_C_RESET_READ_REQUEST 147
|
||||
# define BIO_C_SET_MD_CTX 148
|
||||
|
||||
# define BIO_C_SET_PREFIX 149
|
||||
# define BIO_C_GET_PREFIX 150
|
||||
# define BIO_C_SET_SUFFIX 151
|
||||
# define BIO_C_GET_SUFFIX 152
|
||||
|
||||
# define BIO_C_SET_EX_ARG 153
|
||||
# define BIO_C_GET_EX_ARG 154
|
||||
|
||||
# define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
|
||||
# define BIO_get_app_data(s) BIO_get_ex_data(s,0)
|
||||
|
||||
/* BIO_s_connect() and BIO_s_socks4a_connect() */
|
||||
# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
|
||||
# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
|
||||
# define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
|
||||
# define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
|
||||
# define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
|
||||
# define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
|
||||
# define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
|
||||
# define BIO_get_conn_int_port(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)
|
||||
|
||||
# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
|
||||
|
||||
/* BIO_s_accept() */
|
||||
# define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
|
||||
# define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
|
||||
/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
|
||||
# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)"a":NULL)
|
||||
# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)
|
||||
|
||||
# define BIO_BIND_NORMAL 0
|
||||
# define BIO_BIND_REUSEADDR_IF_UNUSED 1
|
||||
# define BIO_BIND_REUSEADDR 2
|
||||
# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
|
||||
# define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
|
||||
|
||||
/* BIO_s_accept() and BIO_s_connect() */
|
||||
# define BIO_do_connect(b) BIO_do_handshake(b)
|
||||
# define BIO_do_accept(b) BIO_do_handshake(b)
|
||||
# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
|
||||
|
||||
/* BIO_s_proxy_client() */
|
||||
# define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))
|
||||
# define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))
|
||||
/* BIO_set_nbio(b,n) */
|
||||
# define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
|
||||
/* BIO *BIO_get_filter_bio(BIO *bio); */
|
||||
# define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
|
||||
# define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
|
||||
# define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)
|
||||
|
||||
# define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)
|
||||
# define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))
|
||||
# define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))
|
||||
# define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)
|
||||
|
||||
/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */
|
||||
# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
|
||||
# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
|
||||
|
||||
/* BIO_s_file() */
|
||||
# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
|
||||
# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
|
||||
|
||||
/* BIO_s_fd() and BIO_s_file() */
|
||||
# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
|
||||
# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
|
||||
|
||||
/*
|
||||
* name is cast to lose const, but might be better to route through a
|
||||
* function so we can do it safely
|
||||
*/
|
||||
# ifdef CONST_STRICT
|
||||
/*
|
||||
* If you are wondering why this isn't defined, its because CONST_STRICT is
|
||||
* purely a compile-time kludge to allow const to be checked.
|
||||
*/
|
||||
int BIO_read_filename(BIO *b, const char *name);
|
||||
# else
|
||||
# define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_READ,(char *)name)
|
||||
# endif
|
||||
# define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_WRITE,name)
|
||||
# define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_APPEND,name)
|
||||
# define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
|
||||
|
||||
/*
|
||||
* WARNING WARNING, this ups the reference count on the read bio of the SSL
|
||||
* structure. This is because the ssl read BIO is now pointed to by the
|
||||
* next_bio field in the bio. So when you free the BIO, make sure you are
|
||||
* doing a BIO_free_all() to catch the underlying BIO.
|
||||
*/
|
||||
# define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
|
||||
# define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
|
||||
# define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
|
||||
# define BIO_set_ssl_renegotiate_bytes(b,num) \
|
||||
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
|
||||
# define BIO_get_num_renegotiates(b) \
|
||||
BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL);
|
||||
# define BIO_set_ssl_renegotiate_timeout(b,seconds) \
|
||||
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);
|
||||
|
||||
/* defined in evp.h */
|
||||
/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
|
||||
|
||||
# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
|
||||
# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
|
||||
# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
|
||||
# define BIO_set_mem_eof_return(b,v) \
|
||||
BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
|
||||
|
||||
/* For the BIO_f_buffer() type */
|
||||
# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
|
||||
# define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
|
||||
# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
|
||||
# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
|
||||
# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
|
||||
|
||||
/* Don't use the next one unless you know what you are doing :-) */
|
||||
# define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
|
||||
|
||||
# define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
|
||||
# define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
|
||||
# define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
|
||||
# define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
|
||||
# define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
|
||||
# define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
|
||||
/* ...pending macros have inappropriate return type */
|
||||
size_t BIO_ctrl_pending(BIO *b);
|
||||
size_t BIO_ctrl_wpending(BIO *b);
|
||||
# define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
|
||||
# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
|
||||
cbp)
|
||||
# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
|
||||
|
||||
/* For the BIO_f_buffer() type */
|
||||
# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
|
||||
|
||||
/* For BIO_s_bio() */
|
||||
# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
|
||||
# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
|
||||
# define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
|
||||
# define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
|
||||
# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
|
||||
/* macros with inappropriate type -- but ...pending macros use int too: */
|
||||
# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
|
||||
# define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
|
||||
size_t BIO_ctrl_get_write_guarantee(BIO *b);
|
||||
size_t BIO_ctrl_get_read_request(BIO *b);
|
||||
int BIO_ctrl_reset_read_request(BIO *b);
|
||||
|
||||
/* ctrl macros for dgram */
|
||||
# define BIO_ctrl_dgram_connect(b,peer) \
|
||||
(int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)
|
||||
# define BIO_ctrl_set_connected(b, state, peer) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)
|
||||
# define BIO_dgram_recv_timedout(b) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
|
||||
# define BIO_dgram_send_timedout(b) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
|
||||
# define BIO_dgram_get_peer(b,peer) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)
|
||||
# define BIO_dgram_set_peer(b,peer) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
|
||||
# define BIO_dgram_get_mtu_overhead(b) \
|
||||
(unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)
|
||||
|
||||
/* These two aren't currently implemented */
|
||||
/* int BIO_get_ex_num(BIO *bio); */
|
||||
/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
|
||||
int BIO_set_ex_data(BIO *bio, int idx, void *data);
|
||||
void *BIO_get_ex_data(BIO *bio, int idx);
|
||||
int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
|
||||
unsigned long BIO_number_read(BIO *bio);
|
||||
unsigned long BIO_number_written(BIO *bio);
|
||||
|
||||
/* For BIO_f_asn1() */
|
||||
int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
|
||||
asn1_ps_func *prefix_free);
|
||||
int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
|
||||
asn1_ps_func **pprefix_free);
|
||||
int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
|
||||
asn1_ps_func *suffix_free);
|
||||
int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
|
||||
asn1_ps_func **psuffix_free);
|
||||
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
BIO_METHOD *BIO_s_file(void);
|
||||
BIO *BIO_new_file(const char *filename, const char *mode);
|
||||
BIO *BIO_new_fp(FILE *stream, int close_flag);
|
||||
# define BIO_s_file_internal BIO_s_file
|
||||
# endif
|
||||
BIO *BIO_new(BIO_METHOD *type);
|
||||
int BIO_set(BIO *a, BIO_METHOD *type);
|
||||
int BIO_free(BIO *a);
|
||||
void BIO_vfree(BIO *a);
|
||||
int BIO_read(BIO *b, void *data, int len);
|
||||
int BIO_gets(BIO *bp, char *buf, int size);
|
||||
int BIO_write(BIO *b, const void *data, int len);
|
||||
int BIO_puts(BIO *bp, const char *buf);
|
||||
int BIO_indent(BIO *b, int indent, int max);
|
||||
long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
|
||||
long BIO_callback_ctrl(BIO *b, int cmd,
|
||||
void (*fp) (struct bio_st *, int, const char *, int,
|
||||
long, long));
|
||||
char *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
|
||||
long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
|
||||
BIO *BIO_push(BIO *b, BIO *append);
|
||||
BIO *BIO_pop(BIO *b);
|
||||
void BIO_free_all(BIO *a);
|
||||
BIO *BIO_find_type(BIO *b, int bio_type);
|
||||
BIO *BIO_next(BIO *b);
|
||||
BIO *BIO_get_retry_BIO(BIO *bio, int *reason);
|
||||
int BIO_get_retry_reason(BIO *bio);
|
||||
BIO *BIO_dup_chain(BIO *in);
|
||||
|
||||
int BIO_nread0(BIO *bio, char **buf);
|
||||
int BIO_nread(BIO *bio, char **buf, int num);
|
||||
int BIO_nwrite0(BIO *bio, char **buf);
|
||||
int BIO_nwrite(BIO *bio, char **buf, int num);
|
||||
|
||||
long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
|
||||
long argl, long ret);
|
||||
|
||||
BIO_METHOD *BIO_s_mem(void);
|
||||
BIO *BIO_new_mem_buf(const void *buf, int len);
|
||||
BIO_METHOD *BIO_s_socket(void);
|
||||
BIO_METHOD *BIO_s_connect(void);
|
||||
BIO_METHOD *BIO_s_accept(void);
|
||||
BIO_METHOD *BIO_s_fd(void);
|
||||
# ifndef OPENSSL_SYS_OS2
|
||||
BIO_METHOD *BIO_s_log(void);
|
||||
# endif
|
||||
BIO_METHOD *BIO_s_bio(void);
|
||||
BIO_METHOD *BIO_s_null(void);
|
||||
BIO_METHOD *BIO_f_null(void);
|
||||
BIO_METHOD *BIO_f_buffer(void);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
BIO_METHOD *BIO_f_linebuffer(void);
|
||||
# endif
|
||||
BIO_METHOD *BIO_f_nbio_test(void);
|
||||
# ifndef OPENSSL_NO_DGRAM
|
||||
BIO_METHOD *BIO_s_datagram(void);
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
BIO_METHOD *BIO_s_datagram_sctp(void);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* BIO_METHOD *BIO_f_ber(void); */
|
||||
|
||||
int BIO_sock_should_retry(int i);
|
||||
int BIO_sock_non_fatal_error(int error);
|
||||
int BIO_dgram_non_fatal_error(int error);
|
||||
|
||||
int BIO_fd_should_retry(int i);
|
||||
int BIO_fd_non_fatal_error(int error);
|
||||
int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),
|
||||
void *u, const char *s, int len);
|
||||
int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
|
||||
void *u, const char *s, int len, int indent);
|
||||
int BIO_dump(BIO *b, const char *bytes, int len);
|
||||
int BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
int BIO_dump_fp(FILE *fp, const char *s, int len);
|
||||
int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
|
||||
# endif
|
||||
int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,
|
||||
int datalen);
|
||||
|
||||
struct hostent *BIO_gethostbyname(const char *name);
|
||||
/*-
|
||||
* We might want a thread-safe interface too:
|
||||
* struct hostent *BIO_gethostbyname_r(const char *name,
|
||||
* struct hostent *result, void *buffer, size_t buflen);
|
||||
* or something similar (caller allocates a struct hostent,
|
||||
* pointed to by "result", and additional buffer space for the various
|
||||
* substructures; if the buffer does not suffice, NULL is returned
|
||||
* and an appropriate error code is set).
|
||||
*/
|
||||
int BIO_sock_error(int sock);
|
||||
int BIO_socket_ioctl(int fd, long type, void *arg);
|
||||
int BIO_socket_nbio(int fd, int mode);
|
||||
int BIO_get_port(const char *str, unsigned short *port_ptr);
|
||||
int BIO_get_host_ip(const char *str, unsigned char *ip);
|
||||
int BIO_get_accept_socket(char *host_port, int mode);
|
||||
int BIO_accept(int sock, char **ip_port);
|
||||
int BIO_sock_init(void);
|
||||
void BIO_sock_cleanup(void);
|
||||
int BIO_set_tcp_ndelay(int sock, int turn_on);
|
||||
|
||||
BIO *BIO_new_socket(int sock, int close_flag);
|
||||
BIO *BIO_new_dgram(int fd, int close_flag);
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
BIO *BIO_new_dgram_sctp(int fd, int close_flag);
|
||||
int BIO_dgram_is_sctp(BIO *bio);
|
||||
int BIO_dgram_sctp_notification_cb(BIO *b,
|
||||
void (*handle_notifications) (BIO *bio,
|
||||
void
|
||||
*context,
|
||||
void *buf),
|
||||
void *context);
|
||||
int BIO_dgram_sctp_wait_for_dry(BIO *b);
|
||||
int BIO_dgram_sctp_msg_waiting(BIO *b);
|
||||
# endif
|
||||
BIO *BIO_new_fd(int fd, int close_flag);
|
||||
BIO *BIO_new_connect(const char *host_port);
|
||||
BIO *BIO_new_accept(const char *host_port);
|
||||
|
||||
int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
|
||||
BIO **bio2, size_t writebuf2);
|
||||
/*
|
||||
* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
|
||||
* Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default
|
||||
* value.
|
||||
*/
|
||||
|
||||
void BIO_copy_next_retry(BIO *b);
|
||||
|
||||
/*
|
||||
* long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);
|
||||
*/
|
||||
|
||||
# ifdef __GNUC__
|
||||
# define __bio_h__attr__ __attribute__
|
||||
# else
|
||||
# define __bio_h__attr__(x)
|
||||
# endif
|
||||
int BIO_printf(BIO *bio, const char *format, ...)
|
||||
__bio_h__attr__((__format__(__printf__, 2, 3)));
|
||||
int BIO_vprintf(BIO *bio, const char *format, va_list args)
|
||||
__bio_h__attr__((__format__(__printf__, 2, 0)));
|
||||
int BIO_snprintf(char *buf, size_t n, const char *format, ...)
|
||||
__bio_h__attr__((__format__(__printf__, 3, 4)));
|
||||
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
|
||||
__bio_h__attr__((__format__(__printf__, 3, 0)));
|
||||
# undef __bio_h__attr__
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_BIO_strings(void);
|
||||
|
||||
/* Error codes for the BIO functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define BIO_F_ACPT_STATE 100
|
||||
# define BIO_F_BIO_ACCEPT 101
|
||||
# define BIO_F_BIO_BER_GET_HEADER 102
|
||||
# define BIO_F_BIO_CALLBACK_CTRL 131
|
||||
# define BIO_F_BIO_CTRL 103
|
||||
# define BIO_F_BIO_GETHOSTBYNAME 120
|
||||
# define BIO_F_BIO_GETS 104
|
||||
# define BIO_F_BIO_GET_ACCEPT_SOCKET 105
|
||||
# define BIO_F_BIO_GET_HOST_IP 106
|
||||
# define BIO_F_BIO_GET_PORT 107
|
||||
# define BIO_F_BIO_MAKE_PAIR 121
|
||||
# define BIO_F_BIO_NEW 108
|
||||
# define BIO_F_BIO_NEW_FILE 109
|
||||
# define BIO_F_BIO_NEW_MEM_BUF 126
|
||||
# define BIO_F_BIO_NREAD 123
|
||||
# define BIO_F_BIO_NREAD0 124
|
||||
# define BIO_F_BIO_NWRITE 125
|
||||
# define BIO_F_BIO_NWRITE0 122
|
||||
# define BIO_F_BIO_PUTS 110
|
||||
# define BIO_F_BIO_READ 111
|
||||
# define BIO_F_BIO_SOCK_INIT 112
|
||||
# define BIO_F_BIO_WRITE 113
|
||||
# define BIO_F_BUFFER_CTRL 114
|
||||
# define BIO_F_CONN_CTRL 127
|
||||
# define BIO_F_CONN_STATE 115
|
||||
# define BIO_F_DGRAM_SCTP_READ 132
|
||||
# define BIO_F_DGRAM_SCTP_WRITE 133
|
||||
# define BIO_F_FILE_CTRL 116
|
||||
# define BIO_F_FILE_READ 130
|
||||
# define BIO_F_LINEBUFFER_CTRL 129
|
||||
# define BIO_F_MEM_READ 128
|
||||
# define BIO_F_MEM_WRITE 117
|
||||
# define BIO_F_SSL_NEW 118
|
||||
# define BIO_F_WSASTARTUP 119
|
||||
|
||||
/* Reason codes. */
|
||||
# define BIO_R_ACCEPT_ERROR 100
|
||||
# define BIO_R_BAD_FOPEN_MODE 101
|
||||
# define BIO_R_BAD_HOSTNAME_LOOKUP 102
|
||||
# define BIO_R_BROKEN_PIPE 124
|
||||
# define BIO_R_CONNECT_ERROR 103
|
||||
# define BIO_R_EOF_ON_MEMORY_BIO 127
|
||||
# define BIO_R_ERROR_SETTING_NBIO 104
|
||||
# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105
|
||||
# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106
|
||||
# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107
|
||||
# define BIO_R_INVALID_ARGUMENT 125
|
||||
# define BIO_R_INVALID_IP_ADDRESS 108
|
||||
# define BIO_R_IN_USE 123
|
||||
# define BIO_R_KEEPALIVE 109
|
||||
# define BIO_R_NBIO_CONNECT_ERROR 110
|
||||
# define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111
|
||||
# define BIO_R_NO_HOSTNAME_SPECIFIED 112
|
||||
# define BIO_R_NO_PORT_DEFINED 113
|
||||
# define BIO_R_NO_PORT_SPECIFIED 114
|
||||
# define BIO_R_NO_SUCH_FILE 128
|
||||
# define BIO_R_NULL_PARAMETER 115
|
||||
# define BIO_R_TAG_MISMATCH 116
|
||||
# define BIO_R_UNABLE_TO_BIND_SOCKET 117
|
||||
# define BIO_R_UNABLE_TO_CREATE_SOCKET 118
|
||||
# define BIO_R_UNABLE_TO_LISTEN_SOCKET 119
|
||||
# define BIO_R_UNINITIALIZED 120
|
||||
# define BIO_R_UNSUPPORTED_METHOD 121
|
||||
# define BIO_R_WRITE_TO_READ_ONLY_BIO 126
|
||||
# define BIO_R_WSASTARTUP 122
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
130
sgx-jvm/dependencies/root/usr/include/openssl/blowfish.h
Normal file
130
sgx-jvm/dependencies/root/usr/include/openssl/blowfish.h
Normal file
@ -0,0 +1,130 @@
|
||||
/* crypto/bf/blowfish.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BLOWFISH_H
|
||||
# define HEADER_BLOWFISH_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# ifdef OPENSSL_NO_BF
|
||||
# error BF is disabled.
|
||||
# endif
|
||||
|
||||
# define BF_ENCRYPT 1
|
||||
# define BF_DECRYPT 0
|
||||
|
||||
/*-
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* ! BF_LONG has to be at least 32 bits wide. If it's wider, then !
|
||||
* ! BF_LONG_LOG2 has to be defined along. !
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
|
||||
# if defined(__LP32__)
|
||||
# define BF_LONG unsigned long
|
||||
# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
|
||||
# define BF_LONG unsigned long
|
||||
# define BF_LONG_LOG2 3
|
||||
/*
|
||||
* _CRAY note. I could declare short, but I have no idea what impact
|
||||
* does it have on performance on none-T3E machines. I could declare
|
||||
* int, but at least on C90 sizeof(int) can be chosen at compile time.
|
||||
* So I've chosen long...
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
# else
|
||||
# define BF_LONG unsigned int
|
||||
# endif
|
||||
|
||||
# define BF_ROUNDS 16
|
||||
# define BF_BLOCK 8
|
||||
|
||||
typedef struct bf_key_st {
|
||||
BF_LONG P[BF_ROUNDS + 2];
|
||||
BF_LONG S[4 * 256];
|
||||
} BF_KEY;
|
||||
|
||||
# ifdef OPENSSL_FIPS
|
||||
void private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);
|
||||
# endif
|
||||
void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
|
||||
|
||||
void BF_encrypt(BF_LONG *data, const BF_KEY *key);
|
||||
void BF_decrypt(BF_LONG *data, const BF_KEY *key);
|
||||
|
||||
void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const BF_KEY *key, int enc);
|
||||
void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
|
||||
const BF_KEY *schedule, unsigned char *ivec, int enc);
|
||||
void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const BF_KEY *schedule,
|
||||
unsigned char *ivec, int *num, int enc);
|
||||
void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const BF_KEY *schedule,
|
||||
unsigned char *ivec, int *num);
|
||||
const char *BF_options(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
949
sgx-jvm/dependencies/root/usr/include/openssl/bn.h
Normal file
949
sgx-jvm/dependencies/root/usr/include/openssl/bn.h
Normal file
@ -0,0 +1,949 @@
|
||||
/* crypto/bn/bn.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
* Portions of the attached software ("Contribution") are developed by
|
||||
* SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
|
||||
*
|
||||
* The Contribution is licensed pursuant to the Eric Young open source
|
||||
* license provided above.
|
||||
*
|
||||
* The binary polynomial arithmetic software is originally written by
|
||||
* Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_H
|
||||
# define HEADER_BN_H
|
||||
|
||||
# include <limits.h>
|
||||
# include <openssl/e_os2.h>
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
# include <stdio.h> /* FILE */
|
||||
# endif
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* These preprocessor symbols control various aspects of the bignum headers
|
||||
* and library code. They're not defined by any "normal" configuration, as
|
||||
* they are intended for development and testing purposes. NB: defining all
|
||||
* three can be useful for debugging application code as well as openssl
|
||||
* itself. BN_DEBUG - turn on various debugging alterations to the bignum
|
||||
* code BN_DEBUG_RAND - uses random poisoning of unused words to trip up
|
||||
* mismanagement of bignum internals. You must also define BN_DEBUG.
|
||||
*/
|
||||
/* #define BN_DEBUG */
|
||||
/* #define BN_DEBUG_RAND */
|
||||
|
||||
# ifndef OPENSSL_SMALL_FOOTPRINT
|
||||
# define BN_MUL_COMBA
|
||||
# define BN_SQR_COMBA
|
||||
# define BN_RECURSION
|
||||
# endif
|
||||
|
||||
/*
|
||||
* This next option uses the C libraries (2 word)/(1 word) function. If it is
|
||||
* not defined, I use my C version (which is slower). The reason for this
|
||||
* flag is that when the particular C compiler library routine is used, and
|
||||
* the library is linked with a different compiler, the library is missing.
|
||||
* This mostly happens when the library is built with gcc and then linked
|
||||
* using normal cc. This would be a common occurrence because gcc normally
|
||||
* produces code that is 2 times faster than system compilers for the big
|
||||
* number stuff. For machines with only one compiler (or shared libraries),
|
||||
* this should be on. Again this in only really a problem on machines using
|
||||
* "long long's", are 32bit, and are not using my assembler code.
|
||||
*/
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \
|
||||
defined(OPENSSL_SYS_WIN32) || defined(linux)
|
||||
# ifndef BN_DIV2W
|
||||
# define BN_DIV2W
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/*
|
||||
* assuming long is 64bit - this is the DEC Alpha unsigned long long is only
|
||||
* 64 bits :-(, don't define BN_LLONG for the DEC Alpha
|
||||
*/
|
||||
# ifdef SIXTY_FOUR_BIT_LONG
|
||||
# define BN_ULLONG unsigned long long
|
||||
# define BN_ULONG unsigned long
|
||||
# define BN_LONG long
|
||||
# define BN_BITS 128
|
||||
# define BN_BYTES 8
|
||||
# define BN_BITS2 64
|
||||
# define BN_BITS4 32
|
||||
# define BN_MASK (0xffffffffffffffffffffffffffffffffLL)
|
||||
# define BN_MASK2 (0xffffffffffffffffL)
|
||||
# define BN_MASK2l (0xffffffffL)
|
||||
# define BN_MASK2h (0xffffffff00000000L)
|
||||
# define BN_MASK2h1 (0xffffffff80000000L)
|
||||
# define BN_TBIT (0x8000000000000000L)
|
||||
# define BN_DEC_CONV (10000000000000000000UL)
|
||||
# define BN_DEC_FMT1 "%lu"
|
||||
# define BN_DEC_FMT2 "%019lu"
|
||||
# define BN_DEC_NUM 19
|
||||
# define BN_HEX_FMT1 "%lX"
|
||||
# define BN_HEX_FMT2 "%016lX"
|
||||
# endif
|
||||
|
||||
/*
|
||||
* This is where the long long data type is 64 bits, but long is 32. For
|
||||
* machines where there are 64bit registers, this is the mode to use. IRIX,
|
||||
* on R4000 and above should use this mode, along with the relevant assembler
|
||||
* code :-). Do NOT define BN_LLONG.
|
||||
*/
|
||||
# ifdef SIXTY_FOUR_BIT
|
||||
# undef BN_LLONG
|
||||
# undef BN_ULLONG
|
||||
# define BN_ULONG unsigned long long
|
||||
# define BN_LONG long long
|
||||
# define BN_BITS 128
|
||||
# define BN_BYTES 8
|
||||
# define BN_BITS2 64
|
||||
# define BN_BITS4 32
|
||||
# define BN_MASK2 (0xffffffffffffffffLL)
|
||||
# define BN_MASK2l (0xffffffffL)
|
||||
# define BN_MASK2h (0xffffffff00000000LL)
|
||||
# define BN_MASK2h1 (0xffffffff80000000LL)
|
||||
# define BN_TBIT (0x8000000000000000LL)
|
||||
# define BN_DEC_CONV (10000000000000000000ULL)
|
||||
# define BN_DEC_FMT1 "%llu"
|
||||
# define BN_DEC_FMT2 "%019llu"
|
||||
# define BN_DEC_NUM 19
|
||||
# define BN_HEX_FMT1 "%llX"
|
||||
# define BN_HEX_FMT2 "%016llX"
|
||||
# endif
|
||||
|
||||
# ifdef THIRTY_TWO_BIT
|
||||
# ifdef BN_LLONG
|
||||
# if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define BN_ULLONG unsigned __int64
|
||||
# define BN_MASK (0xffffffffffffffffI64)
|
||||
# else
|
||||
# define BN_ULLONG unsigned long long
|
||||
# define BN_MASK (0xffffffffffffffffLL)
|
||||
# endif
|
||||
# endif
|
||||
# define BN_ULONG unsigned int
|
||||
# define BN_LONG int
|
||||
# define BN_BITS 64
|
||||
# define BN_BYTES 4
|
||||
# define BN_BITS2 32
|
||||
# define BN_BITS4 16
|
||||
# define BN_MASK2 (0xffffffffL)
|
||||
# define BN_MASK2l (0xffff)
|
||||
# define BN_MASK2h1 (0xffff8000L)
|
||||
# define BN_MASK2h (0xffff0000L)
|
||||
# define BN_TBIT (0x80000000L)
|
||||
# define BN_DEC_CONV (1000000000L)
|
||||
# define BN_DEC_FMT1 "%u"
|
||||
# define BN_DEC_FMT2 "%09u"
|
||||
# define BN_DEC_NUM 9
|
||||
# define BN_HEX_FMT1 "%X"
|
||||
# define BN_HEX_FMT2 "%08X"
|
||||
# endif
|
||||
|
||||
# define BN_DEFAULT_BITS 1280
|
||||
|
||||
# define BN_FLG_MALLOCED 0x01
|
||||
# define BN_FLG_STATIC_DATA 0x02
|
||||
|
||||
/*
|
||||
* avoid leaking exponent information through timing,
|
||||
* BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,
|
||||
* BN_div() will call BN_div_no_branch,
|
||||
* BN_mod_inverse() will call BN_mod_inverse_no_branch.
|
||||
*/
|
||||
# define BN_FLG_CONSTTIME 0x04
|
||||
|
||||
# ifdef OPENSSL_NO_DEPRECATED
|
||||
/* deprecated name for the flag */
|
||||
# define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME
|
||||
/*
|
||||
* avoid leaking exponent information through timings
|
||||
* (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime)
|
||||
*/
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
# define BN_FLG_FREE 0x8000
|
||||
/* used for debuging */
|
||||
# endif
|
||||
# define BN_set_flags(b,n) ((b)->flags|=(n))
|
||||
# define BN_get_flags(b,n) ((b)->flags&(n))
|
||||
|
||||
/*
|
||||
* get a clone of a BIGNUM with changed flags, for *temporary* use only (the
|
||||
* two BIGNUMs cannot not be used in parallel!)
|
||||
*/
|
||||
# define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \
|
||||
(dest)->top=(b)->top, \
|
||||
(dest)->dmax=(b)->dmax, \
|
||||
(dest)->neg=(b)->neg, \
|
||||
(dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \
|
||||
| ((b)->flags & ~BN_FLG_MALLOCED) \
|
||||
| BN_FLG_STATIC_DATA \
|
||||
| (n)))
|
||||
|
||||
/* Already declared in ossl_typ.h */
|
||||
# if 0
|
||||
typedef struct bignum_st BIGNUM;
|
||||
/* Used for temp variables (declaration hidden in bn_lcl.h) */
|
||||
typedef struct bignum_ctx BN_CTX;
|
||||
typedef struct bn_blinding_st BN_BLINDING;
|
||||
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
||||
typedef struct bn_recp_ctx_st BN_RECP_CTX;
|
||||
typedef struct bn_gencb_st BN_GENCB;
|
||||
# endif
|
||||
|
||||
struct bignum_st {
|
||||
BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit
|
||||
* chunks. */
|
||||
int top; /* Index of last used d +1. */
|
||||
/* The next are internal book keeping for bn_expand. */
|
||||
int dmax; /* Size of the d array. */
|
||||
int neg; /* one if the number is negative */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for montgomery multiplication */
|
||||
struct bn_mont_ctx_st {
|
||||
int ri; /* number of bits in R */
|
||||
BIGNUM RR; /* used to convert to montgomery form */
|
||||
BIGNUM N; /* The modulus */
|
||||
BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 (Ni is only
|
||||
* stored for bignum algorithm) */
|
||||
BN_ULONG n0[2]; /* least significant word(s) of Ni; (type
|
||||
* changed with 0.9.9, was "BN_ULONG n0;"
|
||||
* before) */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/*
|
||||
* Used for reciprocal division/mod functions It cannot be shared between
|
||||
* threads
|
||||
*/
|
||||
struct bn_recp_ctx_st {
|
||||
BIGNUM N; /* the divisor */
|
||||
BIGNUM Nr; /* the reciprocal */
|
||||
int num_bits;
|
||||
int shift;
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for slow "generation" functions. */
|
||||
struct bn_gencb_st {
|
||||
unsigned int ver; /* To handle binary (in)compatibility */
|
||||
void *arg; /* callback-specific data */
|
||||
union {
|
||||
/* if(ver==1) - handles old style callbacks */
|
||||
void (*cb_1) (int, int, void *);
|
||||
/* if(ver==2) - new callback style */
|
||||
int (*cb_2) (int, int, BN_GENCB *);
|
||||
} cb;
|
||||
};
|
||||
/* Wrapper function to make using BN_GENCB easier, */
|
||||
int BN_GENCB_call(BN_GENCB *cb, int a, int b);
|
||||
/* Macro to populate a BN_GENCB structure with an "old"-style callback */
|
||||
# define BN_GENCB_set_old(gencb, callback, cb_arg) { \
|
||||
BN_GENCB *tmp_gencb = (gencb); \
|
||||
tmp_gencb->ver = 1; \
|
||||
tmp_gencb->arg = (cb_arg); \
|
||||
tmp_gencb->cb.cb_1 = (callback); }
|
||||
/* Macro to populate a BN_GENCB structure with a "new"-style callback */
|
||||
# define BN_GENCB_set(gencb, callback, cb_arg) { \
|
||||
BN_GENCB *tmp_gencb = (gencb); \
|
||||
tmp_gencb->ver = 2; \
|
||||
tmp_gencb->arg = (cb_arg); \
|
||||
tmp_gencb->cb.cb_2 = (callback); }
|
||||
|
||||
# define BN_prime_checks 0 /* default: select number of iterations based
|
||||
* on the size of the number */
|
||||
|
||||
/*
|
||||
* number of Miller-Rabin iterations for an error rate of less than 2^-80 for
|
||||
* random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook of
|
||||
* Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
|
||||
* original paper: Damgaard, Landrock, Pomerance: Average case error
|
||||
* estimates for the strong probable prime test. -- Math. Comp. 61 (1993)
|
||||
* 177-194)
|
||||
*/
|
||||
# define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
|
||||
(b) >= 850 ? 3 : \
|
||||
(b) >= 650 ? 4 : \
|
||||
(b) >= 550 ? 5 : \
|
||||
(b) >= 450 ? 6 : \
|
||||
(b) >= 400 ? 7 : \
|
||||
(b) >= 350 ? 8 : \
|
||||
(b) >= 300 ? 9 : \
|
||||
(b) >= 250 ? 12 : \
|
||||
(b) >= 200 ? 15 : \
|
||||
(b) >= 150 ? 18 : \
|
||||
/* b >= 100 */ 27)
|
||||
|
||||
# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
||||
|
||||
/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */
|
||||
# define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \
|
||||
(((w) == 0) && ((a)->top == 0)))
|
||||
# define BN_is_zero(a) ((a)->top == 0)
|
||||
# define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg)
|
||||
# define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))
|
||||
# define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1))
|
||||
|
||||
# define BN_one(a) (BN_set_word((a),1))
|
||||
# define BN_zero_ex(a) \
|
||||
do { \
|
||||
BIGNUM *_tmp_bn = (a); \
|
||||
_tmp_bn->top = 0; \
|
||||
_tmp_bn->neg = 0; \
|
||||
} while(0)
|
||||
# ifdef OPENSSL_NO_DEPRECATED
|
||||
# define BN_zero(a) BN_zero_ex(a)
|
||||
# else
|
||||
# define BN_zero(a) (BN_set_word((a),0))
|
||||
# endif
|
||||
|
||||
const BIGNUM *BN_value_one(void);
|
||||
char *BN_options(void);
|
||||
BN_CTX *BN_CTX_new(void);
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
void BN_CTX_init(BN_CTX *c);
|
||||
# endif
|
||||
void BN_CTX_free(BN_CTX *c);
|
||||
void BN_CTX_start(BN_CTX *ctx);
|
||||
BIGNUM *BN_CTX_get(BN_CTX *ctx);
|
||||
void BN_CTX_end(BN_CTX *ctx);
|
||||
int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||
int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||
int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||
int BN_num_bits(const BIGNUM *a);
|
||||
int BN_num_bits_word(BN_ULONG);
|
||||
BIGNUM *BN_new(void);
|
||||
void BN_init(BIGNUM *);
|
||||
void BN_clear_free(BIGNUM *a);
|
||||
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
|
||||
void BN_swap(BIGNUM *a, BIGNUM *b);
|
||||
BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
int BN_bn2bin(const BIGNUM *a, unsigned char *to);
|
||||
BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
|
||||
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
|
||||
/** BN_set_negative sets sign of a BIGNUM
|
||||
* \param b pointer to the BIGNUM object
|
||||
* \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise
|
||||
*/
|
||||
void BN_set_negative(BIGNUM *b, int n);
|
||||
/** BN_is_negative returns 1 if the BIGNUM is negative
|
||||
* \param a pointer to the BIGNUM object
|
||||
* \return 1 if a < 0 and 0 otherwise
|
||||
*/
|
||||
# define BN_is_negative(a) ((a)->neg != 0)
|
||||
|
||||
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
|
||||
BN_CTX *ctx);
|
||||
# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))
|
||||
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
|
||||
int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
BN_CTX *ctx);
|
||||
int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m);
|
||||
int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
BN_CTX *ctx);
|
||||
int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m);
|
||||
int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
BN_CTX *ctx);
|
||||
int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
|
||||
int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,
|
||||
BN_CTX *ctx);
|
||||
int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
|
||||
|
||||
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_mul_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_add_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_sub_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_set_word(BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_get_word(const BIGNUM *a);
|
||||
|
||||
int BN_cmp(const BIGNUM *a, const BIGNUM *b);
|
||||
void BN_free(BIGNUM *a);
|
||||
int BN_is_bit_set(const BIGNUM *a, int n);
|
||||
int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_lshift1(BIGNUM *r, const BIGNUM *a);
|
||||
int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx,
|
||||
BN_MONT_CTX *in_mont);
|
||||
int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
|
||||
const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,
|
||||
BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
|
||||
int BN_mask_bits(BIGNUM *a, int n);
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
int BN_print_fp(FILE *fp, const BIGNUM *a);
|
||||
# endif
|
||||
# ifdef HEADER_BIO_H
|
||||
int BN_print(BIO *fp, const BIGNUM *a);
|
||||
# else
|
||||
int BN_print(void *fp, const BIGNUM *a);
|
||||
# endif
|
||||
int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
|
||||
int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_rshift1(BIGNUM *r, const BIGNUM *a);
|
||||
void BN_clear(BIGNUM *a);
|
||||
BIGNUM *BN_dup(const BIGNUM *a);
|
||||
int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_set_bit(BIGNUM *a, int n);
|
||||
int BN_clear_bit(BIGNUM *a, int n);
|
||||
char *BN_bn2hex(const BIGNUM *a);
|
||||
char *BN_bn2dec(const BIGNUM *a);
|
||||
int BN_hex2bn(BIGNUM **a, const char *str);
|
||||
int BN_dec2bn(BIGNUM **a, const char *str);
|
||||
int BN_asc2bn(BIGNUM **a, const char *str);
|
||||
int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns
|
||||
* -2 for
|
||||
* error */
|
||||
BIGNUM *BN_mod_inverse(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);
|
||||
BIGNUM *BN_mod_sqrt(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);
|
||||
|
||||
void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);
|
||||
|
||||
/* Deprecated versions */
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
|
||||
const BIGNUM *add, const BIGNUM *rem,
|
||||
void (*callback) (int, int, void *), void *cb_arg);
|
||||
int BN_is_prime(const BIGNUM *p, int nchecks,
|
||||
void (*callback) (int, int, void *),
|
||||
BN_CTX *ctx, void *cb_arg);
|
||||
int BN_is_prime_fasttest(const BIGNUM *p, int nchecks,
|
||||
void (*callback) (int, int, void *), BN_CTX *ctx,
|
||||
void *cb_arg, int do_trial_division);
|
||||
# endif /* !defined(OPENSSL_NO_DEPRECATED) */
|
||||
|
||||
/* Newer versions */
|
||||
int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
|
||||
const BIGNUM *rem, BN_GENCB *cb);
|
||||
int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);
|
||||
int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,
|
||||
int do_trial_division, BN_GENCB *cb);
|
||||
|
||||
int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
|
||||
|
||||
int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
|
||||
const BIGNUM *Xp, const BIGNUM *Xp1,
|
||||
const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,
|
||||
BN_GENCB *cb);
|
||||
int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,
|
||||
BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e,
|
||||
BN_CTX *ctx, BN_GENCB *cb);
|
||||
|
||||
BN_MONT_CTX *BN_MONT_CTX_new(void);
|
||||
void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
|
||||
int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
# define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
|
||||
(r),(a),&((mont)->RR),(mont),(ctx))
|
||||
int BN_from_montgomery(BIGNUM *r, const BIGNUM *a,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
void BN_MONT_CTX_free(BN_MONT_CTX *mont);
|
||||
int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);
|
||||
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
|
||||
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
|
||||
const BIGNUM *mod, BN_CTX *ctx);
|
||||
|
||||
/* BN_BLINDING flags */
|
||||
# define BN_BLINDING_NO_UPDATE 0x00000001
|
||||
# define BN_BLINDING_NO_RECREATE 0x00000002
|
||||
|
||||
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
|
||||
void BN_BLINDING_free(BN_BLINDING *b);
|
||||
int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
|
||||
int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,
|
||||
BN_CTX *);
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
|
||||
void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
|
||||
# endif
|
||||
CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
|
||||
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
|
||||
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
|
||||
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
|
||||
const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
|
||||
int (*bn_mod_exp) (BIGNUM *r,
|
||||
const BIGNUM *a,
|
||||
const BIGNUM *p,
|
||||
const BIGNUM *m,
|
||||
BN_CTX *ctx,
|
||||
BN_MONT_CTX *m_ctx),
|
||||
BN_MONT_CTX *m_ctx);
|
||||
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
void BN_set_params(int mul, int high, int low, int mont);
|
||||
int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */
|
||||
# endif
|
||||
|
||||
void BN_RECP_CTX_init(BN_RECP_CTX *recp);
|
||||
BN_RECP_CTX *BN_RECP_CTX_new(void);
|
||||
void BN_RECP_CTX_free(BN_RECP_CTX *recp);
|
||||
int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);
|
||||
int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||
int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||
|
||||
# ifndef OPENSSL_NO_EC2M
|
||||
|
||||
/*
|
||||
* Functions for arithmetic over binary polynomials represented by BIGNUMs.
|
||||
* The BIGNUM::neg property of BIGNUMs representing binary polynomials is
|
||||
* ignored. Note that input arguments are not const so that their bit arrays
|
||||
* can be expanded to the appropriate size if needed.
|
||||
*/
|
||||
|
||||
/*
|
||||
* r = a + b
|
||||
*/
|
||||
int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
# define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)
|
||||
/*
|
||||
* r=a mod p
|
||||
*/
|
||||
int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);
|
||||
/* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx);
|
||||
/* r^2 + r = a mod p */
|
||||
int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx);
|
||||
# define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))
|
||||
/*-
|
||||
* Some functions allow for representation of the irreducible polynomials
|
||||
* as an unsigned int[], say p. The irreducible f(t) is then of the form:
|
||||
* t^p[0] + t^p[1] + ... + t^p[k]
|
||||
* where m = p[0] > p[1] > ... > p[k] = 0.
|
||||
*/
|
||||
/* r = a mod p */
|
||||
int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);
|
||||
/* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx);
|
||||
/* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
|
||||
BN_CTX *ctx);
|
||||
/* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],
|
||||
BN_CTX *ctx);
|
||||
/* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx);
|
||||
/* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx);
|
||||
/* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const int p[], BN_CTX *ctx);
|
||||
/* r^2 + r = a mod p */
|
||||
int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const int p[], BN_CTX *ctx);
|
||||
int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
|
||||
int BN_GF2m_arr2poly(const int p[], BIGNUM *a);
|
||||
|
||||
# endif
|
||||
|
||||
/*
|
||||
* faster mod functions for the 'NIST primes' 0 <= a < p^2
|
||||
*/
|
||||
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
const BIGNUM *BN_get0_nist_prime_192(void);
|
||||
const BIGNUM *BN_get0_nist_prime_224(void);
|
||||
const BIGNUM *BN_get0_nist_prime_256(void);
|
||||
const BIGNUM *BN_get0_nist_prime_384(void);
|
||||
const BIGNUM *BN_get0_nist_prime_521(void);
|
||||
|
||||
/* library internal functions */
|
||||
|
||||
# define bn_expand(a,bits) \
|
||||
( \
|
||||
bits > (INT_MAX - BN_BITS2 + 1) ? \
|
||||
NULL \
|
||||
: \
|
||||
(((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax) ? \
|
||||
(a) \
|
||||
: \
|
||||
bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2) \
|
||||
)
|
||||
|
||||
# define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
|
||||
BIGNUM *bn_expand2(BIGNUM *a, int words);
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
|
||||
# endif
|
||||
|
||||
/*-
|
||||
* Bignum consistency macros
|
||||
* There is one "API" macro, bn_fix_top(), for stripping leading zeroes from
|
||||
* bignum data after direct manipulations on the data. There is also an
|
||||
* "internal" macro, bn_check_top(), for verifying that there are no leading
|
||||
* zeroes. Unfortunately, some auditing is required due to the fact that
|
||||
* bn_fix_top() has become an overabused duct-tape because bignum data is
|
||||
* occasionally passed around in an inconsistent state. So the following
|
||||
* changes have been made to sort this out;
|
||||
* - bn_fix_top()s implementation has been moved to bn_correct_top()
|
||||
* - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and
|
||||
* bn_check_top() is as before.
|
||||
* - if BN_DEBUG *is* defined;
|
||||
* - bn_check_top() tries to pollute unused words even if the bignum 'top' is
|
||||
* consistent. (ed: only if BN_DEBUG_RAND is defined)
|
||||
* - bn_fix_top() maps to bn_check_top() rather than "fixing" anything.
|
||||
* The idea is to have debug builds flag up inconsistent bignums when they
|
||||
* occur. If that occurs in a bn_fix_top(), we examine the code in question; if
|
||||
* the use of bn_fix_top() was appropriate (ie. it follows directly after code
|
||||
* that manipulates the bignum) it is converted to bn_correct_top(), and if it
|
||||
* was not appropriate, we convert it permanently to bn_check_top() and track
|
||||
* down the cause of the bug. Eventually, no internal code should be using the
|
||||
* bn_fix_top() macro. External applications and libraries should try this with
|
||||
* their own code too, both in terms of building against the openssl headers
|
||||
* with BN_DEBUG defined *and* linking with a version of OpenSSL built with it
|
||||
* defined. This not only improves external code, it provides more test
|
||||
* coverage for openssl's own code.
|
||||
*/
|
||||
|
||||
# ifdef BN_DEBUG
|
||||
|
||||
/* We only need assert() when debugging */
|
||||
# include <assert.h>
|
||||
|
||||
# ifdef BN_DEBUG_RAND
|
||||
/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */
|
||||
# ifndef RAND_pseudo_bytes
|
||||
int RAND_pseudo_bytes(unsigned char *buf, int num);
|
||||
# define BN_DEBUG_TRIX
|
||||
# endif
|
||||
# define bn_pollute(a) \
|
||||
do { \
|
||||
const BIGNUM *_bnum1 = (a); \
|
||||
if(_bnum1->top < _bnum1->dmax) { \
|
||||
unsigned char _tmp_char; \
|
||||
/* We cast away const without the compiler knowing, any \
|
||||
* *genuinely* constant variables that aren't mutable \
|
||||
* wouldn't be constructed with top!=dmax. */ \
|
||||
BN_ULONG *_not_const; \
|
||||
memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \
|
||||
/* Debug only - safe to ignore error return */ \
|
||||
RAND_pseudo_bytes(&_tmp_char, 1); \
|
||||
memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \
|
||||
(_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \
|
||||
} \
|
||||
} while(0)
|
||||
# ifdef BN_DEBUG_TRIX
|
||||
# undef RAND_pseudo_bytes
|
||||
# endif
|
||||
# else
|
||||
# define bn_pollute(a)
|
||||
# endif
|
||||
# define bn_check_top(a) \
|
||||
do { \
|
||||
const BIGNUM *_bnum2 = (a); \
|
||||
if (_bnum2 != NULL) { \
|
||||
assert((_bnum2->top == 0) || \
|
||||
(_bnum2->d[_bnum2->top - 1] != 0)); \
|
||||
bn_pollute(_bnum2); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
# define bn_fix_top(a) bn_check_top(a)
|
||||
|
||||
# define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)
|
||||
# define bn_wcheck_size(bn, words) \
|
||||
do { \
|
||||
const BIGNUM *_bnum2 = (bn); \
|
||||
assert((words) <= (_bnum2)->dmax && (words) >= (_bnum2)->top); \
|
||||
/* avoid unused variable warning with NDEBUG */ \
|
||||
(void)(_bnum2); \
|
||||
} while(0)
|
||||
|
||||
# else /* !BN_DEBUG */
|
||||
|
||||
# define bn_pollute(a)
|
||||
# define bn_check_top(a)
|
||||
# define bn_fix_top(a) bn_correct_top(a)
|
||||
# define bn_check_size(bn, bits)
|
||||
# define bn_wcheck_size(bn, words)
|
||||
|
||||
# endif
|
||||
|
||||
# define bn_correct_top(a) \
|
||||
{ \
|
||||
BN_ULONG *ftl; \
|
||||
int tmp_top = (a)->top; \
|
||||
if (tmp_top > 0) \
|
||||
{ \
|
||||
for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \
|
||||
if (*(ftl--)) break; \
|
||||
(a)->top = tmp_top; \
|
||||
} \
|
||||
bn_pollute(a); \
|
||||
}
|
||||
|
||||
BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,
|
||||
BN_ULONG w);
|
||||
BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
|
||||
void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
|
||||
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
|
||||
BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
|
||||
int num);
|
||||
BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
|
||||
int num);
|
||||
|
||||
/* Primes from RFC 2409 */
|
||||
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
|
||||
BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);
|
||||
|
||||
/* Primes from RFC 3526 */
|
||||
BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
|
||||
|
||||
int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_BN_strings(void);
|
||||
|
||||
/* Error codes for the BN functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define BN_F_BNRAND 127
|
||||
# define BN_F_BN_BLINDING_CONVERT_EX 100
|
||||
# define BN_F_BN_BLINDING_CREATE_PARAM 128
|
||||
# define BN_F_BN_BLINDING_INVERT_EX 101
|
||||
# define BN_F_BN_BLINDING_NEW 102
|
||||
# define BN_F_BN_BLINDING_UPDATE 103
|
||||
# define BN_F_BN_BN2DEC 104
|
||||
# define BN_F_BN_BN2HEX 105
|
||||
# define BN_F_BN_CTX_GET 116
|
||||
# define BN_F_BN_CTX_NEW 106
|
||||
# define BN_F_BN_CTX_START 129
|
||||
# define BN_F_BN_DIV 107
|
||||
# define BN_F_BN_DIV_NO_BRANCH 138
|
||||
# define BN_F_BN_DIV_RECP 130
|
||||
# define BN_F_BN_EXP 123
|
||||
# define BN_F_BN_EXPAND2 108
|
||||
# define BN_F_BN_EXPAND_INTERNAL 120
|
||||
# define BN_F_BN_GF2M_MOD 131
|
||||
# define BN_F_BN_GF2M_MOD_EXP 132
|
||||
# define BN_F_BN_GF2M_MOD_MUL 133
|
||||
# define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134
|
||||
# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135
|
||||
# define BN_F_BN_GF2M_MOD_SQR 136
|
||||
# define BN_F_BN_GF2M_MOD_SQRT 137
|
||||
# define BN_F_BN_LSHIFT 145
|
||||
# define BN_F_BN_MOD_EXP2_MONT 118
|
||||
# define BN_F_BN_MOD_EXP_MONT 109
|
||||
# define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124
|
||||
# define BN_F_BN_MOD_EXP_MONT_WORD 117
|
||||
# define BN_F_BN_MOD_EXP_RECP 125
|
||||
# define BN_F_BN_MOD_EXP_SIMPLE 126
|
||||
# define BN_F_BN_MOD_INVERSE 110
|
||||
# define BN_F_BN_MOD_INVERSE_NO_BRANCH 139
|
||||
# define BN_F_BN_MOD_LSHIFT_QUICK 119
|
||||
# define BN_F_BN_MOD_MUL_RECIPROCAL 111
|
||||
# define BN_F_BN_MOD_SQRT 121
|
||||
# define BN_F_BN_MPI2BN 112
|
||||
# define BN_F_BN_NEW 113
|
||||
# define BN_F_BN_RAND 114
|
||||
# define BN_F_BN_RAND_RANGE 122
|
||||
# define BN_F_BN_RSHIFT 146
|
||||
# define BN_F_BN_USUB 115
|
||||
|
||||
/* Reason codes. */
|
||||
# define BN_R_ARG2_LT_ARG3 100
|
||||
# define BN_R_BAD_RECIPROCAL 101
|
||||
# define BN_R_BIGNUM_TOO_LONG 114
|
||||
# define BN_R_BITS_TOO_SMALL 118
|
||||
# define BN_R_CALLED_WITH_EVEN_MODULUS 102
|
||||
# define BN_R_DIV_BY_ZERO 103
|
||||
# define BN_R_ENCODING_ERROR 104
|
||||
# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
|
||||
# define BN_R_INPUT_NOT_REDUCED 110
|
||||
# define BN_R_INVALID_LENGTH 106
|
||||
# define BN_R_INVALID_RANGE 115
|
||||
# define BN_R_INVALID_SHIFT 119
|
||||
# define BN_R_NOT_A_SQUARE 111
|
||||
# define BN_R_NOT_INITIALIZED 107
|
||||
# define BN_R_NO_INVERSE 108
|
||||
# define BN_R_NO_SOLUTION 116
|
||||
# define BN_R_P_IS_NOT_PRIME 112
|
||||
# define BN_R_TOO_MANY_ITERATIONS 113
|
||||
# define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
125
sgx-jvm/dependencies/root/usr/include/openssl/buffer.h
Normal file
125
sgx-jvm/dependencies/root/usr/include/openssl/buffer.h
Normal file
@ -0,0 +1,125 @@
|
||||
/* crypto/buffer/buffer.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BUFFER_H
|
||||
# define HEADER_BUFFER_H
|
||||
|
||||
# include <openssl/ossl_typ.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
# if !defined(NO_SYS_TYPES_H)
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
|
||||
/* Already declared in ossl_typ.h */
|
||||
/* typedef struct buf_mem_st BUF_MEM; */
|
||||
|
||||
struct buf_mem_st {
|
||||
size_t length; /* current number of bytes */
|
||||
char *data;
|
||||
size_t max; /* size of buffer */
|
||||
};
|
||||
|
||||
BUF_MEM *BUF_MEM_new(void);
|
||||
void BUF_MEM_free(BUF_MEM *a);
|
||||
int BUF_MEM_grow(BUF_MEM *str, size_t len);
|
||||
int BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
|
||||
size_t BUF_strnlen(const char *str, size_t maxlen);
|
||||
char *BUF_strdup(const char *str);
|
||||
|
||||
/*
|
||||
* Like strndup, but in addition, explicitly guarantees to never read past the
|
||||
* first |siz| bytes of |str|.
|
||||
*/
|
||||
char *BUF_strndup(const char *str, size_t siz);
|
||||
|
||||
void *BUF_memdup(const void *data, size_t siz);
|
||||
void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);
|
||||
|
||||
/* safe string functions */
|
||||
size_t BUF_strlcpy(char *dst, const char *src, size_t siz);
|
||||
size_t BUF_strlcat(char *dst, const char *src, size_t siz);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_BUF_strings(void);
|
||||
|
||||
/* Error codes for the BUF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define BUF_F_BUF_MEMDUP 103
|
||||
# define BUF_F_BUF_MEM_GROW 100
|
||||
# define BUF_F_BUF_MEM_GROW_CLEAN 105
|
||||
# define BUF_F_BUF_MEM_NEW 101
|
||||
# define BUF_F_BUF_STRDUP 102
|
||||
# define BUF_F_BUF_STRNDUP 104
|
||||
|
||||
/* Reason codes. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
132
sgx-jvm/dependencies/root/usr/include/openssl/camellia.h
Normal file
132
sgx-jvm/dependencies/root/usr/include/openssl/camellia.h
Normal file
@ -0,0 +1,132 @@
|
||||
/* crypto/camellia/camellia.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CAMELLIA_H
|
||||
# define HEADER_CAMELLIA_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifdef OPENSSL_NO_CAMELLIA
|
||||
# error CAMELLIA is disabled.
|
||||
# endif
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
# define CAMELLIA_ENCRYPT 1
|
||||
# define CAMELLIA_DECRYPT 0
|
||||
|
||||
/*
|
||||
* Because array size can't be a const in C, the following two are macros.
|
||||
* Both sizes are in bytes.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This should be a hidden type, but EVP requires that the size be known */
|
||||
|
||||
# define CAMELLIA_BLOCK_SIZE 16
|
||||
# define CAMELLIA_TABLE_BYTE_LEN 272
|
||||
# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
|
||||
|
||||
typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match
|
||||
* with WORD */
|
||||
|
||||
struct camellia_key_st {
|
||||
union {
|
||||
double d; /* ensures 64-bit align */
|
||||
KEY_TABLE_TYPE rd_key;
|
||||
} u;
|
||||
int grand_rounds;
|
||||
};
|
||||
typedef struct camellia_key_st CAMELLIA_KEY;
|
||||
|
||||
# ifdef OPENSSL_FIPS
|
||||
int private_Camellia_set_key(const unsigned char *userKey, const int bits,
|
||||
CAMELLIA_KEY *key);
|
||||
# endif
|
||||
int Camellia_set_key(const unsigned char *userKey, const int bits,
|
||||
CAMELLIA_KEY *key);
|
||||
|
||||
void Camellia_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key);
|
||||
void Camellia_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key);
|
||||
|
||||
void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key, const int enc);
|
||||
void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num);
|
||||
void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char ivec[CAMELLIA_BLOCK_SIZE],
|
||||
unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],
|
||||
unsigned int *num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !HEADER_Camellia_H */
|
107
sgx-jvm/dependencies/root/usr/include/openssl/cast.h
Normal file
107
sgx-jvm/dependencies/root/usr/include/openssl/cast.h
Normal file
@ -0,0 +1,107 @@
|
||||
/* crypto/cast/cast.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CAST_H
|
||||
# define HEADER_CAST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifdef OPENSSL_NO_CAST
|
||||
# error CAST is disabled.
|
||||
# endif
|
||||
|
||||
# define CAST_ENCRYPT 1
|
||||
# define CAST_DECRYPT 0
|
||||
|
||||
# define CAST_LONG unsigned int
|
||||
|
||||
# define CAST_BLOCK 8
|
||||
# define CAST_KEY_LENGTH 16
|
||||
|
||||
typedef struct cast_key_st {
|
||||
CAST_LONG data[32];
|
||||
int short_key; /* Use reduced rounds for short key */
|
||||
} CAST_KEY;
|
||||
|
||||
# ifdef OPENSSL_FIPS
|
||||
void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
|
||||
# endif
|
||||
void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
|
||||
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAST_KEY *key, int enc);
|
||||
void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);
|
||||
void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);
|
||||
void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const CAST_KEY *ks, unsigned char *iv,
|
||||
int enc);
|
||||
void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const CAST_KEY *schedule,
|
||||
unsigned char *ivec, int *num, int enc);
|
||||
void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const CAST_KEY *schedule,
|
||||
unsigned char *ivec, int *num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
82
sgx-jvm/dependencies/root/usr/include/openssl/cmac.h
Normal file
82
sgx-jvm/dependencies/root/usr/include/openssl/cmac.h
Normal file
@ -0,0 +1,82 @@
|
||||
/* crypto/cmac/cmac.h */
|
||||
/*
|
||||
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2010 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CMAC_H
|
||||
# define HEADER_CMAC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# include <openssl/evp.h>
|
||||
|
||||
/* Opaque */
|
||||
typedef struct CMAC_CTX_st CMAC_CTX;
|
||||
|
||||
CMAC_CTX *CMAC_CTX_new(void);
|
||||
void CMAC_CTX_cleanup(CMAC_CTX *ctx);
|
||||
void CMAC_CTX_free(CMAC_CTX *ctx);
|
||||
EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);
|
||||
int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);
|
||||
|
||||
int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
|
||||
const EVP_CIPHER *cipher, ENGINE *impl);
|
||||
int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);
|
||||
int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);
|
||||
int CMAC_resume(CMAC_CTX *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
555
sgx-jvm/dependencies/root/usr/include/openssl/cms.h
Normal file
555
sgx-jvm/dependencies/root/usr/include/openssl/cms.h
Normal file
@ -0,0 +1,555 @@
|
||||
/* crypto/cms/cms.h */
|
||||
/*
|
||||
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2008 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CMS_H
|
||||
# define HEADER_CMS_H
|
||||
|
||||
# include <openssl/x509.h>
|
||||
|
||||
# ifdef OPENSSL_NO_CMS
|
||||
# error CMS is disabled.
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct CMS_ContentInfo_st CMS_ContentInfo;
|
||||
typedef struct CMS_SignerInfo_st CMS_SignerInfo;
|
||||
typedef struct CMS_CertificateChoices CMS_CertificateChoices;
|
||||
typedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;
|
||||
typedef struct CMS_RecipientInfo_st CMS_RecipientInfo;
|
||||
typedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;
|
||||
typedef struct CMS_Receipt_st CMS_Receipt;
|
||||
typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;
|
||||
typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;
|
||||
|
||||
DECLARE_STACK_OF(CMS_SignerInfo)
|
||||
DECLARE_STACK_OF(GENERAL_NAMES)
|
||||
DECLARE_STACK_OF(CMS_RecipientEncryptedKey)
|
||||
DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
|
||||
DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)
|
||||
DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
|
||||
|
||||
# define CMS_SIGNERINFO_ISSUER_SERIAL 0
|
||||
# define CMS_SIGNERINFO_KEYIDENTIFIER 1
|
||||
|
||||
# define CMS_RECIPINFO_NONE -1
|
||||
# define CMS_RECIPINFO_TRANS 0
|
||||
# define CMS_RECIPINFO_AGREE 1
|
||||
# define CMS_RECIPINFO_KEK 2
|
||||
# define CMS_RECIPINFO_PASS 3
|
||||
# define CMS_RECIPINFO_OTHER 4
|
||||
|
||||
/* S/MIME related flags */
|
||||
|
||||
# define CMS_TEXT 0x1
|
||||
# define CMS_NOCERTS 0x2
|
||||
# define CMS_NO_CONTENT_VERIFY 0x4
|
||||
# define CMS_NO_ATTR_VERIFY 0x8
|
||||
# define CMS_NOSIGS \
|
||||
(CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)
|
||||
# define CMS_NOINTERN 0x10
|
||||
# define CMS_NO_SIGNER_CERT_VERIFY 0x20
|
||||
# define CMS_NOVERIFY 0x20
|
||||
# define CMS_DETACHED 0x40
|
||||
# define CMS_BINARY 0x80
|
||||
# define CMS_NOATTR 0x100
|
||||
# define CMS_NOSMIMECAP 0x200
|
||||
# define CMS_NOOLDMIMETYPE 0x400
|
||||
# define CMS_CRLFEOL 0x800
|
||||
# define CMS_STREAM 0x1000
|
||||
# define CMS_NOCRL 0x2000
|
||||
# define CMS_PARTIAL 0x4000
|
||||
# define CMS_REUSE_DIGEST 0x8000
|
||||
# define CMS_USE_KEYID 0x10000
|
||||
# define CMS_DEBUG_DECRYPT 0x20000
|
||||
# define CMS_KEY_PARAM 0x40000
|
||||
|
||||
const ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms);
|
||||
|
||||
BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);
|
||||
int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);
|
||||
|
||||
ASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);
|
||||
int CMS_is_detached(CMS_ContentInfo *cms);
|
||||
int CMS_set_detached(CMS_ContentInfo *cms, int detached);
|
||||
|
||||
# ifdef HEADER_PEM_H
|
||||
DECLARE_PEM_rw_const(CMS, CMS_ContentInfo)
|
||||
# endif
|
||||
int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);
|
||||
CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);
|
||||
int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);
|
||||
|
||||
BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);
|
||||
int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);
|
||||
int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,
|
||||
int flags);
|
||||
CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);
|
||||
int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);
|
||||
|
||||
int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,
|
||||
unsigned int flags);
|
||||
|
||||
CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,
|
||||
STACK_OF(X509) *certs, BIO *data,
|
||||
unsigned int flags);
|
||||
|
||||
CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
|
||||
X509 *signcert, EVP_PKEY *pkey,
|
||||
STACK_OF(X509) *certs, unsigned int flags);
|
||||
|
||||
int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);
|
||||
CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);
|
||||
|
||||
int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
|
||||
unsigned int flags);
|
||||
CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,
|
||||
unsigned int flags);
|
||||
|
||||
int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,
|
||||
const unsigned char *key, size_t keylen,
|
||||
BIO *dcont, BIO *out, unsigned int flags);
|
||||
|
||||
CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,
|
||||
const unsigned char *key,
|
||||
size_t keylen, unsigned int flags);
|
||||
|
||||
int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,
|
||||
const unsigned char *key, size_t keylen);
|
||||
|
||||
int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
|
||||
X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);
|
||||
|
||||
int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,
|
||||
STACK_OF(X509) *certs,
|
||||
X509_STORE *store, unsigned int flags);
|
||||
|
||||
STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
|
||||
|
||||
CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,
|
||||
const EVP_CIPHER *cipher, unsigned int flags);
|
||||
|
||||
int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,
|
||||
BIO *dcont, BIO *out, unsigned int flags);
|
||||
|
||||
int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);
|
||||
int CMS_decrypt_set1_key(CMS_ContentInfo *cms,
|
||||
unsigned char *key, size_t keylen,
|
||||
unsigned char *id, size_t idlen);
|
||||
int CMS_decrypt_set1_password(CMS_ContentInfo *cms,
|
||||
unsigned char *pass, ossl_ssize_t passlen);
|
||||
|
||||
STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);
|
||||
int CMS_RecipientInfo_type(CMS_RecipientInfo *ri);
|
||||
EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);
|
||||
CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);
|
||||
CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,
|
||||
X509 *recip, unsigned int flags);
|
||||
int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);
|
||||
int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);
|
||||
int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,
|
||||
EVP_PKEY **pk, X509 **recip,
|
||||
X509_ALGOR **palg);
|
||||
int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,
|
||||
ASN1_OCTET_STRING **keyid,
|
||||
X509_NAME **issuer,
|
||||
ASN1_INTEGER **sno);
|
||||
|
||||
CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,
|
||||
unsigned char *key, size_t keylen,
|
||||
unsigned char *id, size_t idlen,
|
||||
ASN1_GENERALIZEDTIME *date,
|
||||
ASN1_OBJECT *otherTypeId,
|
||||
ASN1_TYPE *otherType);
|
||||
|
||||
int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,
|
||||
X509_ALGOR **palg,
|
||||
ASN1_OCTET_STRING **pid,
|
||||
ASN1_GENERALIZEDTIME **pdate,
|
||||
ASN1_OBJECT **potherid,
|
||||
ASN1_TYPE **pothertype);
|
||||
|
||||
int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,
|
||||
unsigned char *key, size_t keylen);
|
||||
|
||||
int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,
|
||||
const unsigned char *id, size_t idlen);
|
||||
|
||||
int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,
|
||||
unsigned char *pass,
|
||||
ossl_ssize_t passlen);
|
||||
|
||||
CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
|
||||
int iter, int wrap_nid,
|
||||
int pbe_nid,
|
||||
unsigned char *pass,
|
||||
ossl_ssize_t passlen,
|
||||
const EVP_CIPHER *kekciph);
|
||||
|
||||
int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
|
||||
int CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
|
||||
|
||||
int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
|
||||
unsigned int flags);
|
||||
CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);
|
||||
|
||||
int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);
|
||||
const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);
|
||||
|
||||
CMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);
|
||||
int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);
|
||||
int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);
|
||||
STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);
|
||||
|
||||
CMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);
|
||||
int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);
|
||||
int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);
|
||||
STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);
|
||||
|
||||
int CMS_SignedData_init(CMS_ContentInfo *cms);
|
||||
CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
|
||||
X509 *signer, EVP_PKEY *pk, const EVP_MD *md,
|
||||
unsigned int flags);
|
||||
EVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);
|
||||
EVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);
|
||||
STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);
|
||||
|
||||
void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);
|
||||
int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,
|
||||
ASN1_OCTET_STRING **keyid,
|
||||
X509_NAME **issuer, ASN1_INTEGER **sno);
|
||||
int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);
|
||||
int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
|
||||
unsigned int flags);
|
||||
void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,
|
||||
X509 **signer, X509_ALGOR **pdig,
|
||||
X509_ALGOR **psig);
|
||||
ASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);
|
||||
int CMS_SignerInfo_sign(CMS_SignerInfo *si);
|
||||
int CMS_SignerInfo_verify(CMS_SignerInfo *si);
|
||||
int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);
|
||||
|
||||
int CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);
|
||||
int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,
|
||||
int algnid, int keysize);
|
||||
int CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);
|
||||
|
||||
int CMS_signed_get_attr_count(const CMS_SignerInfo *si);
|
||||
int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
|
||||
int lastpos);
|
||||
int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,
|
||||
int lastpos);
|
||||
X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);
|
||||
X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);
|
||||
int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
|
||||
int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,
|
||||
const ASN1_OBJECT *obj, int type,
|
||||
const void *bytes, int len);
|
||||
int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,
|
||||
int nid, int type,
|
||||
const void *bytes, int len);
|
||||
int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,
|
||||
const char *attrname, int type,
|
||||
const void *bytes, int len);
|
||||
void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
|
||||
int lastpos, int type);
|
||||
|
||||
int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);
|
||||
int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
|
||||
int lastpos);
|
||||
int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,
|
||||
int lastpos);
|
||||
X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);
|
||||
X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);
|
||||
int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
|
||||
int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,
|
||||
const ASN1_OBJECT *obj, int type,
|
||||
const void *bytes, int len);
|
||||
int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,
|
||||
int nid, int type,
|
||||
const void *bytes, int len);
|
||||
int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,
|
||||
const char *attrname, int type,
|
||||
const void *bytes, int len);
|
||||
void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
|
||||
int lastpos, int type);
|
||||
|
||||
# ifdef HEADER_X509V3_H
|
||||
|
||||
int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);
|
||||
CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,
|
||||
int allorfirst,
|
||||
STACK_OF(GENERAL_NAMES)
|
||||
*receiptList, STACK_OF(GENERAL_NAMES)
|
||||
*receiptsTo);
|
||||
int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);
|
||||
void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,
|
||||
ASN1_STRING **pcid,
|
||||
int *pallorfirst,
|
||||
STACK_OF(GENERAL_NAMES) **plist,
|
||||
STACK_OF(GENERAL_NAMES) **prto);
|
||||
# endif
|
||||
int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,
|
||||
X509_ALGOR **palg,
|
||||
ASN1_OCTET_STRING **pukm);
|
||||
STACK_OF(CMS_RecipientEncryptedKey)
|
||||
*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);
|
||||
|
||||
int CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,
|
||||
X509_ALGOR **pubalg,
|
||||
ASN1_BIT_STRING **pubkey,
|
||||
ASN1_OCTET_STRING **keyid,
|
||||
X509_NAME **issuer,
|
||||
ASN1_INTEGER **sno);
|
||||
|
||||
int CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);
|
||||
|
||||
int CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,
|
||||
ASN1_OCTET_STRING **keyid,
|
||||
ASN1_GENERALIZEDTIME **tm,
|
||||
CMS_OtherKeyAttribute **other,
|
||||
X509_NAME **issuer, ASN1_INTEGER **sno);
|
||||
int CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,
|
||||
X509 *cert);
|
||||
int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);
|
||||
EVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);
|
||||
int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,
|
||||
CMS_RecipientInfo *ri,
|
||||
CMS_RecipientEncryptedKey *rek);
|
||||
|
||||
int CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,
|
||||
ASN1_OCTET_STRING *ukm, int keylen);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_CMS_strings(void);
|
||||
|
||||
/* Error codes for the CMS functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define CMS_F_CHECK_CONTENT 99
|
||||
# define CMS_F_CMS_ADD0_CERT 164
|
||||
# define CMS_F_CMS_ADD0_RECIPIENT_KEY 100
|
||||
# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD 165
|
||||
# define CMS_F_CMS_ADD1_RECEIPTREQUEST 158
|
||||
# define CMS_F_CMS_ADD1_RECIPIENT_CERT 101
|
||||
# define CMS_F_CMS_ADD1_SIGNER 102
|
||||
# define CMS_F_CMS_ADD1_SIGNINGTIME 103
|
||||
# define CMS_F_CMS_COMPRESS 104
|
||||
# define CMS_F_CMS_COMPRESSEDDATA_CREATE 105
|
||||
# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO 106
|
||||
# define CMS_F_CMS_COPY_CONTENT 107
|
||||
# define CMS_F_CMS_COPY_MESSAGEDIGEST 108
|
||||
# define CMS_F_CMS_DATA 109
|
||||
# define CMS_F_CMS_DATAFINAL 110
|
||||
# define CMS_F_CMS_DATAINIT 111
|
||||
# define CMS_F_CMS_DECRYPT 112
|
||||
# define CMS_F_CMS_DECRYPT_SET1_KEY 113
|
||||
# define CMS_F_CMS_DECRYPT_SET1_PASSWORD 166
|
||||
# define CMS_F_CMS_DECRYPT_SET1_PKEY 114
|
||||
# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX 115
|
||||
# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO 116
|
||||
# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL 117
|
||||
# define CMS_F_CMS_DIGEST_VERIFY 118
|
||||
# define CMS_F_CMS_ENCODE_RECEIPT 161
|
||||
# define CMS_F_CMS_ENCRYPT 119
|
||||
# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO 120
|
||||
# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT 121
|
||||
# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT 122
|
||||
# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY 123
|
||||
# define CMS_F_CMS_ENVELOPEDDATA_CREATE 124
|
||||
# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO 125
|
||||
# define CMS_F_CMS_ENVELOPED_DATA_INIT 126
|
||||
# define CMS_F_CMS_ENV_ASN1_CTRL 171
|
||||
# define CMS_F_CMS_FINAL 127
|
||||
# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES 128
|
||||
# define CMS_F_CMS_GET0_CONTENT 129
|
||||
# define CMS_F_CMS_GET0_ECONTENT_TYPE 130
|
||||
# define CMS_F_CMS_GET0_ENVELOPED 131
|
||||
# define CMS_F_CMS_GET0_REVOCATION_CHOICES 132
|
||||
# define CMS_F_CMS_GET0_SIGNED 133
|
||||
# define CMS_F_CMS_MSGSIGDIGEST_ADD1 162
|
||||
# define CMS_F_CMS_RECEIPTREQUEST_CREATE0 159
|
||||
# define CMS_F_CMS_RECEIPT_VERIFY 160
|
||||
# define CMS_F_CMS_RECIPIENTINFO_DECRYPT 134
|
||||
# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT 169
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT 178
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG 175
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID 173
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS 172
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP 174
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT 135
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT 136
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID 137
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP 138
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP 139
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT 140
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT 141
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS 142
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID 143
|
||||
# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT 167
|
||||
# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY 144
|
||||
# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD 168
|
||||
# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY 145
|
||||
# define CMS_F_CMS_SD_ASN1_CTRL 170
|
||||
# define CMS_F_CMS_SET1_IAS 176
|
||||
# define CMS_F_CMS_SET1_KEYID 177
|
||||
# define CMS_F_CMS_SET1_SIGNERIDENTIFIER 146
|
||||
# define CMS_F_CMS_SET_DETACHED 147
|
||||
# define CMS_F_CMS_SIGN 148
|
||||
# define CMS_F_CMS_SIGNED_DATA_INIT 149
|
||||
# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN 150
|
||||
# define CMS_F_CMS_SIGNERINFO_SIGN 151
|
||||
# define CMS_F_CMS_SIGNERINFO_VERIFY 152
|
||||
# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT 153
|
||||
# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT 154
|
||||
# define CMS_F_CMS_SIGN_RECEIPT 163
|
||||
# define CMS_F_CMS_STREAM 155
|
||||
# define CMS_F_CMS_UNCOMPRESS 156
|
||||
# define CMS_F_CMS_VERIFY 157
|
||||
|
||||
/* Reason codes. */
|
||||
# define CMS_R_ADD_SIGNER_ERROR 99
|
||||
# define CMS_R_CERTIFICATE_ALREADY_PRESENT 175
|
||||
# define CMS_R_CERTIFICATE_HAS_NO_KEYID 160
|
||||
# define CMS_R_CERTIFICATE_VERIFY_ERROR 100
|
||||
# define CMS_R_CIPHER_INITIALISATION_ERROR 101
|
||||
# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR 102
|
||||
# define CMS_R_CMS_DATAFINAL_ERROR 103
|
||||
# define CMS_R_CMS_LIB 104
|
||||
# define CMS_R_CONTENTIDENTIFIER_MISMATCH 170
|
||||
# define CMS_R_CONTENT_NOT_FOUND 105
|
||||
# define CMS_R_CONTENT_TYPE_MISMATCH 171
|
||||
# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA 106
|
||||
# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA 107
|
||||
# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA 108
|
||||
# define CMS_R_CONTENT_VERIFY_ERROR 109
|
||||
# define CMS_R_CTRL_ERROR 110
|
||||
# define CMS_R_CTRL_FAILURE 111
|
||||
# define CMS_R_DECRYPT_ERROR 112
|
||||
# define CMS_R_DIGEST_ERROR 161
|
||||
# define CMS_R_ERROR_GETTING_PUBLIC_KEY 113
|
||||
# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114
|
||||
# define CMS_R_ERROR_SETTING_KEY 115
|
||||
# define CMS_R_ERROR_SETTING_RECIPIENTINFO 116
|
||||
# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117
|
||||
# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176
|
||||
# define CMS_R_INVALID_KEY_LENGTH 118
|
||||
# define CMS_R_MD_BIO_INIT_ERROR 119
|
||||
# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH 120
|
||||
# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH 121
|
||||
# define CMS_R_MSGSIGDIGEST_ERROR 172
|
||||
# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE 162
|
||||
# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH 163
|
||||
# define CMS_R_NEED_ONE_SIGNER 164
|
||||
# define CMS_R_NOT_A_SIGNED_RECEIPT 165
|
||||
# define CMS_R_NOT_ENCRYPTED_DATA 122
|
||||
# define CMS_R_NOT_KEK 123
|
||||
# define CMS_R_NOT_KEY_AGREEMENT 181
|
||||
# define CMS_R_NOT_KEY_TRANSPORT 124
|
||||
# define CMS_R_NOT_PWRI 177
|
||||
# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125
|
||||
# define CMS_R_NO_CIPHER 126
|
||||
# define CMS_R_NO_CONTENT 127
|
||||
# define CMS_R_NO_CONTENT_TYPE 173
|
||||
# define CMS_R_NO_DEFAULT_DIGEST 128
|
||||
# define CMS_R_NO_DIGEST_SET 129
|
||||
# define CMS_R_NO_KEY 130
|
||||
# define CMS_R_NO_KEY_OR_CERT 174
|
||||
# define CMS_R_NO_MATCHING_DIGEST 131
|
||||
# define CMS_R_NO_MATCHING_RECIPIENT 132
|
||||
# define CMS_R_NO_MATCHING_SIGNATURE 166
|
||||
# define CMS_R_NO_MSGSIGDIGEST 167
|
||||
# define CMS_R_NO_PASSWORD 178
|
||||
# define CMS_R_NO_PRIVATE_KEY 133
|
||||
# define CMS_R_NO_PUBLIC_KEY 134
|
||||
# define CMS_R_NO_RECEIPT_REQUEST 168
|
||||
# define CMS_R_NO_SIGNERS 135
|
||||
# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 136
|
||||
# define CMS_R_RECEIPT_DECODE_ERROR 169
|
||||
# define CMS_R_RECIPIENT_ERROR 137
|
||||
# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND 138
|
||||
# define CMS_R_SIGNFINAL_ERROR 139
|
||||
# define CMS_R_SMIME_TEXT_ERROR 140
|
||||
# define CMS_R_STORE_INIT_ERROR 141
|
||||
# define CMS_R_TYPE_NOT_COMPRESSED_DATA 142
|
||||
# define CMS_R_TYPE_NOT_DATA 143
|
||||
# define CMS_R_TYPE_NOT_DIGESTED_DATA 144
|
||||
# define CMS_R_TYPE_NOT_ENCRYPTED_DATA 145
|
||||
# define CMS_R_TYPE_NOT_ENVELOPED_DATA 146
|
||||
# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT 147
|
||||
# define CMS_R_UNKNOWN_CIPHER 148
|
||||
# define CMS_R_UNKNOWN_DIGEST_ALGORIHM 149
|
||||
# define CMS_R_UNKNOWN_ID 150
|
||||
# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM 151
|
||||
# define CMS_R_UNSUPPORTED_CONTENT_TYPE 152
|
||||
# define CMS_R_UNSUPPORTED_KEK_ALGORITHM 153
|
||||
# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM 179
|
||||
# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE 154
|
||||
# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE 155
|
||||
# define CMS_R_UNSUPPORTED_TYPE 156
|
||||
# define CMS_R_UNWRAP_ERROR 157
|
||||
# define CMS_R_UNWRAP_FAILURE 180
|
||||
# define CMS_R_VERIFICATION_FAILURE 158
|
||||
# define CMS_R_WRAP_ERROR 159
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
79
sgx-jvm/dependencies/root/usr/include/openssl/comp.h
Normal file
79
sgx-jvm/dependencies/root/usr/include/openssl/comp.h
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
#ifndef HEADER_COMP_H
|
||||
# define HEADER_COMP_H
|
||||
|
||||
# include <openssl/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct comp_ctx_st COMP_CTX;
|
||||
|
||||
typedef struct comp_method_st {
|
||||
int type; /* NID for compression library */
|
||||
const char *name; /* A text string to identify the library */
|
||||
int (*init) (COMP_CTX *ctx);
|
||||
void (*finish) (COMP_CTX *ctx);
|
||||
int (*compress) (COMP_CTX *ctx,
|
||||
unsigned char *out, unsigned int olen,
|
||||
unsigned char *in, unsigned int ilen);
|
||||
int (*expand) (COMP_CTX *ctx,
|
||||
unsigned char *out, unsigned int olen,
|
||||
unsigned char *in, unsigned int ilen);
|
||||
/*
|
||||
* The following two do NOTHING, but are kept for backward compatibility
|
||||
*/
|
||||
long (*ctrl) (void);
|
||||
long (*callback_ctrl) (void);
|
||||
} COMP_METHOD;
|
||||
|
||||
struct comp_ctx_st {
|
||||
COMP_METHOD *meth;
|
||||
unsigned long compress_in;
|
||||
unsigned long compress_out;
|
||||
unsigned long expand_in;
|
||||
unsigned long expand_out;
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
};
|
||||
|
||||
COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
|
||||
void COMP_CTX_free(COMP_CTX *ctx);
|
||||
int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||
unsigned char *in, int ilen);
|
||||
int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||
unsigned char *in, int ilen);
|
||||
COMP_METHOD *COMP_rle(void);
|
||||
COMP_METHOD *COMP_zlib(void);
|
||||
void COMP_zlib_cleanup(void);
|
||||
|
||||
# ifdef HEADER_BIO_H
|
||||
# ifdef ZLIB
|
||||
BIO_METHOD *BIO_f_zlib(void);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_COMP_strings(void);
|
||||
|
||||
/* Error codes for the COMP functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define COMP_F_BIO_ZLIB_FLUSH 99
|
||||
# define COMP_F_BIO_ZLIB_NEW 100
|
||||
# define COMP_F_BIO_ZLIB_READ 101
|
||||
# define COMP_F_BIO_ZLIB_WRITE 102
|
||||
|
||||
/* Reason codes. */
|
||||
# define COMP_R_ZLIB_DEFLATE_ERROR 99
|
||||
# define COMP_R_ZLIB_INFLATE_ERROR 100
|
||||
# define COMP_R_ZLIB_NOT_SUPPORTED 101
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
267
sgx-jvm/dependencies/root/usr/include/openssl/conf.h
Normal file
267
sgx-jvm/dependencies/root/usr/include/openssl/conf.h
Normal file
@ -0,0 +1,267 @@
|
||||
/* crypto/conf/conf.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CONF_H
|
||||
# define HEADER_CONF_H
|
||||
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/lhash.h>
|
||||
# include <openssl/stack.h>
|
||||
# include <openssl/safestack.h>
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# include <openssl/ossl_typ.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char *section;
|
||||
char *name;
|
||||
char *value;
|
||||
} CONF_VALUE;
|
||||
|
||||
DECLARE_STACK_OF(CONF_VALUE)
|
||||
DECLARE_LHASH_OF(CONF_VALUE);
|
||||
|
||||
struct conf_st;
|
||||
struct conf_method_st;
|
||||
typedef struct conf_method_st CONF_METHOD;
|
||||
|
||||
struct conf_method_st {
|
||||
const char *name;
|
||||
CONF *(*create) (CONF_METHOD *meth);
|
||||
int (*init) (CONF *conf);
|
||||
int (*destroy) (CONF *conf);
|
||||
int (*destroy_data) (CONF *conf);
|
||||
int (*load_bio) (CONF *conf, BIO *bp, long *eline);
|
||||
int (*dump) (const CONF *conf, BIO *bp);
|
||||
int (*is_number) (const CONF *conf, char c);
|
||||
int (*to_int) (const CONF *conf, char c);
|
||||
int (*load) (CONF *conf, const char *name, long *eline);
|
||||
};
|
||||
|
||||
/* Module definitions */
|
||||
|
||||
typedef struct conf_imodule_st CONF_IMODULE;
|
||||
typedef struct conf_module_st CONF_MODULE;
|
||||
|
||||
DECLARE_STACK_OF(CONF_MODULE)
|
||||
DECLARE_STACK_OF(CONF_IMODULE)
|
||||
|
||||
/* DSO module function typedefs */
|
||||
typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);
|
||||
typedef void conf_finish_func (CONF_IMODULE *md);
|
||||
|
||||
# define CONF_MFLAGS_IGNORE_ERRORS 0x1
|
||||
# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2
|
||||
# define CONF_MFLAGS_SILENT 0x4
|
||||
# define CONF_MFLAGS_NO_DSO 0x8
|
||||
# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10
|
||||
# define CONF_MFLAGS_DEFAULT_SECTION 0x20
|
||||
|
||||
int CONF_set_default_method(CONF_METHOD *meth);
|
||||
void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);
|
||||
LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
|
||||
long *eline);
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
|
||||
long *eline);
|
||||
# endif
|
||||
LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,
|
||||
long *eline);
|
||||
STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
|
||||
const char *section);
|
||||
char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,
|
||||
const char *name);
|
||||
long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,
|
||||
const char *name);
|
||||
void CONF_free(LHASH_OF(CONF_VALUE) *conf);
|
||||
int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
|
||||
int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
|
||||
|
||||
void OPENSSL_config(const char *config_name);
|
||||
void OPENSSL_no_config(void);
|
||||
|
||||
/*
|
||||
* New conf code. The semantics are different from the functions above. If
|
||||
* that wasn't the case, the above functions would have been replaced
|
||||
*/
|
||||
|
||||
struct conf_st {
|
||||
CONF_METHOD *meth;
|
||||
void *meth_data;
|
||||
LHASH_OF(CONF_VALUE) *data;
|
||||
};
|
||||
|
||||
CONF *NCONF_new(CONF_METHOD *meth);
|
||||
CONF_METHOD *NCONF_default(void);
|
||||
CONF_METHOD *NCONF_WIN32(void);
|
||||
# if 0 /* Just to give you an idea of what I have in
|
||||
* mind */
|
||||
CONF_METHOD *NCONF_XML(void);
|
||||
# endif
|
||||
void NCONF_free(CONF *conf);
|
||||
void NCONF_free_data(CONF *conf);
|
||||
|
||||
int NCONF_load(CONF *conf, const char *file, long *eline);
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
int NCONF_load_fp(CONF *conf, FILE *fp, long *eline);
|
||||
# endif
|
||||
int NCONF_load_bio(CONF *conf, BIO *bp, long *eline);
|
||||
STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,
|
||||
const char *section);
|
||||
char *NCONF_get_string(const CONF *conf, const char *group, const char *name);
|
||||
int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
|
||||
long *result);
|
||||
int NCONF_dump_fp(const CONF *conf, FILE *out);
|
||||
int NCONF_dump_bio(const CONF *conf, BIO *out);
|
||||
|
||||
# if 0 /* The following function has no error
|
||||
* checking, and should therefore be avoided */
|
||||
long NCONF_get_number(CONF *conf, char *group, char *name);
|
||||
# else
|
||||
# define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)
|
||||
# endif
|
||||
|
||||
/* Module functions */
|
||||
|
||||
int CONF_modules_load(const CONF *cnf, const char *appname,
|
||||
unsigned long flags);
|
||||
int CONF_modules_load_file(const char *filename, const char *appname,
|
||||
unsigned long flags);
|
||||
void CONF_modules_unload(int all);
|
||||
void CONF_modules_finish(void);
|
||||
void CONF_modules_free(void);
|
||||
int CONF_module_add(const char *name, conf_init_func *ifunc,
|
||||
conf_finish_func *ffunc);
|
||||
|
||||
const char *CONF_imodule_get_name(const CONF_IMODULE *md);
|
||||
const char *CONF_imodule_get_value(const CONF_IMODULE *md);
|
||||
void *CONF_imodule_get_usr_data(const CONF_IMODULE *md);
|
||||
void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);
|
||||
CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);
|
||||
unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);
|
||||
void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);
|
||||
void *CONF_module_get_usr_data(CONF_MODULE *pmod);
|
||||
void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);
|
||||
|
||||
char *CONF_get1_default_config_file(void);
|
||||
|
||||
int CONF_parse_list(const char *list, int sep, int nospc,
|
||||
int (*list_cb) (const char *elem, int len, void *usr),
|
||||
void *arg);
|
||||
|
||||
void OPENSSL_load_builtin_modules(void);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_CONF_strings(void);
|
||||
|
||||
/* Error codes for the CONF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define CONF_F_CONF_DUMP_FP 104
|
||||
# define CONF_F_CONF_LOAD 100
|
||||
# define CONF_F_CONF_LOAD_BIO 102
|
||||
# define CONF_F_CONF_LOAD_FP 103
|
||||
# define CONF_F_CONF_MODULES_LOAD 116
|
||||
# define CONF_F_CONF_PARSE_LIST 119
|
||||
# define CONF_F_DEF_LOAD 120
|
||||
# define CONF_F_DEF_LOAD_BIO 121
|
||||
# define CONF_F_MODULE_INIT 115
|
||||
# define CONF_F_MODULE_LOAD_DSO 117
|
||||
# define CONF_F_MODULE_RUN 118
|
||||
# define CONF_F_NCONF_DUMP_BIO 105
|
||||
# define CONF_F_NCONF_DUMP_FP 106
|
||||
# define CONF_F_NCONF_GET_NUMBER 107
|
||||
# define CONF_F_NCONF_GET_NUMBER_E 112
|
||||
# define CONF_F_NCONF_GET_SECTION 108
|
||||
# define CONF_F_NCONF_GET_STRING 109
|
||||
# define CONF_F_NCONF_LOAD 113
|
||||
# define CONF_F_NCONF_LOAD_BIO 110
|
||||
# define CONF_F_NCONF_LOAD_FP 114
|
||||
# define CONF_F_NCONF_NEW 111
|
||||
# define CONF_F_STR_COPY 101
|
||||
|
||||
/* Reason codes. */
|
||||
# define CONF_R_ERROR_LOADING_DSO 110
|
||||
# define CONF_R_LIST_CANNOT_BE_NULL 115
|
||||
# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
|
||||
# define CONF_R_MISSING_EQUAL_SIGN 101
|
||||
# define CONF_R_MISSING_FINISH_FUNCTION 111
|
||||
# define CONF_R_MISSING_INIT_FUNCTION 112
|
||||
# define CONF_R_MODULE_INITIALIZATION_ERROR 109
|
||||
# define CONF_R_NO_CLOSE_BRACE 102
|
||||
# define CONF_R_NO_CONF 105
|
||||
# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106
|
||||
# define CONF_R_NO_SECTION 107
|
||||
# define CONF_R_NO_SUCH_FILE 114
|
||||
# define CONF_R_NO_VALUE 108
|
||||
# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103
|
||||
# define CONF_R_UNKNOWN_MODULE_NAME 113
|
||||
# define CONF_R_VARIABLE_HAS_NO_VALUE 104
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
89
sgx-jvm/dependencies/root/usr/include/openssl/conf_api.h
Normal file
89
sgx-jvm/dependencies/root/usr/include/openssl/conf_api.h
Normal file
@ -0,0 +1,89 @@
|
||||
/* conf_api.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CONF_API_H
|
||||
# define HEADER_CONF_API_H
|
||||
|
||||
# include <openssl/lhash.h>
|
||||
# include <openssl/conf.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Up until OpenSSL 0.9.5a, this was new_section */
|
||||
CONF_VALUE *_CONF_new_section(CONF *conf, const char *section);
|
||||
/* Up until OpenSSL 0.9.5a, this was get_section */
|
||||
CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);
|
||||
/* Up until OpenSSL 0.9.5a, this was CONF_get_section */
|
||||
STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,
|
||||
const char *section);
|
||||
|
||||
int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);
|
||||
char *_CONF_get_string(const CONF *conf, const char *section,
|
||||
const char *name);
|
||||
long _CONF_get_number(const CONF *conf, const char *section,
|
||||
const char *name);
|
||||
|
||||
int _CONF_new_data(CONF *conf);
|
||||
void _CONF_free_data(CONF *conf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
661
sgx-jvm/dependencies/root/usr/include/openssl/crypto.h
Normal file
661
sgx-jvm/dependencies/root/usr/include/openssl/crypto.h
Normal file
@ -0,0 +1,661 @@
|
||||
/* crypto/crypto.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CRYPTO_H
|
||||
# define HEADER_CRYPTO_H
|
||||
|
||||
# include <stdlib.h>
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
|
||||
# include <openssl/stack.h>
|
||||
# include <openssl/safestack.h>
|
||||
# include <openssl/opensslv.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
|
||||
# ifdef CHARSET_EBCDIC
|
||||
# include <openssl/ebcdic.h>
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Resolve problems on some operating systems with symbol names that clash
|
||||
* one way or another
|
||||
*/
|
||||
# include <openssl/symhacks.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Backward compatibility to SSLeay */
|
||||
/*
|
||||
* This is more to be used to check the correct DLL is being used in the MS
|
||||
* world.
|
||||
*/
|
||||
# define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
|
||||
# define SSLEAY_VERSION 0
|
||||
/* #define SSLEAY_OPTIONS 1 no longer supported */
|
||||
# define SSLEAY_CFLAGS 2
|
||||
# define SSLEAY_BUILT_ON 3
|
||||
# define SSLEAY_PLATFORM 4
|
||||
# define SSLEAY_DIR 5
|
||||
|
||||
/* Already declared in ossl_typ.h */
|
||||
# if 0
|
||||
typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
|
||||
/* Called when a new object is created */
|
||||
typedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
/* Called when an object is free()ed */
|
||||
typedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
/* Called when we need to dup an object */
|
||||
typedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,
|
||||
void *from_d, int idx, long argl, void *argp);
|
||||
# endif
|
||||
|
||||
/* A generic structure to pass assorted data in a expandable way */
|
||||
typedef struct openssl_item_st {
|
||||
int code;
|
||||
void *value; /* Not used for flag attributes */
|
||||
size_t value_size; /* Max size of value for output, length for
|
||||
* input */
|
||||
size_t *value_length; /* Returned length of value for output */
|
||||
} OPENSSL_ITEM;
|
||||
|
||||
/*
|
||||
* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
|
||||
* names in cryptlib.c
|
||||
*/
|
||||
|
||||
# define CRYPTO_LOCK_ERR 1
|
||||
# define CRYPTO_LOCK_EX_DATA 2
|
||||
# define CRYPTO_LOCK_X509 3
|
||||
# define CRYPTO_LOCK_X509_INFO 4
|
||||
# define CRYPTO_LOCK_X509_PKEY 5
|
||||
# define CRYPTO_LOCK_X509_CRL 6
|
||||
# define CRYPTO_LOCK_X509_REQ 7
|
||||
# define CRYPTO_LOCK_DSA 8
|
||||
# define CRYPTO_LOCK_RSA 9
|
||||
# define CRYPTO_LOCK_EVP_PKEY 10
|
||||
# define CRYPTO_LOCK_X509_STORE 11
|
||||
# define CRYPTO_LOCK_SSL_CTX 12
|
||||
# define CRYPTO_LOCK_SSL_CERT 13
|
||||
# define CRYPTO_LOCK_SSL_SESSION 14
|
||||
# define CRYPTO_LOCK_SSL_SESS_CERT 15
|
||||
# define CRYPTO_LOCK_SSL 16
|
||||
# define CRYPTO_LOCK_SSL_METHOD 17
|
||||
# define CRYPTO_LOCK_RAND 18
|
||||
# define CRYPTO_LOCK_RAND2 19
|
||||
# define CRYPTO_LOCK_MALLOC 20
|
||||
# define CRYPTO_LOCK_BIO 21
|
||||
# define CRYPTO_LOCK_GETHOSTBYNAME 22
|
||||
# define CRYPTO_LOCK_GETSERVBYNAME 23
|
||||
# define CRYPTO_LOCK_READDIR 24
|
||||
# define CRYPTO_LOCK_RSA_BLINDING 25
|
||||
# define CRYPTO_LOCK_DH 26
|
||||
# define CRYPTO_LOCK_MALLOC2 27
|
||||
# define CRYPTO_LOCK_DSO 28
|
||||
# define CRYPTO_LOCK_DYNLOCK 29
|
||||
# define CRYPTO_LOCK_ENGINE 30
|
||||
# define CRYPTO_LOCK_UI 31
|
||||
# define CRYPTO_LOCK_ECDSA 32
|
||||
# define CRYPTO_LOCK_EC 33
|
||||
# define CRYPTO_LOCK_ECDH 34
|
||||
# define CRYPTO_LOCK_BN 35
|
||||
# define CRYPTO_LOCK_EC_PRE_COMP 36
|
||||
# define CRYPTO_LOCK_STORE 37
|
||||
# define CRYPTO_LOCK_COMP 38
|
||||
# define CRYPTO_LOCK_FIPS 39
|
||||
# define CRYPTO_LOCK_FIPS2 40
|
||||
# define CRYPTO_NUM_LOCKS 41
|
||||
|
||||
# define CRYPTO_LOCK 1
|
||||
# define CRYPTO_UNLOCK 2
|
||||
# define CRYPTO_READ 4
|
||||
# define CRYPTO_WRITE 8
|
||||
|
||||
# ifndef OPENSSL_NO_LOCKING
|
||||
# ifndef CRYPTO_w_lock
|
||||
# define CRYPTO_w_lock(type) \
|
||||
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
|
||||
# define CRYPTO_w_unlock(type) \
|
||||
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
|
||||
# define CRYPTO_r_lock(type) \
|
||||
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
|
||||
# define CRYPTO_r_unlock(type) \
|
||||
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
|
||||
# define CRYPTO_add(addr,amount,type) \
|
||||
CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
|
||||
# endif
|
||||
# else
|
||||
# define CRYPTO_w_lock(a)
|
||||
# define CRYPTO_w_unlock(a)
|
||||
# define CRYPTO_r_lock(a)
|
||||
# define CRYPTO_r_unlock(a)
|
||||
# define CRYPTO_add(a,b,c) ((*(a))+=(b))
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Some applications as well as some parts of OpenSSL need to allocate and
|
||||
* deallocate locks in a dynamic fashion. The following typedef makes this
|
||||
* possible in a type-safe manner.
|
||||
*/
|
||||
/* struct CRYPTO_dynlock_value has to be defined by the application. */
|
||||
typedef struct {
|
||||
int references;
|
||||
struct CRYPTO_dynlock_value *data;
|
||||
} CRYPTO_dynlock;
|
||||
|
||||
/*
|
||||
* The following can be used to detect memory leaks in the SSLeay library. It
|
||||
* used, it turns on malloc checking
|
||||
*/
|
||||
|
||||
# define CRYPTO_MEM_CHECK_OFF 0x0/* an enume */
|
||||
# define CRYPTO_MEM_CHECK_ON 0x1/* a bit */
|
||||
# define CRYPTO_MEM_CHECK_ENABLE 0x2/* a bit */
|
||||
# define CRYPTO_MEM_CHECK_DISABLE 0x3/* an enume */
|
||||
|
||||
/*
|
||||
* The following are bit values to turn on or off options connected to the
|
||||
* malloc checking functionality
|
||||
*/
|
||||
|
||||
/* Adds time to the memory checking information */
|
||||
# define V_CRYPTO_MDEBUG_TIME 0x1/* a bit */
|
||||
/* Adds thread number to the memory checking information */
|
||||
# define V_CRYPTO_MDEBUG_THREAD 0x2/* a bit */
|
||||
|
||||
# define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
|
||||
|
||||
/* predec of the BIO type */
|
||||
typedef struct bio_st BIO_dummy;
|
||||
|
||||
struct crypto_ex_data_st {
|
||||
STACK_OF(void) *sk;
|
||||
/* gcc is screwing up this data structure :-( */
|
||||
int dummy;
|
||||
};
|
||||
DECLARE_STACK_OF(void)
|
||||
|
||||
/*
|
||||
* This stuff is basically class callback functions The current classes are
|
||||
* SSL_CTX, SSL, SSL_SESSION, and a few more
|
||||
*/
|
||||
|
||||
typedef struct crypto_ex_data_func_st {
|
||||
long argl; /* Arbitary long */
|
||||
void *argp; /* Arbitary void * */
|
||||
CRYPTO_EX_new *new_func;
|
||||
CRYPTO_EX_free *free_func;
|
||||
CRYPTO_EX_dup *dup_func;
|
||||
} CRYPTO_EX_DATA_FUNCS;
|
||||
|
||||
DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
|
||||
|
||||
/*
|
||||
* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
|
||||
* entry.
|
||||
*/
|
||||
|
||||
# define CRYPTO_EX_INDEX_BIO 0
|
||||
# define CRYPTO_EX_INDEX_SSL 1
|
||||
# define CRYPTO_EX_INDEX_SSL_CTX 2
|
||||
# define CRYPTO_EX_INDEX_SSL_SESSION 3
|
||||
# define CRYPTO_EX_INDEX_X509_STORE 4
|
||||
# define CRYPTO_EX_INDEX_X509_STORE_CTX 5
|
||||
# define CRYPTO_EX_INDEX_RSA 6
|
||||
# define CRYPTO_EX_INDEX_DSA 7
|
||||
# define CRYPTO_EX_INDEX_DH 8
|
||||
# define CRYPTO_EX_INDEX_ENGINE 9
|
||||
# define CRYPTO_EX_INDEX_X509 10
|
||||
# define CRYPTO_EX_INDEX_UI 11
|
||||
# define CRYPTO_EX_INDEX_ECDSA 12
|
||||
# define CRYPTO_EX_INDEX_ECDH 13
|
||||
# define CRYPTO_EX_INDEX_COMP 14
|
||||
# define CRYPTO_EX_INDEX_STORE 15
|
||||
|
||||
/*
|
||||
* Dynamically assigned indexes start from this value (don't use directly,
|
||||
* use via CRYPTO_ex_data_new_class).
|
||||
*/
|
||||
# define CRYPTO_EX_INDEX_USER 100
|
||||
|
||||
/*
|
||||
* This is the default callbacks, but we can have others as well: this is
|
||||
* needed in Win32 where the application malloc and the library malloc may
|
||||
* not be the same.
|
||||
*/
|
||||
# define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
|
||||
malloc, realloc, free)
|
||||
|
||||
# if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
|
||||
# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
|
||||
# define CRYPTO_MDEBUG
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Set standard debugging functions (not done by default unless CRYPTO_MDEBUG
|
||||
* is defined)
|
||||
*/
|
||||
# define CRYPTO_malloc_debug_init() do {\
|
||||
CRYPTO_set_mem_debug_functions(\
|
||||
CRYPTO_dbg_malloc,\
|
||||
CRYPTO_dbg_realloc,\
|
||||
CRYPTO_dbg_free,\
|
||||
CRYPTO_dbg_set_options,\
|
||||
CRYPTO_dbg_get_options);\
|
||||
} while(0)
|
||||
|
||||
int CRYPTO_mem_ctrl(int mode);
|
||||
int CRYPTO_is_mem_check_on(void);
|
||||
|
||||
/* for applications */
|
||||
# define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
|
||||
# define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
|
||||
|
||||
/* for library-internal use */
|
||||
# define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
|
||||
# define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
|
||||
# define is_MemCheck_on() CRYPTO_is_mem_check_on()
|
||||
|
||||
# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
|
||||
# define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
|
||||
# define OPENSSL_realloc(addr,num) \
|
||||
CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
|
||||
# define OPENSSL_realloc_clean(addr,old_num,num) \
|
||||
CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
|
||||
# define OPENSSL_remalloc(addr,num) \
|
||||
CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
|
||||
# define OPENSSL_freeFunc CRYPTO_free
|
||||
# define OPENSSL_free(addr) CRYPTO_free(addr)
|
||||
|
||||
# define OPENSSL_malloc_locked(num) \
|
||||
CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
|
||||
# define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
|
||||
|
||||
const char *SSLeay_version(int type);
|
||||
unsigned long SSLeay(void);
|
||||
|
||||
int OPENSSL_issetugid(void);
|
||||
|
||||
/* An opaque type representing an implementation of "ex_data" support */
|
||||
typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
|
||||
/* Return an opaque pointer to the current "ex_data" implementation */
|
||||
const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
|
||||
/* Sets the "ex_data" implementation to be used (if it's not too late) */
|
||||
int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
|
||||
/* Get a new "ex_data" class, and return the corresponding "class_index" */
|
||||
int CRYPTO_ex_data_new_class(void);
|
||||
/* Within a given class, get/register a new index */
|
||||
int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
|
||||
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
|
||||
CRYPTO_EX_free *free_func);
|
||||
/*
|
||||
* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a
|
||||
* given class (invokes whatever per-class callbacks are applicable)
|
||||
*/
|
||||
int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
|
||||
CRYPTO_EX_DATA *from);
|
||||
void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
/*
|
||||
* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular
|
||||
* index (relative to the class type involved)
|
||||
*/
|
||||
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
|
||||
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);
|
||||
/*
|
||||
* This function cleans up all "ex_data" state. It mustn't be called under
|
||||
* potential race-conditions.
|
||||
*/
|
||||
void CRYPTO_cleanup_all_ex_data(void);
|
||||
|
||||
int CRYPTO_get_new_lockid(char *name);
|
||||
|
||||
int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
|
||||
void CRYPTO_lock(int mode, int type, const char *file, int line);
|
||||
void CRYPTO_set_locking_callback(void (*func) (int mode, int type,
|
||||
const char *file, int line));
|
||||
void (*CRYPTO_get_locking_callback(void)) (int mode, int type,
|
||||
const char *file, int line);
|
||||
void CRYPTO_set_add_lock_callback(int (*func)
|
||||
(int *num, int mount, int type,
|
||||
const char *file, int line));
|
||||
int (*CRYPTO_get_add_lock_callback(void)) (int *num, int mount, int type,
|
||||
const char *file, int line);
|
||||
|
||||
/* Don't use this structure directly. */
|
||||
typedef struct crypto_threadid_st {
|
||||
void *ptr;
|
||||
unsigned long val;
|
||||
} CRYPTO_THREADID;
|
||||
/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
|
||||
void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
|
||||
void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
|
||||
int CRYPTO_THREADID_set_callback(void (*threadid_func) (CRYPTO_THREADID *));
|
||||
void (*CRYPTO_THREADID_get_callback(void)) (CRYPTO_THREADID *);
|
||||
void CRYPTO_THREADID_current(CRYPTO_THREADID *id);
|
||||
int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);
|
||||
void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);
|
||||
unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
void CRYPTO_set_id_callback(unsigned long (*func) (void));
|
||||
unsigned long (*CRYPTO_get_id_callback(void)) (void);
|
||||
unsigned long CRYPTO_thread_id(void);
|
||||
# endif
|
||||
|
||||
const char *CRYPTO_get_lock_name(int type);
|
||||
int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
|
||||
int line);
|
||||
|
||||
int CRYPTO_get_new_dynlockid(void);
|
||||
void CRYPTO_destroy_dynlockid(int i);
|
||||
struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
|
||||
void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value
|
||||
*(*dyn_create_function) (const char
|
||||
*file,
|
||||
int line));
|
||||
void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)
|
||||
(int mode,
|
||||
struct CRYPTO_dynlock_value *l,
|
||||
const char *file, int line));
|
||||
void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)
|
||||
(struct CRYPTO_dynlock_value *l,
|
||||
const char *file, int line));
|
||||
struct CRYPTO_dynlock_value
|
||||
*(*CRYPTO_get_dynlock_create_callback(void)) (const char *file, int line);
|
||||
void (*CRYPTO_get_dynlock_lock_callback(void)) (int mode,
|
||||
struct CRYPTO_dynlock_value
|
||||
*l, const char *file,
|
||||
int line);
|
||||
void (*CRYPTO_get_dynlock_destroy_callback(void)) (struct CRYPTO_dynlock_value
|
||||
*l, const char *file,
|
||||
int line);
|
||||
|
||||
/*
|
||||
* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- call
|
||||
* the latter last if you need different functions
|
||||
*/
|
||||
int CRYPTO_set_mem_functions(void *(*m) (size_t), void *(*r) (void *, size_t),
|
||||
void (*f) (void *));
|
||||
int CRYPTO_set_locked_mem_functions(void *(*m) (size_t),
|
||||
void (*free_func) (void *));
|
||||
int CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const char *, int),
|
||||
void *(*r) (void *, size_t, const char *,
|
||||
int), void (*f) (void *));
|
||||
int CRYPTO_set_locked_mem_ex_functions(void *(*m) (size_t, const char *, int),
|
||||
void (*free_func) (void *));
|
||||
int CRYPTO_set_mem_debug_functions(void (*m)
|
||||
(void *, int, const char *, int, int),
|
||||
void (*r) (void *, void *, int,
|
||||
const char *, int, int),
|
||||
void (*f) (void *, int), void (*so) (long),
|
||||
long (*go) (void));
|
||||
void CRYPTO_get_mem_functions(void *(**m) (size_t),
|
||||
void *(**r) (void *, size_t),
|
||||
void (**f) (void *));
|
||||
void CRYPTO_get_locked_mem_functions(void *(**m) (size_t),
|
||||
void (**f) (void *));
|
||||
void CRYPTO_get_mem_ex_functions(void *(**m) (size_t, const char *, int),
|
||||
void *(**r) (void *, size_t, const char *,
|
||||
int), void (**f) (void *));
|
||||
void CRYPTO_get_locked_mem_ex_functions(void
|
||||
*(**m) (size_t, const char *, int),
|
||||
void (**f) (void *));
|
||||
void CRYPTO_get_mem_debug_functions(void (**m)
|
||||
(void *, int, const char *, int, int),
|
||||
void (**r) (void *, void *, int,
|
||||
const char *, int, int),
|
||||
void (**f) (void *, int),
|
||||
void (**so) (long), long (**go) (void));
|
||||
|
||||
void *CRYPTO_malloc_locked(int num, const char *file, int line);
|
||||
void CRYPTO_free_locked(void *ptr);
|
||||
void *CRYPTO_malloc(int num, const char *file, int line);
|
||||
char *CRYPTO_strdup(const char *str, const char *file, int line);
|
||||
void CRYPTO_free(void *ptr);
|
||||
void *CRYPTO_realloc(void *addr, int num, const char *file, int line);
|
||||
void *CRYPTO_realloc_clean(void *addr, int old_num, int num, const char *file,
|
||||
int line);
|
||||
void *CRYPTO_remalloc(void *addr, int num, const char *file, int line);
|
||||
|
||||
void OPENSSL_cleanse(void *ptr, size_t len);
|
||||
|
||||
void CRYPTO_set_mem_debug_options(long bits);
|
||||
long CRYPTO_get_mem_debug_options(void);
|
||||
|
||||
# define CRYPTO_push_info(info) \
|
||||
CRYPTO_push_info_(info, __FILE__, __LINE__);
|
||||
int CRYPTO_push_info_(const char *info, const char *file, int line);
|
||||
int CRYPTO_pop_info(void);
|
||||
int CRYPTO_remove_all_info(void);
|
||||
|
||||
/*
|
||||
* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
|
||||
* used as default in CRYPTO_MDEBUG compilations):
|
||||
*/
|
||||
/*-
|
||||
* The last argument has the following significance:
|
||||
*
|
||||
* 0: called before the actual memory allocation has taken place
|
||||
* 1: called after the actual memory allocation has taken place
|
||||
*/
|
||||
void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
|
||||
int before_p);
|
||||
void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file,
|
||||
int line, int before_p);
|
||||
void CRYPTO_dbg_free(void *addr, int before_p);
|
||||
/*-
|
||||
* Tell the debugging code about options. By default, the following values
|
||||
* apply:
|
||||
*
|
||||
* 0: Clear all options.
|
||||
* V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option.
|
||||
* V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option.
|
||||
* V_CRYPTO_MDEBUG_ALL (3): 1 + 2
|
||||
*/
|
||||
void CRYPTO_dbg_set_options(long bits);
|
||||
long CRYPTO_dbg_get_options(void);
|
||||
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
void CRYPTO_mem_leaks_fp(FILE *);
|
||||
# endif
|
||||
void CRYPTO_mem_leaks(struct bio_st *bio);
|
||||
/* unsigned long order, char *file, int line, int num_bytes, char *addr */
|
||||
typedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, int,
|
||||
void *);
|
||||
void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
|
||||
|
||||
/* die if we have to */
|
||||
void OpenSSLDie(const char *file, int line, const char *assertion);
|
||||
# define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
|
||||
|
||||
unsigned long *OPENSSL_ia32cap_loc(void);
|
||||
# define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
|
||||
int OPENSSL_isservice(void);
|
||||
|
||||
int FIPS_mode(void);
|
||||
int FIPS_mode_set(int r);
|
||||
|
||||
void OPENSSL_init(void);
|
||||
|
||||
# define fips_md_init(alg) fips_md_init_ctx(alg, alg)
|
||||
|
||||
# ifdef OPENSSL_FIPS
|
||||
# define fips_md_init_ctx(alg, cx) \
|
||||
int alg##_Init(cx##_CTX *c) \
|
||||
{ \
|
||||
if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
|
||||
"Low level API call to digest " #alg " forbidden in FIPS mode!"); \
|
||||
return private_##alg##_Init(c); \
|
||||
} \
|
||||
int private_##alg##_Init(cx##_CTX *c)
|
||||
|
||||
# define fips_cipher_abort(alg) \
|
||||
if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
|
||||
"Low level API call to cipher " #alg " forbidden in FIPS mode!")
|
||||
|
||||
# else
|
||||
# define fips_md_init_ctx(alg, cx) \
|
||||
int alg##_Init(cx##_CTX *c)
|
||||
# define fips_cipher_abort(alg) while(0)
|
||||
# endif
|
||||
|
||||
/*
|
||||
* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.
|
||||
* It takes an amount of time dependent on |len|, but independent of the
|
||||
* contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements
|
||||
* into a defined order as the return value when a != b is undefined, other
|
||||
* than to be non-zero.
|
||||
*/
|
||||
int CRYPTO_memcmp(const volatile void *a, const volatile void *b, size_t len);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_CRYPTO_strings(void);
|
||||
|
||||
/* Error codes for the CRYPTO functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
|
||||
# define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103
|
||||
# define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
|
||||
# define CRYPTO_F_CRYPTO_SET_EX_DATA 102
|
||||
# define CRYPTO_F_DEF_ADD_INDEX 104
|
||||
# define CRYPTO_F_DEF_GET_CLASS 105
|
||||
# define CRYPTO_F_FIPS_MODE_SET 109
|
||||
# define CRYPTO_F_INT_DUP_EX_DATA 106
|
||||
# define CRYPTO_F_INT_FREE_EX_DATA 107
|
||||
# define CRYPTO_F_INT_NEW_EX_DATA 108
|
||||
|
||||
/* Reason codes. */
|
||||
# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101
|
||||
# define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
257
sgx-jvm/dependencies/root/usr/include/openssl/des.h
Normal file
257
sgx-jvm/dependencies/root/usr/include/openssl/des.h
Normal file
@ -0,0 +1,257 @@
|
||||
/* crypto/des/des.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_NEW_DES_H
|
||||
# define HEADER_NEW_DES_H
|
||||
|
||||
# include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG
|
||||
* (via openssl/opensslconf.h */
|
||||
|
||||
# ifdef OPENSSL_NO_DES
|
||||
# error DES is disabled.
|
||||
# endif
|
||||
|
||||
# ifdef OPENSSL_BUILD_SHLIBCRYPTO
|
||||
# undef OPENSSL_EXTERN
|
||||
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned char DES_cblock[8];
|
||||
typedef /* const */ unsigned char const_DES_cblock[8];
|
||||
/*
|
||||
* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * and
|
||||
* const_DES_cblock * are incompatible pointer types.
|
||||
*/
|
||||
|
||||
typedef struct DES_ks {
|
||||
union {
|
||||
DES_cblock cblock;
|
||||
/*
|
||||
* make sure things are correct size on machines with 8 byte longs
|
||||
*/
|
||||
DES_LONG deslong[2];
|
||||
} ks[16];
|
||||
} DES_key_schedule;
|
||||
|
||||
# ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT
|
||||
# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT
|
||||
# define OPENSSL_ENABLE_OLD_DES_SUPPORT
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT
|
||||
# include <openssl/des_old.h>
|
||||
# endif
|
||||
|
||||
# define DES_KEY_SZ (sizeof(DES_cblock))
|
||||
# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))
|
||||
|
||||
# define DES_ENCRYPT 1
|
||||
# define DES_DECRYPT 0
|
||||
|
||||
# define DES_CBC_MODE 0
|
||||
# define DES_PCBC_MODE 1
|
||||
|
||||
# define DES_ecb2_encrypt(i,o,k1,k2,e) \
|
||||
DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
|
||||
|
||||
# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
|
||||
DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
|
||||
|
||||
# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
|
||||
DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
|
||||
|
||||
# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
|
||||
DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
|
||||
|
||||
OPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */
|
||||
# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)
|
||||
OPENSSL_DECLARE_GLOBAL(int, DES_rw_mode); /* defaults to DES_PCBC_MODE */
|
||||
# define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)
|
||||
|
||||
const char *DES_options(void);
|
||||
void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
|
||||
DES_key_schedule *ks1, DES_key_schedule *ks2,
|
||||
DES_key_schedule *ks3, int enc);
|
||||
DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
const_DES_cblock *ivec);
|
||||
/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */
|
||||
void DES_cbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int enc);
|
||||
void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int enc);
|
||||
void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, const_DES_cblock *inw,
|
||||
const_DES_cblock *outw, int enc);
|
||||
void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int enc);
|
||||
void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
|
||||
DES_key_schedule *ks, int enc);
|
||||
|
||||
/*
|
||||
* This is the DES encryption function that gets called by just about every
|
||||
* other DES routine in the library. You should not use this function except
|
||||
* to implement 'modes' of DES. I say this because the functions that call
|
||||
* this routine do the conversion from 'char *' to long, and this needs to be
|
||||
* done to make sure 'non-aligned' memory access do not occur. The
|
||||
* characters are loaded 'little endian'. Data is a pointer to 2 unsigned
|
||||
* long's and ks is the DES_key_schedule to use. enc, is non zero specifies
|
||||
* encryption, zero if decryption.
|
||||
*/
|
||||
void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);
|
||||
|
||||
/*
|
||||
* This functions is the same as DES_encrypt1() except that the DES initial
|
||||
* permutation (IP) and final permutation (FP) have been left out. As for
|
||||
* DES_encrypt1(), you should not use this function. It is used by the
|
||||
* routines in the library that implement triple DES. IP() DES_encrypt2()
|
||||
* DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()
|
||||
* DES_encrypt1() DES_encrypt1() except faster :-).
|
||||
*/
|
||||
void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);
|
||||
|
||||
void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3);
|
||||
void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3);
|
||||
void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length,
|
||||
DES_key_schedule *ks1, DES_key_schedule *ks2,
|
||||
DES_key_schedule *ks3, DES_cblock *ivec, int enc);
|
||||
void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length,
|
||||
DES_key_schedule *ks1, DES_key_schedule *ks2,
|
||||
DES_key_schedule *ks3,
|
||||
DES_cblock *ivec1, DES_cblock *ivec2, int enc);
|
||||
void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3,
|
||||
DES_cblock *ivec, int *num, int enc);
|
||||
void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
int numbits, long length, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3,
|
||||
DES_cblock *ivec, int enc);
|
||||
void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3,
|
||||
DES_cblock *ivec, int *num);
|
||||
# if 0
|
||||
void DES_xwhite_in2out(const_DES_cblock *DES_key, const_DES_cblock *in_white,
|
||||
DES_cblock *out_white);
|
||||
# endif
|
||||
|
||||
int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
|
||||
DES_cblock *iv);
|
||||
int DES_enc_write(int fd, const void *buf, int len, DES_key_schedule *sched,
|
||||
DES_cblock *iv);
|
||||
char *DES_fcrypt(const char *buf, const char *salt, char *ret);
|
||||
char *DES_crypt(const char *buf, const char *salt);
|
||||
void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec);
|
||||
void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int enc);
|
||||
DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
|
||||
long length, int out_count, DES_cblock *seed);
|
||||
int DES_random_key(DES_cblock *ret);
|
||||
void DES_set_odd_parity(DES_cblock *key);
|
||||
int DES_check_key_parity(const_DES_cblock *key);
|
||||
int DES_is_weak_key(const_DES_cblock *key);
|
||||
/*
|
||||
* DES_set_key (= set_key = DES_key_sched = key_sched) calls
|
||||
* DES_set_key_checked if global variable DES_check_key is set,
|
||||
* DES_set_key_unchecked otherwise.
|
||||
*/
|
||||
int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
|
||||
int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);
|
||||
int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);
|
||||
void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);
|
||||
# ifdef OPENSSL_FIPS
|
||||
void private_DES_set_key_unchecked(const_DES_cblock *key,
|
||||
DES_key_schedule *schedule);
|
||||
# endif
|
||||
void DES_string_to_key(const char *str, DES_cblock *key);
|
||||
void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);
|
||||
void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int *num, int enc);
|
||||
void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int *num);
|
||||
|
||||
int DES_read_password(DES_cblock *key, const char *prompt, int verify);
|
||||
int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2,
|
||||
const char *prompt, int verify);
|
||||
|
||||
# define DES_fixup_key_parity DES_set_odd_parity
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
497
sgx-jvm/dependencies/root/usr/include/openssl/des_old.h
Normal file
497
sgx-jvm/dependencies/root/usr/include/openssl/des_old.h
Normal file
@ -0,0 +1,497 @@
|
||||
/* crypto/des/des_old.h */
|
||||
|
||||
/*-
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* The function names in here are deprecated and are only present to
|
||||
* provide an interface compatible with openssl 0.9.6 and older as
|
||||
* well as libdes. OpenSSL now provides functions where "des_" has
|
||||
* been replaced with "DES_" in the names, to make it possible to
|
||||
* make incompatible changes that are needed for C type security and
|
||||
* other stuff.
|
||||
*
|
||||
* This include files has two compatibility modes:
|
||||
*
|
||||
* - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API
|
||||
* that is compatible with libdes and SSLeay.
|
||||
* - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an
|
||||
* API that is compatible with OpenSSL 0.9.5x to 0.9.6x.
|
||||
*
|
||||
* Note that these modes break earlier snapshots of OpenSSL, where
|
||||
* libdes compatibility was the only available mode or (later on) the
|
||||
* prefered compatibility mode. However, after much consideration
|
||||
* (and more or less violent discussions with external parties), it
|
||||
* was concluded that OpenSSL should be compatible with earlier versions
|
||||
* of itself before anything else. Also, in all honesty, libdes is
|
||||
* an old beast that shouldn't really be used any more.
|
||||
*
|
||||
* Please consider starting to use the DES_ functions rather than the
|
||||
* des_ ones. The des_ functions will disappear completely before
|
||||
* OpenSSL 1.0!
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
/*
|
||||
* Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
|
||||
* 2001.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DES_H
|
||||
# define HEADER_DES_H
|
||||
|
||||
# include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */
|
||||
|
||||
# ifdef OPENSSL_NO_DES
|
||||
# error DES is disabled.
|
||||
# endif
|
||||
|
||||
# ifndef HEADER_NEW_DES_H
|
||||
# error You must include des.h, not des_old.h directly.
|
||||
# endif
|
||||
|
||||
# ifdef _KERBEROS_DES_H
|
||||
# error <openssl/des_old.h> replaces <kerberos/des.h>.
|
||||
# endif
|
||||
|
||||
# include <openssl/symhacks.h>
|
||||
|
||||
# ifdef OPENSSL_BUILD_SHLIBCRYPTO
|
||||
# undef OPENSSL_EXTERN
|
||||
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# ifdef _
|
||||
# undef _
|
||||
# endif
|
||||
|
||||
typedef unsigned char _ossl_old_des_cblock[8];
|
||||
typedef struct _ossl_old_des_ks_struct {
|
||||
union {
|
||||
_ossl_old_des_cblock _;
|
||||
/*
|
||||
* make sure things are correct size on machines with 8 byte longs
|
||||
*/
|
||||
DES_LONG pad[2];
|
||||
} ks;
|
||||
} _ossl_old_des_key_schedule[16];
|
||||
|
||||
# ifndef OPENSSL_DES_LIBDES_COMPATIBILITY
|
||||
# define des_cblock DES_cblock
|
||||
# define const_des_cblock const_DES_cblock
|
||||
# define des_key_schedule DES_key_schedule
|
||||
# define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
|
||||
DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e))
|
||||
# define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
|
||||
DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e))
|
||||
# define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\
|
||||
DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e))
|
||||
# define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
|
||||
DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e))
|
||||
# define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
|
||||
DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n))
|
||||
# define des_options()\
|
||||
DES_options()
|
||||
# define des_cbc_cksum(i,o,l,k,iv)\
|
||||
DES_cbc_cksum((i),(o),(l),&(k),(iv))
|
||||
# define des_cbc_encrypt(i,o,l,k,iv,e)\
|
||||
DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))
|
||||
# define des_ncbc_encrypt(i,o,l,k,iv,e)\
|
||||
DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e))
|
||||
# define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
|
||||
DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e))
|
||||
# define des_cfb_encrypt(i,o,n,l,k,iv,e)\
|
||||
DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e))
|
||||
# define des_ecb_encrypt(i,o,k,e)\
|
||||
DES_ecb_encrypt((i),(o),&(k),(e))
|
||||
# define des_encrypt1(d,k,e)\
|
||||
DES_encrypt1((d),&(k),(e))
|
||||
# define des_encrypt2(d,k,e)\
|
||||
DES_encrypt2((d),&(k),(e))
|
||||
# define des_encrypt3(d,k1,k2,k3)\
|
||||
DES_encrypt3((d),&(k1),&(k2),&(k3))
|
||||
# define des_decrypt3(d,k1,k2,k3)\
|
||||
DES_decrypt3((d),&(k1),&(k2),&(k3))
|
||||
# define des_xwhite_in2out(k,i,o)\
|
||||
DES_xwhite_in2out((k),(i),(o))
|
||||
# define des_enc_read(f,b,l,k,iv)\
|
||||
DES_enc_read((f),(b),(l),&(k),(iv))
|
||||
# define des_enc_write(f,b,l,k,iv)\
|
||||
DES_enc_write((f),(b),(l),&(k),(iv))
|
||||
# define des_fcrypt(b,s,r)\
|
||||
DES_fcrypt((b),(s),(r))
|
||||
# if 0
|
||||
# define des_crypt(b,s)\
|
||||
DES_crypt((b),(s))
|
||||
# if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
|
||||
# define crypt(b,s)\
|
||||
DES_crypt((b),(s))
|
||||
# endif
|
||||
# endif
|
||||
# define des_ofb_encrypt(i,o,n,l,k,iv)\
|
||||
DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))
|
||||
# define des_pcbc_encrypt(i,o,l,k,iv,e)\
|
||||
DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e))
|
||||
# define des_quad_cksum(i,o,l,c,s)\
|
||||
DES_quad_cksum((i),(o),(l),(c),(s))
|
||||
# define des_random_seed(k)\
|
||||
_ossl_096_des_random_seed((k))
|
||||
# define des_random_key(r)\
|
||||
DES_random_key((r))
|
||||
# define des_read_password(k,p,v) \
|
||||
DES_read_password((k),(p),(v))
|
||||
# define des_read_2passwords(k1,k2,p,v) \
|
||||
DES_read_2passwords((k1),(k2),(p),(v))
|
||||
# define des_set_odd_parity(k)\
|
||||
DES_set_odd_parity((k))
|
||||
# define des_check_key_parity(k)\
|
||||
DES_check_key_parity((k))
|
||||
# define des_is_weak_key(k)\
|
||||
DES_is_weak_key((k))
|
||||
# define des_set_key(k,ks)\
|
||||
DES_set_key((k),&(ks))
|
||||
# define des_key_sched(k,ks)\
|
||||
DES_key_sched((k),&(ks))
|
||||
# define des_set_key_checked(k,ks)\
|
||||
DES_set_key_checked((k),&(ks))
|
||||
# define des_set_key_unchecked(k,ks)\
|
||||
DES_set_key_unchecked((k),&(ks))
|
||||
# define des_string_to_key(s,k)\
|
||||
DES_string_to_key((s),(k))
|
||||
# define des_string_to_2keys(s,k1,k2)\
|
||||
DES_string_to_2keys((s),(k1),(k2))
|
||||
# define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
|
||||
DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e))
|
||||
# define des_ofb64_encrypt(i,o,l,ks,iv,n)\
|
||||
DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n))
|
||||
|
||||
# define des_ecb2_encrypt(i,o,k1,k2,e) \
|
||||
des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
|
||||
|
||||
# define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
|
||||
des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
|
||||
|
||||
# define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
|
||||
des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
|
||||
|
||||
# define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
|
||||
des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
|
||||
|
||||
# define des_check_key DES_check_key
|
||||
# define des_rw_mode DES_rw_mode
|
||||
# else /* libdes compatibility */
|
||||
/*
|
||||
* Map all symbol names to _ossl_old_des_* form, so we avoid all clashes with
|
||||
* libdes
|
||||
*/
|
||||
# define des_cblock _ossl_old_des_cblock
|
||||
# define des_key_schedule _ossl_old_des_key_schedule
|
||||
# define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
|
||||
_ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))
|
||||
# define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
|
||||
_ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))
|
||||
# define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
|
||||
_ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e))
|
||||
# define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
|
||||
_ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))
|
||||
# define des_options()\
|
||||
_ossl_old_des_options()
|
||||
# define des_cbc_cksum(i,o,l,k,iv)\
|
||||
_ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))
|
||||
# define des_cbc_encrypt(i,o,l,k,iv,e)\
|
||||
_ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))
|
||||
# define des_ncbc_encrypt(i,o,l,k,iv,e)\
|
||||
_ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))
|
||||
# define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
|
||||
_ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))
|
||||
# define des_cfb_encrypt(i,o,n,l,k,iv,e)\
|
||||
_ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e))
|
||||
# define des_ecb_encrypt(i,o,k,e)\
|
||||
_ossl_old_des_ecb_encrypt((i),(o),(k),(e))
|
||||
# define des_encrypt(d,k,e)\
|
||||
_ossl_old_des_encrypt((d),(k),(e))
|
||||
# define des_encrypt2(d,k,e)\
|
||||
_ossl_old_des_encrypt2((d),(k),(e))
|
||||
# define des_encrypt3(d,k1,k2,k3)\
|
||||
_ossl_old_des_encrypt3((d),(k1),(k2),(k3))
|
||||
# define des_decrypt3(d,k1,k2,k3)\
|
||||
_ossl_old_des_decrypt3((d),(k1),(k2),(k3))
|
||||
# define des_xwhite_in2out(k,i,o)\
|
||||
_ossl_old_des_xwhite_in2out((k),(i),(o))
|
||||
# define des_enc_read(f,b,l,k,iv)\
|
||||
_ossl_old_des_enc_read((f),(b),(l),(k),(iv))
|
||||
# define des_enc_write(f,b,l,k,iv)\
|
||||
_ossl_old_des_enc_write((f),(b),(l),(k),(iv))
|
||||
# define des_fcrypt(b,s,r)\
|
||||
_ossl_old_des_fcrypt((b),(s),(r))
|
||||
# define des_crypt(b,s)\
|
||||
_ossl_old_des_crypt((b),(s))
|
||||
# if 0
|
||||
# define crypt(b,s)\
|
||||
_ossl_old_crypt((b),(s))
|
||||
# endif
|
||||
# define des_ofb_encrypt(i,o,n,l,k,iv)\
|
||||
_ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))
|
||||
# define des_pcbc_encrypt(i,o,l,k,iv,e)\
|
||||
_ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))
|
||||
# define des_quad_cksum(i,o,l,c,s)\
|
||||
_ossl_old_des_quad_cksum((i),(o),(l),(c),(s))
|
||||
# define des_random_seed(k)\
|
||||
_ossl_old_des_random_seed((k))
|
||||
# define des_random_key(r)\
|
||||
_ossl_old_des_random_key((r))
|
||||
# define des_read_password(k,p,v) \
|
||||
_ossl_old_des_read_password((k),(p),(v))
|
||||
# define des_read_2passwords(k1,k2,p,v) \
|
||||
_ossl_old_des_read_2passwords((k1),(k2),(p),(v))
|
||||
# define des_set_odd_parity(k)\
|
||||
_ossl_old_des_set_odd_parity((k))
|
||||
# define des_is_weak_key(k)\
|
||||
_ossl_old_des_is_weak_key((k))
|
||||
# define des_set_key(k,ks)\
|
||||
_ossl_old_des_set_key((k),(ks))
|
||||
# define des_key_sched(k,ks)\
|
||||
_ossl_old_des_key_sched((k),(ks))
|
||||
# define des_string_to_key(s,k)\
|
||||
_ossl_old_des_string_to_key((s),(k))
|
||||
# define des_string_to_2keys(s,k1,k2)\
|
||||
_ossl_old_des_string_to_2keys((s),(k1),(k2))
|
||||
# define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
|
||||
_ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))
|
||||
# define des_ofb64_encrypt(i,o,l,ks,iv,n)\
|
||||
_ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))
|
||||
|
||||
# define des_ecb2_encrypt(i,o,k1,k2,e) \
|
||||
des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
|
||||
|
||||
# define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
|
||||
des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
|
||||
|
||||
# define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
|
||||
des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
|
||||
|
||||
# define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
|
||||
des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
|
||||
|
||||
# define des_check_key DES_check_key
|
||||
# define des_rw_mode DES_rw_mode
|
||||
# endif
|
||||
|
||||
const char *_ossl_old_des_options(void);
|
||||
void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,
|
||||
_ossl_old_des_cblock *output,
|
||||
_ossl_old_des_key_schedule ks1,
|
||||
_ossl_old_des_key_schedule ks2,
|
||||
_ossl_old_des_key_schedule ks3, int enc);
|
||||
DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,
|
||||
_ossl_old_des_cblock *output, long length,
|
||||
_ossl_old_des_key_schedule schedule,
|
||||
_ossl_old_des_cblock *ivec);
|
||||
void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,
|
||||
_ossl_old_des_cblock *output, long length,
|
||||
_ossl_old_des_key_schedule schedule,
|
||||
_ossl_old_des_cblock *ivec, int enc);
|
||||
void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,
|
||||
_ossl_old_des_cblock *output, long length,
|
||||
_ossl_old_des_key_schedule schedule,
|
||||
_ossl_old_des_cblock *ivec, int enc);
|
||||
void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,
|
||||
_ossl_old_des_cblock *output, long length,
|
||||
_ossl_old_des_key_schedule schedule,
|
||||
_ossl_old_des_cblock *ivec,
|
||||
_ossl_old_des_cblock *inw,
|
||||
_ossl_old_des_cblock *outw, int enc);
|
||||
void _ossl_old_des_cfb_encrypt(unsigned char *in, unsigned char *out,
|
||||
int numbits, long length,
|
||||
_ossl_old_des_key_schedule schedule,
|
||||
_ossl_old_des_cblock *ivec, int enc);
|
||||
void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,
|
||||
_ossl_old_des_cblock *output,
|
||||
_ossl_old_des_key_schedule ks, int enc);
|
||||
void _ossl_old_des_encrypt(DES_LONG *data, _ossl_old_des_key_schedule ks,
|
||||
int enc);
|
||||
void _ossl_old_des_encrypt2(DES_LONG *data, _ossl_old_des_key_schedule ks,
|
||||
int enc);
|
||||
void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
|
||||
_ossl_old_des_key_schedule ks2,
|
||||
_ossl_old_des_key_schedule ks3);
|
||||
void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
|
||||
_ossl_old_des_key_schedule ks2,
|
||||
_ossl_old_des_key_schedule ks3);
|
||||
void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input,
|
||||
_ossl_old_des_cblock *output, long length,
|
||||
_ossl_old_des_key_schedule ks1,
|
||||
_ossl_old_des_key_schedule ks2,
|
||||
_ossl_old_des_key_schedule ks3,
|
||||
_ossl_old_des_cblock *ivec, int enc);
|
||||
void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length,
|
||||
_ossl_old_des_key_schedule ks1,
|
||||
_ossl_old_des_key_schedule ks2,
|
||||
_ossl_old_des_key_schedule ks3,
|
||||
_ossl_old_des_cblock *ivec, int *num,
|
||||
int enc);
|
||||
void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length,
|
||||
_ossl_old_des_key_schedule ks1,
|
||||
_ossl_old_des_key_schedule ks2,
|
||||
_ossl_old_des_key_schedule ks3,
|
||||
_ossl_old_des_cblock *ivec, int *num);
|
||||
# if 0
|
||||
void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key),
|
||||
_ossl_old_des_cblock (*in_white),
|
||||
_ossl_old_des_cblock (*out_white));
|
||||
# endif
|
||||
|
||||
int _ossl_old_des_enc_read(int fd, char *buf, int len,
|
||||
_ossl_old_des_key_schedule sched,
|
||||
_ossl_old_des_cblock *iv);
|
||||
int _ossl_old_des_enc_write(int fd, char *buf, int len,
|
||||
_ossl_old_des_key_schedule sched,
|
||||
_ossl_old_des_cblock *iv);
|
||||
char *_ossl_old_des_fcrypt(const char *buf, const char *salt, char *ret);
|
||||
char *_ossl_old_des_crypt(const char *buf, const char *salt);
|
||||
# if !defined(PERL5) && !defined(NeXT)
|
||||
char *_ossl_old_crypt(const char *buf, const char *salt);
|
||||
# endif
|
||||
void _ossl_old_des_ofb_encrypt(unsigned char *in, unsigned char *out,
|
||||
int numbits, long length,
|
||||
_ossl_old_des_key_schedule schedule,
|
||||
_ossl_old_des_cblock *ivec);
|
||||
void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,
|
||||
_ossl_old_des_cblock *output, long length,
|
||||
_ossl_old_des_key_schedule schedule,
|
||||
_ossl_old_des_cblock *ivec, int enc);
|
||||
DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,
|
||||
_ossl_old_des_cblock *output, long length,
|
||||
int out_count, _ossl_old_des_cblock *seed);
|
||||
void _ossl_old_des_random_seed(_ossl_old_des_cblock key);
|
||||
void _ossl_old_des_random_key(_ossl_old_des_cblock ret);
|
||||
int _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,
|
||||
int verify);
|
||||
int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,
|
||||
_ossl_old_des_cblock *key2,
|
||||
const char *prompt, int verify);
|
||||
void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);
|
||||
int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);
|
||||
int _ossl_old_des_set_key(_ossl_old_des_cblock *key,
|
||||
_ossl_old_des_key_schedule schedule);
|
||||
int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,
|
||||
_ossl_old_des_key_schedule schedule);
|
||||
void _ossl_old_des_string_to_key(char *str, _ossl_old_des_cblock *key);
|
||||
void _ossl_old_des_string_to_2keys(char *str, _ossl_old_des_cblock *key1,
|
||||
_ossl_old_des_cblock *key2);
|
||||
void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length,
|
||||
_ossl_old_des_key_schedule schedule,
|
||||
_ossl_old_des_cblock *ivec, int *num,
|
||||
int enc);
|
||||
void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length,
|
||||
_ossl_old_des_key_schedule schedule,
|
||||
_ossl_old_des_cblock *ivec, int *num);
|
||||
|
||||
void _ossl_096_des_random_seed(des_cblock *key);
|
||||
|
||||
/*
|
||||
* The following definitions provide compatibility with the MIT Kerberos
|
||||
* library. The _ossl_old_des_key_schedule structure is not binary
|
||||
* compatible.
|
||||
*/
|
||||
|
||||
# define _KERBEROS_DES_H
|
||||
|
||||
# define KRBDES_ENCRYPT DES_ENCRYPT
|
||||
# define KRBDES_DECRYPT DES_DECRYPT
|
||||
|
||||
# ifdef KERBEROS
|
||||
# define ENCRYPT DES_ENCRYPT
|
||||
# define DECRYPT DES_DECRYPT
|
||||
# endif
|
||||
|
||||
# ifndef NCOMPAT
|
||||
# define C_Block des_cblock
|
||||
# define Key_schedule des_key_schedule
|
||||
# define KEY_SZ DES_KEY_SZ
|
||||
# define string_to_key des_string_to_key
|
||||
# define read_pw_string des_read_pw_string
|
||||
# define random_key des_random_key
|
||||
# define pcbc_encrypt des_pcbc_encrypt
|
||||
# define set_key des_set_key
|
||||
# define key_sched des_key_sched
|
||||
# define ecb_encrypt des_ecb_encrypt
|
||||
# define cbc_encrypt des_cbc_encrypt
|
||||
# define ncbc_encrypt des_ncbc_encrypt
|
||||
# define xcbc_encrypt des_xcbc_encrypt
|
||||
# define cbc_cksum des_cbc_cksum
|
||||
# define quad_cksum des_quad_cksum
|
||||
# define check_parity des_check_key_parity
|
||||
# endif
|
||||
|
||||
# define des_fixup_key_parity DES_fixup_key_parity
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* for DES_read_pw_string et al */
|
||||
# include <openssl/ui_compat.h>
|
||||
|
||||
#endif
|
393
sgx-jvm/dependencies/root/usr/include/openssl/dh.h
Normal file
393
sgx-jvm/dependencies/root/usr/include/openssl/dh.h
Normal file
@ -0,0 +1,393 @@
|
||||
/* crypto/dh/dh.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DH_H
|
||||
# define HEADER_DH_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# ifdef OPENSSL_NO_DH
|
||||
# error DH is disabled.
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_NO_BIO
|
||||
# include <openssl/bio.h>
|
||||
# endif
|
||||
# include <openssl/ossl_typ.h>
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
# include <openssl/bn.h>
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_DH_MAX_MODULUS_BITS
|
||||
# define OPENSSL_DH_MAX_MODULUS_BITS 10000
|
||||
# endif
|
||||
|
||||
# define DH_FLAG_CACHE_MONT_P 0x01
|
||||
|
||||
/*
|
||||
* new with 0.9.7h; the built-in DH
|
||||
* implementation now uses constant time
|
||||
* modular exponentiation for secret exponents
|
||||
* by default. This flag causes the
|
||||
* faster variable sliding window method to
|
||||
* be used for all exponents.
|
||||
*/
|
||||
# define DH_FLAG_NO_EXP_CONSTTIME 0x02
|
||||
|
||||
/*
|
||||
* If this flag is set the DH method is FIPS compliant and can be used in
|
||||
* FIPS mode. This is set in the validated module method. If an application
|
||||
* sets this flag in its own methods it is its reposibility to ensure the
|
||||
* result is compliant.
|
||||
*/
|
||||
|
||||
# define DH_FLAG_FIPS_METHOD 0x0400
|
||||
|
||||
/*
|
||||
* If this flag is set the operations normally disabled in FIPS mode are
|
||||
* permitted it is then the applications responsibility to ensure that the
|
||||
* usage is compliant.
|
||||
*/
|
||||
|
||||
# define DH_FLAG_NON_FIPS_ALLOW 0x0400
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Already defined in ossl_typ.h */
|
||||
/* typedef struct dh_st DH; */
|
||||
/* typedef struct dh_method DH_METHOD; */
|
||||
|
||||
struct dh_method {
|
||||
const char *name;
|
||||
/* Methods here */
|
||||
int (*generate_key) (DH *dh);
|
||||
int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh);
|
||||
/* Can be null */
|
||||
int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a,
|
||||
const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
|
||||
BN_MONT_CTX *m_ctx);
|
||||
int (*init) (DH *dh);
|
||||
int (*finish) (DH *dh);
|
||||
int flags;
|
||||
char *app_data;
|
||||
/* If this is non-NULL, it will be used to generate parameters */
|
||||
int (*generate_params) (DH *dh, int prime_len, int generator,
|
||||
BN_GENCB *cb);
|
||||
};
|
||||
|
||||
struct dh_st {
|
||||
/*
|
||||
* This first argument is used to pick up errors when a DH is passed
|
||||
* instead of a EVP_PKEY
|
||||
*/
|
||||
int pad;
|
||||
int version;
|
||||
BIGNUM *p;
|
||||
BIGNUM *g;
|
||||
long length; /* optional */
|
||||
BIGNUM *pub_key; /* g^x % p */
|
||||
BIGNUM *priv_key; /* x */
|
||||
int flags;
|
||||
BN_MONT_CTX *method_mont_p;
|
||||
/* Place holders if we want to do X9.42 DH */
|
||||
BIGNUM *q;
|
||||
BIGNUM *j;
|
||||
unsigned char *seed;
|
||||
int seedlen;
|
||||
BIGNUM *counter;
|
||||
int references;
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
const DH_METHOD *meth;
|
||||
ENGINE *engine;
|
||||
};
|
||||
|
||||
# define DH_GENERATOR_2 2
|
||||
/* #define DH_GENERATOR_3 3 */
|
||||
# define DH_GENERATOR_5 5
|
||||
|
||||
/* DH_check error codes */
|
||||
# define DH_CHECK_P_NOT_PRIME 0x01
|
||||
# define DH_CHECK_P_NOT_SAFE_PRIME 0x02
|
||||
# define DH_UNABLE_TO_CHECK_GENERATOR 0x04
|
||||
# define DH_NOT_SUITABLE_GENERATOR 0x08
|
||||
# define DH_CHECK_Q_NOT_PRIME 0x10
|
||||
# define DH_CHECK_INVALID_Q_VALUE 0x20
|
||||
# define DH_CHECK_INVALID_J_VALUE 0x40
|
||||
|
||||
/* DH_check_pub_key error codes */
|
||||
# define DH_CHECK_PUBKEY_TOO_SMALL 0x01
|
||||
# define DH_CHECK_PUBKEY_TOO_LARGE 0x02
|
||||
# define DH_CHECK_PUBKEY_INVALID 0x04
|
||||
|
||||
/*
|
||||
* primes p where (p-1)/2 is prime too are called "safe"; we define this for
|
||||
* backward compatibility:
|
||||
*/
|
||||
# define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
|
||||
|
||||
# define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
|
||||
(char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
|
||||
# define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
|
||||
(unsigned char *)(x))
|
||||
# define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
|
||||
# define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
|
||||
|
||||
DH *DHparams_dup(DH *);
|
||||
|
||||
const DH_METHOD *DH_OpenSSL(void);
|
||||
|
||||
void DH_set_default_method(const DH_METHOD *meth);
|
||||
const DH_METHOD *DH_get_default_method(void);
|
||||
int DH_set_method(DH *dh, const DH_METHOD *meth);
|
||||
DH *DH_new_method(ENGINE *engine);
|
||||
|
||||
DH *DH_new(void);
|
||||
void DH_free(DH *dh);
|
||||
int DH_up_ref(DH *dh);
|
||||
int DH_size(const DH *dh);
|
||||
int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
|
||||
int DH_set_ex_data(DH *d, int idx, void *arg);
|
||||
void *DH_get_ex_data(DH *d, int idx);
|
||||
|
||||
/* Deprecated version */
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
DH *DH_generate_parameters(int prime_len, int generator,
|
||||
void (*callback) (int, int, void *), void *cb_arg);
|
||||
# endif /* !defined(OPENSSL_NO_DEPRECATED) */
|
||||
|
||||
/* New version */
|
||||
int DH_generate_parameters_ex(DH *dh, int prime_len, int generator,
|
||||
BN_GENCB *cb);
|
||||
|
||||
int DH_check(const DH *dh, int *codes);
|
||||
int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes);
|
||||
int DH_generate_key(DH *dh);
|
||||
int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
|
||||
int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);
|
||||
DH *d2i_DHparams(DH **a, const unsigned char **pp, long length);
|
||||
int i2d_DHparams(const DH *a, unsigned char **pp);
|
||||
DH *d2i_DHxparams(DH **a, const unsigned char **pp, long length);
|
||||
int i2d_DHxparams(const DH *a, unsigned char **pp);
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
int DHparams_print_fp(FILE *fp, const DH *x);
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_BIO
|
||||
int DHparams_print(BIO *bp, const DH *x);
|
||||
# else
|
||||
int DHparams_print(char *bp, const DH *x);
|
||||
# endif
|
||||
|
||||
/* RFC 5114 parameters */
|
||||
DH *DH_get_1024_160(void);
|
||||
DH *DH_get_2048_224(void);
|
||||
DH *DH_get_2048_256(void);
|
||||
|
||||
/* RFC2631 KDF */
|
||||
int DH_KDF_X9_42(unsigned char *out, size_t outlen,
|
||||
const unsigned char *Z, size_t Zlen,
|
||||
ASN1_OBJECT *key_oid,
|
||||
const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)oid)
|
||||
|
||||
# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)poid)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)md)
|
||||
|
||||
# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)pmd)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)plen)
|
||||
|
||||
# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)p)
|
||||
|
||||
# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)p)
|
||||
|
||||
# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1)
|
||||
# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2)
|
||||
# define EVP_PKEY_CTRL_DH_RFC5114 (EVP_PKEY_ALG_CTRL + 3)
|
||||
# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN (EVP_PKEY_ALG_CTRL + 4)
|
||||
# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE (EVP_PKEY_ALG_CTRL + 5)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_TYPE (EVP_PKEY_ALG_CTRL + 6)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 7)
|
||||
# define EVP_PKEY_CTRL_GET_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 8)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 9)
|
||||
# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 10)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 11)
|
||||
# define EVP_PKEY_CTRL_GET_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 12)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13)
|
||||
# define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14)
|
||||
|
||||
/* KDF types */
|
||||
# define EVP_PKEY_DH_KDF_NONE 1
|
||||
# define EVP_PKEY_DH_KDF_X9_42 2
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_DH_strings(void);
|
||||
|
||||
/* Error codes for the DH functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define DH_F_COMPUTE_KEY 102
|
||||
# define DH_F_DHPARAMS_PRINT_FP 101
|
||||
# define DH_F_DH_BUILTIN_GENPARAMS 106
|
||||
# define DH_F_DH_CMS_DECRYPT 117
|
||||
# define DH_F_DH_CMS_SET_PEERKEY 118
|
||||
# define DH_F_DH_CMS_SET_SHARED_INFO 119
|
||||
# define DH_F_DH_COMPUTE_KEY 114
|
||||
# define DH_F_DH_GENERATE_KEY 115
|
||||
# define DH_F_DH_GENERATE_PARAMETERS_EX 116
|
||||
# define DH_F_DH_NEW_METHOD 105
|
||||
# define DH_F_DH_PARAM_DECODE 107
|
||||
# define DH_F_DH_PRIV_DECODE 110
|
||||
# define DH_F_DH_PRIV_ENCODE 111
|
||||
# define DH_F_DH_PUB_DECODE 108
|
||||
# define DH_F_DH_PUB_ENCODE 109
|
||||
# define DH_F_DO_DH_PRINT 100
|
||||
# define DH_F_GENERATE_KEY 103
|
||||
# define DH_F_GENERATE_PARAMETERS 104
|
||||
# define DH_F_PKEY_DH_DERIVE 112
|
||||
# define DH_F_PKEY_DH_KEYGEN 113
|
||||
|
||||
/* Reason codes. */
|
||||
# define DH_R_BAD_GENERATOR 101
|
||||
# define DH_R_BN_DECODE_ERROR 109
|
||||
# define DH_R_BN_ERROR 106
|
||||
# define DH_R_DECODE_ERROR 104
|
||||
# define DH_R_INVALID_PUBKEY 102
|
||||
# define DH_R_KDF_PARAMETER_ERROR 112
|
||||
# define DH_R_KEYS_NOT_SET 108
|
||||
# define DH_R_KEY_SIZE_TOO_SMALL 110
|
||||
# define DH_R_MODULUS_TOO_LARGE 103
|
||||
# define DH_R_NON_FIPS_METHOD 111
|
||||
# define DH_R_NO_PARAMETERS_SET 107
|
||||
# define DH_R_NO_PRIVATE_VALUE 100
|
||||
# define DH_R_PARAMETER_ENCODING_ERROR 105
|
||||
# define DH_R_PEER_KEY_ERROR 113
|
||||
# define DH_R_SHARED_INFO_ERROR 114
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
332
sgx-jvm/dependencies/root/usr/include/openssl/dsa.h
Normal file
332
sgx-jvm/dependencies/root/usr/include/openssl/dsa.h
Normal file
@ -0,0 +1,332 @@
|
||||
/* crypto/dsa/dsa.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/*
|
||||
* The DSS routines are based on patches supplied by
|
||||
* Steven Schoch <schoch@sheba.arc.nasa.gov>. He basically did the
|
||||
* work and I have just tweaked them a little to fit into my
|
||||
* stylistic vision for SSLeay :-) */
|
||||
|
||||
#ifndef HEADER_DSA_H
|
||||
# define HEADER_DSA_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# ifdef OPENSSL_NO_DSA
|
||||
# error DSA is disabled.
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_NO_BIO
|
||||
# include <openssl/bio.h>
|
||||
# endif
|
||||
# include <openssl/crypto.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
# include <openssl/bn.h>
|
||||
# ifndef OPENSSL_NO_DH
|
||||
# include <openssl/dh.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_DSA_MAX_MODULUS_BITS
|
||||
# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
|
||||
# endif
|
||||
|
||||
# define DSA_FLAG_CACHE_MONT_P 0x01
|
||||
/*
|
||||
* new with 0.9.7h; the built-in DSA implementation now uses constant time
|
||||
* modular exponentiation for secret exponents by default. This flag causes
|
||||
* the faster variable sliding window method to be used for all exponents.
|
||||
*/
|
||||
# define DSA_FLAG_NO_EXP_CONSTTIME 0x02
|
||||
|
||||
/*
|
||||
* If this flag is set the DSA method is FIPS compliant and can be used in
|
||||
* FIPS mode. This is set in the validated module method. If an application
|
||||
* sets this flag in its own methods it is its reposibility to ensure the
|
||||
* result is compliant.
|
||||
*/
|
||||
|
||||
# define DSA_FLAG_FIPS_METHOD 0x0400
|
||||
|
||||
/*
|
||||
* If this flag is set the operations normally disabled in FIPS mode are
|
||||
* permitted it is then the applications responsibility to ensure that the
|
||||
* usage is compliant.
|
||||
*/
|
||||
|
||||
# define DSA_FLAG_NON_FIPS_ALLOW 0x0400
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Already defined in ossl_typ.h */
|
||||
/* typedef struct dsa_st DSA; */
|
||||
/* typedef struct dsa_method DSA_METHOD; */
|
||||
|
||||
typedef struct DSA_SIG_st {
|
||||
BIGNUM *r;
|
||||
BIGNUM *s;
|
||||
} DSA_SIG;
|
||||
|
||||
struct dsa_method {
|
||||
const char *name;
|
||||
DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);
|
||||
int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
|
||||
BIGNUM **rp);
|
||||
int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,
|
||||
DSA_SIG *sig, DSA *dsa);
|
||||
int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
|
||||
BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
|
||||
BN_MONT_CTX *in_mont);
|
||||
/* Can be null */
|
||||
int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int (*init) (DSA *dsa);
|
||||
int (*finish) (DSA *dsa);
|
||||
int flags;
|
||||
char *app_data;
|
||||
/* If this is non-NULL, it is used to generate DSA parameters */
|
||||
int (*dsa_paramgen) (DSA *dsa, int bits,
|
||||
const unsigned char *seed, int seed_len,
|
||||
int *counter_ret, unsigned long *h_ret,
|
||||
BN_GENCB *cb);
|
||||
/* If this is non-NULL, it is used to generate DSA keys */
|
||||
int (*dsa_keygen) (DSA *dsa);
|
||||
};
|
||||
|
||||
struct dsa_st {
|
||||
/*
|
||||
* This first variable is used to pick up errors where a DSA is passed
|
||||
* instead of of a EVP_PKEY
|
||||
*/
|
||||
int pad;
|
||||
long version;
|
||||
int write_params;
|
||||
BIGNUM *p;
|
||||
BIGNUM *q; /* == 20 */
|
||||
BIGNUM *g;
|
||||
BIGNUM *pub_key; /* y public key */
|
||||
BIGNUM *priv_key; /* x private key */
|
||||
BIGNUM *kinv; /* Signing pre-calc */
|
||||
BIGNUM *r; /* Signing pre-calc */
|
||||
int flags;
|
||||
/* Normally used to cache montgomery values */
|
||||
BN_MONT_CTX *method_mont_p;
|
||||
int references;
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
const DSA_METHOD *meth;
|
||||
/* functional reference if 'meth' is ENGINE-provided */
|
||||
ENGINE *engine;
|
||||
};
|
||||
|
||||
# define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
|
||||
(char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))
|
||||
# define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \
|
||||
(unsigned char *)(x))
|
||||
# define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)
|
||||
# define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)
|
||||
|
||||
DSA *DSAparams_dup(DSA *x);
|
||||
DSA_SIG *DSA_SIG_new(void);
|
||||
void DSA_SIG_free(DSA_SIG *a);
|
||||
int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
|
||||
DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
|
||||
|
||||
DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
|
||||
int DSA_do_verify(const unsigned char *dgst, int dgst_len,
|
||||
DSA_SIG *sig, DSA *dsa);
|
||||
|
||||
const DSA_METHOD *DSA_OpenSSL(void);
|
||||
|
||||
void DSA_set_default_method(const DSA_METHOD *);
|
||||
const DSA_METHOD *DSA_get_default_method(void);
|
||||
int DSA_set_method(DSA *dsa, const DSA_METHOD *);
|
||||
|
||||
DSA *DSA_new(void);
|
||||
DSA *DSA_new_method(ENGINE *engine);
|
||||
void DSA_free(DSA *r);
|
||||
/* "up" the DSA object's reference count */
|
||||
int DSA_up_ref(DSA *r);
|
||||
int DSA_size(const DSA *);
|
||||
/* next 4 return -1 on error */
|
||||
int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
|
||||
int DSA_sign(int type, const unsigned char *dgst, int dlen,
|
||||
unsigned char *sig, unsigned int *siglen, DSA *dsa);
|
||||
int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
|
||||
const unsigned char *sigbuf, int siglen, DSA *dsa);
|
||||
int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
|
||||
int DSA_set_ex_data(DSA *d, int idx, void *arg);
|
||||
void *DSA_get_ex_data(DSA *d, int idx);
|
||||
|
||||
DSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
|
||||
DSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
|
||||
DSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
|
||||
|
||||
/* Deprecated version */
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
DSA *DSA_generate_parameters(int bits,
|
||||
unsigned char *seed, int seed_len,
|
||||
int *counter_ret, unsigned long *h_ret, void
|
||||
(*callback) (int, int, void *), void *cb_arg);
|
||||
# endif /* !defined(OPENSSL_NO_DEPRECATED) */
|
||||
|
||||
/* New version */
|
||||
int DSA_generate_parameters_ex(DSA *dsa, int bits,
|
||||
const unsigned char *seed, int seed_len,
|
||||
int *counter_ret, unsigned long *h_ret,
|
||||
BN_GENCB *cb);
|
||||
|
||||
int DSA_generate_key(DSA *a);
|
||||
int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
|
||||
int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
|
||||
int i2d_DSAparams(const DSA *a, unsigned char **pp);
|
||||
|
||||
# ifndef OPENSSL_NO_BIO
|
||||
int DSAparams_print(BIO *bp, const DSA *x);
|
||||
int DSA_print(BIO *bp, const DSA *x, int off);
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
int DSAparams_print_fp(FILE *fp, const DSA *x);
|
||||
int DSA_print_fp(FILE *bp, const DSA *x, int off);
|
||||
# endif
|
||||
|
||||
# define DSS_prime_checks 50
|
||||
/*
|
||||
* Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of
|
||||
* Rabin-Miller
|
||||
*/
|
||||
# define DSA_is_prime(n, callback, cb_arg) \
|
||||
BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
|
||||
|
||||
# ifndef OPENSSL_NO_DH
|
||||
/*
|
||||
* Convert DSA structure (key or just parameters) into DH structure (be
|
||||
* careful to avoid small subgroup attacks when using this!)
|
||||
*/
|
||||
DH *DSA_dup_DH(const DSA *r);
|
||||
# endif
|
||||
|
||||
# define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)
|
||||
|
||||
# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1)
|
||||
# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2)
|
||||
# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3)
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_DSA_strings(void);
|
||||
|
||||
/* Error codes for the DSA functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define DSA_F_D2I_DSA_SIG 110
|
||||
# define DSA_F_DO_DSA_PRINT 104
|
||||
# define DSA_F_DSAPARAMS_PRINT 100
|
||||
# define DSA_F_DSAPARAMS_PRINT_FP 101
|
||||
# define DSA_F_DSA_BUILTIN_PARAMGEN2 126
|
||||
# define DSA_F_DSA_DO_SIGN 112
|
||||
# define DSA_F_DSA_DO_VERIFY 113
|
||||
# define DSA_F_DSA_GENERATE_KEY 124
|
||||
# define DSA_F_DSA_GENERATE_PARAMETERS_EX 123
|
||||
# define DSA_F_DSA_NEW_METHOD 103
|
||||
# define DSA_F_DSA_PARAM_DECODE 119
|
||||
# define DSA_F_DSA_PRINT_FP 105
|
||||
# define DSA_F_DSA_PRIV_DECODE 115
|
||||
# define DSA_F_DSA_PRIV_ENCODE 116
|
||||
# define DSA_F_DSA_PUB_DECODE 117
|
||||
# define DSA_F_DSA_PUB_ENCODE 118
|
||||
# define DSA_F_DSA_SIGN 106
|
||||
# define DSA_F_DSA_SIGN_SETUP 107
|
||||
# define DSA_F_DSA_SIG_NEW 109
|
||||
# define DSA_F_DSA_SIG_PRINT 125
|
||||
# define DSA_F_DSA_VERIFY 108
|
||||
# define DSA_F_I2D_DSA_SIG 111
|
||||
# define DSA_F_OLD_DSA_PRIV_DECODE 122
|
||||
# define DSA_F_PKEY_DSA_CTRL 120
|
||||
# define DSA_F_PKEY_DSA_KEYGEN 121
|
||||
# define DSA_F_SIG_CB 114
|
||||
|
||||
/* Reason codes. */
|
||||
# define DSA_R_BAD_Q_VALUE 102
|
||||
# define DSA_R_BN_DECODE_ERROR 108
|
||||
# define DSA_R_BN_ERROR 109
|
||||
# define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
|
||||
# define DSA_R_DECODE_ERROR 104
|
||||
# define DSA_R_INVALID_DIGEST_TYPE 106
|
||||
# define DSA_R_INVALID_PARAMETERS 112
|
||||
# define DSA_R_MISSING_PARAMETERS 101
|
||||
# define DSA_R_MODULUS_TOO_LARGE 103
|
||||
# define DSA_R_NEED_NEW_SETUP_VALUES 110
|
||||
# define DSA_R_NON_FIPS_DSA_METHOD 111
|
||||
# define DSA_R_NO_PARAMETERS_SET 107
|
||||
# define DSA_R_PARAMETER_ENCODING_ERROR 105
|
||||
# define DSA_R_Q_NOT_PRIME 113
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
451
sgx-jvm/dependencies/root/usr/include/openssl/dso.h
Normal file
451
sgx-jvm/dependencies/root/usr/include/openssl/dso.h
Normal file
@ -0,0 +1,451 @@
|
||||
/* dso.h */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DSO_H
|
||||
# define HEADER_DSO_H
|
||||
|
||||
# include <openssl/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* These values are used as commands to DSO_ctrl() */
|
||||
# define DSO_CTRL_GET_FLAGS 1
|
||||
# define DSO_CTRL_SET_FLAGS 2
|
||||
# define DSO_CTRL_OR_FLAGS 3
|
||||
|
||||
/*
|
||||
* By default, DSO_load() will translate the provided filename into a form
|
||||
* typical for the platform (more specifically the DSO_METHOD) using the
|
||||
* dso_name_converter function of the method. Eg. win32 will transform "blah"
|
||||
* into "blah.dll", and dlfcn will transform it into "libblah.so". The
|
||||
* behaviour can be overriden by setting the name_converter callback in the
|
||||
* DSO object (using DSO_set_name_converter()). This callback could even
|
||||
* utilise the DSO_METHOD's converter too if it only wants to override
|
||||
* behaviour for one or two possible DSO methods. However, the following flag
|
||||
* can be set in a DSO to prevent *any* native name-translation at all - eg.
|
||||
* if the caller has prompted the user for a path to a driver library so the
|
||||
* filename should be interpreted as-is.
|
||||
*/
|
||||
# define DSO_FLAG_NO_NAME_TRANSLATION 0x01
|
||||
/*
|
||||
* An extra flag to give if only the extension should be added as
|
||||
* translation. This is obviously only of importance on Unix and other
|
||||
* operating systems where the translation also may prefix the name with
|
||||
* something, like 'lib', and ignored everywhere else. This flag is also
|
||||
* ignored if DSO_FLAG_NO_NAME_TRANSLATION is used at the same time.
|
||||
*/
|
||||
# define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02
|
||||
|
||||
/*
|
||||
* The following flag controls the translation of symbol names to upper case.
|
||||
* This is currently only being implemented for OpenVMS.
|
||||
*/
|
||||
# define DSO_FLAG_UPCASE_SYMBOL 0x10
|
||||
|
||||
/*
|
||||
* This flag loads the library with public symbols. Meaning: The exported
|
||||
* symbols of this library are public to all libraries loaded after this
|
||||
* library. At the moment only implemented in unix.
|
||||
*/
|
||||
# define DSO_FLAG_GLOBAL_SYMBOLS 0x20
|
||||
|
||||
typedef void (*DSO_FUNC_TYPE) (void);
|
||||
|
||||
typedef struct dso_st DSO;
|
||||
|
||||
/*
|
||||
* The function prototype used for method functions (or caller-provided
|
||||
* callbacks) that transform filenames. They are passed a DSO structure
|
||||
* pointer (or NULL if they are to be used independantly of a DSO object) and
|
||||
* a filename to transform. They should either return NULL (if there is an
|
||||
* error condition) or a newly allocated string containing the transformed
|
||||
* form that the caller will need to free with OPENSSL_free() when done.
|
||||
*/
|
||||
typedef char *(*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *);
|
||||
/*
|
||||
* The function prototype used for method functions (or caller-provided
|
||||
* callbacks) that merge two file specifications. They are passed a DSO
|
||||
* structure pointer (or NULL if they are to be used independantly of a DSO
|
||||
* object) and two file specifications to merge. They should either return
|
||||
* NULL (if there is an error condition) or a newly allocated string
|
||||
* containing the result of merging that the caller will need to free with
|
||||
* OPENSSL_free() when done. Here, merging means that bits and pieces are
|
||||
* taken from each of the file specifications and added together in whatever
|
||||
* fashion that is sensible for the DSO method in question. The only rule
|
||||
* that really applies is that if the two specification contain pieces of the
|
||||
* same type, the copy from the first string takes priority. One could see
|
||||
* it as the first specification is the one given by the user and the second
|
||||
* being a bunch of defaults to add on if they're missing in the first.
|
||||
*/
|
||||
typedef char *(*DSO_MERGER_FUNC)(DSO *, const char *, const char *);
|
||||
|
||||
typedef struct dso_meth_st {
|
||||
const char *name;
|
||||
/*
|
||||
* Loads a shared library, NB: new DSO_METHODs must ensure that a
|
||||
* successful load populates the loaded_filename field, and likewise a
|
||||
* successful unload OPENSSL_frees and NULLs it out.
|
||||
*/
|
||||
int (*dso_load) (DSO *dso);
|
||||
/* Unloads a shared library */
|
||||
int (*dso_unload) (DSO *dso);
|
||||
/* Binds a variable */
|
||||
void *(*dso_bind_var) (DSO *dso, const char *symname);
|
||||
/*
|
||||
* Binds a function - assumes a return type of DSO_FUNC_TYPE. This should
|
||||
* be cast to the real function prototype by the caller. Platforms that
|
||||
* don't have compatible representations for different prototypes (this
|
||||
* is possible within ANSI C) are highly unlikely to have shared
|
||||
* libraries at all, let alone a DSO_METHOD implemented for them.
|
||||
*/
|
||||
DSO_FUNC_TYPE (*dso_bind_func) (DSO *dso, const char *symname);
|
||||
/* I don't think this would actually be used in any circumstances. */
|
||||
# if 0
|
||||
/* Unbinds a variable */
|
||||
int (*dso_unbind_var) (DSO *dso, char *symname, void *symptr);
|
||||
/* Unbinds a function */
|
||||
int (*dso_unbind_func) (DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
|
||||
# endif
|
||||
/*
|
||||
* The generic (yuck) "ctrl()" function. NB: Negative return values
|
||||
* (rather than zero) indicate errors.
|
||||
*/
|
||||
long (*dso_ctrl) (DSO *dso, int cmd, long larg, void *parg);
|
||||
/*
|
||||
* The default DSO_METHOD-specific function for converting filenames to a
|
||||
* canonical native form.
|
||||
*/
|
||||
DSO_NAME_CONVERTER_FUNC dso_name_converter;
|
||||
/*
|
||||
* The default DSO_METHOD-specific function for converting filenames to a
|
||||
* canonical native form.
|
||||
*/
|
||||
DSO_MERGER_FUNC dso_merger;
|
||||
/* [De]Initialisation handlers. */
|
||||
int (*init) (DSO *dso);
|
||||
int (*finish) (DSO *dso);
|
||||
/* Return pathname of the module containing location */
|
||||
int (*pathbyaddr) (void *addr, char *path, int sz);
|
||||
/* Perform global symbol lookup, i.e. among *all* modules */
|
||||
void *(*globallookup) (const char *symname);
|
||||
} DSO_METHOD;
|
||||
|
||||
/**********************************************************************/
|
||||
/* The low-level handle type used to refer to a loaded shared library */
|
||||
|
||||
struct dso_st {
|
||||
DSO_METHOD *meth;
|
||||
/*
|
||||
* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS doesn't use
|
||||
* anything but will need to cache the filename for use in the dso_bind
|
||||
* handler. All in all, let each method control its own destiny.
|
||||
* "Handles" and such go in a STACK.
|
||||
*/
|
||||
STACK_OF(void) *meth_data;
|
||||
int references;
|
||||
int flags;
|
||||
/*
|
||||
* For use by applications etc ... use this for your bits'n'pieces, don't
|
||||
* touch meth_data!
|
||||
*/
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
/*
|
||||
* If this callback function pointer is set to non-NULL, then it will be
|
||||
* used in DSO_load() in place of meth->dso_name_converter. NB: This
|
||||
* should normally set using DSO_set_name_converter().
|
||||
*/
|
||||
DSO_NAME_CONVERTER_FUNC name_converter;
|
||||
/*
|
||||
* If this callback function pointer is set to non-NULL, then it will be
|
||||
* used in DSO_load() in place of meth->dso_merger. NB: This should
|
||||
* normally set using DSO_set_merger().
|
||||
*/
|
||||
DSO_MERGER_FUNC merger;
|
||||
/*
|
||||
* This is populated with (a copy of) the platform-independant filename
|
||||
* used for this DSO.
|
||||
*/
|
||||
char *filename;
|
||||
/*
|
||||
* This is populated with (a copy of) the translated filename by which
|
||||
* the DSO was actually loaded. It is NULL iff the DSO is not currently
|
||||
* loaded. NB: This is here because the filename translation process may
|
||||
* involve a callback being invoked more than once not only to convert to
|
||||
* a platform-specific form, but also to try different filenames in the
|
||||
* process of trying to perform a load. As such, this variable can be
|
||||
* used to indicate (a) whether this DSO structure corresponds to a
|
||||
* loaded library or not, and (b) the filename with which it was actually
|
||||
* loaded.
|
||||
*/
|
||||
char *loaded_filename;
|
||||
};
|
||||
|
||||
DSO *DSO_new(void);
|
||||
DSO *DSO_new_method(DSO_METHOD *method);
|
||||
int DSO_free(DSO *dso);
|
||||
int DSO_flags(DSO *dso);
|
||||
int DSO_up_ref(DSO *dso);
|
||||
long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);
|
||||
|
||||
/*
|
||||
* This function sets the DSO's name_converter callback. If it is non-NULL,
|
||||
* then it will be used instead of the associated DSO_METHOD's function. If
|
||||
* oldcb is non-NULL then it is set to the function pointer value being
|
||||
* replaced. Return value is non-zero for success.
|
||||
*/
|
||||
int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,
|
||||
DSO_NAME_CONVERTER_FUNC *oldcb);
|
||||
/*
|
||||
* These functions can be used to get/set the platform-independant filename
|
||||
* used for a DSO. NB: set will fail if the DSO is already loaded.
|
||||
*/
|
||||
const char *DSO_get_filename(DSO *dso);
|
||||
int DSO_set_filename(DSO *dso, const char *filename);
|
||||
/*
|
||||
* This function will invoke the DSO's name_converter callback to translate a
|
||||
* filename, or if the callback isn't set it will instead use the DSO_METHOD's
|
||||
* converter. If "filename" is NULL, the "filename" in the DSO itself will be
|
||||
* used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is
|
||||
* simply duplicated. NB: This function is usually called from within a
|
||||
* DSO_METHOD during the processing of a DSO_load() call, and is exposed so
|
||||
* that caller-created DSO_METHODs can do the same thing. A non-NULL return
|
||||
* value will need to be OPENSSL_free()'d.
|
||||
*/
|
||||
char *DSO_convert_filename(DSO *dso, const char *filename);
|
||||
/*
|
||||
* This function will invoke the DSO's merger callback to merge two file
|
||||
* specifications, or if the callback isn't set it will instead use the
|
||||
* DSO_METHOD's merger. A non-NULL return value will need to be
|
||||
* OPENSSL_free()'d.
|
||||
*/
|
||||
char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2);
|
||||
/*
|
||||
* If the DSO is currently loaded, this returns the filename that it was
|
||||
* loaded under, otherwise it returns NULL. So it is also useful as a test as
|
||||
* to whether the DSO is currently loaded. NB: This will not necessarily
|
||||
* return the same value as DSO_convert_filename(dso, dso->filename), because
|
||||
* the DSO_METHOD's load function may have tried a variety of filenames (with
|
||||
* and/or without the aid of the converters) before settling on the one it
|
||||
* actually loaded.
|
||||
*/
|
||||
const char *DSO_get_loaded_filename(DSO *dso);
|
||||
|
||||
void DSO_set_default_method(DSO_METHOD *meth);
|
||||
DSO_METHOD *DSO_get_default_method(void);
|
||||
DSO_METHOD *DSO_get_method(DSO *dso);
|
||||
DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth);
|
||||
|
||||
/*
|
||||
* The all-singing all-dancing load function, you normally pass NULL for the
|
||||
* first and third parameters. Use DSO_up and DSO_free for subsequent
|
||||
* reference count handling. Any flags passed in will be set in the
|
||||
* constructed DSO after its init() function but before the load operation.
|
||||
* If 'dso' is non-NULL, 'flags' is ignored.
|
||||
*/
|
||||
DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags);
|
||||
|
||||
/* This function binds to a variable inside a shared library. */
|
||||
void *DSO_bind_var(DSO *dso, const char *symname);
|
||||
|
||||
/* This function binds to a function inside a shared library. */
|
||||
DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname);
|
||||
|
||||
/*
|
||||
* This method is the default, but will beg, borrow, or steal whatever method
|
||||
* should be the default on any particular platform (including
|
||||
* DSO_METH_null() if necessary).
|
||||
*/
|
||||
DSO_METHOD *DSO_METHOD_openssl(void);
|
||||
|
||||
/*
|
||||
* This method is defined for all platforms - if a platform has no DSO
|
||||
* support then this will be the only method!
|
||||
*/
|
||||
DSO_METHOD *DSO_METHOD_null(void);
|
||||
|
||||
/*
|
||||
* If DSO_DLFCN is defined, the standard dlfcn.h-style functions (dlopen,
|
||||
* dlclose, dlsym, etc) will be used and incorporated into this method. If
|
||||
* not, this method will return NULL.
|
||||
*/
|
||||
DSO_METHOD *DSO_METHOD_dlfcn(void);
|
||||
|
||||
/*
|
||||
* If DSO_DL is defined, the standard dl.h-style functions (shl_load,
|
||||
* shl_unload, shl_findsym, etc) will be used and incorporated into this
|
||||
* method. If not, this method will return NULL.
|
||||
*/
|
||||
DSO_METHOD *DSO_METHOD_dl(void);
|
||||
|
||||
/* If WIN32 is defined, use DLLs. If not, return NULL. */
|
||||
DSO_METHOD *DSO_METHOD_win32(void);
|
||||
|
||||
/* If VMS is defined, use shared images. If not, return NULL. */
|
||||
DSO_METHOD *DSO_METHOD_vms(void);
|
||||
|
||||
/*
|
||||
* This function writes null-terminated pathname of DSO module containing
|
||||
* 'addr' into 'sz' large caller-provided 'path' and returns the number of
|
||||
* characters [including trailing zero] written to it. If 'sz' is 0 or
|
||||
* negative, 'path' is ignored and required amount of charachers [including
|
||||
* trailing zero] to accomodate pathname is returned. If 'addr' is NULL, then
|
||||
* pathname of cryptolib itself is returned. Negative or zero return value
|
||||
* denotes error.
|
||||
*/
|
||||
int DSO_pathbyaddr(void *addr, char *path, int sz);
|
||||
|
||||
/*
|
||||
* This function should be used with caution! It looks up symbols in *all*
|
||||
* loaded modules and if module gets unloaded by somebody else attempt to
|
||||
* dereference the pointer is doomed to have fatal consequences. Primary
|
||||
* usage for this function is to probe *core* system functionality, e.g.
|
||||
* check if getnameinfo(3) is available at run-time without bothering about
|
||||
* OS-specific details such as libc.so.versioning or where does it actually
|
||||
* reside: in libc itself or libsocket.
|
||||
*/
|
||||
void *DSO_global_lookup(const char *name);
|
||||
|
||||
/* If BeOS is defined, use shared images. If not, return NULL. */
|
||||
DSO_METHOD *DSO_METHOD_beos(void);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_DSO_strings(void);
|
||||
|
||||
/* Error codes for the DSO functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define DSO_F_BEOS_BIND_FUNC 144
|
||||
# define DSO_F_BEOS_BIND_VAR 145
|
||||
# define DSO_F_BEOS_LOAD 146
|
||||
# define DSO_F_BEOS_NAME_CONVERTER 147
|
||||
# define DSO_F_BEOS_UNLOAD 148
|
||||
# define DSO_F_DLFCN_BIND_FUNC 100
|
||||
# define DSO_F_DLFCN_BIND_VAR 101
|
||||
# define DSO_F_DLFCN_LOAD 102
|
||||
# define DSO_F_DLFCN_MERGER 130
|
||||
# define DSO_F_DLFCN_NAME_CONVERTER 123
|
||||
# define DSO_F_DLFCN_UNLOAD 103
|
||||
# define DSO_F_DL_BIND_FUNC 104
|
||||
# define DSO_F_DL_BIND_VAR 105
|
||||
# define DSO_F_DL_LOAD 106
|
||||
# define DSO_F_DL_MERGER 131
|
||||
# define DSO_F_DL_NAME_CONVERTER 124
|
||||
# define DSO_F_DL_UNLOAD 107
|
||||
# define DSO_F_DSO_BIND_FUNC 108
|
||||
# define DSO_F_DSO_BIND_VAR 109
|
||||
# define DSO_F_DSO_CONVERT_FILENAME 126
|
||||
# define DSO_F_DSO_CTRL 110
|
||||
# define DSO_F_DSO_FREE 111
|
||||
# define DSO_F_DSO_GET_FILENAME 127
|
||||
# define DSO_F_DSO_GET_LOADED_FILENAME 128
|
||||
# define DSO_F_DSO_GLOBAL_LOOKUP 139
|
||||
# define DSO_F_DSO_LOAD 112
|
||||
# define DSO_F_DSO_MERGE 132
|
||||
# define DSO_F_DSO_NEW_METHOD 113
|
||||
# define DSO_F_DSO_PATHBYADDR 140
|
||||
# define DSO_F_DSO_SET_FILENAME 129
|
||||
# define DSO_F_DSO_SET_NAME_CONVERTER 122
|
||||
# define DSO_F_DSO_UP_REF 114
|
||||
# define DSO_F_GLOBAL_LOOKUP_FUNC 138
|
||||
# define DSO_F_PATHBYADDR 137
|
||||
# define DSO_F_VMS_BIND_SYM 115
|
||||
# define DSO_F_VMS_LOAD 116
|
||||
# define DSO_F_VMS_MERGER 133
|
||||
# define DSO_F_VMS_UNLOAD 117
|
||||
# define DSO_F_WIN32_BIND_FUNC 118
|
||||
# define DSO_F_WIN32_BIND_VAR 119
|
||||
# define DSO_F_WIN32_GLOBALLOOKUP 142
|
||||
# define DSO_F_WIN32_GLOBALLOOKUP_FUNC 143
|
||||
# define DSO_F_WIN32_JOINER 135
|
||||
# define DSO_F_WIN32_LOAD 120
|
||||
# define DSO_F_WIN32_MERGER 134
|
||||
# define DSO_F_WIN32_NAME_CONVERTER 125
|
||||
# define DSO_F_WIN32_PATHBYADDR 141
|
||||
# define DSO_F_WIN32_SPLITTER 136
|
||||
# define DSO_F_WIN32_UNLOAD 121
|
||||
|
||||
/* Reason codes. */
|
||||
# define DSO_R_CTRL_FAILED 100
|
||||
# define DSO_R_DSO_ALREADY_LOADED 110
|
||||
# define DSO_R_EMPTY_FILE_STRUCTURE 113
|
||||
# define DSO_R_FAILURE 114
|
||||
# define DSO_R_FILENAME_TOO_BIG 101
|
||||
# define DSO_R_FINISH_FAILED 102
|
||||
# define DSO_R_INCORRECT_FILE_SYNTAX 115
|
||||
# define DSO_R_LOAD_FAILED 103
|
||||
# define DSO_R_NAME_TRANSLATION_FAILED 109
|
||||
# define DSO_R_NO_FILENAME 111
|
||||
# define DSO_R_NO_FILE_SPECIFICATION 116
|
||||
# define DSO_R_NULL_HANDLE 104
|
||||
# define DSO_R_SET_FILENAME_FAILED 112
|
||||
# define DSO_R_STACK_ERROR 105
|
||||
# define DSO_R_SYM_FAILURE 106
|
||||
# define DSO_R_UNLOAD_FAILED 107
|
||||
# define DSO_R_UNSUPPORTED 108
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
272
sgx-jvm/dependencies/root/usr/include/openssl/dtls1.h
Normal file
272
sgx-jvm/dependencies/root/usr/include/openssl/dtls1.h
Normal file
@ -0,0 +1,272 @@
|
||||
/* ssl/dtls1.h */
|
||||
/*
|
||||
* DTLS implementation written by Nagendra Modadugu
|
||||
* (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DTLS1_H
|
||||
# define HEADER_DTLS1_H
|
||||
|
||||
# include <openssl/buffer.h>
|
||||
# include <openssl/pqueue.h>
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
# include <resource.h>
|
||||
# include <sys/timeb.h>
|
||||
# endif
|
||||
# ifdef OPENSSL_SYS_WIN32
|
||||
/* Needed for struct timeval */
|
||||
# include <winsock.h>
|
||||
# elif defined(OPENSSL_SYS_NETWARE) && !defined(_WINSOCK2API_)
|
||||
# include <sys/timeval.h>
|
||||
# else
|
||||
# if defined(OPENSSL_SYS_VXWORKS)
|
||||
# include <sys/times.h>
|
||||
# else
|
||||
# include <sys/time.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# define DTLS1_VERSION 0xFEFF
|
||||
# define DTLS1_2_VERSION 0xFEFD
|
||||
# define DTLS_MAX_VERSION DTLS1_2_VERSION
|
||||
# define DTLS1_VERSION_MAJOR 0xFE
|
||||
|
||||
# define DTLS1_BAD_VER 0x0100
|
||||
|
||||
/* Special value for method supporting multiple versions */
|
||||
# define DTLS_ANY_VERSION 0x1FFFF
|
||||
|
||||
# if 0
|
||||
/* this alert description is not specified anywhere... */
|
||||
# define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110
|
||||
# endif
|
||||
|
||||
/* lengths of messages */
|
||||
# define DTLS1_COOKIE_LENGTH 256
|
||||
|
||||
# define DTLS1_RT_HEADER_LENGTH 13
|
||||
|
||||
# define DTLS1_HM_HEADER_LENGTH 12
|
||||
|
||||
# define DTLS1_HM_BAD_FRAGMENT -2
|
||||
# define DTLS1_HM_FRAGMENT_RETRY -3
|
||||
|
||||
# define DTLS1_CCS_HEADER_LENGTH 1
|
||||
|
||||
# ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE
|
||||
# define DTLS1_AL_HEADER_LENGTH 7
|
||||
# else
|
||||
# define DTLS1_AL_HEADER_LENGTH 2
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_NO_SSL_INTERN
|
||||
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
# define DTLS1_SCTP_AUTH_LABEL "EXPORTER_DTLS_OVER_SCTP"
|
||||
# endif
|
||||
|
||||
/* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */
|
||||
# define DTLS1_MAX_MTU_OVERHEAD 48
|
||||
|
||||
typedef struct dtls1_bitmap_st {
|
||||
unsigned long map; /* track 32 packets on 32-bit systems and 64
|
||||
* - on 64-bit systems */
|
||||
unsigned char max_seq_num[8]; /* max record number seen so far, 64-bit
|
||||
* value in big-endian encoding */
|
||||
} DTLS1_BITMAP;
|
||||
|
||||
struct dtls1_retransmit_state {
|
||||
EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
|
||||
EVP_MD_CTX *write_hash; /* used for mac generation */
|
||||
# ifndef OPENSSL_NO_COMP
|
||||
COMP_CTX *compress; /* compression */
|
||||
# else
|
||||
char *compress;
|
||||
# endif
|
||||
SSL_SESSION *session;
|
||||
unsigned short epoch;
|
||||
};
|
||||
|
||||
struct hm_header_st {
|
||||
unsigned char type;
|
||||
unsigned long msg_len;
|
||||
unsigned short seq;
|
||||
unsigned long frag_off;
|
||||
unsigned long frag_len;
|
||||
unsigned int is_ccs;
|
||||
struct dtls1_retransmit_state saved_retransmit_state;
|
||||
};
|
||||
|
||||
struct ccs_header_st {
|
||||
unsigned char type;
|
||||
unsigned short seq;
|
||||
};
|
||||
|
||||
struct dtls1_timeout_st {
|
||||
/* Number of read timeouts so far */
|
||||
unsigned int read_timeouts;
|
||||
/* Number of write timeouts so far */
|
||||
unsigned int write_timeouts;
|
||||
/* Number of alerts received so far */
|
||||
unsigned int num_alerts;
|
||||
};
|
||||
|
||||
typedef struct record_pqueue_st {
|
||||
unsigned short epoch;
|
||||
pqueue q;
|
||||
} record_pqueue;
|
||||
|
||||
typedef struct hm_fragment_st {
|
||||
struct hm_header_st msg_header;
|
||||
unsigned char *fragment;
|
||||
unsigned char *reassembly;
|
||||
} hm_fragment;
|
||||
|
||||
typedef struct dtls1_state_st {
|
||||
unsigned int send_cookie;
|
||||
unsigned char cookie[DTLS1_COOKIE_LENGTH];
|
||||
unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH];
|
||||
unsigned int cookie_len;
|
||||
/*
|
||||
* The current data and handshake epoch. This is initially
|
||||
* undefined, and starts at zero once the initial handshake is
|
||||
* completed
|
||||
*/
|
||||
unsigned short r_epoch;
|
||||
unsigned short w_epoch;
|
||||
/* records being received in the current epoch */
|
||||
DTLS1_BITMAP bitmap;
|
||||
/* renegotiation starts a new set of sequence numbers */
|
||||
DTLS1_BITMAP next_bitmap;
|
||||
/* handshake message numbers */
|
||||
unsigned short handshake_write_seq;
|
||||
unsigned short next_handshake_write_seq;
|
||||
unsigned short handshake_read_seq;
|
||||
/* save last sequence number for retransmissions */
|
||||
unsigned char last_write_sequence[8];
|
||||
/* Received handshake records (processed and unprocessed) */
|
||||
record_pqueue unprocessed_rcds;
|
||||
record_pqueue processed_rcds;
|
||||
/* Buffered handshake messages */
|
||||
pqueue buffered_messages;
|
||||
/* Buffered (sent) handshake records */
|
||||
pqueue sent_messages;
|
||||
/*
|
||||
* Buffered application records. Only for records between CCS and
|
||||
* Finished to prevent either protocol violation or unnecessary message
|
||||
* loss.
|
||||
*/
|
||||
record_pqueue buffered_app_data;
|
||||
/* Is set when listening for new connections with dtls1_listen() */
|
||||
unsigned int listen;
|
||||
unsigned int link_mtu; /* max on-the-wire DTLS packet size */
|
||||
unsigned int mtu; /* max DTLS packet size */
|
||||
struct hm_header_st w_msg_hdr;
|
||||
struct hm_header_st r_msg_hdr;
|
||||
struct dtls1_timeout_st timeout;
|
||||
/*
|
||||
* Indicates when the last handshake msg or heartbeat sent will timeout
|
||||
*/
|
||||
struct timeval next_timeout;
|
||||
/* Timeout duration */
|
||||
unsigned short timeout_duration;
|
||||
/*
|
||||
* storage for Alert/Handshake protocol data received but not yet
|
||||
* processed by ssl3_read_bytes:
|
||||
*/
|
||||
unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH];
|
||||
unsigned int alert_fragment_len;
|
||||
unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH];
|
||||
unsigned int handshake_fragment_len;
|
||||
unsigned int retransmitting;
|
||||
/*
|
||||
* Set when the handshake is ready to process peer's ChangeCipherSpec message.
|
||||
* Cleared after the message has been processed.
|
||||
*/
|
||||
unsigned int change_cipher_spec_ok;
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
/* used when SSL_ST_XX_FLUSH is entered */
|
||||
int next_state;
|
||||
int shutdown_received;
|
||||
# endif
|
||||
} DTLS1_STATE;
|
||||
|
||||
typedef struct dtls1_record_data_st {
|
||||
unsigned char *packet;
|
||||
unsigned int packet_length;
|
||||
SSL3_BUFFER rbuf;
|
||||
SSL3_RECORD rrec;
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
struct bio_dgram_sctp_rcvinfo recordinfo;
|
||||
# endif
|
||||
} DTLS1_RECORD_DATA;
|
||||
|
||||
# endif
|
||||
|
||||
/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */
|
||||
# define DTLS1_TMO_READ_COUNT 2
|
||||
# define DTLS1_TMO_WRITE_COUNT 2
|
||||
|
||||
# define DTLS1_TMO_ALERT_COUNT 12
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
328
sgx-jvm/dependencies/root/usr/include/openssl/e_os2.h
Normal file
328
sgx-jvm/dependencies/root/usr/include/openssl/e_os2.h
Normal file
@ -0,0 +1,328 @@
|
||||
/* e_os2.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#ifndef HEADER_E_OS2_H
|
||||
# define HEADER_E_OS2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Detect operating systems. This probably needs completing.
|
||||
* The result is that at least one OPENSSL_SYS_os macro should be defined.
|
||||
* However, if none is defined, Unix is assumed.
|
||||
**/
|
||||
|
||||
# define OPENSSL_SYS_UNIX
|
||||
|
||||
/* ---------------------- Macintosh, before MacOS X ----------------------- */
|
||||
# if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_MACINTOSH_CLASSIC
|
||||
# endif
|
||||
|
||||
/* ---------------------- NetWare ----------------------------------------- */
|
||||
# if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_NETWARE
|
||||
# endif
|
||||
|
||||
/* --------------------- Microsoft operating systems ---------------------- */
|
||||
|
||||
/*
|
||||
* Note that MSDOS actually denotes 32-bit environments running on top of
|
||||
* MS-DOS, such as DJGPP one.
|
||||
*/
|
||||
# if defined(OPENSSL_SYSNAME_MSDOS)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_MSDOS
|
||||
# endif
|
||||
|
||||
/*
|
||||
* For 32 bit environment, there seems to be the CygWin environment and then
|
||||
* all the others that try to do the same thing Microsoft does...
|
||||
*/
|
||||
# if defined(OPENSSL_SYSNAME_UWIN)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WIN32_UWIN
|
||||
# else
|
||||
# if defined(__CYGWIN__) || defined(OPENSSL_SYSNAME_CYGWIN)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WIN32_CYGWIN
|
||||
# else
|
||||
# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WIN32
|
||||
# endif
|
||||
# if defined(_WIN64) || defined(OPENSSL_SYSNAME_WIN64)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# if !defined(OPENSSL_SYS_WIN64)
|
||||
# define OPENSSL_SYS_WIN64
|
||||
# endif
|
||||
# endif
|
||||
# if defined(OPENSSL_SYSNAME_WINNT)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WINNT
|
||||
# endif
|
||||
# if defined(OPENSSL_SYSNAME_WINCE)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WINCE
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Anything that tries to look like Microsoft is "Windows" */
|
||||
# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WINDOWS
|
||||
# ifndef OPENSSL_SYS_MSDOS
|
||||
# define OPENSSL_SYS_MSDOS
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/*
|
||||
* DLL settings. This part is a bit tough, because it's up to the
|
||||
* application implementor how he or she will link the application, so it
|
||||
* requires some macro to be used.
|
||||
*/
|
||||
# ifdef OPENSSL_SYS_WINDOWS
|
||||
# ifndef OPENSSL_OPT_WINDLL
|
||||
# if defined(_WINDLL) /* This is used when building OpenSSL to
|
||||
* indicate that DLL linkage should be used */
|
||||
# define OPENSSL_OPT_WINDLL
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* ------------------------------- OpenVMS -------------------------------- */
|
||||
# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_VMS
|
||||
# if defined(__DECC)
|
||||
# define OPENSSL_SYS_VMS_DECC
|
||||
# elif defined(__DECCXX)
|
||||
# define OPENSSL_SYS_VMS_DECC
|
||||
# define OPENSSL_SYS_VMS_DECCXX
|
||||
# else
|
||||
# define OPENSSL_SYS_VMS_NODECC
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* -------------------------------- OS/2 ---------------------------------- */
|
||||
# if defined(__EMX__) || defined(__OS2__)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_OS2
|
||||
# endif
|
||||
|
||||
/* -------------------------------- Unix ---------------------------------- */
|
||||
# ifdef OPENSSL_SYS_UNIX
|
||||
# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX)
|
||||
# define OPENSSL_SYS_LINUX
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_MPE
|
||||
# define OPENSSL_SYS_MPE
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_SNI
|
||||
# define OPENSSL_SYS_SNI
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_ULTRASPARC
|
||||
# define OPENSSL_SYS_ULTRASPARC
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_NEWS4
|
||||
# define OPENSSL_SYS_NEWS4
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_MACOSX
|
||||
# define OPENSSL_SYS_MACOSX
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY
|
||||
# define OPENSSL_SYS_MACOSX_RHAPSODY
|
||||
# define OPENSSL_SYS_MACOSX
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_SUNOS
|
||||
# define OPENSSL_SYS_SUNOS
|
||||
# endif
|
||||
# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY)
|
||||
# define OPENSSL_SYS_CRAY
|
||||
# endif
|
||||
# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX)
|
||||
# define OPENSSL_SYS_AIX
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* -------------------------------- VOS ----------------------------------- */
|
||||
# if defined(__VOS__) || defined(OPENSSL_SYSNAME_VOS)
|
||||
# define OPENSSL_SYS_VOS
|
||||
# ifdef __HPPA__
|
||||
# define OPENSSL_SYS_VOS_HPPA
|
||||
# endif
|
||||
# ifdef __IA32__
|
||||
# define OPENSSL_SYS_VOS_IA32
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* ------------------------------ VxWorks --------------------------------- */
|
||||
# ifdef OPENSSL_SYSNAME_VXWORKS
|
||||
# define OPENSSL_SYS_VXWORKS
|
||||
# endif
|
||||
|
||||
/* -------------------------------- BeOS ---------------------------------- */
|
||||
# if defined(__BEOS__)
|
||||
# define OPENSSL_SYS_BEOS
|
||||
# include <sys/socket.h>
|
||||
# if defined(BONE_VERSION)
|
||||
# define OPENSSL_SYS_BEOS_BONE
|
||||
# else
|
||||
# define OPENSSL_SYS_BEOS_R5
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/**
|
||||
* That's it for OS-specific stuff
|
||||
*****************************************************************************/
|
||||
|
||||
/* Specials for I/O an exit */
|
||||
# ifdef OPENSSL_SYS_MSDOS
|
||||
# define OPENSSL_UNISTD_IO <io.h>
|
||||
# define OPENSSL_DECLARE_EXIT extern void exit(int);
|
||||
# else
|
||||
# define OPENSSL_UNISTD_IO OPENSSL_UNISTD
|
||||
# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */
|
||||
# endif
|
||||
|
||||
/*-
|
||||
* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare
|
||||
* certain global symbols that, with some compilers under VMS, have to be
|
||||
* defined and declared explicitely with globaldef and globalref.
|
||||
* Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare
|
||||
* DLL exports and imports for compilers under Win32. These are a little
|
||||
* more complicated to use. Basically, for any library that exports some
|
||||
* global variables, the following code must be present in the header file
|
||||
* that declares them, before OPENSSL_EXTERN is used:
|
||||
*
|
||||
* #ifdef SOME_BUILD_FLAG_MACRO
|
||||
* # undef OPENSSL_EXTERN
|
||||
* # define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||
* #endif
|
||||
*
|
||||
* The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL
|
||||
* have some generally sensible values, and for OPENSSL_EXTERN to have the
|
||||
* value OPENSSL_IMPORT.
|
||||
*/
|
||||
|
||||
# if defined(OPENSSL_SYS_VMS_NODECC)
|
||||
# define OPENSSL_EXPORT globalref
|
||||
# define OPENSSL_IMPORT globalref
|
||||
# define OPENSSL_GLOBAL globaldef
|
||||
# elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
|
||||
# define OPENSSL_EXPORT extern __declspec(dllexport)
|
||||
# define OPENSSL_IMPORT extern __declspec(dllimport)
|
||||
# define OPENSSL_GLOBAL
|
||||
# else
|
||||
# define OPENSSL_EXPORT extern
|
||||
# define OPENSSL_IMPORT extern
|
||||
# define OPENSSL_GLOBAL
|
||||
# endif
|
||||
# define OPENSSL_EXTERN OPENSSL_IMPORT
|
||||
|
||||
/*-
|
||||
* Macros to allow global variables to be reached through function calls when
|
||||
* required (if a shared library version requires it, for example.
|
||||
* The way it's done allows definitions like this:
|
||||
*
|
||||
* // in foobar.c
|
||||
* OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0)
|
||||
* // in foobar.h
|
||||
* OPENSSL_DECLARE_GLOBAL(int,foobar);
|
||||
* #define foobar OPENSSL_GLOBAL_REF(foobar)
|
||||
*/
|
||||
# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \
|
||||
type *_shadow_##name(void) \
|
||||
{ static type _hide_##name=value; return &_hide_##name; }
|
||||
# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)
|
||||
# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))
|
||||
# else
|
||||
# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value;
|
||||
# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name
|
||||
# define OPENSSL_GLOBAL_REF(name) _shadow_##name
|
||||
# endif
|
||||
|
||||
# if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && macintosh==1 && !defined(MAC_OS_GUSI_SOURCE)
|
||||
# define ossl_ssize_t long
|
||||
# endif
|
||||
|
||||
# ifdef OPENSSL_SYS_MSDOS
|
||||
# define ossl_ssize_t long
|
||||
# endif
|
||||
|
||||
# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
|
||||
# define ssize_t int
|
||||
# endif
|
||||
|
||||
# if defined(__ultrix) && !defined(ssize_t)
|
||||
# define ossl_ssize_t int
|
||||
# endif
|
||||
|
||||
# ifndef ossl_ssize_t
|
||||
# define ossl_ssize_t ssize_t
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user