summaryrefslogtreecommitdiff
path: root/src/htsserver.h
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2012-03-19 12:57:43 +0000
committerXavier Roche <xroche@users.noreply.github.com>2012-03-19 12:57:43 +0000
commit64cc4a88da8887ef1f7f4d90be0158d2cc76222d (patch)
treee72af709fbce8bc495f51e7f0518de9a9a2c3b7f /src/htsserver.h
parent844ecc37072d515513177c65a8c9dc35c9cdfc1a (diff)
httrack 3.40.4
Diffstat (limited to 'src/htsserver.h')
-rw-r--r--src/htsserver.h52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/htsserver.h b/src/htsserver.h
index acac908..9a633cb 100644
--- a/src/htsserver.h
+++ b/src/htsserver.h
@@ -39,7 +39,7 @@ Please visit our Website: http://www.httrack.com
#ifndef HTS_SERVER_DEFH
#define HTS_SERVER_DEFH
-#include "htsbasenet.h"
+#include "htsnet.h"
/* String */
#include "htsstrings.h"
@@ -47,7 +47,7 @@ Please visit our Website: http://www.httrack.com
// Fonctions
void socinput(T_SOC soc,char* s,int max);
-T_SOC smallserver_init_std(int* port_prox,char* adr_prox);
+T_SOC smallserver_init_std(int* port_prox,char* adr_prox,int defaultPort);
T_SOC smallserver_init(int* port,char* adr);
int smallserver(T_SOC soc,char* url,char* method,char* data, char* path);
@@ -116,7 +116,53 @@ static int linput_trim(FILE* fp,char* s,int max);
static char* concat(const char* a,const char* b);
static int fexist(char* s);
static int linput(FILE* fp,char* s,int max);
-static int linputsoc_t(T_SOC soc, char* s, int max, int timeout);
+
+static int linputsoc(T_SOC soc, char* s, int max) {
+ int c;
+ int j=0;
+ do {
+ unsigned char ch;
+ if (recv(soc, &ch, 1, 0) == 1) {
+ c = ch;
+ } else {
+ c = EOF;
+ }
+ if (c!=EOF) {
+ switch(c) {
+ case 13: break; // sauter CR
+ case 10: c=-1; break;
+ case 9: case 12: break; // sauter ces caractères
+ default: s[j++]=(char) c; break;
+ }
+ }
+ } while((c!=-1) && (c!=EOF) && (j<(max-1)));
+ s[j]='\0';
+ return j;
+}
+
+static int check_readinput_t(T_SOC soc, int timeout) {
+ if (soc != INVALID_SOCKET) {
+ fd_set fds; // poll structures
+ struct timeval tv; // structure for select
+ FD_ZERO(&fds);
+ FD_SET(soc,&fds);
+ tv.tv_sec=timeout;
+ tv.tv_usec=0;
+ select(soc + 1,&fds,NULL,NULL,&tv);
+ if (FD_ISSET(soc,&fds))
+ return 1;
+ else
+ return 0;
+ } else
+ return 0;
+}
+
+static int linputsoc_t(T_SOC soc, char* s, int max, int timeout) {
+ if (check_readinput_t(soc, timeout)) {
+ return linputsoc(soc, s, max);
+ }
+ return -1;
+}
static char* gethomedir(void) {
char* home = getenv( "HOME" );