Author: mturk
Date: Tue Mar 22 18:36:19 2011
New Revision: 1084288
URL: http://svn.apache.org/viewvc?rev=1084288&view=rev
Log:
Start adding common stuff
Added:
commons/sandbox/runtime/trunk/src/main/native/buildmark.c (with props)
commons/sandbox/runtime/trunk/src/main/native/bzip2.c (with props)
commons/sandbox/runtime/trunk/src/main/native/error.c (with props)
commons/sandbox/runtime/trunk/src/main/native/include/acr/api.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/include/acr/config.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/include/acr/port.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/include/acr/stddefs.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/include/acr/stdinc.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/include/acr/stdtypes.h
(with props)
commons/sandbox/runtime/trunk/src/main/native/os/
commons/sandbox/runtime/trunk/src/main/native/os/aix/
commons/sandbox/runtime/trunk/src/main/native/os/bsdx/
commons/sandbox/runtime/trunk/src/main/native/os/darwin/
commons/sandbox/runtime/trunk/src/main/native/os/hpux/
commons/sandbox/runtime/trunk/src/main/native/os/linux/
commons/sandbox/runtime/trunk/src/main/native/os/solaris/
commons/sandbox/runtime/trunk/src/main/native/os/unix/
commons/sandbox/runtime/trunk/src/main/native/os/win32/
commons/sandbox/runtime/trunk/src/main/native/port/
commons/sandbox/runtime/trunk/src/main/native/port/bsdstring.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/CHANGES
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/LICENSE (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/README (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/blocksort.c
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/bzlib.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/bzlib.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/bzlib_private.h
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/compress.c
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/crctable.c
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/decompress.c
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/huffman.c
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/bzip2/randtable.c
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/ChangeLog
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/README (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/adler32.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/compress.c
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/crc32.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/crc32.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/deflate.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/deflate.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/infback.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/inffast.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/inffast.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/inffixed.h
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/inflate.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/inflate.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/inftrees.c
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/inftrees.h
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/trees.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/trees.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/uncompr.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/unix/
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/unix/amd64-match.S
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/unix/gvmat64.S
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/unix/i686-match.S
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/win32/
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/win32/gvmat64.asm
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/win32/inffas32.asm
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/win32/inffas8664.c
(with props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/win32/inffasx64.asm
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/win32/match686.asm
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/zconf.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/zlib.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/zutil.c (with
props)
commons/sandbox/runtime/trunk/src/main/native/srclib/zlib/zutil.h (with
props)
Added: commons/sandbox/runtime/trunk/src/main/native/buildmark.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/buildmark.c?rev=1084288&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/buildmark.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/buildmark.c Tue Mar 22
18:36:19 2011
@@ -0,0 +1,25 @@
+/* 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 "cpr/version.h"
+#include "cpr/stdtypes.h"
+
+#if defined(__DATE__) && defined(__TIME__)
+static const char __built[] = __DATE__ " " __TIME__;
+#else
+static const char __built[] = PACKAGE_CONFIGURED;
+#endif
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/buildmark.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/bzip2.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/bzip2.c?rev=1084288&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/bzip2.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/bzip2.c Tue Mar 22 18:36:19
2011
@@ -0,0 +1,27 @@
+/* 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 "acr/api.h"
+#include "acr/version.h"
+#include "bzip2/bzlib.h"
+
+void _cr_bz_internal_error(int errorcode)
+{
+ /* TODO: Make this as configurable callback
+ * So that those messages can pop up in loggers.
+ */
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/bzip2.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/error.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/error.c?rev=1084288&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/error.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/error.c Tue Mar 22 18:36:19
2011
@@ -0,0 +1,599 @@
+/* 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 "acr/error.h"
+#include "acr/port.h"
+
+static const char *const _canon_errors[] = {
+ "Undefined error: 0", /* 0 - ENOERROR */
+ "Operation not permitted", /* 1 - EPERM */
+ "No such file or directory", /* 2 - ENOENT */
+ "No such process", /* 3 - ESRCH */
+ "Interrupted system call", /* 4 - EINTR */
+ "Input/output error", /* 5 - EIO */
+ "Device not configured", /* 6 - ENXIO */
+ "Argument list too long", /* 7 - E2BIG */
+ "Exec format error", /* 8 - ENOEXEC */
+ "Bad file descriptor", /* 9 - EBADF */
+ "No child processes", /* 10 - ECHILD */
+ "Resource deadlock avoided", /* 11 - EDEADLK */
+ "Cannot allocate memory", /* 12 - ENOMEM */
+ "Permission denied", /* 13 - EACCES */
+ "Bad address", /* 14 - EFAULT */
+ "Block device required", /* 15 - ENOTBLK */
+ "Device busy", /* 16 - EBUSY */
+ "File exists", /* 17 - EEXIST */
+ "Cross-device link", /* 18 - EXDEV */
+ "Operation not supported by device", /* 19 - ENODEV */
+ "Not a directory", /* 20 - ENOTDIR */
+ "Is a directory", /* 21 - EISDIR */
+ "Invalid argument", /* 22 - EINVAL */
+ "Too many open files in system", /* 23 - ENFILE */
+ "Too many open files", /* 24 - EMFILE */
+ "Inappropriate ioctl for device", /* 25 - ENOTTY */
+ "Text file busy", /* 26 - ETXTBSY */
+ "File too large", /* 27 - EFBIG */
+ "No space left on device", /* 28 - ENOSPC */
+ "Illegal seek", /* 29 - ESPIPE */
+ "Read-only file system", /* 30 - EROFS */
+ "Too many links", /* 31 - EMLINK */
+ "Broken pipe", /* 32 - EPIPE */
+
+ /* math software */
+ "Numerical argument out of domain", /* 33 - EDOM */
+ "Result too large", /* 34 - ERANGE */
+
+ /* non-blocking and interrupt i/o */
+ "Resource temporarily unavailable", /* 35 - EAGAIN */
+ /* 35 - EWOULDBLOCK */
+ "Operation now in progress", /* 36 - EINPROGRESS */
+ "Operation already in progress", /* 37 - EALREADY */
+
+ /* ipc/network software -- argument errors */
+ "Socket operation on non-socket", /* 38 - ENOTSOCK */
+ "Destination address required", /* 39 - EDESTADDRREQ */
+ "Message too long", /* 40 - EMSGSIZE */
+ "Protocol wrong type for socket", /* 41 - EPROTOTYPE */
+ "Protocol not available", /* 42 - ENOPROTOOPT */
+ "Protocol not supported", /* 43 - EPROTONOSUPPORT */
+ "Socket type not supported", /* 44 - ESOCKTNOSUPPORT */
+ "Operation not supported", /* 45 - EOPNOTSUPP */
+ "Protocol family not supported", /* 46 - EPFNOSUPPORT */
+ /* 47 - EAFNOSUPPORT */
+ "Address family not supported by protocol family",
+ "Address already in use", /* 48 - EADDRINUSE */
+ "Can't assign requested address", /* 49 - EADDRNOTAVAIL */
+
+ /* ipc/network software -- operational errors */
+ "Network is down", /* 50 - ENETDOWN */
+ "Network is unreachable", /* 51 - ENETUNREACH */
+ "Network dropped connection on reset", /* 52 - ENETRESET */
+ "Software caused connection abort", /* 53 - ECONNABORTED */
+ "Connection reset by peer", /* 54 - ECONNRESET */
+ "No buffer space available", /* 55 - ENOBUFS */
+ "Socket is already connected", /* 56 - EISCONN */
+ "Socket is not connected", /* 57 - ENOTCONN */
+ "Can't send after socket shutdown", /* 58 - ESHUTDOWN */
+ "Too many references: can't splice", /* 59 - ETOOMANYREFS */
+ "Operation timed out", /* 60 - ETIMEDOUT */
+ "Connection refused", /* 61 - ECONNREFUSED */
+
+ "Too many levels of symbolic links", /* 62 - ELOOP */
+ "File name too long", /* 63 - ENAMETOOLONG */
+
+ /* should be rearranged */
+ "Host is down", /* 64 - EHOSTDOWN */
+ "No route to host", /* 65 - EHOSTUNREACH */
+ "Directory not empty", /* 66 - ENOTEMPTY */
+
+ /* quotas & mush */
+ "Too many processes", /* 67 - EPROCLIM */
+ "Too many users", /* 68 - EUSERS */
+ "Disk quota exceeded", /* 69 - EDQUOT */
+
+ /* Network File System */
+ "Stale NFS file handle", /* 70 - ESTALE */
+ "Too many levels of remote in path", /* 71 - EREMOTE */
+ "RPC struct is bad", /* 72 - EBADRPC */
+ "RPC version wrong", /* 73 - ERPCMISMATCH */
+ "RPC prog. not avail", /* 74 - EPROGUNAVAIL */
+ "Program version wrong", /* 75 - EPROGMISMATCH */
+ "Bad procedure for program", /* 76 - EPROCUNAVAIL */
+
+ "No locks available", /* 77 - ENOLCK */
+ "Function not implemented", /* 78 - ENOSYS */
+ "Inappropriate file type or format", /* 79 - EFTYPE */
+ "Authentication error", /* 80 - EAUTH */
+ "Need authenticator", /* 81 - ENEEDAUTH */
+ "IPsec processing failure", /* 82 - EIPSEC */
+ "Attribute not found", /* 83 - ENOATTR */
+ "Illegal byte sequence", /* 84 - EILSEQ */
+ "No medium found", /* 85 - ENOMEDIUM */
+ "Wrong medium type", /* 86 - EMEDIUMTYPE */
+ /* 87 - EOVERFLOW */
+ "Value too large to be stored in data type",
+ "Operation canceled", /* 88 - ECANCELED */
+ "Identifier removed", /* 89 - EIDRM */
+ "No message of desired type", /* 90 - ENOMSG */
+ 0
+};
+
+/*
+ * _stuff_sbuff - like strlcpy() but returns the address of the
+ * dest buffer instead of the size
+ */
+ACR_INLINE(char *) _stuff_sbuff(char *buf, size_t bufsize, const char *s)
+{
+ strlcpy(buf, s, bufsize);
+ return buf;
+}
+
+ACR_INLINE(char *) _stuff_canon(char *buf, size_t bufsize, int statcode)
+{
+ if (statcode > ACR_OS_START_CANONERR && statcode < ACR_OS_LAST_CANONERR) {
+ strlcpy(buf, _canon_errors[statcode - ACR_OS_START_CANONERR], bufsize);
+ }
+ else
+ snprintf(buf, bufsize, "Unrecognized ACR error code %d", statcode);
+ return buf;
+}
+
+static const char *_private_error_desc(int statcode)
+{
+ switch (statcode) {
+ case ACR_ENOPOOL:
+ return "No pool structure was provided and one was required";
+ case ACR_EBADDATE:
+ return "An invalid date has been provided";
+ case ACR_EINVALSOCK:
+ return "An invalid socket was returned";
+ case ACR_ENOPROC:
+ return "No process was provided and one was required";
+ case ACR_ENOTIME:
+ return "No time was provided and one was required";
+ case ACR_ENODIR:
+ return "No directory was provided and one was required";
+ case ACR_ENOLOCK:
+ return "No lock was provided and one was required";
+ case ACR_ENOPOLL:
+ return "No poll structure was provided and one was required";
+ case ACR_ENOSOCKET:
+ return "No socket was provided and one was required";
+ case ACR_ENOTHREAD:
+ return "No thread was provided and one was required";
+ case ACR_ENOTHDKEY:
+ return "No thread key structure was provided and one was required";
+ case ACR_ENOSHMAVAIL:
+ return "No shared memory is currently available";
+ case ACR_EDSOOPEN:
+#if HAVE_DLFCN_H
+ return dlerror();
+#else
+ return "DSO load failed";
+#endif /* HAVE_DLFCN_H */
+ case ACR_EBADIP:
+ return "The specified IP address is invalid";
+ case ACR_EBADMASK:
+ return "The specified network mask is invalid";
+
+ case ACR_INCHILD:
+ return
+ "Your code just forked, and you are currently executing in the "
+ "child process";
+ case ACR_INPARENT:
+ return
+ "Your code just forked, and you are currently executing in the "
+ "parent process";
+ case ACR_DETACH:
+ return "The specified thread is detached";
+ case ACR_NOTDETACH:
+ return "The specified thread is not detached";
+ case ACR_CHILD_DONE:
+ return "The specified child process is done executing";
+ case ACR_CHILD_NOTDONE:
+ return "The specified child process is not done executing";
+ case ACR_TIMEUP:
+ return "The timeout specified has expired";
+ case ACR_INCOMPLETE:
+ return "Partial results are valid but processing is incomplete";
+ case ACR_BADCH:
+ return "Bad character specified on command line";
+ case ACR_BADARG:
+ return "Missing parameter for the specified command line option";
+ case ACR_EOF:
+ return "End of file found";
+ case ACR_NOTFOUND:
+ return "Could not find specified socket in poll list";
+ case ACR_ANONYMOUS:
+ return "Shared memory is implemented anonymously";
+ case ACR_FILEBASED:
+ return "Shared memory is implemented using files";
+ case ACR_KEYBASED:
+ return "Shared memory is implemented using a key system";
+ case ACR_EINIT:
+ return "Requested operation failed to initialize";
+ case ACR_ENOTIMPL:
+ return "This function has not been implemented on this platform";
+ case ACR_EMISMATCH:
+ return "Passwords do not match";
+ case ACR_EABSOLUTE:
+ return "The given path is absolute";
+ case ACR_ERELATIVE:
+ return "The given path is relative";
+ case ACR_EINCOMPLETE:
+ return "The given path is incomplete";
+ case ACR_EABOVEROOT:
+ return "The given path was above the root path";
+ case ACR_EBADPATH:
+ return "The given path is misformatted or contained invalid
characters";
+ case ACR_EPATHWILD:
+ return "The given path contained wildcard characters";
+ case ACR_EPROC_UNKNOWN:
+ return "The process is not recognized.";
+ case ACR_EGENERAL:
+ return "Internal error";
+ case ACR_EISNULL:
+ return "The given argument is null";
+ case ACR_EINVALSIZ:
+ return "The given argument size is invalid";
+ default:
+ return "Error string not specified yet";
+ }
+}
+
+#if defined(_WINDOWS)
+/* Winsock error strings
+ *
+ */
+static const struct {
+ int code;
+ const char *desc;
+} _winsock_errors[] = {
+ WSAEINTR, "Interrupted system call",
+ WSAEBADF, "Bad file number",
+ WSAEACCES, "Permission denied",
+ WSAEFAULT, "Bad address",
+ WSAEINVAL, "Invalid argument",
+ WSAEMFILE, "Too many open sockets",
+ WSAEWOULDBLOCK, "Operation would block",
+ WSAEINPROGRESS, "Operation now in progress",
+ WSAEALREADY, "Operation already in progress",
+ WSAENOTSOCK, "Socket operation on non-socket",
+ WSAEDESTADDRREQ, "Destination address required",
+ WSAEMSGSIZE, "Message too long",
+ WSAEPROTOTYPE, "Protocol wrong type for socket",
+ WSAENOPROTOOPT, "Bad protocol option",
+ WSAEPROTONOSUPPORT, "Protocol not supported",
+ WSAESOCKTNOSUPPORT, "Socket type not supported",
+ WSAEOPNOTSUPP, "Operation not supported on socket",
+ WSAEPFNOSUPPORT, "Protocol family not supported",
+ WSAEAFNOSUPPORT, "Address family not supported",
+ WSAEADDRINUSE, "Address already in use",
+ WSAEADDRNOTAVAIL, "Can't assign requested address",
+ WSAENETDOWN, "Network is down",
+ WSAENETUNREACH, "Network is unreachable",
+ WSAENETRESET, "Net connection reset",
+ WSAECONNABORTED, "Software caused connection abort",
+ WSAECONNRESET, "Connection reset by peer",
+ WSAENOBUFS, "No buffer space available",
+ WSAEISCONN, "Socket is already connected",
+ WSAENOTCONN, "Socket is not connected",
+ WSAESHUTDOWN, "Can't send after socket shutdown",
+ WSAETOOMANYREFS, "Too many references, can't splice",
+ WSAETIMEDOUT, "Connection timed out",
+ WSAECONNREFUSED, "Connection refused",
+ WSAELOOP, "Too many levels of symbolic links",
+ WSAENAMETOOLONG, "File name too long",
+ WSAEHOSTDOWN, "Host is down",
+ WSAEHOSTUNREACH, "No route to host",
+ WSAENOTEMPTY, "Directory not empty",
+ WSAEPROCLIM, "Too many processes",
+ WSAEUSERS, "Too many users",
+ WSAEDQUOT, "Disc quota exceeded",
+ WSAESTALE, "Stale NFS file handle",
+ WSAEREMOTE, "Too many levels of remote in path",
+ WSASYSNOTREADY, "Network system is unavailable",
+ WSAVERNOTSUPPORTED, "Winsock version out of range",
+ WSANOTINITIALISED, "WSAStartup not yet called",
+ WSAEDISCON, "Graceful shutdown in progress",
+ WSAHOST_NOT_FOUND, "Host not found",
+ WSANO_DATA, "No host data of that type was found",
+ /* Extra errors */
+ WSATRY_AGAIN, "Temporary failure in name resolution",
+ WSANO_RECOVERY, "Nonrecoverable failure in name resolution",
+#if defined(WSA_NOT_ENOUGH_MEMORY)
+ WSA_NOT_ENOUGH_MEMORY
+#else
+ ERROR_NOT_ENOUGH_MEMORY
+#endif
+ , "Memory allocation failed",
+ WSASERVICE_NOT_FOUND, "Service not found.",
+ WSATYPE_NOT_FOUND, "Class type not found.",
+ WSASYSCALLFAILURE, "System call failure",
+ 0, 0
+};
+
+static const struct {
+ DWORD win32_error; /* Error returned from GetLastError() */
+ int posix_error; /* POSIX error code */
+} _posix_errors[] = {
+ { ERROR_INVALID_FUNCTION, ACR_EINVAL },
+ { ERROR_FILE_NOT_FOUND, ACR_ENOENT },
+ { ERROR_PATH_NOT_FOUND, ACR_ENOENT },
+ { ERROR_TOO_MANY_OPEN_FILES, ACR_EMFILE },
+ { ERROR_ACCESS_DENIED, ACR_EACCES },
+ { ERROR_INVALID_HANDLE, ACR_EBADF },
+ { ERROR_ARENA_TRASHED, ACR_ENOMEM },
+ { ERROR_NOT_ENOUGH_MEMORY, ACR_ENOMEM },
+ { ERROR_INVALID_BLOCK, ACR_ENOMEM },
+ { ERROR_BAD_ENVIRONMENT, ACR_E2BIG },
+ { ERROR_BAD_FORMAT, ACR_ENOEXEC },
+ { ERROR_INVALID_ACCESS, ACR_EINVAL },
+ { ERROR_INVALID_DATA, ACR_EINVAL },
+ { ERROR_INVALID_DRIVE, ACR_ENOENT },
+ { ERROR_CURRENT_DIRECTORY, ACR_EACCES },
+ { ERROR_NOT_SAME_DEVICE, ACR_EXDEV },
+ { ERROR_NO_MORE_FILES, ACR_ENOENT },
+ { ERROR_LOCK_VIOLATION, ACR_EACCES },
+ { ERROR_BAD_NETPATH, ACR_ENOENT },
+ { ERROR_NETWORK_ACCESS_DENIED, ACR_EACCES },
+ { ERROR_BAD_NET_NAME, ACR_ENOENT },
+ { ERROR_FILE_EXISTS, ACR_EEXIST },
+ { ERROR_CANNOT_MAKE, ACR_EACCES },
+ { ERROR_FAIL_I24, ACR_EACCES },
+ { ERROR_INVALID_PARAMETER, ACR_EINVAL },
+ { ERROR_NO_PROC_SLOTS, ACR_EAGAIN },
+ { ERROR_DRIVE_LOCKED, ACR_EACCES },
+ { ERROR_BROKEN_PIPE, ACR_EPIPE },
+ { ERROR_DISK_FULL, ACR_ENOSPC },
+ { ERROR_INVALID_TARGET_HANDLE, ACR_EBADF },
+ { ERROR_INVALID_HANDLE, ACR_EINVAL },
+ { ERROR_WAIT_NO_CHILDREN, ACR_ECHILD },
+ { ERROR_CHILD_NOT_COMPLETE, ACR_ECHILD },
+ { ERROR_DIRECT_ACCESS_HANDLE, ACR_EBADF },
+ { ERROR_NEGATIVE_SEEK, ACR_EINVAL },
+ { ERROR_SEEK_ON_DEVICE, ACR_EACCES },
+ { ERROR_DIR_NOT_EMPTY, ACR_ENOTEMPTY },
+ { ERROR_NOT_LOCKED, ACR_EACCES },
+ { ERROR_BAD_PATHNAME, ACR_ENOENT },
+ { ERROR_MAX_THRDS_REACHED, ACR_EAGAIN },
+ { ERROR_LOCK_FAILED, ACR_EACCES },
+ { ERROR_ALREADY_EXISTS, ACR_EEXIST },
+ { ERROR_FILENAME_EXCED_RANGE, ACR_ENOENT },
+ { ERROR_NESTING_NOT_ALLOWED, ACR_EAGAIN },
+ { ERROR_NOT_ENOUGH_QUOTA, ACR_ENOMEM },
+
+ { 0, 0 }
+};
+
+void
+cr_set_crt_error(int oserror)
+{
+ int i;
+ if (!oserror) {
+ SetLastError(0);
+ errno = 0;
+ return;
+ }
+ for (i = 0; i < ACR_COUNTOF(_posix_errors); i++) {
+ if (oserror == (int)_posix_errors[i].win32_error) {
+ errno = _posix_errors[i].posix_error;
+ break;
+ }
+ }
+
+ SetLastError(oserror);
+}
+
+int
+cr_get_crt_error()
+{
+ int i, crt;
+ DWORD os;
+ if ((os = GetLastError()))
+ return os;
+ crt = errno;
+ for (i = 0; crt, i < ACR_COUNTOF(_posix_errors); i++) {
+ if (crt == _posix_errors[i].posix_error)
+ return _posix_errors[i].win32_error;
+ }
+
+ return crt == 0 ? 0 : crt + ACR_OS_START_SYSERR;
+}
+
+
+#define _os_strerror_r _sys_strerror_r
+
+#else /* !_WINDOWS */
+/* On Unix, apr_os_strerror() handles error codes from the resolver
+ * (h_errno).
+ */
+static char *_os_strerror_r(char *buf, size_t bufsize, int err)
+{
+#if HAVE_HSTRERROR
+ return _stuff_sbuff(buf, bufsize, hstrerror(err));
+#else
+ const char *msg;
+
+ switch(err) {
+ case HOST_NOT_FOUND:
+ msg = "Unknown host";
+ break;
+# if defined(NO_DATA)
+ case NO_DATA:
+# if defined(NO_ADDRESS) && (NO_DATA != NO_ADDRESS)
+ case NO_ADDRESS:
+# endif
+ msg = "No address for host";
+ break;
+# elif defined(NO_ADDRESS)
+ case NO_ADDRESS:
+ msg = "No address for host";
+ break;
+# endif /* NO_DATA */
+ default:
+ msg = "Unrecognized resolver error";
+ }
+ return _stuff_sbuff(buf, bufsize, msg);
+#endif /* HAVE_HSTRERROR */
+}
+#endif
+
+#if defined (_WINDOWS)
+static char *_sys_strerror_r(char *buf, size_t bufsize, int statcode)
+{
+ DWORD len = 0;
+ int i;
+
+ if (statcode > WSABASEERR) {
+ for (i = 0; _winsock_errors[i].desc; i++) {
+ if (_winsock_errors[i].code == statcode) {
+ strlcpy(buf, _winsock_errors[i].desc, bufsize);
+ return buf;
+ }
+ }
+ }
+ len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ 0,
+ statcode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default
language */
+ buf,
+ (DWORD)bufsize,
+ 0);
+ if (len) {
+ /* FormatMessage put the message in the buffer, but it may
+ * have embedded a newline (\r\n), and possible more than one.
+ * Remove the newlines replacing them with a space. This is not
+ * as visually perfect as moving all the remaining message over,
+ * but more efficient.
+ */
+ while (len--) {
+ if ((buf[len] == '\r') || (buf[len] == '\n'))
+ buf[len] = ' ';
+ }
+ }
+ else {
+ /* Windows didn't provide us with a message. Even stuff like
+ * WSAECONNREFUSED won't get a message.
+ */
+ snprintf(buf, bufsize, "Unrecognized Win32 error code %d", statcode);
+ }
+
+ return buf;
+}
+#elif HAVE_STRERROR_R
+/* glibc style */
+static char *_sys_strerror_r(char *buf, size_t bufsize, int statcode)
+{
+#if defined(_GNU_SOURCE)
+ const char *msg;
+ buf[0] = '\0';
+ msg = strerror_r(statcode, buf, bufsize);
+ if (buf[0] == '\0') /* libc didn't use our buffer */
+ return _stuff_sbuff(buf, bufsize, msg);
+#else
+ buf[0] = '\0';
+ if (!strerror_r(statcode, buf, bufsize))
+ return buf;
+#endif
+ else
+ return buf;
+}
+#else /* !HAVE_HSTRERROR_R */
+/* plain old strerror();
+ * thread-safe on some platforms (e.g., Solaris, OS/390)
+ */
+static char *_sys_strerror_r(char *buf, size_t bufsize, int statcode)
+{
+ const char *err = strerror(statcode);
+ if (err)
+ return _stuff_sbuff(buf, bufsize, err);
+ else
+ return _stuff_canon(buf, bufsize, statcode);
+}
+#endif
+
+#if HAVE_THREAD_LOCAL
+static ACR_THREAD char _error_buffer[ACR_ERR_BUFFSIZE];
+#else
+#define _error_buffer _cr__thread()->err_buffer
+#endif
+
+ACR_API(char *)
+cr_strerror_r(int statcode, char *buf, size_t bufsize)
+{
+
+ if (buf == 0) {
+ buf = _error_buffer;
+ bufsize = ACR_ERR_BUFFSIZE;
+ }
+ if (statcode == 0) {
+ strlcpy(buf, _canon_errors[0], bufsize);
+ return buf;
+ }
+ else if (statcode < ACR_OS_START_ERROR)
+ return _sys_strerror_r(buf, bufsize, statcode);
+ else if (statcode < ACR_OS_START_USERERR)
+ return _stuff_sbuff(buf, bufsize, _private_error_desc(statcode));
+ else if (statcode < ACR_OS_START_EAIERR)
+ return _stuff_canon(buf, bufsize, statcode);
+ else if (statcode < ACR_OS_START_SYSERR) {
+#if HAVE_NETDB_H
+ statcode -= ACR_OS_START_EAIERR;
+# if defined(NEGATIVE_EAI)
+ statcode = -statcode;
+# endif
+ return _stuff_sbuff(buf, bufsize, gai_strerror(statcode));
+#else
+ return _stuff_canon(buf, bufsize, statcode);
+#endif
+ }
+ else {
+ if ((statcode - ACR_OS_START_SYSERR) < ACR_OS_ERRSPACE_SIZE)
+ return _os_strerror_r(buf, bufsize, statcode -
ACR_OS_START_SYSERR);
+ else
+ return _stuff_canon(buf, bufsize, statcode);
+ }
+}
+
+void _cr_fatal_error(const char *file, const char *func, int line,
+ int error, const char *msg, ...)
+{
+ if (msg) {
+ va_list ap;
+ va_start(ap, msg);
+ vfprintf(stderr, msg, ap);
+ va_end(ap);
+ }
+ if (file) {
+ if (msg)
+ fputs(", ", stderr);
+ fprintf(stderr, "file %s, line #%d, func %s." ACR_CRLF,
+ _bsd_basename_c(file), line, func);
+ }
+ else {
+ fputs(".\n", stderr);
+ }
+#if defined(_DEBUG)
+ if (error) {
+ fprintf(stderr, "Error #%d: %s." ACR_CRLF, error,
+ pr_strerror_r(error, 0, 0));
+ }
+#endif
+ fflush(stderr);
+ _exit(1);
+}
Propchange: commons/sandbox/runtime/trunk/src/main/native/error.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr/api.h
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/api.h?rev=1084288&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/api.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/api.h Tue Mar 22
18:36:19 2011
@@ -0,0 +1,34 @@
+/* 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 _ACR_API_H_
+#define _ACR_API_H_
+#include <acr/config.h>
+
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+# define ACR_API(type) __attribute__ ((visibility("default"))) type
+#elif defined(_MSC_VER)
+# define ACR_API(type) __declspec(dllexport) type __stdcall
+#else
+# define ACR_API(type) type
+#endif
+
+#define ACR_INITIALIZE_SIGNALS_EX 0x0001
+#define ACR_INITIALIZE_SEH 0x0002
+#define ACR_INITIALIZE_EXECMEM 0x0004
+#define ACR_INITIALIZE_MEMPTRS 0x0008
+
+#endif /* _ACR_API_H_ */
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr/api.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr/config.h
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/config.h?rev=1084288&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/config.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/config.h Tue Mar
22 18:36:19 2011
@@ -0,0 +1,54 @@
+/* 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 _ACR_CONFIG_H_
+#define _ACR_CONFIG_H_
+/**
+ * @file config.h
+ * @brief ACR configure file.
+ * This file is here to prevent a file conflict on multiarch systems.
+ * A conflict will occur because config.h has arch-specific definitions.
+ *
+ * DO NOT INCLUDE THE NEW FILE DIRECTLY -- ALWAYS INCLUDE THIS ONE INSTEAD.
+ */
+
+#if defined(_I386_)
+# include <acr/config_i386.h>
+#elif defined(_IA64_)
+# include <acr/config_ia64.h>
+#elif defined(_PPC64_)
+# include <acr/config_ppc64.h>
+#elif defined(_PPC_)
+# include <acr/config_ppc.h>
+#elif defined(_S390X_)
+# include <acr/config_s390x.h>
+#elif defined(_S390_)
+# include <acr/config_s390.h>
+#elif defined(_X86_64_)
+# include <acr/config_x86_64.h>
+#elif defined(_SPARC_)
+# include <acr/config_sparc.h>
+#elif defined(_SPARC64_)
+# include <acr/config_sparc64.h>
+#elif defined(_PARISC_)
+# include <acr/config_parisc.h>
+#elif defined(_PARISC64_)
+# include <acr/config_parisc64.h>
+#else
+# error "This package does not work with your architecture?"
+#endif
+
+#endif /* _ACR_CONFIG_H_ */
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr/config.h
------------------------------------------------------------------------------
svn:eol-style = native