aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2004-05-17 12:28:56 +0000
committergoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2004-05-17 12:28:56 +0000
commitee9aa83b4b377ab5e18eeff6612f7ab15b3ecf3f (patch)
tree9d704ea57d5e320d67a3190522532d478f47cc2f
parent0f6d8eb2db87c7c71875c9e80802ed8033170602 (diff)
Untabified. Please try to adhere to the Cactus coding guidelines when
modifying or adding files. git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@206 1faa4e14-9dd3-4be0-9f0e-ffe519881164
-rw-r--r--src/Content.c40
-rw-r--r--src/Cookies.c4
-rw-r--r--src/Groups.c46
-rw-r--r--src/Headers.c46
-rw-r--r--src/Parameters.c34
-rw-r--r--src/SStringHTML.c26
-rw-r--r--src/Steer.c2
-rw-r--r--src/Thorns.c6
-rw-r--r--src/base64.c360
-rw-r--r--src/http.c4
10 files changed, 284 insertions, 284 deletions
diff --git a/src/Content.c b/src/Content.c
index 1e0c647..cbb4279 100644
--- a/src/Content.c
+++ b/src/Content.c
@@ -447,7 +447,7 @@ static int MainPage(const cGH *cctkGH, httpRequest *request, void *data)
"<h2>");
Concat(message, title );
ConcatCString(message,
- "</h2>\n"
+ "</h2>\n"
"<p>This browser is connected to a Cactus simulation which \n"
"contains a web server thorn. This thorn provides information \n"
" and control for the simulation.</p>\n"
@@ -460,7 +460,7 @@ static int MainPage(const cGH *cctkGH, httpRequest *request, void *data)
"</td>\n"
"</tr>\n"
"</table>\n"
- "</div>\n");
+ "</div>\n");
HTTP_SendString(request, message );
@@ -505,15 +505,15 @@ static int MainPage(const cGH *cctkGH, httpRequest *request, void *data)
"<li>Flesh version <span class=\"hilite\"> ");
ConcatCString(message, CCTK_FullVersion() );
ConcatCString(message,
- "</span></li>\n"
+ "</span></li>\n"
"<li>Flesh compiled on <span class=\"hilite\">");
ConcatCString(message, CCTK_CompileDate() );
ConcatCString(message,
- "</span>\n"
+ "</span>\n"
" at <span class=\"hilite\">");
ConcatCString(message, CCTK_CompileTime() );
ConcatCString(message,
- "</span></li>\n");
+ "</span></li>\n");
HTTP_SendString(request, message );
@@ -667,7 +667,7 @@ static int MainPage(const cGH *cctkGH, httpRequest *request, void *data)
SetToCString(message, " <li>Multiprocessor run on " );
ConcatDecimal(message, CCTK_nProcs(cctkGH));
ConcatCString(message, " CPUs</li>\n"
- " <li>Processor 0 running on <span class=\"hilite\">");
+ " <li>Processor 0 running on <span class=\"hilite\">");
ConcatCString(message, host);
ConcatCString(message, "</span></li>\n");
}
@@ -878,7 +878,7 @@ static int ControlPage(const cGH *cctkGH, httpRequest *request, void *data)
HTTP_Send(request,
"<h4> Run Control </h4>\n"
"<p> Select if the run should be paused, running normally, "
- "or terminated.\n"
+ "or terminated.\n"
" You may also single step to the next iteration.</p>\n");
HTTP_Send(request,
@@ -889,36 +889,36 @@ static int ControlPage(const cGH *cctkGH, httpRequest *request, void *data)
"<td><input type=\"radio\" name=\"runstate\" ");
ConcatCString(message, pause ? "checked=\"checked\"" : "");
ConcatCString(message,
- " value=\"PAUSE\" /> PAUSE</td>\n");
+ " value=\"PAUSE\" /> PAUSE</td>\n");
HTTP_SendString(request, message);
SetToCString(message,
"<td><input type=\"radio\" name=\"runstate\" ");
ConcatCString(message, pause ? "checked=\"checked\"" : "");
ConcatCString(message,
- " value=\"RUN\" /> RUN</td>\n");
+ " value=\"RUN\" /> RUN</td>\n");
HTTP_SendString(request, message);
HTTP_Send(request,
"<td><input type=\"radio\" name=\"runstate\" "
- "value=\"TERMINATE\" /> TERMINATE</td>\n");
+ "value=\"TERMINATE\" /> TERMINATE</td>\n");
HTTP_Send(request,
"<td><input type=\"submit\" name=\"step\" "
- "value=\"STEP\" /></td>\n");
+ "value=\"STEP\" /></td>\n");
HTTP_Send(request,
"</tr></table>\n"
"<table>\n"
"<tr><td><input type=\"submit\" value=\"OK\" /></td>\n"
- "<td> <input type=\"reset\" /></td>\n"
+ "<td> <input type=\"reset\" /></td>\n"
"</tr>\n"
"</table>\n");
HTTP_Send(request,
"<h4> Run Until </h4>\n"
"<p> The following parameters allow you to select an iteration\n"
- "number or physical time at which the code will pause.\n"
+ "number or physical time at which the code will pause.\n"
" You may also choose to pause if a particular expression made up\n"
" of grid scalars, simulation time and iteration is true. \n"
" Note that even if 'run' is selected above, the settings here have"
@@ -931,33 +931,33 @@ static int ControlPage(const cGH *cctkGH, httpRequest *request, void *data)
"<td><input type=\"text\" value=\"");
ConcatDecimal(message, until_it );
ConcatCString(message,
- "\" name=\"iteration\" /></td>\n"
+ "\" name=\"iteration\" /></td>\n"
"<td><input type=\"checkbox\" value=\"yes\" ");
ConcatCString(message, until_it_active ? "checked=\"checked\"" : "" );
ConcatCString(message,
- " name=\"until_it_active\" /></td>\n"
+ " name=\"until_it_active\" /></td>\n"
"</tr>\n");
ConcatCString(message,
"<tr><td>Time</td>"
"<td><input type=\"text\" value=\"");
ConcatDouble(message, until_time );
ConcatCString(message,
- "\" name=\"time\" /></td>\n"
+ "\" name=\"time\" /></td>\n"
"<td><input type=\"checkbox\" value=\"yes\" ");
ConcatCString(message, until_time_active ? "checked=\"checked\"" : "" );
ConcatCString(message,
- " name=\"until_time_active\" /></td>\n"
+ " name=\"until_time_active\" /></td>\n"
"</tr>\n");
ConcatCString(message,
"<tr><td>Expression</td>\n"
"<td><input type=\"text\" value=\"");
ConcatCString(message, until_expression );
ConcatCString(message,
- "\" name=\"expression\" /></td>\n"
+ "\" name=\"expression\" /></td>\n"
"<td><input type=\"checkbox\" value=\"yes\" ");
ConcatCString(message, until_expression_active ? " checked=\"checked\"" : "" );
ConcatCString(message,
- " name=\"until_expression_active\" /></td>\n"
+ " name=\"until_expression_active\" /></td>\n"
"</tr>\n");
ConcatCString(message,"</table>\n");
@@ -1228,7 +1228,7 @@ static int ControlTerminationPage(const cGH *cctkGH, httpRequest *request)
ConcatCString(message,
"</span></li>\n"
"<li>Flesh compiled on <span class=\"hilite\"> " __DATE__" </span>\n"
- "at <span class=\"hilite\"> "__TIME__" </span></li>\n");
+ "at <span class=\"hilite\"> "__TIME__" </span></li>\n");
HTTP_SendString(request, message);
diff --git a/src/Cookies.c b/src/Cookies.c
index c153608..0558006 100644
--- a/src/Cookies.c
+++ b/src/Cookies.c
@@ -177,12 +177,12 @@ char *HTTP_CookieGet(httpRequest *request, const char *cookie_name)
&& position == 0 )
{
if( FindCharFrom( value, '=', &position )
- && position == Length( name ) )
+ && position == Length( name ) )
{
TrimLeading( value, position + 1 );
retval = Util_Strdup( GetBuffer( value ) );
}
- break;
+ break;
}
}
String_Delete(name);
diff --git a/src/Groups.c b/src/Groups.c
index 5ee0453..16624cb 100644
--- a/src/Groups.c
+++ b/src/Groups.c
@@ -115,9 +115,9 @@ static int GroupsPage(const cGH *cctkGH, httpRequest *request, void *data)
HTTP_SendString(request, message );
HTTP_Send(request,"<style type=\"text/css\">\n"
- "\ttable.groups { background-color: #E9F4D3; } \n"
- "\t\t.groups td { text-align: left; } \n"
- "</style>\n");
+ "\ttable.groups { background-color: #E9F4D3; } \n"
+ "\t\t.groups td { text-align: left; } \n"
+ "</style>\n");
HTTP_Send(request,"</head>\n<body>\n");
@@ -130,33 +130,33 @@ static int GroupsPage(const cGH *cctkGH, httpRequest *request, void *data)
ngroups = CCTK_NumGroups();
retval = HTTP_Send(request, "<h1>Groups and Grid Variables</h1>\n"
- "<p>These pages describe the grid variables and groups \n"
- "active in this simulation.</p>\n");
+ "<p>These pages describe the grid variables and groups \n"
+ "active in this simulation.</p>\n");
SetToCString(message,
- "<p>This simulation contains ");
+ "<p>This simulation contains ");
ConcatDecimal(message, CCTK_NumGroups());
ConcatCString(message,
- " groups, and ");
+ " groups, and ");
ConcatDecimal(message, CCTK_NumVars());
ConcatCString(message,
- " variables, "
- "set in ");
+ " variables, "
+ "set in ");
ConcatDecimal(message, CCTK_MaxDim());
ConcatCString(message,
- "-space dimensions. \nGroups for which storage is currently\n"
- "assigned are written in <span class=\"hilite\">red</span>. \n"
- "The numbers in square brackets are the group and variable indices."
- "</p>\n");
+ "-space dimensions. \nGroups for which storage is currently\n"
+ "assigned are written in <span class=\"hilite\">red</span>. \n"
+ "The numbers in square brackets are the group and variable indices."
+ "</p>\n");
retval = HTTP_SendString(request, message);
retval = HTTP_Send(request,"<form action=\"/Groups.html\" method=\"get\">\n");
retval = HTTP_Send(request,"<div class=\"centered\">\n"
"<table class=\"groups\" width=\"100%\" cellpadding=\"5\" "
- "cellspacing=\"5\">\n"
- "<tr><th>Groups</th><th>Group Properties</th>"
- "<th>Variables</th></tr>\n");
+ "cellspacing=\"5\">\n"
+ "<tr><th>Groups</th><th>Group Properties</th>"
+ "<th>Variables</th></tr>\n");
for(i=0; i < ngroups; i++)
{
@@ -193,16 +193,16 @@ static int GroupsPage(const cGH *cctkGH, httpRequest *request, void *data)
switch (CCTK_GroupTypeI(i))
{
case CCTK_SCALAR:
- ConcatCString(message,"Grid scalar");
- break;
+ ConcatCString(message,"Grid scalar");
+ break;
case CCTK_ARRAY:
- ConcatCString(message,"Grid array");
- break;
+ ConcatCString(message,"Grid array");
+ break;
case CCTK_GF:
- ConcatCString(message,"Grid function");
- break;
+ ConcatCString(message,"Grid function");
+ break;
}
-
+
ConcatCString(message, " " );
ConcatCString(message, CCTK_VarTypeName(gdata.vartype) );
ConcatCString(message, " <br />\n(");
diff --git a/src/Headers.c b/src/Headers.c
index f24ac49..cf92f45 100644
--- a/src/Headers.c
+++ b/src/Headers.c
@@ -49,31 +49,31 @@ struct httpLink
static const char *cactus_styles =
"<style type=\"text/css\">\n"
-" body { color: black; background-color: white; }\n"
-" h1, h2 { text-align: center; }\n"
-" dfn { font-style: italic; }\n"
-" td { vertical-align: top; }\n"
-" a:link { color: #1B831D; }\n"
-" a:visited { color: #768000; }\n"
-" a:active { color: green; }\n"
-" div.centered { text-align: center; } \n"
-" div.centered table { margin: auto; } \n"
-" span.hilite { color: red; } \n"
-" td.menu { color: black; background-color: #E5FFA2; \n"
-" text-align: left; vertical-align: top; width: 20ex; \n"
-" font-size: small; }\n"
-" td.menu h2 { font-weight: normal; font-size: medium; \n"
+" body { color: black; background-color: white; }\n"
+" h1, h2 { text-align: center; }\n"
+" dfn { font-style: italic; }\n"
+" td { vertical-align: top; }\n"
+" a:link { color: #1B831D; }\n"
+" a:visited { color: #768000; }\n"
+" a:active { color: green; }\n"
+" div.centered { text-align: center; } \n"
+" div.centered table { margin: auto; } \n"
+" span.hilite { color: red; } \n"
+" td.menu { color: black; background-color: #E5FFA2; \n"
+" text-align: left; vertical-align: top; width: 20ex; \n"
+" font-size: small; }\n"
+" td.menu h2 { font-weight: normal; font-size: medium; \n"
" text-align: left; margin-top: 0; } \n"
-" td.menu h3 { font-weight: bold; font-size: small; \n"
+" td.menu h3 { font-weight: bold; font-size: small; \n"
" margin-top: 1.2em; margin-bottom: 0; } \n"
-" td.menu span.simulation_name { font-style: italic; } \n"
-" td.menu kbd { font-family: monospace; font-style: normal; } \n"
-" .footer td { font-size: small; vertical-align: top; } \n"
-" .footer td.by { text-align: right; } \n"
-" .footer img { border: 0; } \n"
-" div.banner { text-align: center; } \n"
-" div.banner table { margin: auto; } \n"
-" div.banner img { border: 0; } \n"
+" td.menu span.simulation_name { font-style: italic; } \n"
+" td.menu kbd { font-family: monospace; font-style: normal; } \n"
+" .footer td { font-size: small; vertical-align: top; } \n"
+" .footer td.by { text-align: right; } \n"
+" .footer img { border: 0; } \n"
+" div.banner { text-align: center; } \n"
+" div.banner table { margin: auto; } \n"
+" div.banner img { border: 0; } \n"
"</style>\n";
static const char *cactus_footer =
diff --git a/src/Parameters.c b/src/Parameters.c
index 3348494..55f0e98 100644
--- a/src/Parameters.c
+++ b/src/Parameters.c
@@ -216,17 +216,17 @@ static int MainParameterPage(const cGH *cctkGH, httpRequest *request, void *data
HTTP_Send(request,
"<h1>Check/Modify Parameters</h1>\n"
"<p>From this page you can check the values of all parameters for \n"
- "the simulation, and modify any parameters which have been \n"
- "designated as <i>steerable</i></p>\n"
+ "the simulation, and modify any parameters which have been \n"
+ "designated as <i>steerable</i></p>\n"
"<p>Parameters can be viewed for all <i>Active Thorns</i>, that is,\n"
"for thorns which have been activated in the parameter file for the\n"
" simulation. \n"
"Select one of the active thorns for this simulation from the list \n"
- "below to view all of its parameters</p>\n"
+ "below to view all of its parameters</p>\n"
"<p>Steerable parameters can be identified by the presence of a \n"
- "form input box, to change the value of a parameter, simply edit \n"
- "the value in the box and press the submit button to register the \n"
- "new values.</p>\n"
+ "form input box, to change the value of a parameter, simply edit \n"
+ "the value in the box and press the submit button to register the \n"
+ "new values.</p>\n"
"<div class=\"centered\">\n"
"<table cellspacing=\"5\" cellpadding=\"5\">\n"
"<tr><th>Thorn Name</th><th>Implementation</th></tr>\n");
@@ -313,10 +313,10 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
{
first = 0;
fprintf(stderr, "Setting %s::%s to %s\n", thorn,
- HTTP_ArgName( argument),
- HTTP_ArgValue( argument ));
+ HTTP_ArgName( argument),
+ HTTP_ArgValue( argument ));
HTTP_SteerQueue(thorn, HTTP_ArgName( argument),
- HTTP_ArgValue( argument ));
+ HTTP_ArgValue( argument ));
}
}
SendHTTP_Redirect_Header( request );
@@ -401,7 +401,7 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
"<h2>Thorn ");
ConcatCString(message, thorn);
ConcatCString(message,
- "</h2>\n");
+ "</h2>\n");
ConcatCString(message,
"<p>Parameters in Cactus can be either <dfn>fixed</dfn> or <dfn>steerable</dfn>. \n"
"Steerable parameters are those which can be modified during a simulation.\n"
@@ -700,7 +700,7 @@ static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data)
char *value;
char user[USER_LENGTH+1] = EMPTYSTRING;
int notauthorised = HTTP_AuthenticateBasic(request, "user", user,
- USER_LENGTH);
+ USER_LENGTH);
int readonly = notauthorised;
if(HTTP_NumArguments( request ) > 0)
@@ -718,10 +718,10 @@ static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data)
{
first = 0;
fprintf(stderr, "Setting %s::%s to %s\n", pData->thorn,
- HTTP_ArgName( argument),
- HTTP_ArgValue( argument ));
+ HTTP_ArgName( argument),
+ HTTP_ArgValue( argument ));
HTTP_SteerQueue(pData->thorn, HTTP_ArgName( argument),
- HTTP_ArgValue( argument ));
+ HTTP_ArgValue( argument ));
}
}
SendHTTP_Redirect_Header( request );
@@ -799,9 +799,9 @@ static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data)
"<div class=\"centered\">Return to all parameters for this \n"
"<a href=\"Parameters/");
ConcatCString(message,
- CCTK_ThornImplementation(pData->thorn));
+ CCTK_ThornImplementation(pData->thorn));
ConcatCString(message,
- "\">thorn</a>.</div> ");
+ "\">thorn</a>.</div> ");
HTTP_SendString(request, message);
@@ -815,7 +815,7 @@ static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data)
{
SetToCString(message,"<div class=\"centered\">\n"
- "<table class=\"thornparams\" cellpadding=\"5\" cellspacing=\"5\" "
+ "<table class=\"thornparams\" cellpadding=\"5\" cellspacing=\"5\" "
" border=\"1\">\n" );
ConcatCString(message, "<tr>\n<th>Name:</th>\n<td>");
ConcatCString(message, pData->name);
diff --git a/src/SStringHTML.c b/src/SStringHTML.c
index 42a317b..d75cf48 100644
--- a/src/SStringHTML.c
+++ b/src/SStringHTML.c
@@ -14,27 +14,27 @@ StringReplaceCharWithCString( String * str, SSCHAR c, const SSCHAR *cstr );
String *
StringSetToEncodedHTMLCString( String * str, const SSCHAR *c )
{
- return StringEncodeHTML( StringSetToCString( str, c ) );
+ return StringEncodeHTML( StringSetToCString( str, c ) );
}
String *
StringEncodeHTML( String * str )
{
- StringReplaceCharWithCString( str, '&', "&amp;" );
- StringReplaceCharWithCString( str, '<', "&lt;" );
- StringReplaceCharWithCString( str, '>', "&gt;" );
- return str;
+ StringReplaceCharWithCString( str, '&', "&amp;" );
+ StringReplaceCharWithCString( str, '<', "&lt;" );
+ StringReplaceCharWithCString( str, '>', "&gt;" );
+ return str;
}
String *
StringReplaceCharWithCString( String * str, SSCHAR c, const SSCHAR *cstr )
{
- size_t position = 0;
- while( StringFindCharFrom( str, c, &position ) )
- {
- StringDeleteChar( str, position );
- StringInsertCString( str, cstr, position );
- position ++;
- }
- return str;
+ size_t position = 0;
+ while( StringFindCharFrom( str, c, &position ) )
+ {
+ StringDeleteChar( str, position );
+ StringInsertCString( str, cstr, position );
+ position ++;
+ }
+ return str;
}
diff --git a/src/Steer.c b/src/Steer.c
index ed87922..e474325 100644
--- a/src/Steer.c
+++ b/src/Steer.c
@@ -374,7 +374,7 @@ static void ByteSwap(void *buf,int nelements,int elementsize)
/* do the swap thing on each element */
for(s=0, d=elementsize-1; s < d; s++,d--)
{
- char c=buffer[s];
+ char c=buffer[s];
buffer[s]=buffer[d];
buffer[d]=c;
}
diff --git a/src/Thorns.c b/src/Thorns.c
index 99fe222..a0720bb 100644
--- a/src/Thorns.c
+++ b/src/Thorns.c
@@ -132,8 +132,8 @@ static int ThornMainPage(const cGH *cctkGH, httpRequest *request, void *data)
HTTP_SendString(request, message );
HTTP_Send(request,"<style type=\"text/css\">\n"
- "\t.thorns td { text-align: left; } \n"
- "</style>\n");
+ "\t.thorns td { text-align: left; } \n"
+ "</style>\n");
HTTP_Send(request,"</head>\n<body>\n");
/* HTTP_SendString out the header part. */
@@ -194,7 +194,7 @@ static int ThornMainPage(const cGH *cctkGH, httpRequest *request, void *data)
HTTP_Send(request,
"<h2>Dormant Thorns</h2>\n"
"<div class=\"centered\">\n"
- "<table class=\"thorns\" cellspacing=\"0\" cellpadding=\"5\">\n"
+ "<table class=\"thorns\" cellspacing=\"0\" cellpadding=\"5\">\n"
"<tr>\n"
"<th>Thorn Name</th>\n"
"<th>Implementation</th>\n"
diff --git a/src/base64.c b/src/base64.c
index f209acf..bd09102 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -63,7 +63,7 @@
#include "base64.h"
static const char Base64[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char Pad64 = '=';
/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
@@ -119,75 +119,75 @@ static const char Pad64 = '=';
(1) the final quantum of encoding input is an integral
multiple of 24 bits; here, the final unit of encoded
- output will be an integral multiple of 4 characters
- with no "=" padding,
+ output will be an integral multiple of 4 characters
+ with no "=" padding,
(2) the final quantum of encoding input is exactly 8 bits;
here, the final unit of encoded output will be two
- characters followed by two "=" padding characters, or
+ characters followed by two "=" padding characters, or
(3) the final quantum of encoding input is exactly 16 bits;
here, the final unit of encoded output will be three
- characters followed by one "=" padding character.
+ characters followed by one "=" padding character.
*/
int HTTP_b64_ntop(unsigned char *src, size_t srclength,
char *target, size_t targsize)
{
- size_t datalength = 0;
- unsigned char input[3];
- unsigned char output[4];
- size_t i;
-
- while (2 < srclength) {
- input[0] = *src++;
- input[1] = *src++;
- input[2] = *src++;
- srclength -= 3;
-
- output[0] = input[0] >> 2;
- output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
- output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
- output[3] = input[2] & 0x3f;
- Assert(output[0] < 64);
- Assert(output[1] < 64);
- Assert(output[2] < 64);
- Assert(output[3] < 64);
-
- if (datalength + 4 > targsize)
- return (-1);
- target[datalength++] = Base64[output[0]];
- target[datalength++] = Base64[output[1]];
- target[datalength++] = Base64[output[2]];
- target[datalength++] = Base64[output[3]];
- }
-
- /* Now we worry about padding. */
- if (0 != srclength) {
- /* Get what's left. */
- input[0] = input[1] = input[2] = '\0';
- for (i = 0; i < srclength; i++)
- input[i] = *src++;
-
- output[0] = input[0] >> 2;
- output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
- output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
- Assert(output[0] < 64);
- Assert(output[1] < 64);
- Assert(output[2] < 64);
-
- if (datalength + 4 > targsize)
- return (-1);
- target[datalength++] = Base64[output[0]];
- target[datalength++] = Base64[output[1]];
- if (srclength == 1)
- target[datalength++] = Pad64;
- else
- target[datalength++] = Base64[output[2]];
- target[datalength++] = Pad64;
- }
- if (datalength >= targsize)
- return (-1);
- target[datalength] = '\0'; /* Returned value doesn't count \0. */
- return (datalength);
+ size_t datalength = 0;
+ unsigned char input[3];
+ unsigned char output[4];
+ size_t i;
+
+ while (2 < srclength) {
+ input[0] = *src++;
+ input[1] = *src++;
+ input[2] = *src++;
+ srclength -= 3;
+
+ output[0] = input[0] >> 2;
+ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+ output[3] = input[2] & 0x3f;
+ Assert(output[0] < 64);
+ Assert(output[1] < 64);
+ Assert(output[2] < 64);
+ Assert(output[3] < 64);
+
+ if (datalength + 4 > targsize)
+ return (-1);
+ target[datalength++] = Base64[output[0]];
+ target[datalength++] = Base64[output[1]];
+ target[datalength++] = Base64[output[2]];
+ target[datalength++] = Base64[output[3]];
+ }
+
+ /* Now we worry about padding. */
+ if (0 != srclength) {
+ /* Get what's left. */
+ input[0] = input[1] = input[2] = '\0';
+ for (i = 0; i < srclength; i++)
+ input[i] = *src++;
+
+ output[0] = input[0] >> 2;
+ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+ Assert(output[0] < 64);
+ Assert(output[1] < 64);
+ Assert(output[2] < 64);
+
+ if (datalength + 4 > targsize)
+ return (-1);
+ target[datalength++] = Base64[output[0]];
+ target[datalength++] = Base64[output[1]];
+ if (srclength == 1)
+ target[datalength++] = Pad64;
+ else
+ target[datalength++] = Base64[output[2]];
+ target[datalength++] = Pad64;
+ }
+ if (datalength >= targsize)
+ return (-1);
+ target[datalength] = '\0'; /* Returned value doesn't count \0. */
+ return (datalength);
}
/* skips all whitespace anywhere.
@@ -198,129 +198,129 @@ int HTTP_b64_ntop(unsigned char *src, size_t srclength,
int HTTP_b64_pton(const char *src, unsigned char *target, size_t targsize)
{
- size_t tarindex;
- int state, ch;
- char *pos;
-
- state = 0;
- tarindex = 0;
-
- while ((ch = *src++) != '\0') {
- if (isspace(ch)) /* Skip whitespace anywhere. */
- continue;
-
- if (ch == Pad64)
- break;
-
- pos = strchr(Base64, ch);
- if (pos == 0) /* A non-base64 character. */
- return (-1);
-
- switch (state) {
- case 0:
- if (target) {
- if (tarindex >= targsize)
- return (-1);
- target[tarindex] = (pos - Base64) << 2;
- }
- state = 1;
- break;
- case 1:
- if (target) {
- if (tarindex + 1 >= targsize)
- return (-1);
- target[tarindex] |= (pos - Base64) >> 4;
- target[tarindex+1] = ((pos - Base64) & 0x0f)
- << 4 ;
- }
- tarindex++;
- state = 2;
- break;
- case 2:
- if (target) {
- if (tarindex + 1 >= targsize)
- return (-1);
- target[tarindex] |= (pos - Base64) >> 2;
- target[tarindex+1] = ((pos - Base64) & 0x03)
- << 6;
- }
- tarindex++;
- state = 3;
- break;
- case 3:
- if (target) {
- if (tarindex >= targsize)
- return (-1);
- target[tarindex] |= (pos - Base64);
- }
- tarindex++;
- state = 0;
- break;
- default:
- abort();
- }
- }
-
- /*
- * We are done decoding Base-64 chars. Let's see if we ended
- * on a byte boundary, and/or with erroneous trailing characters.
- */
-
- if (ch == Pad64) { /* We got a pad char. */
- ch = *src++; /* Skip it, get next. */
- switch (state) {
- case 0: /* Invalid = in first position */
- case 1: /* Invalid = in second position */
- return (-1);
-
- case 2: /* Valid, means one byte of info */
- /* Skip any number of spaces. */
+ size_t tarindex;
+ int state, ch;
+ char *pos;
+
+ state = 0;
+ tarindex = 0;
+
+ while ((ch = *src++) != '\0') {
+ if (isspace(ch)) /* Skip whitespace anywhere. */
+ continue;
+
+ if (ch == Pad64)
+ break;
+
+ pos = strchr(Base64, ch);
+ if (pos == 0) /* A non-base64 character. */
+ return (-1);
+
+ switch (state) {
+ case 0:
+ if (target) {
+ if (tarindex >= targsize)
+ return (-1);
+ target[tarindex] = (pos - Base64) << 2;
+ }
+ state = 1;
+ break;
+ case 1:
+ if (target) {
+ if (tarindex + 1 >= targsize)
+ return (-1);
+ target[tarindex] |= (pos - Base64) >> 4;
+ target[tarindex+1] = ((pos - Base64) & 0x0f)
+ << 4 ;
+ }
+ tarindex++;
+ state = 2;
+ break;
+ case 2:
+ if (target) {
+ if (tarindex + 1 >= targsize)
+ return (-1);
+ target[tarindex] |= (pos - Base64) >> 2;
+ target[tarindex+1] = ((pos - Base64) & 0x03)
+ << 6;
+ }
+ tarindex++;
+ state = 3;
+ break;
+ case 3:
+ if (target) {
+ if (tarindex >= targsize)
+ return (-1);
+ target[tarindex] |= (pos - Base64);
+ }
+ tarindex++;
+ state = 0;
+ break;
+ default:
+ abort();
+ }
+ }
+
+ /*
+ * We are done decoding Base-64 chars. Let's see if we ended
+ * on a byte boundary, and/or with erroneous trailing characters.
+ */
+
+ if (ch == Pad64) { /* We got a pad char. */
+ ch = *src++; /* Skip it, get next. */
+ switch (state) {
+ case 0: /* Invalid = in first position */
+ case 1: /* Invalid = in second position */
+ return (-1);
+
+ case 2: /* Valid, means one byte of info */
+ /* Skip any number of spaces. */
#ifdef _LIBC
- /* To avoid warnings. */
- for ( ; ch != '\0'; ch = *src++)
+ /* To avoid warnings. */
+ for ( ; ch != '\0'; ch = *src++)
#else
- for (NULL; ch != '\0'; ch = *src++)
+ for (NULL; ch != '\0'; ch = *src++)
#endif
- if (!isspace(ch))
- break;
- /* Make sure there is another trailing = sign. */
- if (ch != Pad64)
- return (-1);
- ch = *src++; /* Skip the = */
- /* Fall through to "single trailing =" case. */
- /* FALLTHROUGH */
-
- case 3: /* Valid, means two bytes of info */
- /*
- * We know this char is an =. Is there anything but
- * whitespace after it?
- */
+ if (!isspace(ch))
+ break;
+ /* Make sure there is another trailing = sign. */
+ if (ch != Pad64)
+ return (-1);
+ ch = *src++; /* Skip the = */
+ /* Fall through to "single trailing =" case. */
+ /* FALLTHROUGH */
+
+ case 3: /* Valid, means two bytes of info */
+ /*
+ * We know this char is an =. Is there anything but
+ * whitespace after it?
+ */
#ifdef _LIBC
- /* To avoid warnings. */
- for ( ; ch != '\0'; ch = *src++)
+ /* To avoid warnings. */
+ for ( ; ch != '\0'; ch = *src++)
#else
- for (NULL; ch != '\0'; ch = *src++)
+ for (NULL; ch != '\0'; ch = *src++)
#endif
- if (!isspace(ch))
- return (-1);
-
- /*
- * Now make sure for cases 2 and 3 that the "extra"
- * bits that slopped past the last full byte were
- * zeros. If we don't check them, they become a
- * subliminal channel.
- */
- if (target && target[tarindex] != 0)
- return (-1);
- }
- } else {
- /*
- * We ended by seeing the end of the string. Make sure we
- * have no partial bytes lying around.
- */
- if (state != 0)
- return (-1);
- }
-
- return (tarindex);
+ if (!isspace(ch))
+ return (-1);
+
+ /*
+ * Now make sure for cases 2 and 3 that the "extra"
+ * bits that slopped past the last full byte were
+ * zeros. If we don't check them, they become a
+ * subliminal channel.
+ */
+ if (target && target[tarindex] != 0)
+ return (-1);
+ }
+ } else {
+ /*
+ * We ended by seeing the end of the string. Make sure we
+ * have no partial bytes lying around.
+ */
+ if (state != 0)
+ return (-1);
+ }
+
+ return (tarindex);
}
diff --git a/src/http.c b/src/http.c
index a2e2ff1..36fcc5f 100644
--- a/src/http.c
+++ b/src/http.c
@@ -139,7 +139,7 @@ httpSocket * HTTP_Connection( const httpRequest *request )
}
SSBOOL HTTP_GetHeaderValueString(const httpRequest *request,
- const String *header, String *value)
+ const String *header, String *value)
{
const char * v = HTTP_HeaderValue(request, GetBuffer( header ) );
if( v )
@@ -752,7 +752,7 @@ static int StripArgs(httpRequest *request, char *request_uri)
}
/* Append to local list */
- /* SW it isn't perfecty obvious this non NULL */
+ /* SW it isn't perfecty obvious this non NULL */
last->next = argument;
}
else