[Pcsclite-cvs-commit] PCSC/src powermgt_generic.c,NONE,1.1 Makefile.am,1.28,1.29 debuglog.c,1.13,1.14 dyn_hpux.c,1.4,1.5 dyn_macosx.c,1.3,1.4 dyn_unix.c,1.5,1.6 dyn_win32.c,1.4,1.5 powermgt_macosx.c,1.9,1.10 sys_unix.c,1.6,1.7 winscard_msg.c,1.7,1.8

aet-guest@quantz.debian.org aet-guest@quantz.debian.org
Sun, 07 Sep 2003 22:28:55 +0200


Update of /cvsroot/pcsclite/PCSC/src
In directory quantz:/tmp/cvs-serv24028/src

Modified Files:
	Makefile.am debuglog.c dyn_hpux.c dyn_macosx.c dyn_unix.c 
	dyn_win32.c powermgt_macosx.c sys_unix.c winscard_msg.c 
Added Files:
	powermgt_generic.c 
Log Message:
Build fixes. The first version that actually compiles for
Linux, Solaris, Tru64 and AIX after src/Makefile.am and
configure.in modifications.

- Untested
- No hotplug/power management support
- Untested for *BSD, MacOS X and HP-UX,
  there's other things to do before even
  trying to compile.


--- NEW FILE: powermgt_generic.c ---
/******************************************************************

	MUSCLE SmartCard Development ( http://www.linuxnet.com )
	Title  : powermgt_generic.c
	Package: pcsc lite
	Author : David Corcoran
	Date   : 09/07/03
	License: Copyright (C) 2000-2003 David Corcoran, <corcoran@linuxnet.com>

$Id: powermgt_generic.c,v 1.1 2003/09/07 20:28:53 aet-guest Exp $
********************************************************************/

#include "config.h"
#include "wintypes.h"
#include "pcsclite.h"

ULONG PMRegisterForPowerEvents()
{
  return 0;
}

Index: Makefile.am
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/Makefile.am,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- Makefile.am	7 Sep 2003 17:57:34 -0000	1.28
+++ Makefile.am	7 Sep 2003 20:28:53 -0000	1.29
@@ -16,6 +16,12 @@
 PCSC_DYNLOAD_SRC = dyn_unix.c dyn_hpux.c dyn_macosx.c
 PCSC_SYSTEM_SRC  = sys_unix.c
 PCSC_THREAD_SRC  = thread_unix.c
+PCSC_HOTPLUG_SRC  = \
+	hotplug_generic.c
+# hotplug_libusb.c \
+#	hotplug_linux.c hotplug_macosx.c
+PCSC_POWERMGT_SRC = powermgt_generic.c
+# powermgt_macosx.c
 
 if MSC_ENABLE_SCF
 PCSC_CLIENT_SRC  = winscard_scf.c
@@ -29,21 +35,8 @@
 PCSC_CLIENT =
 endif
 
-# <TO BE REMOVED>
-#if PCSC_ARCH_OSX
 #PCSC_INCLUDE_LIBS   = -Wl,-framework,IOKit
 #PCSCD_INCLUDE_LIBS  = -Wl,-framework,IOKit -Wl,-framework,CoreFoundation
-#endif
-#if PCSC_USE_LIBUSB
-#PCSC_HOTPLUG_SRC = hotplug_libusb.c
-#elif PCSC_LINUX_USB
-#PCSC_HOTPLUG_SRC = hotplug_linux.c
-#elif PCSC_ARCH_OSX
-#PCSC_HOTPLUG_SRC = hotplug_macosx.c powermgt_macosx.c
-#else
-#PCSC_HOTPLUG_SRC = hotplug_generic.c
-#endif
-# </TO BE REMOVED>
 
 libpcsclite_core_la_SOURCES = \
 	atrhandler.c \
@@ -59,9 +52,8 @@
 	$(PCSC_SYSTEM_SRC) \
 	$(PCSC_THREAD_SRC) \
 	$(PCSC_DYNLOAD_SRC) \
-	$(PCSC_HOTPLUG_SRC)
-libpcsclite_core_la_LDFLAGS = -version-info 0:2:0
-libpcsclite_core_la_LIDADD = @LIBDL@
+	$(PCSC_HOTPLUG_SRC) \
+	$(PCSC_POWERMGT_SRC)
 
 libpcsclite_la_SOURCES = \
 	debuglog.c \
@@ -77,11 +69,10 @@
 	tokenparser.l \
 	tokenfactory.c \
 	$(PCSC_DYNLOAD_SRC)
-libmusclecard_la_LIBADD = libpcsclite.la @LIBDL@
+libmusclecard_la_LIBADD = libpcsclite.la @LIBDL@ @LIBFL@
 
 pcscd_SOURCES = pcscdaemon.c winscard_svc.c
-pcscd_LDFLAGS = -rdynamic $(PCSCD_INCLUDE_LIBS)
-pcscd_LDADD = libpcsclite-core.la @LIBUSB@ @LIBDL@
+pcscd_LDADD = libpcsclite-core.la @LIBUSB@ @LIBDL@ @LIBFL@
 
 testpcsc_SOURCES = testpcsc.c
 testpcsc_LDADD = libpcsclite.la

Index: debuglog.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/debuglog.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- debuglog.c	7 Sep 2003 18:06:58 -0000	1.13
+++ debuglog.c	7 Sep 2003 20:28:53 -0000	1.14
@@ -28,6 +28,7 @@
 #include "wintypes.h"
 #include "pcsclite.h"
 #include "debuglog.h"
+#include "sys_generic.h"
 
 // Max string size when dumping a 256 bytes longs APDU
 #define DEBUG_BUF_SIZE (256*3+30)

Index: dyn_hpux.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/dyn_hpux.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dyn_hpux.c	7 Sep 2003 18:06:58 -0000	1.4
+++ dyn_hpux.c	7 Sep 2003 20:28:53 -0000	1.5
@@ -14,6 +14,7 @@
 
 #include "config.h"
 #include <string.h>
+#ifdef HAVE_DL_H
 #include <dl.h>
 #include <errno.h>
 
@@ -95,3 +96,5 @@
 
 	return rv;
 }
+
+#endif	/* HAVE_DL_H */

Index: dyn_macosx.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/dyn_macosx.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dyn_macosx.c	7 Sep 2003 18:06:58 -0000	1.3
+++ dyn_macosx.c	7 Sep 2003 20:28:53 -0000	1.4
@@ -13,6 +13,7 @@
 ********************************************************************/
 
 #include "config.h"
+#ifdef __APPLE__
 #include <CoreFoundation/CFBundle.h>
 #include <CoreFoundation/CFString.h>
 #include <CoreFoundation/CFURL.h>
@@ -114,3 +115,5 @@
 
 	return SCARD_S_SUCCESS;
 }
+
+#endif	/* __APPLE__ */

Index: dyn_unix.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/dyn_unix.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dyn_unix.c	7 Sep 2003 18:06:58 -0000	1.5
+++ dyn_unix.c	7 Sep 2003 20:28:53 -0000	1.6
@@ -13,7 +13,9 @@
 ********************************************************************/
 
 #include "config.h"
+#include <stdio.h>
 #include <string.h>
+#ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
 #include <stdlib.h>
 
@@ -54,27 +56,21 @@
 
 int DYN_GetAddress(void *pvLHandle, void **pvFHandle, char *pcFunction)
 {
-	int rv, iSize;
-	char *pcFunctionName;
+	char pcFunctionName[256];
+	int rv;
 
 	/*
 	 * Zero out everything 
 	 */
 	rv = 0;
-	pcFunctionName = NULL;
-	iSize = 0;
 
-	iSize = strlen(pcFunction) + 2;	/* 1-NULL, 2-_ */
-	pcFunctionName = (char *) malloc(iSize * sizeof(char));
-	pcFunctionName[0] = '_';
-	strcpy(&pcFunctionName[1], pcFunction);
+	/* Some platforms might need a leading underscore for the symbol */
+	snprintf(pcFunctionName, sizeof(pcFunctionName), "_%s", pcFunction);
 
 	*pvFHandle = NULL;
 	*pvFHandle = dlsym(pvLHandle, pcFunctionName);
 
-	/*
-	 * also try without a leading '_' (needed for FreeBSD) 
-	 */
+	/* Failed? Try again without the leading underscore */
 	if (*pvFHandle == NULL)
 		*pvFHandle = dlsym(pvLHandle, pcFunction);
 
@@ -85,7 +81,7 @@
 	} else
 		rv = SCARD_S_SUCCESS;
 
-	free(pcFunctionName);
-
 	return rv;
 }
+
+#endif	/* HAVE_DLFCN_H */

Index: dyn_win32.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/dyn_win32.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dyn_win32.c	7 Sep 2003 18:06:58 -0000	1.4
+++ dyn_win32.c	7 Sep 2003 20:28:53 -0000	1.5
@@ -14,6 +14,7 @@
 ********************************************************************/
 
 #include "config.h"
+#ifdef WIN32
 #include <string.h>
 
 #include "windows.h"
@@ -78,3 +79,4 @@
 	return rv;
 }
 
+#endif	/* WIN32 */

Index: powermgt_macosx.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/powermgt_macosx.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- powermgt_macosx.c	7 Sep 2003 18:06:58 -0000	1.9
+++ powermgt_macosx.c	7 Sep 2003 20:28:53 -0000	1.10
@@ -21,6 +21,7 @@
  */
 
 #include "config.h"
+#ifdef __APPLE__
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -38,7 +39,6 @@
 #include "readerfactory.h"
 #include "thread_generic.h"
 
-
 static io_connect_t		root_port;
 static IONotificationPortRef	notify;
 static io_object_t 		anIterator;
@@ -48,7 +48,6 @@
 
 void PMPowerRegistrationThread();
 
-
 void PMPowerEventCallback(void * x,io_service_t y,natural_t messageType,void * messageArgument)
 {
 
@@ -98,5 +97,4 @@
   return 0;
 }
 
-
-
+#endif	/* __APPLE__ */

Index: sys_unix.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/sys_unix.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- sys_unix.c	7 Sep 2003 18:06:58 -0000	1.6
+++ sys_unix.c	7 Sep 2003 20:28:53 -0000	1.7
@@ -14,7 +14,6 @@
 ********************************************************************/
 
 #include "config.h"
-#include <sys_generic.h>
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
@@ -26,9 +25,13 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <signal.h>
 #include <time.h>
 
+#include "sys_generic.h"
+#include "debuglog.h"
+
 int SYS_Initialize()
 {
 	/*
@@ -272,6 +275,7 @@
 		if (SYS_Chdir("/"))
 			DebugLogB("main: SYS_Chdir() failed: %s", strerror(errno));
 	}
+	return 0;
 #endif
 }
 

Index: winscard_msg.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/winscard_msg.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- winscard_msg.c	7 Sep 2003 18:06:58 -0000	1.7
+++ winscard_msg.c	7 Sep 2003 20:28:53 -0000	1.8
@@ -160,9 +160,10 @@
 int SHMProcessCommonChannelRequest()
 {
 
-	int i, clnt_len;
+	int i;
 	int new_sock;
 	struct sockaddr_un clnt_addr;
+	socklen_t clnt_len;
 	int one;
 
 	clnt_len = sizeof(clnt_addr);