[PATCH] storescp: add '#i' as placeholder for PID

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
eludias
Posts: 6
Joined: Tue, 2005-08-30, 16:18

[PATCH] storescp: add '#i' as placeholder for PID

#1 Post by eludias »

I'm parsing output of storescp in realtime (via a pipe), but together with --fork it becomes impossible to see the source of the message. So here a patch to be able to add the PID in the command to execute on reception.

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.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

Thank you for your contribution. We've added another entry to our internal to-do-list :-)

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest