]> granicus.if.org Git - curl/commitdiff
Subs for refactoring purposes
authorYang Tse <yangsita@gmail.com>
Thu, 31 Dec 2009 02:29:55 +0000 (02:29 +0000)
committerYang Tse <yangsita@gmail.com>
Thu, 31 Dec 2009 02:29:55 +0000 (02:29 +0000)
tests/serverhelp.pm

index 54cc42ee3a39f7f8ae79577c0c76f161da188ca0..424697e5e252a8c282e37867871fae03bbd9b742 100644 (file)
@@ -50,6 +50,15 @@ use vars qw(
     servername_id
     servername_str
     servername_canon
+    server_pidfilename
+    server_logfilename
+    server_cmdfilename
+    server_inputfilename
+    server_outputfilename
+    mainsockf_pidfilename
+    mainsockf_logfilename
+    datasockf_pidfilename
+    datasockf_logfilename
     );
 
 
@@ -97,6 +106,104 @@ sub servername_canon {
 }
 
 
+#***************************************************************************
+# Return file name for server pid file.
+#
+sub server_pidfilename {
+    my ($proto, $ipver, $idnum) = @_;
+    my $trailer = '_server.pid';
+    return '.'. servername_canon($proto, $ipver, $idnum) ."$trailer";
+}
+
+
+#***************************************************************************
+# Return file name for server log file.
+#
+sub server_logfilename {
+    my ($logdir, $proto, $ipver, $idnum) = @_;
+    my $trailer = '_server.log';
+    return "${logdir}/". servername_canon($proto, $ipver, $idnum) ."$trailer";
+}
+
+
+#***************************************************************************
+# Return file name for server commands file.
+#
+sub server_cmdfilename {
+    my ($logdir, $proto, $ipver, $idnum) = @_;
+    my $trailer = '_server.cmd';
+    return "${logdir}/". servername_canon($proto, $ipver, $idnum) ."$trailer";
+}
+
+
+#***************************************************************************
+# Return file name for server input file.
+#
+sub server_inputfilename {
+    my ($logdir, $proto, $ipver, $idnum) = @_;
+    my $trailer = '_server.input';
+    return "${logdir}/". servername_canon($proto, $ipver, $idnum) ."$trailer";
+}
+
+
+#***************************************************************************
+# Return file name for server output file.
+#
+sub server_outputfilename {
+    my ($logdir, $proto, $ipver, $idnum) = @_;
+    my $trailer = '_server.output';
+    return "${logdir}/". servername_canon($proto, $ipver, $idnum) ."$trailer";
+}
+
+
+#***************************************************************************
+# Return file name for main or primary sockfilter pid file.
+#
+sub mainsockf_pidfilename {
+    my ($proto, $ipver, $idnum) = @_;
+    die "unsupported protocol: $proto" unless($proto &&
+        (lc($proto) =~ /^(ftp|imap|pop3|smtp)s?$/));
+    my $trailer = (lc($proto) =~ /^ftps?$/) ? '_sockctrl.pid':'_sockfilt.pid';
+    return '.'. servername_canon($proto, $ipver, $idnum) ."$trailer";
+}
+
+
+#***************************************************************************
+# Return file name for main or primary sockfilter log file.
+#
+sub mainsockf_logfilename {
+    my ($logdir, $proto, $ipver, $idnum) = @_;
+    die "unsupported protocol: $proto" unless($proto &&
+        (lc($proto) =~ /^(ftp|imap|pop3|smtp)s?$/));
+    my $trailer = (lc($proto) =~ /^ftps?$/) ? '_sockctrl.log':'_sockfilt.log';
+    return "${logdir}/". servername_canon($proto, $ipver, $idnum) ."$trailer";
+}
+
+
+#***************************************************************************
+# Return file name for data or secondary sockfilter pid file.
+#
+sub datasockf_pidfilename {
+    my ($proto, $ipver, $idnum) = @_;
+    die "unsupported protocol: $proto" unless($proto &&
+        (lc($proto) =~ /^ftps?$/));
+    my $trailer = '_sockdata.pid';
+    return '.'. servername_canon($proto, $ipver, $idnum) ."$trailer";
+}
+
+
+#***************************************************************************
+# Return file name for data or secondary sockfilter log file.
+#
+sub datasockf_logfilename {
+    my ($logdir, $proto, $ipver, $idnum) = @_;
+    die "unsupported protocol: $proto" unless($proto &&
+        (lc($proto) =~ /^ftps?$/));
+    my $trailer = '_sockdata.log';
+    return "${logdir}/". servername_canon($proto, $ipver, $idnum) ."$trailer";
+}
+
+
 #***************************************************************************
 # End of library
 1;