Code: Select all
commit 86f64fb136e06d527a91dee3a718e9faaaf10070
Author: Rutger Nijlunsing <dcmtk@tux.tmfweb.nl>
Date: Sat Mar 3 14:44:27 2007 +0100
storescp: Add '#i' as placeholder for PID (Process ID) of current process.
Together with '--fork', this enables to distinguish between senders, even
when those senders send in parrallel.
Signed-off-by: Rutger Nijlunsing <dcmtk@tux.tmfweb.nl>
diff --git a/dcmnet/apps/storescp.cc b/dcmnet/apps/storescp.cc
index 39b6e50..f8a0468 100644
--- a/dcmnet/apps/storescp.cc
+++ b/dcmnet/apps/storescp.cc
@@ -116,6 +116,7 @@ static char rcsid[] = "$dcmtk: " OFFIS_CONSOLE_APPLICATION " v" OFFIS_DCMTK_VERS
#define FILENAME_PLACEHOLDER "#f"
#define CALLING_AETITLE_PLACEHOLDER "#a"
#define CALLED_AETITLE_PLACEHOLDER "#c"
+#define PID_PLACEHOLDER "#i"
static OFCondition processCommands(T_ASC_Association *assoc);
static OFCondition acceptAssociation(T_ASC_Network *net, DcmAssociationConfiguration& asccfg);
@@ -2148,6 +2149,11 @@ static void executeOnReception()
// perform substitution for placeholder #c
cmd = replaceChars( cmd, OFString(CALLED_AETITLE_PLACEHOLDER), calledaetitle );
+ // perform substitution for placeholder #i
+ char pidAsString[20];
+ sprintf(pidAsString, "%ld", getpid());
+ cmd = replaceChars( cmd, OFString(PID_PLACEHOLDER), OFString(pidAsString) );
+
// Execute command in a new process
executeCommand( cmd );
}
diff --git a/dcmnet/docs/storescp.man b/dcmnet/docs/storescp.man
index a15f7a4..7578eae 100644
--- a/dcmnet/docs/storescp.man
+++ b/dcmnet/docs/storescp.man
@@ -399,6 +399,7 @@ number of placeholders which will be replaced at run time:
\li \b #a: calling application entity title of the peer Storage SCU
\li \b #c: called application entity title used by the peer Storage SCU to
address \b storescp.
+\li \b #i: PID of receiving process. Useful in combination with \e --fork.
The specified command line is executed as a separate process, so that
the execution of \b storescp will not be held back.