From 8898ad9b25fca6afe2374d293a981db02a83d7e9 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 31 May 2012 14:46:27 +0000 Subject: Committing the documentation to svn to have it accessible online --- .../html/_net_file_servlet_8cpp_source.html | 236 +++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 Doc/doxygen/html/_net_file_servlet_8cpp_source.html (limited to 'Doc/doxygen/html/_net_file_servlet_8cpp_source.html') diff --git a/Doc/doxygen/html/_net_file_servlet_8cpp_source.html b/Doc/doxygen/html/_net_file_servlet_8cpp_source.html new file mode 100644 index 0000000..06b2132 --- /dev/null +++ b/Doc/doxygen/html/_net_file_servlet_8cpp_source.html @@ -0,0 +1,236 @@ + + + + + +Starshatter_Open: D:/SRC/StarshatterSVN/Stars45/NetFileServlet.cpp Source File + + + + + + + + + + + + + +
+
+ + + + + + +
+
Starshatter_Open +
+
Open source Starshatter engine
+
+
+ + + + + +
+
+ +
+
+
+ +
+ + + + +
+ +
+ +
+
+
NetFileServlet.cpp
+
+
+Go to the documentation of this file.
1 /* Project Starshatter 4.5
+
2  Destroyer Studios LLC
+
3  Copyright © 1997-2004. All Rights Reserved.
+
4 
+
5  SUBSYSTEM: Stars.exe
+
6  FILE: NetFileServlet.cpp
+
7  AUTHOR: John DiCamillo
+
8 
+
9 
+
10  OVERVIEW
+
11  ========
+
12  HTTP Servlet for File Transfer
+
13 */
+
14 
+
15 
+
16 #include "MemDebug.h"
+
17 #include "NetFileServlet.h"
+
18 #include "NetAdminServer.h"
+
19 #include "NetLayer.h"
+
20 
+
21 #include "DataLoader.h"
+
22 
+
23 // +-------------------------------------------------------------------+
+
24 
+
25 bool
+ +
27 {
+
28  if (!CheckUser(request, response))
+
29  return true;
+
30 
+
31  Text content;
+
32  Text path = request.GetParam("path");
+
33  Text name = request.GetParam("name");
+
34 
+
35  if (name.length()) {
+
36  BYTE* buffer = 0;
+ +
38 
+
39  if (loader) {
+
40  loader->SetDataPath(path);
+
41  int len = loader->LoadBuffer(name, buffer);
+
42 
+
43  if (len) {
+
44  content = Text((const char*) buffer, len);
+
45  }
+
46 
+
47  loader->ReleaseBuffer(buffer);
+
48  loader->SetDataPath(0);
+
49  }
+
50  }
+
51 
+ +
53  response.AddHeader("MIME-Version", "1.0");
+
54  response.AddHeader("Cache-Control", "no-cache");
+
55  response.AddHeader("Expires", "-1");
+
56  response.AddHeader("Content-Type", "text/plain");
+
57  response.SetContent(content);
+
58 
+
59  return true;
+
60 }
+
61 
+
62 // +-------------------------------------------------------------------+
+
63 
+
64 bool
+ +
66 {
+
67  Text content;
+
68  Text name = request.URI();
+
69  bool found = false;
+
70 
+
71  if (name.length() > 4) {
+
72  char filename[256];
+
73  strcpy_s(filename, name.data() + 1); // skip leading '/'
+
74 
+
75  FILE* f;
+
76  ::fopen_s(&f, filename, "rb");
+
77 
+
78  if (f) {
+
79  ::fseek(f, 0, SEEK_END);
+
80  int len = ftell(f);
+
81  ::fseek(f, 0, SEEK_SET);
+
82 
+
83  BYTE* buf = new(__FILE__,__LINE__) BYTE[len];
+
84 
+
85  ::fread(buf, len, 1, f);
+
86  ::fclose(f);
+
87 
+
88  content = Text((const char*) buf, len);
+
89  delete [] buf;
+
90 
+
91  found = true;
+
92  ::Print("weblog: 200 OK %s %d bytes\n", name.data(), len);
+
93  }
+
94  else {
+
95  ::Print("weblog: 404 Not Found %s\n", name.data());
+
96  }
+
97  }
+
98 
+
99  if (found) {
+
100  Text content_type = "text/plain";
+
101 
+
102  if (name.contains(".gif"))
+
103  content_type = "image/gif";
+
104  else if (name.contains(".jpg"))
+
105  content_type = "image/jpeg";
+
106  else if (name.contains(".htm"))
+
107  content_type = "text/html";
+
108 
+
109  response.SetStatus(HttpResponse::SC_OK);
+
110  response.AddHeader("MIME-Version", "1.0");
+
111  response.AddHeader("Content-Type", content_type);
+
112  response.SetContent(content);
+
113  }
+
114  else {
+ +
116  }
+
117 
+
118  return true;
+
119 }
+
+
+ + + + -- cgit v1.1