[interchange-cvs] interchange - heins modified 4 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Tue Dec 30 20:59:22 UTC 2008
User: heins
Date: 2008-12-30 20:59:22 GMT
Modified: scripts compile_link.PL
Modified: dist/src config.h.in tlink.c vlink.c
Log:
* Add 504 status to link messages.
* Make HTML just a tad more modern.
* Make message configurable in config.h.in.
* Alter compile_link.PL to allow error message to be built from a file.
Uses four lines, concatenating remainder of file into one big line 4.
Tested with 70K file with many double-quotes, newlines, and carriage
returns.
* Add status option to make compile_link.PL to make error status
configurable.
* Add status option to make compile_link.PL to make error content type
configurable.
Revision Changes Path
2.9 interchange/scripts/compile_link.PL
rev 2.9, prev_rev 2.8
Index: compile_link.PL
===================================================================
RCS file: /var/cvs/interchange/scripts/compile_link.PL,v
retrieving revision 2.8
retrieving revision 2.9
diff -u -r2.8 -r2.9
--- compile_link.PL 9 Aug 2007 13:40:56 -0000 2.8
+++ compile_link.PL 30 Dec 2008 20:59:22 -0000 2.9
@@ -3,7 +3,7 @@
#
# Interchange link program configurator
#
-# $Id: compile_link.PL,v 2.8 2007-08-09 13:40:56 pajamian Exp $
+# $Id: compile_link.PL,v 2.9 2008-12-30 20:59:22 mheins Exp $
#
# Copyright (C) 2002-2007 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -73,6 +73,7 @@
-b dir, --build=dir Alternate build directory
(default $Self->{SRC_DIR})
+ -e, --error-file File to build error message from
-f, --force Force compile even if already there
-h host, --host=host Name of host the TCP link should contact
(default $Self->{LINK_HOST})
@@ -81,8 +82,10 @@
-o cgifile, Write it to a specific file as well as the
--output=cgifile link catalog directory
-p port, --port=port Port number to use (default $Self->{LINK_PORT})
+ -S status HTTP status line to use for error (default 504 timeout)
-s socketfile, Location of UNIX socket (default
--socket=file $Self->{INSTALLARCHLIB}/etc/socket)
+ -t content-type HTTP content-type (default text/html)
-w N, --timeout=N Number of seconds before timeout (default $Self->{LINK_TIMEOUT})
-u, --unixmode Copy the vlink file to outputfile (default)
--nosuid Don't change mode to suid for vlink (CGIWRAP)
@@ -97,6 +100,9 @@
my $Unix = 1;
my $NoSUID;
my $Nostrip;
+my $ErrorFile;
+my $Status = "504 Gateway Timeout";
+my $ContentType = 'text/html';
my $Perl_tlink;
my $Build_dir;
@@ -109,6 +115,9 @@
'build' => \ $Build_dir,
'source' => \ $Self->{SRC_DIR},
'inetmode' => \ $Inet,
+ 'content-type' => \ $ContentType,
+ 'status' => \ $Status,
+ 'error-file' => \ $ErrorFile,
'unixmode' => \ $Unix,
'nosuid' => \ $NoSUID,
'nostrip' => \ $Nostrip,
@@ -131,6 +140,9 @@
nostrip|n
nosuid
perl
+ error-file|e=s
+ content-type|t=s
+ status|S=s
force|f
build|b=s
source=s
@@ -176,6 +188,42 @@
or die "Couldn't change to source directory: $!\n";
}
+if($Status !~ /^\d+\s+\w+/) {
+ die "Misformed status value -- should be numeric code followed by message.\n";
+}
+
+$Self->{LINK_MESSAGE_HEAD}
+ = qq{Status: $Status\\r\\nContent-Type: $ContentType\\r\\n\\r\\n};
+
+if($ErrorFile) {
+ unless(-f $ErrorFile and -r $ErrorFile) {
+ die "error message file $ErrorFile missing.\n";
+ }
+
+ open ERRFILE, $ErrorFile
+ or die "Read error message file $ErrorFile: $!\n";
+
+ for(1 .. 3) {
+ my $line = <ERRFILE>;
+ $line ||= ' ';
+ $line =~ s/\r/\\r/g;
+ $line =~ s/\n/\\n/g;
+ $line =~ s/"/\\"/g;
+ $Self->{"LINK_MESSAGE_LINE$_"} = $line;
+ }
+
+ my $line = '';
+ while(<ERRFILE>) {
+ $line .= $_;
+ }
+
+ $line ||= ' ';
+ $line =~ s/\r/\\r/g;
+ $line =~ s/\n/\\n/g;
+ $line =~ s/"/\\"/g;
+ $Self->{"LINK_MESSAGE_LINE4"} = $line;
+}
+
if(! $Perl_tlink and ! -f "config.h" || ! -f "syscfg") {
system "/bin/sh ./configure";
if($?) {
2.2 interchange/dist/src/config.h.in
rev 2.2, prev_rev 2.1
Index: config.h.in
===================================================================
RCS file: /var/cvs/interchange/dist/src/config.h.in,v
retrieving revision 2.1
retrieving revision 2.2
diff -u -r2.1 -r2.2
--- config.h.in 8 Oct 2001 08:59:09 -0000 2.1
+++ config.h.in 30 Dec 2008 20:59:22 -0000 2.2
@@ -42,4 +42,13 @@
/*#define LINK_PORT ~_~LINK_PORT~_~*/
#define LINK_TIMEOUT 30
/*#define LINK_TIMEOUT ~_~LINK_TIMEOUT~_~*/
-
+#define LINK_MESSAGE_HEAD "Status: 504 Gateway Timeout\r\nContent-type: text/html\r\n\r\n"
+/*#define LINK_MESSAGE_HEAD "~_~LINK_MESSAGE_HEAD~_~"*/
+#define LINK_MESSAGE_LINE1 "<html>\r\n<head>\r\n\t<title>No response</title>\r\n</head>\r\n<body>\r\n"
+/*#define LINK_MESSAGE_LINE1 "~_~LINK_MESSAGE_LINE1~_~"*/
+#define LINK_MESSAGE_LINE2 "<strong>We're sorry, the Interchange server is unavailable...</strong>\r\n"
+/*#define LINK_MESSAGE_LINE2 "~_~LINK_MESSAGE_LINE2~_~"*/
+#define LINK_MESSAGE_LINE3 "<p>We are out of service or may be experiencing high system demand. Please try again soon.</p>\r\n"
+/*#define LINK_MESSAGE_LINE3 "~_~LINK_MESSAGE_LINE3~_~"*/
+#define LINK_MESSAGE_LINE4 "</body>\r\n</html>\r\n"
+/*#define LINK_MESSAGE_LINE4 "~_~LINK_MESSAGE_LINE4~_~"*/
2.7 interchange/dist/src/tlink.c
rev 2.7, prev_rev 2.6
Index: tlink.c
===================================================================
RCS file: /var/cvs/interchange/dist/src/tlink.c,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -r2.6 -r2.7
--- tlink.c 9 Aug 2007 13:40:52 -0000 2.6
+++ tlink.c 30 Dec 2008 20:59:22 -0000 2.7
@@ -2,7 +2,7 @@
* tlink.c: runs as a CGI program and passes request to Interchange
* server via TCP/IP
*
- * $Id: tlink.c,v 2.6 2007-08-09 13:40:52 pajamian Exp $
+ * $Id: tlink.c,v 2.7 2008-12-30 20:59:22 mheins Exp $
*
* Copyright (C) 2005-2007 Interchange Development Group,
* http://www.icdevgroup.org/
@@ -71,11 +71,11 @@
*/
void server_not_running()
{
- printf("Content-type: text/html\r\n\r\n");
- printf("<HTML><HEAD><TITLE>No response</TITLE></HEAD><BODY BGCOLOR=\"#FFFFFF\">");
- printf("<H3>We're sorry, the Interchange server is unavailable...</H3>\r\n");
- printf("We are out of service or may be experiencing high system\r\n");
- printf("demand. Please try again soon.</BODY></HTML>\r\n");
+ printf(LINK_MESSAGE_HEAD);
+ printf(LINK_MESSAGE_LINE1);
+ printf(LINK_MESSAGE_LINE2);
+ printf(LINK_MESSAGE_LINE3);
+ printf(LINK_MESSAGE_LINE4);
exit(1);
}
2.7 interchange/dist/src/vlink.c
rev 2.7, prev_rev 2.6
Index: vlink.c
===================================================================
RCS file: /var/cvs/interchange/dist/src/vlink.c,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -r2.6 -r2.7
--- vlink.c 9 Aug 2007 13:40:52 -0000 2.6
+++ vlink.c 30 Dec 2008 20:59:22 -0000 2.7
@@ -2,7 +2,7 @@
* vlink.c: runs as a CGI program and passes request to Interchange
* server via UNIX socket
*
- * $Id: vlink.c,v 2.6 2007-08-09 13:40:52 pajamian Exp $
+ * $Id: vlink.c,v 2.7 2008-12-30 20:59:22 mheins Exp $
*
* Copyright (C) 2005-2007 Interchange Development Group,
* http://www.icdevgroup.org/
@@ -60,11 +60,11 @@
*/
void server_not_running()
{
- printf("Content-type: text/html\r\n\r\n");
- printf("<HTML><HEAD><TITLE>No response</TITLE></HEAD><BODY BGCOLOR=\"#FFFFFF\">");
- printf("<H3>We're sorry, the Interchange server is unavailable...</H3>\r\n");
- printf("We are out of service or may be experiencing high system\r\n");
- printf("demand. Please try again soon.</BODY></HTML>\r\n");
+ printf(LINK_MESSAGE_HEAD);
+ printf(LINK_MESSAGE_LINE1);
+ printf(LINK_MESSAGE_LINE2);
+ printf(LINK_MESSAGE_LINE3);
+ printf(LINK_MESSAGE_LINE4);
exit(1);
}
More information about the interchange-cvs
mailing list