[Pcsclite-cvs-commit] r2500 - trunk/PCSC/src

Ludovic Rousseau rousseau at alioth.debian.org
Wed Apr 4 08:51:43 UTC 2007


Author: rousseau
Date: 2007-04-04 08:51:42 +0000 (Wed, 04 Apr 2007)
New Revision: 2500

Added:
   trunk/PCSC/src/utils.c
   trunk/PCSC/src/utils.h
Modified:
   trunk/PCSC/src/pcscdaemon.c
Log:
move GetDaemonPid() in utils.c so we can also use it elsewhere


Modified: trunk/PCSC/src/pcscdaemon.c
===================================================================
--- trunk/PCSC/src/pcscdaemon.c	2007-03-29 14:05:22 UTC (rev 2499)
+++ trunk/PCSC/src/pcscdaemon.c	2007-04-04 08:51:42 UTC (rev 2500)
@@ -44,6 +44,7 @@
 #include "readerfactory.h"
 #include "configfile.h"
 #include "powermgt_generic.h"
+#include "utils.h"
 
 #ifndef TRUE
 #define TRUE 1
@@ -68,37 +69,6 @@
 
 PCSCLITE_MUTEX usbNotifierMutex;
 
-#ifdef USE_RUN_PID
-pid_t GetDaemonPid(void);
-pid_t GetDaemonPid(void)
-{
-	FILE *f;
-	pid_t pid;
-
-	/* pids are only 15 bits but 4294967296
-	 * (32 bits in case of a new system use it) is on 10 bytes
-	 */
-	if ((f = fopen(USE_RUN_PID, "rb")) != NULL)
-	{
-#define PID_ASCII_SIZE 11
-		char pid_ascii[PID_ASCII_SIZE];
-
-		fgets(pid_ascii, PID_ASCII_SIZE, f);
-		fclose(f);
-
-		pid = atoi(pid_ascii);
-	}
-	else
-	{
-		Log2(PCSC_LOG_CRITICAL, "Can't open " USE_RUN_PID ": %s",
-			strerror(errno));
-		return -1;
-	}
-
-	return pid;
-} /* GetDaemonPid */
-#endif
-
 int SendHotplugSignal(void)
 {
 #ifdef USE_RUN_PID

Added: trunk/PCSC/src/utils.c
===================================================================
--- trunk/PCSC/src/utils.c	2007-03-29 14:05:22 UTC (rev 2499)
+++ trunk/PCSC/src/utils.c	2007-04-04 08:51:42 UTC (rev 2500)
@@ -0,0 +1,53 @@
+/*
+ * MUSCLE SmartCard Development ( http://www.linuxnet.com )
+ *
+ * Copyright (C) 2006-2007
+ *  Ludovic Rousseau <ludovic.rousseau at free.fr>
+ *
+ * $Id: pcscdaemon.c 2377 2007-02-05 13:13:56Z rousseau $
+ */
+
+/**
+ * @file
+ * @brief utility functions
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "debug.h"
+#include "config.h"
+#include "utils.h"
+
+pid_t GetDaemonPid(void)
+{
+	FILE *f;
+	pid_t pid;
+
+	/* pids are only 15 bits but 4294967296
+	 * (32 bits in case of a new system use it) is on 10 bytes
+	 */
+	if ((f = fopen(USE_RUN_PID, "rb")) != NULL)
+	{
+#define PID_ASCII_SIZE 11
+		char pid_ascii[PID_ASCII_SIZE];
+
+		fgets(pid_ascii, PID_ASCII_SIZE, f);
+		fclose(f);
+
+		pid = atoi(pid_ascii);
+	}
+	else
+	{
+		Log2(PCSC_LOG_CRITICAL, "Can't open " USE_RUN_PID ": %s",
+			strerror(errno));
+		return -1;
+	}
+
+	return pid;
+} /* GetDaemonPid */
+

Added: trunk/PCSC/src/utils.h
===================================================================
--- trunk/PCSC/src/utils.h	2007-03-29 14:05:22 UTC (rev 2499)
+++ trunk/PCSC/src/utils.h	2007-04-04 08:51:42 UTC (rev 2500)
@@ -0,0 +1,16 @@
+/*
+ * MUSCLE SmartCard Development ( http://www.linuxnet.com )
+ *
+ * Copyright (C) 2006-2007
+ *  Ludovic Rousseau <ludovic.rousseau at free.fr>
+ *
+ * $Id: pcscdaemon.c 2377 2007-02-05 13:13:56Z rousseau $
+ */
+
+#ifndef __utils_h__
+#define __utils_h__
+
+pid_t GetDaemonPid(void);
+
+#endif
+




More information about the Pcsclite-cvs-commit mailing list