aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2001-11-12 21:22:40 +0000
committertradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2001-11-12 21:22:40 +0000
commit94e4993218a3673057dcf91e4e5e66eeff771c01 (patch)
tree3234a8e56b9f6f761cb70d2835d9a2e86020cd69
parente99c324ec8dccbfab747c1e0ebc27ef1429531bb (diff)
Announce the HTTPD server URL into an HTML file "server_url.html" in directory
HTPPD::announce_server_url_outdir if parameter HTTPD::announce_server_url was set to "yes". This is a dirty hack for SC'01 which will probably be taken back soon. git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@137 1faa4e14-9dd3-4be0-9f0e-ffe519881164
-rw-r--r--param.ccl9
-rw-r--r--src/Sockets.c25
2 files changed, 34 insertions, 0 deletions
diff --git a/param.ccl b/param.ccl
index 2bf9e78..2a0cb9e 100644
--- a/param.ccl
+++ b/param.ccl
@@ -60,6 +60,15 @@ BOOLEAN use_pthreads "Use a threaded implementation if possible ?"
{
} "no"
+BOOLEAN announce_server_url "Announce HTTPD server URL into an HTML file ?"
+{
+} "no"
+
+STRING announce_server_url_outdir "Where to write the HTTPD server URL HTML file to ?"
+{
+ ".+" :: "Any string"
+} "."
+
##################################################################
# Tuning parameters
diff --git a/src/Sockets.c b/src/Sockets.c
index 38a5ced..000a363 100644
--- a/src/Sockets.c
+++ b/src/Sockets.c
@@ -11,6 +11,7 @@
@@*/
#include "cctk.h"
+#include "cctk_Parameters.h"
#include "util_Network.h"
#include <stdio.h>
@@ -76,6 +77,10 @@ CCTK_FILEVERSION(CactusConnect_HTTPD_Sockets_c)
#define MSG_NOSIGNAL 0
#endif
+/* HTML filename to take the server URL */
+#define SERVER_URL_FILENAME "server_url.html"
+
+
typedef enum {closed, open} httpSocketState;
typedef struct HTTPSocket
@@ -140,6 +145,8 @@ int HTTP_SetupServer(int port, int queue_size, int hunt)
{
char hostname[1025];
int realport;
+ DECLARE_CCTK_PARAMETERS
+
/* Some systems need special logic for starting up TCP. */
InitialiseTCP();
@@ -159,6 +166,24 @@ int HTTP_SetupServer(int port, int queue_size, int hunt)
httpport = hunt ? realport : port;
printf("Server started on http://%s:%lu/\n", hostname, httpport);
+ if (announce_server_url)
+ {
+ char *filename;
+ FILE *file;
+
+
+ CCTK_CreateDirectory (0755, announce_server_url_outdir);
+ filename = (char *) malloc (strlen (announce_server_url_outdir) + 20);
+ sprintf (filename, "%s/%s", announce_server_url_outdir, SERVER_URL_FILENAME);
+ file = fopen (filename, "w");
+ if (file)
+ {
+ fprintf (file, "HTTPD server started on <A HREF=\"http://%s:%lu\">http://%s:%lu</A>",
+ hostname, httpport, hostname, httpport);
+ fclose (file);
+ }
+ free (filename);
+ }
minsock = sock;
maxsock = sock;