├── CHANGELOG.md ├── LICENSE ├── README.md ├── README.zh_cn.md ├── doc └── Guide.md ├── efc ├── EBase.hh ├── EUtils.hh ├── Efc.hh ├── build │ ├── Makefile_arm_libc │ ├── Makefile_unix_efc │ ├── Makefile_unix_libc │ ├── Makefile_win_efc │ ├── Makefile_win_libc │ └── genlib.bat ├── es_comm.h ├── es_config.h ├── es_main.h ├── es_status.h ├── es_types.h ├── inc │ ├── EA.hh │ ├── EAbstractCollection.hh │ ├── EAbstractList.hh │ ├── EAbstractMap.hh │ ├── EAbstractQueue.hh │ ├── EAbstractSet.hh │ ├── EAdler32.hh │ ├── EAlreadyBoundException.hh │ ├── EAlreadyConnectedException.hh │ ├── EArithmeticException.hh │ ├── EArray.hh │ ├── EArrayDeque.hh │ ├── EArrayIndexOutOfBoundsException.hh │ ├── EArrayList.hh │ ├── EArrays.hh │ ├── EAuthenticationException.hh │ ├── EBase64.hh │ ├── EBigDecimal.hh │ ├── EBigInteger.hh │ ├── EBindException.hh │ ├── EBitSet.hh │ ├── EBits.hh │ ├── EBoolean.hh │ ├── EBson.hh │ ├── EBsonParser.hh │ ├── EBufferedInputStream.hh │ ├── EBufferedOutputStream.hh │ ├── EByte.hh │ ├── EByteArrayInputStream.hh │ ├── EByteArrayOutputStream.hh │ ├── EByteBuffer.hh │ ├── ECRC32.hh │ ├── ECalendar.hh │ ├── ECharacter.hh │ ├── ECheckedInputStream.hh │ ├── ECheckedOutputStream.hh │ ├── EChecksum.hh │ ├── EClassCastException.hh │ ├── ECloseable.hh │ ├── ECollection.hh │ ├── ECollections.hh │ ├── EComparable.hh │ ├── EComparator.hh │ ├── EConcurrentModificationException.hh │ ├── ECondition.hh │ ├── EConfig.hh │ ├── EConnectException.hh │ ├── EDataFormatException.hh │ ├── EDataInput.hh │ ├── EDataInputStream.hh │ ├── EDataOutput.hh │ ├── EDataOutputStream.hh │ ├── EDatagramPacket.hh │ ├── EDatagramSocket.hh │ ├── EDate.hh │ ├── EDeflater.hh │ ├── EDeflaterOutputStream.hh │ ├── EDeque.hh │ ├── EDictionary.hh │ ├── EDouble.hh │ ├── EEOFException.hh │ ├── EEmptyStackException.hh │ ├── EEnumeration.hh │ ├── EEventListener.hh │ ├── EEventListenerProxy.hh │ ├── EEventObject.hh │ ├── EException.hh │ ├── EFile.hh │ ├── EFileFilter.hh │ ├── EFileInputStream.hh │ ├── EFileNotFoundException.hh │ ├── EFileOutputStream.hh │ ├── EFilenameFilter.hh │ ├── EFilterInputStream.hh │ ├── EFilterOutputStream.hh │ ├── EFloat.hh │ ├── EFlushable.hh │ ├── EFork.hh │ ├── EGZIPInputStream.hh │ ├── EGZIPOutputStream.hh │ ├── EHashMap.hh │ ├── EHashSet.hh │ ├── EIOException.hh │ ├── EIOStatus.hh │ ├── EIPAddressUtil.hh │ ├── EIdentityHashMap.hh │ ├── EIllegalArgumentException.hh │ ├── EIllegalBlockingModeException.hh │ ├── EIllegalStateException.hh │ ├── EIllegalThreadStateException.hh │ ├── EIndexOutOfBoundsException.hh │ ├── EInetAddress.hh │ ├── EInetSocketAddress.hh │ ├── EInflater.hh │ ├── EInflaterInputStream.hh │ ├── EInputStream.hh │ ├── EInteger.hh │ ├── EInterfaceAddress.hh │ ├── EInterruptedException.hh │ ├── EInterruptedIOException.hh │ ├── EInterruptible.hh │ ├── EIterable.hh │ ├── EIterator.hh │ ├── ELLong.hh │ ├── ELinkedList.hh │ ├── EList.hh │ ├── EListIterator.hh │ ├── ELock.hh │ ├── ELockPool.hh │ ├── EMalformedURLException.hh │ ├── EMap.hh │ ├── EMatchResult.hh │ ├── EMatcher.hh │ ├── EMath.hh │ ├── EMulticastSocket.hh │ ├── ENavigableMap.hh │ ├── ENavigableSet.hh │ ├── ENetWrapper.hh │ ├── ENetworkInterface.hh │ ├── ENoConnectionPendingException.hh │ ├── ENoRouteToHostException.hh │ ├── ENoSuchElementException.hh │ ├── ENotYetBoundException.hh │ ├── ENotYetConnectedException.hh │ ├── ENullPointerException.hh │ ├── ENumber.hh │ ├── ENumberFormatException.hh │ ├── EOS.hh │ ├── EObject.hh │ ├── EObservable.hh │ ├── EObserver.hh │ ├── EOutOfMemoryError.hh │ ├── EOutputStream.hh │ ├── EPattern.hh │ ├── EPatternSyntaxException.hh │ ├── EPipedInputStream.hh │ ├── EPipedOutputStream.hh │ ├── EPortUnreachableException.hh │ ├── EPrintStream.hh │ ├── EPriorityQueue.hh │ ├── EProcess.hh │ ├── EProperties.hh │ ├── EProtocolException.hh │ ├── EPushbackInputStream.hh │ ├── EQueue.hh │ ├── ERandom.hh │ ├── ERandomAccessFile.hh │ ├── EReference.hh │ ├── ERunnable.hh │ ├── ERuntime.hh │ ├── ERuntimeException.hh │ ├── ESSLCommon.hh │ ├── ESSLServerSocket.hh │ ├── ESSLSocket.hh │ ├── ESaslException.hh │ ├── ESecureRandom.hh │ ├── ESecurityException.hh │ ├── ESentry.hh │ ├── ESequenceInputStream.hh │ ├── EServerSocket.hh │ ├── ESet.hh │ ├── ESharedPtr.hh │ ├── EShort.hh │ ├── ESimpleCondition.hh │ ├── ESimpleEnumeration.hh │ ├── ESimpleLock.hh │ ├── ESimpleMap.hh │ ├── ESimpleStack.hh │ ├── ESimpleVector.hh │ ├── ESocket.hh │ ├── ESocketException.hh │ ├── ESocketOptions.hh │ ├── ESocketTimeoutException.hh │ ├── ESortedMap.hh │ ├── ESortedSet.hh │ ├── ESpinLock.hh │ ├── EStack.hh │ ├── EStream.hh │ ├── EString.hh │ ├── EStringTokenizer.hh │ ├── ESynchronizeable.hh │ ├── ESystem.hh │ ├── EThread.hh │ ├── EThreadGroup.hh │ ├── EThreadLocal.hh │ ├── EThreadLocalStorage.hh │ ├── EThreadUnCInitException.hh │ ├── EThrowable.hh │ ├── ETimeUnit.hh │ ├── ETimer.hh │ ├── ETimerTask.hh │ ├── EToDoException.hh │ ├── ETraits.hh │ ├── ETreeMap.hh │ ├── ETreeSet.hh │ ├── EURI.hh │ ├── EURISyntaxException.hh │ ├── EURLDecoder.hh │ ├── EURLEncoder.hh │ ├── EURLString.hh │ ├── EUnknownHostException.hh │ ├── EUnknownServiceException.hh │ ├── EUnresolvedAddressException.hh │ ├── EUnsupportedAddressTypeException.hh │ ├── EUnsupportedEncodingException.hh │ ├── EUnsupportedOperationException.hh │ ├── EVector.hh │ ├── concurrent │ │ ├── EAbstractExecutorService.hh │ │ ├── EAbstractOwnableSynchronizer.hh │ │ ├── EAbstractQueuedSynchronizer.hh │ │ ├── EArrayBlockingQueue.hh │ │ ├── EAtomic.hh │ │ ├── EAtomicBoolean.hh │ │ ├── EAtomicCounter.hh │ │ ├── EAtomicDouble.hh │ │ ├── EAtomicInteger.hh │ │ ├── EAtomicLLong.hh │ │ ├── EAtomicReference.hh │ │ ├── EBlockingQueue.hh │ │ ├── EBrokenBarrierException.hh │ │ ├── ECallable.hh │ │ ├── ECancellationException.hh │ │ ├── ECompletionService.hh │ │ ├── EConcurrentHashMap.hh │ │ ├── EConcurrentIntrusiveDeque.hh │ │ ├── EConcurrentLinkedQueue.hh │ │ ├── EConcurrentLiteQueue.hh │ │ ├── EConcurrentMap.hh │ │ ├── EConcurrentNavigableMap.hh │ │ ├── EConcurrentSkipListMap.hh │ │ ├── EConcurrentSortedMap.hh │ │ ├── ECopyOnWriteArrayList.hh │ │ ├── ECountDownLatch.hh │ │ ├── ECyclicBarrier.hh │ │ ├── EExchanger.hh │ │ ├── EExecutionException.hh │ │ ├── EExecutor.hh │ │ ├── EExecutorCompletionService.hh │ │ ├── EExecutorService.hh │ │ ├── EExecutors.hh │ │ ├── EFuture.hh │ │ ├── EFutureTask.hh │ │ ├── ELinkedBlockingQueue.hh │ │ ├── ELinkedTransferQueue.hh │ │ ├── ELockSupport.hh │ │ ├── EMutexLinkedQueue.hh │ │ ├── EOrderAccess.hh │ │ ├── EReadWriteLock.hh │ │ ├── EReentrantLock.hh │ │ ├── EReentrantReadWriteLock.hh │ │ ├── ERejectedExecutionException.hh │ │ ├── ERejectedExecutionHandler.hh │ │ ├── ERunnableFuture.hh │ │ ├── ESemaphore.hh │ │ ├── ESynchronousQueue.hh │ │ ├── EThreadFactory.hh │ │ ├── EThreadLocalRandom.hh │ │ ├── EThreadPoolExecutor.hh │ │ ├── ETimeoutException.hh │ │ ├── ETransferQueue.hh │ │ └── EUnsafe.hh │ └── cpp11 │ │ └── EScopeGuard.hh ├── libc │ ├── inc │ │ ├── eso_alogger.h │ │ ├── eso_array.h │ │ ├── eso_array_int.h │ │ ├── eso_array_ptr.h │ │ ├── eso_atomic.h │ │ ├── eso_base64.h │ │ ├── eso_bitset.h │ │ ├── eso_bson.h │ │ ├── eso_bson_ext.h │ │ ├── eso_buffer.h │ │ ├── eso_canonicalize.h │ │ ├── eso_conf.h │ │ ├── eso_crc32.h │ │ ├── eso_datetime.h │ │ ├── eso_debug.h │ │ ├── eso_dso.h │ │ ├── eso_encode.h │ │ ├── eso_except.h │ │ ├── eso_file.h │ │ ├── eso_flip_buffer.h │ │ ├── eso_fmttime.h │ │ ├── eso_hash.h │ │ ├── eso_ini.h │ │ ├── eso_json.h │ │ ├── eso_libc.h │ │ ├── eso_locale_str.h │ │ ├── eso_lz77.h │ │ ├── eso_lzma.h │ │ ├── eso_map.h │ │ ├── eso_md4.h │ │ ├── eso_md5.h │ │ ├── eso_mem.h │ │ ├── eso_mmap.h │ │ ├── eso_mpool.h │ │ ├── eso_net.h │ │ ├── eso_object.h │ │ ├── eso_pcre.h │ │ ├── eso_pipe.h │ │ ├── eso_poll.h │ │ ├── eso_printf_upper_bound.h │ │ ├── eso_proc.h │ │ ├── eso_proc_mutex.h │ │ ├── eso_queue.h │ │ ├── eso_ring.h │ │ ├── eso_ring_buffer.h │ │ ├── eso_sha1.h │ │ ├── eso_sha2.h │ │ ├── eso_shm.h │ │ ├── eso_signal.h │ │ ├── eso_sigsegv.h │ │ ├── eso_stack.h │ │ ├── eso_string.h │ │ ├── eso_sys.h │ │ ├── eso_thread.h │ │ ├── eso_thread_cond.h │ │ ├── eso_thread_mutex.h │ │ ├── eso_thread_rwlock.h │ │ ├── eso_thread_spin.h │ │ ├── eso_util.h │ │ ├── eso_uuid.h │ │ ├── eso_vector.h │ │ └── eso_zlib.h │ ├── libc.h │ └── src │ │ ├── canonicalize_unix.inl │ │ ├── canonicalize_win.inl │ │ ├── eso_alogger.c │ │ ├── eso_array.c │ │ ├── eso_array_int.c │ │ ├── eso_array_ptr.c │ │ ├── eso_atomic.c │ │ ├── eso_base64.c │ │ ├── eso_bitset.c │ │ ├── eso_bson.c │ │ ├── eso_bson_ext.c │ │ ├── eso_buffer.c │ │ ├── eso_canonicalize.c │ │ ├── eso_conf.c │ │ ├── eso_crc32.c │ │ ├── eso_datetime.c │ │ ├── eso_debug.c │ │ ├── eso_dso.c │ │ ├── eso_encode.c │ │ ├── eso_except.c │ │ ├── eso_file.c │ │ ├── eso_flip_buffer.c │ │ ├── eso_fmttime.c │ │ ├── eso_hash.c │ │ ├── eso_ini.c │ │ ├── eso_json.c │ │ ├── eso_lz77.c │ │ ├── eso_lzma.c │ │ ├── eso_map.c │ │ ├── eso_md4.c │ │ ├── eso_md5.c │ │ ├── eso_mem.c │ │ ├── eso_mmap.c │ │ ├── eso_mpool.c │ │ ├── eso_net.c │ │ ├── eso_object.c │ │ ├── eso_pcre.c │ │ ├── eso_pipe.c │ │ ├── eso_poll.c │ │ ├── eso_printf_upper_bound.c │ │ ├── eso_proc.c │ │ ├── eso_proc_mutex.c │ │ ├── eso_queue.c │ │ ├── eso_ring_buffer.c │ │ ├── eso_sha1.c │ │ ├── eso_sha2.c │ │ ├── eso_shm.c │ │ ├── eso_signal.c │ │ ├── eso_sigsegv.c │ │ ├── eso_stack.c │ │ ├── eso_string.c │ │ ├── eso_sys.c │ │ ├── eso_thread.c │ │ ├── eso_thread_cond.c │ │ ├── eso_thread_mutex.c │ │ ├── eso_thread_rwlock.c │ │ ├── eso_thread_spin.c │ │ ├── eso_util.c │ │ ├── eso_uuid.c │ │ ├── eso_vector.c │ │ ├── eso_zlib.c │ │ ├── lzma │ │ ├── LzFind.c │ │ ├── LzFind.h │ │ ├── LzHash.h │ │ ├── LzmaDec.c │ │ ├── LzmaDec.h │ │ ├── LzmaEnc.c │ │ ├── LzmaEnc.h │ │ └── Types.h │ │ ├── pcre │ │ ├── AUTHORS │ │ ├── COPYING │ │ ├── ChangeLog │ │ ├── HACKING │ │ ├── LICENCE │ │ ├── NEWS │ │ ├── NON-UNIX-USE │ │ ├── README │ │ ├── config.h │ │ ├── doc │ │ │ └── pcre.txt │ │ ├── pcre.h │ │ ├── pcre_chartables.c │ │ ├── pcre_compile.c │ │ ├── pcre_config.c │ │ ├── pcre_exec.c │ │ ├── pcre_fullinfo.c │ │ ├── pcre_get.c │ │ ├── pcre_globals.c │ │ ├── pcre_internal.h │ │ ├── pcre_maketables.c │ │ ├── pcre_newline.c │ │ ├── pcre_ord2utf8.c │ │ ├── pcre_printint.src │ │ ├── pcre_refcount.c │ │ ├── pcre_study.c │ │ ├── pcre_tables.c │ │ ├── pcre_ucd.c │ │ ├── pcre_valid_utf8.c │ │ ├── pcre_version.c │ │ ├── pcre_xclass.c │ │ ├── testdata │ │ │ ├── grepinput │ │ │ ├── grepinput8 │ │ │ ├── grepinputx │ │ │ ├── greplist │ │ │ ├── grepoutput │ │ │ ├── grepoutput8 │ │ │ ├── grepoutputN │ │ │ ├── testinput1 │ │ │ ├── testinput10 │ │ │ ├── testinput2 │ │ │ ├── testinput3 │ │ │ ├── testinput4 │ │ │ ├── testinput5 │ │ │ ├── testinput6 │ │ │ ├── testinput7 │ │ │ ├── testinput8 │ │ │ ├── testinput9 │ │ │ ├── testoutput1 │ │ │ ├── testoutput10 │ │ │ ├── testoutput2 │ │ │ ├── testoutput3 │ │ │ ├── testoutput4 │ │ │ ├── testoutput5 │ │ │ ├── testoutput6 │ │ │ ├── testoutput7 │ │ │ ├── testoutput8 │ │ │ └── testoutput9 │ │ └── ucp.h │ │ ├── poll │ │ ├── ae_epoll.c │ │ ├── ae_evport.c │ │ ├── ae_kqueue.c │ │ └── ae_select.c │ │ ├── sample1.conf │ │ ├── sample2.conf │ │ └── zlib │ │ ├── adler32.c │ │ ├── compress.c │ │ ├── crc32.c │ │ ├── crc32.h │ │ ├── deflate.c │ │ ├── deflate.h │ │ ├── gzclose.c │ │ ├── gzguts.h │ │ ├── gzlib.c │ │ ├── gzread.c │ │ ├── gzwrite.c │ │ ├── infback.c │ │ ├── inffast.c │ │ ├── inffast.h │ │ ├── inffixed.h │ │ ├── inflate.c │ │ ├── inflate.h │ │ ├── inftrees.c │ │ ├── inftrees.h │ │ ├── trees.c │ │ ├── trees.h │ │ ├── uncompr.c │ │ ├── zconf.h │ │ ├── zlib.h │ │ ├── zutil.c │ │ └── zutil.h ├── nio │ ├── inc │ │ ├── EAsynchronousCloseException.hh │ │ ├── EBufferOverflowException.hh │ │ ├── EBufferUnderflowException.hh │ │ ├── EByteChannel.hh │ │ ├── ECancelledKeyException.hh │ │ ├── EChannel.hh │ │ ├── EChannelInputStream.hh │ │ ├── EClosedByInterruptException.hh │ │ ├── EClosedChannelException.hh │ │ ├── EClosedSelectorException.hh │ │ ├── EConnectionPendingException.hh │ │ ├── EDatagramChannel.hh │ │ ├── EFileChannel.hh │ │ ├── EFileDispatcher.hh │ │ ├── EFileKey.hh │ │ ├── EFileLock.hh │ │ ├── EIOByteBuffer.hh │ │ ├── EInterruptibleChannel.hh │ │ ├── EInvalidMarkException.hh │ │ ├── EMappedByteBuffer.hh │ │ ├── EMembershipKey.hh │ │ ├── EMulticastChannel.hh │ │ ├── ENativeThreadSet.hh │ │ ├── ENonReadableChannelException.hh │ │ ├── ENonWritableChannelException.hh │ │ ├── EOverlappingFileLockException.hh │ │ ├── EReadOnlyBufferException.hh │ │ ├── ESelectableChannel.hh │ │ ├── ESelectionKey.hh │ │ ├── ESelector.hh │ │ ├── EServerSocketChannel.hh │ │ └── ESocketChannel.hh │ └── src │ │ ├── EChannelInputStream.cpp │ │ ├── EDatagramChannel.cpp │ │ ├── EDatagramDispatcher.cpp │ │ ├── EDatagramDispatcher.hh │ │ ├── EDatagramSocketAdaptor.cpp │ │ ├── EDatagramSocketAdaptor.hh │ │ ├── EEPollArrayWrapper.cpp │ │ ├── EEPollArrayWrapper.hh │ │ ├── EEPollSelectorImpl.cpp │ │ ├── EEPollSelectorImpl.hh │ │ ├── EFileChannel.cpp │ │ ├── EFileDispatcher.cpp │ │ ├── EFileKey.cpp │ │ ├── EFileLock.cpp │ │ ├── EIOByteBuffer.cpp │ │ ├── EIONetWrapper.cpp │ │ ├── EIONetWrapper.hh │ │ ├── EInterruptibleChannel.cpp │ │ ├── EKQueueArrayWrapper.cpp │ │ ├── EKQueueArrayWrapper.hh │ │ ├── EKQueueSelectorImpl.cpp │ │ ├── EKQueueSelectorImpl.hh │ │ ├── EMappedByteBuffer.cpp │ │ ├── EMembershipKey.cpp │ │ ├── EMembershipRegistry.cpp │ │ ├── EMembershipRegistry.hh │ │ ├── ENIOUtil.cpp │ │ ├── ENIOUtil.hh │ │ ├── ENativeThread.cpp │ │ ├── ENativeThread.hh │ │ ├── ENativeThreadSet.cpp │ │ ├── EPipeWrapper.cpp │ │ ├── EPipeWrapper.hh │ │ ├── EPollArrayWrapper.cpp │ │ ├── EPollArrayWrapper.hh │ │ ├── EPollSelectorImpl.cpp │ │ ├── EPollSelectorImpl.hh │ │ ├── ESelectableChannel.cpp │ │ ├── ESelectionKey.cpp │ │ ├── ESelector.cpp │ │ ├── EServerSocketAdaptor.cpp │ │ ├── EServerSocketAdaptor.hh │ │ ├── EServerSocketChannel.cpp │ │ ├── ESocketAdaptor.cpp │ │ ├── ESocketAdaptor.hh │ │ ├── ESocketChannel.cpp │ │ ├── ESocketDispatcher.cpp │ │ └── ESocketDispatcher.hh ├── src │ ├── EAdler32.cpp │ ├── EBase64.cpp │ ├── EBigDecimal.cpp │ ├── EBigInteger.cpp │ ├── EBitSet.cpp │ ├── EBits.cpp │ ├── EBoolean.cpp │ ├── EBson.cpp │ ├── EBsonParser.cpp │ ├── EBufferedInputStream.cpp │ ├── EBufferedOutputStream.cpp │ ├── EByte.cpp │ ├── EByteArrayInputStream.cpp │ ├── EByteArrayOutputStream.cpp │ ├── EByteBuffer.cpp │ ├── ECRC32.cpp │ ├── ECalendar.cpp │ ├── ECharacter.cpp │ ├── ECheckedInputStream.cpp │ ├── ECheckedOutputStream.cpp │ ├── EConfig.cpp │ ├── EDataInputStream.cpp │ ├── EDataOutputStream.cpp │ ├── EDatagramPacket.cpp │ ├── EDatagramSocket.cpp │ ├── EDate.cpp │ ├── EDeflater.cpp │ ├── EDeflaterOutputStream.cpp │ ├── EDouble.cpp │ ├── EEventObject.cpp │ ├── EFile.cpp │ ├── EFileInputStream.cpp │ ├── EFileOutputStream.cpp │ ├── EFilterInputStream.cpp │ ├── EFilterOutputStream.cpp │ ├── EFloat.cpp │ ├── EFork.cpp │ ├── EGZIPInputStream.cpp │ ├── EGZIPOutputStream.cpp │ ├── EIPAddressUtil.cpp │ ├── EIdentityHashMap.cpp │ ├── EInetAddress.cpp │ ├── EInetSocketAddress.cpp │ ├── EInflater.cpp │ ├── EInflaterInputStream.cpp │ ├── EInputStream.cpp │ ├── EInteger.cpp │ ├── EInterfaceAddress.cpp │ ├── ELLong.cpp │ ├── EMatcher.cpp │ ├── EMath.cpp │ ├── EMulticastSocket.cpp │ ├── ENetWrapper.cpp │ ├── ENetworkInterface.cpp │ ├── EOS.cpp │ ├── EObject.cpp │ ├── EObservable.cpp │ ├── EOutputStream.cpp │ ├── EPark.cpp │ ├── EPark.hh │ ├── EPattern.cpp │ ├── EPipedInputStream.cpp │ ├── EPipedOutputStream.cpp │ ├── EPrintStream.cpp │ ├── EProcess.cpp │ ├── EProperties.cpp │ ├── EPushbackInputStream.cpp │ ├── ERandom.cpp │ ├── ERandomAccessFile.cpp │ ├── ERuntime.cpp │ ├── ESSLCommon.cpp │ ├── ESSLServerSocket.cpp │ ├── ESSLSocket.cpp │ ├── ESecureRandom.cpp │ ├── ESentry.cpp │ ├── ESequenceInputStream.cpp │ ├── EServerSocket.cpp │ ├── ESharedPtr.cpp │ ├── EShort.cpp │ ├── ESimpleCondition.cpp │ ├── ESimpleLock.cpp │ ├── ESimpleMap.cpp │ ├── ESimpleStack.cpp │ ├── ESimpleVector.cpp │ ├── ESocket.cpp │ ├── ESocketOptions.cpp │ ├── ESpinLock.cpp │ ├── EStream.cpp │ ├── EString.cpp │ ├── EStringTokenizer.cpp │ ├── ESystem.cpp │ ├── EThread.cpp │ ├── EThreadGroup.cpp │ ├── EThreadLocal.cpp │ ├── EThreadLocalStorage.cpp │ ├── EThreadService.hh │ ├── EThrowable.cpp │ ├── ETimeUnit.cpp │ ├── ETimer.cpp │ ├── ETimerTask.cpp │ ├── EURI.cpp │ ├── EURLDecoder.cpp │ ├── EURLEncoder.cpp │ ├── EURLString.cpp │ └── concurrent │ │ ├── EAbstractQueuedSynchronizer.cpp │ │ ├── EAtomic.cpp │ │ ├── EAtomicBoolean.cpp │ │ ├── EAtomicCounter.cpp │ │ ├── EAtomicDouble.cpp │ │ ├── EAtomicInteger.cpp │ │ ├── EAtomicLLong.cpp │ │ ├── ECountDownLatch.cpp │ │ ├── ECyclicBarrier.cpp │ │ ├── EExecutors.cpp │ │ ├── ELockSupport.cpp │ │ ├── EOrderAccess.cpp │ │ ├── EReentrantLock.cpp │ │ ├── EReentrantReadWriteLock.cpp │ │ ├── ESemaphore.cpp │ │ ├── EThreadLocalRandom.cpp │ │ ├── EThreadPoolExecutor.cpp │ │ └── EUnsafe.cpp └── utils │ ├── inc │ ├── EBoundedInputStream.hh │ ├── EDomainServerSocket.hh │ └── EDomainSocket.hh │ └── src │ ├── EBoundedInputStream.cpp │ ├── EDomainServerSocket.cpp │ └── EDomainSocket.cpp ├── img └── test_concurrentHashmap.gif ├── lib ├── cl_version_LE.bat ├── linux │ ├── libefc32.a │ ├── libefc64.a │ ├── libeso32.a │ └── libeso64.a ├── osx │ ├── libefc64.a │ └── libeso64.a └── win │ ├── efc16.lib │ ├── efc19.lib │ ├── eso16.lib │ └── eso19.lib └── test ├── Makefile_unix ├── Makefile_win ├── main.cpp ├── sample.conf ├── sample.ini ├── testbson.cpp ├── testc11.cpp ├── testefc.cpp ├── testlibc.cpp ├── testnio.cpp ├── testssl.cpp ├── teststr.cpp └── testutils.cpp /efc/EUtils.hh: -------------------------------------------------------------------------------- 1 | #ifndef __EUTILS_H__ 2 | #define __EUTILS_H__ 3 | 4 | #define EUTILS_VERSION "0.1.0" 5 | 6 | #include "Efc.hh" 7 | 8 | //utils 9 | #include "./utils/inc/EBoundedInputStream.hh" 10 | #include "./utils/inc/EDomainSocket.hh" 11 | #include "./utils/inc/EDomainServerSocket.hh" 12 | 13 | using namespace efc::utils; 14 | 15 | #endif /* __EUTILS_H__ */ 16 | -------------------------------------------------------------------------------- /efc/build/genlib.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat" 3 | rem "C:\Program Files\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat" 4 | 5 | echo =============================== 6 | echo make win eso8.lib 7 | echo =============================== 8 | rem ..\..\tools\bmake.exe -f Makefile_win all 9 | nmake.exe -f Makefile_win all 10 | 11 | echo =============================== 12 | echo make arm libeso_l.a 13 | echo =============================== 14 | rem ..\..\tools\bmake.exe -DLIBNAME=libeso_l.a -DENDIANMODE=littleend -f Makefile_arm all 15 | nmake.exe -DLIBNAME=libeso_l.a -DENDIANMODE=littleend -f Makefile_arm all 16 | 17 | pause 18 | -------------------------------------------------------------------------------- /efc/es_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file es_config.h 3 | * @brief ES Prefix Definitions 4 | */ 5 | 6 | #ifndef ES_CONFIG_H_ 7 | #define ES_CONFIG_H_ 8 | 9 | #ifdef WIN32 10 | 11 | #define WIN32_LEAN_AND_MEAN //@see: http://www.cppblog.com/tx7do/archive/2008/04/20/47654.html 12 | 13 | #elif defined(__sun) //solaris 14 | 15 | #define HAVE_EVPORT //solaris evport 16 | 17 | #elif defined(__linux__) //linux 18 | 19 | #define HAVE_EPOLL //linux epoll 20 | 21 | #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) //bsd 22 | 23 | #define __bsd__ 24 | 25 | #define HAVE_KQUEUE //bsd kqueue 26 | 27 | #else //other. 28 | 29 | #endif 30 | 31 | #define HAVE_SELECT //default 32 | 33 | /** 34 | * The accept4 system call which exists from kernel 2.6.28 35 | * and from glibc 2.10 (both conditions must be satisfied). 36 | */ 37 | //#define HAVE_ACCEPT4 38 | 39 | //#define HAVE_IPV6 40 | 41 | #define HAVE_THREADS 42 | 43 | #define HAVE_OPENSSL 44 | 45 | #endif /* ES_CONFIG_H_ */ 46 | -------------------------------------------------------------------------------- /efc/es_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * es_main.h 3 | * 4 | * Created on: 2013-8-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ES_MAIN_H_ 9 | #define ES_MAIN_H_ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | #ifdef __MAIN__ 16 | #define MAIN_IMPL(name) int main(int argc, const char **argv) 17 | #else //! 18 | #define MAIN_IMPL(name) \ 19 | int run_main_##name(int argc, const char** argv); \ 20 | int run_main_##name(int argc, const char** argv) 21 | 22 | #define MAIN_CALL(name) \ 23 | extern int run_main_##name(int argc, const char** argv); \ 24 | run_main_##name(argc, argv) 25 | #endif //!__MAIN__ 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* ES_MAIN_H_ */ 32 | -------------------------------------------------------------------------------- /efc/inc/EAdler32.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EADLER32.hh 3 | * 4 | * Created on: 2017-12-24 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EADLER32_HH_ 9 | #define EADLER32_HH_ 10 | 11 | #include "EObject.hh" 12 | #include "EChecksum.hh" 13 | 14 | namespace efc { 15 | 16 | /** 17 | * A class that can be used to compute the Adler-32 checksum of a data 18 | * stream. An Adler-32 checksum is almost as reliable as a CRC-32 but 19 | * can be computed much faster. 20 | * 21 | *

Passing a {@code null} argument to a method in this class will cause 22 | * a {@link NullPointerException} to be thrown. 23 | * 24 | * @see Checksum 25 | */ 26 | 27 | class EAdler32: virtual public EChecksum { 28 | public: 29 | virtual ~EAdler32(); 30 | 31 | /** 32 | * Creates a new Adler32 object. 33 | */ 34 | EAdler32(); 35 | 36 | /** 37 | * Updates the checksum with the specified byte (the low eight 38 | * bits of the argument b). 39 | * 40 | * @param b the byte to update the checksum with 41 | */ 42 | void update(byte b); 43 | 44 | /** 45 | * Updates the checksum with the specified array of bytes. 46 | * 47 | * @param b the byte array to update the checksum with 48 | */ 49 | void update(byte* b, int len); 50 | 51 | /** 52 | * Resets the checksum to initial value. 53 | */ 54 | llong getValue(); 55 | 56 | /** 57 | * Resets CRC-32 to initial value. 58 | */ 59 | void reset(); 60 | 61 | private: 62 | ulong adler;// = 1; 63 | }; 64 | 65 | } /* namespace efc */ 66 | #endif /* EADLER32_HH_ */ 67 | -------------------------------------------------------------------------------- /efc/inc/EAlreadyBoundException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EAlreadyBoundException.h 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EALREADYBOUNDEXCEPTION_HH_ 9 | #define EALREADYBOUNDEXCEPTION_HH_ 10 | 11 | #include "EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EALREADYBOUNDEXCEPTION EAlreadyBoundException(__FILE__, __LINE__, errno) 16 | #define EALREADYBOUNDEXCEPTIONS(msg) EAlreadyBoundException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * An AlreadyBoundException is thrown if an attempt 20 | * is made to bind an object in the registry to a name that already 21 | * has an associated binding. 22 | * 23 | * @since JDK1.1 24 | * @see java.rmi.Naming#bind(String, java.rmi.Remote) 25 | * @see java.rmi.registry.Registry#bind(String, java.rmi.Remote) 26 | */ 27 | 28 | class EAlreadyBoundException: public EIllegalStateException { 29 | public: 30 | /** 31 | * Constructs an EAlreadyBoundException with no 32 | * detail message. 33 | * 34 | * @param _file_ __FILE__ 35 | * @param _line_ __LINE__ 36 | * @param errn errno 37 | */ 38 | EAlreadyBoundException(const char *_file_, int _line_, int errn = 0) : 39 | EIllegalStateException(_file_, _line_, errn) { 40 | } 41 | 42 | /** 43 | * Constructs an EAlreadyBoundException with the 44 | * specified detail message. 45 | * 46 | * @param _file_ __FILE__. 47 | * @param _line_ __LINE__. 48 | * @param s the detail message. 49 | */ 50 | EAlreadyBoundException(const char *_file_, int _line_, const char *s) : 51 | EIllegalStateException(_file_, _line_, s) { 52 | } 53 | }; 54 | 55 | } /* namespace efc */ 56 | #endif /* EALREADYBOUNDEXCEPTION_HH_ */ 57 | -------------------------------------------------------------------------------- /efc/inc/EAlreadyConnectedException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EAlreadyConnectedException.hh 3 | * 4 | * Created on: 2013-12-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EALREADYCONNECTEDEXCEPTION_HH_ 9 | #define EALREADYCONNECTEDEXCEPTION_HH_ 10 | 11 | #include "EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EALREADYCONNECTEDEXCEPTION EAlreadyConnectedException(__FILE__, __LINE__, errno) 16 | #define EALREADYCONNECTEDEXCEPTIONS(msg) EAlreadyConnectedException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Unchecked exception thrown when an attempt is made to connect a {@link 20 | * SocketChannel} that is already connected. 21 | */ 22 | 23 | class EAlreadyConnectedException : public EIllegalStateException { 24 | public: 25 | /** 26 | * Constructs an EAlreadyConnectedException with no 27 | * detail message. 28 | * 29 | * @param _file_ __FILE__ 30 | * @param _line_ __LINE__ 31 | * @param errn errno 32 | */ 33 | EAlreadyConnectedException(const char *_file_, int _line_, int errn = 0) : 34 | EIllegalStateException(_file_, _line_, errn) { 35 | } 36 | 37 | /** 38 | * Constructs an EAlreadyConnectedException with the 39 | * specified detail message. 40 | * 41 | * @param _file_ __FILE__. 42 | * @param _line_ __LINE__. 43 | * @param s the detail message. 44 | */ 45 | EAlreadyConnectedException(const char *_file_, 46 | int _line_, const char *s) : 47 | EIllegalStateException(_file_, _line_, s) { 48 | } 49 | }; 50 | 51 | } /* namespace efc */ 52 | #endif /* EALREADYCONNECTEDEXCEPTION_HH_ */ 53 | -------------------------------------------------------------------------------- /efc/inc/EArithmeticException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EArithmeticException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EARITHMETICEXCEPTION_H_ 9 | #define EARITHMETICEXCEPTION_H_ 10 | 11 | #include "ERuntimeException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EARITHMETICEXCEPTION EArithmeticException(__FILE__, __LINE__, errno) 16 | #define EARITHMETICEXCEPTIONS(msg) EArithmeticException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown when an exceptional arithmetic condition has occurred. For 20 | * example, an integer "divide by zero" throws an 21 | * instance of this class. 22 | * 23 | * {@code ArithmeticException} objects may be constructed by the 24 | * virtual machine as if {@linkplain Throwable#Throwable(String, 25 | * Throwable, boolean, boolean) suppression were disabled and/or the 26 | * stack trace was not writable}. 27 | * 28 | * @since JDK1.0 29 | */ 30 | 31 | class EArithmeticException: public ERuntimeException { 32 | public: 33 | /** 34 | * Constructs an EArithmeticException with no 35 | * detail message. 36 | * 37 | * @param _file_ __FILE__ 38 | * @param _line_ __LINE__ 39 | * @param errn errno 40 | */ 41 | EArithmeticException(const char *_file_, int _line_, int errn = 0) : 42 | ERuntimeException(_file_, _line_, errn) { 43 | } 44 | 45 | /** 46 | * Constructs an EArithmeticException with the 47 | * specified detail message. 48 | * 49 | * @param _file_ __FILE__. 50 | * @param _line_ __LINE__. 51 | * @param s the detail message. 52 | */ 53 | EArithmeticException(const char *_file_, 54 | int _line_, const char *s) : 55 | ERuntimeException(_file_, _line_, s) { 56 | } 57 | }; 58 | 59 | } /* namespace efc */ 60 | #endif /* EARITHMETICEXCEPTION_H_ */ 61 | -------------------------------------------------------------------------------- /efc/inc/EArrayIndexOutOfBoundsException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EArrayIndexOutOfBoundsException.hh 3 | * 4 | * Created on: 2018-1-1 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EARRAYINDEXOUTOFBOUNDSEXCEPTION_HH_ 9 | #define EARRAYINDEXOUTOFBOUNDSEXCEPTION_HH_ 10 | 11 | #include "EIndexOutOfBoundsException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EARRAYINDEXOUTOFBOUNDSEXCEPTION EArrayIndexOutOfBoundsException(__FILE__, __LINE__, errno) 16 | #define EARRAYINDEXOUTOFBOUNDSEXCEPTIONS(msg) EArrayIndexOutOfBoundsException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that an array has been accessed with an 20 | * illegal index. The index is either negative or greater than or 21 | * equal to the size of the array. 22 | * 23 | * @since JDK1.0 24 | */ 25 | 26 | class EArrayIndexOutOfBoundsException: public EIndexOutOfBoundsException { 27 | public: 28 | /** 29 | * Constructs a new ArrayIndexOutOfBoundsException 30 | * class with an argument indicating the illegal index. 31 | * 32 | * @param _file_ __FILE__. 33 | * @param _line_ __LINE__. 34 | * @param index the illegal index. 35 | */ 36 | EArrayIndexOutOfBoundsException(const char *_file_, int _line_, int index) : 37 | EIndexOutOfBoundsException(_file_, _line_, (EString("Array index out of range: ") + index).c_str()) { 38 | } 39 | 40 | /** 41 | * Constructs an EArrayIndexOutOfBoundsException with the 42 | * specified detail message. 43 | * 44 | * @param _file_ __FILE__. 45 | * @param _line_ __LINE__. 46 | * @param s the detail message. 47 | */ 48 | EArrayIndexOutOfBoundsException(const char *_file_, int _line_, const char *s) : 49 | EIndexOutOfBoundsException(_file_, _line_, s) { 50 | } 51 | }; 52 | 53 | } /* namespace efc */ 54 | #endif /* EARRAYINDEXOUTOFBOUNDSEXCEPTION_HH_ */ 55 | -------------------------------------------------------------------------------- /efc/inc/EBase64.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EBase64.hh 3 | * 4 | * Created on: 2013-7-17 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EBASE64_HH_ 9 | #define EBASE64_HH_ 10 | 11 | #include "EA.hh" 12 | #include "EByteBuffer.hh" 13 | #include "EIllegalArgumentException.hh" 14 | 15 | namespace efc { 16 | 17 | class EBase64 { 18 | public: 19 | /** 20 | * Translates the specified byte array into a Base64 string as per 21 | * Preferences.put(byte[]). 22 | */ 23 | static EString byteArrayToBase64(byte* a, int len); 24 | static EString encodeBase64(byte* a, int len); 25 | 26 | /** 27 | * Translates the specified Base64 string (as per Preferences.get(byte[])) 28 | * into a byte array. 29 | * 30 | * @throw IllegalArgumentException if s is not a valid Base64 31 | * string. 32 | */ 33 | static void base64ToByteArray(EByteBuffer *out, const char* s) THROWS(EIllegalArgumentException); 34 | static EA decodeBase64(const char* s) THROWS(EIllegalArgumentException); 35 | }; 36 | 37 | } /* namespace efc */ 38 | #endif /* EBASE64_HH_ */ 39 | -------------------------------------------------------------------------------- /efc/inc/EBindException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EBindException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EBindException_H_ 9 | #define EBindException_H_ 10 | 11 | #include "ESocketException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EBINDEXCEPTION EBindException(__FILE__, __LINE__, errno) 16 | #define EBINDEXCEPTIONS(msg) EBindException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that there is an error in the underlying 20 | * protocol, such as a TCP error. 21 | * 22 | * @version 1.18, 11/17/05 23 | * @since JDK1.0 24 | */ 25 | 26 | class EBindException: public ESocketException { 27 | public: 28 | /** 29 | * Constructs an EBindException with no 30 | * detail message. 31 | * 32 | * @param _file_ __FILE__ 33 | * @param _line_ __LINE__ 34 | * @param errn errno 35 | */ 36 | EBindException(const char *_file_, int _line_, int errn = 0) : 37 | ESocketException(_file_, _line_, errn) { 38 | } 39 | 40 | /** 41 | * Constructs an EBindException with the 42 | * specified detail message. 43 | * 44 | * @param _file_ __FILE__. 45 | * @param _line_ __LINE__. 46 | * @param s the detail message. 47 | */ 48 | EBindException(const char *_file_, int _line_, const char *s, int errn = 0) : 49 | ESocketException(_file_, _line_, s, errn) { 50 | } 51 | }; 52 | 53 | } /* namespace efc */ 54 | #endif /* EBindException_H_ */ 55 | -------------------------------------------------------------------------------- /efc/inc/EBsonParser.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EBsonParser.hh 3 | * 4 | * Created on: 2013-7-30 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EBSONPARSER_HH_ 9 | #define EBSONPARSER_HH_ 10 | 11 | #include "EBson.hh" 12 | #include "EInputStream.hh" 13 | #include "EDataFormatException.hh" 14 | 15 | namespace efc { 16 | 17 | class EBsonParser: public EObject { 18 | public: 19 | virtual ~EBsonParser(); 20 | 21 | EBsonParser(EInputStream* is); 22 | 23 | // unsupported. 24 | EBsonParser(const EBsonParser& that); 25 | // unsupported. 26 | EBsonParser& operator= (const EBsonParser& that); 27 | 28 | boolean nextBson(EBson* bson) THROWS(EDataFormateException); 29 | 30 | virtual void parsing(es_bson_node_t* node) {}; 31 | 32 | protected: 33 | EInputStream* _is; 34 | EBson* _bson; 35 | 36 | struct Stream { 37 | es_bson_stream_t stm; 38 | EBsonParser* self; 39 | } _es; 40 | 41 | static es_int32_t stream_read(void *s, void *buf, es_size_t *size); 42 | static void parsed_node(void *s, es_bson_t *bson, es_bson_node_t *node); 43 | }; 44 | 45 | } /* namespace efc */ 46 | #endif /* EBSONPARSER_HH_ */ 47 | -------------------------------------------------------------------------------- /efc/inc/ECRC32.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ECRC32.hh 3 | * 4 | * Created on: 2013-7-24 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECRC32_HH_ 9 | #define ECRC32_HH_ 10 | 11 | #include "EObject.hh" 12 | #include "EChecksum.hh" 13 | 14 | namespace efc { 15 | 16 | /** 17 | * A class that can be used to compute the CRC-32 of a data stream. 18 | * 19 | *

Passing a {@code null} argument to a method in this class will cause 20 | * a {@link NullPointerException} to be thrown. 21 | * 22 | * @see Checksum 23 | */ 24 | 25 | class ECRC32: virtual public EChecksum { 26 | public: 27 | virtual ~ECRC32(); 28 | 29 | /** 30 | * Creates a new CRC32 object. 31 | */ 32 | ECRC32(); 33 | 34 | /** 35 | * Updates CRC-32 with specified byte. 36 | */ 37 | void update(byte b); 38 | 39 | /** 40 | * Updates CRC-32 with specified array of bytes. 41 | */ 42 | void update(byte* b, int len); 43 | 44 | /** 45 | * Returns CRC-32 value. 46 | */ 47 | llong getValue(); 48 | 49 | /** 50 | * Resets CRC-32 to initial value. 51 | */ 52 | void reset(); 53 | 54 | private: 55 | es_uint32_t _crc; 56 | }; 57 | 58 | } /* namespace efc */ 59 | #endif /* ECRC32_HH_ */ 60 | -------------------------------------------------------------------------------- /efc/inc/EChecksum.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EChecksum.hh 3 | * 4 | * Created on: 2013-7-24 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECHECKSUM_HH_ 9 | #define ECHECKSUM_HH_ 10 | 11 | #include "EBase.hh" 12 | 13 | namespace efc { 14 | 15 | /** 16 | * An interface representing a data checksum. 17 | * 18 | * @version 1.17, 11/17/05 19 | */ 20 | interface EChecksum : virtual public EObject { 21 | virtual ~EChecksum() { 22 | } 23 | 24 | /** 25 | * Updates the current checksum with the specified byte. 26 | * 27 | * @param b the byte to update the checksum with 28 | */ 29 | virtual void update(byte b) = 0; 30 | 31 | /** 32 | * Updates the current checksum with the specified array of bytes. 33 | * @param b the byte array to update the checksum with 34 | * @param off the start offset of the data 35 | * @param len the number of bytes to use for the update 36 | */ 37 | virtual void update(byte* b, int len) = 0; 38 | 39 | /** 40 | * Returns the current checksum value. 41 | * @return the current checksum value 42 | */ 43 | virtual llong getValue() = 0; 44 | 45 | /** 46 | * Resets the checksum to its initial value. 47 | */ 48 | virtual void reset() = 0; 49 | }; 50 | 51 | } /* namespace efc */ 52 | #endif /* ECHECKSUM_HH_ */ 53 | -------------------------------------------------------------------------------- /efc/inc/EClassCastException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EClassCastException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECLASSCASTEXCEPTION_H_ 9 | #define ECLASSCASTEXCEPTION_H_ 10 | 11 | #include "ERuntimeException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ECLASSCASTEXCEPTION EClassCastException(__FILE__, __LINE__, errno) 16 | #define ECLASSCASTEXCEPTIONS(msg) EClassCastException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that the code has attempted to cast an object 20 | * to a subclass of which it is not an instance. For example, the 21 | * following code generates a ClassCastException: 22 | *

23 |  *     Object x = new Integer(0);
24 |  *     System.out.println((String)x);
25 |  * 
26 | * 27 | * @since JDK1.0 28 | */ 29 | 30 | class EClassCastException: public ERuntimeException { 31 | public: 32 | /** 33 | * Constructs an EClassCastException with no 34 | * detail message. 35 | * 36 | * @param _file_ __FILE__ 37 | * @param _line_ __LINE__ 38 | * @param errn errno 39 | */ 40 | EClassCastException(const char *_file_, int _line_, int errn = 0) : 41 | ERuntimeException(_file_, _line_, errn) { 42 | } 43 | 44 | /** 45 | * Constructs an EClassCastException with the 46 | * specified detail message. 47 | * 48 | * @param _file_ __FILE__. 49 | * @param _line_ __LINE__. 50 | * @param s the detail message. 51 | */ 52 | EClassCastException(const char *_file_, 53 | int _line_, const char *s) : 54 | ERuntimeException(_file_, _line_, s) { 55 | } 56 | }; 57 | 58 | } /* namespace efc */ 59 | #endif /* ECLASSCASTEXCEPTION_H_ */ 60 | -------------------------------------------------------------------------------- /efc/inc/ECloseable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ECloseable.hh 3 | * 4 | * Created on: 2013-3-19 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECloseable_HH_ 9 | #define ECloseable_HH_ 10 | 11 | #include "EIOException.hh" 12 | 13 | namespace efc { 14 | 15 | /** 16 | * A {@code Closeable} is a source or destination of data that can be closed. 17 | * The close method is invoked to release resources that the object is 18 | * holding (such as open files). 19 | * 20 | * @since 1.5 21 | */ 22 | interface ECloseable : virtual public EObject { 23 | virtual ~ECloseable(){} 24 | 25 | /** 26 | * Closes this stream and releases any system resources associated 27 | * with it. If the stream is already closed then invoking this 28 | * method has no effect. 29 | * 30 | *

As noted in {@link AutoCloseable#close()}, cases where the 31 | * close may fail require careful attention. It is strongly advised 32 | * to relinquish the underlying resources and to internally 33 | * mark the {@code Closeable} as closed, prior to throwing 34 | * the {@code IOException}. 35 | * 36 | * @throws IOException if an I/O error occurs 37 | */ 38 | virtual void close() THROWS(IOException) = 0; 39 | }; 40 | 41 | } /* namespace efc */ 42 | #endif /* ECloseable_HH_ */ 43 | 44 | -------------------------------------------------------------------------------- /efc/inc/EConnectException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EConnectException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EConnectException_H_ 9 | #define EConnectException_H_ 10 | 11 | #include "ESocketException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ECONNECTEXCEPTION EConnectException(__FILE__, __LINE__, errno) 16 | #define ECONNECTEXCEPTIONS(msg) EConnectException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Signals that an error occurred while attempting to connect a 20 | * socket to a remote address and port. Typically, the connection 21 | * was refused remotely (e.g., no process is listening on the 22 | * remote address/port). 23 | * 24 | * @since JDK1.1 25 | */ 26 | 27 | class EConnectException: public ESocketException { 28 | public: 29 | /** 30 | * Constructs an EConnectException with no 31 | * detail message. 32 | * 33 | * @param _file_ __FILE__ 34 | * @param _line_ __LINE__ 35 | * @param errn errno 36 | */ 37 | EConnectException(const char *_file_, int _line_, int errn = 0) : 38 | ESocketException(_file_, _line_, errn) { 39 | } 40 | 41 | /** 42 | * Constructs an EConnectException with the 43 | * specified detail message. 44 | * 45 | * @param _file_ __FILE__. 46 | * @param _line_ __LINE__. 47 | * @param s the detail message. 48 | */ 49 | EConnectException(const char *_file_, int _line_, const char *s, int errn = 0) : 50 | ESocketException(_file_, _line_, s, errn) { 51 | } 52 | }; 53 | 54 | } /* namespace efc */ 55 | #endif /* EConnectException_H_ */ 56 | -------------------------------------------------------------------------------- /efc/inc/EDataFormatException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EDataFormatException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EDATAFORMATEXCEPTION_HH_ 9 | #define EDATAFORMATEXCEPTION_HH_ 10 | 11 | #include "EException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EDATAFORMATEXCEPTION EDataFormatException(__FILE__, __LINE__, errno) 16 | #define EDATAFORMATEXCEPTIONS(msg) EDataFormatException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Signals that a data format error has occurred. 20 | * 21 | * @version 1.14, 11/17/05 22 | */ 23 | 24 | class EDataFormatException: public EException { 25 | public: 26 | /** 27 | * Constructs an EDataFormatException with no 28 | * detail message. 29 | * 30 | * @param _file_ __FILE__ 31 | * @param _line_ __LINE__ 32 | * @param errn errno 33 | */ 34 | EDataFormatException(const char *_file_, int _line_, int errn = 0) : 35 | EException(_file_, _line_, errn) { 36 | } 37 | 38 | /** 39 | * Constructs an EDataFormatException with the 40 | * specified detail message. 41 | * 42 | * @param _file_ __FILE__. 43 | * @param _line_ __LINE__. 44 | * @param s the detail message. 45 | */ 46 | EDataFormatException(const char *_file_, 47 | int _line_, const char *s) : 48 | EException(_file_, _line_, s) { 49 | } 50 | }; 51 | 52 | } /* namespace efc */ 53 | #endif /* EDATAFORMATEXCEPTION_HH_ */ 54 | -------------------------------------------------------------------------------- /efc/inc/EEOFException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EEOFException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EEOFEXCEPTION_HH_ 9 | #define EEOFEXCEPTION_HH_ 10 | 11 | #include "EIOException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EEOFEXCEPTION EEOFException(__FILE__, __LINE__, errno) 16 | #define EEOFEXCEPTIONS(msg) EEOFException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Signals that an end of file or end of stream has been reached 20 | * unexpectedly during input. 21 | *

22 | * This exception is mainly used by data input streams to signal end of 23 | * stream. Note that many other input operations return a special value on 24 | * end of stream rather than throwing an exception. 25 | *

26 | * 27 | * @see java.io.DataInputStream 28 | * @see java.io.IOException 29 | * @since JDK1.0 30 | */ 31 | 32 | class EEOFException: public EIOException { 33 | public: 34 | /** 35 | * Constructs an EEOFException with no 36 | * detail message. 37 | * 38 | * @param _file_ __FILE__ 39 | * @param _line_ __LINE__ 40 | * @param errn errno 41 | */ 42 | EEOFException(const char *_file_, int _line_, int errn = 0) : 43 | EIOException(_file_, _line_, errn) { 44 | } 45 | 46 | /** 47 | * Constructs an EEOFException with the 48 | * specified detail message. 49 | * 50 | * @param _file_ __FILE__. 51 | * @param _line_ __LINE__. 52 | * @param s the detail message. 53 | */ 54 | EEOFException(const char *_file_, int _line_, const char *s, int errn = 0) : 55 | EIOException(_file_, _line_, s, errn) { 56 | } 57 | }; 58 | 59 | } /* namespace efc */ 60 | #endif /* EEOFEXCEPTION_HH_ */ 61 | -------------------------------------------------------------------------------- /efc/inc/EEmptyStackException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EEmptyStackException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EEMPTYSTACKEXCEPTION_H_ 9 | #define EEMPTYSTACKEXCEPTION_H_ 10 | 11 | #include "ERuntimeException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EEMPTYSTACKEXCEPTION EEmptyStackException(__FILE__, __LINE__, errno) 16 | #define EEMPTYSTACKEXCEPTIONS(msg) EEmptyStackException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown by methods in the Stack class to indicate 20 | * that the stack is empty. 21 | * 22 | * @see java.util.Stack 23 | * @since JDK1.0 24 | */ 25 | 26 | class EEmptyStackException: public ERuntimeException { 27 | public: 28 | /** 29 | * Constructs an EEmptyStackException with no 30 | * detail message. 31 | * 32 | * @param _file_ __FILE__ 33 | * @param _line_ __LINE__ 34 | * @param errn errno 35 | */ 36 | EEmptyStackException(const char *_file_, int _line_, int errn = 0) : 37 | ERuntimeException(_file_, _line_, errn) { 38 | } 39 | 40 | /** 41 | * Constructs an EEmptyStackException with the 42 | * specified detail message. 43 | * 44 | * @param _file_ __FILE__. 45 | * @param _line_ __LINE__. 46 | * @param s the detail message. 47 | */ 48 | EEmptyStackException(const char *_file_, 49 | int _line_, const char *s) : 50 | ERuntimeException(_file_, _line_, s) { 51 | } 52 | }; 53 | 54 | } /* namespace efc */ 55 | #endif /* EEMPTYSTACKEXCEPTION_H_ */ 56 | -------------------------------------------------------------------------------- /efc/inc/EEventListener.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EEventListener.hh 3 | * 4 | * Created on: 2015-2-6 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EEVENTLISTENER_HH_ 9 | #define EEVENTLISTENER_HH_ 10 | 11 | #include "EObject.hh" 12 | 13 | namespace efc { 14 | 15 | /** 16 | * A tagging interface that all event listener interfaces must extend. 17 | * @since JDK1.1 18 | */ 19 | interface EEventListener : virtual public EObject { 20 | virtual ~EEventListener() { 21 | } 22 | }; 23 | 24 | } /* namespace efc */ 25 | #endif /* EEVENTLISTENER_HH_ */ 26 | -------------------------------------------------------------------------------- /efc/inc/EEventObject.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EEventObject.hh 3 | * 4 | * Created on: 2015-2-6 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EEVENTOBJECT_HH_ 9 | #define EEVENTOBJECT_HH_ 10 | 11 | #include "EString.hh" 12 | 13 | namespace efc { 14 | 15 | /** 16 | *

17 | * The root class from which all event state objects shall be derived. 18 | *

19 | * All Events are constructed with a reference to the object, the "source", 20 | * that is logically deemed to be the object upon which the Event in question 21 | * initially occurred upon. 22 | * 23 | * @since JDK1.1 24 | */ 25 | 26 | class EEventObject: public EObject { 27 | public: 28 | /** 29 | * Constructs a prototypical Event. 30 | * 31 | * @param source The object on which the Event initially occurred. 32 | * @exception IllegalArgumentException if source is null. 33 | */ 34 | EEventObject(EObject* source); 35 | 36 | /** 37 | * The object on which the Event initially occurred. 38 | * 39 | * @return The object on which the Event initially occurred. 40 | */ 41 | EObject* getSource(); 42 | 43 | /** 44 | * Returns a String representation of this EventObject. 45 | * 46 | * @return A a String representation of this EventObject. 47 | */ 48 | virtual EString toString(); 49 | 50 | protected: 51 | /** 52 | * The object on which the Event initially occurred. 53 | */ 54 | EObject* source; 55 | }; 56 | 57 | } /* namespace efc */ 58 | #endif /* EEVENTOBJECT_HH_ */ 59 | -------------------------------------------------------------------------------- /efc/inc/EFileFilter.hh: -------------------------------------------------------------------------------- 1 | #ifndef __EFILEFILTER_HH__ 2 | #define __EFILEFILTER_HH__ 3 | 4 | #include "EBase.hh" 5 | 6 | namespace efc { 7 | 8 | class EFile; 9 | 10 | /** 11 | * A filter for abstract pathnames. 12 | * 13 | *

Instances of this interface may be passed to the {@link 14 | * File#listFiles(java.io.FileFilter) listFiles(FileFilter)} method 15 | * of the {@link java.io.File} class. 16 | * 17 | * @since 1.2 18 | */ 19 | 20 | interface EFileFilter : virtual public EObject 21 | { 22 | virtual ~EFileFilter(){} 23 | 24 | /** 25 | * Tests whether or not the specified abstract pathname should be 26 | * included in a pathname list. 27 | * 28 | * @param pathname The abstract pathname to be tested 29 | * @return true if and only if pathname 30 | * should be included 31 | */ 32 | virtual boolean accept(EFile *pathname) = 0; 33 | }; 34 | 35 | } /* namespace efc */ 36 | #endif //!__EFILEFILTER_HH__ 37 | -------------------------------------------------------------------------------- /efc/inc/EFileNotFoundException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EFileNotFoundException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EFILENOTFOUNDEXCEPTION_H_ 9 | #define EFILENOTFOUNDEXCEPTION_H_ 10 | 11 | #include "EIOException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EFILENOTFOUNDEXCEPTION EFileNotFoundException(__FILE__, __LINE__, errno) 16 | #define EFILENOTFOUNDEXCEPTIONS(msg) EFileNotFoundException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Signals that an attempt to open the file denoted by a specified pathname 20 | * has failed. 21 | * 22 | *

This exception will be thrown by the {@link FileInputStream}, {@link 23 | * FileOutputStream}, and {@link RandomAccessFile} constructors when a file 24 | * with the specified pathname does not exist. It will also be thrown by these 25 | * constructors if the file does exist but for some reason is inaccessible, for 26 | * example when an attempt is made to open a read-only file for writing. 27 | */ 28 | 29 | class EFileNotFoundException: public EIOException { 30 | public: 31 | /** 32 | * Constructs an EFileNotFoundException with no 33 | * detail message. 34 | * 35 | * @param _file_ __FILE__ 36 | * @param _line_ __LINE__ 37 | * @param errn errno 38 | */ 39 | EFileNotFoundException(const char *_file_, int _line_, int errn = 0) : 40 | EIOException(_file_, _line_, errn) { 41 | } 42 | 43 | /** 44 | * Constructs an EFileNotFoundException with the 45 | * specified detail message. 46 | * 47 | * @param _file_ __FILE__. 48 | * @param _line_ __LINE__. 49 | * @param s the detail message. 50 | */ 51 | EFileNotFoundException(const char *_file_, 52 | int _line_, const char *s) : 53 | EIOException(_file_, _line_, s) { 54 | } 55 | }; 56 | 57 | } /* namespace efc */ 58 | #endif /* EFILENOTFOUNDEXCEPTION_H_ */ 59 | -------------------------------------------------------------------------------- /efc/inc/EFilenameFilter.hh: -------------------------------------------------------------------------------- 1 | #ifndef __EFILENAMEFILTER_HH__ 2 | #define __EFILENAMEFILTER_HH__ 3 | 4 | #include "EBase.hh" 5 | 6 | namespace efc { 7 | 8 | class EFile; 9 | 10 | /** 11 | * This interface has one method which is used for filtering filenames 12 | * returned in a directory listing. It is currently used by the 13 | * \c File::list() method. 14 | * 15 | * The method in this interface determines if a particular file should 16 | * or should not be included in the file listing. 17 | * 18 | * @class FilenameFilter 19 | * @version $Id: FilenameFilter.h,v 1.4 2003-09-13 08:46:07 florian Exp $ 20 | */ 21 | 22 | interface EFilenameFilter : virtual public EObject 23 | { 24 | virtual ~EFilenameFilter(){} 25 | 26 | /** 27 | * This method determines whether or not a given file should be included 28 | * in a directory listing. 29 | * 30 | * @param dir The \c File instance for the directory being read 31 | * @param name The name of the file to test 32 | * 33 | * @return \c true if the file should be included in the list, 34 | * \c false otherwise. 35 | */ 36 | virtual boolean accept(EFile *dir, const char *name) = 0; 37 | }; 38 | 39 | } /* namespace efc */ 40 | #endif //!__EFILENAMEFILTER_HH__ 41 | -------------------------------------------------------------------------------- /efc/inc/EFlushable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EFlushable.hh 3 | * 4 | * Created on: 2013-3-19 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EFlushable_HH_ 9 | #define EFlushable_HH_ 10 | 11 | #include "EIOException.hh" 12 | 13 | namespace efc { 14 | 15 | /** 16 | * A Flushable is a destination of data that can be flushed. The 17 | * flush method is invoked to write any buffered output to the underlying 18 | * stream. 19 | * 20 | * @since 1.5 21 | */ 22 | interface EFlushable : virtual public EObject { 23 | virtual ~EFlushable(){} 24 | 25 | /** 26 | * Flushes this stream by writing any buffered output to the underlying 27 | * stream. 28 | * 29 | * @throws IOException If an I/O error occurs 30 | */ 31 | virtual void flush() THROWS(IOException) = 0; 32 | }; 33 | 34 | } /* namespace efc */ 35 | #endif /* EFlushable_HH_ */ 36 | 37 | -------------------------------------------------------------------------------- /efc/inc/EIllegalBlockingModeException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EIllegalBlockingModeException.hh 3 | * 4 | * Created on: 2013-12-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EILLEGALBLOCKINGMODEEXCEPTION_HH_ 9 | #define EILLEGALBLOCKINGMODEEXCEPTION_HH_ 10 | 11 | #include "EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EILLEGALBLOCKINGMODEEXCEPTION EIllegalBlockingModeException(__FILE__, __LINE__, errno) 16 | #define EILLEGALBLOCKINGMODEEXCEPTIONS(msg) EIllegalBlockingModeException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Unchecked exception thrown when a blocking-mode-specific operation 20 | * is invoked upon a channel in the incorrect blocking mode. 21 | * 22 | * @version 1.9, 01/11/19 23 | * @since 1.4 24 | */ 25 | 26 | class EIllegalBlockingModeException: public EIllegalStateException { 27 | public: 28 | /** 29 | * Constructs an EIllegalBlockingModeException with no 30 | * detail message. 31 | * 32 | * @param _file_ __FILE__ 33 | * @param _line_ __LINE__ 34 | * @param errn errno 35 | */ 36 | EIllegalBlockingModeException(const char *_file_, int _line_, int errn = 0) : 37 | EIllegalStateException(_file_, _line_, errn) { 38 | } 39 | 40 | /** 41 | * Constructs an EIllegalBlockingModeException with the 42 | * specified detail message. 43 | * 44 | * @param _file_ __FILE__. 45 | * @param _line_ __LINE__. 46 | * @param s the detail message. 47 | */ 48 | EIllegalBlockingModeException(const char *_file_, int _line_, 49 | const char *s) : 50 | EIllegalStateException(_file_, _line_, s) { 51 | } 52 | }; 53 | 54 | } /* namespace efc */ 55 | #endif /* EILLEGALBLOCKINGMODEEXCEPTION_HH_ */ 56 | -------------------------------------------------------------------------------- /efc/inc/EIllegalThreadStateException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EIllegalThreadStateException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EILLEGALTHREADSTATEEXCEPTION_HH_ 9 | #define EILLEGALTHREADSTATEEXCEPTION_HH_ 10 | 11 | #include "EIllegalArgumentException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EILLEGALTHREADSTATEEXCEPTION EIllegalThreadStateException(__FILE__, __LINE__, errno) 16 | #define EILLEGALTHREADSTATEEXCEPTIONS(msg) EIllegalThreadStateException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that a thread is not in an appropriate state 20 | * for the requested operation. See, for example, the 21 | * suspend and resume methods in class 22 | * Thread. 23 | * 24 | * @see java.lang.Thread#resume() 25 | * @see java.lang.Thread#suspend() 26 | * @since JDK1.0 27 | */ 28 | 29 | class EIllegalThreadStateException: public EIllegalArgumentException { 30 | public: 31 | /** 32 | * Constructs an EIllegalThreadStateException with no 33 | * detail message. 34 | * 35 | * @param _file_ __FILE__ 36 | * @param _line_ __LINE__ 37 | * @param errn errno 38 | */ 39 | EIllegalThreadStateException(const char *_file_, int _line_, int errn = 0) : 40 | EIllegalArgumentException(_file_, _line_, errn) { 41 | } 42 | 43 | /** 44 | * Constructs an EIllegalThreadStateException with the 45 | * specified detail message. 46 | * 47 | * @param _file_ __FILE__. 48 | * @param _line_ __LINE__. 49 | * @param s the detail message. 50 | */ 51 | EIllegalThreadStateException(const char *_file_, int _line_, const char *s, int errn = 0) : 52 | EIllegalArgumentException(_file_, _line_, s, errn) { 53 | } 54 | }; 55 | 56 | } /* namespace efc */ 57 | #endif /* EILLEGALTHREADSTATEEXCEPTION_HH_ */ 58 | -------------------------------------------------------------------------------- /efc/inc/EIndexOutOfBoundsException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EIndexOutOfBoundsException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EINDEXOUTOFBOUNDSEXCEPTION_H_ 9 | #define EINDEXOUTOFBOUNDSEXCEPTION_H_ 10 | 11 | #include "EException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EINDEXOUTOFBOUNDSEXCEPTION EIndexOutOfBoundsException(__FILE__, __LINE__, errno) 16 | #define EINDEXOUTOFBOUNDSEXCEPTIONS(msg) EIndexOutOfBoundsException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that an index of some sort (such as to an array, 20 | * to a string, or to a vector) is out of range. 21 | *

22 | * Applications can subclass this class to indicate similar exceptions. 23 | */ 24 | 25 | class EIndexOutOfBoundsException: public EException { 26 | public: 27 | /** 28 | * Constructs an EIndexOutOfBoundsException with no 29 | * detail message. 30 | * 31 | * @param _file_ __FILE__ 32 | * @param _line_ __LINE__ 33 | * @param errn errno 34 | */ 35 | EIndexOutOfBoundsException(const char *_file_, int _line_, int errn = 0) : 36 | EException(_file_, _line_, errn) { 37 | } 38 | 39 | /** 40 | * Constructs an EIndexOutOfBoundsException with the 41 | * specified detail message. 42 | * 43 | * @param _file_ __FILE__. 44 | * @param _line_ __LINE__. 45 | * @param s the detail message. 46 | */ 47 | EIndexOutOfBoundsException(const char *_file_, 48 | int _line_, const char *s) : 49 | EException(_file_, _line_, s) { 50 | } 51 | }; 52 | 53 | } /* namespace efc */ 54 | #endif /* EINDEXOUTOFBOUNDSEXCEPTION_H_ */ 55 | -------------------------------------------------------------------------------- /efc/inc/EInterruptible.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EInterruptible.hh 3 | * 4 | * Created on: 2014-10-21 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EINTERRUPTIBLE_HH_ 9 | #define EINTERRUPTIBLE_HH_ 10 | 11 | #include "EThread.hh" 12 | 13 | namespace efc { 14 | 15 | interface EInterruptible { 16 | 17 | virtual ~EInterruptible(){} 18 | 19 | virtual void interrupt(EThread* t) = 0; 20 | 21 | }; 22 | 23 | } /* namespace efc */ 24 | #endif /* EINTERRUPTIBLE_HH_ */ 25 | -------------------------------------------------------------------------------- /efc/inc/EIterable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EIterable.hh 3 | * 4 | * Created on: 2013-3-19 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EITERABLE_HH_ 9 | #define EITERABLE_HH_ 10 | 11 | #include "EIterator.hh" 12 | 13 | namespace efc { 14 | 15 | /** 16 | * Implementing this interface allows an object to be the target of 17 | * the "foreach" statement. 18 | * 19 | * @param the type of elements returned by the iterator 20 | * 21 | * @since 1.5 22 | */ 23 | 24 | #ifdef CPP11_SUPPORT 25 | template 26 | class RangeIter { 27 | public: 28 | RangeIter() {} 29 | RangeIter(sp > i) : i(i) {} 30 | 31 | bool operator!=(const RangeIter& other) const { 32 | return i->hasNext(); 33 | } 34 | 35 | const T operator*() { 36 | return i->next(); 37 | } 38 | 39 | const RangeIter& operator++() { 40 | return *this; 41 | } 42 | 43 | private: 44 | sp > i; 45 | }; 46 | #endif 47 | 48 | template 49 | interface EIterable : virtual public EObject 50 | { 51 | virtual ~EIterable(){} 52 | 53 | /** 54 | * Returns an iterator over a set of elements of type T. 55 | * 56 | * @return an Iterator. 57 | */ 58 | virtual sp > iterator(int index=0) = 0; 59 | 60 | #ifdef CPP11_SUPPORT 61 | RangeIter begin() { 62 | return RangeIter(iterator()); 63 | } 64 | RangeIter end() { 65 | return RangeIter(); 66 | } 67 | #endif 68 | }; 69 | 70 | } /* namespace efc */ 71 | #endif /* EITERABLE_HH_ */ 72 | -------------------------------------------------------------------------------- /efc/inc/EMalformedURLException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EMalformedURLException.h 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EMALFORMEDURLEXCEPTION_H_ 9 | #define EMALFORMEDURLEXCEPTION_H_ 10 | 11 | #include "EIOException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EMALFORMEDURLEXCEPTION EMalformedURLException(__FILE__, __LINE__, errno) 16 | #define EMALFORMEDURLEXCEPTIONS(msg) EMalformedURLException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that a malformed URL has occurred. Either no 20 | * legal protocol could be found in a specification string or the 21 | * string could not be parsed. 22 | * 23 | * @since JDK1.0 24 | */ 25 | 26 | class EMalformedURLException: public EIOException { 27 | public: 28 | /** 29 | * Constructs an EMalformedURLException with no 30 | * detail message. 31 | * 32 | * @param _file_ __FILE__ 33 | * @param _line_ __LINE__ 34 | * @param errn errno 35 | */ 36 | EMalformedURLException(const char *_file_, int _line_, int errn = 0) : 37 | EIOException(_file_, _line_, errn) { 38 | } 39 | 40 | /** 41 | * Constructs an EMalformedURLException with the 42 | * specified detail message. 43 | * 44 | * @param _file_ __FILE__. 45 | * @param _line_ __LINE__. 46 | * @param s the detail message. 47 | */ 48 | EMalformedURLException(const char *_file_, int _line_, const char *s, int errn = 0) : 49 | EIOException(_file_, _line_, s, errn) { 50 | } 51 | }; 52 | 53 | } /* namespace efc */ 54 | #endif /* EMALFORMEDURLEXCEPTION_H_ */ 55 | -------------------------------------------------------------------------------- /efc/inc/ENoConnectionPendingException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENoConnectionPendingException.hh 3 | * 4 | * Created on: 2013-12-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENOCONNECTIONPENDINGEXCEPTION_HH_ 9 | #define ENOCONNECTIONPENDINGEXCEPTION_HH_ 10 | 11 | #include "EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ENOCONNECTIONPENDINGEXCEPTION ENoConnectionPendingException(__FILE__, __LINE__, errno) 16 | #define ENOCONNECTIONPENDINGEXCEPTIONS(msg) ENoConnectionPendingException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Unchecked exception thrown when an attempt is made to connect a {@link 20 | * SocketChannel} for which a non-blocking connection operation is already in 21 | * progress. 22 | */ 23 | 24 | class ENoConnectionPendingException : public EIllegalStateException { 25 | public: 26 | /** 27 | * Constructs an ENoConnectionPendingException with no 28 | * detail message. 29 | * 30 | * @param _file_ __FILE__ 31 | * @param _line_ __LINE__ 32 | * @param errn errno 33 | */ 34 | ENoConnectionPendingException(const char *_file_, int _line_, int errn = 0) : 35 | EIllegalStateException(_file_, _line_, errn) { 36 | } 37 | 38 | /** 39 | * Constructs an ENoConnectionPendingException with the 40 | * specified detail message. 41 | * 42 | * @param _file_ __FILE__. 43 | * @param _line_ __LINE__. 44 | * @param s the detail message. 45 | */ 46 | ENoConnectionPendingException(const char *_file_, 47 | int _line_, const char *s) : 48 | EIllegalStateException(_file_, _line_, s) { 49 | } 50 | }; 51 | 52 | } /* namespace efc */ 53 | #endif /* ENOCONNECTIONPENDINGEXCEPTION_HH_ */ 54 | -------------------------------------------------------------------------------- /efc/inc/ENoRouteToHostException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENoRouteToHostException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENoRouteToHostException_H_ 9 | #define ENoRouteToHostException_H_ 10 | 11 | #include "ESocketException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ENOROUTETOHOSTEXCEPTION ENoRouteToHostException(__FILE__, __LINE__, errno) 16 | #define ENOROUTETOHOSTEXCEPTIONS(msg) ENoRouteToHostException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Signals that an error occurred while attempting to connect a 20 | * socket to a remote address and port. Typically, the remote 21 | * host cannot be reached because of an intervening firewall, or 22 | * if an intermediate router is down. 23 | * 24 | * @since JDK1.1 25 | */ 26 | 27 | class ENoRouteToHostException: public ESocketException { 28 | public: 29 | /** 30 | * Constructs an ENoRouteToHostException with no 31 | * detail message. 32 | * 33 | * @param _file_ __FILE__ 34 | * @param _line_ __LINE__ 35 | * @param errn errno 36 | */ 37 | ENoRouteToHostException(const char *_file_, int _line_, int errn = 0) : 38 | ESocketException(_file_, _line_, errn) { 39 | } 40 | 41 | /** 42 | * Constructs an ENoRouteToHostException with the 43 | * specified detail message. 44 | * 45 | * @param _file_ __FILE__. 46 | * @param _line_ __LINE__. 47 | * @param s the detail message. 48 | */ 49 | ENoRouteToHostException(const char *_file_, int _line_, const char *s, int errn = 0) : 50 | ESocketException(_file_, _line_, s, errn) { 51 | } 52 | }; 53 | 54 | } /* namespace efc */ 55 | #endif /* ENoRouteToHostException_H_ */ 56 | -------------------------------------------------------------------------------- /efc/inc/ENoSuchElementException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENoSuchElementException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENOSUCHELEMENTEXCEPTION_H_ 9 | #define ENOSUCHELEMENTEXCEPTION_H_ 10 | 11 | #include "ERuntimeException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ENOSUCHELEMENTEXCEPTION ENoSuchElementException(__FILE__, __LINE__, errno) 16 | #define ENOSUCHELEMENTEXCEPTIONS(msg) ENoSuchElementException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown by the nextElement method of an 20 | * Enumeration to indicate that there are no more 21 | * elements in the enumeration. 22 | * 23 | * @see java.util.Enumeration 24 | * @see java.util.Enumeration#nextElement() 25 | * @since JDK1.0 26 | */ 27 | 28 | class ENoSuchElementException: public ERuntimeException { 29 | public: 30 | /** 31 | * Constructs an ENoSuchElementException with no 32 | * detail message. 33 | * 34 | * @param _file_ __FILE__ 35 | * @param _line_ __LINE__ 36 | * @param errn errno 37 | */ 38 | ENoSuchElementException(const char *_file_, int _line_, int errn = 0) : 39 | ERuntimeException(_file_, _line_, errn) { 40 | } 41 | 42 | /** 43 | * Constructs an ENoSuchElementException with the 44 | * specified detail message. 45 | * 46 | * @param _file_ __FILE__. 47 | * @param _line_ __LINE__. 48 | * @param s the detail message. 49 | */ 50 | ENoSuchElementException(const char *_file_, 51 | int _line_, const char *s) : 52 | ERuntimeException(_file_, _line_, s) { 53 | } 54 | }; 55 | 56 | } /* namespace efc */ 57 | #endif /* ENOSUCHELEMENTEXCEPTION_H_ */ 58 | -------------------------------------------------------------------------------- /efc/inc/ENotYetBoundException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENotYetBoundException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENOTYETBOUNDEXCEPTION_HH_ 9 | #define ENOTYETBOUNDEXCEPTION_HH_ 10 | 11 | #include "EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ENOTYETBOUNDEXCEPTION ENotYetBoundException(__FILE__, __LINE__, errno) 16 | #define ENOTYETBOUNDEXCEPTIONS(msg) ENotYetBoundException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Unchecked exception thrown when an attempt is made to invoke an I/O 20 | * operation upon a server socket channel that is not yet bound. 21 | */ 22 | 23 | class ENotYetBoundException: public EIllegalStateException { 24 | public: 25 | /** 26 | * Constructs an ENotYetBoundException with no 27 | * detail message. 28 | * 29 | * @param _file_ __FILE__ 30 | * @param _line_ __LINE__ 31 | * @param errn errno 32 | */ 33 | ENotYetBoundException(const char *_file_, int _line_, int errn = 0) : 34 | EIllegalStateException(_file_, _line_, errn) { 35 | } 36 | 37 | /** 38 | * Constructs an ENotYetBoundException with the 39 | * specified detail message. 40 | * 41 | * @param _file_ __FILE__. 42 | * @param _line_ __LINE__. 43 | * @param s the detail message. 44 | */ 45 | ENotYetBoundException(const char *_file_, int _line_, const char *s) : 46 | EIllegalStateException(_file_, _line_, s) { 47 | } 48 | }; 49 | 50 | } /* namespace efc */ 51 | #endif /* ENOTYETBOUNDEXCEPTION_HH_ */ 52 | -------------------------------------------------------------------------------- /efc/inc/ENotYetConnectedException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENotYetConnectedException.hh 3 | * 4 | * Created on: 2013-12-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENOTYETCONNECTEDEXCEPTION_HH_ 9 | #define ENOTYETCONNECTEDEXCEPTION_HH_ 10 | 11 | #include "EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ENOTYETCONNECTEDEXCEPTION ENotYetConnectedException(__FILE__, __LINE__, errno) 16 | #define ENOTYETCONNECTEDEXCEPTIONS(msg) ENotYetConnectedException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Unchecked exception thrown when an attempt is made to invoke an I/O 20 | * operation upon a socket channel that is not yet connected. 21 | */ 22 | 23 | class ENotYetConnectedException : public EIllegalStateException { 24 | public: 25 | /** 26 | * Constructs an ENotYetConnectedException with no 27 | * detail message. 28 | * 29 | * @param _file_ __FILE__ 30 | * @param _line_ __LINE__ 31 | * @param errn errno 32 | */ 33 | ENotYetConnectedException(const char *_file_, int _line_, int errn = 0) : 34 | EIllegalStateException(_file_, _line_, errn) { 35 | } 36 | 37 | /** 38 | * Constructs an ENotYetConnectedException with the 39 | * specified detail message. 40 | * 41 | * @param _file_ __FILE__. 42 | * @param _line_ __LINE__. 43 | * @param s the detail message. 44 | */ 45 | ENotYetConnectedException(const char *_file_, 46 | int _line_, const char *s) : 47 | EIllegalStateException(_file_, _line_, s) { 48 | } 49 | }; 50 | 51 | } /* namespace efc */ 52 | #endif /* ENOTYETCONNECTEDEXCEPTION_HH_ */ 53 | -------------------------------------------------------------------------------- /efc/inc/ENumberFormatException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENumberFormatException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENUMBERFORMATEXCEPTION_H_ 9 | #define ENUMBERFORMATEXCEPTION_H_ 10 | 11 | #include "EException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ENUMBERFORMATEXCEPTION ENumberFormatException(__FILE__, __LINE__, errno) 16 | #define ENUMBERFORMATEXCEPTIONS(msg) ENumberFormatException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that the application has attempted to convert 20 | * a string to one of the numeric types, but that the string does not 21 | * have the appropriate format. 22 | */ 23 | 24 | class ENumberFormatException: public EException { 25 | public: 26 | /** 27 | * Constructs an ENumberFormatException with no 28 | * detail message. 29 | * 30 | * @param _file_ __FILE__ 31 | * @param _line_ __LINE__ 32 | * @param errn errno 33 | */ 34 | ENumberFormatException(const char *_file_, int _line_, int errn = 0) : 35 | EException(_file_, _line_, errn) { 36 | } 37 | 38 | /** 39 | * Constructs an IllegalArgumentException with the 40 | * specified detail message. 41 | * 42 | * @param _file_ __FILE__. 43 | * @param _line_ __LINE__. 44 | * @param s the detail message. 45 | */ 46 | ENumberFormatException(const char *_file_, int _line_, 47 | const char *s) : 48 | EException(_file_, _line_, s) { 49 | } 50 | }; 51 | 52 | } /* namespace efc */ 53 | #endif /* ENUMBERFORMATEXCEPTION_H_ */ 54 | -------------------------------------------------------------------------------- /efc/inc/EOS.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EOS.hh 3 | * 4 | * Created on: 2015-2-11 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EOS_HH_ 9 | #define EOS_HH_ 10 | 11 | #include "EBase.hh" 12 | 13 | namespace efc { 14 | 15 | class EOS { 16 | public: 17 | DECLARE_STATIC_INITZZ; 18 | 19 | public: 20 | // Interface for detecting multiprocessor system 21 | static inline boolean is_MP() { 22 | ES_ASSERT(_processor_count > 0); 23 | return _processor_count > 1; 24 | } 25 | static ullong available_memory(); 26 | static ullong physical_memory(); 27 | 28 | // number of CPUs 29 | static int processor_count() { 30 | return _processor_count; 31 | } 32 | 33 | // size of Page. 34 | static int page_size(void) { 35 | return _page_size; 36 | } 37 | 38 | // Returns the number of CPUs this process is currently allowed to run on. 39 | // Note that on some OSes this can change dynamically. 40 | static int active_processor_count(); 41 | 42 | // Bind processes to processors. 43 | // This is a two step procedure: 44 | // first you generate a distribution of processes to processors, 45 | // then you bind processes according to that distribution. 46 | // Compute a distribution for number of processes to processors. 47 | // Stores the processor id's into the distribution array argument. 48 | // Returns true if it worked, false if it didn't. 49 | static boolean distribute_processes(uint length, uint* distribution); 50 | // Binds the current process to a processor. 51 | // Returns true if it worked, false if it didn't. 52 | static boolean bind_to_processor(uint processor_id); 53 | 54 | protected: 55 | static int _processor_count; // number of processors 56 | static int _page_size; // size of page 57 | static ullong _physical_memory; // number of memorys 58 | }; 59 | 60 | } /* namespace efc */ 61 | #endif /* EOS_HH_ */ 62 | -------------------------------------------------------------------------------- /efc/inc/EObserver.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EObserver.hh 3 | * 4 | * Created on: 2013-3-19 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EOBSERVER_HH_ 9 | #define EOBSERVER_HH_ 10 | 11 | #include "EObject.hh" 12 | 13 | namespace efc { 14 | 15 | class EObservable; 16 | 17 | /** 18 | * A class can implement the Observer interface when it 19 | * wants to be informed of changes in observable objects. 20 | * 21 | * @see java.util.Observable 22 | * @since JDK1.0 23 | */ 24 | 25 | interface EObserver : virtual public EObject 26 | { 27 | virtual ~EObserver(){} 28 | 29 | /** 30 | * This method is called whenever the observed object is changed. An 31 | * application calls an Observable object's 32 | * notifyObservers method to have all the object's 33 | * observers notified of the change. 34 | * 35 | * @param o the observable object. 36 | * @param arg an argument passed to the notifyObservers 37 | * method. 38 | */ 39 | virtual void update(EObservable* o, void* arg) = 0; 40 | }; 41 | 42 | } /* namespace efc */ 43 | #endif /* EOBSERVER_HH_ */ 44 | -------------------------------------------------------------------------------- /efc/inc/EOutOfMemoryError.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EOutOfMemoryError.hh 3 | * 4 | * Created on: 2014-2-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EOUTOFMEMORYERROR_HH_ 9 | #define EOUTOFMEMORYERROR_HH_ 10 | 11 | #include "EThrowable.hh" 12 | 13 | namespace efc { 14 | 15 | #define EOUTOFMEMORYERROR EOutOfMemoryError(__FILE__, __LINE__, errno) 16 | #define EOUTOFMEMORYERRORS(msg) EOutOfMemoryError(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * The class EOutOfMemoryError and its subclasses are a form of 20 | * Throwable that indicates conditions that a reasonable 21 | * application out of memory. 22 | */ 23 | 24 | class EOutOfMemoryError : public EThrowable { 25 | public: 26 | /** 27 | * Constructs an EOutOfMemoryError with no specified detail message. 28 | * 29 | * @param _file_ __FILE__ 30 | * @param _line_ __LINE__ 31 | * @param errn errno 32 | */ 33 | EOutOfMemoryError(const char *_file_, int _line_, int errn = 0) : 34 | EThrowable(_file_, _line_, errn) { 35 | } 36 | 37 | /** 38 | * Constructs an EOutOfMemoryError with the specified detail message. 39 | * 40 | * @param _file_ __FILE__ 41 | * @param _line_ __LINE__ 42 | * @param s the detail message. 43 | */ 44 | EOutOfMemoryError(const char *_file_, int _line_, const char *s, int errn = 0) : 45 | EThrowable(_file_, _line_, s, errn) { 46 | } 47 | }; 48 | 49 | } /* namespace efc */ 50 | #endif /* EOUTOFMEMORYERROR_HH_ */ 51 | -------------------------------------------------------------------------------- /efc/inc/EPortUnreachableException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EPortUnreachableException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EPORTUNREACHABLEEXCEPTION_H_ 9 | #define EPORTUNREACHABLEEXCEPTION_H_ 10 | 11 | #include "ESocketException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EPORTUNREACHABLEEXCEPTION EPortUnreachableException(__FILE__, __LINE__, errno) 16 | #define EPORTUNREACHABLEEXCEPTIONS(msg) EPortUnreachableException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Signals that an ICMP Port Unreachable message has been 20 | * received on a connected datagram. 21 | * 22 | * @since 1.4 23 | */ 24 | 25 | class EPortUnreachableException: public ESocketException { 26 | public: 27 | /** 28 | * Constructs an EPortUnreachableException with no 29 | * detail message. 30 | * 31 | * @param _file_ __FILE__ 32 | * @param _line_ __LINE__ 33 | * @param errn errno 34 | */ 35 | EPortUnreachableException(const char *_file_, int _line_, int errn = 0) : 36 | ESocketException(_file_, _line_, errn) { 37 | } 38 | 39 | /** 40 | * Constructs an EPortUnreachableException with the 41 | * specified detail message. 42 | * 43 | * @param _file_ __FILE__. 44 | * @param _line_ __LINE__. 45 | * @param s the detail message. 46 | */ 47 | EPortUnreachableException(const char *_file_, int _line_, const char *s, int errn = 0) : 48 | ESocketException(_file_, _line_, s, errn) { 49 | } 50 | }; 51 | 52 | } /* namespace efc */ 53 | #endif /* EPORTUNREACHABLEEXCEPTION_H_ */ 54 | -------------------------------------------------------------------------------- /efc/inc/EProtocolException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EProtocolException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EPROTOCOLEXCEPTION_HH_ 9 | #define EPROTOCOLEXCEPTION_HH_ 10 | 11 | #include "EIOException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EPROTOCOLEXCEPTION EProtocolException(__FILE__, __LINE__, errno) 16 | #define EPROTOCOLEXCEPTIONS(msg) EProtocolException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that there is an error in the underlying 20 | * protocol, such as a TCP error. 21 | * 22 | * @since JDK1.0 23 | */ 24 | 25 | class EProtocolException: public EIOException { 26 | public: 27 | /** 28 | * Constructs an EProtocolException with no 29 | * detail message. 30 | * 31 | * @param _file_ __FILE__ 32 | * @param _line_ __LINE__ 33 | * @param errn errno 34 | */ 35 | EProtocolException(const char *_file_, int _line_, int errn = 0) : 36 | EIOException(_file_, _line_, errn) { 37 | } 38 | 39 | /** 40 | * Constructs an EProtocolException with the 41 | * specified detail message. 42 | * 43 | * @param _file_ __FILE__. 44 | * @param _line_ __LINE__. 45 | * @param s the detail message. 46 | */ 47 | EProtocolException(const char *_file_, int _line_, const char *s, int errn = 0) : 48 | EIOException(_file_, _line_, s, errn) { 49 | } 50 | }; 51 | 52 | } /* namespace efc */ 53 | #endif /* EPROTOCOLEXCEPTION_HH_ */ 54 | -------------------------------------------------------------------------------- /efc/inc/EReference.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EReference.hh 3 | * 4 | * Created on: 2014-11-26 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EREFERENCE_HH_ 9 | #define EREFERENCE_HH_ 10 | 11 | #include "EObject.hh" 12 | #include "ESharedPtr.hh" 13 | 14 | namespace efc { 15 | 16 | /** 17 | * This class is for reference objects. This class defines the 18 | * operations common to all reference objects. Because reference objects are 19 | * implemented in close cooperation with the garbage collector, this class may 20 | * not be subclassed directly. 21 | * 22 | * @since 1.2 23 | */ 24 | template 25 | class EReference : public EObject { 26 | public: 27 | EReference(sp& o) : referent(o) { 28 | } 29 | 30 | /* -- Referent accessor and setters -- */ 31 | 32 | /** 33 | * Returns this reference object's referent. If this reference object has 34 | * been cleared, either by the program or by the garbage collector, then 35 | * this method returns null. 36 | * 37 | * @return The object to which this reference refers, or 38 | * null if this reference object has been cleared 39 | */ 40 | sp get() { 41 | return referent.lock(); 42 | } 43 | 44 | /** 45 | * Clears this reference object. Invoking this method will not cause this 46 | * object to be enqueued. 47 | * 48 | *

This method is invoked only by Java code; when the garbage collector 49 | * clears references it does so directly, without invoking this method. 50 | */ 51 | void clear() { 52 | referent.reset(); 53 | } 54 | 55 | private: 56 | sp referent; 57 | }; 58 | 59 | } /* namespace efc */ 60 | #endif /* EREFERENCE_HH_ */ 61 | -------------------------------------------------------------------------------- /efc/inc/ESSLCommon.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ESSLCommon.hh 3 | * 4 | * Created on: 2017-1-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ESSLCOMMON_HH_ 9 | #define ESSLCOMMON_HH_ 10 | 11 | #include "es_config.h" 12 | 13 | #ifdef HAVE_OPENSSL 14 | 15 | #include "EString.hh" 16 | 17 | namespace efc { 18 | 19 | class ESSLCommon { 20 | public: 21 | DECLARE_STATIC_INITZZ; 22 | 23 | public: 24 | /** 25 | * Convenience function to call getErrors() with the current errno value. 26 | * 27 | * Make sure that you only call this when there was no intervening operation 28 | * since the last OpenSSL error that may have changed the current errno value. 29 | */ 30 | static EString getErrors(); 31 | 32 | /** 33 | * Examine OpenSSL's error stack, and return a string description of the 34 | * errors. 35 | * 36 | * This operation removes the errors from OpenSSL's error stack. 37 | */ 38 | static EString getErrors(unsigned long errnoCopy); 39 | }; 40 | 41 | } /* namespace efc */ 42 | #endif //!HAVE_OPENSSL 43 | #endif /* ESSLCOMMON_HH_ */ 44 | -------------------------------------------------------------------------------- /efc/inc/ESentry.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ESentry.hh 3 | * 4 | * Created on: 2015-9-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef __ESentry_H__ 9 | #define __ESentry_H__ 10 | 11 | #include "ELock.hh" 12 | 13 | namespace efc { 14 | 15 | #ifdef HAVE_THREADS 16 | # define SYNCBLOCK(lock) { \ 17 | ESentry __synchronizer__(lock); 18 | #endif 19 | 20 | /** 21 | * @brief A simple wrapper for \c EReentrantLock objects. 22 | * You should not use this class directly but use the 23 | * \c SYNCHRONIZED macro. 24 | * 25 | * To achieve a more Java-like behaviour this 26 | * macro can be used as a substitution for the \c synchronized keyword in java 27 | * to synchronize a whole block of c++ code on 28 | * a certain \c EReentrantLock: 29 | * 30 | * \code 31 | * EReentrantLock* lock = new EReentrantLock(); 32 | * 33 | * { 34 | * ESentry sentry(lock); 35 | * ... 36 | * } 37 | * \endcode 38 | * 39 | * @deprecated Use \c Synchronizeable instead 40 | * @class ESentry 41 | */ 42 | class ESentry { 43 | public: 44 | ~ESentry(); 45 | ESentry(ELock* lock); 46 | private: 47 | ELock* _lock; 48 | }; 49 | 50 | } /* namespace efc */ 51 | #endif //!__ESentry_H__ 52 | -------------------------------------------------------------------------------- /efc/inc/ESimpleEnumeration.hh: -------------------------------------------------------------------------------- 1 | #ifndef __ESimpleEnumeration_H__ 2 | #define __ESimpleEnumeration_H__ 3 | 4 | #include "EBase.hh" 5 | 6 | namespace efc { 7 | 8 | /** 9 | * for (EEnumeration* e = v.elements(); e->hasMoreElements();) { 10 | * //e->nextElement(); 11 | * } 12 | */ 13 | 14 | interface ESimpleEnumeration : virtual public EObject 15 | { 16 | virtual ~ESimpleEnumeration() {} 17 | 18 | //Tests if this enumeration contains more elements. 19 | virtual boolean hasMoreElements() = 0; 20 | //Returns the next element of this enumeration if this enumeration object has at least one more element to provide. 21 | virtual void nextElement(void* element) = 0; 22 | virtual EObject* nextElement() = 0; 23 | }; 24 | 25 | } /* namespace efc */ 26 | #endif //!__ESimpleEnumeration_H__ 27 | -------------------------------------------------------------------------------- /efc/inc/ESimpleStack.hh: -------------------------------------------------------------------------------- 1 | #ifndef __ESimpleStack_H__ 2 | #define __ESimpleStack_H__ 3 | 4 | #include "ESimpleVector.hh" 5 | 6 | namespace efc { 7 | 8 | class ESimpleStack : public ESimpleVector 9 | { 10 | public: 11 | //virtual ~ESimpleStack(){} 12 | 13 | /** 14 | * Pushes an item onto the top of this stack. 15 | */ 16 | void push(EObject* item); 17 | 18 | /** 19 | * Removes the object at the top of this stack and returns that 20 | * object as the value of this function. 21 | */ 22 | EObject* pop(); 23 | 24 | /** 25 | * Looks at the object at the top of this stack without removing it 26 | * from the stack. 27 | */ 28 | EObject* peek(); 29 | 30 | /** 31 | * Tests if this stack is empty. 32 | */ 33 | boolean empty(); 34 | 35 | /** 36 | * Returns the 0-based position where an object is on this stack. 37 | * If the object o occurs as an item in this stack, this 38 | * method returns the distance from the top of the stack of the 39 | * occurrence nearest the top of the stack; the topmost item on the 40 | * stack is considered to be at distance 0. The equals 41 | * method is used to compare o to the 42 | * items in this stack. 43 | * 44 | * @param o the desired object. 45 | * @return the 1-based position from the top of the stack where 46 | * the object is located; the return value -1 47 | * indicates that the object is not on the stack. 48 | */ 49 | int search(EObject *o); 50 | }; 51 | 52 | } /* namespace efc */ 53 | #endif //!__ESimpleStack_H__ 54 | -------------------------------------------------------------------------------- /efc/inc/ESocketTimeoutException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ESocketTimeoutException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ESOCKETTIMEOUTEXCEPTION_HH_ 9 | #define ESOCKETTIMEOUTEXCEPTION_HH_ 10 | 11 | #include "EInterruptedIOException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ESOCKETTIMEOUTEXCEPTION ESocketTimeoutException(__FILE__, __LINE__, errno) 16 | #define ESOCKETTIMEOUTEXCEPTIONS(msg) ESocketTimeoutException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Signals that a timeout has occurred on a socket read or accept. 20 | * 21 | * @since 1.4 22 | */ 23 | 24 | class ESocketTimeoutException: public EInterruptedIOException { 25 | public: 26 | /** 27 | * Constructs an ESocketTimeoutException with no 28 | * detail message. 29 | * 30 | * @param _file_ __FILE__ 31 | * @param _line_ __LINE__ 32 | * @param errn errno 33 | */ 34 | ESocketTimeoutException(const char *_file_, int _line_, int errn = 0) : 35 | EInterruptedIOException(_file_, _line_, errn) { 36 | } 37 | 38 | /** 39 | * Constructs an ESocketTimeoutException with the 40 | * specified detail message. 41 | * 42 | * @param _file_ __FILE__. 43 | * @param _line_ __LINE__. 44 | * @param s the detail message. 45 | */ 46 | ESocketTimeoutException(const char *_file_, 47 | int _line_, const char *s) : 48 | EInterruptedIOException(_file_, _line_, s) { 49 | } 50 | }; 51 | 52 | } /* namespace efc */ 53 | #endif /* ESOCKETTIMEOUTEXCEPTION_HH_ */ 54 | -------------------------------------------------------------------------------- /efc/inc/ESpinLock.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ESpinLock.hh 3 | * 4 | * Created on: 2013-3-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ESpinLock_HH_ 9 | #define ESpinLock_HH_ 10 | 11 | #include "ELock.hh" 12 | #include "ETimeUnit.hh" 13 | #include "EUnsupportedOperationException.hh" 14 | 15 | namespace efc { 16 | 17 | /** 18 | * Spin Lock. 19 | * 20 | *

It is recommended practice to always immediately 21 | * follow a call to {@code lock} with a {@code try} block, most 22 | * typically in a before/after construction such as: 23 | * 24 | *

25 |  * class X {
26 |  *   private final ReentrantLock lock = new ReentrantLock();
27 |  *   // ...
28 |  *
29 |  *   public void m() {
30 |  *     lock.lock();  // block until condition holds
31 |  *     try {
32 |  *       // ... method body
33 |  *     } finally {
34 |  *       lock.unlock()
35 |  *     }
36 |  *   }
37 |  * }
38 |  * 
39 | */ 40 | 41 | class ESpinLock : virtual public ELock{ 42 | public: 43 | ESpinLock(); 44 | ~ESpinLock(); 45 | 46 | void lock(); 47 | void lockInterruptibly() THROWS(EInterruptedException); 48 | boolean tryLock(); 49 | boolean tryLock(llong time, ETimeUnit* unit) THROWS(EInterruptedException); 50 | void unlock(); 51 | 52 | ECondition* newCondition() {throw EUNSUPPORTEDOPERATIONEXCEPTION;} 53 | 54 | private: 55 | es_thread_spin_t *m_Spin; 56 | }; 57 | 58 | } /* namespace efc */ 59 | #endif /* ESpinLock_HH_ */ 60 | -------------------------------------------------------------------------------- /efc/inc/EThreadLocalStorage.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EThreadLocalStorage.hh 3 | * 4 | * Created on: 2014-1-27 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ETHREADLOCALSTORAGE_HH_ 9 | #define ETHREADLOCALSTORAGE_HH_ 10 | 11 | #include "EBase.hh" 12 | 13 | namespace efc { 14 | 15 | class EThreadLocalStorage { 16 | public: 17 | virtual ~EThreadLocalStorage(); 18 | 19 | EThreadLocalStorage(); 20 | 21 | // unsupported. 22 | EThreadLocalStorage(const EThreadLocalStorage& that); 23 | EThreadLocalStorage& operator= (const EThreadLocalStorage& that); 24 | 25 | /** 26 | * Returns the value in the current thread's copy of this 27 | * thread-local variable. If the variable has no value for the 28 | * current thread, it is first initialized to the value returned 29 | * by an invocation of the {@link #initialValue} method. 30 | * 31 | * @return the current thread's value of this thread-local 32 | */ 33 | void* get(); 34 | 35 | /** 36 | * Sets the current thread's copy of this thread-local variable 37 | * to the specified value. Most subclasses will have no need to 38 | * override this method, relying solely on the {@link #initialValue} 39 | * method to set the values of thread-locals. 40 | * 41 | * @param value the value to be stored in the current thread's copy of 42 | * this thread-local. 43 | */ 44 | void set(void* value); 45 | 46 | private: 47 | long thread_key; 48 | }; 49 | 50 | } /* namespace efc */ 51 | #endif /* ETHREADLOCALSTORAGE_HH_ */ 52 | -------------------------------------------------------------------------------- /efc/inc/EThreadUnCInitException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EThreadUnCInitException.hh 3 | * 4 | * Created on: 2017-10-26 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ETHREADUNCINITEXCEPTION_H_ 9 | #define ETHREADUNCINITEXCEPTION_H_ 10 | 11 | #include "ERuntimeException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ETHREADUNCINITEXCEPTION EThreadUnCInitException(__FILE__, __LINE__, errno) 16 | #define ETHREADUNCINITEXCEPTIONS(msg) EThreadUnCInitException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown this exception when a native thread have not called EThread::c_init(). 20 | */ 21 | 22 | class EThreadUnCInitException: public ERuntimeException { 23 | public: 24 | /** 25 | * Constructs an EThreadUnCInitException with no 26 | * detail message. 27 | * 28 | * @param _file_ __FILE__ 29 | * @param _line_ __LINE__ 30 | * @param errn errno 31 | */ 32 | EThreadUnCInitException(const char *_file_, int _line_, int errn = 0) : 33 | ERuntimeException(_file_, _line_, errn) { 34 | } 35 | 36 | /** 37 | * Constructs an EThreadUnCInitException with the 38 | * specified detail message. 39 | * 40 | * @param _file_ __FILE__. 41 | * @param _line_ __LINE__. 42 | * @param s the detail message. 43 | */ 44 | EThreadUnCInitException(const char *_file_, 45 | int _line_, const char *s) : 46 | ERuntimeException(_file_, _line_, s) { 47 | } 48 | }; 49 | 50 | } /* namespace efc */ 51 | #endif /* ETHREADUNCINITEXCEPTION_H_ */ 52 | -------------------------------------------------------------------------------- /efc/inc/EToDoException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EToDoException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ETODOEXCEPTION_H_ 9 | #define ETODOEXCEPTION_H_ 10 | 11 | #include "EException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ETODOEXCEPTION EToDoException(__FILE__, __LINE__, errno) 16 | #define ETODOEXCEPTIONS(msg) EToDoException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * EToDoException means this need to do. 20 | */ 21 | 22 | class EToDoException: public EException { 23 | public: 24 | /** 25 | * Constructs an EToDoException with no 26 | * detail message. 27 | * 28 | * @param _file_ __FILE__ 29 | * @param _line_ __LINE__ 30 | * @param errn errno 31 | */ 32 | EToDoException(const char *_file_, int _line_, int errn = 0) : 33 | EException(_file_, _line_, errn) { 34 | } 35 | 36 | /** 37 | * Constructs an EToDoException with the 38 | * specified detail message. 39 | * 40 | * @param _file_ __FILE__. 41 | * @param _line_ __LINE__. 42 | * @param s the detail message. 43 | */ 44 | EToDoException(const char *_file_, int _line_, const char *s, int errn = 0) : 45 | EException(_file_, _line_, s, errn) { 46 | } 47 | }; 48 | 49 | } /* namespace efc */ 50 | #endif /* ETODOEXCEPTION_H_ */ 51 | -------------------------------------------------------------------------------- /efc/inc/EURLString.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EURLString.hh 3 | * 4 | * Created on: 2013-3-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef __EURLString_H__ 9 | #define __EURLString_H__ 10 | 11 | #include "EString.hh" 12 | 13 | namespace efc { 14 | 15 | class EURLString : public EString 16 | { 17 | public: 18 | virtual ~EURLString(){} 19 | 20 | EURLString(const char* s); 21 | 22 | /** 23 | * Concat of a string. 24 | */ 25 | EURLString& concat(const char* s, int len=-1); 26 | 27 | /** 28 | * Concat of a format string. 29 | */ 30 | EURLString& fmtcat(const char* fmt, ...); 31 | 32 | /** 33 | *Concat of a encoded URL string. 34 | */ 35 | EURLString& enccat(const char* s, int len=-1); 36 | 37 | /** 38 | * Concat of a decoded URL string. 39 | */ 40 | EURLString& deccat(const char* s); 41 | }; 42 | 43 | } /* namespace efc */ 44 | #endif //!__EURLString_H__ 45 | -------------------------------------------------------------------------------- /efc/inc/EUnknownHostException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EUnknownHostException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EUNKNOWNHOSTEXCEPTION_HH_ 9 | #define EUNKNOWNHOSTEXCEPTION_HH_ 10 | 11 | #include "EIOException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EUNKNOWNHOSTEXCEPTION EUnknownHostException(__FILE__, __LINE__, errno) 16 | #define EUNKNOWNHOSTEXCEPTIONS(msg) EUnknownHostException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that the IP address of a host could not be determined. 20 | * 21 | * @since JDK1.0 22 | */ 23 | 24 | class EUnknownHostException: public EIOException { 25 | public: 26 | /** 27 | * Constructs an EUnknownHostException with no 28 | * detail message. 29 | * 30 | * @param _file_ __FILE__ 31 | * @param _line_ __LINE__ 32 | * @param errn errno 33 | */ 34 | EUnknownHostException(const char *_file_, int _line_, int errn = 0) : 35 | EIOException(_file_, _line_, errn) { 36 | } 37 | 38 | /** 39 | * Constructs an EUnknownHostException with the 40 | * specified detail message. 41 | * 42 | * @param _file_ __FILE__. 43 | * @param _line_ __LINE__. 44 | * @param s the detail message. 45 | */ 46 | EUnknownHostException(const char *_file_, 47 | int _line_, const char *s) : 48 | EIOException(_file_, _line_, s) { 49 | } 50 | }; 51 | 52 | } /* namespace efc */ 53 | #endif /* EUNKNOWNHOSTEXCEPTION_HH_ */ 54 | -------------------------------------------------------------------------------- /efc/inc/EUnknownServiceException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EUnknownServiceException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EUNKNOWNSERVICEEXCEPTION_HH_ 9 | #define EUNKNOWNSERVICEEXCEPTION_HH_ 10 | 11 | #include "EIOException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EUNKNOWNSERVICEEXCEPTION EUnknownServiceException(__FILE__, __LINE__, errno) 16 | #define EUNKNOWNSERVICEEXCEPTIONS(msg) EUnknownServiceException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Thrown to indicate that an unknown service exception has 20 | * occurred. Either the MIME type returned by a URL connection does 21 | * not make sense, or the application is attempting to write to a 22 | * read-only URL connection. 23 | * 24 | * @since JDK1.0 25 | */ 26 | 27 | class EUnknownServiceException: public EIOException { 28 | public: 29 | /** 30 | * Constructs an EUnknownServiceException with no 31 | * detail message. 32 | * 33 | * @param _file_ __FILE__ 34 | * @param _line_ __LINE__ 35 | * @param errn errno 36 | */ 37 | EUnknownServiceException(const char *_file_, int _line_, int errn = 0) : 38 | EIOException(_file_, _line_, errn) { 39 | } 40 | 41 | /** 42 | * Constructs an EUnknownServiceException with the 43 | * specified detail message. 44 | * 45 | * @param _file_ __FILE__. 46 | * @param _line_ __LINE__. 47 | * @param s the detail message. 48 | */ 49 | EUnknownServiceException(const char *_file_, 50 | int _line_, const char *s) : 51 | EIOException(_file_, _line_, s) { 52 | } 53 | }; 54 | 55 | } /* namespace efc */ 56 | #endif /* EUNKNOWNSERVICEEXCEPTION_HH_ */ 57 | -------------------------------------------------------------------------------- /efc/inc/EUnresolvedAddressException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EUnresolvedAddressException.h 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EUNRESOLVEDADDRESSEXCEPTION_HH_ 9 | #define EUNRESOLVEDADDRESSEXCEPTION_HH_ 10 | 11 | #include "EIllegalArgumentException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EUNRESOLVEDADDRESSEXCEPTION EUnresolvedAddressException(__FILE__, __LINE__, errno) 16 | #define EUNRESOLVEDADDRESSEXCEPTIONS(msg) EUnresolvedAddressException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Unchecked exception thrown when an attempt is made to invoke a network 20 | * operation upon an unresolved socket address. 21 | */ 22 | 23 | class EUnresolvedAddressException: public EIllegalArgumentException { 24 | public: 25 | /** 26 | * Constructs an EUnresolvedAddressException with no 27 | * detail message. 28 | * 29 | * @param _file_ __FILE__ 30 | * @param _line_ __LINE__ 31 | * @param errn errno 32 | */ 33 | EUnresolvedAddressException(const char *_file_, int _line_, int errn = 0) : 34 | EIllegalArgumentException(_file_, _line_, errn) { 35 | } 36 | 37 | /** 38 | * Constructs an EUnresolvedAddressException with the 39 | * specified detail message. 40 | * 41 | * @param _file_ __FILE__. 42 | * @param _line_ __LINE__. 43 | * @param s the detail message. 44 | */ 45 | EUnresolvedAddressException(const char *_file_, int _line_, const char *s, int errn = 0) : 46 | EIllegalArgumentException(_file_, _line_, s, errn) { 47 | } 48 | }; 49 | 50 | } /* namespace efc */ 51 | #endif /* EUNRESOLVEDADDRESSEXCEPTION_HH_ */ 52 | -------------------------------------------------------------------------------- /efc/inc/EUnsupportedAddressTypeException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EUnsupportedAddressTypeException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EUNSUPPORTEDADDRESSTYPEEXCEPTION_HH_ 9 | #define EUNSUPPORTEDADDRESSTYPEEXCEPTION_HH_ 10 | 11 | #include "EIllegalArgumentException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EUNSUPPORTEDADDRESSTYPEEXCEPTION EUnsupportedAddressTypeException(__FILE__, __LINE__, errno) 16 | #define EUNSUPPORTEDADDRESSTYPEEXCEPTIONS(msg) EUnsupportedAddressTypeException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Unchecked exception thrown when an attempt is made to bind or connect 20 | * to a socket address of a type that is not supported. 21 | */ 22 | 23 | class EUnsupportedAddressTypeException: public EIllegalArgumentException { 24 | public: 25 | /** 26 | * Constructs an EUnsupportedAddressTypeException with no 27 | * detail message. 28 | * 29 | * @param _file_ __FILE__ 30 | * @param _line_ __LINE__ 31 | * @param errn errno 32 | */ 33 | EUnsupportedAddressTypeException(const char *_file_, int _line_, int errn = 0) : 34 | EIllegalArgumentException(_file_, _line_, errn) { 35 | } 36 | 37 | /** 38 | * Constructs an EUnsupportedAddressTypeException with the 39 | * specified detail message. 40 | * 41 | * @param _file_ __FILE__. 42 | * @param _line_ __LINE__. 43 | * @param s the detail message. 44 | */ 45 | EUnsupportedAddressTypeException(const char *_file_, int _line_, const char *s, int errn = 0) : 46 | EIllegalArgumentException(_file_, _line_, s, errn) { 47 | } 48 | }; 49 | 50 | } /* namespace efc */ 51 | #endif /* EUNSUPPORTEDADDRESSTYPEEXCEPTION_HH_ */ 52 | -------------------------------------------------------------------------------- /efc/inc/EUnsupportedEncodingException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EUnsupportedEncodingException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EUNSUPPORTEDENCODINGEXCEPTION_H_ 9 | #define EUNSUPPORTEDENCODINGEXCEPTION_H_ 10 | 11 | #include "EIOException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EUNSUPPORTEDENCODINGEXCEPTION EUnsupportedEncodingException(__FILE__, __LINE__, errno) 16 | #define EUNSUPPORTEDENCODINGEXCEPTIONS(msg) EUnsupportedEncodingException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * The Character Encoding is not supported. 20 | * 21 | * @since JDK1.1 22 | */ 23 | 24 | class EUnsupportedEncodingException: public EIOException { 25 | public: 26 | /** 27 | * Constructs an EUnsupportedEncodingException with no 28 | * detail message. 29 | * 30 | * @param _file_ __FILE__ 31 | * @param _line_ __LINE__ 32 | * @param errn errno 33 | */ 34 | EUnsupportedEncodingException(const char *_file_, int _line_, int errn = 0) : 35 | EIOException(_file_, _line_, errn) { 36 | } 37 | 38 | /** 39 | * Constructs an EUnsupportedEncodingException with the 40 | * specified detail message. 41 | * 42 | * @param _file_ __FILE__. 43 | * @param _line_ __LINE__. 44 | * @param s the detail message. 45 | */ 46 | EUnsupportedEncodingException(const char *_file_, 47 | int _line_, const char *s) : 48 | EIOException(_file_, _line_, s) { 49 | } 50 | }; 51 | 52 | } /* namespace efc */ 53 | #endif /* EUNSUPPORTEDENCODINGEXCEPTION_H_ */ 54 | -------------------------------------------------------------------------------- /efc/inc/concurrent/EBrokenBarrierException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EBrokenBarrierException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EBrokenBarrierException_HH_ 9 | #define EBrokenBarrierException_HH_ 10 | 11 | #include "../EException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EBROKENBARRIEREXCEPTION EBROKENBARRIEREXCEPTION(__FILE__, __LINE__, errno) 16 | #define EBROKENBARRIEREXCEPTIONS(msg) EBROKENBARRIEREXCEPTION(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Exception thrown when a thread tries to wait upon a barrier that is 20 | * in a broken state, or which enters the broken state while the thread 21 | * is waiting. 22 | * 23 | * @see CyclicBarrier 24 | * 25 | * @since 1.5 26 | * 27 | */ 28 | 29 | class EBrokenBarrierException: public EException { 30 | public: 31 | /** 32 | * Constructs an EBrokenBarrierException with no 33 | * detail message. 34 | * 35 | * @param _file_ __FILE__ 36 | * @param _line_ __LINE__ 37 | * @param errn errno 38 | */ 39 | EBrokenBarrierException(const char *_file_, int _line_, int errn = 0) : 40 | EException(_file_, _line_, errn) { 41 | } 42 | 43 | /** 44 | * Constructs an EBrokenBarrierException with the 45 | * specified detail message. 46 | * 47 | * @param _file_ __FILE__. 48 | * @param _line_ __LINE__. 49 | * @param s the detail message. 50 | */ 51 | EBrokenBarrierException(const char *_file_, 52 | int _line_, const char *s) : 53 | EException(_file_, _line_, s) { 54 | } 55 | }; 56 | 57 | } /* namespace efc */ 58 | #endif /* EBrokenBarrierException_HH_ */ 59 | -------------------------------------------------------------------------------- /efc/inc/concurrent/ECallable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ECallable.hh 3 | * 4 | * Created on: 2013-8-19 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECALLABLE_HH_ 9 | #define ECALLABLE_HH_ 10 | 11 | #include "../ESharedPtr.hh" 12 | #include "../EException.hh" 13 | 14 | #ifdef CPP11_SUPPORT 15 | #include 16 | #endif 17 | 18 | namespace efc { 19 | 20 | /** 21 | * A task that returns a result and may throw an exception. 22 | * Implementors define a single method with no arguments called 23 | * call. 24 | * 25 | *

The Callable interface is similar to {@link 26 | * java.lang.Runnable}, in that both are designed for classes whose 27 | * instances are potentially executed by another thread. A 28 | * Runnable, however, does not return a result and cannot 29 | * throw a checked exception. 30 | * 31 | *

The {@link Executors} class contains utility methods to 32 | * convert from other common forms to Callable classes. 33 | * 34 | * @see Executor 35 | * @since 1.5 36 | * @param the result type of method call 37 | */ 38 | 39 | template 40 | interface ECallable : virtual public EObject { 41 | virtual ~ECallable(){} 42 | 43 | /** 44 | * Computes a result, or throws an exception if unable to do so. 45 | * 46 | * @return computed result 47 | * @throws Exception if unable to compute a result 48 | */ 49 | virtual sp call() THROWS(EException) = 0; 50 | }; 51 | 52 | #ifdef CPP11_SUPPORT 53 | template 54 | class ECallableTarget: virtual public ECallable { 55 | public: 56 | virtual ~ECallableTarget(){} 57 | 58 | ECallableTarget(std::function()>& f) { 59 | this->f = f; 60 | } 61 | virtual sp call() { 62 | return f(); 63 | } 64 | private: 65 | std::function()> f; 66 | }; 67 | #endif 68 | 69 | } /* namespace efc */ 70 | #endif /* ECALLABLE_HH_ */ 71 | -------------------------------------------------------------------------------- /efc/inc/concurrent/ECancellationException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ECancellationException.hh 3 | * 4 | * Created on: 2013-12-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECANCELLATIONEXCEPTION_HH_ 9 | #define ECANCELLATIONEXCEPTION_HH_ 10 | 11 | #include "../EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ECANCELLATIONEXCEPTION ECancellationException(__FILE__, __LINE__, errno) 16 | #define ECANCELLATIONEXCEPTIONS(msg) ECancellationException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Unchecked exception thrown when an attempt is made to read 20 | * from a channel that was not originally opened for reading. 21 | */ 22 | 23 | class ECancellationException: public EIllegalStateException { 24 | public: 25 | /** 26 | * Constructs an ECancellationException with no 27 | * detail message. 28 | * 29 | * @param _file_ __FILE__ 30 | * @param _line_ __LINE__ 31 | * @param errn errno 32 | */ 33 | ECancellationException(const char *_file_, int _line_, int errn = 0) : 34 | EIllegalStateException(_file_, _line_, errn) { 35 | } 36 | 37 | /** 38 | * Constructs an ECancellationException with the 39 | * specified detail message. 40 | * 41 | * @param _file_ __FILE__. 42 | * @param _line_ __LINE__. 43 | * @param s the detail message. 44 | */ 45 | ECancellationException(const char *_file_, int _line_, 46 | const char *s) : 47 | EIllegalStateException(_file_, _line_, s) { 48 | } 49 | }; 50 | 51 | } /* namespace efc */ 52 | #endif /* ECANCELLATIONEXCEPTION_HH_ */ 53 | -------------------------------------------------------------------------------- /efc/inc/concurrent/ERejectedExecutionHandler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ERejectedExecutionHandler.hh 3 | * 4 | * Created on: 2015-3-5 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EREJECTEDEXECUTIONHANDLER_HH_ 9 | #define EREJECTEDEXECUTIONHANDLER_HH_ 10 | 11 | #include "../EObject.hh" 12 | 13 | namespace efc { 14 | 15 | interface ERunnable; 16 | class EThreadPoolExecutor; 17 | 18 | /** 19 | * A handler for tasks that cannot be executed by a {@link ThreadPoolExecutor}. 20 | * 21 | * @since 1.5 22 | */ 23 | 24 | interface ERejectedExecutionHandler : virtual public EObject { 25 | virtual ~ERejectedExecutionHandler(){} 26 | 27 | /** 28 | * Method that may be invoked by a {@link ThreadPoolExecutor} when 29 | * {@link ThreadPoolExecutor#execute execute} cannot accept a 30 | * task. This may occur when no more threads or queue slots are 31 | * available because their bounds would be exceeded, or upon 32 | * shutdown of the Executor. 33 | * 34 | *

In the absence of other alternatives, the method may throw 35 | * an unchecked {@link RejectedExecutionException}, which will be 36 | * propagated to the caller of {@code execute}. 37 | * 38 | * @param r the runnable task requested to be executed 39 | * @param executor the executor attempting to execute this task 40 | * @throws RejectedExecutionException if there is no remedy 41 | */ 42 | virtual void rejectedExecution(sp r, EThreadPoolExecutor* executor) = 0; 43 | }; 44 | 45 | } /* namespace efc */ 46 | #endif /* EREJECTEDEXECUTIONHANDLER_HH_ */ 47 | -------------------------------------------------------------------------------- /efc/inc/concurrent/ERunnableFuture.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ERunnableFuture.hh 3 | * 4 | * Created on: 2013-8-19 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ERUNNABLEFUTURE_HH_ 9 | #define ERUNNABLEFUTURE_HH_ 10 | 11 | #include "../ERunnable.hh" 12 | #include "./EFuture.hh" 13 | 14 | namespace efc { 15 | 16 | /** 17 | * A {@link Future} that is {@link Runnable}. Successful execution of 18 | * the run method causes completion of the Future 19 | * and allows access to its results. 20 | * @see FutureTask 21 | * @see Executor 22 | * @since 1.6 23 | * @param The result type returned by this Future's get method 24 | */ 25 | 26 | template 27 | interface ERunnableFuture: virtual public ERunnable, virtual public EFuture { 28 | virtual ~ERunnableFuture(){} 29 | 30 | /** 31 | * Sets this Future to the result of its computation 32 | * unless it has been cancelled. 33 | */ 34 | virtual void run() = 0; 35 | }; 36 | 37 | } /* namespace efc */ 38 | #endif /* ERUNNABLEFUTURE_HH_ */ 39 | -------------------------------------------------------------------------------- /efc/inc/concurrent/EThreadFactory.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EThreadFactory.hh 3 | * 4 | * Created on: 2013-11-12 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ETHREADFACTORY_HH_ 9 | #define ETHREADFACTORY_HH_ 10 | 11 | #include "../EThread.hh" 12 | 13 | namespace efc { 14 | 15 | /** 16 | * An object that creates new threads on demand. Using thread factories 17 | * removes hardwiring of calls to {@link Thread#Thread(Runnable) new Thread}, 18 | * enabling applications to use special thread subclasses, priorities, etc. 19 | * 20 | *

21 | * The simplest implementation of this interface is just: 22 | *

23 |  * class SimpleThreadFactory implements ThreadFactory {
24 |  *   public Thread newThread(Runnable r) {
25 |  *     return new Thread(r);
26 |  *   }
27 |  * }
28 |  * 
29 | * 30 | * The {@link Executors#defaultThreadFactory} method provides a more 31 | * useful simple implementation, that sets the created thread context 32 | * to known values before returning it. 33 | * @since 1.5 34 | */ 35 | 36 | interface EThreadFactory : virtual public EObject { 37 | virtual ~EThreadFactory(){} 38 | 39 | /** 40 | * Constructs a new {@code Thread}. Implementations may also initialize 41 | * priority, name, daemon status, {@code ThreadGroup}, etc. 42 | * 43 | * @param r a runnable to be executed by new thread instance 44 | * @return constructed thread, or {@code null} if the request to 45 | * create a thread is rejected 46 | */ 47 | virtual EThread* newThread(sp r) = 0; 48 | 49 | #ifdef CPP11_SUPPORT 50 | virtual EThread* newThreadX(std::function func) { 51 | return this->newThread(new ERunnableTarget(func)); 52 | } 53 | #endif 54 | }; 55 | 56 | } /* namespace efc */ 57 | #endif /* ETHREADFACTORY_HH_ */ 58 | -------------------------------------------------------------------------------- /efc/inc/concurrent/ETimeoutException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ETimeoutException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ETIMEOUTEXCEPTION_H_ 9 | #define ETIMEOUTEXCEPTION_H_ 10 | 11 | #include "../EException.hh" 12 | 13 | namespace efc { 14 | 15 | #define ETIMEOUTEXCEPTION ETimeoutException(__FILE__, __LINE__, errno) 16 | #define ETIMEOUTEXCEPTIONS(msg) ETimeoutException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Exception thrown when a blocking operation times out. Blocking 20 | * operations for which a timeout is specified need a means to 21 | * indicate that the timeout has occurred. For many such operations it 22 | * is possible to return a value that indicates timeout; when that is 23 | * not possible or desirable then TimeoutException should be 24 | * declared and thrown. 25 | * 26 | * @since 1.5 27 | */ 28 | 29 | class ETimeoutException: public EException { 30 | public: 31 | /** 32 | * Constructs an ETimeoutException with no 33 | * detail message. 34 | * 35 | * @param _file_ __FILE__ 36 | * @param _line_ __LINE__ 37 | * @param errn errno 38 | */ 39 | ETimeoutException(const char *_file_, int _line_, int errn = 0) : 40 | EException(_file_, _line_, errn) { 41 | } 42 | 43 | /** 44 | * Constructs an ETimeoutException with the 45 | * specified detail message. 46 | * 47 | * @param _file_ __FILE__. 48 | * @param _line_ __LINE__. 49 | * @param s the detail message. 50 | */ 51 | ETimeoutException(const char *_file_, int _line_, const char *s, int errn = 0) : 52 | EException(_file_, _line_, s, errn) { 53 | } 54 | }; 55 | 56 | } /* namespace efc */ 57 | #endif /* ETIMEOUTEXCEPTION_H_ */ 58 | -------------------------------------------------------------------------------- /efc/inc/cpp11/EScopeGuard.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EScopeGuard.hh 3 | * 4 | * Created on: 2015-9-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ESCOPEGUARD_HH_ 9 | #define ESCOPEGUARD_HH_ 10 | 11 | #include "../../EBase.hh" 12 | 13 | #ifdef CPP11_SUPPORT 14 | 15 | namespace efc { 16 | 17 | //@see: http://the-witness.net/news/2012/11/scopeexit-in-c11/ 18 | 19 | /** How to use it: 20 | // 1. MakeScopeGuard 21 | { 22 | auto onFailureRollback = MakeScopeGuard([&] { 23 | LOG("onFailureRollback..."); 24 | }); 25 | 26 | ... 27 | 28 | onFailureRollback.dismiss(); 29 | } 30 | 31 | // 2. ON_SCOPE_EXIT 32 | { 33 | ON_SCOPE_EXIT( ... ); 34 | ... 35 | } 36 | 37 | // 3. ON_FINALLY_NOTHROW 38 | { 39 | ON_FINALLY_NOTHROW( 40 | ... 41 | ) { 42 | ... 43 | }} 44 | } 45 | */ 46 | 47 | template 48 | class EScopeGuard { 49 | public: 50 | EScopeGuard(F f) : f(f), d(false) {} 51 | ~EScopeGuard() { if(!d) { f();} } 52 | void dismiss() { d = true; } 53 | private: 54 | F f; 55 | boolean d; 56 | }; 57 | 58 | template 59 | EScopeGuard MakeScopeGuard(F f) { 60 | return EScopeGuard(f); 61 | }; 62 | 63 | #define DO_STRING_JOIN2(arg1, arg2) arg1 ## arg2 64 | #define STRING_JOIN2(arg1, arg2) DO_STRING_JOIN2(arg1, arg2) 65 | 66 | #define ON_SCOPE_EXIT(code) \ 67 | auto STRING_JOIN2(scope_exit_, __LINE__) = MakeScopeGuard([&](){code;}) 68 | 69 | #define ON_FINALLY_NOTHROW(code) { \ 70 | auto __scope_exit__ = MakeScopeGuard([&](){ try{ code; } catch(...){} }); 71 | 72 | } /* namespace efc */ 73 | 74 | #endif //!CPP11_SUPPORT 75 | 76 | #endif /* ESCOPEGUARD_HH_ */ 77 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_alogger.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_alogger.h 3 | * @brief ES async logger. 4 | */ 5 | 6 | #ifndef ESO_ALOGGER_H_ 7 | #define ESO_ALOGGER_H_ 8 | 9 | #include "eso_thread.h" 10 | #include "eso_thread_spin.h" 11 | #include "eso_ring_buffer.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif /* __cplusplus */ 16 | 17 | typedef struct es_alogger_t es_alogger_t; 18 | struct es_alogger_t { 19 | es_string_t *logger_name; 20 | es_thread_t *daemon_thread; 21 | es_int32_t daemon_stat; 22 | 23 | es_thread_spin_t *spin_lock; 24 | es_size_t buffer_size; 25 | es_ring_buffer_t *ring_buffer; 26 | es_byte_t *read_buffer; 27 | }; 28 | 29 | es_alogger_t* eso_alogger_create(const char* name, es_long_t maxmem); 30 | 31 | void eso_alogger_free(es_alogger_t** logger); 32 | 33 | void eso_alogger_logfmt(es_alogger_t* logger, const char *fmt, ...); 34 | 35 | void eso_alogger_logstr(es_alogger_t* logger, const char *str); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* ESO_ALOGGER_H_ */ 42 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_base64.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @@file eso_base64.h 3 | * @@brief ES eso standard base64 encode/decode 4 | */ 5 | 6 | 7 | #ifndef __ESO_BASE64_H__ 8 | #define __ESO_BASE64_H__ 9 | 10 | #include "es_types.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif /* __cplusplus */ 15 | 16 | /** 17 | * Base64 encode (standard implementation) 18 | * @limit olen>=(ilen+2)/3 * 4 19 | * @return >=0 the valid encoding data length 20 | * -1 failure 21 | */ 22 | int eso_base64_encode(es_uint8_t *in, int ilen, es_uint8_t *out, int olen); 23 | 24 | /** 25 | * Base64 decode (standard implementation) 26 | * @limit olen>=ilen/4 * 3 27 | * @return >=0 the valid decoding data length 28 | * -1 failure 29 | */ 30 | int eso_base64_decode(es_uint8_t *in, int ilen, es_uint8_t *out, int olen); 31 | 32 | /* 33 | * XBase64 encode (non standard implementation) 34 | * @limit olen>=(ilen+2)/3 * 4 35 | * @return >=0 the valid encoding data length 36 | * -1 failure 37 | */ 38 | int eso_xbase64_encode(es_uint8_t *in, int ilen, es_uint8_t *out, int olen); 39 | 40 | /* 41 | * XBase64 decode (non standard implementation) 42 | * @limit olen>=ilen/4 * 3 43 | * @return >=0 the valid decoding data length 44 | * -1 failure 45 | */ 46 | int eso_xbase64_decode(es_uint8_t *in, int ilen, es_uint8_t *out, int olen); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* ! __ESO_BASE64_H__ */ 53 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_bson_ext.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_bson_ext.h 3 | * @brief Binary Serialized Object Notation. 4 | */ 5 | 6 | #ifndef __ESO_BSON_EXT_H__ 7 | #define __ESO_BSON_EXT_H__ 8 | 9 | #include "eso_bson.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | /** 16 | * Make a bson object load from file. 17 | * @param bson The bson object. 18 | * @param fname The file name. 19 | * @return ES_SUCCESS or ES_FAILURE,ES_IOERROR 20 | */ 21 | es_status_t eso_bson_load(es_bson_t *bson, 22 | const char *fname); 23 | 24 | /** 25 | * Save data to a file from bson object. 26 | * @param bson The bson object. 27 | * @param fname The file name. 28 | * @param node The node path, if NULL then export all, !NULL export only this node tree. 29 | * @return ES_SUCCESS or ES_FAILURE,ES_IOERROR 30 | */ 31 | es_status_t eso_bson_save(es_bson_t *bson, 32 | const char *fname, 33 | const char *node); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* __ESO_BSON_EXT_H__ */ 40 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_canonicalize.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_canonicalize.h 3 | * @brief Pathname canonicalization 4 | */ 5 | 6 | 7 | #ifndef __ESO_CANONICALIZE_H__ 8 | #define __ESO_CANONICALIZE_H__ 9 | 10 | #include "es_types.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif /* __cplusplus */ 15 | 16 | /** 17 | * Convert a pathname to canonical form. The input path is assumed to contain 18 | * no duplicate slashes. On Solaris we can use realpath() to do most of the 19 | * work, though once that's done we still must collapse any remaining "." and 20 | * ".." names by hand. 21 | * 22 | * @param path original path string. 23 | * @param out resolved path string. 24 | * @param len resolved buffer size, must be >= ES_PATH_MAX. 25 | */ 26 | int canonicalize(const char *path, char *out, int len); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* ! __ESO_CANONICALIZE_H__ */ 33 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_conf.h 3 | * @brief ES Config Routines 4 | */ 5 | 6 | 7 | #ifndef __ESO_CONF_H__ 8 | #define __ESO_CONF_H__ 9 | 10 | #include "eso_bson.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif /* __cplusplus */ 15 | 16 | 17 | /** 18 | * Load config file 19 | */ 20 | es_bool_t eso_conf_load(es_bson_t *bson, 21 | const char *fname); 22 | 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif /* ! __ESO_CONF_H__ */ 29 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_crc32.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_crc32.h 3 | * @brief CRC-32 Calculation 4 | */ 5 | 6 | #ifndef __ESO_CRC32_H__ 7 | #define __ESO_CRC32_H__ 8 | 9 | 10 | #include "es_comm.h" 11 | #include "es_types.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * CRC-32 routine 19 | */ 20 | es_uint32_t eso_crc32_calc(es_byte_t *p, es_size_t len); 21 | 22 | 23 | /** 24 | * CRC-32 advanced routine 25 | */ 26 | #define eso_crc32_init(crc) \ 27 | crc = 0xffffffff 28 | 29 | void eso_crc32_update(es_uint32_t *crc, es_byte_t *p, es_size_t len); 30 | 31 | #define eso_crc32_final(crc) \ 32 | crc ^= 0xffffffff 33 | 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* __ESO_CRC32_H__ */ 40 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_debug.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_debug.h 3 | * @brief ES eso debug define 4 | */ 5 | 6 | #ifndef __ESO_DEBUG_H__ 7 | #define __ESO_DEBUG_H__ 8 | 9 | #include "eso_libc.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | #ifdef __DEBUG 16 | 17 | extern es_uint32_t g_tickcount_last; 18 | 19 | #define DBG_PRINTF(a) \ 20 | do { \ 21 | eso_log a; \ 22 | }while(0) 23 | 24 | #define QUICK_DBG \ 25 | do { \ 26 | es_uint32_t tickcount_curr = eso_get_tick_count(); \ 27 | DBG_PRINTF(("FILE:%s @LINE: %d @TICK: %d", __FILE__,__LINE__, tickcount_curr - g_tickcount_last)); \ 28 | g_tickcount_last = tickcount_curr; \ 29 | }while(0) 30 | 31 | #else 32 | 33 | #define DBG_PRINTF(a) 34 | #define QUICK_DBG 35 | 36 | #endif //!__DEBUG 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* __ESO_DEBUG_H__ */ 43 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_dso.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_dso.h 3 | * @brief Dynamic Object Handling Routines 4 | */ 5 | 6 | #ifndef __ES_DSO_H__ 7 | #define __ES_DSO_H__ 8 | 9 | #include "es_comm.h" 10 | #include "es_types.h" 11 | 12 | #ifdef WIN32 13 | #include 14 | #else 15 | #include 16 | #endif 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /** 23 | * Structure for referencing dynamic objects 24 | */ 25 | typedef void es_dso_t; 26 | 27 | /** 28 | * Load a DSO library. 29 | * @param path Path to the DSO library 30 | * @param flags This parameter describes how dlopen()/LoadLibraryEx() 31 | * will operate upon file with respect to the processing of relocations 32 | * and the scope of visibility of the symbols provided within file. 33 | * @return Location to store new handle for the DSO. 34 | */ 35 | es_dso_t* eso_dso_load(const char *path); 36 | es_dso_t* eso_dso_load_ext(const char *path, int flags); 37 | 38 | /** 39 | * Close a DSO library. 40 | * @param handle handle to close. 41 | */ 42 | void eso_dso_unload(es_dso_t **handle); 43 | 44 | /** 45 | * Load a symbol from a DSO handle. 46 | * @param ressym Location to store the loaded symbol 47 | * @param handle handle to load the symbol from. 48 | * @param symname Name of the symbol to load. 49 | */ 50 | void* eso_dso_sym(es_dso_t *handle, 51 | const char *symname); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif /* __ES_DSO_H__ */ 58 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_lz77.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_lz77.h 3 | * @brief ES lz77 zip api. 4 | */ 5 | 6 | #ifndef __ESO_LZ77_H__ 7 | #define __ESO_LZ77_H__ 8 | 9 | #include "es_types.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | 16 | //LZ77 ziped 17 | es_int32_t eso_lz77_zip(es_ostream_t *outStream, es_istream_t *inStream); 18 | 19 | //LZ77 unziped 20 | es_int32_t eso_lz77_unzip(es_ostream_t *outStream, es_istream_t *inStream); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif /* __ESO_LZ77_H__ */ 27 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_map.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @@file eso_map.h 3 | * @@brief ES map (map table) 4 | */ 5 | 6 | 7 | #ifndef __ESO_MAP_H__ 8 | #define __ESO_MAP_H__ 9 | 10 | #include "es_types.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif /* __cplusplus */ 15 | 16 | /** 17 | * opaque structure 18 | */ 19 | typedef struct es_map_t es_map_t; 20 | 21 | /** 22 | * item element structure 23 | */ 24 | typedef struct es_map_elem_t es_map_elem_t; 25 | 26 | /** 27 | * free item data callback 28 | */ 29 | typedef void es_map_free_t(void *data); 30 | 31 | /** 32 | * create a map 33 | * @returns The new map 34 | */ 35 | es_map_t* eso_map_create(es_map_free_t *free); 36 | 37 | /** 38 | * put/add a key-object to the map 39 | * 40 | * @param map the map table 41 | * @param key the map table key 42 | * @param data the map table data 43 | */ 44 | es_int32_t eso_map_set(es_map_t *map, es_int32_t key, const void *data); 45 | 46 | /** 47 | * get an object from the map 48 | * 49 | * @param map the map table 50 | * @param key the map table key 51 | * @returns the map table data 52 | */ 53 | void* eso_map_get(es_map_t *map, es_int32_t key); 54 | 55 | /** 56 | * returns the size of the map. 57 | * 58 | * @param map the map table 59 | * @returns the size of the map 60 | */ 61 | es_int32_t eso_map_size(es_map_t *map); 62 | 63 | /** 64 | * Destroy a map 65 | * @param t The map to destroy 66 | */ 67 | void eso_map_destroy(es_map_t **map); 68 | 69 | es_map_elem_t* eso_map_first(es_map_t *map); 70 | 71 | es_map_elem_t* eso_map_next(es_map_t *map, es_map_elem_t *mi); 72 | 73 | void eso_map_this(es_map_elem_t *mi, es_int32_t *key, void **val); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* ! __ESO_MAP_H__ */ 80 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_md4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_md4.h 3 | * @brief ES RSA Data Security 4 | */ 5 | 6 | 7 | /* 8 | * This code implements the MD4 message-digest algorithm. 9 | * The algorithm is due to Ron Rivest. This code was 10 | * written by Colin Plumb in 1993, no copyright is claimed. 11 | * This code is in the public domain; do with it what you wish. 12 | * Todd C. Miller modified the MD5 code to do MD4 based on RFC 1186. 13 | * 14 | * Equivalent code is available from RSA Data Security, Inc. 15 | * This code has been tested against that, and is equivalent, 16 | * except that you don't need to include two pages of legalese 17 | * with every copy. 18 | */ 19 | 20 | #ifndef __ESO_MD4_H__ 21 | #define __ESO_MD4_H__ 22 | 23 | #include "es_types.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #define MD4_BLOCK_LENGTH 64 30 | #define MD4_DIGEST_LENGTH 16 31 | #define MD4_DIGEST_STRING_LENGTH (MD4_DIGEST_LENGTH * 2 + 1) 32 | 33 | /* MD5 context. */ 34 | typedef struct { 35 | es_uint32_t state[4]; /* state */ 36 | es_uint32_t count[2]; /* number of bits, mod 2^64 */ 37 | unsigned char buffer[MD4_BLOCK_LENGTH]; /* input buffer */ 38 | } MD4_CTX; 39 | 40 | void MD4_Init(MD4_CTX *context); 41 | void MD4_Update(MD4_CTX *mdContext, const es_uint8_t *inBuf, es_uint32_t inLen); 42 | void MD4_Final(es_uint8_t hash[], MD4_CTX *mdContext); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif /* __ESO_MD4_H__ */ 49 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file es_mem.h 3 | * @brief ES memory manager. 4 | */ 5 | 6 | #ifndef __ESO_MEM_H__ 7 | #define __ESO_MEM_H__ 8 | 9 | #include "es_types.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | void* eso_mmalloc(es_size_t size); 16 | void* eso_mcalloc(es_size_t size); 17 | void* eso_mrealloc(void *ptr, es_size_t newsize); 18 | void eso_mfree(void *ptr); 19 | void eso_mfree_and_nil(void **ptr); 20 | 21 | es_size_t eso_mnode_size(void *ptr); 22 | 23 | #define ESO_MFREE(pp) eso_mfree_and_nil((void**)(pp)); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* __ESO_MEM_H__ */ 30 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_pipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_pipe.h 3 | * @brief Pipe routines 4 | */ 5 | 6 | #ifndef __ESO_PIPE_H__ 7 | #define __ESO_PIPE_H__ 8 | 9 | #include "es_comm.h" 10 | #include "es_types.h" 11 | #include "eso_file.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif /* __cplusplus */ 16 | 17 | typedef struct es_pipe_t es_pipe_t; 18 | struct es_pipe_t { 19 | es_file_t *in; //in for write. 20 | es_file_t *out; //out for read. 21 | }; 22 | 23 | /** 24 | * Create pipe. 25 | */ 26 | es_pipe_t* eso_pipe_create(void); 27 | 28 | /** 29 | * Destroy pipe. 30 | */ 31 | void eso_pipe_destroy(es_pipe_t **pipe); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* ! __ESO_PIPE_H__ */ 38 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_printf_upper_bound.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_printf_upper_bound.h 3 | * @brief ES calculate printf upper bound 4 | */ 5 | 6 | #ifndef __ESO_PRINTF_UPPER_BOUND_H__ 7 | #define __ESO_PRINTF_UPPER_BOUND_H__ 8 | 9 | #include "es_types.h" 10 | #include "es_comm.h" 11 | #include "eso_libc.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif /* __cplusplus */ 16 | 17 | #define MAX_INT2STR_LEN ((sizeof(es_uint32_t) * CHAR_BIT + 2) / 3 + 1) 18 | 19 | /* Returns the maximum length of given format string when expanded. 20 | * If the format is invalid, i_fatal() is called. 21 | */ 22 | es_size_t eso_printf_upper_bound(const char *format, va_list args); 23 | 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* ! __ESO_PRINTF_UPPER_BOUND_H__ */ 30 | 31 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_signal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_signal.c 3 | * @brief EZ Signal Handling 4 | */ 5 | 6 | #ifndef __ESO_SIGNAL_H__ 7 | #define __ESO_SIGNAL_H__ 8 | 9 | #include "es_comm.h" 10 | #include "es_types.h" 11 | #include "es_status.h" 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif /* __cplusplus */ 18 | 19 | /** 20 | * Call installs a new signal handler for the signal with number signum. 21 | */ 22 | es_status_t eso_signal(int signum, void(*handler)(int sig)); 23 | 24 | /** 25 | * Get the description for a specific signal number 26 | * @param signum The signal number 27 | * @return The description of the signal 28 | */ 29 | const char* eso_signal_description(int signum); 30 | 31 | /** 32 | * Block the delivery of a particular signal 33 | * @param signum The signal number 34 | * @return status 35 | */ 36 | es_status_t eso_signal_block(int signum); 37 | 38 | /** 39 | * Enable the delivery of a particular signal 40 | * @param signum The signal number 41 | * @return status 42 | */ 43 | es_status_t eso_signal_unblock(int signum); 44 | 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif /* __cplusplus */ 49 | 50 | #endif /* __ESO_SIGNAL_H__ */ 51 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_sigsegv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_sigsegv.h 3 | * @brief ES stack-trace for segfaults 4 | */ 5 | 6 | #ifndef __ESO_SIGSEGV_H__ 7 | #define __ESO_SIGSEGV_H__ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif /* __cplusplus */ 12 | 13 | /** Install signal handler 14 | * link add: -rdynamic -ldl 15 | */ 16 | int eso_setup_sigsegv(const char *dumpfile); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif /* __ESO_SIGSEGV_H__ */ 23 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_sys.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_sys.h 3 | * @brief ES System Assistant. 4 | */ 5 | 6 | #ifndef __ESO_SYS_H__ 7 | #define __ESO_SYS_H__ 8 | 9 | #include "es_comm.h" 10 | #include "es_types.h" 11 | #include "es_status.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif /* __cplusplus */ 16 | 17 | /** 18 | * Setup any ESO internal data structures. This MUST be the first function 19 | * called for any ESO library. It is safe to call eso_initialize several 20 | * times as long as eso_terminate is called the same number of times. 21 | */ 22 | es_status_t eso_initialize(void); 23 | 24 | /** 25 | * Tear down any ESO internal data structures which aren't torn down 26 | * automatically. eso_terminate must be called once for every call to 27 | * eso_initialize(). 28 | */ 29 | void eso_terminate(void); 30 | 31 | /** 32 | * Get wordsize is 32 or 64. 33 | */ 34 | int eso_wordsize_get(void); 35 | 36 | /** 37 | * Check big endian or little endian. 38 | */ 39 | es_bool_t eso_is_bigendian(void); 40 | 41 | /** 42 | * Get backtrace information. 43 | */ 44 | char* eso_backtrace_get_from(es_string_t **trace, int top); 45 | char* eso_backtrace_get(es_string_t **trace); 46 | 47 | /** 48 | * Get the program current work path. 49 | */ 50 | char* eso_current_workpath(es_string_t **path); 51 | 52 | /** 53 | * Get the program execute's file name. 54 | */ 55 | char* eso_execute_filename(es_string_t **path); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* __ESO_SYS_H__ */ 62 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_uuid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_uuid.h 3 | * @brief ES UUID Library 4 | */ 5 | 6 | 7 | #ifndef __ESO_UUID_H__ 8 | #define __ESO_UUID_H__ 9 | 10 | #include "es_comm.h" 11 | #include "es_types.h" 12 | #include "es_status.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif /* __cplusplus */ 17 | 18 | /** 19 | * we represent a UUID as a block of 16 bytes. 20 | */ 21 | 22 | typedef struct { 23 | unsigned char data[16]; /**< the actual UUID */ 24 | } es_uuid_t; 25 | 26 | /** UUIDs are formatted as: 00112233-4455-6677-8899-AABBCCDDEEFF */ 27 | #define ES_UUID_FORMATTED_LENGTH 36 28 | 29 | 30 | /** 31 | * Generate and return a (new) UUID 32 | * @param uuid The resulting UUID 33 | */ 34 | void eso_uuid_get(es_uuid_t *uuid); 35 | 36 | /** 37 | * Format a UUID into a string, following the standard format 38 | * @param buffer The buffer to place the formatted UUID string into. It must 39 | * be at least EZ_UUID_FORMATTED_LENGTH + 1 bytes long to hold 40 | * the formatted UUID and a null terminator 41 | * @param uuid The UUID to format 42 | */ 43 | void eso_uuid_format(char *buffer, const es_uuid_t *uuid); 44 | 45 | /** 46 | * Parse a standard-format string into a UUID 47 | * @param uuid The resulting UUID 48 | * @param uuid_str The formatted UUID 49 | */ 50 | es_status_t eso_uuid_parse(es_uuid_t *uuid, const char *uuid_str); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* __ESO_UUID_H__ */ 57 | -------------------------------------------------------------------------------- /efc/libc/inc/eso_zlib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_zlib.h 3 | * @brief ES zlib zip api. 4 | */ 5 | 6 | #ifndef __ESO_ZLIB_H__ 7 | #define __ESO_ZLIB_H__ 8 | 9 | #include "es_types.h" 10 | #include "es_comm.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif /* __cplusplus */ 15 | 16 | //============================================================================== 17 | // zlib 18 | //============================================================================== 19 | 20 | #define ES_Z_OK 0 21 | #define ES_Z_STREAM_END 1 22 | #define ES_Z_NEED_DICT 2 23 | #define ES_Z_ERRNO (-1) 24 | #define ES_Z_STREAM_ERROR (-2) 25 | #define ES_Z_DATA_ERROR (-3) 26 | #define ES_Z_MEM_ERROR (-4) 27 | #define ES_Z_BUF_ERROR (-5) 28 | #define ES_Z_VERSION_ERROR (-6) 29 | /* Return codes for the compression/decompression functions. Negative values 30 | * are errors, positive values are used for special but normal events. 31 | */ 32 | 33 | //============================================================================== 34 | 35 | //ZLIB ziped 36 | es_int32_t eso_zlib_deflate(es_ostream_t *outStream, 37 | es_istream_t *inStream); 38 | 39 | //ZLIB unzipd 40 | es_int32_t eso_zlib_inflate(es_ostream_t *outStream, 41 | es_istream_t *inStream); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* __ESO_ZLIB_H__ */ 48 | -------------------------------------------------------------------------------- /efc/libc/src/eso_canonicalize.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_canonicalize.c 3 | * @brief Pathname canonicalization 4 | */ 5 | 6 | #include "eso_canonicalize.h" 7 | 8 | #ifdef WIN32 9 | #include "canonicalize_win.inl" 10 | #else 11 | #include "canonicalize_unix.inl" 12 | #endif 13 | -------------------------------------------------------------------------------- /efc/libc/src/eso_debug.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_debug.c 3 | * @brief ES eso debug wrapper 4 | */ 5 | 6 | #include "es_types.h" 7 | 8 | es_uint32_t g_tickcount_last = 0; 9 | -------------------------------------------------------------------------------- /efc/libc/src/eso_except.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file eso_debug.c 3 | * @brief ES Exception Handling in C Language 4 | */ 5 | 6 | #include "eso_except.h" 7 | 8 | /*============================================================================== 9 | 注意!!! 10 | 此异常处理模块仅限于C应用层代码使用,其他地方禁止使用; 11 | C++中使用会导致对象销毁异常。 12 | ==============================================================================*/ 13 | 14 | static es_except_element_t* g_element_link_head = NULL; 15 | 16 | /* 把一个异常插入到链表头中 */ 17 | void ___except_push(es_except_element_t* es_except_element_t) 18 | { 19 | if (g_element_link_head) es_except_element_t->next = g_element_link_head; 20 | g_element_link_head = es_except_element_t; 21 | } 22 | 23 | /* 从链表头中,删除并返回一个异常 */ 24 | es_except_element_t* ___except_pop(void) 25 | { 26 | es_except_element_t* ret = NULL; 27 | 28 | ret = g_element_link_head; 29 | g_element_link_head = g_element_link_head->next; 30 | 31 | return ret; 32 | } 33 | 34 | /* 从链表头中,返回一个异常 */ 35 | es_except_element_t* ___except_top(void) 36 | { 37 | return g_element_link_head; 38 | } 39 | 40 | /* 链表中是否有任何异常 */ 41 | int ___except_is_empty(void) 42 | { 43 | return (!g_element_link_head); 44 | } 45 | 46 | /* 缺省的异常处理模块 */ 47 | static void ___uncaught_exception_handler(es_except_t *exception) 48 | { 49 | eso_log("error! get a uncaught exception:type=%d, code=%d, msg=%s", 50 | exception->err_type, exception->err_code, exception->err_msg); 51 | // Close(); 52 | } 53 | 54 | /* 抛出异常 */ 55 | void ___except_thrower(es_except_t* e) 56 | { 57 | es_except_element_t *se; 58 | 59 | if (___except_is_empty()) ___uncaught_exception_handler(e); 60 | 61 | se = ___except_top(); 62 | se->exception.err_type = e->err_type; 63 | se->exception.err_code = e->err_code; 64 | eso_strncpy(se->exception.err_msg, e->err_msg, sizeof(se->exception.err_msg)); 65 | 66 | longjmp(se->status, 1); 67 | } 68 | -------------------------------------------------------------------------------- /efc/libc/src/eso_object.c: -------------------------------------------------------------------------------- 1 | #include "eso_object.h" 2 | 3 | es_object_t* NULL_create(const es_int8_t* file, int line) 4 | { 5 | return NULL; 6 | } 7 | -------------------------------------------------------------------------------- /efc/libc/src/lzma/Types.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/efc/libc/src/lzma/Types.h -------------------------------------------------------------------------------- /efc/libc/src/pcre/AUTHORS: -------------------------------------------------------------------------------- 1 | THE MAIN PCRE LIBRARY 2 | --------------------- 3 | 4 | Written by: Philip Hazel 5 | Email local part: ph10 6 | Email domain: cam.ac.uk 7 | 8 | University of Cambridge Computing Service, 9 | Cambridge, England. 10 | 11 | Copyright (c) 1997-2012 University of Cambridge 12 | All rights reserved 13 | 14 | 15 | PCRE JUST-IN-TIME COMPILATION SUPPORT 16 | ------------------------------------- 17 | 18 | Written by: Zoltan Herczeg 19 | Email local part: hzmester 20 | Emain domain: freemail.hu 21 | 22 | Copyright(c) 2010-2012 Zoltan Herczeg 23 | All rights reserved. 24 | 25 | 26 | STACK-LESS JUST-IN-TIME COMPILER 27 | -------------------------------- 28 | 29 | Written by: Zoltan Herczeg 30 | Email local part: hzmester 31 | Emain domain: freemail.hu 32 | 33 | Copyright(c) 2009-2012 Zoltan Herczeg 34 | All rights reserved. 35 | 36 | 37 | THE C++ WRAPPER LIBRARY 38 | ----------------------- 39 | 40 | Written by: Google Inc. 41 | 42 | Copyright (c) 2007-2012 Google Inc 43 | All rights reserved 44 | 45 | #### 46 | -------------------------------------------------------------------------------- /efc/libc/src/pcre/COPYING: -------------------------------------------------------------------------------- 1 | PCRE LICENCE 2 | 3 | Please see the file LICENCE in the PCRE distribution for licensing details. 4 | 5 | End 6 | -------------------------------------------------------------------------------- /efc/libc/src/pcre/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/efc/libc/src/pcre/ChangeLog -------------------------------------------------------------------------------- /efc/libc/src/pcre/NON-UNIX-USE: -------------------------------------------------------------------------------- 1 | Compiling PCRE on non-Unix systems 2 | ---------------------------------- 3 | 4 | This has been renamed to better reflect its contents. Please see the file 5 | NON-AUTOTOOLS-BUILD for details of how to build PCRE without using autotools. 6 | 7 | #### 8 | -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/grepinput8: -------------------------------------------------------------------------------- 1 | X one 2 | X two X three X four X five 3 | X six 4 | X seven…X eight
X nine
X ten 5 | 6 | Before 111 7 | Before 222
Before 333…Match 8 | After 111 9 | After 222
After 333 10 | And so on and so on 11 | And so on and so on 12 | -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/grepinputx: -------------------------------------------------------------------------------- 1 | This is a second file of input for the pcregrep tests. 2 | 3 | Here is the pattern again. 4 | 5 | Pattern 6 | That time it was on a line by itself. 7 | 8 | To pat or not to pat, that is the question. 9 | 10 | complete pair 11 | of lines 12 | 13 | That was a complete pair 14 | of lines all by themselves. 15 | 16 | complete pair 17 | of lines 18 | 19 | And there they were again, to check line numbers. 20 | 21 | one 22 | two 23 | three 24 | four 25 | five 26 | six 27 | seven 28 | eight 29 | nine 30 | ten 31 | eleven 32 | twelve 33 | thirteen 34 | fourteen 35 | fifteen 36 | sixteen 37 | seventeen 38 | eighteen 39 | nineteen 40 | twenty 41 | 42 | This line contains pattern not on a line by itself. 43 | This is the last line of this file. 44 | -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/greplist: -------------------------------------------------------------------------------- 1 | This is a file of patterns for testing the -f option. Don't include any blank 2 | lines because they will match everything! This is no longer true, so have one. 3 | 4 | pattern 5 | line by itself 6 | 7 | End of the list of patterns. 8 | -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/grepoutput8: -------------------------------------------------------------------------------- 1 | ---------------------------- Test U1 ------------------------------ 2 | 1:X one 3 | 2:X two 3:X three 4:X four 5:X five 4 | 6:X six 5 | 7:X seven…8:X eight
9:X nine
10:X ten 6 | RC=0 7 | ---------------------------- Test U2 ------------------------------ 8 | 12-Before 111 9 | 13-Before 222
14-Before 333…15:Match 10 | 16-After 111 11 | 17-After 222
18-After 333 12 | RC=0 13 | -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/grepoutputN: -------------------------------------------------------------------------------- 1 | ---------------------------- Test N1 ------------------------------ 2 | 1:abc 2:def ---------------------------- Test N2 ------------------------------ 3 | 1:abc def 4 | 2:ghi 5 | jkl---------------------------- Test N3 ------------------------------ 6 | 2:def 3: 7 | ghi 8 | jkl---------------------------- Test N4 ------------------------------ 9 | 2:ghi 10 | jkl---------------------------- Test N5 ------------------------------ 11 | 1:abc 2:def 12 | 3:ghi 13 | 4:jkl---------------------------- Test N6 ------------------------------ 14 | 1:abc 2:def 15 | 3:ghi 16 | 4:jkl -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/testinput1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/efc/libc/src/pcre/testdata/testinput1 -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/testinput3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/efc/libc/src/pcre/testdata/testinput3 -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/testinput8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/efc/libc/src/pcre/testdata/testinput8 -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/testoutput1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/efc/libc/src/pcre/testdata/testoutput1 -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/testoutput3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/efc/libc/src/pcre/testdata/testoutput3 -------------------------------------------------------------------------------- /efc/libc/src/pcre/testdata/testoutput8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/efc/libc/src/pcre/testdata/testoutput8 -------------------------------------------------------------------------------- /efc/libc/src/sample1.conf: -------------------------------------------------------------------------------- 1 | #EZ-FRM Config File 2 | 3 | server_name = "EZ" 4 | server_node = "1" 5 | syslog_size = "500000" 6 | syslog_mark = "DEBUG" 7 | #Log Mark: ALL|EMERG|ALERT|CRIT|ERROR|WARNING|NOTICE|INFO|DEBUG|NONE 8 | 9 | env = { 10 | SYBASE=$(DBPROXY)/dblib/SYBASE_15 11 | INFORMIXDIR=$(DBPROXY)/dblib/INFORMIX_30 12 | DB_LOCALE=EN_US.8859-1 13 | DB2PATH=$(DBPROXY)/dblib/DB2_91 14 | } 15 | 16 | proc = { 17 | exec_file = mproc/access.so 18 | auto_refork = TRUE 19 | refork_wait = 1000 #Waiting times(millisecond) for refork it 20 | process_num = "2" 21 | run_as_group = "root" #Only try to switch if we are running as root 22 | run_as_user = "root" #Only try to switch if we are running as root 23 | prv_conf = 24 | { 25 | wait_timeout = 50 26 | run_times = 100 27 | http = { 28 | include = mime.types; 29 | #default_type = application/octet-stream; 30 | server = { 31 | listen = 80 32 | name = @(server_name) #@->get the value whih a key 33 | } 34 | } 35 | } 36 | } 37 | 38 | proc = { 39 | exec_file = mproc/logger.be 40 | auto_refork = TRUE 41 | refork_wait = 1000 #Waiting times(millisecond) for refork it 42 | process_num = "2" 43 | run_as_group = "root" #Only try to switch if we are running as root 44 | run_as_user = "root" #Only try to switch if we are running as root 45 | prv_conf = 46 | { 47 | wait_timeout = 50 48 | run_times = 100 49 | http = { 50 | include = mime.types; 51 | #default_type = application/octet-stream; 52 | server = { 53 | listen = 80 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /efc/libc/src/sample2.conf: -------------------------------------------------------------------------------- 1 | #EZ-FRM Config File 2 | 3 | server_name = "EZ" 4 | server_node = "1" 5 | syslog_size = "500000" 6 | syslog_mark = "DEBUG" 7 | #Log Mark: ALL|EMERG|ALERT|CRIT|ERROR|WARNING|NOTICE|INFO|DEBUG|NONE 8 | 9 | env = { 10 | test =fffd 11 | { 12 | ; kkkk=jfdk 13 | xxxx = { 14 | ; zzzzzzzz 15 | kkkkk = "YYYYYYYYY" 16 | } 17 | } 18 | SYBASE=$(DBPROXY)/dblib/SYBASE_15 19 | INFORMIXDIR=$(DBPROXY)/dblib/INFORMIX_30 20 | DB_LOCALE=EN_US.8859-1 21 | DB2PATH=$(DBPROXY)/dblib/DB2_91 22 | } 23 | 24 | syslog_mark = "DEBUG" 25 | 26 | env = 27 | { 28 | test =ssssssssssssssssssssssssss 29 | { 30 | kkkk=$(DBPROXY) --- @(/env/test) --- $(DBPROXY) --- fffffffffffffffffffffffffffff 31 | } 32 | SYBASE=$(DBPROXY)/dblib/SYBASE_15 33 | INFORMIXDIR=$(DBPROXY)/dblib/INFORMIX_30 34 | DB_LOCALE=EN_US.8859-1 35 | DB2PATH=$(DBPROXY)/dblib/DB2_91 36 | } 37 | -------------------------------------------------------------------------------- /efc/libc/src/zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /efc/libc/src/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /efc/nio/inc/EAsynchronousCloseException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EAsynchronousCloseException.h 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EAsynchronousCloseException_HH_ 9 | #define EAsynchronousCloseException_HH_ 10 | 11 | #include "./EClosedChannelException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define EASYNCHRONOUSCLOSEEXCEPTION EAsynchronousCloseException(__FILE__, __LINE__, errno) 17 | #define EASYNCHRONOUSCLOSEEXCEPTIONS(msg) EAsynchronousCloseException(__FILE__, __LINE__, msg) 18 | 19 | 20 | /** 21 | * Checked exception received by a thread when another thread closes the 22 | * channel or the part of the channel upon which it is blocked in an I/O 23 | * operation. 24 | */ 25 | 26 | class EAsynchronousCloseException: public EClosedChannelException { 27 | public: 28 | /** 29 | * Constructs an EAsynchronousCloseException with no 30 | * detail message. 31 | * 32 | * @param _file_ __FILE__ 33 | * @param _line_ __LINE__ 34 | * @param errn errno 35 | */ 36 | EAsynchronousCloseException(const char *_file_, int _line_, int errn = 0) : 37 | EClosedChannelException(_file_, _line_, errn) { 38 | } 39 | 40 | /** 41 | * Constructs an EAsynchronousCloseException with the 42 | * specified detail message. 43 | * 44 | * @param _file_ __FILE__. 45 | * @param _line_ __LINE__. 46 | * @param s the detail message. 47 | */ 48 | EAsynchronousCloseException(const char *_file_, int _line_, const char *s, int errn = 0) : 49 | EClosedChannelException(_file_, _line_, s, errn) { 50 | } 51 | }; 52 | 53 | } /* namespace nio */ 54 | } /* namespace efc */ 55 | #endif /* EAsynchronousCloseException_HH_ */ 56 | -------------------------------------------------------------------------------- /efc/nio/inc/EBufferOverflowException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EBufferOverflowException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EBUFFEROVERFLOWEXCEPTION_HH_ 9 | #define EBUFFEROVERFLOWEXCEPTION_HH_ 10 | 11 | #include "../../inc/ERuntimeException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define EBUFFEROVERFLOWEXCEPTION EBufferOverflowException(__FILE__, __LINE__, errno) 17 | #define EBUFFEROVERFLOWEXCEPTIONS(msg) EBufferOverflowException(__FILE__, __LINE__, msg) 18 | 19 | 20 | /** 21 | * Unchecked exception thrown when a relative put operation reaches 22 | * the target buffer's limit. 23 | */ 24 | 25 | class EBufferOverflowException: public ERuntimeException { 26 | public: 27 | /** 28 | * Constructs an EBufferOverflowException with no 29 | * detail message. 30 | * 31 | * @param _file_ __FILE__ 32 | * @param _line_ __LINE__ 33 | * @param errn errno 34 | */ 35 | EBufferOverflowException(const char *_file_, int _line_, int errn = 0) : 36 | ERuntimeException(_file_, _line_, errn) { 37 | } 38 | 39 | /** 40 | * Constructs an EBufferOverflowException with the 41 | * specified detail message. 42 | * 43 | * @param _file_ __FILE__. 44 | * @param _line_ __LINE__. 45 | * @param s the detail message. 46 | */ 47 | EBufferOverflowException(const char *_file_, 48 | int _line_, const char *s) : 49 | ERuntimeException(_file_, _line_, s) { 50 | } 51 | }; 52 | 53 | } /* namespace nio */ 54 | } /* namespace efc */ 55 | #endif /* EBUFFEROVERFLOWEXCEPTION_HH_ */ 56 | -------------------------------------------------------------------------------- /efc/nio/inc/EBufferUnderflowException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EBufferUnderflowException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EBUFFERUNDERFLOWEXCEPTION_HH_ 9 | #define EBUFFERUNDERFLOWEXCEPTION_HH_ 10 | 11 | #include "../../inc/ERuntimeException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define EBUFFERUNDERFLOWEXCEPTION EBufferUnderflowException(__FILE__, __LINE__, errno) 17 | #define EBUFFERUNDERFLOWEXCEPTIONS(msg) EBufferUnderflowException(__FILE__, __LINE__, msg) 18 | 19 | 20 | /** 21 | * Unchecked exception thrown when a relative get operation reaches 22 | * the source buffer's limit. 23 | */ 24 | 25 | class EBufferUnderflowException: public ERuntimeException { 26 | public: 27 | /** 28 | * Constructs an EBufferUnderflowException with no 29 | * detail message. 30 | * 31 | * @param _file_ __FILE__ 32 | * @param _line_ __LINE__ 33 | * @param errn errno 34 | */ 35 | EBufferUnderflowException(const char *_file_, int _line_, int errn = 0) : 36 | ERuntimeException(_file_, _line_, errn) { 37 | } 38 | 39 | /** 40 | * Constructs an EBufferUnderflowException with the 41 | * specified detail message. 42 | * 43 | * @param _file_ __FILE__. 44 | * @param _line_ __LINE__. 45 | * @param s the detail message. 46 | */ 47 | EBufferUnderflowException(const char *_file_, 48 | int _line_, const char *s) : 49 | ERuntimeException(_file_, _line_, s) { 50 | } 51 | }; 52 | 53 | } /* namespace nio */ 54 | } /* namespace efc */ 55 | #endif /* EBUFFERUNDERFLOWEXCEPTION_HH_ */ 56 | -------------------------------------------------------------------------------- /efc/nio/inc/ECancelledKeyException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ECancelledKeyException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECANCELLEDKEYEXCEPTION_HH_ 9 | #define ECANCELLEDKEYEXCEPTION_HH_ 10 | 11 | #include "../../inc/EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define ECANCELLEDKEYEXCEPTION ECancelledKeyException(__FILE__, __LINE__, errno) 17 | #define ECANCELLEDKEYEXCEPTIONS(msg) ECancelledKeyException(__FILE__, __LINE__, msg) 18 | 19 | /** 20 | * Unchecked exception thrown when an attempt is made to use 21 | * a selection key that is no longer valid. 22 | * 23 | * @version 1.9, 01/11/19 24 | * @since 1.4 25 | */ 26 | 27 | class ECancelledKeyException : public EIllegalStateException { 28 | public: 29 | /** 30 | * Constructs an ECancelledKeyException with no 31 | * detail message. 32 | * 33 | * @param _file_ __FILE__ 34 | * @param _line_ __LINE__ 35 | * @param errn errno 36 | */ 37 | ECancelledKeyException(const char *_file_, int _line_, int errn = 0) : 38 | EIllegalStateException(_file_, _line_, errn) { 39 | } 40 | 41 | /** 42 | * Constructs an ECancelledKeyException with the 43 | * specified detail message. 44 | * 45 | * @param _file_ __FILE__. 46 | * @param _line_ __LINE__. 47 | * @param s the detail message. 48 | */ 49 | ECancelledKeyException(const char *_file_, 50 | int _line_, const char *s) : 51 | EIllegalStateException(_file_, _line_, s) { 52 | } 53 | }; 54 | 55 | } /* namespace nio */ 56 | } /* namespace efc */ 57 | #endif /* ECANCELLEDKEYEXCEPTION_HH_ */ 58 | -------------------------------------------------------------------------------- /efc/nio/inc/EChannelInputStream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EChannelInputStream.hh 3 | * 4 | * Created on: 2014-2-8 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECHANNELINPUTSTREAM_HH_ 9 | #define ECHANNELINPUTSTREAM_HH_ 10 | 11 | #include "../../inc/EInputStream.hh" 12 | #include "../../inc/ESynchronizeable.hh" 13 | #include "./EByteChannel.hh" 14 | 15 | namespace efc { 16 | namespace nio { 17 | 18 | /** 19 | * This class is defined here rather than in java.nio.channels.Channels 20 | * so that code can be shared with SocketAdaptor. 21 | * 22 | * @since 1.4 23 | */ 24 | 25 | class EChannelInputStream: public EInputStream, public ESynchronizeable { 26 | public: 27 | EChannelInputStream(EByteChannel* ch); 28 | 29 | virtual ~EChannelInputStream(); 30 | 31 | virtual synchronized int read() THROWS(EIOException); 32 | 33 | virtual synchronized int read(void *b, int len) THROWS(EIOException); 34 | 35 | virtual void close() THROWS(EIOException); 36 | 37 | protected: 38 | EByteChannel* ch; 39 | 40 | virtual int read(EIOByteBuffer* bb) THROWS(EIOException); 41 | 42 | private: 43 | EIOByteBuffer* bb;// = null; 44 | void* bs;// = null; // Invoker's previous array 45 | }; 46 | 47 | } /* namespace nio */ 48 | } /* namespace efc */ 49 | #endif /* ECHANNELINPUTSTREAM_HH_ */ 50 | -------------------------------------------------------------------------------- /efc/nio/inc/EClosedByInterruptException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EClosedByInterruptException.h 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECLOSEDBYINTERRUPTEXCEPTION_HH_ 9 | #define ECLOSEDBYINTERRUPTEXCEPTION_HH_ 10 | 11 | #include "./EAsynchronousCloseException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define ECLOSEDBYINTERRUPTEXCEPTION EClosedByInterruptException(__FILE__, __LINE__, errno) 17 | #define ECLOSEDBYINTERRUPTEXCEPTIONS(msg) EClosedByInterruptException(__FILE__, __LINE__, msg) 18 | 19 | 20 | /** 21 | * * Checked exception received by a thread when another thread interrupts it 22 | * while it is blocked in an I/O operation upon a channel. Before this 23 | * exception is thrown the channel will have been closed and the interrupt 24 | * status of the previously-blocked thread will have been set." 25 | */ 26 | 27 | class EClosedByInterruptException: public EAsynchronousCloseException { 28 | public: 29 | /** 30 | * Constructs an EClosedByInterruptException with no 31 | * detail message. 32 | * 33 | * @param _file_ __FILE__ 34 | * @param _line_ __LINE__ 35 | * @param errn errno 36 | */ 37 | EClosedByInterruptException(const char *_file_, int _line_, int errn = 0) : 38 | EAsynchronousCloseException(_file_, _line_, errn) { 39 | } 40 | 41 | /** 42 | * Constructs an EClosedByInterruptException with the 43 | * specified detail message. 44 | * 45 | * @param _file_ __FILE__. 46 | * @param _line_ __LINE__. 47 | * @param s the detail message. 48 | */ 49 | EClosedByInterruptException(const char *_file_, int _line_, const char *s, int errn = 0) : 50 | EAsynchronousCloseException(_file_, _line_, s, errn) { 51 | } 52 | }; 53 | 54 | } /* namespace nio */ 55 | } /* namespace efc */ 56 | #endif /* ECLOSEDBYINTERRUPTEXCEPTION_HH_ */ 57 | -------------------------------------------------------------------------------- /efc/nio/inc/EClosedChannelException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EClosedChannelException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EClosedChannelException_H_ 9 | #define EClosedChannelException_H_ 10 | 11 | #include "../../inc/EIOException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define ECLOSEDCHANNELEXCEPTION EClosedChannelException(__FILE__, __LINE__, errno) 17 | #define ECLOSEDCHANNELEXCEPTIONS(msg) EClosedChannelException(__FILE__, __LINE__, msg) 18 | 19 | /** 20 | * Checked exception thrown when an attempt is made to invoke or complete an 21 | * I/O operation upon channel that is closed, or at least closed to that 22 | * operation. That this exception is thrown does not necessarily imply that 23 | * the channel is completely closed. A socket channel whose write half has 24 | * been shut down, for example, may still be open for reading. 25 | * 26 | * @version 1.9, 01/11/19 27 | * @since 1.4 28 | */ 29 | 30 | class EClosedChannelException: public EIOException { 31 | public: 32 | /** 33 | * Constructs an EClosedChannelException with no 34 | * detail message. 35 | * 36 | * @param _file_ __FILE__ 37 | * @param _line_ __LINE__ 38 | * @param errn errno 39 | */ 40 | EClosedChannelException(const char *_file_, int _line_, int errn = 0) : 41 | EIOException(_file_, _line_, errn) { 42 | } 43 | 44 | /** 45 | * Constructs an EClosedChannelException with the 46 | * specified detail message. 47 | * 48 | * @param _file_ __FILE__. 49 | * @param _line_ __LINE__. 50 | * @param s the detail message. 51 | */ 52 | EClosedChannelException(const char *_file_, int _line_, const char *s, int errn = 0) : 53 | EIOException(_file_, _line_, s, errn) { 54 | } 55 | }; 56 | 57 | } /* namespace nio */ 58 | } /* namespace efc */ 59 | #endif /* EClosedChannelException_H_ */ 60 | -------------------------------------------------------------------------------- /efc/nio/inc/EClosedSelectorException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EClosedSelectorException.hh 3 | * 4 | * Created on: 2013-12-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECLOSEDSELECTOREXCEPTION_HH_ 9 | #define ECLOSEDSELECTOREXCEPTION_HH_ 10 | 11 | #include "../../inc/EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define ECLOSEDSELECTOREXCEPTION EClosedSelectorException(__FILE__, __LINE__, errno) 17 | #define ECLOSEDSELECTOREXCEPTIONS(msg) EClosedSelectorException(__FILE__, __LINE__, msg) 18 | 19 | /** 20 | * Unchecked exception thrown when an attempt is made to invoke an I/O 21 | * operation upon a closed selector. 22 | * 23 | * @version 1.9, 01/11/19 24 | * @since 1.4 25 | */ 26 | 27 | class EClosedSelectorException : public EIllegalStateException { 28 | public: 29 | /** 30 | * Constructs an EClosedSelectorException with no 31 | * detail message. 32 | * 33 | * @param _file_ __FILE__ 34 | * @param _line_ __LINE__ 35 | * @param errn errno 36 | */ 37 | EClosedSelectorException(const char *_file_, int _line_, int errn = 0) : 38 | EIllegalStateException(_file_, _line_, errn) { 39 | } 40 | 41 | /** 42 | * Constructs an EClosedSelectorException with the 43 | * specified detail message. 44 | * 45 | * @param _file_ __FILE__. 46 | * @param _line_ __LINE__. 47 | * @param s the detail message. 48 | */ 49 | EClosedSelectorException(const char *_file_, 50 | int _line_, const char *s) : 51 | EIllegalStateException(_file_, _line_, s) { 52 | } 53 | }; 54 | 55 | } /* namespace nio */ 56 | } /* namespace efc */ 57 | #endif /* ECLOSEDSELECTOREXCEPTION_HH_ */ 58 | -------------------------------------------------------------------------------- /efc/nio/inc/EConnectionPendingException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EConnectionPendingException.hh 3 | * 4 | * Created on: 2013-12-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ECONNECTIONPENDINGEXCEPTION_HH_ 9 | #define ECONNECTIONPENDINGEXCEPTION_HH_ 10 | 11 | #include "../../inc/EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define ECONNECTIONPENDINGEXCEPTION EConnectionPendingException(__FILE__, __LINE__, errno) 17 | #define ECONNECTIONPENDINGEXCEPTIONS(msg) EConnectionPendingException(__FILE__, __LINE__, msg) 18 | 19 | /** 20 | * Unchecked exception thrown when an attempt is made to connect a {@link 21 | * SocketChannel} for which a non-blocking connection operation is already in 22 | * progress. 23 | */ 24 | 25 | class EConnectionPendingException : public EIllegalStateException { 26 | public: 27 | /** 28 | * Constructs an EConnectionPendingException with no 29 | * detail message. 30 | * 31 | * @param _file_ __FILE__ 32 | * @param _line_ __LINE__ 33 | * @param errn errno 34 | */ 35 | EConnectionPendingException(const char *_file_, int _line_, int errn = 0) : 36 | EIllegalStateException(_file_, _line_, errn) { 37 | } 38 | 39 | /** 40 | * Constructs an EConnectionPendingException with the 41 | * specified detail message. 42 | * 43 | * @param _file_ __FILE__. 44 | * @param _line_ __LINE__. 45 | * @param s the detail message. 46 | */ 47 | EConnectionPendingException(const char *_file_, 48 | int _line_, const char *s) : 49 | EIllegalStateException(_file_, _line_, s) { 50 | } 51 | }; 52 | 53 | } /* namespace nio */ 54 | } /* namespace efc */ 55 | #endif /* ECONNECTIONPENDINGEXCEPTION_HH_ */ 56 | -------------------------------------------------------------------------------- /efc/nio/inc/EFileKey.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EFileKey.hh 3 | * 4 | * Created on: 2014-2-23 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EFILEKEY_HH_ 9 | #define EFILEKEY_HH_ 10 | 11 | #include "../../EBase.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | class EFileKey { 17 | public: 18 | static EFileKey* create(int fd); 19 | 20 | virtual int hashCode(); 21 | boolean equals(EFileKey* obj); 22 | 23 | private: 24 | #ifdef WIN32 25 | long dwVolumeSerialNumber; 26 | long nFileIndexHigh; 27 | long nFileIndexLow; 28 | #else 29 | long st_dev; // ID of device 30 | long st_ino; // Inode number 31 | #endif 32 | EFileKey() { } 33 | }; 34 | 35 | } /* namespace nio */ 36 | } /* namespace efc */ 37 | #endif /* EFILEKEY_HH_ */ 38 | -------------------------------------------------------------------------------- /efc/nio/inc/EInvalidMarkException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EInvalidMarkException.hh 3 | * 4 | * Created on: 2013-12-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EINVALIDMARKEXCEPTION_HH_ 9 | #define EINVALIDMARKEXCEPTION_HH_ 10 | 11 | #include "../../inc/EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | 15 | #define EINVALIDMARKEXCEPTION EInvalidMarkException(__FILE__, __LINE__, errno) 16 | #define EINVALIDMARKEXCEPTIONS(msg) EInvalidMarkException(__FILE__, __LINE__, msg) 17 | 18 | /** 19 | * Unchecked exception thrown when an attempt is made to reset a buffer 20 | * when its mark is not defined. 21 | * 22 | * @version 1.14, 01/05/02 23 | * @since 1.4 24 | */ 25 | 26 | class EInvalidMarkException: public EIllegalStateException { 27 | public: 28 | /** 29 | * Constructs an EInvalidMarkException with no 30 | * detail message. 31 | * 32 | * @param _file_ __FILE__ 33 | * @param _line_ __LINE__ 34 | * @param errn errno 35 | */ 36 | EInvalidMarkException(const char *_file_, int _line_, int errn = 0) : 37 | EIllegalStateException(_file_, _line_, errn) { 38 | } 39 | 40 | /** 41 | * Constructs an EInvalidMarkException with the 42 | * specified detail message. 43 | * 44 | * @param _file_ __FILE__. 45 | * @param _line_ __LINE__. 46 | * @param s the detail message. 47 | */ 48 | EInvalidMarkException(const char *_file_, int _line_, 49 | const char *s) : 50 | EIllegalStateException(_file_, _line_, s) { 51 | } 52 | }; 53 | 54 | } /* namespace efc */ 55 | #endif /* EINVALIDMARKEXCEPTION_HH_ */ 56 | -------------------------------------------------------------------------------- /efc/nio/inc/ENativeThreadSet.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENativeThreadSet.hh 3 | * 4 | * Created on: 2014-2-15 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENATIVETHREADSET_HH_ 9 | #define ENATIVETHREADSET_HH_ 10 | 11 | #include "../../inc/EArrayList.hh" 12 | #include "../../inc/ESynchronizeable.hh" 13 | 14 | namespace efc { 15 | namespace nio { 16 | 17 | // Special-purpose data structure for sets of native threads 18 | 19 | class ENativeThreadSet: public ESynchronizeable { 20 | public: 21 | ~ENativeThreadSet(); 22 | ENativeThreadSet(int n); 23 | 24 | // Adds the current native thread to this set, returning its index so that 25 | // it can efficiently be removed later. 26 | // 27 | int add(); 28 | 29 | // Removes the thread at the given index. 30 | // 31 | void remove(int i); 32 | 33 | // Signals all threads in this set. 34 | // 35 | void signal(); 36 | 37 | private: 38 | EArrayList* elts; 39 | }; 40 | 41 | } /* namespace nio */ 42 | } /* namespace efc */ 43 | #endif /* ENATIVETHREADSET_HH_ */ 44 | -------------------------------------------------------------------------------- /efc/nio/inc/ENonReadableChannelException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENonReadableChannelException.hh 3 | * 4 | * Created on: 2013-12-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENONREADABLECHANNELEXCEPTION_HH_ 9 | #define ENONREADABLECHANNELEXCEPTION_HH_ 10 | 11 | #include "../../inc/EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define ENONREADABLECHANNELEXCEPTION ENonReadableChannelException(__FILE__, __LINE__, errno) 17 | #define ENONREADABLECHANNELEXCEPTIONS(msg) ENonReadableChannelException(__FILE__, __LINE__, msg) 18 | 19 | /** 20 | * Unchecked exception thrown when an attempt is made to read 21 | * from a channel that was not originally opened for reading. 22 | */ 23 | 24 | class ENonReadableChannelException: public EIllegalStateException { 25 | public: 26 | /** 27 | * Constructs an ENonReadableChannelException with no 28 | * detail message. 29 | * 30 | * @param _file_ __FILE__ 31 | * @param _line_ __LINE__ 32 | * @param errn errno 33 | */ 34 | ENonReadableChannelException(const char *_file_, int _line_, int errn = 0) : 35 | EIllegalStateException(_file_, _line_, errn) { 36 | } 37 | 38 | /** 39 | * Constructs an ENonReadableChannelException with the 40 | * specified detail message. 41 | * 42 | * @param _file_ __FILE__. 43 | * @param _line_ __LINE__. 44 | * @param s the detail message. 45 | */ 46 | ENonReadableChannelException(const char *_file_, int _line_, 47 | const char *s) : 48 | EIllegalStateException(_file_, _line_, s) { 49 | } 50 | }; 51 | 52 | } /* namespace nio */ 53 | } /* namespace efc */ 54 | #endif /* ENONREADABLECHANNELEXCEPTION_HH_ */ 55 | -------------------------------------------------------------------------------- /efc/nio/inc/ENonWritableChannelException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENonWritableChannelException.hh 3 | * 4 | * Created on: 2013-12-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENONWRITABLECHANNELEXCEPTION_HH_ 9 | #define ENONWRITABLECHANNELEXCEPTION_HH_ 10 | 11 | #include "../../inc/EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define ENONWRITABLECHANNELEXCEPTION ENonWritableChannelException(__FILE__, __LINE__, errno) 17 | #define ENONWRITABLECHANNELEXCEPTIONS(msg) ENonWritableChannelException(__FILE__, __LINE__, msg) 18 | 19 | /** 20 | * Unchecked exception thrown when an attempt is made to write 21 | * to a channel that was not originally opened for writing. 22 | */ 23 | 24 | class ENonWritableChannelException: public EIllegalStateException { 25 | public: 26 | /** 27 | * Constructs an ENonWritableChannelException with no 28 | * detail message. 29 | * 30 | * @param _file_ __FILE__ 31 | * @param _line_ __LINE__ 32 | * @param errn errno 33 | */ 34 | ENonWritableChannelException(const char *_file_, int _line_, int errn = 0) : 35 | EIllegalStateException(_file_, _line_, errn) { 36 | } 37 | 38 | /** 39 | * Constructs an ENonWritableChannelException with the 40 | * specified detail message. 41 | * 42 | * @param _file_ __FILE__. 43 | * @param _line_ __LINE__. 44 | * @param s the detail message. 45 | */ 46 | ENonWritableChannelException(const char *_file_, int _line_, 47 | const char *s) : 48 | EIllegalStateException(_file_, _line_, s) { 49 | } 50 | }; 51 | 52 | } /* namespace nio */ 53 | } /* namespace efc */ 54 | #endif /* ENONWRITABLECHANNELEXCEPTION_HH_ */ 55 | -------------------------------------------------------------------------------- /efc/nio/inc/EOverlappingFileLockException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EOverlappingFileLockException.hh 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EOVERLAPPINGFILELOCKEXCEPTION_HH_ 9 | #define EOVERLAPPINGFILELOCKEXCEPTION_HH_ 10 | 11 | #include "../../inc/EIllegalStateException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define EOVERLAPPINGFILELOCKEXCEPTION EOverlappingFileLockException(__FILE__, __LINE__, errno) 17 | #define EOVERLAPPINGFILELOCKEXCEPTIONS(msg) EOverlappingFileLockException(__FILE__, __LINE__, msg) 18 | 19 | /** 20 | * Unchecked exception thrown when an attempt is made to acquire a lock on a 21 | * region of a file that overlaps a region already locked by the same Java 22 | * virtual machine, or when another thread is already waiting to lock an 23 | * overlapping region of the same file." 24 | */ 25 | 26 | class EOverlappingFileLockException : public EIllegalStateException { 27 | public: 28 | /** 29 | * Constructs an EOverlappingFileLockException with no 30 | * detail message. 31 | * 32 | * @param _file_ __FILE__ 33 | * @param _line_ __LINE__ 34 | * @param errn errno 35 | */ 36 | EOverlappingFileLockException(const char *_file_, int _line_, int errn = 0) : 37 | EIllegalStateException(_file_, _line_, errn) { 38 | } 39 | 40 | /** 41 | * Constructs an EOverlappingFileLockException with the 42 | * specified detail message. 43 | * 44 | * @param _file_ __FILE__. 45 | * @param _line_ __LINE__. 46 | * @param s the detail message. 47 | */ 48 | EOverlappingFileLockException(const char *_file_, 49 | int _line_, const char *s) : 50 | EIllegalStateException(_file_, _line_, s) { 51 | } 52 | }; 53 | 54 | } /* namespace nio */ 55 | } /* namespace efc */ 56 | #endif /* EOVERLAPPINGFILELOCKEXCEPTION_HH_ */ 57 | -------------------------------------------------------------------------------- /efc/nio/inc/EReadOnlyBufferException.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EReadOnlyBufferException.h 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EREADONLYBUFFEREXCEPTION_HH_ 9 | #define EREADONLYBUFFEREXCEPTION_HH_ 10 | 11 | #include "../../inc/EUnsupportedOperationException.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | #define EREADONLYBUFFEREXCEPTION EReadOnlyBufferException(__FILE__, __LINE__, errno) 17 | #define EREADONLYBUFFEREXCEPTIONS(msg) EReadOnlyBufferException(__FILE__, __LINE__, msg) 18 | 19 | /** 20 | * Unchecked exception thrown when a content-mutation method such as 21 | * put or compact is invoked upon a read-only buffer. 22 | */ 23 | 24 | class EReadOnlyBufferException: public EUnsupportedOperationException { 25 | public: 26 | /** 27 | * Constructs an EReadOnlyBufferException with no 28 | * detail message. 29 | * 30 | * @param _file_ __FILE__ 31 | * @param _line_ __LINE__ 32 | * @param errn errno 33 | */ 34 | EReadOnlyBufferException(const char *_file_, int _line_, int errn = 0) : 35 | EUnsupportedOperationException(_file_, _line_, errn) { 36 | } 37 | 38 | /** 39 | * Constructs an EReadOnlyBufferException with the 40 | * specified detail message. 41 | * 42 | * @param _file_ __FILE__. 43 | * @param _line_ __LINE__. 44 | * @param s the detail message. 45 | */ 46 | EReadOnlyBufferException(const char *_file_, int _line_, const char *s, int errn = 0) : 47 | EUnsupportedOperationException(_file_, _line_, s, errn) { 48 | } 49 | }; 50 | 51 | } /* namespace nio */ 52 | } /* namespace efc */ 53 | #endif /* EREADONLYBUFFEREXCEPTION_HH_ */ 54 | -------------------------------------------------------------------------------- /efc/nio/src/EChannelInputStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EChannelInputStream.cpp 3 | * 4 | * Created on: 2014-2-8 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "../inc/EChannelInputStream.hh" 9 | #include "../../inc/EUnsupportedOperationException.hh" 10 | 11 | namespace efc { 12 | namespace nio { 13 | 14 | EChannelInputStream::EChannelInputStream(EByteChannel* ch) : 15 | bb(null), bs(null) { 16 | this->ch = ch; 17 | } 18 | 19 | EChannelInputStream::~EChannelInputStream() { 20 | delete this->bb; 21 | } 22 | 23 | int EChannelInputStream::read() { 24 | SYNCHRONIZED(this) { 25 | return EInputStream::read(); 26 | }} 27 | } 28 | 29 | int EChannelInputStream::read(void* b, int len) { 30 | SYNCHRONIZED(this) { 31 | if (len < 0) { 32 | throw EINDEXOUTOFBOUNDSEXCEPTION; 33 | } else if (len == 0) 34 | return 0; 35 | 36 | ES_ASSERT(b); 37 | 38 | if (this->bs != b) { 39 | delete bb; 40 | bb = EIOByteBuffer::wrap(b, len); 41 | } 42 | bb->limit(ES_MIN(len, bb->capacity())); 43 | bb->position(0); 44 | this->bs = b; 45 | return read(bb); 46 | }} 47 | } 48 | 49 | void EChannelInputStream::close() { 50 | ch->close(); 51 | } 52 | 53 | int EChannelInputStream::read(EIOByteBuffer* bb) { 54 | throw EUNSUPPORTEDOPERATIONEXCEPTION; 55 | } 56 | 57 | } /* namespace nio */ 58 | } /* namespace efc */ 59 | -------------------------------------------------------------------------------- /efc/nio/src/EDatagramDispatcher.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EDatagramDispatcher.hh 3 | * 4 | * Created on: 2016-8-24 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EDATAGRAMDISPATCHER_HH_ 9 | #define EDATAGRAMDISPATCHER_HH_ 10 | 11 | #include "../../inc/EA.hh" 12 | #include "../inc/EIOByteBuffer.hh" 13 | #include "../../inc/EIOException.hh" 14 | 15 | namespace efc { 16 | namespace nio { 17 | 18 | /** 19 | * Allows different platforms to call different native methods 20 | * for read and write operations. 21 | */ 22 | 23 | class EDatagramDispatcher { 24 | public: 25 | static int read(int fd, void* address, int len) THROWS(EIOException); 26 | static long readv(int fd, void* address, int len) THROWS(EIOException); 27 | static int write(int fd, void* address, int len) THROWS(EIOException); 28 | static long writev(int fd, void* address, int len) THROWS(EIOException); 29 | 30 | static int read(int fd, EIOByteBuffer* bb) THROWS(EIOException); 31 | static int read(int fd, EA* dsts, int offset, int length) THROWS(EIOException); 32 | static int write(int fd, EIOByteBuffer* bb) THROWS(EIOException); 33 | static int write(int fd, EA* srcs, int offset, int length) THROWS(EIOException); 34 | 35 | static int recvfrom(int fd, void* address, int len, boolean connected, int* raddr, int* rport) THROWS(EIOException); 36 | static int sendto(int fd, void* address, int len, int raddr, int rport) THROWS(EIOException); 37 | 38 | static void close(int fd) THROWS(EIOException); 39 | static void preClose(int fd) THROWS(EIOException); 40 | }; 41 | 42 | } /* namespace nio */ 43 | } /* namespace efc */ 44 | #endif /* EDATAGRAMDISPATCHER_HH_ */ 45 | -------------------------------------------------------------------------------- /efc/nio/src/EIONetWrapper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EIONetWrapper.cpp 3 | * 4 | * Created on: 2016-8-24 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "./EIONetWrapper.hh" 9 | #include "../inc/EClosedChannelException.hh" 10 | #include "../../inc/ESocketException.hh" 11 | #include "../../inc/ENotYetConnectedException.hh" 12 | #include "../../inc/EAlreadyBoundException.hh" 13 | #include "../../inc/ENotYetBoundException.hh" 14 | #include "../../inc/EUnsupportedAddressTypeException.hh" 15 | #include "../../inc/EUnresolvedAddressException.hh" 16 | #include "../../inc/ERuntimeException.hh" 17 | 18 | namespace efc { 19 | namespace nio { 20 | 21 | void EIONetWrapper::translateToSocketException(EException& x) { 22 | if (instanceof(x)) 23 | throw dynamic_cast(x); 24 | 25 | if (instanceof(x)) { 26 | throw ESocketException(__FILE__, __LINE__, "Socket is closed", &x); 27 | } 28 | else if (instanceof(x)) { 29 | throw ESocketException(__FILE__, __LINE__, "Socket is not connected", &x); 30 | } 31 | else if (instanceof(x)) { 32 | throw ESocketException(__FILE__, __LINE__, "Already bound", &x); 33 | } 34 | else if (instanceof(x)) { 35 | throw ESocketException(__FILE__, __LINE__, "Socket is not bound yet", &x); 36 | } 37 | else if (instanceof(x)) { 38 | throw ESocketException(__FILE__, __LINE__, "Unsupported address type", &x); 39 | } 40 | else if (instanceof(x)) { 41 | throw ESocketException(__FILE__, __LINE__, "Unresolved address", &x); 42 | } 43 | else if (instanceof(x)) 44 | throw dynamic_cast(x); 45 | else 46 | throw ERuntimeException(__FILE__, __LINE__, "Untranslated exception", &x); 47 | } 48 | 49 | } /* namespace nio */ 50 | } /* namespace efc */ 51 | -------------------------------------------------------------------------------- /efc/nio/src/EIONetWrapper.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EIONetWrapper.hh 3 | * 4 | * Created on: 2016-8-24 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EIONETWRAPPER_HH_ 9 | #define EIONETWRAPPER_HH_ 10 | 11 | #include "../../inc/ENetWrapper.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | class EIONetWrapper: public ENetWrapper { 17 | public: 18 | /** 19 | * Convert Exception to SocketException 20 | */ 21 | static void translateToSocketException(EException& x) THROWS(ESocketException); 22 | }; 23 | 24 | } /* namespace nio */ 25 | } /* namespace efc */ 26 | #endif /* EIONETWRAPPER_HH_ */ 27 | -------------------------------------------------------------------------------- /efc/nio/src/EMembershipRegistry.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EMembershipRegistry.hh 3 | * 4 | * Created on: 2016-8-23 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EMEMBERSHIPREGISTRY_HH_ 9 | #define EMEMBERSHIPREGISTRY_HH_ 10 | 11 | #include "../../inc/EHashMap.hh" 12 | #include "../../inc/ELinkedList.hh" 13 | #include "../inc/EMembershipKey.hh" 14 | #include "../../inc/EInetAddress.hh" 15 | #include "../../inc/ENetworkInterface.hh" 16 | 17 | namespace efc { 18 | namespace nio { 19 | 20 | /** 21 | * Simple registry of membership keys for a MulticastChannel. 22 | * 23 | * Instances of this object are not safe by multiple concurrent threads. 24 | */ 25 | 26 | class EMembershipRegistry: public EObject { 27 | public: 28 | virtual ~EMembershipRegistry(); 29 | 30 | /** 31 | * Checks registry for membership of the group on the given 32 | * network interface. 33 | */ 34 | EMembershipKey* checkMembership(EInetAddress* group, ENetworkInterface* interf, 35 | EInetAddress* source); 36 | 37 | /** 38 | * Add membership to the registry, returning a new membership key. 39 | */ 40 | void add(EMembershipKey* key); 41 | 42 | /** 43 | * Remove a key from the registry 44 | */ 45 | void remove(EMembershipKey* key); 46 | 47 | /** 48 | * Invalidate all keys in the registry 49 | */ 50 | void invalidateAll(); 51 | 52 | private: 53 | // map multicast group to keys 54 | EHashMap* >* groups;// = null; 55 | }; 56 | 57 | } /* namespace nio */ 58 | } /* namespace efc */ 59 | #endif /* EMEMBERSHIPREGISTRY_HH_ */ 60 | -------------------------------------------------------------------------------- /efc/nio/src/ENIOUtil.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENIOUtil.hh 3 | * 4 | * Created on: 2014-1-7 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENIOUTIL_HH_ 9 | #define ENIOUTIL_HH_ 10 | 11 | #include "../../inc/EA.hh" 12 | #include "../inc/EIOByteBuffer.hh" 13 | #include "../../inc/EIOException.hh" 14 | 15 | namespace efc { 16 | namespace nio { 17 | 18 | class ENIOUtil { 19 | public: 20 | static long convertReturnVal(long n, boolean reading) THROWS(EIOException); 21 | 22 | static boolean drain(int fd) THROWS(EIOException); 23 | 24 | /* 25 | * Returns the index of first buffer in bufs with remaining, 26 | * or -1 if there is nothing left 27 | */ 28 | static int remaining(EA* bufs); 29 | 30 | #ifdef WIN32 31 | // 32 | #else 33 | static int fdLimit(); 34 | #endif 35 | }; 36 | 37 | } /* namespace nio */ 38 | } /* namespace efc */ 39 | #endif /* ENIOUTIL_HH_ */ 40 | -------------------------------------------------------------------------------- /efc/nio/src/ENativeThread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ENativeThread.cpp 3 | * 4 | * Created on: 2014-1-3 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "./ENativeThread.hh" 9 | #include "../../inc/EIOException.hh" 10 | 11 | namespace efc { 12 | namespace nio { 13 | 14 | int ENativeThread::inited = false; 15 | 16 | static void 17 | nullHandler(int sig) 18 | { 19 | } 20 | 21 | void ENativeThread::init() { 22 | if (!inited) { 23 | if (eso_os_thread_sigaction_init(nullHandler) != 0) { 24 | throw EIOException(__FILE__, __LINE__, "sigaction"); 25 | } 26 | inited = true; 27 | } 28 | } 29 | 30 | es_os_thread_t ENativeThread::current() { 31 | init(); 32 | return eso_os_thread_current(); 33 | } 34 | 35 | void ENativeThread::signal(es_os_thread_t nt) { 36 | init(); 37 | eso_os_thread_kill(nt); 38 | } 39 | 40 | } /* namespace nio */ 41 | } /* namespace efc */ 42 | -------------------------------------------------------------------------------- /efc/nio/src/ENativeThread.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ENativeThread.hh 3 | * 4 | * Created on: 2014-1-3 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ENATIVETHREAD_HH_ 9 | #define ENATIVETHREAD_HH_ 10 | 11 | #include "../../EBase.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | class ENativeThread { 17 | public: 18 | // Returns an opaque token representing the native thread underlying the 19 | // invoking Java thread. On systems that do not require signalling, this 20 | // method always returns -1. 21 | // 22 | static es_os_thread_t current(); 23 | 24 | // Signals the given native thread so as to release it from a blocking I/O 25 | // operation. On systems that do not require signalling, this method has 26 | // no effect. 27 | // 28 | static void signal(es_os_thread_t nt); 29 | 30 | private: 31 | /* File descriptor to which we dup other fd's 32 | * before closing them for real 33 | */ 34 | static int inited;// = false; 35 | static void init() THROWS(EIOException); 36 | }; 37 | 38 | } /* namespace nio */ 39 | } /* namespace efc */ 40 | #endif /* ENATIVETHREAD_HH_ */ 41 | -------------------------------------------------------------------------------- /efc/nio/src/ENativeThreadSet.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ENativeThreadSet.cpp 3 | * 4 | * Created on: 2014-2-15 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "../inc/ENativeThreadSet.hh" 9 | #include "./ENativeThread.hh" 10 | 11 | namespace efc { 12 | namespace nio { 13 | 14 | ENativeThreadSet::~ENativeThreadSet() { 15 | delete elts; 16 | } 17 | 18 | ENativeThreadSet::ENativeThreadSet(int n) { 19 | elts = new EArrayList(n); 20 | } 21 | 22 | int ENativeThreadSet::add() { 23 | llong th = (llong)ENativeThread::current(); 24 | if (th == -1) 25 | return -1; 26 | SYNCHRONIZED (this) { 27 | int length = elts->size(); 28 | for (int i = 0; i < length; i++) { 29 | if (elts->getAt(i) == 0) { 30 | elts->setAt(i, th); 31 | return i; 32 | } 33 | } 34 | elts->add(th); 35 | return length; 36 | }} 37 | } 38 | 39 | void ENativeThreadSet::remove(int i) { 40 | if (i < 0) 41 | return; 42 | SYNCHRONIZED (this) { 43 | elts->setAt(i, 0); 44 | }} 45 | } 46 | 47 | void ENativeThreadSet::signal() { 48 | SYNCHRONIZED (this) { 49 | int n = elts->size(); 50 | for (int i = 0; i < n; i++) { 51 | llong th = elts->getAt(i); 52 | if (th == 0) 53 | continue; 54 | ENativeThread::signal((es_os_thread_t)th); 55 | } 56 | }} 57 | } 58 | 59 | } /* namespace nio */ 60 | } /* namespace efc */ 61 | -------------------------------------------------------------------------------- /efc/nio/src/EPipeWrapper.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EPipeWrapper.hh 3 | * 4 | * Created on: 2014-1-26 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EPIPEWRAPPER_HH_ 9 | #define EPIPEWRAPPER_HH_ 10 | 11 | #include "../inc/ESocketChannel.hh" 12 | 13 | namespace efc { 14 | namespace nio { 15 | 16 | class EPipeWrapper { 17 | public: 18 | EPipeWrapper(); 19 | ~EPipeWrapper(); 20 | 21 | int inFD(); 22 | int outFD(); 23 | 24 | private: 25 | #ifdef WIN32 26 | ESocketChannel* source; 27 | ESocketChannel* sink; 28 | #else 29 | es_pipe_t *pipe; 30 | #endif 31 | }; 32 | 33 | } /* namespace nio */ 34 | } /* namespace efc */ 35 | #endif /* EPIPEWRAPPER_HH_ */ 36 | -------------------------------------------------------------------------------- /efc/nio/src/ESocketDispatcher.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * ESocketDispatcher.hh 3 | * 4 | * Created on: 2013-12-31 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef ESOCKETDISPATCHER_HH_ 9 | #define ESOCKETDISPATCHER_HH_ 10 | 11 | #include "../../inc/EA.hh" 12 | #include "../inc/EFileDispatcher.hh" 13 | 14 | namespace efc { 15 | namespace nio { 16 | 17 | /** 18 | * Allows different platforms to call different native methods 19 | * for read and write operations. 20 | */ 21 | class ESocketDispatcher { 22 | public: 23 | static int read(int fd, void* address, int len) THROWS(EIOException); 24 | static long readv(int fd, void* address, int len) THROWS(EIOException); 25 | static int write(int fd, void* address, int len) THROWS(EIOException); 26 | static long writev(int fd, void* address, int len) THROWS(EIOException); 27 | 28 | static int read(int fd, EIOByteBuffer* bb) THROWS(EIOException); 29 | static int read(int fd, EA* dsts, int offset, int length) THROWS(EIOException); 30 | static int write(int fd, EIOByteBuffer* bb) THROWS(EIOException); 31 | static int write(int fd, EA* srcs, int offset, int length) THROWS(EIOException); 32 | 33 | static void close(int fd) THROWS(EIOException); 34 | static void preClose(int fd) THROWS(EIOException); 35 | }; 36 | 37 | } /* namespace nio */ 38 | } /* namespace efc */ 39 | 40 | #endif /* ESOCKETDISPATCHER_HH_ */ 41 | -------------------------------------------------------------------------------- /efc/src/EAdler32.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EAdler32.cpp 3 | * 4 | * Created on: 2013-7-24 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EAdler32.hh" 9 | 10 | #include "../libc/src/zlib/zlib.h" 11 | 12 | namespace efc { 13 | 14 | EAdler32::~EAdler32() { 15 | } 16 | 17 | EAdler32::EAdler32() { 18 | adler = 1; 19 | } 20 | 21 | void EAdler32::update(byte b) { 22 | adler = adler32(adler, (Bytef*)&b, 1); 23 | } 24 | 25 | void EAdler32::update(byte* b, int len) { 26 | adler = adler32(adler, (Bytef*)b, len); 27 | } 28 | 29 | llong EAdler32::getValue() { 30 | return (llong)adler & 0xffffffffL; 31 | } 32 | 33 | void EAdler32::reset() { 34 | adler = 1; 35 | } 36 | 37 | } /* namespace efc */ 38 | -------------------------------------------------------------------------------- /efc/src/EBoolean.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EBoolean.cpp 3 | * 4 | * Created on: 2013-11-12 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EBoolean.hh" 9 | 10 | namespace efc { 11 | 12 | EBoolean::EBoolean(boolean value) { 13 | _value = value; 14 | } 15 | 16 | EBoolean::EBoolean(const char* s) { 17 | _value = toBoolean(s); 18 | } 19 | 20 | boolean EBoolean::parseBoolean(const char* s) { 21 | return toBoolean(s); 22 | } 23 | 24 | boolean EBoolean::booleanValue() { 25 | return _value; 26 | } 27 | 28 | EBoolean EBoolean::valueOf(boolean b) { 29 | return EBoolean(b); 30 | } 31 | 32 | EBoolean EBoolean::valueOf(const char* s) { 33 | return EBoolean(toBoolean(s)); 34 | } 35 | 36 | EString EBoolean::toString(boolean b) { 37 | return EString(b ? "true" : "false"); 38 | } 39 | 40 | EString EBoolean::toString() { 41 | return EString(_value ? "true" : "false"); 42 | } 43 | 44 | int EBoolean::hashCode() { 45 | return _value ? 1231 : 1237; 46 | } 47 | 48 | boolean EBoolean::equals(EBoolean* obj) { 49 | if (!obj) return false; 50 | return _value == obj->booleanValue(); 51 | } 52 | 53 | boolean EBoolean::equals(EObject* obj) { 54 | if (this == obj) { 55 | return true; 56 | } 57 | EBoolean* that = dynamic_cast(obj); 58 | if (!that) { 59 | return false; 60 | } 61 | return _value == that->booleanValue(); 62 | } 63 | 64 | int EBoolean::compareTo(EBoolean* b) { 65 | return (b->_value == _value ? 0 : (_value ? 1 : -1)); 66 | } 67 | 68 | boolean EBoolean::toBoolean(const char* name) { 69 | return ((name != null) && (!eso_strcasecmp(name, "true") || eso_atol(name))); 70 | } 71 | 72 | } /* namespace efc */ 73 | -------------------------------------------------------------------------------- /efc/src/EBsonParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EBsonParser.cpp 3 | * 4 | * Created on: 2013-7-30 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EBsonParser.hh" 9 | 10 | namespace efc { 11 | 12 | es_int32_t EBsonParser::stream_read(void *s, void *buf, es_size_t *size) 13 | { 14 | EBsonParser::Stream *ins = (EBsonParser::Stream*)s; 15 | int ret = ins->self->_is->read(buf, *size); 16 | *size = (ret >= 0) ? ret : 0; 17 | return ret > 0 ? ES_SUCCESS : BSON_EREAD; 18 | } 19 | 20 | void EBsonParser::parsed_node(void *s, es_bson_t *bson, es_bson_node_t *node) 21 | { 22 | EBsonParser::Stream *ins = (EBsonParser::Stream*)s; 23 | ins->self->parsing(node); 24 | } 25 | 26 | EBsonParser::~EBsonParser() { 27 | eso_bson_parser_uninit(&_es.stm); 28 | } 29 | 30 | EBsonParser::EBsonParser(EInputStream* is) : 31 | _is(is), _bson(null) { 32 | eso_bson_parser_init(&_es.stm, EBsonParser::stream_read, EBsonParser::parsed_node); 33 | _es.self = this; 34 | } 35 | 36 | boolean EBsonParser::nextBson(EBson* bson) { 37 | if (bson) { 38 | bson->clear(); 39 | } 40 | _bson = bson; 41 | 42 | if (_es.stm.finished) { 43 | return false; 44 | } 45 | 46 | if (eso_bson_parse(_bson->c_bson(), (es_bson_stream_t*) &_es) != ES_SUCCESS) { 47 | return false; 48 | } 49 | 50 | return true; 51 | } 52 | 53 | } /* namespace efc */ 54 | -------------------------------------------------------------------------------- /efc/src/EByte.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EByte.cpp 3 | * 4 | * Created on: 2013-3-21 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EByte.hh" 9 | #include "EInteger.hh" 10 | 11 | namespace efc { 12 | 13 | EByte::EByte(byte value) { 14 | this->value = value; 15 | } 16 | 17 | boolean EByte::equals(byte that) 18 | { 19 | return (value == that); 20 | } 21 | 22 | EString EByte::toString() 23 | { 24 | return EString::valueOf(value); 25 | } 26 | 27 | byte EByte::parseByte(const char *s, int radix) THROWS(ENumberFormatException) 28 | { 29 | int i = EInteger::parseInt(s, radix); 30 | if (i < MIN_VALUE || i > MAX_VALUE) 31 | throw ENumberFormatException(__FILE__, __LINE__); 32 | return (byte) i; 33 | } 34 | 35 | int EByte::compare(byte x, byte y) { 36 | return x - y; 37 | } 38 | 39 | boolean EByte::equals(EByte* obj) 40 | { 41 | if (!obj) return false; 42 | return value == obj->byteValue(); 43 | } 44 | 45 | boolean EByte::equals(EObject* obj) { 46 | if (!obj) return false; 47 | EByte* that = dynamic_cast(obj); 48 | if (!that) return false; 49 | return value == that->byteValue(); 50 | } 51 | 52 | int EByte::hashCode() { 53 | return (int)value; 54 | } 55 | 56 | int EByte::compareTo(EByte* anotherByte) { 57 | return compare(this->value, anotherByte->value); 58 | } 59 | 60 | 61 | byte EByte::byteValue() 62 | { 63 | return (byte)value; 64 | } 65 | 66 | short EByte::shortValue() 67 | { 68 | return (short)value; 69 | } 70 | 71 | int EByte::intValue() 72 | { 73 | return (int)value; 74 | } 75 | 76 | llong EByte::llongValue() 77 | { 78 | return (llong)value; 79 | } 80 | 81 | float EByte::floatValue() { 82 | return (float)value; 83 | } 84 | 85 | double EByte::doubleValue() { 86 | return (double)value; 87 | } 88 | 89 | } /* namespace efc */ 90 | -------------------------------------------------------------------------------- /efc/src/EByteArrayInputStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EByteArrayInputStream.hh 3 | * 4 | * Created on: 2013-3-25 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EByteArrayInputStream.hh" 9 | 10 | namespace efc { 11 | 12 | #undef SYNCHRONIZED 13 | #define SYNCHRONIZED(obj) { \ 14 | ESentry __synchronizer__(lock ? (obj)->getLock() : null); 15 | 16 | EByteArrayInputStream::~EByteArrayInputStream() 17 | { 18 | } 19 | 20 | EByteArrayInputStream::EByteArrayInputStream(void *buf, int len, boolean lock) 21 | { 22 | this->buf = (byte*)buf; 23 | this->count = len; 24 | this->pos = 0; 25 | this->lock = lock; 26 | } 27 | 28 | synchronized int EByteArrayInputStream::read(void *b, int len) 29 | { 30 | SYNCHRONIZED(this) { 31 | if (b == null) { 32 | throw ENullPointerException(__FILE__, __LINE__); 33 | } 34 | if (pos >= count) { 35 | return -1; 36 | } 37 | if (pos + len > count) { 38 | len = count - pos; 39 | } 40 | if (len <= 0) { 41 | return 0; 42 | } 43 | eso_memcpy(b, buf + pos, len); 44 | pos += len; 45 | return len; 46 | }} 47 | } 48 | 49 | synchronized long EByteArrayInputStream::skip(long n) 50 | { 51 | SYNCHRONIZED(this) { 52 | if (pos + n > count) { 53 | n = count - pos; 54 | } 55 | if (n < 0) { 56 | return 0; 57 | } 58 | pos += n; 59 | return n; 60 | }} 61 | } 62 | 63 | synchronized long EByteArrayInputStream::available() 64 | { 65 | SYNCHRONIZED(this) { 66 | return count - pos; 67 | }} 68 | } 69 | 70 | } /* namespace efc */ 71 | -------------------------------------------------------------------------------- /efc/src/ECRC32.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ECRC32.cpp 3 | * 4 | * Created on: 2013-7-24 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ECRC32.hh" 9 | 10 | namespace efc { 11 | 12 | ECRC32::~ECRC32() { 13 | } 14 | 15 | ECRC32::ECRC32() { 16 | eso_crc32_init(_crc); 17 | } 18 | 19 | void ECRC32::update(byte b) { 20 | eso_crc32_update(&_crc, (es_byte_t*)&b, 1); 21 | } 22 | 23 | void ECRC32::update(byte* b, int len) { 24 | eso_crc32_update(&_crc, (es_byte_t*)b, len); 25 | } 26 | 27 | llong ECRC32::getValue() { 28 | return eso_crc32_final(_crc); 29 | } 30 | 31 | void ECRC32::reset() { 32 | eso_crc32_init(_crc); 33 | } 34 | 35 | } /* namespace efc */ 36 | -------------------------------------------------------------------------------- /efc/src/ECharacter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ECharacter.cpp 3 | * 4 | * Created on: 2013-3-21 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ECharacter.hh" 9 | #include "EInteger.hh" 10 | 11 | namespace efc { 12 | 13 | ECharacter::ECharacter(char value) { 14 | m_value = value; 15 | } 16 | 17 | char ECharacter::charValue() 18 | { 19 | return m_value; 20 | } 21 | 22 | boolean ECharacter::equals(char that) 23 | { 24 | return (m_value == that); 25 | } 26 | 27 | boolean ECharacter::equals(EObject* obj) { 28 | if (!obj) return false; 29 | ECharacter* that = dynamic_cast(obj); 30 | if (!that) return false; 31 | return (m_value == that->charValue()); 32 | } 33 | 34 | EString ECharacter::toString() 35 | { 36 | return EString::valueOf(m_value); 37 | } 38 | 39 | boolean ECharacter::isLowerCase(char ch) 40 | { 41 | return eso_islower(ch); 42 | } 43 | 44 | boolean ECharacter::isUpperCase(char ch) 45 | { 46 | return eso_isupper(ch); 47 | } 48 | 49 | boolean ECharacter::isDigit(char ch) 50 | { 51 | return eso_isdigit(ch); 52 | } 53 | 54 | char ECharacter::toLowerCase(char ch) 55 | { 56 | return eso_tolower(ch); 57 | } 58 | 59 | char ECharacter::toUpperCase(char ch) 60 | { 61 | return eso_toupper(ch); 62 | } 63 | 64 | int ECharacter::digit(char ch, int radix) 65 | { 66 | return EInteger::toDigit(ch, radix); 67 | } 68 | 69 | } /* namespace efc */ 70 | -------------------------------------------------------------------------------- /efc/src/ECheckedInputStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ECheckedInputStream.cpp 3 | * 4 | * Created on: 2013-7-24 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ECheckedInputStream.hh" 9 | 10 | namespace efc { 11 | 12 | #define TMP_BUFSIZE 512 13 | 14 | ECheckedInputStream::~ECheckedInputStream() { 15 | } 16 | 17 | ECheckedInputStream::ECheckedInputStream(EInputStream* in, EChecksum* cksum, boolean owned) : 18 | EFilterInputStream(in, owned) { 19 | _cksum = cksum; 20 | } 21 | 22 | int ECheckedInputStream::read() 23 | { 24 | int b = _in->read(); 25 | if (b != -1) { 26 | _cksum->update(b); 27 | } 28 | return b; 29 | } 30 | 31 | int ECheckedInputStream::read(void* b, int len) { 32 | len = _in->read(b, len); 33 | if (len != -1) { 34 | _cksum->update((byte*)b, len); 35 | } 36 | return len; 37 | } 38 | 39 | long ECheckedInputStream::skip(long n) { 40 | byte* buf = (byte*)eso_malloc(TMP_BUFSIZE); 41 | long total = 0; 42 | while (total < n) { 43 | long len = n - total; 44 | len = read(buf, len < TMP_BUFSIZE ? (int) len : TMP_BUFSIZE); 45 | if (len == -1) { 46 | eso_free(buf); 47 | return total; 48 | } 49 | total += len; 50 | } 51 | eso_free(buf); 52 | return total; 53 | } 54 | 55 | EChecksum* ECheckedInputStream::getChecksum() { 56 | return _cksum; 57 | } 58 | 59 | } /* namespace efc */ 60 | -------------------------------------------------------------------------------- /efc/src/ECheckedOutputStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ECheckedOutputStream.cpp 3 | * 4 | * Created on: 2017-12-8 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ECheckedOutputStream.hh" 9 | 10 | namespace efc { 11 | 12 | ECheckedOutputStream::~ECheckedOutputStream() { 13 | // 14 | } 15 | 16 | ECheckedOutputStream::ECheckedOutputStream(EOutputStream* out, EChecksum* cksum, boolean owned) : 17 | EFilterOutputStream(out, owned) { 18 | this->cksum = cksum; 19 | } 20 | 21 | void ECheckedOutputStream::write(int b) { 22 | _out->write(b); 23 | cksum->update(b); 24 | } 25 | 26 | void ECheckedOutputStream::write(const void *b, int len) { 27 | _out->write(b, len); 28 | cksum->update((byte*)b, len); 29 | } 30 | 31 | EChecksum* ECheckedOutputStream::getChecksum() { 32 | return cksum; 33 | } 34 | 35 | } /* namespace efc */ 36 | -------------------------------------------------------------------------------- /efc/src/EEventObject.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EEventObject.cpp 3 | * 4 | * Created on: 2015-2-6 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EEventObject.hh" 9 | #include "EIllegalArgumentException.hh" 10 | 11 | namespace efc { 12 | 13 | EEventObject::EEventObject(EObject* source) { 14 | if (source == null) 15 | throw EIllegalArgumentException(__FILE__, __LINE__, "null source"); 16 | 17 | this->source = source; 18 | } 19 | 20 | /** 21 | * The object on which the Event initially occurred. 22 | * 23 | * @return The object on which the Event initially occurred. 24 | */ 25 | EObject* EEventObject::getSource() { 26 | return source; 27 | } 28 | 29 | /** 30 | * Returns a String representation of this EventObject. 31 | * 32 | * @return A a String representation of this EventObject. 33 | */ 34 | EString EEventObject::toString() { 35 | return EString::formatOf("EEventObject[%p]", source); 36 | } 37 | 38 | } /* namespace efc */ 39 | -------------------------------------------------------------------------------- /efc/src/EFilterInputStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EFilterInputStream.cpp 3 | * 4 | * Created on: 2013-3-25 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EFilterInputStream.hh" 9 | 10 | namespace efc { 11 | 12 | EFilterInputStream::~EFilterInputStream() { 13 | if (_owned) { 14 | delete _in; 15 | } 16 | } 17 | 18 | EFilterInputStream::EFilterInputStream(EInputStream *in, boolean owned) : 19 | _in(in), _owned(owned) { 20 | } 21 | 22 | int EFilterInputStream::read(void *b, int len) 23 | { 24 | return _in->read(b, len); 25 | } 26 | 27 | long EFilterInputStream::skip(long n) 28 | { 29 | return _in->skip(n); 30 | } 31 | 32 | long EFilterInputStream::available() 33 | { 34 | return _in->available(); 35 | } 36 | 37 | void EFilterInputStream::close() 38 | { 39 | _in->close(); 40 | } 41 | 42 | } /* namespace efc */ 43 | -------------------------------------------------------------------------------- /efc/src/EFilterOutputStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EFilterOutputStream.cpp 3 | * 4 | * Created on: 2013-3-25 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EFilterOutputStream.hh" 9 | 10 | namespace efc { 11 | 12 | EFilterOutputStream::~EFilterOutputStream() { 13 | if (_owned) { 14 | delete _out; 15 | } 16 | } 17 | 18 | EFilterOutputStream::EFilterOutputStream(EOutputStream *out, boolean owned) : 19 | _out(out), _owned(owned), closed(false) { 20 | } 21 | 22 | void EFilterOutputStream::write(const void *b, int len) 23 | { 24 | _out->write(b, len); 25 | } 26 | 27 | void EFilterOutputStream::write(const char *s) 28 | { 29 | EOutputStream::write(s); 30 | } 31 | 32 | void EFilterOutputStream::write(int b) 33 | { 34 | EOutputStream::write(b); 35 | } 36 | 37 | void EFilterOutputStream::flush() 38 | { 39 | _out->flush(); 40 | } 41 | 42 | void EFilterOutputStream::close() 43 | { 44 | if (closed) { 45 | return; 46 | } 47 | closed = true; 48 | 49 | try { 50 | flush(); 51 | } catch (...) { 52 | } 53 | _out->close(); 54 | } 55 | 56 | } /* namespace efc */ 57 | -------------------------------------------------------------------------------- /efc/src/EIdentityHashMap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EIdentityHashMap.cpp 3 | * 4 | * Created on: 2015-7-18 5 | * Author: cxxjava@163.com 6 | */ 7 | #include "EIdentityHashMap.hh" 8 | 9 | namespace efc { 10 | namespace idhm { 11 | EObject* NULL_KEY = new EObject(); 12 | } 13 | } /* namespace efc */ 14 | -------------------------------------------------------------------------------- /efc/src/EInputStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EInputStream.hh 3 | * 4 | * Created on: 2013-3-25 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EInputStream.hh" 9 | 10 | namespace efc { 11 | 12 | // SKIP_BUFFER_SIZE is used to determine the size of skipBuffer 13 | #define SKIP_BUFFER_SIZE 2048 14 | 15 | int EInputStream::read() 16 | { 17 | unsigned char c; 18 | int r = read((byte*)&c, 1); 19 | return (r == -1) ? -1 : (int)c; 20 | } 21 | 22 | long EInputStream::skip(long n) 23 | { 24 | long remaining = n; 25 | int nr; 26 | byte localSkipBuffer[SKIP_BUFFER_SIZE];; 27 | 28 | if (n <= 0) { 29 | return 0; 30 | } 31 | 32 | while (remaining > 0) { 33 | nr = read(localSkipBuffer, 34 | (int) ES_MIN(SKIP_BUFFER_SIZE, remaining)); 35 | if (nr < 0) { 36 | break; 37 | } 38 | remaining -= nr; 39 | } 40 | 41 | return n - remaining; 42 | } 43 | 44 | long EInputStream::available() 45 | { 46 | return 0; 47 | } 48 | 49 | void EInputStream::close() 50 | { 51 | } 52 | 53 | } /* namespace efc */ 54 | -------------------------------------------------------------------------------- /efc/src/EInterfaceAddress.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EInterfaceAddress.cpp 3 | * 4 | * Created on: 2016-8-12 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EInterfaceAddress.hh" 9 | 10 | namespace efc { 11 | 12 | EInterfaceAddress::~EInterfaceAddress() { 13 | // 14 | } 15 | 16 | EInterfaceAddress::EInterfaceAddress(): maskLength(0) { 17 | } 18 | 19 | EInterfaceAddress::EInterfaceAddress(sp address, 20 | sp broadcast, short mask) : maskLength(mask) { 21 | this->address = address; 22 | this->broadcast = broadcast; 23 | } 24 | 25 | EInetAddress* EInterfaceAddress::getAddress() { 26 | return address.get(); 27 | } 28 | 29 | EInetAddress* EInterfaceAddress::getBroadcast() { 30 | return broadcast.get(); 31 | } 32 | 33 | short EInterfaceAddress::getNetworkPrefixLength() { 34 | return maskLength; 35 | } 36 | 37 | bool EInterfaceAddress::equals(EObject* obj) { 38 | EInterfaceAddress* cmp = dynamic_cast(obj); 39 | if (!cmp) 40 | return false; 41 | if ( !(address == null ? cmp->address == null : address->equals(cmp->address.get())) ) 42 | return false; 43 | if ( !(broadcast == null ? cmp->broadcast == null : broadcast->equals(cmp->broadcast.get())) ) 44 | return false; 45 | if (maskLength != cmp->maskLength) 46 | return false; 47 | return true; 48 | } 49 | 50 | int EInterfaceAddress::hashCode() { 51 | return address->hashCode() + ((broadcast != null) ? broadcast->hashCode() : 0) + maskLength; 52 | } 53 | 54 | EString EInterfaceAddress::toString() { 55 | return address->toString() + "/" + maskLength + " [" + (broadcast != null ? broadcast->toString() : "") + "]"; 56 | } 57 | 58 | } /* namespace efc */ 59 | -------------------------------------------------------------------------------- /efc/src/EMath.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EMath.cpp 3 | * 4 | * Created on: 2013-3-21 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EMath.hh" 9 | #include "ERandom.hh" 10 | #include "EThread.hh" 11 | #include "ESynchronizeable.hh" 12 | 13 | namespace efc { 14 | 15 | const double EMath::E = 2.7182818284590452354; 16 | const double EMath::PI = 3.14159265358979323846; 17 | ERandom* EMath::randomNumberGenerator; 18 | 19 | DEFINE_STATIC_INITZZ_BEGIN(EMath) 20 | EThread::_initzz_(); // for ERandom::lock 21 | randomNumberGenerator = EMath::getRandom(); 22 | DEFINE_STATIC_INITZZ_END 23 | 24 | ERandom* EMath::getRandom() { 25 | static ERandom random; 26 | return &random; 27 | } 28 | 29 | double EMath::toDegrees(double rads) 30 | { 31 | return rads / 0.017453292519943295; 32 | } 33 | 34 | double EMath::toRadians(double degrees) 35 | { 36 | return degrees * 0.017453292519943295; 37 | } 38 | 39 | double EMath::random() { 40 | randomNumberGenerator = getRandom(); 41 | return randomNumberGenerator->nextDouble(); 42 | } 43 | 44 | } /* namespace efc */ 45 | -------------------------------------------------------------------------------- /efc/src/EObject.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "EString.hh" 4 | 5 | namespace efc { 6 | 7 | EObject::EObject() 8 | { 9 | } 10 | 11 | EObject::~EObject() 12 | { 13 | } 14 | 15 | boolean EObject::equals(EObject* obj) 16 | { 17 | return obj ? (((void*)this == (void*)obj) ? true : false) : false; 18 | } 19 | 20 | /** 21 | * The general contract of hashCode is: 22 | * Whenever it is invoked on the same object more than once during an execution of a Java application, 23 | * the hashCode method must consistently return the same integer, provided no information used in equals 24 | * comparisons on the object is modified. This integer need not remain consistent from one execution of 25 | * an application to another execution of the same application. 26 | * If two objects are equal according to the equals(Object) method, then calling the hashCode method on 27 | * each of the two objects must produce the same integer result. 28 | * It is not required that if two objects are unequal according to the equals(java.lang.Object) method, 29 | * then calling the hashCode method on each of the two objects must produce distinct integer results. 30 | * However, the programmer should be aware that producing distinct integer results for unequal objects 31 | * may improve the performance of hashtables. 32 | */ 33 | int EObject::hashCode() 34 | { 35 | es_size_t v = (es_size_t)this; 36 | return (int)(v ^ (v >> sizeof(es_size_t))); 37 | } 38 | 39 | EString EObject::toString() { 40 | char s[256] = {}; 41 | eso_snprintf(s, sizeof(s), "%s@%d", typeid(*this).name(), hashCode()); 42 | return s; 43 | } 44 | 45 | } /* namespace efc */ 46 | -------------------------------------------------------------------------------- /efc/src/EOutputStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EOutputStream.hh 3 | * 4 | * Created on: 2013-3-25 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EOutputStream.hh" 9 | 10 | namespace efc { 11 | 12 | void EOutputStream::write(int b) 13 | { 14 | char c = (char)b; 15 | write((byte*)&c, 1); 16 | } 17 | 18 | void EOutputStream::write(const char* s) 19 | { 20 | write(s, eso_strlen(s)); 21 | } 22 | 23 | void EOutputStream::flush() 24 | { 25 | } 26 | 27 | void EOutputStream::close() 28 | { 29 | } 30 | 31 | } /* namespace efc */ 32 | -------------------------------------------------------------------------------- /efc/src/ESentry.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ESentry.cpp 3 | * 4 | * Created on: 2013-3-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ESentry.hh" 9 | 10 | namespace efc { 11 | 12 | ESentry::ESentry(ELock* lock) : 13 | _lock(lock) { 14 | if (_lock) { 15 | _lock->lock(); 16 | } 17 | } 18 | 19 | ESentry::~ESentry() 20 | { 21 | if (_lock) { 22 | _lock->unlock(); 23 | } 24 | } 25 | 26 | } /* namespace efc */ 27 | -------------------------------------------------------------------------------- /efc/src/ESharedPtr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ESharedPtr.cpp 3 | * 4 | * Created on: 2013-11-12 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ESharedPtr.hh" 9 | #include "ESpinLock.hh" 10 | 11 | namespace efc { 12 | 13 | ELock* gRCLock = new ESpinLock(); 14 | 15 | } /* namespace efc */ 16 | -------------------------------------------------------------------------------- /efc/src/EShort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EShort.cpp 3 | * 4 | * Created on: 2017-6-21 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EShort.hh" 9 | #include "EInteger.hh" 10 | 11 | namespace efc { 12 | 13 | EShort::EShort(short value) { 14 | this->value = value; 15 | } 16 | 17 | boolean EShort::equals(short that) 18 | { 19 | return (value == that); 20 | } 21 | 22 | EString EShort::toString() 23 | { 24 | return EString::valueOf(value); 25 | } 26 | 27 | short EShort::parseShort(const char *s, int radix) THROWS(ENumberFormatException) 28 | { 29 | int i = EInteger::parseInt(s, radix); 30 | if (i < MIN_VALUE || i > MAX_VALUE) 31 | throw ENumberFormatException(__FILE__, __LINE__); 32 | return (short) i; 33 | } 34 | 35 | EShort EShort::valueOf(const char* s, int radix) 36 | { 37 | return EShort(parseShort(s, radix)); 38 | } 39 | 40 | int EShort::compare(short x, short y) { 41 | return x - y; 42 | } 43 | 44 | boolean EShort::equals(EShort* obj) 45 | { 46 | if (!obj) return false; 47 | return value == obj->shortValue(); 48 | } 49 | 50 | boolean EShort::equals(EObject* obj) { 51 | if (!obj) return false; 52 | EShort* that = dynamic_cast(obj); 53 | if (!that) return false; 54 | return value == that->shortValue(); 55 | } 56 | 57 | int EShort::hashCode() { 58 | return (int)value; 59 | } 60 | 61 | int EShort::compareTo(EShort* anotherShort) { 62 | return compare(this->value, anotherShort->value); 63 | } 64 | 65 | byte EShort::byteValue() 66 | { 67 | return (byte)value; 68 | } 69 | 70 | short EShort::shortValue() 71 | { 72 | return (short)value; 73 | } 74 | 75 | int EShort::intValue() 76 | { 77 | return (int)value; 78 | } 79 | 80 | llong EShort::llongValue() 81 | { 82 | return (llong)value; 83 | } 84 | 85 | float EShort::floatValue() { 86 | return (float)value; 87 | } 88 | 89 | double EShort::doubleValue() { 90 | return (double)value; 91 | } 92 | 93 | } /* namespace efc */ 94 | -------------------------------------------------------------------------------- /efc/src/ESimpleCondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ESimpleCondition.cpp 3 | * 4 | * Created on: 2013-3-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ESimpleCondition.hh" 9 | #include "ESystem.hh" 10 | 11 | namespace efc { 12 | 13 | ESimpleCondition::~ESimpleCondition() { 14 | eso_thread_cond_destroy(&m_Cond); 15 | } 16 | 17 | ESimpleCondition::ESimpleCondition(es_thread_mutex_t *mutex) { 18 | m_Cond = eso_thread_cond_create(); 19 | m_Mutex = mutex; 20 | } 21 | 22 | void ESimpleCondition::await() { 23 | eso_thread_cond_wait(m_Cond, m_Mutex); 24 | } 25 | 26 | llong ESimpleCondition::awaitNanos(llong nanosTimeout) { 27 | llong lastTime = ESystem::nanoTime(); 28 | eso_thread_cond_timedwait(m_Cond, m_Mutex, nanosTimeout); 29 | llong currTime = ESystem::nanoTime(); 30 | return nanosTimeout - (currTime - lastTime); 31 | } 32 | 33 | boolean ESimpleCondition::await(llong time, ETimeUnit* unit) { 34 | llong nanosTimeout = unit->toNanos(time); 35 | return (awaitNanos(nanosTimeout) > 0) ? false : true; 36 | } 37 | 38 | boolean ESimpleCondition::awaitUntil(EDate* deadline) THROWS(ERuntimeException) { 39 | llong currTime = ESystem::currentTimeMillis(); 40 | llong abstime = deadline->getTime(); 41 | llong t = abstime - currTime; 42 | if (t < LLONG(0)) { 43 | throw ERuntimeException(__FILE__, __LINE__); 44 | } 45 | eso_thread_cond_timedwait(m_Cond, m_Mutex, (es_uint32_t)t); 46 | currTime = ESystem::currentTimeMillis(); 47 | return (currTime - abstime) > LLONG(0) ? false : true; 48 | } 49 | 50 | void ESimpleCondition::signal() { 51 | eso_thread_cond_signal(m_Cond); 52 | } 53 | 54 | void ESimpleCondition::signalAll() { 55 | eso_thread_cond_broadcast(m_Cond); 56 | } 57 | 58 | } /* namespace efc */ 59 | -------------------------------------------------------------------------------- /efc/src/ESimpleLock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ESimpleLock.cpp 3 | * 4 | * Created on: 2013-3-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ESimpleLock.hh" 9 | #include "ESimpleCondition.hh" 10 | 11 | namespace efc { 12 | 13 | ESimpleLock::ESimpleLock(int flag) { 14 | m_Mutex = eso_thread_mutex_create(flag); 15 | } 16 | 17 | ESimpleLock::~ESimpleLock() { 18 | eso_thread_mutex_destroy(&m_Mutex); 19 | } 20 | 21 | void ESimpleLock::lock() 22 | { 23 | eso_thread_mutex_lock(m_Mutex); 24 | } 25 | 26 | void ESimpleLock::lockInterruptibly() { 27 | //TODO... 28 | } 29 | 30 | boolean ESimpleLock::tryLock() 31 | { 32 | es_status_t rv = eso_thread_mutex_trylock(m_Mutex); 33 | return (rv == ES_SUCCESS) ? true : false; 34 | } 35 | 36 | boolean ESimpleLock::tryLock(llong timeout, ETimeUnit* unit) 37 | { 38 | es_status_t rv = eso_thread_mutex_timedlock(m_Mutex, unit->toMillis(timeout)); 39 | return (rv == ES_SUCCESS) ? true : false; 40 | } 41 | 42 | void ESimpleLock::unlock() 43 | { 44 | eso_thread_mutex_unlock(m_Mutex); 45 | } 46 | 47 | ECondition* ESimpleLock::newCondition() 48 | { 49 | return new ESimpleCondition(m_Mutex); 50 | } 51 | 52 | } /* namespace efc */ 53 | -------------------------------------------------------------------------------- /efc/src/ESimpleStack.cpp: -------------------------------------------------------------------------------- 1 | #include "ESimpleStack.hh" 2 | 3 | namespace efc { 4 | 5 | void ESimpleStack::push(EObject* item) 6 | { 7 | pushElement(item); 8 | } 9 | 10 | EObject* ESimpleStack::pop() 11 | { 12 | return popElement(); 13 | } 14 | 15 | EObject* ESimpleStack::peek() 16 | { 17 | int len = size(); 18 | 19 | if (len == 0) { 20 | return NULL; 21 | } 22 | 23 | return elementAt(len - 1); 24 | } 25 | 26 | boolean ESimpleStack::empty() 27 | { 28 | return size() == 0; 29 | } 30 | 31 | int ESimpleStack::search(EObject *o) 32 | { 33 | int i = lastIndexOf(o); 34 | 35 | if (i >= 0) { 36 | return size() - i - 1; 37 | } 38 | 39 | return -1; 40 | } 41 | 42 | } /* namespace efc */ 43 | -------------------------------------------------------------------------------- /efc/src/ESocketOptions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ESocketOptions.cpp 3 | * 4 | * Created on: 2013-3-14 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ESocketOptions.hh" 9 | 10 | namespace efc { 11 | 12 | const int ESocketOptions::_SO_REUSEADDR = 0x0004; 13 | const int ESocketOptions::_SO_KEEPALIVE = 0x0008; 14 | const int ESocketOptions::_SO_BROADCAST = 0x0020; 15 | const int ESocketOptions::_SO_LINGER = 0x0080; 16 | const int ESocketOptions::_SO_TIMEOUT = 0x1006; 17 | const int ESocketOptions::_SO_SNDBUF = 0x1001; 18 | const int ESocketOptions::_SO_RCVBUF = 0x1002; 19 | const int ESocketOptions::_SO_OOBINLINE = 0x1003; 20 | 21 | const int ESocketOptions::_TCP_NODELAY = 0x0001; 22 | 23 | const int ESocketOptions::_IP_MULTICAST_IF = 0x10; 24 | const int ESocketOptions::_IP_MULTICAST_IF2 = 0x1f; 25 | const int ESocketOptions::_IP_MULTICAST_LOOP = 0x12; 26 | const int ESocketOptions::_IP_TOS = 0x3; 27 | 28 | const int ESocketOptions::_IP_ADD_MEMBERSHIP = 0x0c; 29 | const int ESocketOptions::_IP_DROP_MEMBERSHIP = 0x0d; 30 | const int ESocketOptions::_IP_MULTICAST_TTL = 0x0a; 31 | 32 | } /* namespace efc */ 33 | -------------------------------------------------------------------------------- /efc/src/ESpinLock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ESpinLock.cpp 3 | * 4 | * Created on: 2013-3-18 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ESpinLock.hh" 9 | 10 | namespace efc { 11 | 12 | ESpinLock::ESpinLock() { 13 | m_Spin = eso_thread_spin_create(); 14 | } 15 | 16 | ESpinLock::~ESpinLock() { 17 | eso_thread_spin_destroy(&m_Spin); 18 | } 19 | 20 | void ESpinLock::lock() 21 | { 22 | eso_thread_spin_lock(m_Spin); 23 | } 24 | 25 | void ESpinLock::lockInterruptibly() { 26 | throw EUnsupportedOperationException(__FILE__, __LINE__); 27 | } 28 | 29 | boolean ESpinLock::tryLock() 30 | { 31 | es_status_t rv = eso_thread_spin_trylock(m_Spin); 32 | return (rv == ES_SUCCESS) ? true : false; 33 | } 34 | 35 | boolean ESpinLock::tryLock(llong time, ETimeUnit* unit) { 36 | es_status_t rv = eso_thread_spin_timedlock(m_Spin, unit->toMillis(time)); 37 | return (rv == ES_SUCCESS) ? true : false; 38 | } 39 | 40 | void ESpinLock::unlock() 41 | { 42 | eso_thread_spin_unlock(m_Spin); 43 | } 44 | 45 | } /* namespace efc */ 46 | -------------------------------------------------------------------------------- /efc/src/EThreadLocalStorage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EThreadLocalStorage.cpp 3 | * 4 | * Created on: 2014-1-27 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EThreadLocalStorage.hh" 9 | #include "EException.hh" 10 | 11 | namespace efc { 12 | 13 | #ifdef WIN32 14 | 15 | EThreadLocalStorage::EThreadLocalStorage() { 16 | thread_key = TlsAlloc(); 17 | } 18 | 19 | EThreadLocalStorage::~EThreadLocalStorage() { 20 | TlsFree(thread_key); 21 | } 22 | 23 | void* EThreadLocalStorage::get() { 24 | return TlsGetValue(thread_key); 25 | } 26 | 27 | void EThreadLocalStorage::set(void* value) { 28 | TlsSetValue(thread_key, value); 29 | } 30 | 31 | #elif defined(__solaris__) 32 | 33 | EThreadLocalStorage::EThreadLocalStorage() { 34 | thread_key_t key; 35 | if (thr_keycreate(&key, NULL)) { 36 | throw EException(__FILE__, __LINE__, "thr_keycreate error"); 37 | } 38 | thread_key = (long)key; 39 | } 40 | 41 | EThreadLocalStorage::~EThreadLocalStorage() { 42 | /* no-op */ 43 | } 44 | 45 | void* EThreadLocalStorage::get() { 46 | void* r = NULL; 47 | thr_getspecific((thread_key_t)thread_key, &r); 48 | return r; 49 | } 50 | 51 | void EThreadLocalStorage::set(void* value) { 52 | thr_setspecific((thread_key_t)thread_key, value) ; 53 | } 54 | 55 | #else //linux||bsd 56 | 57 | EThreadLocalStorage::EThreadLocalStorage() { 58 | pthread_key_t key; 59 | if (pthread_key_create(&key, NULL)) { 60 | throw EException(__FILE__, __LINE__, "pthread_key_create error"); 61 | } 62 | thread_key = (long)key; 63 | } 64 | 65 | EThreadLocalStorage::~EThreadLocalStorage() { 66 | pthread_key_delete((pthread_key_t)thread_key); 67 | } 68 | 69 | void* EThreadLocalStorage::get() { 70 | return pthread_getspecific((pthread_key_t)thread_key); 71 | } 72 | 73 | void EThreadLocalStorage::set(void* value) { 74 | pthread_setspecific((pthread_key_t)thread_key, value) ; 75 | } 76 | 77 | #endif //!WIN32 78 | 79 | } /* namespace efc */ 80 | -------------------------------------------------------------------------------- /efc/src/ETimerTask.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ETimerTask.cpp 3 | * 4 | * Created on: 2015-2-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "ETimerTask.hh" 9 | #include "ESynchronizeable.hh" 10 | 11 | namespace efc { 12 | 13 | ETimerTask::~ETimerTask() { 14 | 15 | } 16 | 17 | boolean ETimerTask::cancel() { 18 | SYNCBLOCK(&lock) { 19 | boolean result = (state == SCHEDULED); 20 | state = CANCELLED; 21 | return result; 22 | }} 23 | } 24 | 25 | llong ETimerTask::scheduledExecutionTime() { 26 | SYNCBLOCK(&lock) { 27 | return (period < 0 ? nextExecutionTime + period 28 | : nextExecutionTime - period); 29 | }} 30 | } 31 | 32 | ETimerTask::ETimerTask() : state(VIRGIN), nextExecutionTime(0), period(0) { 33 | } 34 | 35 | } /* namespace efc */ 36 | -------------------------------------------------------------------------------- /efc/src/EURLDecoder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EURLDecoder.cpp 3 | * 4 | * Created on: 2013-3-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EURLDecoder.hh" 9 | 10 | namespace efc { 11 | 12 | EString EURLDecoder::decode(const char* s) 13 | { 14 | EString decodeStr; 15 | 16 | if (!s || !*s) { 17 | return decodeStr; 18 | } 19 | 20 | es_string_t* decode_str = NULL; 21 | eso_murldecode(&decode_str, s); 22 | decodeStr.concat(decode_str); 23 | eso_mfree(decode_str); 24 | 25 | return decodeStr; 26 | } 27 | 28 | } /* namespace efc */ 29 | -------------------------------------------------------------------------------- /efc/src/EURLEncoder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EURLEncoder.cpp 3 | * 4 | * Created on: 2013-3-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EURLEncoder.hh" 9 | 10 | namespace efc { 11 | 12 | EString EURLEncoder::encode(const char* s, int len) 13 | { 14 | EString encodeStr; 15 | 16 | if (!s || !*s) { 17 | return encodeStr; 18 | } 19 | 20 | if (len <= 0) { 21 | len = eso_strlen(s); 22 | } 23 | 24 | es_string_t* encode_str = NULL; 25 | eso_murlencode(&encode_str, s, len); 26 | encodeStr.concat(encode_str); 27 | eso_mfree(encode_str); 28 | 29 | return encodeStr; 30 | } 31 | 32 | } /* namespace efc */ 33 | -------------------------------------------------------------------------------- /efc/src/EURLString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EURLString.hhcpp 3 | * 4 | * Created on: 2013-3-16 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "EURLString.hh" 9 | 10 | namespace efc { 11 | 12 | EURLString::EURLString(const char* s) : EString(s) 13 | { 14 | } 15 | 16 | EURLString& EURLString::enccat(const char* s, int len) 17 | { 18 | es_string_t *to = NULL; 19 | to = eso_murlencode(&to, s, len); 20 | concat(to); 21 | eso_mfree(to); 22 | return (*this); 23 | } 24 | 25 | EURLString& EURLString::deccat(const char* s) 26 | { 27 | es_string_t *to = NULL; 28 | to = eso_murldecode(&to, s); 29 | concat(to); 30 | eso_mfree(to); 31 | return (*this); 32 | } 33 | 34 | EURLString& EURLString::concat(const char* s, int len) 35 | { 36 | EString::concat(s, len); 37 | return (*this); 38 | } 39 | 40 | EURLString& EURLString::fmtcat(const char* fmt, ...) 41 | { 42 | va_list args; 43 | EString estr; 44 | 45 | va_start(args, fmt); 46 | estr.vformat(fmt, args); 47 | va_end(args); 48 | 49 | return concat(estr.c_str()); 50 | } 51 | 52 | } /* namespace efc */ 53 | -------------------------------------------------------------------------------- /efc/src/concurrent/EAtomicBoolean.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EAtomicBoolean.cpp 3 | * 4 | * Created on: 2013-11-12 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "../../inc/concurrent/EAtomicBoolean.hh" 9 | #include "../../inc/EBoolean.hh" 10 | #include "../../inc/concurrent/EUnsafe.hh" 11 | 12 | namespace efc { 13 | 14 | EAtomicBoolean::EAtomicBoolean(boolean initialValue) { 15 | value = initialValue ? 1 : 0; 16 | } 17 | 18 | EAtomicBoolean::EAtomicBoolean() : value(0) { 19 | } 20 | 21 | boolean EAtomicBoolean::get() { 22 | return value != 0; 23 | } 24 | 25 | boolean EAtomicBoolean::compareAndSet(boolean expect, boolean update) { 26 | int e = expect ? 1 : 0; 27 | int u = update ? 1 : 0; 28 | // return EUnsafe::compareAndSwapInt(&value, e, u); 29 | return eso_atomic_compare_and_swap32(&value, e, u); 30 | } 31 | 32 | boolean EAtomicBoolean::weakCompareAndSet(boolean expect, boolean update) { 33 | int e = expect ? 1 : 0; 34 | int u = update ? 1 : 0; 35 | // return EUnsafe::compareAndSwapInt(&value, e, u); 36 | return eso_atomic_compare_and_swap32(&value, e, u); 37 | } 38 | 39 | void EAtomicBoolean::set(boolean newValue) { 40 | value = newValue ? 1 : 0; 41 | } 42 | 43 | void EAtomicBoolean::lazySet(boolean newValue) { 44 | int v = newValue ? 1 : 0; 45 | EUnsafe::putOrdered(&value, v); 46 | } 47 | 48 | boolean EAtomicBoolean::getAndSet(boolean newValue) { 49 | int n = newValue ? 1 : 0; 50 | return eso_atomic_test_and_set32(&value, n); 51 | 52 | // for (;;) { 53 | // boolean current = get(); 54 | // if (compareAndSet(current, newValue)) 55 | // return current; 56 | // } 57 | } 58 | 59 | EString EAtomicBoolean::toString() { 60 | return EBoolean::toString(get()).c_str(); 61 | } 62 | 63 | } /* namespace efc */ 64 | -------------------------------------------------------------------------------- /efc/src/concurrent/EAtomicCounter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * EAtomicCounter.cpp 3 | * 4 | * Created on: 2014-04-08 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | // @see: poco/1.4/Foundation/src/AtomicCounter.cpp 9 | 10 | #include "../../inc/concurrent/EAtomicCounter.hh" 11 | 12 | namespace efc { 13 | 14 | EAtomicCounter::EAtomicCounter(): 15 | _counter(0) 16 | { 17 | } 18 | 19 | EAtomicCounter::EAtomicCounter(int initialValue): 20 | _counter(initialValue) 21 | { 22 | } 23 | 24 | EAtomicCounter::EAtomicCounter(const EAtomicCounter& counter): 25 | _counter(counter.value()) 26 | { 27 | } 28 | 29 | EAtomicCounter::~EAtomicCounter() 30 | { 31 | } 32 | 33 | EAtomicCounter& EAtomicCounter::operator = (const EAtomicCounter& counter) 34 | { 35 | eso_atomic_test_and_set32(&_counter, counter.value()); 36 | return *this; 37 | } 38 | 39 | EAtomicCounter& EAtomicCounter::operator = (int value) 40 | { 41 | eso_atomic_test_and_set32(&_counter, value); 42 | return *this; 43 | } 44 | 45 | } // namespace efc 46 | -------------------------------------------------------------------------------- /efc/src/concurrent/ECountDownLatch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ECountDownLatch.cpp 3 | * 4 | * Created on: 2015-2-6 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "../../inc/concurrent/ECountDownLatch.hh" 9 | #include "../../inc/concurrent/EAbstractQueuedSynchronizer.hh" 10 | 11 | namespace efc { 12 | 13 | namespace cdl { 14 | /** 15 | * Synchronization control For CountDownLatch. 16 | * Uses AQS state to represent count. 17 | */ 18 | class Sync: public EAbstractQueuedSynchronizer { 19 | public: 20 | Sync(int count) { 21 | setState(count); 22 | } 23 | 24 | int getCount() { 25 | return getState(); 26 | } 27 | 28 | int tryAcquireShared(int acquires) { 29 | return (getState() == 0) ? 1 : -1; 30 | } 31 | 32 | boolean tryReleaseShared(int releases) { 33 | // Decrement count; signal when transition to zero 34 | for (;;) { 35 | int c = getState(); 36 | if (c == 0) 37 | return false; 38 | int nextc = c-1; 39 | if (compareAndSetState(c, nextc)) 40 | return nextc == 0; 41 | } 42 | } 43 | }; 44 | } /* namespace cdl */ 45 | 46 | 47 | ECountDownLatch::~ECountDownLatch() { 48 | delete sync; 49 | } 50 | 51 | ECountDownLatch::ECountDownLatch(int count) { 52 | if (count < 0) throw EIllegalArgumentException(__FILE__, __LINE__, "count < 0"); 53 | this->sync = new cdl::Sync(count); 54 | } 55 | 56 | void ECountDownLatch::await() { 57 | sync->acquireSharedInterruptibly(1); 58 | } 59 | 60 | boolean ECountDownLatch::await(llong timeout, ETimeUnit* unit) { 61 | return sync->tryAcquireSharedNanos(1, unit->toNanos(timeout)); 62 | } 63 | 64 | void ECountDownLatch::countDown() { 65 | sync->releaseShared(1); 66 | } 67 | 68 | long ECountDownLatch::getCount() { 69 | return sync->getCount(); 70 | } 71 | 72 | EString ECountDownLatch::toString() { 73 | return EString::formatOf("ECountDownLatch[Count = %ld]", sync->getCount()); 74 | } 75 | 76 | } /* namespace efc */ 77 | -------------------------------------------------------------------------------- /efc/src/concurrent/ELockSupport.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ELockSupport.cpp 3 | * 4 | * Created on: 2014-9-25 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #include "../../inc/concurrent/ELockSupport.hh" 9 | #include "../../inc/concurrent/EUnsafe.hh" 10 | 11 | namespace efc { 12 | 13 | void ELockSupport::unpark(EThread* thread) { 14 | if (thread != null) 15 | EUnsafe::unpark(thread); 16 | } 17 | 18 | void ELockSupport::park() { 19 | EUnsafe::park(false, 0L); 20 | } 21 | 22 | void ELockSupport::parkNanos(llong nanos) { 23 | if (nanos > 0) 24 | EUnsafe::park(false, nanos); 25 | } 26 | 27 | void ELockSupport::parkUntil(llong deadline) { 28 | EUnsafe::park(true, deadline); 29 | } 30 | 31 | } /* namespace efc */ 32 | -------------------------------------------------------------------------------- /efc/utils/inc/EDomainServerSocket.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * EDomainServerSocket.hh 3 | * 4 | * Created on: 2017-9-27 5 | * Author: cxxjava@163.com 6 | */ 7 | 8 | #ifndef EDOMAINSERVERSOCKET_HH_ 9 | #define EDOMAINSERVERSOCKET_HH_ 10 | 11 | #include "Efc.hh" 12 | 13 | namespace efc { 14 | namespace utils { 15 | 16 | /** 17 | * 18 | */ 19 | 20 | #ifdef WIN32 21 | 22 | class EDomainServerSocket: public efc::EServerSocket { 23 | public: 24 | virtual void bind(const char* pathname) THROWS(EIOException) { 25 | throw EUnsupportedOperationException(__FILE__, __LINE__); 26 | } 27 | using EServerSocket::bind; 28 | }; 29 | 30 | #else //! 31 | 32 | class EDomainServerSocket: public efc::EServerSocket { 33 | public: 34 | virtual ~EDomainServerSocket(); 35 | 36 | EDomainServerSocket(); 37 | 38 | //TODO: 39 | EDomainServerSocket(const EDomainServerSocket& that); 40 | EDomainServerSocket& operator= (const EDomainServerSocket& that); 41 | 42 | virtual void bind(const char* pathname) THROWS(EIOException); 43 | virtual void bind(const char* pathname, int /* ignore */, int backlog=50) THROWS(EIOException); 44 | 45 | virtual ESocket* accept() THROWS(EIOException); 46 | 47 | private: 48 | virtual void bind(EInetSocketAddress *endpoint, int backlog=50) THROWS(EIOException) { 49 | throw EUnsupportedOperationException(__FILE__, __LINE__); 50 | } 51 | virtual void bind(int port, int backlog=50) THROWS(EIOException) { 52 | throw EUnsupportedOperationException(__FILE__, __LINE__); 53 | } 54 | }; 55 | 56 | #endif //!WIN32 57 | 58 | } /* namespace utils */ 59 | } /* namespace efc */ 60 | #endif /* EDOMAINSERVERSOCKET_HH_ */ 61 | -------------------------------------------------------------------------------- /img/test_concurrentHashmap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/img/test_concurrentHashmap.gif -------------------------------------------------------------------------------- /lib/cl_version_LE.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | FOR /L %%G IN (10,1,%1) DO ( 4 | cl /? 2>&1 | findstr /C:" %%G." > nul && goto %%G 5 | ) 6 | EXIT /B 0 7 | :8 8 | EXIT /B 8 9 | :9 10 | EXIT /B 9 11 | :10 12 | EXIT /B 10 13 | :11 14 | EXIT /B 11 15 | :12 16 | EXIT /B 12 17 | :13 18 | EXIT /B 13 19 | :14 20 | EXIT /B 14 21 | :15 22 | EXIT /B 15 23 | :16 24 | EXIT /B 16 25 | :17 26 | EXIT /B 17 27 | :18 28 | EXIT /B 18 29 | :19 30 | EXIT /B 19 31 | :20 32 | EXIT /B 20 33 | :21 34 | EXIT /B 21 35 | :22 36 | EXIT /B 22 37 | :23 38 | EXIT /B 23 39 | :24 40 | EXIT /B 24 41 | -------------------------------------------------------------------------------- /lib/linux/libefc32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/linux/libefc32.a -------------------------------------------------------------------------------- /lib/linux/libefc64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/linux/libefc64.a -------------------------------------------------------------------------------- /lib/linux/libeso32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/linux/libeso32.a -------------------------------------------------------------------------------- /lib/linux/libeso64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/linux/libeso64.a -------------------------------------------------------------------------------- /lib/osx/libefc64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/osx/libefc64.a -------------------------------------------------------------------------------- /lib/osx/libeso64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/osx/libeso64.a -------------------------------------------------------------------------------- /lib/win/efc16.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/win/efc16.lib -------------------------------------------------------------------------------- /lib/win/efc19.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/win/efc19.lib -------------------------------------------------------------------------------- /lib/win/eso16.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/win/eso16.lib -------------------------------------------------------------------------------- /lib/win/eso19.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxxjava/CxxJDK/ebd7a47ca553c1145807970855bb0fed952545c2/lib/win/eso19.lib -------------------------------------------------------------------------------- /test/main.cpp: -------------------------------------------------------------------------------- 1 | #include "es_main.h" 2 | 3 | int main(int argc, const char **argv) { 4 | 5 | // MAIN_CALL(testlibc); 6 | 7 | MAIN_CALL(testefc); 8 | 9 | // MAIN_CALL(testbson); 10 | 11 | // MAIN_CALL(testnio); 12 | 13 | // MAIN_CALL(testc11); 14 | 15 | // MAIN_CALL(testssl); 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /test/sample.ini: -------------------------------------------------------------------------------- 1 | [COMMON] 2 | #general configuration 3 | host = 192.168.1.199 4 | port = 8080 5 | name = $(HOSTNAME) #$->get the value from getenv 6 | 7 | [KAFKA] 8 | #redis configuration 9 | kafka_broker_list = 127.0.0.1:9092 10 | --------------------------------------------------------------------------------