added build for older CLIB version.
Этот коммит содержится в:
родитель
a87fdff9e9
Коммит
4ec68bdc04
@ -64,6 +64,11 @@ extern "C" {
|
|||||||
# include <sys/uio.h>
|
# include <sys/uio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
|
||||||
|
# include <sys/bsdskt.h>
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(LIBSSH2_WIN32) && defined(_MSC_VER) && (_MSC_VER <= 1310)
|
#if defined(LIBSSH2_WIN32) && defined(_MSC_VER) && (_MSC_VER <= 1310)
|
||||||
typedef unsigned __int64 libssh2_uint64_t;
|
typedef unsigned __int64 libssh2_uint64_t;
|
||||||
typedef __int64 libssh2_int64_t;
|
typedef __int64 libssh2_int64_t;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
##
|
##
|
||||||
## Comments to: Guenter Knauf <eflash@gmx.net>
|
## Comments to: Guenter Knauf <eflash@gmx.net>
|
||||||
##
|
##
|
||||||
## $Id: Makefile.netware,v 1.9 2007/06/20 23:44:58 gknauf Exp $
|
## $Id: Makefile.netware,v 1.10 2007/07/09 22:47:24 gknauf Exp $
|
||||||
#
|
#
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
@ -67,11 +67,13 @@ else
|
|||||||
OBJDIR = debug
|
OBJDIR = debug
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Include the version info retrieved from libssh2.h
|
# The following lines defines your compiler.
|
||||||
-include $(OBJDIR)/version.inc
|
ifdef CWFolder
|
||||||
|
METROWERKS = $(CWFolder)
|
||||||
# The following line defines your compiler.
|
endif
|
||||||
ifdef METROWERKS
|
ifdef METROWERKS
|
||||||
|
# MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support
|
||||||
|
MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support/Metrowerks Support
|
||||||
CC = mwccnlm
|
CC = mwccnlm
|
||||||
else
|
else
|
||||||
CC = gcc
|
CC = gcc
|
||||||
@ -87,8 +89,15 @@ AWK = awk
|
|||||||
MPKXDC = mkxdc
|
MPKXDC = mkxdc
|
||||||
ZIP = zip -qzr9
|
ZIP = zip -qzr9
|
||||||
|
|
||||||
|
# LIBARCH_U = $(shell $(AWK) 'BEGIN {print toupper(ARGV[1])}' $(LIBARCH))
|
||||||
|
LIBARCH_L = $(shell $(AWK) 'BEGIN {print tolower(ARGV[1])}' $(LIBARCH))
|
||||||
|
|
||||||
|
# Include the version info retrieved from libssh2.h
|
||||||
|
-include $(OBJDIR)/version.inc
|
||||||
|
|
||||||
# Global flags for all compilers
|
# Global flags for all compilers
|
||||||
CFLAGS = $(OPT) -D$(DB) -DNETWARE -nostdinc # -DHAVE_CONFIG_H
|
CFLAGS = $(OPT) -D$(DB) -DNETWARE -nostdinc
|
||||||
|
#CFLAGS += -DHAVE_CONFIG_H
|
||||||
|
|
||||||
ifeq ($(CC),mwccnlm)
|
ifeq ($(CC),mwccnlm)
|
||||||
LD = mwldnlm
|
LD = mwldnlm
|
||||||
@ -103,8 +112,10 @@ ifeq ($(LIBARCH),LIBC)
|
|||||||
PRELUDE = $(SDK_LIBC)/imports/libcpre.o
|
PRELUDE = $(SDK_LIBC)/imports/libcpre.o
|
||||||
CFLAGS += -align 4
|
CFLAGS += -align 4
|
||||||
else
|
else
|
||||||
PRELUDE = "$(METROWERKS)/Novell Support/libraries/runtime/prelude.obj"
|
# PRELUDE = $(SDK_CLIB)/imports/clibpre.o
|
||||||
# CFLAGS += -include "$(METROWERKS)/Novell Support/headers/nlm_prefix.h"
|
# to avoid the __init_* / __deinit_* whoes dont use prelude from NDK
|
||||||
|
PRELUDE = "$(MWCW_PATH)/libraries/runtime/prelude.obj"
|
||||||
|
# CFLAGS += -include "$(MWCW_PATH)/headers/nlm_clib_prefix.h"
|
||||||
CFLAGS += -align 1
|
CFLAGS += -align 1
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
@ -130,34 +141,32 @@ LDLIBS =
|
|||||||
NDK_ROOT = $(NDKBASE)/ndk
|
NDK_ROOT = $(NDKBASE)/ndk
|
||||||
SDK_CLIB = $(NDK_ROOT)/nwsdk
|
SDK_CLIB = $(NDK_ROOT)/nwsdk
|
||||||
SDK_LIBC = $(NDK_ROOT)/libc
|
SDK_LIBC = $(NDK_ROOT)/libc
|
||||||
SDK_LDAP = $(NDK_ROOT)/cldapsdk/netware
|
|
||||||
|
|
||||||
INCLUDES = -I. -I../include
|
INCLUDES = -I. -I../include
|
||||||
|
|
||||||
ifdef WITH_ZLIB
|
ifdef WITH_ZLIB
|
||||||
INCLUDES += -I$(ZLIB_PATH)
|
INCLUDES += -I$(ZLIB_PATH)
|
||||||
ifdef LINK_STATIC
|
ifdef LINK_STATIC
|
||||||
LDLIBS += $(ZLIB_PATH)/nw/libz.$(LIBEXT)
|
LDLIBS += $(ZLIB_PATH)/nw/$(LIBARCH)/libz.$(LIBEXT)
|
||||||
else
|
else
|
||||||
MODULES += libz.nlm
|
MODULES += libz.nlm
|
||||||
IMPORTS += @$(ZLIB_PATH)/nw/libz.imp
|
IMPORTS += @$(ZLIB_PATH)/nw/$(LIBARCH)/libz.imp
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
INCLUDES += -I$(OPENSSL_PATH)/outinc_nw_libc -I$(OPENSSL_PATH)/outinc_nw_libc/openssl
|
INCLUDES += -I$(OPENSSL_PATH)/outinc_nw_$(LIBARCH_L) -I$(OPENSSL_PATH)/outinc_nw_$(LIBARCH_L)/openssl
|
||||||
LDLIBS += $(OPENSSL_PATH)/out_nw_libc/ssl.$(LIBEXT) $(OPENSSL_PATH)/out_nw_libc/crypto.$(LIBEXT)
|
LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/ssl.$(LIBEXT)
|
||||||
|
LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/crypto.$(LIBEXT)
|
||||||
IMPORTS += GetProcessSwitchCount RunningProcess
|
IMPORTS += GetProcessSwitchCount RunningProcess
|
||||||
|
|
||||||
ifeq ($(LIBARCH),LIBC)
|
ifeq ($(LIBARCH),LIBC)
|
||||||
INCLUDES += -I$(SDK_LIBC)/include -I$(SDK_LIBC)/include/nks
|
INCLUDES += -I$(SDK_LIBC)/include
|
||||||
|
# INCLUDES += -I$(SDK_LIBC)/include/nks
|
||||||
# INCLUDES += -I$(SDK_LIBC)/include/winsock
|
# INCLUDES += -I$(SDK_LIBC)/include/winsock
|
||||||
# INCLUDES += -I$(SDK_LDAP)/libc/inc
|
|
||||||
CFLAGS += -D_POSIX_SOURCE
|
CFLAGS += -D_POSIX_SOURCE
|
||||||
# CFLAGS += -D__ANSIC__
|
|
||||||
else
|
else
|
||||||
INCLUDES += -I$(SDK_CLIB)/include/nlm -I$(SDK_CLIB)/include
|
INCLUDES += -I$(SDK_CLIB)/include/nlm
|
||||||
# INCLUDES += -I$(SDK_CLIB)/include/nlm/obsolete
|
# INCLUDES += -I$(SDK_CLIB)/include/nlm/obsolete
|
||||||
# INCLUDES += -I$(SDK_LDAP)/clib/inc
|
# INCLUDES += -I$(SDK_CLIB)/include
|
||||||
CFLAGS += -DNETDB_USE_INTERNET
|
|
||||||
endif
|
endif
|
||||||
CFLAGS += $(INCLUDES)
|
CFLAGS += $(INCLUDES)
|
||||||
|
|
||||||
@ -200,7 +209,7 @@ OBJECTS = \
|
|||||||
userauth.o
|
userauth.o
|
||||||
|
|
||||||
OBJS := $(addprefix $(OBJDIR)/,$(OBJECTS))
|
OBJS := $(addprefix $(OBJDIR)/,$(OBJECTS))
|
||||||
OBJL = $(OBJS) $(OBJDIR)/nwlibc.o $(LDLIBS)
|
OBJL = $(OBJS) $(OBJDIR)/nwlib.o $(LDLIBS)
|
||||||
|
|
||||||
all: lib nlm
|
all: lib nlm
|
||||||
|
|
||||||
@ -353,62 +362,82 @@ libssh2_config.h: Makefile.netware
|
|||||||
@echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
|
@echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
|
||||||
@echo $(DL)** All your changes will be lost!!$(DL) >> $@
|
@echo $(DL)** All your changes will be lost!!$(DL) >> $@
|
||||||
@echo $(DL)*/$(DL) >> $@
|
@echo $(DL)*/$(DL) >> $@
|
||||||
@echo $(DL)#define OS "i586-pc-NetWare"$(DL) >> $@
|
|
||||||
@echo $(DL)#define VERSION "$(LIBSSH2_VERSION_STR)"$(DL) >> $@
|
@echo $(DL)#define VERSION "$(LIBSSH2_VERSION_STR)"$(DL) >> $@
|
||||||
@echo $(DL)#define PACKAGE_BUGREPORT "http://sourceforge.net/projects/libssh2"$(DL) >> $@
|
@echo $(DL)#define PACKAGE_BUGREPORT "http://sourceforge.net/projects/libssh2"$(DL) >> $@
|
||||||
|
ifeq ($(LIBARCH),CLIB)
|
||||||
|
@echo $(DL)#define OS "i586-pc-clib-NetWare"$(DL) >> $@
|
||||||
|
@echo $(DL)#define NETDB_USE_INTERNET 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_STRICMP 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define socklen_t int$(DL) >> $@
|
||||||
|
else
|
||||||
|
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_INET_PTON 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_INTTYPES_H 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_LIMITS_H 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_LONGLONG 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_STDINT_H 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_STRCASECMP 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_STRLCAT 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_STRLCPY 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_STRTOLL 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_SYS_PARAM_H 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_SYS_SELECT_H 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_TERMIOS_H 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_AF_INET6 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_PF_INET6 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_STRUCT_IN6_ADDR 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_STRUCT_SOCKADDR_IN6 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
|
||||||
|
ifdef ENABLE_IPV6
|
||||||
|
@echo $(DL)#define ENABLE_IPV6 1$(DL) >> $@
|
||||||
|
endif
|
||||||
|
endif
|
||||||
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_CTYPE_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_CTYPE_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_ERRNO_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_ERRNO_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
|
@echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
|
@echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
|
@echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
|
@echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_INET_NTOA 1$(DL) >> $@
|
@echo $(DL)#define HAVE_INET_NTOA 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_INET_PTON 1$(DL) >> $@
|
@echo $(DL)#define HAVE_LL 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_INTTYPES_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_LIMITS_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_LONGLONG 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_MATH_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_NETINET_IN_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_NETINET_IN_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_SELECT 1$(DL) >> $@
|
@echo $(DL)#define HAVE_SELECT 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_SETJMP_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_SETJMP_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_SIGNAL 1$(DL) >> $@
|
@echo $(DL)#define HAVE_SIGNAL 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_SIGNAL_H 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_SIG_ATOMIC_T 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_SOCKET 1$(DL) >> $@
|
@echo $(DL)#define HAVE_SOCKET 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_STDARG_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STDDEF_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STDINT_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STDLIB_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_STDLIB_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_STRCASECMP 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRDUP 1$(DL) >> $@
|
@echo $(DL)#define HAVE_STRDUP 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_STRFTIME 1$(DL) >> $@
|
@echo $(DL)#define HAVE_STRFTIME 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_STRING_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_STRING_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_STRLCAT 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRLCPY 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRSTR 1$(DL) >> $@
|
@echo $(DL)#define HAVE_STRSTR 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_SYS_PARAM_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_STRUCT_ADDRINFO 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_SYS_SELECT_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_STRUCT_TIMEVAL 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_SYS_IOCTL_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_SYS_STAT_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_SYS_STAT_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_SYS_TIME_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_SYS_TIME_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_TERMIOS_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_TIME_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_TIME_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_UNAME 1$(DL) >> $@
|
@echo $(DL)#define HAVE_UNAME 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_UNISTD_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_UNISTD_H 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_UTIME 1$(DL) >> $@
|
||||||
|
@echo $(DL)#define HAVE_UTIME_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define RETSIGTYPE void$(DL) >> $@
|
@echo $(DL)#define RETSIGTYPE void$(DL) >> $@
|
||||||
|
@echo $(DL)#define SIZEOF_STRUCT_IN_ADDR 4$(DL) >> $@
|
||||||
@echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
|
@echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
|
||||||
@echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
|
@echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_AF_INET6 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_PF_INET6 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRUCT_IN6_ADDR 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRUCT_SOCKADDR_IN6 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRUCT_ADDRINFO 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
|
|
||||||
@echo $(DL)#define SIZEOF_STRUCT_IN_ADDR 4$(DL) >> $@
|
|
||||||
@echo $(DL)#define USE_SSLEAY 1$(DL) >> $@
|
@echo $(DL)#define USE_SSLEAY 1$(DL) >> $@
|
||||||
@echo $(DL)#define USE_OPENSSL 1$(DL) >> $@
|
@echo $(DL)#define USE_OPENSSL 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_OPENSSL_X509_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_OPENSSL_X509_H 1$(DL) >> $@
|
||||||
@ -427,9 +456,6 @@ ifdef WITH_ZLIB
|
|||||||
@echo $(DL)#define HAVE_LIBZ 1$(DL) >> $@
|
@echo $(DL)#define HAVE_LIBZ 1$(DL) >> $@
|
||||||
@echo $(DL)#define LIBSSH2_HAVE_ZLIB 1$(DL) >> $@
|
@echo $(DL)#define LIBSSH2_HAVE_ZLIB 1$(DL) >> $@
|
||||||
endif
|
endif
|
||||||
ifdef ENABLE_IPV6
|
|
||||||
@echo $(DL)#define ENABLE_IPV6 1$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifdef NW_WINSOCK
|
ifdef NW_WINSOCK
|
||||||
@echo $(DL)#define HAVE_CLOSESOCKET 1$(DL) >> $@
|
@echo $(DL)#define HAVE_CLOSESOCKET 1$(DL) >> $@
|
||||||
else
|
else
|
||||||
|
306
nw/nwlib.c
Обычный файл
306
nw/nwlib.c
Обычный файл
@ -0,0 +1,306 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* Universal NetWare library stub. *
|
||||||
|
* written by Ulrich Neuman and given to OpenSource copyright-free. *
|
||||||
|
* Extended for CLIB support by Guenter Knauf. *
|
||||||
|
*********************************************************************
|
||||||
|
* $Id: nwlib.c,v 1.1 2007/07/09 22:50:02 gknauf Exp $ *
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
#ifdef NETWARE /* Novell NetWare */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifdef __NOVELL_LIBC__
|
||||||
|
/* For native LibC-based NLM we need to register as a real lib. */
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <library.h>
|
||||||
|
#include <netware.h>
|
||||||
|
#include <screen.h>
|
||||||
|
#include <nks/thread.h>
|
||||||
|
#include <nks/synch.h>
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int _errno;
|
||||||
|
void *twentybytes;
|
||||||
|
} libthreaddata_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int z;
|
||||||
|
void *tenbytes;
|
||||||
|
NXKey_t perthreadkey; /* if -1, no key obtained... */
|
||||||
|
NXMutex_t *lock;
|
||||||
|
} libdata_t;
|
||||||
|
|
||||||
|
int gLibId = -1;
|
||||||
|
void *gLibHandle = (void *) NULL;
|
||||||
|
rtag_t gAllocTag = (rtag_t) NULL;
|
||||||
|
NXMutex_t *gLibLock = (NXMutex_t *) NULL;
|
||||||
|
|
||||||
|
/* internal library function prototypes... */
|
||||||
|
int DisposeLibraryData ( void * );
|
||||||
|
void DisposeThreadData ( void * );
|
||||||
|
int GetOrSetUpData ( int id, libdata_t **data, libthreaddata_t **threaddata );
|
||||||
|
|
||||||
|
|
||||||
|
int _NonAppStart( void *NLMHandle,
|
||||||
|
void *errorScreen,
|
||||||
|
const char *cmdLine,
|
||||||
|
const char *loadDirPath,
|
||||||
|
size_t uninitializedDataLength,
|
||||||
|
void *NLMFileHandle,
|
||||||
|
int (*readRoutineP)( int conn,
|
||||||
|
void *fileHandle, size_t offset,
|
||||||
|
size_t nbytes,
|
||||||
|
size_t *bytesRead,
|
||||||
|
void *buffer ),
|
||||||
|
size_t customDataOffset,
|
||||||
|
size_t customDataSize,
|
||||||
|
int messageCount,
|
||||||
|
const char **messages )
|
||||||
|
{
|
||||||
|
NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
|
||||||
|
|
||||||
|
#ifndef __GNUC__
|
||||||
|
#pragma unused(cmdLine)
|
||||||
|
#pragma unused(loadDirPath)
|
||||||
|
#pragma unused(uninitializedDataLength)
|
||||||
|
#pragma unused(NLMFileHandle)
|
||||||
|
#pragma unused(readRoutineP)
|
||||||
|
#pragma unused(customDataOffset)
|
||||||
|
#pragma unused(customDataSize)
|
||||||
|
#pragma unused(messageCount)
|
||||||
|
#pragma unused(messages)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Here we process our command line, post errors (to the error screen),
|
||||||
|
** perform initializations and anything else we need to do before being able
|
||||||
|
** to accept calls into us. If we succeed, we return non-zero and the NetWare
|
||||||
|
** Loader will leave us up, otherwise we fail to load and get dumped.
|
||||||
|
*/
|
||||||
|
gAllocTag = AllocateResourceTag(NLMHandle,
|
||||||
|
"<library-name> memory allocations", AllocSignature);
|
||||||
|
|
||||||
|
if (!gAllocTag) {
|
||||||
|
OutputToScreen(errorScreen, "Unable to allocate resource tag for "
|
||||||
|
"library memory allocations.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gLibId = register_library(DisposeLibraryData);
|
||||||
|
|
||||||
|
if (gLibId < -1) {
|
||||||
|
OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gLibHandle = NLMHandle;
|
||||||
|
|
||||||
|
gLibLock = NXMutexAlloc(0, 0, &liblock);
|
||||||
|
|
||||||
|
if (!gLibLock) {
|
||||||
|
OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Here we clean up any resources we allocated. Resource tags is a big part
|
||||||
|
** of what we created, but NetWare doesn't ask us to free those.
|
||||||
|
*/
|
||||||
|
void _NonAppStop( void )
|
||||||
|
{
|
||||||
|
(void) unregister_library(gLibId);
|
||||||
|
NXMutexFree(gLibLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** This function cannot be the first in the file for if the file is linked
|
||||||
|
** first, then the check-unload function's offset will be nlmname.nlm+0
|
||||||
|
** which is how to tell that there isn't one. When the check function is
|
||||||
|
** first in the linked objects, it is ambiguous. For this reason, we will
|
||||||
|
** put it inside this file after the stop function.
|
||||||
|
**
|
||||||
|
** Here we check to see if it's alright to ourselves to be unloaded. If not,
|
||||||
|
** we return a non-zero value. Right now, there isn't any reason not to allow
|
||||||
|
** it.
|
||||||
|
*/
|
||||||
|
int _NonAppCheckUnload( void )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetOrSetUpData(int id, libdata_t **appData, libthreaddata_t **threadData)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
libdata_t *app_data;
|
||||||
|
libthreaddata_t *thread_data;
|
||||||
|
NXKey_t key;
|
||||||
|
NX_LOCK_INFO_ALLOC(liblock, "Application Data Lock", 0);
|
||||||
|
|
||||||
|
err = 0;
|
||||||
|
thread_data = (libthreaddata_t *) NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Attempt to get our data for the application calling us. This is where we
|
||||||
|
** store whatever application-specific information we need to carry in support
|
||||||
|
** of calling applications.
|
||||||
|
*/
|
||||||
|
app_data = (libdata_t *) get_app_data(id);
|
||||||
|
|
||||||
|
if (!app_data) {
|
||||||
|
/*
|
||||||
|
** This application hasn't called us before; set up application AND per-thread
|
||||||
|
** data. Of course, just in case a thread from this same application is calling
|
||||||
|
** us simultaneously, we better lock our application data-creation mutex. We
|
||||||
|
** also need to recheck for data after we acquire the lock because WE might be
|
||||||
|
** that other thread that was too late to create the data and the first thread
|
||||||
|
** in will have created it.
|
||||||
|
*/
|
||||||
|
NXLock(gLibLock);
|
||||||
|
|
||||||
|
if (!(app_data = (libdata_t *) get_app_data(id))) {
|
||||||
|
app_data = (libdata_t *) malloc(sizeof(libdata_t));
|
||||||
|
|
||||||
|
if (app_data) {
|
||||||
|
memset(app_data, 0, sizeof(libdata_t));
|
||||||
|
|
||||||
|
app_data->tenbytes = malloc(10);
|
||||||
|
app_data->lock = NXMutexAlloc(0, 0, &liblock);
|
||||||
|
|
||||||
|
if (!app_data->tenbytes || !app_data->lock) {
|
||||||
|
if (app_data->lock)
|
||||||
|
NXMutexFree(app_data->lock);
|
||||||
|
|
||||||
|
free(app_data);
|
||||||
|
app_data = (libdata_t *) NULL;
|
||||||
|
err = ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app_data) {
|
||||||
|
/*
|
||||||
|
** Here we burn in the application data that we were trying to get by calling
|
||||||
|
** get_app_data(). Next time we call the first function, we'll get this data
|
||||||
|
** we're just now setting. We also go on here to establish the per-thread data
|
||||||
|
** for the calling thread, something we'll have to do on each application
|
||||||
|
** thread the first time it calls us.
|
||||||
|
*/
|
||||||
|
err = set_app_data(gLibId, app_data);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
free(app_data);
|
||||||
|
app_data = (libdata_t *) NULL;
|
||||||
|
err = ENOMEM;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* create key for thread-specific data... */
|
||||||
|
err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key);
|
||||||
|
|
||||||
|
if (err) /* (no more keys left?) */
|
||||||
|
key = -1;
|
||||||
|
|
||||||
|
app_data->perthreadkey = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NXUnlock(gLibLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app_data) {
|
||||||
|
key = app_data->perthreadkey;
|
||||||
|
|
||||||
|
if (key != -1 /* couldn't create a key? no thread data */
|
||||||
|
&& !(err = NXKeyGetValue(key, (void **) &thread_data))
|
||||||
|
&& !thread_data) {
|
||||||
|
/*
|
||||||
|
** Allocate the per-thread data for the calling thread. Regardless of whether
|
||||||
|
** there was already application data or not, this may be the first call by a
|
||||||
|
** a new thread. The fact that we allocation 20 bytes on a pointer is not very
|
||||||
|
** important, this just helps to demonstrate that we can have arbitrarily
|
||||||
|
** complex per-thread data.
|
||||||
|
*/
|
||||||
|
thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
|
||||||
|
|
||||||
|
if (thread_data) {
|
||||||
|
thread_data->_errno = 0;
|
||||||
|
thread_data->twentybytes = malloc(20);
|
||||||
|
|
||||||
|
if (!thread_data->twentybytes) {
|
||||||
|
free(thread_data);
|
||||||
|
thread_data = (libthreaddata_t *) NULL;
|
||||||
|
err = ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((err = NXKeySetValue(key, thread_data))) {
|
||||||
|
free(thread_data->twentybytes);
|
||||||
|
free(thread_data);
|
||||||
|
thread_data = (libthreaddata_t *) NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appData)
|
||||||
|
*appData = app_data;
|
||||||
|
|
||||||
|
if (threadData)
|
||||||
|
*threadData = thread_data;
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DisposeLibraryData( void *data )
|
||||||
|
{
|
||||||
|
if (data) {
|
||||||
|
void *tenbytes = ((libdata_t *) data)->tenbytes;
|
||||||
|
|
||||||
|
if (tenbytes)
|
||||||
|
free(tenbytes);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisposeThreadData( void *data )
|
||||||
|
{
|
||||||
|
if (data) {
|
||||||
|
void *twentybytes = ((libthreaddata_t *) data)->twentybytes;
|
||||||
|
|
||||||
|
if (twentybytes)
|
||||||
|
free(twentybytes);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* __NOVELL_LIBC__ */
|
||||||
|
/* For native CLib-based NLM seems we can do a bit more simple. */
|
||||||
|
#include <nwthread.h>
|
||||||
|
|
||||||
|
int main ( void )
|
||||||
|
{
|
||||||
|
/* initialize any globals here... */
|
||||||
|
|
||||||
|
/* do this if any global initializing was done
|
||||||
|
SynchronizeStart();
|
||||||
|
*/
|
||||||
|
ExitThread (TSR_THREAD, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __NOVELL_LIBC__ */
|
||||||
|
|
||||||
|
#endif /* NETWARE */
|
||||||
|
|
||||||
|
|
309
nw/nwlibc.c
309
nw/nwlibc.c
@ -1,309 +0,0 @@
|
|||||||
/*********************************************************************
|
|
||||||
* Universal NetWare library stub. *
|
|
||||||
* written by Ulrich Neuman and given to OpenSource copyright-free. *
|
|
||||||
* version: 1.0 *
|
|
||||||
*********************************************************************/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <library.h>
|
|
||||||
#include <netware.h>
|
|
||||||
#include <screen.h>
|
|
||||||
#include <nks/thread.h>
|
|
||||||
#include <nks/synch.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int _errno;
|
|
||||||
void *twentybytes;
|
|
||||||
} libthreaddata_t;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int z;
|
|
||||||
void *tenbytes;
|
|
||||||
NXKey_t perthreadkey; /* if -1, no key obtained... */
|
|
||||||
NXMutex_t *lock;
|
|
||||||
} libdata_t;
|
|
||||||
|
|
||||||
int gLibId = -1;
|
|
||||||
void *gLibHandle = (void *) NULL;
|
|
||||||
rtag_t gAllocTag = (rtag_t) NULL;
|
|
||||||
NXMutex_t *gLibLock = (NXMutex_t *) NULL;
|
|
||||||
|
|
||||||
/* internal library function prototypes... */
|
|
||||||
int DisposeLibraryData ( void * );
|
|
||||||
void DisposeThreadData ( void * );
|
|
||||||
int GetOrSetUpData ( int id, libdata_t **data, libthreaddata_t **threaddata );
|
|
||||||
|
|
||||||
|
|
||||||
int _NonAppStart
|
|
||||||
(
|
|
||||||
void *NLMHandle,
|
|
||||||
void *errorScreen,
|
|
||||||
const char *cmdLine,
|
|
||||||
const char *loadDirPath,
|
|
||||||
size_t uninitializedDataLength,
|
|
||||||
void *NLMFileHandle,
|
|
||||||
int (*readRoutineP)( int conn, void *fileHandle, size_t offset,
|
|
||||||
size_t nbytes, size_t *bytesRead, void *buffer ),
|
|
||||||
size_t customDataOffset,
|
|
||||||
size_t customDataSize,
|
|
||||||
int messageCount,
|
|
||||||
const char **messages
|
|
||||||
)
|
|
||||||
{
|
|
||||||
NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
|
|
||||||
|
|
||||||
#ifndef __GNUC__
|
|
||||||
#pragma unused(cmdLine)
|
|
||||||
#pragma unused(loadDirPath)
|
|
||||||
#pragma unused(uninitializedDataLength)
|
|
||||||
#pragma unused(NLMFileHandle)
|
|
||||||
#pragma unused(readRoutineP)
|
|
||||||
#pragma unused(customDataOffset)
|
|
||||||
#pragma unused(customDataSize)
|
|
||||||
#pragma unused(messageCount)
|
|
||||||
#pragma unused(messages)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Here we process our command line, post errors (to the error screen),
|
|
||||||
** perform initializations and anything else we need to do before being able
|
|
||||||
** to accept calls into us. If we succeed, we return non-zero and the NetWare
|
|
||||||
** Loader will leave us up, otherwise we fail to load and get dumped.
|
|
||||||
*/
|
|
||||||
gAllocTag = AllocateResourceTag(NLMHandle,
|
|
||||||
"<library-name> memory allocations", AllocSignature);
|
|
||||||
|
|
||||||
if (!gAllocTag)
|
|
||||||
{
|
|
||||||
OutputToScreen(errorScreen, "Unable to allocate resource tag for "
|
|
||||||
"library memory allocations.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
gLibId = register_library(DisposeLibraryData);
|
|
||||||
|
|
||||||
if (gLibId < -1)
|
|
||||||
{
|
|
||||||
OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
gLibHandle = NLMHandle;
|
|
||||||
|
|
||||||
gLibLock = NXMutexAlloc(0, 0, &liblock);
|
|
||||||
|
|
||||||
if (!gLibLock)
|
|
||||||
{
|
|
||||||
OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Here we clean up any resources we allocated. Resource tags is a big part
|
|
||||||
** of what we created, but NetWare doesn't ask us to free those.
|
|
||||||
*/
|
|
||||||
void _NonAppStop( void )
|
|
||||||
{
|
|
||||||
(void) unregister_library(gLibId);
|
|
||||||
NXMutexFree(gLibLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** This function cannot be the first in the file for if the file is linked
|
|
||||||
** first, then the check-unload function's offset will be nlmname.nlm+0
|
|
||||||
** which is how to tell that there isn't one. When the check function is
|
|
||||||
** first in the linked objects, it is ambiguous. For this reason, we will
|
|
||||||
** put it inside this file after the stop function.
|
|
||||||
**
|
|
||||||
** Here we check to see if it's alright to ourselves to be unloaded. If not,
|
|
||||||
** we return a non-zero value. Right now, there isn't any reason not to allow
|
|
||||||
** it.
|
|
||||||
*/
|
|
||||||
int _NonAppCheckUnload( void )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetOrSetUpData
|
|
||||||
(
|
|
||||||
int id,
|
|
||||||
libdata_t **appData,
|
|
||||||
libthreaddata_t **threadData
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
libdata_t *app_data;
|
|
||||||
libthreaddata_t *thread_data;
|
|
||||||
NXKey_t key;
|
|
||||||
NX_LOCK_INFO_ALLOC(liblock, "Application Data Lock", 0);
|
|
||||||
|
|
||||||
err = 0;
|
|
||||||
thread_data = (libthreaddata_t *) NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Attempt to get our data for the application calling us. This is where we
|
|
||||||
** store whatever application-specific information we need to carry in support
|
|
||||||
** of calling applications.
|
|
||||||
*/
|
|
||||||
app_data = (libdata_t *) get_app_data(id);
|
|
||||||
|
|
||||||
if (!app_data)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
** This application hasn't called us before; set up application AND per-thread
|
|
||||||
** data. Of course, just in case a thread from this same application is calling
|
|
||||||
** us simultaneously, we better lock our application data-creation mutex. We
|
|
||||||
** also need to recheck for data after we acquire the lock because WE might be
|
|
||||||
** that other thread that was too late to create the data and the first thread
|
|
||||||
** in will have created it.
|
|
||||||
*/
|
|
||||||
NXLock(gLibLock);
|
|
||||||
|
|
||||||
if (!(app_data = (libdata_t *) get_app_data(id)))
|
|
||||||
{
|
|
||||||
app_data = (libdata_t *) malloc(sizeof(libdata_t));
|
|
||||||
|
|
||||||
if (app_data)
|
|
||||||
{
|
|
||||||
memset(app_data, 0, sizeof(libdata_t));
|
|
||||||
|
|
||||||
app_data->tenbytes = malloc(10);
|
|
||||||
app_data->lock = NXMutexAlloc(0, 0, &liblock);
|
|
||||||
|
|
||||||
if (!app_data->tenbytes || !app_data->lock)
|
|
||||||
{
|
|
||||||
if (app_data->lock)
|
|
||||||
NXMutexFree(app_data->lock);
|
|
||||||
|
|
||||||
free(app_data);
|
|
||||||
app_data = (libdata_t *) NULL;
|
|
||||||
err = ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app_data)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
** Here we burn in the application data that we were trying to get by calling
|
|
||||||
** get_app_data(). Next time we call the first function, we'll get this data
|
|
||||||
** we're just now setting. We also go on here to establish the per-thread data
|
|
||||||
** for the calling thread, something we'll have to do on each application
|
|
||||||
** thread the first time it calls us.
|
|
||||||
*/
|
|
||||||
err = set_app_data(gLibId, app_data);
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
free(app_data);
|
|
||||||
app_data = (libdata_t *) NULL;
|
|
||||||
err = ENOMEM;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* create key for thread-specific data... */
|
|
||||||
err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key);
|
|
||||||
|
|
||||||
if (err) /* (no more keys left?) */
|
|
||||||
key = -1;
|
|
||||||
|
|
||||||
app_data->perthreadkey = key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NXUnlock(gLibLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app_data)
|
|
||||||
{
|
|
||||||
key = app_data->perthreadkey;
|
|
||||||
|
|
||||||
if ( key != -1 /* couldn't create a key? no thread data */
|
|
||||||
&& !(err = NXKeyGetValue(key, (void **) &thread_data))
|
|
||||||
&& !thread_data)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
** Allocate the per-thread data for the calling thread. Regardless of whether
|
|
||||||
** there was already application data or not, this may be the first call by a
|
|
||||||
** a new thread. The fact that we allocation 20 bytes on a pointer is not very
|
|
||||||
** important, this just helps to demonstrate that we can have arbitrarily
|
|
||||||
** complex per-thread data.
|
|
||||||
*/
|
|
||||||
thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
|
|
||||||
|
|
||||||
if (thread_data)
|
|
||||||
{
|
|
||||||
thread_data->_errno = 0;
|
|
||||||
thread_data->twentybytes = malloc(20);
|
|
||||||
|
|
||||||
if (!thread_data->twentybytes)
|
|
||||||
{
|
|
||||||
free(thread_data);
|
|
||||||
thread_data = (libthreaddata_t *) NULL;
|
|
||||||
err = ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((err = NXKeySetValue(key, thread_data)))
|
|
||||||
{
|
|
||||||
free(thread_data->twentybytes);
|
|
||||||
free(thread_data);
|
|
||||||
thread_data = (libthreaddata_t *) NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (appData)
|
|
||||||
*appData = app_data;
|
|
||||||
|
|
||||||
if (threadData)
|
|
||||||
*threadData = thread_data;
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DisposeLibraryData
|
|
||||||
(
|
|
||||||
void *data
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
void *tenbytes = ((libdata_t *) data)->tenbytes;
|
|
||||||
|
|
||||||
if (tenbytes)
|
|
||||||
free(tenbytes);
|
|
||||||
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisposeThreadData
|
|
||||||
(
|
|
||||||
void *data
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
void *twentybytes = ((libthreaddata_t *) data)->twentybytes;
|
|
||||||
|
|
||||||
if (twentybytes)
|
|
||||||
free(twentybytes);
|
|
||||||
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Загрузка…
x
Ссылка в новой задаче
Block a user