Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 03528200B4C for ; Fri, 22 Jul 2016 09:00:43 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0215C160A91; Fri, 22 Jul 2016 07:00:43 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 203F9160A77 for ; Fri, 22 Jul 2016 09:00:41 +0200 (CEST) Received: (qmail 42738 invoked by uid 500); 22 Jul 2016 07:00:31 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 40203 invoked by uid 99); 22 Jul 2016 07:00:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jul 2016 07:00:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3CF0CE0B40; Fri, 22 Jul 2016 07:00:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sdp@apache.org To: commits@commons.apache.org Date: Fri, 22 Jul 2016 07:01:03 -0000 Message-Id: <61699d4f8c3145a5a3f79359cc8cbb1d@git.apache.org> In-Reply-To: <95881723ed294320bfa48ab8602a4c58@git.apache.org> References: <95881723ed294320bfa48ab8602a4c58@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [35/50] commons-crypto git commit: CRYPTO-114 exception.c/exception.h are not used archived-at: Fri, 22 Jul 2016 07:00:43 -0000 CRYPTO-114 exception.c/exception.h are not used Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/4ac4fedf Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/4ac4fedf Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/4ac4fedf Branch: refs/heads/CRYPTO-1.0.0 Commit: 4ac4fedf1bbe662e8c485eee653f9dbe34f2b853 Parents: 79502d4 Author: Sebb Authored: Sun Jul 10 12:50:21 2016 +0100 Committer: Sebb Committed: Sun Jul 10 12:50:21 2016 +0100 ---------------------------------------------------------------------- .../org/apache/commons/crypto/exception.c | 124 ------------------- .../org/apache/commons/crypto/exception.h | 104 ---------------- 2 files changed, 228 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4ac4fedf/src/main/native/org/apache/commons/crypto/exception.c ---------------------------------------------------------------------- diff --git a/src/main/native/org/apache/commons/crypto/exception.c b/src/main/native/org/apache/commons/crypto/exception.c deleted file mode 100644 index fc072e8..0000000 --- a/src/main/native/org/apache/commons/crypto/exception.c +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "exception.h" - -#include -#include -#include -#include - -jthrowable newExceptionV(JNIEnv* env, const char *name, - const char *fmt, va_list ap) -{ - int need; - char buf[1], *msg = NULL; - va_list ap2; - jstring jstr = NULL; - jthrowable jthr; - jclass clazz; - jmethodID excCtor; - - va_copy(ap2, ap); - clazz = (*env)->FindClass(env, name); - if (!clazz) { - jthr = (*env)->ExceptionOccurred(env); - (*env)->ExceptionClear(env); - goto done; - } - excCtor = (*env)->GetMethodID(env, - clazz, "", "(Ljava/lang/String;)V"); - if (!excCtor) { - jthr = (*env)->ExceptionOccurred(env); - (*env)->ExceptionClear(env); - goto done; - } - need = vsnprintf(buf, sizeof(buf), fmt, ap); - if (need < 0) { - fmt = "vsnprintf error"; - need = strlen(fmt); - } - msg = malloc(need + 1); - vsnprintf(msg, need + 1, fmt, ap2); - jstr = (*env)->NewStringUTF(env, msg); - if (!jstr) { - jthr = (*env)->ExceptionOccurred(env); - (*env)->ExceptionClear(env); - goto done; - } - jthr = (*env)->NewObject(env, clazz, excCtor, jstr); - if (!jthr) { - jthr = (*env)->ExceptionOccurred(env); - (*env)->ExceptionClear(env); - goto done; - } - -done: - free(msg); - va_end(ap2); - (*env)->DeleteLocalRef(env, jstr); - return jthr; -} - -jthrowable newException(JNIEnv* env, const char *name, const char *fmt, ...) -{ - va_list ap; - jthrowable jthr; - - va_start(ap, fmt); - jthr = newExceptionV(env, name, fmt, ap); - va_end(ap); - return jthr; -} - -jthrowable newRuntimeException(JNIEnv* env, const char *fmt, ...) -{ - va_list ap; - jthrowable jthr; - - va_start(ap, fmt); - jthr = newExceptionV(env, "java/lang/RuntimeException", fmt, ap); - va_end(ap); - return jthr; -} - -jthrowable newIOException(JNIEnv* env, const char *fmt, ...) -{ - va_list ap; - jthrowable jthr; - - va_start(ap, fmt); - jthr = newExceptionV(env, "java/io/IOException", fmt, ap); - va_end(ap); - return jthr; -} - -const char* terror(int errnum) -{ - -#if defined(__sun) -// MT-Safe under Solaris which doesn't support sys_errlist/sys_nerr - return strerror(errnum); -#else - if ((errnum < 0) || (errnum >= sys_nerr)) { - return "unknown error."; - } - return sys_errlist[errnum]; -#endif -} - http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4ac4fedf/src/main/native/org/apache/commons/crypto/exception.h ---------------------------------------------------------------------- diff --git a/src/main/native/org/apache/commons/crypto/exception.h b/src/main/native/org/apache/commons/crypto/exception.h deleted file mode 100644 index d67d553..0000000 --- a/src/main/native/org/apache/commons/crypto/exception.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef COMMONS_CRYPTO_NATIVE_SRC_EXCEPTION_H -#define COMMONS_CRYPTO_NATIVE_SRC_EXCEPTION_H - -#include /* for jthrowable */ -#include /* for va_list */ -#include "org_apache_commons_crypto.h" - -#ifdef WINDOWS -/* - * gcc-style type-checked format arguments are not supported on Windows, so just - * stub this macro. - */ -#define TYPE_CHECKED_PRINTF_FORMAT(formatArg, varArgs) -# else -/* Use gcc type-checked format arguments. */ -#define TYPE_CHECKED_PRINTF_FORMAT(formatArg, varArgs) \ - __attribute__((format(printf, formatArg, varArgs))) -#endif - -/** - * Create a new Exception. - * - * No exceptions will be pending on return. - * - * @param env The JNI environment - * @param name full name of the Java exception class - * @param fmt printf-style format string - * @param ap printf-style arguments - * - * @return The RuntimeException - */ -jthrowable newExceptionV(JNIEnv* env, const char *name, - const char *fmt, va_list ap); - -/** - * Create a new Exception. - * - * No exceptions will be pending on return. - * - * @param env The JNI environment - * @param name full name of the Java exception class - * @param fmt printf-style format string - * @param ... printf-style arguments - * - * @return The RuntimeException - */ -jthrowable newException(JNIEnv* env, const char *name, const char *fmt, ...) - TYPE_CHECKED_PRINTF_FORMAT(3, 4); - -/** - * Create a new RuntimeException. - * - * No exceptions will be pending on return. - * - * @param env The JNI environment - * @param fmt printf-style format string - * @param ... printf-style arguments - * - * @return The RuntimeException - */ -jthrowable newRuntimeException(JNIEnv* env, const char *fmt, ...) - TYPE_CHECKED_PRINTF_FORMAT(2, 3); - -/** - * Create a new IOException. - * - * No exceptions will be pending on return. - * - * @param env The JNI environment - * @param fmt printf-style format string - * @param ... printf-style arguments - * - * @return The IOException, or another exception if we failed - * to create the NativeIOException. - */ -jthrowable newIOException(JNIEnv* env, const char *fmt, ...) - TYPE_CHECKED_PRINTF_FORMAT(2, 3); - -/** - * Thread-safe strerror alternative. - * - * @param errnum Error number. - * @return Statically allocated error string. - */ -const char* terror(int errnum); - -#undef TYPE_CHECKED_PRINTF_FORMAT -#endif