aboutsummaryrefslogtreecommitdiff
path: root/src/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.c')
-rw-r--r--src/client.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/src/client.c b/src/client.c
index 25ad55b8..22862020 100644
--- a/src/client.c
+++ b/src/client.c
@@ -14,12 +14,9 @@
14 14
15 15
16#include "client.h" 16#include "client.h"
17#include "outstream.h"
18#include "clientinfo.h"
17 19
18
19extern char *_libwebserver_version; // Defined in server.c
20
21
22struct web_client *current_web_client;
23int WEBTIMEOUT=10000; 20int WEBTIMEOUT=10000;
24 21
25/*********************************************************************************************************/ 22/*********************************************************************************************************/
@@ -30,7 +27,6 @@ struct web_client *__ILWS_init_client_list() {
30 struct web_client *ret; 27 struct web_client *ret;
31 ret=__ILWS_malloc(sizeof(struct web_client)); 28 ret=__ILWS_malloc(sizeof(struct web_client));
32 if(ret==NULL) { 29 if(ret==NULL) {
33 LWSERR(LE_MEMORY);
34 return NULL; 30 return NULL;
35 }; 31 };
36#ifdef HAVE_OPENSSL 32#ifdef HAVE_OPENSSL
@@ -182,7 +178,7 @@ void __ILWS_read_client(struct web_client *node) {
182 } else { 178 } else {
183 datasize=node->rbufsize-node->headersize; 179 datasize=node->rbufsize-node->headersize;
184 if(node->contentlength==0) { // well if it 0 read all at once 180 if(node->contentlength==0) { // well if it 0 read all at once
185 __ILWS_init_clientinfo(); // always call this? 181 __ILWS_init_clientinfo(); // always call this?
186 node->contentlength=atol(ClientInfo->Header("Content-Length")); 182 node->contentlength=atol(ClientInfo->Header("Content-Length"));
187 // range for resuming 183 // range for resuming
188 if((tmp3=strstr(ClientInfo->Header("Range"),"bytes="))) { // if it is in bytes (i hope, always) 184 if((tmp3=strstr(ClientInfo->Header("Range"),"bytes="))) { // if it is in bytes (i hope, always)
@@ -212,7 +208,6 @@ void __ILWS_read_client(struct web_client *node) {
212 node->rbufsize+=tmp; 208 node->rbufsize+=tmp;
213 tmp2=__ILWS_realloc(node->rbuf,node->rbufsize+1); 209 tmp2=__ILWS_realloc(node->rbuf,node->rbufsize+1);
214 if(tmp2==NULL) { 210 if(tmp2==NULL) {
215 LWSERR(LE_MEMORY);
216 node->stat=5; 211 node->stat=5;
217 212
218 return; 213 return;
@@ -420,10 +415,7 @@ void __ILWS_process_client(struct web_client *node,struct gethandler *list) {
420 return; 415 return;
421 }; 416 };
422 417
423 }else { 418 }
424 LWSERR(LE_FILESYS);
425
426 };
427 node->stat=4; 419 node->stat=4;
428 if(node->HTTPdirective==NULL) { 420 if(node->HTTPdirective==NULL) {
429 if(node->range>0) { 421 if(node->range>0) {
@@ -475,7 +467,6 @@ void __ILWS_output_client(struct web_client *node) {
475 if(tstream->next->fname!=NULL) { 467 if(tstream->next->fname!=NULL) {
476 if(tstream->next->fstream==NULL) { 468 if(tstream->next->fstream==NULL) {
477 if((tstream->next->fstream=fopen(tstream->next->fname,"rb"))==NULL) { 469 if((tstream->next->fstream=fopen(tstream->next->fname,"rb"))==NULL) {
478 LWSERR(LE_FILESYS);
479 __ILWS_delete_next_outstream(tstream); 470 __ILWS_delete_next_outstream(tstream);
480 //node->outstream->next=tstream->next; 471 //node->outstream->next=tstream->next;
481 return; 472 return;
@@ -506,7 +497,6 @@ void __ILWS_output_client(struct web_client *node) {
506 if(namesize>0) { 497 if(namesize>0) {
507 if(namesize==1) { // this is $; for sure 498 if(namesize==1) { // this is $; for sure
508 if(!(tmp3=__ILWS_malloc(2))) { 499 if(!(tmp3=__ILWS_malloc(2))) {
509 LWSERR(LE_MEMORY);
510 node->stat=5; 500 node->stat=5;
511 return; 501 return;
512 }; 502 };
@@ -514,7 +504,6 @@ void __ILWS_output_client(struct web_client *node) {
514 tmp3[namesize]=0; 504 tmp3[namesize]=0;
515 } else { 505 } else {
516 if(!(tmp3=__ILWS_malloc(namesize))) { 506 if(!(tmp3=__ILWS_malloc(namesize))) {
517 LWSERR(LE_MEMORY);
518 node->stat=5; 507 node->stat=5;
519 return; 508 return;
520 }; 509 };
@@ -547,7 +536,6 @@ void __ILWS_output_client(struct web_client *node) {
547 tstream->next->rsize=(beginsize+varsize); 536 tstream->next->rsize=(beginsize+varsize);
548 tstream->next->varsize+=(varsize-namesize)-1; 537 tstream->next->varsize+=(varsize-namesize)-1;
549 } else { 538 } else {
550 LWSERR(LE_MEMORY);
551 __ILWS_free(tmp3); 539 __ILWS_free(tmp3);
552 node->stat=5; 540 node->stat=5;
553 return; 541 return;
@@ -655,7 +643,6 @@ char *__ILWS_web_client_getreq() {
655 if(size<1) return NULL; 643 if(size<1) return NULL;
656 644
657 if(!(ret=__ILWS_malloc(size+1))) { 645 if(!(ret=__ILWS_malloc(size+1))) {
658 LWSERR(LE_MEMORY);
659 return NULL; 646 return NULL;
660 }; 647 };
661 memcpy(ret,current_web_client->rbuf,size); 648 memcpy(ret,current_web_client->rbuf,size);
@@ -677,7 +664,6 @@ char *__ILWS_web_client_getreqline() {
677 if(size<1) return NULL; 664 if(size<1) return NULL;
678 665
679 if(!(ret=__ILWS_malloc(size+1))) { 666 if(!(ret=__ILWS_malloc(size+1))) {
680 LWSERR(LE_MEMORY);
681 return NULL; 667 return NULL;
682 }; 668 };
683 memcpy(ret,current_web_client->rbuf,size); 669 memcpy(ret,current_web_client->rbuf,size);
@@ -704,7 +690,6 @@ int web_client_addfile(char *in) {
704 nfd=dup(fileno(stdout)); 690 nfd=dup(fileno(stdout));
705 nfile=fdopen(nfd,"wb+"); 691 nfile=fdopen(nfd,"wb+");
706 if(!__ILWS_add_outstream(current_web_client->outstream,fname,nfile,1)) { 692 if(!__ILWS_add_outstream(current_web_client->outstream,fname,nfile,1)) {
707 LWSERR(LE_MEMORY);
708 return 0; 693 return 0;
709 }; 694 };
710 }; 695 };
@@ -913,7 +898,6 @@ int web_client_delvar(char *name) {
913struct web_var *__ILWS_init_var_list() { 898struct web_var *__ILWS_init_var_list() {
914 struct web_var *ret; 899 struct web_var *ret;
915 if(!(ret=__ILWS_malloc(sizeof(struct web_var)))) { 900 if(!(ret=__ILWS_malloc(sizeof(struct web_var)))) {
916 LWSERR(LE_MEMORY);
917 return NULL; 901 return NULL;
918 }; 902 };
919 ret->name=NULL; 903 ret->name=NULL;
@@ -934,19 +918,16 @@ int __ILWS_add_var(struct web_var *list, char *name, char *value) {
934 }; 918 };
935 919
936 if(!(node->next=__ILWS_malloc(sizeof(struct web_var)))) { 920 if(!(node->next=__ILWS_malloc(sizeof(struct web_var)))) {
937 LWSERR(LE_MEMORY);
938 return 0; 921 return 0;
939 }; 922 };
940 923
941 if(!(node->next->name=__ILWS_malloc(namesize+1))) { 924 if(!(node->next->name=__ILWS_malloc(namesize+1))) {
942 LWSERR(LE_MEMORY);
943 return 0; 925 return 0;
944 }; 926 };
945 memcpy(node->next->name,name,namesize); 927 memcpy(node->next->name,name,namesize);
946 node->next->name[namesize]=0; 928 node->next->name[namesize]=0;
947 929
948 if(!(node->next->value=__ILWS_malloc(valuesize+1))) { 930 if(!(node->next->value=__ILWS_malloc(valuesize+1))) {
949 LWSERR(LE_MEMORY);
950 return 0; 931 return 0;
951 }; 932 };
952 memcpy(node->next->value,value,valuesize); 933 memcpy(node->next->value,value,valuesize);