Commit 1afc5049 authored by Thomas Milius's avatar Thomas Milius
Browse files

Replace start because of minor changes and style as requested.

parent 8a009e55
......@@ -47,9 +47,9 @@
#define HTTP_OTHER_METHOD_FLAG_MASK_TYPE 3
typedef struct {
char *name;
unsigned long flags;
unsigned long usage_counter;
char *name;
unsigned long flags;
unsigned long usage_counter;
} http_other_method;
http_other_method http_other_methods[128];
......@@ -64,31 +64,31 @@ static _kernel_oserror *http_start_main(_kernel_swi_regs *r);
/* Called at start of module */
void http_start_init(void)
{
int i;
int i;
for (i=0; i < 128; i++) {
for (i=0; i < 128; i++) {
http_other_methods[i].name=NULL;
http_other_methods[i].flags=0;
http_other_methods[i].usage_counter=0;
}
/* Mark reserved methods as used */
http_other_methods[0].usage_counter=1;
/* Mark HTTP standard methods as used */
http_other_methods[method_HTTP_GET].usage_counter=1;
http_other_methods[method_HTTP_HEAD].usage_counter=1;
http_other_methods[method_HTTP_POST].usage_counter=1;
http_other_methods[method_HTTP_PUT].usage_counter=1;
http_other_methods[method_HTTP_OPTIONS].usage_counter=1;
http_other_methods[method_HTTP_TRACE].usage_counter=1;
http_other_methods[method_HTTP_DELETE].usage_counter=1;
/* Mark reserved methods as used */
http_other_methods[0].usage_counter=1;
/* Mark HTTP standard methods as used */
http_other_methods[method_HTTP_GET].usage_counter=1;
http_other_methods[method_HTTP_HEAD].usage_counter=1;
http_other_methods[method_HTTP_POST].usage_counter=1;
http_other_methods[method_HTTP_PUT].usage_counter=1;
http_other_methods[method_HTTP_OPTIONS].usage_counter=1;
http_other_methods[method_HTTP_TRACE].usage_counter=1;
http_other_methods[method_HTTP_DELETE].usage_counter=1;
}
/* Called at finalization of module */
void http_start_cleanup(void)
{
int i;
int i;
for (i=0; i < 128; i++) {
for (i=0; i < 128; i++) {
if (http_other_methods[i].name != NULL) {
free(http_other_methods[i].name);
http_other_methods[i].name=NULL;
......@@ -112,16 +112,15 @@ for (i=0; i < 128; i++) {
/*************************************************************/
_kernel_oserror *http_register_method(_kernel_swi_regs *r)
{
int i;
int first_unused_method;
int string_length;
int i;
int first_unused_method;
int string_length;
/* Warning: Should not run in parallel!
/* Warning: Should not run in parallel!
But how to ensure this at multicore environment? */
if (r == NULL) return make_error(HTTP_GENERAL_ERROR, 0);
/* Indicates failure. */
r->r[2]=-1;
if (r->r[0] != NULL) {
/* Indicates failure. */
r->r[2]=-1;
if (r->r[0] == NULL) return make_error(HTTP_BAD_PARAMETER, 0);
first_unused_method=-1;
i=0;
while (i < 128) {
......@@ -143,7 +142,7 @@ if (r->r[0] != NULL) {
}
i++;
}
if (first_unused_method != -1) {
if (first_unused_method == -1) return make_error(HTTP_NO_RESOURCES, 0);
/* Method doesn't exists yet and there is a free method we can use for it. */
string_length=strlen((char *) r->r[0]);
if (string_length > 0) {
......@@ -155,10 +154,6 @@ if (r->r[0] != NULL) {
}
}
return NULL;
}
else return make_error(HTTP_NO_RESOURCES, 0);
}
else return make_error(HTTP_BAD_PARAMETER, 0);
}
/*************************************************************/
......@@ -173,12 +168,11 @@ else return make_error(HTTP_BAD_PARAMETER, 0);
/*************************************************************/
_kernel_oserror *http_deregister_method(_kernel_swi_regs *r)
{
int i;
int i;
/* Warning: Should not run in parallel!
/* Warning: Should not run in parallel!
But how to ensure this at multicore environment? */
if (r == NULL) return make_error(HTTP_GENERAL_ERROR,0);
if (r->r[0] != NULL) {
if (r->r[0] == NULL) return make_error(HTTP_BAD_PARAMETER,0);
i=0;
while (i < 128) {
if (http_other_methods[i].usage_counter > 0 &&
......@@ -199,8 +193,6 @@ if (r->r[0] != NULL) {
i++;
}
return make_error(HTTP_METHOD_UNSUPPORTED,0);
}
else return make_error(HTTP_BAD_PARAMETER,0);
}
/*************************************************************/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment