[-]
[+]
|
Changed |
liblfcbase.changes
|
|
[-]
[+]
|
Changed |
liblfcbase.spec
^
|
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/Makefile.in
^
|
@@ -243,8 +243,6 @@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MINGW32DEF = @MINGW32DEF@
-MINGW32HEADER = @MINGW32HEADER@
-MINGW32SOURCE = @MINGW32SOURCE@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
|
[-]
[+]
|
Added |
lfcbase-1.5.10.tar.bz2/config.h.in~
^
|
@@ -0,0 +1,213 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+ systems. This function is required for `alloca.c' support on those systems.
+ */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#undef C_ALLOCA
+
+/* Define to 1 if you have the `alarm' function. */
+#undef HAVE_ALARM
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+ */
+#undef HAVE_ALLOCA_H
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#undef HAVE_ARPA_INET_H
+
+/* Define to 1 if you have the `bzero' function. */
+#undef HAVE_BZERO
+
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the `fork' function. */
+#undef HAVE_FORK
+
+/* Define to 1 if you have the `ftruncate' function. */
+#undef HAVE_FTRUNCATE
+
+/* Define to 1 if you have the `gethostname' function. */
+#undef HAVE_GETHOSTNAME
+
+/* Define to 1 if you have the `gethrtime' function. */
+#undef HAVE_GETHRTIME
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `curses' library (-lcurses). */
+#undef HAVE_LIBCURSES
+
+/* Define to 1 if you have the `nsl' library (-lnsl). */
+#undef HAVE_LIBNSL
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#undef HAVE_LIBPTHREAD
+
+/* Define to 1 if you have the `rt' library (-lrt). */
+#undef HAVE_LIBRT
+
+/* Define to 1 if you have the `socket' library (-lsocket). */
+#undef HAVE_LIBSOCKET
+
+/* Define to 1 if you have the `ws2_32' library (-lws2_32). */
+#undef HAVE_LIBWS2_32
+
+/* Define to 1 if you have the `mach_timebase_info' function. */
+#undef HAVE_MACH_TIMEBASE_INFO
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+ to 0 otherwise. */
+#undef HAVE_MALLOC
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if your system has a GNU libc compatible `realloc' function,
+ and to 0 otherwise. */
+#undef HAVE_REALLOC
+
+/* Define to 1 if you have the `select' function. */
+#undef HAVE_SELECT
+
+/* Define to 1 if you have the `socket' function. */
+#undef HAVE_SOCKET
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strerror' function. */
+#undef HAVE_STRERROR
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define if your system's sys/sem.h file defines struct semun */
+#undef HAVE_STRUCT_SEMUN
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the `tzset' function. */
+#undef HAVE_TZSET
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `vfork' function. */
+#undef HAVE_VFORK
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#undef HAVE_VFORK_H
+
+/* Define to 1 if `fork' works. */
+#undef HAVE_WORKING_FORK
+
+/* Define to 1 if `vfork' works. */
+#undef HAVE_WORKING_VFORK
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at runtime.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to rpl_malloc if the replacement function should be used. */
+#undef malloc
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef pid_t
+
+/* Define to rpl_realloc if the replacement function should be used. */
+#undef realloc
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define as `fork' if `vfork' does not work. */
+#undef vfork
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/configure
^
|
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for lfcbase 1.5.9.
+# Generated by GNU Autoconf 2.69 for lfcbase 1.5.10.
#
# Report bugs to <lemke@lemke-it.com>.
#
@@ -590,8 +590,8 @@
# Identity of this package.
PACKAGE_NAME='lfcbase'
PACKAGE_TARNAME='lfcbase'
-PACKAGE_VERSION='1.5.9'
-PACKAGE_STRING='lfcbase 1.5.9'
+PACKAGE_VERSION='1.5.10'
+PACKAGE_STRING='lfcbase 1.5.10'
PACKAGE_BUGREPORT='lemke@lemke-it.com'
PACKAGE_URL=''
@@ -661,9 +661,9 @@
EGREP
GREP
CPP
+HAS_MINGW32_FALSE
+HAS_MINGW32_TRUE
MINGW32DEF
-MINGW32HEADER
-MINGW32SOURCE
host_os
host_vendor
host_cpu
@@ -1328,7 +1328,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures lfcbase 1.5.9 to adapt to many kinds of systems.
+\`configure' configures lfcbase 1.5.10 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1398,7 +1398,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of lfcbase 1.5.9:";;
+ short | recursive ) echo "Configuration of lfcbase 1.5.10:";;
esac
cat <<\_ACEOF
@@ -1506,7 +1506,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-lfcbase configure 1.5.9
+lfcbase configure 1.5.10
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2050,7 +2050,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by lfcbase $as_me 1.5.9, which was
+It was created by lfcbase $as_me 1.5.10, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2916,7 +2916,7 @@
# Define the identity of the package.
PACKAGE='lfcbase'
- VERSION='1.5.9'
+ VERSION='1.5.10'
cat >>confdefs.h <<_ACEOF
@@ -4698,14 +4698,19 @@
if [ "$MINGW32" = "yes" ]
then
- MINGW32SOURCE="regex.c regex.h strptime.c"
-
- MINGW32HEADER="regex.h"
-
MINGW32DEF="-DHAVE_MINGW32"
fi
+ if test "$MINGW32" = "yes"; then
+ HAS_MINGW32_TRUE=
+ HAS_MINGW32_FALSE='#'
+else
+ HAS_MINGW32_TRUE='#'
+ HAS_MINGW32_FALSE=
+fi
+
+
# Checks for header files.
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
@@ -16832,6 +16837,10 @@
as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${HAS_MINGW32_TRUE}" && test -z "${HAS_MINGW32_FALSE}"; then
+ as_fn_error $? "conditional \"HAS_MINGW32\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
@@ -17229,7 +17238,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by lfcbase $as_me 1.5.9, which was
+This file was extended by lfcbase $as_me 1.5.10, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -17295,7 +17304,7 @@
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-lfcbase config.status 1.5.9
+lfcbase config.status 1.5.10
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/configure.ac
^
|
@@ -16,7 +16,7 @@
])# AC_MINGW32
AC_PREREQ([2.69])
-AC_INIT([lfcbase], [1.5.9], [lemke@lemke-it.com])
+AC_INIT([lfcbase], [1.5.10], [lemke@lemke-it.com])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
@@ -43,11 +43,11 @@
if [[ "$MINGW32" = "yes" ]]
then
- AC_SUBST(MINGW32SOURCE, "regex.c regex.h strptime.c")
- AC_SUBST(MINGW32HEADER, "regex.h")
AC_SUBST(MINGW32DEF, "-DHAVE_MINGW32")
fi
+AM_CONDITIONAL([HAS_MINGW32], [test "$MINGW32" = "yes"])
+
# Checks for header files.
AC_FUNC_ALLOCA
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stddef.h stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h])
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/AVLTreeTest.cc
^
|
@@ -64,7 +64,7 @@
cout << "ok" << endl;
- srandom(time(0));
+ srand(42);
AVLTreeT<int> bTree;
@@ -72,7 +72,7 @@
unsigned long count = 1000;
while (count)
{
- int elem = random() % (100 * count);
+ int elem = rand() % (100 * count);
bTree.Insert(elem);
count--;
}
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/ListTest.cc
^
|
@@ -63,8 +63,6 @@
cout << "ok" << endl;
cout << " Member methods...";
- srandom(time(0));
-
unsigned long count = 1000;
ListT<int> l1;
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/Makefile.in
^
|
@@ -345,8 +345,6 @@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MINGW32DEF = @MINGW32DEF@
-MINGW32HEADER = @MINGW32HEADER@
-MINGW32SOURCE = @MINGW32SOURCE@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/NetClient.cc
^
|
@@ -20,12 +20,8 @@
try {
- int msgCluster=Chain(argv[1]).asInteger();
- int numCluster=Chain(argv[2]).asInteger();
-
-
- cout << numCluster << " " << msgCluster << endl;
-
+ int msgsize=Chain(argv[1]).asInteger();
+
Net n(1024, 10);
NetHandler* pN;
@@ -35,22 +31,12 @@
pN->setMsg(data, data.length());
- for ( int i=0; i < numCluster; i++)
- {
- Timer t;
- t.start();
-
- cout << "Send msg cluster .." << endl;
- for ( int j=0; j<msgCluster; j++)
- {
- cout << "Write msg .." << endl;
- pN->writeMsg();
- cout << "Read msg .." << endl;
- pN->readMsg();
- }
- t.stop();
- cout << t << endl;
- }
+ cout << "Write msg .." << endl;
+ pN->writeMsg();
+ cout << "Read msg .." << endl;
+ pN->readMsg();
+ cout << "Msg read : " << pN->getMsg() << endl;
+
}
catch (Exception e)
{
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/NetServer.cc
^
|
@@ -35,8 +35,11 @@
cout << "Next request ..." << endl;
if ( pNetHandle->getMsgSize() > 0 )
{
+ cout << "Got Msg = " << pNetHandle->getMsg() << endl;
+
Chain answer = Chain("this is the answer to XXXX"); // + Chain(pNetHandle->getId());
pNetHandle->setMsg((char*)answer, answer.length());
+ cout << "Sending answer ..." << endl;
pNetHandle->writeMsg();
}
}
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/SetTest.cc
^
|
@@ -69,7 +69,7 @@
SetT<int> intSet;
SetT<Chain> chainSet;
- srandom(time(0));
+ srand(42);
unsigned long count;
@@ -81,8 +81,8 @@
count = 1000;
while ( count > 0 )
{
- intSet.Insert( random() % 100 );
- chainSet.Insert( Chain(random() % 100 ) );
+ intSet.Insert( rand() % 100 );
+ chainSet.Insert( Chain(rand() % 100 ) );
count--;
}
@@ -90,16 +90,16 @@
while ( count > 0 )
{
- intSet.Remove( random() % 100 );
- chainSet.Remove( Chain(random() % 100 ) );
+ intSet.Remove( rand() % 100 );
+ chainSet.Remove( Chain(rand() % 100 ) );
count--;
}
while ( count > 0 )
{
- intSet.Find( random() % 100 );
- chainSet.Find( Chain(random() % 100 ) );
+ intSet.Find( rand() % 100 );
+ chainSet.Find( Chain(rand() % 100 ) );
count--;
}
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/StackTest.cc
^
|
@@ -43,9 +43,6 @@
StackT<Chain> myStack;
-
- srandom(time(0));
-
myStack.Push("Hello");
myStack.Push("fsdfdsfsd");
myStack.Push("KJJJJJJ");
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/ThreadTest.cc
^
|
@@ -11,7 +11,6 @@
#include <unistd.h>
#include <stdlib.h>
-#include <pthread.h>
#include "Exception.h"
#include "Thread.h"
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/TimerTest.cc
^
|
@@ -30,8 +30,12 @@
for ( j = 0 ; j < 3 ; j++ )
{
nt.start();
- sleep(1);
+#ifdef HAVE_MINGW32
+ Sleep(1);
+#else
+ sleep(1);
+#endif
nt.stop();
}
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/samples/TreeTest.cc
^
|
@@ -85,7 +85,7 @@
cout << "ok" << endl;
cout << " Member methods...";
- srandom(time(0));
+ srand(42);
@@ -103,7 +103,7 @@
while (count)
{
- int elem = random() % (100 * count);
+ int elem = rand() % (100 * count);
bTree.Insert(elem);
@@ -131,7 +131,7 @@
while (j)
{
- int elem = random() % count2;
+ int elem = rand() % count2;
baseTree.Insert(elem);
j--;
}
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/src/Crypt.h
^
|
@@ -1,5 +1,5 @@
#ifndef _CRYPT_H_INCLUDED_
-#define _CRYPR_H_INCLUDED_
+#define _CRYPT_H_INCLUDED_
///////////////////////////////////////////////////////////////////////////////
//
// Crypt.h
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/src/Directory.cc
^
|
@@ -78,9 +78,13 @@
void Directory::create()
{
+#ifdef HAVE_MINGW32
+ int ret = ::mkdir(_dir);
+#else
mode_t m = 0755;
int ret = ::mkdir(_dir, m);
-
+#endif
+
if ( ret == -1 )
{
Chain msg = Chain("Cannot create directory ") + _dir + Chain(" : ") + Chain(strerror(errno));
|
[-]
[+]
|
Added |
lfcbase-1.5.10.tar.bz2/src/Directory.cc.save
^
|
@@ -0,0 +1,142 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Directory.cc
+// ------------
+// Directory class implementation
+//
+// Design and Implementation by Bjoern Lemke
+//
+// (C)opyright 2000-2013 Bjoern Lemke
+//
+// Design and Implementation by Bjoern Lemke
+//
+// IMPLEMENTATION MODULE
+//
+// Class: Directory
+//
+// Description: All base operations on files
+//
+// Status: IMPLEMENTED
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _REENTRANT
+#define _REENTRANT /* basic 3-lines for threads */
+#endif
+
+
+// BASE INCLUDES
+#include "Exception.h"
+#include "Chain.h"
+#include "Directory.h"
+#include "Tokenizer.h"
+
+// SYSTEM INCLUDES
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <errno.h>
+
+Directory::Directory()
+{
+}
+
+
+Directory::Directory(const Chain& str)
+{
+ _dir = str;
+}
+
+Directory::~Directory()
+{
+
+}
+
+bool Directory::exists()
+{
+ struct stat sb;
+ int ret = ::stat(_dir, &sb);
+
+ if ( ret == -1 )
+ {
+ if ( errno == ENOENT )
+ return false;
+ else
+ {
+ Chain msg = Chain("Cannot stat directory ") + _dir + Chain(" : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+
+ }
+ }
+ return true;
+}
+
+void Directory::create()
+{
+
+ mode_t m = 0755;
+ int ret = ::mkdir(_dir, m);
+
+ if ( ret == -1 )
+ {
+ Chain msg = Chain("Cannot create directory ") + _dir + Chain(" : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+
+ }
+ return;
+}
+
+ListT<Chain> Directory::list() const
+{
+ ListT<Chain> dirList;
+
+ DIR *dp;
+ struct dirent *ep;
+ dp = opendir (_dir);
+
+ if (dp != NULL)
+ {
+ while ( ( ep = readdir (dp) ) != NULL )
+ {
+ dirList.Insert( Chain(ep->d_name));
+ }
+ closedir (dp);
+ }
+ else
+ {
+ Chain msg = Chain("Cannot list directory ") + _dir + Chain(" : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ return dirList;
+}
+
+void Directory::setCurrent()
+{
+ char buf[MAXPATHLEN];
+
+ if ( ::getcwd(buf, MAXPATHLEN) == NULL )
+ {
+ Chain msg = "Cannot get working directory";
+ throw Exception(EXLOC, msg);
+ }
+
+ _dir = Chain(buf);
+}
+
+const Chain& Directory::getName() const
+{
+ return _dir;
+}
+
+
+
+
+
+
+
+
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/src/Makefile.am
^
|
@@ -1,6 +1,43 @@
AM_CPPFLAGS = -fPIC -O3 ${MINGW32DEF}
lib_LTLIBRARIES = liblfcbase.la
liblfcbase_la_LDFLAGS = -version-info 1:0:0
+if HAS_MINGW32
+liblfcbase_la_SOURCES = AESCrypt.cc AESCrypt.h \
+ Base64Coder.cc Base64Code.h \
+ BigDecimal.cc BigDecimal.h \
+ BigInteger.cc BigInteger.h \
+ Bitmap.cc Bitmap.h \
+ Chain.cc Chain.h \
+ CommandExecuter.cc CommandExecuter.h \
+ Crypt.cc Crypt.h \
+ Datetime.cc Datetime.h \
+ Directory.cc Directory.h \
+ File.cc File.h \
+ GetLongOpt.cc GetLongOpt.h \
+ GetOpt.cc GetOpt.h \
+ Host.cc Host.h \
+ Logger.cc Logger.h \
+ Matcher.cc Matcher.h \
+ NanoTimer.cc Nanotimer.h \
+ Net.cc Net.h \
+ NetHandler.cc NetHandler.h \
+ Process.cc Process.h \
+ Semaphore.cc Semaphore.h \
+ SharedMemory.cc SharedMemory.h \
+ SigHandler.cc SigHandler.h \
+ Sleeper.cc Sleeper.h \
+ Thread.cc Thread.h \
+ ThreadLock.cc ThreadLock.h \
+ Timer.cc Timer.h \
+ Tokenizer.cc Tokenizer.h \
+ Version.cc \
+ base64.c base64.h \
+ AVLTreeT.h \
+ ListT.h \
+ SetT.h \
+ StackT.h \
+ TreeT.h regex.c regex.h strptime.c
+else
liblfcbase_la_SOURCES = AESCrypt.cc AESCrypt.h \
Base64Coder.cc Base64Code.h \
BigDecimal.cc BigDecimal.h \
@@ -36,6 +73,9 @@
SetT.h \
StackT.h \
TreeT.h
+endif
+
+
library_includedir=$(includedir)/lfcbase
-library_include_HEADERS = AESCrypt.h Base64Coder.h BigDecimal.h BigInteger.h Bitmap.h Chain.h CommandExecuter.h Crypt.h Datetime.h Directory.h File.h GetLongOpt.h GetOpt.h Host.h Logger.h Matcher.h NanoTimer.h Net.h NetHandler.h Process.h Semaphore.h SharedMemory.h SigHandler.h Sleeper.h Thread.h ThreadLock.h Timer.h Tokenizer.h AVLTreeT.h ListT.h SetT.h StackT.h TreeT.h Exception.h
\ No newline at end of file
+library_include_HEADERS = AESCrypt.h Base64Coder.h BigDecimal.h BigInteger.h Bitmap.h Chain.h CommandExecuter.h Crypt.h Datetime.h Directory.h File.h GetLongOpt.h GetOpt.h Host.h Logger.h Matcher.h NanoTimer.h Net.h NetHandler.h Process.h Semaphore.h SharedMemory.h SigHandler.h Sleeper.h Thread.h ThreadLock.h Timer.h Tokenizer.h AVLTreeT.h ListT.h SetT.h StackT.h TreeT.h Exception.h
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/src/Makefile.in
^
|
@@ -124,13 +124,40 @@
"$(DESTDIR)$(library_includedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
liblfcbase_la_LIBADD =
-am_liblfcbase_la_OBJECTS = AESCrypt.lo Base64Coder.lo BigDecimal.lo \
- BigInteger.lo Bitmap.lo Chain.lo CommandExecuter.lo Crypt.lo \
- Datetime.lo Directory.lo File.lo GetLongOpt.lo GetOpt.lo \
- Host.lo Logger.lo Matcher.lo NanoTimer.lo Net.lo NetHandler.lo \
- Process.lo Semaphore.lo SharedMemory.lo SigHandler.lo \
- Sleeper.lo Thread.lo ThreadLock.lo Timer.lo Tokenizer.lo \
- Version.lo base64.lo
+am__liblfcbase_la_SOURCES_DIST = AESCrypt.cc AESCrypt.h Base64Coder.cc \
+ Base64Code.h BigDecimal.cc BigDecimal.h BigInteger.cc \
+ BigInteger.h Bitmap.cc Bitmap.h Chain.cc Chain.h \
+ CommandExecuter.cc CommandExecuter.h Crypt.cc Crypt.h \
+ Datetime.cc Datetime.h Directory.cc Directory.h File.cc File.h \
+ GetLongOpt.cc GetLongOpt.h GetOpt.cc GetOpt.h Host.cc Host.h \
+ Logger.cc Logger.h Matcher.cc Matcher.h NanoTimer.cc \
+ Nanotimer.h Net.cc Net.h NetHandler.cc NetHandler.h Process.cc \
+ Process.h Semaphore.cc Semaphore.h SharedMemory.cc \
+ SharedMemory.h SigHandler.cc SigHandler.h Sleeper.cc Sleeper.h \
+ Thread.cc Thread.h ThreadLock.cc ThreadLock.h Timer.cc Timer.h \
+ Tokenizer.cc Tokenizer.h Version.cc base64.c base64.h \
+ AVLTreeT.h ListT.h SetT.h StackT.h TreeT.h regex.c regex.h \
+ strptime.c
+@HAS_MINGW32_FALSE@am_liblfcbase_la_OBJECTS = AESCrypt.lo \
+@HAS_MINGW32_FALSE@ Base64Coder.lo BigDecimal.lo BigInteger.lo \
+@HAS_MINGW32_FALSE@ Bitmap.lo Chain.lo CommandExecuter.lo \
+@HAS_MINGW32_FALSE@ Crypt.lo Datetime.lo Directory.lo File.lo \
+@HAS_MINGW32_FALSE@ GetLongOpt.lo GetOpt.lo Host.lo Logger.lo \
+@HAS_MINGW32_FALSE@ Matcher.lo NanoTimer.lo Net.lo \
+@HAS_MINGW32_FALSE@ NetHandler.lo Process.lo Semaphore.lo \
+@HAS_MINGW32_FALSE@ SharedMemory.lo SigHandler.lo Sleeper.lo \
+@HAS_MINGW32_FALSE@ Thread.lo ThreadLock.lo Timer.lo \
+@HAS_MINGW32_FALSE@ Tokenizer.lo Version.lo base64.lo
+@HAS_MINGW32_TRUE@am_liblfcbase_la_OBJECTS = AESCrypt.lo \
+@HAS_MINGW32_TRUE@ Base64Coder.lo BigDecimal.lo BigInteger.lo \
+@HAS_MINGW32_TRUE@ Bitmap.lo Chain.lo CommandExecuter.lo \
+@HAS_MINGW32_TRUE@ Crypt.lo Datetime.lo Directory.lo File.lo \
+@HAS_MINGW32_TRUE@ GetLongOpt.lo GetOpt.lo Host.lo Logger.lo \
+@HAS_MINGW32_TRUE@ Matcher.lo NanoTimer.lo Net.lo NetHandler.lo \
+@HAS_MINGW32_TRUE@ Process.lo Semaphore.lo SharedMemory.lo \
+@HAS_MINGW32_TRUE@ SigHandler.lo Sleeper.lo Thread.lo \
+@HAS_MINGW32_TRUE@ ThreadLock.lo Timer.lo Tokenizer.lo \
+@HAS_MINGW32_TRUE@ Version.lo base64.lo regex.lo strptime.lo
liblfcbase_la_OBJECTS = $(am_liblfcbase_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -193,7 +220,7 @@
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
SOURCES = $(liblfcbase_la_SOURCES)
-DIST_SOURCES = $(liblfcbase_la_SOURCES)
+DIST_SOURCES = $(am__liblfcbase_la_SOURCES_DIST)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -268,8 +295,6 @@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MINGW32DEF = @MINGW32DEF@
-MINGW32HEADER = @MINGW32HEADER@
-MINGW32SOURCE = @MINGW32SOURCE@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
@@ -347,41 +372,77 @@
AM_CPPFLAGS = -fPIC -O3 ${MINGW32DEF}
lib_LTLIBRARIES = liblfcbase.la
liblfcbase_la_LDFLAGS = -version-info 1:0:0
-liblfcbase_la_SOURCES = AESCrypt.cc AESCrypt.h \
- Base64Coder.cc Base64Code.h \
- BigDecimal.cc BigDecimal.h \
- BigInteger.cc BigInteger.h \
- Bitmap.cc Bitmap.h \
- Chain.cc Chain.h \
- CommandExecuter.cc CommandExecuter.h \
- Crypt.cc Crypt.h \
- Datetime.cc Datetime.h \
- Directory.cc Directory.h \
- File.cc File.h \
- GetLongOpt.cc GetLongOpt.h \
- GetOpt.cc GetOpt.h \
- Host.cc Host.h \
- Logger.cc Logger.h \
- Matcher.cc Matcher.h \
- NanoTimer.cc Nanotimer.h \
- Net.cc Net.h \
- NetHandler.cc NetHandler.h \
- Process.cc Process.h \
- Semaphore.cc Semaphore.h \
- SharedMemory.cc SharedMemory.h \
- SigHandler.cc SigHandler.h \
- Sleeper.cc Sleeper.h \
- Thread.cc Thread.h \
- ThreadLock.cc ThreadLock.h \
- Timer.cc Timer.h \
- Tokenizer.cc Tokenizer.h \
- Version.cc \
- base64.c base64.h \
- AVLTreeT.h \
- ListT.h \
- SetT.h \
- StackT.h \
- TreeT.h
+@HAS_MINGW32_FALSE@liblfcbase_la_SOURCES = AESCrypt.cc AESCrypt.h \
+@HAS_MINGW32_FALSE@ Base64Coder.cc Base64Code.h \
+@HAS_MINGW32_FALSE@ BigDecimal.cc BigDecimal.h \
+@HAS_MINGW32_FALSE@ BigInteger.cc BigInteger.h \
+@HAS_MINGW32_FALSE@ Bitmap.cc Bitmap.h \
+@HAS_MINGW32_FALSE@ Chain.cc Chain.h \
+@HAS_MINGW32_FALSE@ CommandExecuter.cc CommandExecuter.h \
+@HAS_MINGW32_FALSE@ Crypt.cc Crypt.h \
+@HAS_MINGW32_FALSE@ Datetime.cc Datetime.h \
+@HAS_MINGW32_FALSE@ Directory.cc Directory.h \
+@HAS_MINGW32_FALSE@ File.cc File.h \
+@HAS_MINGW32_FALSE@ GetLongOpt.cc GetLongOpt.h \
+@HAS_MINGW32_FALSE@ GetOpt.cc GetOpt.h \
+@HAS_MINGW32_FALSE@ Host.cc Host.h \
+@HAS_MINGW32_FALSE@ Logger.cc Logger.h \
+@HAS_MINGW32_FALSE@ Matcher.cc Matcher.h \
+@HAS_MINGW32_FALSE@ NanoTimer.cc Nanotimer.h \
+@HAS_MINGW32_FALSE@ Net.cc Net.h \
+@HAS_MINGW32_FALSE@ NetHandler.cc NetHandler.h \
+@HAS_MINGW32_FALSE@ Process.cc Process.h \
+@HAS_MINGW32_FALSE@ Semaphore.cc Semaphore.h \
+@HAS_MINGW32_FALSE@ SharedMemory.cc SharedMemory.h \
+@HAS_MINGW32_FALSE@ SigHandler.cc SigHandler.h \
+@HAS_MINGW32_FALSE@ Sleeper.cc Sleeper.h \
+@HAS_MINGW32_FALSE@ Thread.cc Thread.h \
+@HAS_MINGW32_FALSE@ ThreadLock.cc ThreadLock.h \
+@HAS_MINGW32_FALSE@ Timer.cc Timer.h \
+@HAS_MINGW32_FALSE@ Tokenizer.cc Tokenizer.h \
+@HAS_MINGW32_FALSE@ Version.cc \
+@HAS_MINGW32_FALSE@ base64.c base64.h \
+@HAS_MINGW32_FALSE@ AVLTreeT.h \
+@HAS_MINGW32_FALSE@ ListT.h \
+@HAS_MINGW32_FALSE@ SetT.h \
+@HAS_MINGW32_FALSE@ StackT.h \
+@HAS_MINGW32_FALSE@ TreeT.h
+
+@HAS_MINGW32_TRUE@liblfcbase_la_SOURCES = AESCrypt.cc AESCrypt.h \
+@HAS_MINGW32_TRUE@ Base64Coder.cc Base64Code.h \
+@HAS_MINGW32_TRUE@ BigDecimal.cc BigDecimal.h \
+@HAS_MINGW32_TRUE@ BigInteger.cc BigInteger.h \
+@HAS_MINGW32_TRUE@ Bitmap.cc Bitmap.h \
+@HAS_MINGW32_TRUE@ Chain.cc Chain.h \
+@HAS_MINGW32_TRUE@ CommandExecuter.cc CommandExecuter.h \
+@HAS_MINGW32_TRUE@ Crypt.cc Crypt.h \
+@HAS_MINGW32_TRUE@ Datetime.cc Datetime.h \
+@HAS_MINGW32_TRUE@ Directory.cc Directory.h \
+@HAS_MINGW32_TRUE@ File.cc File.h \
+@HAS_MINGW32_TRUE@ GetLongOpt.cc GetLongOpt.h \
+@HAS_MINGW32_TRUE@ GetOpt.cc GetOpt.h \
+@HAS_MINGW32_TRUE@ Host.cc Host.h \
+@HAS_MINGW32_TRUE@ Logger.cc Logger.h \
+@HAS_MINGW32_TRUE@ Matcher.cc Matcher.h \
+@HAS_MINGW32_TRUE@ NanoTimer.cc Nanotimer.h \
+@HAS_MINGW32_TRUE@ Net.cc Net.h \
+@HAS_MINGW32_TRUE@ NetHandler.cc NetHandler.h \
+@HAS_MINGW32_TRUE@ Process.cc Process.h \
+@HAS_MINGW32_TRUE@ Semaphore.cc Semaphore.h \
+@HAS_MINGW32_TRUE@ SharedMemory.cc SharedMemory.h \
+@HAS_MINGW32_TRUE@ SigHandler.cc SigHandler.h \
+@HAS_MINGW32_TRUE@ Sleeper.cc Sleeper.h \
+@HAS_MINGW32_TRUE@ Thread.cc Thread.h \
+@HAS_MINGW32_TRUE@ ThreadLock.cc ThreadLock.h \
+@HAS_MINGW32_TRUE@ Timer.cc Timer.h \
+@HAS_MINGW32_TRUE@ Tokenizer.cc Tokenizer.h \
+@HAS_MINGW32_TRUE@ Version.cc \
+@HAS_MINGW32_TRUE@ base64.c base64.h \
+@HAS_MINGW32_TRUE@ AVLTreeT.h \
+@HAS_MINGW32_TRUE@ ListT.h \
+@HAS_MINGW32_TRUE@ SetT.h \
+@HAS_MINGW32_TRUE@ StackT.h \
+@HAS_MINGW32_TRUE@ TreeT.h regex.c regex.h strptime.c
library_includedir = $(includedir)/lfcbase
library_include_HEADERS = AESCrypt.h Base64Coder.h BigDecimal.h BigInteger.h Bitmap.h Chain.h CommandExecuter.h Crypt.h Datetime.h Directory.h File.h GetLongOpt.h GetOpt.h Host.h Logger.h Matcher.h NanoTimer.h Net.h NetHandler.h Process.h Semaphore.h SharedMemory.h SigHandler.h Sleeper.h Thread.h ThreadLock.h Timer.h Tokenizer.h AVLTreeT.h ListT.h SetT.h StackT.h TreeT.h Exception.h
@@ -494,6 +555,8 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Tokenizer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Version.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strptime.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/src/Matcher.cc
^
|
@@ -45,7 +45,7 @@
if ( (char*)_expr != 0 )
{
_pRE = (regex_t*)malloc(sizeof(regex_t));
- if ( ::regcomp(_pRE, (char*)_expr, 0) != 0 )
+ if ( regcomp(_pRE, (char*)_expr, 0) != 0 )
{
throw Exception(EXLOC, "regcomp error");
}
@@ -63,7 +63,7 @@
if ( _isPrepared )
{
if ( (char*)str != 0 )
- if (::regexec(_pRE, (char*)str, 0, NULL, 0) == 0)
+ if (regexec(_pRE, (char*)str, 0, NULL, 0) == 0)
return true;
return false;
}
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/src/Net.cc
^
|
@@ -27,9 +27,8 @@
#include <fcntl.h>
#ifdef HAVE_MINGW32
-#define WINVER 0x0501
-#include <windows.h>
#include <winsock2.h>
+#include <windows.h>
#include <ws2tcpip.h>
#else
#include <sys/types.h>
@@ -69,42 +68,19 @@
}
}
-/* OLD style
-NetHandler* Net::connect(const Chain& hostname, int port)
+NetHandler* Net::connect(const Chain& hostname, const Chain& service)
{
- struct sockaddr_in sa;
- struct hostent *he;
-
- if ((he = gethostbyname((char*)hostname)) == NULL)
- {
- Chain msg = Chain("Cannot resolve hostname ") + hostname;
- throw Exception(EXLOC, msg);
- }
- int socket;
- if ( (socket = ::socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
- {
- Chain msg = Chain("socket system error : ") + Chain(strerror(errno));
- throw Exception(EXLOC, msg);
- }
-
- memcpy(&sa.sin_addr, he->h_addr_list[0], he->h_length);
- sa.sin_family = AF_INET;
- sa.sin_port = htons(port);
+#ifdef HAVE_MINGW32
- if (::connect(socket, (struct sockaddr *)&sa, sizeof(sa)) < 0 )
+ if ( service.isNum() == false )
{
- Chain msg = Chain("connect system error : ") + Chain(strerror(errno));
+ Chain msg = Chain("Service must be numeric value");
throw Exception(EXLOC, msg);
}
- NetHandler* pNH = new NetHandler(socket, _msgBufSize, _sizeBufLen);
-
- return pNH;
-}
-
-NetHandler* Net::connect(const Chain& hostname, int port, int timeout)
-{
+ /* mingw does not seem to support getaddrinfo and friends
+ in an appropriate way, so we have to use old style */
struct sockaddr_in sa;
struct hostent *he;
@@ -114,8 +90,8 @@
Chain msg = Chain("Cannot resolve hostname ") + hostname;
throw Exception(EXLOC, msg);
}
- int socket;
- if ( (socket = ::socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
+ int sock;
+ if ( (sock = ::socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
Chain msg = Chain("socket system error : ") + Chain(strerror(errno));
throw Exception(EXLOC, msg);
@@ -123,99 +99,15 @@
memcpy(&sa.sin_addr, he->h_addr_list[0], he->h_length);
sa.sin_family = AF_INET;
- sa.sin_port = htons(port);
-
- int res, opt;
-
- if ((opt = fcntl(socket, F_GETFL, NULL)) < 0)
- {
- Chain msg = Chain("fcntl system error : ") + Chain(strerror(errno));
- throw Exception(EXLOC, msg);
- }
-
- if (fcntl(socket, F_SETFL, opt | O_NONBLOCK) < 0)
- {
- Chain msg = Chain("fcntl system error : ") + Chain(strerror(errno));
- throw Exception(EXLOC, msg);
- }
-
- if (::connect(socket, (struct sockaddr *)&sa, sizeof(sa)) < 0 )
- {
- if (errno == EINPROGRESS)
- {
- fd_set wait_set;
-
- FD_ZERO(&wait_set);
- FD_SET(socket, &wait_set);
-
- struct timeval tv;
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
-
- if ( select(socket + 1, NULL, &wait_set, NULL, &tv) < 0 )
- {
- Chain msg = Chain("select system error : ") + Chain(strerror(errno));
- throw Exception(EXLOC, msg);
- }
- }
- else
- {
- Chain msg = Chain("connect system error : ") + Chain(strerror(errno));
- throw Exception(EXLOC, msg);
- }
- }
-
- if (fcntl(socket, F_SETFL, opt) < 0)
- {
- Chain msg = Chain("fcntl system error : ") + Chain(strerror(errno));
- throw Exception(EXLOC, msg);
- }
-
- NetHandler* pNH = new NetHandler(socket, _msgBufSize, _sizeBufLen);
-
- return pNH;
-
-}
-
-
-void Net::serve(int port)
-{
-
- struct sockaddr_in sa;
- int addrlen;
-
- if ( (_csock=socket(AF_INET,SOCK_STREAM,0)) == 0)
- throw Exception(EXLOC, "socket system error");
-
-
- int optVal = 1;
- if ( setsockopt(_csock, SOL_SOCKET, SO_REUSEADDR, &optVal, sizeof(int)) )
- {
- Chain msg = Chain("setsockopt system error : ") + Chain(strerror(errno));
- throw Exception(EXLOC, msg);
- }
-
- sa.sin_family = AF_INET;
- sa.sin_addr.s_addr = INADDR_ANY;
- sa.sin_port = htons(port);
+ sa.sin_port = htons(service.asInteger());
- if ( bind(_csock,(struct sockaddr *)&sa, sizeof(sa)) < 0)
+ if (::connect(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0 )
{
- Chain msg = Chain("bind system error on port ") + Chain(port) + Chain(" : ") + Chain(strerror(errno));
- throw Exception(EXLOC, msg);
- }
-
- if (listen(_csock,3) < 0 )
- {
- Chain msg = Chain("listen system error : ") + Chain(strerror(errno));
+ Chain msg = Chain("connect system error : ") + Chain(strerror(errno));
throw Exception(EXLOC, msg);
}
-}
-*/
-
-NetHandler* Net::connect(const Chain& hostname, const Chain& service)
-{
+#else
struct addrinfo hints, *res0, *res;
int err;
@@ -223,11 +115,9 @@
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
-#ifdef HAVE_MINGW32
- hints.ai_family = AF_INET;
-#else
+
hints.ai_family = PF_UNSPEC;
-#endif
+
if ((err = getaddrinfo((char*)hostname, (char*)service, &hints, &res0)) != 0)
{
@@ -260,6 +150,7 @@
throw Exception(EXLOC, msg);
}
+#endif
NetHandler* pNH = new NetHandler(sock, _msgBufSize, _sizeBufLen);
@@ -271,6 +162,78 @@
NetHandler* Net::connect(const Chain& hostname, const Chain& service, int timeout)
{
+#ifdef HAVE_MINGW32
+
+ if ( service.isNum() == false )
+ {
+ Chain msg = Chain("Service must be numeric value");
+ throw Exception(EXLOC, msg);
+ }
+
+ struct sockaddr_in sa;
+ struct hostent *he;
+
+ if ((he = gethostbyname((char*)hostname)) == NULL)
+ {
+ Chain msg = Chain("Cannot resolve hostname ") + hostname;
+ throw Exception(EXLOC, msg);
+ }
+ int sock;
+ if ( (sock = ::socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
+ {
+ Chain msg = Chain("socket system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ memcpy(&sa.sin_addr, he->h_addr_list[0], he->h_length);
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(service.asInteger());
+
+ int res;
+ u_long opt = 0;
+ res = ioctlsocket(sock, FIONBIO, &opt);
+ if (res != NO_ERROR)
+ {
+ Chain msg = Chain("ioctlsocket system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if (::connect(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0 )
+ {
+ if (errno == WSAEINPROGRESS)
+ {
+ fd_set wait_set;
+
+ FD_ZERO(&wait_set);
+ FD_SET(sock, &wait_set);
+
+ struct timeval tv;
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
+
+ if ( select(sock + 1, NULL, &wait_set, NULL, &tv) < 0 )
+ {
+ Chain msg = Chain("select system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+ }
+ else
+ {
+ Chain msg = Chain("connect system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+ }
+
+ opt=1;
+ res = ioctlsocket(sock, FIONBIO, &opt);
+ if (res != NO_ERROR)
+ {
+ Chain msg = Chain("ioctlsocket system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+#else
+
struct addrinfo hints, *res0, *res;
int err;
int sock;
@@ -278,12 +241,7 @@
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
-#ifdef HAVE_MINGW32
- hints.ai_family = AF_INET;
-#else
hints.ai_family = PF_UNSPEC;
-#endif
-
if ((err = getaddrinfo((char*)hostname, (char*)service, &hints, &res0)) != 0)
{
@@ -299,18 +257,6 @@
continue;
}
-
-#ifdef HAVE_MINGW32
- // no blocking supported
-
- if ( ::connect(sock, res->ai_addr, res->ai_addrlen) != 0)
- {
- close(sock);
- continue;
- }
-
-#else
-
int opt;
if ((opt = fcntl(sock, F_GETFL, NULL)) < 0)
@@ -357,7 +303,6 @@
continue;
}
}
-#endif
break;
}
@@ -369,6 +314,8 @@
Chain msg = Chain("Cannot connect to ") + hostname;
throw Exception(EXLOC, msg);
}
+
+#endif
NetHandler* pNH = new NetHandler(sock, _msgBufSize, _sizeBufLen);
@@ -379,17 +326,50 @@
void Net::serve(const Chain& hostname, const Chain& service)
{
+
+#ifdef HAVE_MINGW32
+
+ struct sockaddr_in sa;
+ int addrlen;
+
+ if ( (_csock=socket(AF_INET,SOCK_STREAM,0)) == 0)
+ throw Exception(EXLOC, "socket system error");
+
+
+ int optVal = 1;
+ if ( setsockopt(_csock, SOL_SOCKET, SO_REUSEADDR, (char*)&optVal, sizeof(int)) )
+ {
+ Chain msg = Chain("setsockopt system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = INADDR_ANY;
+ sa.sin_port = htons(service.asInteger());
+
+ if ( bind(_csock,(struct sockaddr *)&sa, sizeof(sa)) < 0)
+ {
+ Chain msg = Chain("bind system error on port ") + service + Chain(" : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if (listen(_csock,3) < 0 )
+ {
+ Chain msg = Chain("listen system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+
+#else
+
struct addrinfo hints, *res;
int err;
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
-#ifdef HAVE_MINGW32
- hints.ai_family = AF_INET;
-#else
+
hints.ai_family = PF_UNSPEC;
-#endif
if ((err = getaddrinfo((char*)hostname, (char*)service, &hints, &res)) != 0)
{
@@ -406,11 +386,7 @@
throw Exception(EXLOC, "socket system error");
int optVal = 1;
-#ifdef HAVE_MINGW32
- if ( setsockopt(_csock, SOL_SOCKET, SO_REUSEADDR, (char*)&optVal, sizeof(int)) )
-#else
if ( setsockopt(_csock, SOL_SOCKET, SO_REUSEADDR, &optVal, sizeof(int)) )
-#endif
{
Chain msg = Chain("setsockopt system error : ") + Chain(strerror(errno));
throw Exception(EXLOC, msg);
@@ -441,6 +417,9 @@
freeaddrinfo(res);
throw e;
}
+
+#endif
+
}
|
[-]
[+]
|
Added |
lfcbase-1.5.10.tar.bz2/src/Net.cc.save
^
|
@@ -0,0 +1,574 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Net.cc
+// ------
+// Base network driver
+//
+// Design and Implementation by Bjoern Lemke
+//
+// (C)opyright 2000-2013 Bjoern Lemke
+//
+// IMPLEMENTATION MODULE
+//
+// Class: Net
+//
+// Description: All operations on network resources
+//
+// Status: CLEAN
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _REENTRANT
+#define _REENTRANT /* basic 3-lines for threads */
+#endif
+
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+
+#ifdef HAVE_MINGW32
+#define WINVER 0x0501
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#endif
+#include <errno.h>
+
+#include "Exception.h"
+#include "Net.h"
+
+
+Net::Net(int msgBufSize, int sizeBufLen)
+{
+
+#ifdef HAVE_MINGW32
+
+ WSADATA wsa;
+ long rc;
+ rc = WSAStartup(MAKEWORD(2,0), &wsa);
+
+#endif
+
+ _msgBufSize = msgBufSize;
+ _sizeBufLen = sizeBufLen;
+ _csock=0;
+}
+
+Net::~Net()
+{
+ if ( _csock )
+ {
+ ::close(_csock);
+ }
+}
+
+/* OLD style
+NetHandler* Net::connect(const Chain& hostname, int port)
+{
+
+ struct sockaddr_in sa;
+ struct hostent *he;
+
+ if ((he = gethostbyname((char*)hostname)) == NULL)
+ {
+ Chain msg = Chain("Cannot resolve hostname ") + hostname;
+ throw Exception(EXLOC, msg);
+ }
+ int socket;
+ if ( (socket = ::socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
+ {
+ Chain msg = Chain("socket system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ memcpy(&sa.sin_addr, he->h_addr_list[0], he->h_length);
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(port);
+
+ if (::connect(socket, (struct sockaddr *)&sa, sizeof(sa)) < 0 )
+ {
+ Chain msg = Chain("connect system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ NetHandler* pNH = new NetHandler(socket, _msgBufSize, _sizeBufLen);
+
+ return pNH;
+}
+
+NetHandler* Net::connect(const Chain& hostname, int port, int timeout)
+{
+
+ struct sockaddr_in sa;
+ struct hostent *he;
+
+ if ((he = gethostbyname((char*)hostname)) == NULL)
+ {
+ Chain msg = Chain("Cannot resolve hostname ") + hostname;
+ throw Exception(EXLOC, msg);
+ }
+ int socket;
+ if ( (socket = ::socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
+ {
+ Chain msg = Chain("socket system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ memcpy(&sa.sin_addr, he->h_addr_list[0], he->h_length);
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(port);
+
+ int res, opt;
+
+ if ((opt = fcntl(socket, F_GETFL, NULL)) < 0)
+ {
+ Chain msg = Chain("fcntl system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if (fcntl(socket, F_SETFL, opt | O_NONBLOCK) < 0)
+ {
+ Chain msg = Chain("fcntl system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if (::connect(socket, (struct sockaddr *)&sa, sizeof(sa)) < 0 )
+ {
+ if (errno == EINPROGRESS)
+ {
+ fd_set wait_set;
+
+ FD_ZERO(&wait_set);
+ FD_SET(socket, &wait_set);
+
+ struct timeval tv;
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
+
+ if ( select(socket + 1, NULL, &wait_set, NULL, &tv) < 0 )
+ {
+ Chain msg = Chain("select system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+ }
+ else
+ {
+ Chain msg = Chain("connect system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+ }
+
+ if (fcntl(socket, F_SETFL, opt) < 0)
+ {
+ Chain msg = Chain("fcntl system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ NetHandler* pNH = new NetHandler(socket, _msgBufSize, _sizeBufLen);
+
+ return pNH;
+
+}
+
+
+void Net::serve(int port)
+{
+
+ struct sockaddr_in sa;
+ int addrlen;
+
+ if ( (_csock=socket(AF_INET,SOCK_STREAM,0)) == 0)
+ throw Exception(EXLOC, "socket system error");
+
+
+ int optVal = 1;
+ if ( setsockopt(_csock, SOL_SOCKET, SO_REUSEADDR, &optVal, sizeof(int)) )
+ {
+ Chain msg = Chain("setsockopt system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = INADDR_ANY;
+ sa.sin_port = htons(port);
+
+ if ( bind(_csock,(struct sockaddr *)&sa, sizeof(sa)) < 0)
+ {
+ Chain msg = Chain("bind system error on port ") + Chain(port) + Chain(" : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if (listen(_csock,3) < 0 )
+ {
+ Chain msg = Chain("listen system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+}
+
+*/
+
+NetHandler* Net::connect(const Chain& hostname, const Chain& service)
+{
+
+ struct addrinfo hints, *res0, *res;
+ int err;
+ int sock;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_socktype = SOCK_STREAM;
+#ifdef HAVE_MINGW32
+ hints.ai_family = AF_INET;
+#else
+ hints.ai_family = PF_UNSPEC;
+#endif
+
+ if ((err = getaddrinfo((char*)hostname, (char*)service, &hints, &res0)) != 0)
+ {
+ Chain msg = Chain("Cannot adr info for ") + hostname;
+ throw Exception(EXLOC, msg);
+ }
+
+ for (res=res0; res!=NULL; res=res->ai_next)
+ {
+ sock = ::socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (sock < 0)
+ {
+ continue;
+ }
+
+ if ( ::connect(sock, res->ai_addr, res->ai_addrlen) != 0)
+ {
+ close(sock);
+ continue;
+ }
+
+ break;
+ }
+
+ freeaddrinfo(res0);
+
+ if (res == NULL)
+ {
+ Chain msg = Chain("Cannot connect to ") + hostname;
+ throw Exception(EXLOC, msg);
+ }
+
+
+
+ NetHandler* pNH = new NetHandler(sock, _msgBufSize, _sizeBufLen);
+ return pNH;
+
+
+}
+
+NetHandler* Net::connect(const Chain& hostname, const Chain& service, int timeout)
+{
+
+ struct addrinfo hints, *res0, *res;
+ int err;
+ int sock;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_socktype = SOCK_STREAM;
+
+#ifdef HAVE_MINGW32
+ hints.ai_family = AF_INET;
+#else
+ hints.ai_family = PF_UNSPEC;
+#endif
+
+
+ if ((err = getaddrinfo((char*)hostname, (char*)service, &hints, &res0)) != 0)
+ {
+ Chain msg = Chain("Cannot get adr info for ") + hostname;
+ throw Exception(EXLOC, msg);
+ }
+
+ for (res=res0; res!=NULL; res=res->ai_next)
+ {
+ sock = ::socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (sock < 0)
+ {
+ continue;
+ }
+
+
+#ifdef HAVE_MINGW32
+ // no blocking supported
+
+ if ( ::connect(sock, res->ai_addr, res->ai_addrlen) != 0)
+ {
+ close(sock);
+ continue;
+ }
+
+#else
+
+ int opt;
+
+ if ((opt = fcntl(sock, F_GETFL, NULL)) < 0)
+ {
+ Chain msg = Chain("fcntl system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if (fcntl(sock, F_SETFL, opt | O_NONBLOCK) < 0)
+ {
+ Chain msg = Chain("fcntl system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if ( ::connect(sock, res->ai_addr, res->ai_addrlen) != 0)
+ {
+
+ if (errno == EINPROGRESS)
+ {
+ fd_set wait_set;
+
+ FD_ZERO(&wait_set);
+ FD_SET(sock, &wait_set);
+
+ struct timeval tv;
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
+
+ if ( ::select(sock + 1, NULL, &wait_set, NULL, &tv) < 0 )
+ {
+ Chain msg = Chain("select system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if (fcntl(sock, F_SETFL, opt) < 0)
+ {
+ Chain msg = Chain("fcntl system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+ }
+ else
+ {
+ close(sock);
+ continue;
+ }
+ }
+#endif
+
+ break;
+ }
+
+ freeaddrinfo(res0);
+
+ if (res == NULL)
+ {
+ Chain msg = Chain("Cannot connect to ") + hostname;
+ throw Exception(EXLOC, msg);
+ }
+
+ NetHandler* pNH = new NetHandler(sock, _msgBufSize, _sizeBufLen);
+
+ return pNH;
+
+}
+
+void Net::serve(const Chain& hostname, const Chain& service)
+{
+
+ struct addrinfo hints, *res;
+ int err;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_socktype = SOCK_STREAM;
+
+#ifdef HAVE_MINGW32
+ hints.ai_family = AF_INET;
+#else
+ hints.ai_family = PF_UNSPEC;
+#endif
+
+ if ((err = getaddrinfo((char*)hostname, (char*)service, &hints, &res)) != 0)
+ {
+ Chain msg = Chain("Cannot get adr info for ") + hostname + Chain("/") + service;
+ throw Exception(EXLOC, msg);
+ }
+
+ try
+ {
+
+ // struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+
+ if ( (_csock=socket(res->ai_family,res->ai_socktype,res->ai_protocol)) == 0)
+ throw Exception(EXLOC, "socket system error");
+
+ int optVal = 1;
+#ifdef HAVE_MINGW32
+ if ( setsockopt(_csock, SOL_SOCKET, SO_REUSEADDR, (char*)&optVal, sizeof(int)) )
+#else
+ if ( setsockopt(_csock, SOL_SOCKET, SO_REUSEADDR, &optVal, sizeof(int)) )
+#endif
+ {
+ Chain msg = Chain("setsockopt system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ /* struct sockaddr_in6 sin6;
+
+ bzero(&sin6, sizeof(struct sockaddr_in6));
+ sin6.sin6_family = AF_INET6;
+ sin6.sin6_port = htons(port);
+ sin6.sin6_addr = in6addr_any;
+ */
+
+ if ( bind(_csock, res->ai_addr, res->ai_addrlen) < 0)
+ {
+ Chain msg = Chain("bind system error on service ") + service + Chain(" : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if (listen(_csock,3) < 0 )
+ {
+ Chain msg = Chain("listen system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+ }
+ catch ( Exception e )
+ {
+ freeaddrinfo(res);
+ throw e;
+ }
+}
+
+
+void Net::serve(int port)
+{
+
+ struct sockaddr_in sa;
+ int addrlen;
+
+ if ( (_csock=socket(AF_INET,SOCK_STREAM,0)) == 0)
+ throw Exception(EXLOC, "socket system error");
+
+
+ int optVal = 1;
+
+#ifdef HAVE_MINGW32
+ if ( setsockopt(_csock, SOL_SOCKET, SO_REUSEADDR, (char*)&optVal, sizeof(int)) )
+#else
+ if ( setsockopt(_csock, SOL_SOCKET, SO_REUSEADDR, &optVal, sizeof(int)) )
+#endif
+
+ {
+ Chain msg = Chain("setsockopt system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = INADDR_ANY;
+ sa.sin_port = htons(port);
+
+ if ( bind(_csock,(struct sockaddr *)&sa, sizeof(sa)) < 0)
+ {
+ Chain msg = Chain("bind system error on port ") + Chain(port) + Chain(" : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ if (listen(_csock,3) < 0 )
+ {
+ Chain msg = Chain("listen system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+}
+
+
+
+/* with nextRequest, incoming requests are accepted on a well known port. Further
+ incoming messages from the partner are handled outside the method ( in a dedicated thread )
+ */
+
+NetHandler* Net::nextRequest(int timeout)
+{
+
+ int s;
+ struct timeval t;
+ t.tv_sec = timeout / 1000000;
+ t.tv_usec = timeout % 1000000;
+
+ fd_set fdSet;
+
+ FD_ZERO(&fdSet);
+ FD_SET(_csock, &fdSet);
+
+ if ( (s = ::select(_csock + 1, &fdSet, NULL, NULL, &t)) < 0 )
+ {
+ Chain msg = Chain("select system error : ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+
+ int nsocket = 0;
+
+ if ( s > 0 )
+ {
+ if ( FD_ISSET(_csock, &fdSet) )
+ {
+
+ // cout << "New connecction req detected .." << endl;
+ FD_CLR(_csock, &fdSet);
+
+ struct sockaddr_in sa;
+
+#ifdef HAVE_MINGW32
+ int sa_size=sizeof(sa);
+#else
+ socklen_t sa_size=sizeof(sa);
+#endif
+
+ // check for new connections ( non-blocking )
+ if ( (nsocket = ::accept(_csock, (struct sockaddr *)&sa, &sa_size)) < 0)
+ {
+
+#ifdef HAVE_MINGW32
+ if ( errno != 0 )
+ {
+ Chain msg = Chain("accept system error: ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+#else
+ if ( errno != EWOULDBLOCK )
+ {
+ Chain msg = Chain("accept system error: ") + Chain(strerror(errno));
+ throw Exception(EXLOC, msg);
+ }
+#endif
+ }
+ if ( nsocket > 0 )
+ {
+ // cout << "Accepting new connecction ..." << nsocket << endl;
+ NetHandler* pNetHandle = new NetHandler(nsocket, _msgBufSize, _sizeBufLen);
+
+ try
+ {
+ pNetHandle->readMsg();
+ }
+ catch ( Exception e)
+ {
+
+ pNetHandle->disconnect();
+ delete pNetHandle;
+
+ return 0;
+ }
+ return pNetHandle;
+
+ }
+ }
+
+ }
+ return 0;
+}
+
+
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/src/NetHandler.cc
^
|
@@ -174,8 +174,6 @@
}
Chain sizeInfo(_msgBuf, i);
- // cout << "received message size of " << sizeInfo << endl;
-
_msgSize = sizeInfo.asInteger();
if ( _msgSize + 1 > _msgBufSize )
|
[-]
[+]
|
Changed |
lfcbase-1.5.10.tar.bz2/src/strptime.c
^
|
@@ -14,7 +14,7 @@
if (!isdigit(**s)) {
if (j==0) return -1; else break;
}
- i=**s-'0';
+ i= i*10 + **s-'0';
++*s;
}
return i;
@@ -80,7 +80,7 @@
case 'm':
i=getint(&s,2);
if (i==-1 || i>12) return (char*)s;
- tm->tm_mon=i;
+ tm->tm_mon=i-1;
break;
case 'M':
i=getint(&s,2);
@@ -129,7 +129,7 @@
case 'Y':
i=getint(&s,5);
if (i==-1) return (char*)s;
- tm->tm_year=i;
+ tm->tm_year=i-1900;
break;
}
++format;
|