Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
25e98179
Commit
25e98179
authored
21 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
Gisle Vanem: patches to make sws.c compile under MingW/MSVC is
attached. And some cosmetic fixes.
parent
78ebe3fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/server/sws.c
+49
-24
49 additions, 24 deletions
tests/server/sws.c
with
49 additions
and
24 deletions
tests/server/sws.c
+
49
−
24
View file @
25e98179
...
...
@@ -33,11 +33,14 @@
#include
<stdlib.h>
#include
<string.h>
#include
<stdarg.h>
#include
<unistd.h>
#include
<signal.h>
#include
<time.h>
#include
<sys/time.h>
#include
<sys/types.h>
#ifdef HAVE_UNISTD_H
#include
<unistd.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include
<sys/socket.h>
#endif
...
...
@@ -61,14 +64,23 @@
#define TRUE 1
#endif
#if defined(WIN32) && !defined(__
GNUC__) || defined(__MINGW32
__)
#if defined(WIN32) && !defined(__
CYGWIN
__)
#include
<windows.h>
#include
<winsock2.h>
#include
<process.h>
#define sleep(sec) Sleep ((sec)*1000)
#ifdef _MSC_VER
#define strncasecmp strnicmp
#endif
#define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EISCONN WSAEISCONN
#define ENOTSOCK WSAENOTSOCK
#define ECONNREFUSED WSAECONNREFUSED
static
void
win32_cleanup
(
void
);
#endif
#define REQBUFSIZ 150000
...
...
@@ -118,6 +130,8 @@ void storerequest(char *reqbuf);
#define CMD_AUTH_REQUIRED "auth_required"
#define END_OF_HEADERS "\r\n\r\n"
/* global variable, where to find the 'data' dir */
const
char
*
path
=
"."
;
...
...
@@ -134,25 +148,22 @@ enum {
/* sent as reply to a QUIT */
static
const
char
*
docquit
=
"HTTP/1.1 200 Goodbye
\r\n
"
"
\r\n
"
;
"HTTP/1.1 200 Goodbye"
END_OF_HEADERS
;
/* sent as reply to a CONNECT */
static
const
char
*
docconnect
=
"HTTP/1.1 200 Mighty fine indeed
\r\n
"
"
\r\n
"
;
"HTTP/1.1 200 Mighty fine indeed"
END_OF_HEADERS
;
/* sent as reply to a "bad" CONNECT */
static
const
char
*
docbadconnect
=
"HTTP/1.1 501 Forbidden you fool
\r\n
"
"
\r\n
"
;
"HTTP/1.1 501 Forbidden you fool"
END_OF_HEADERS
;
/* send back this on 404 file not found */
static
const
char
*
doc404
=
"HTTP/1.1 404 Not Found
\n
"
"Server: "
SWSVERSION
"
\n
"
"Connection: close
\n
"
"Content-Type: text/html
\n
"
"
\n
"
static
const
char
*
doc404
=
"HTTP/1.1 404 Not Found
\
r\
n
"
"Server: "
SWSVERSION
"
\
r\
n
"
"Connection: close
\
r\
n
"
"Content-Type: text/html"
END_OF_HEADERS
"<!DOCTYPE HTML PUBLIC
\"
-//IETF//DTD HTML 2.0//EN
\"
>
\n
"
"<HTML><HEAD>
\n
"
"<TITLE>404 Not Found</TITLE>
\n
"
...
...
@@ -162,7 +173,7 @@ static const char *doc404 = "HTTP/1.1 404 Not Found\n"
"<P><HR><ADDRESS>"
SWSVERSION
"</ADDRESS>
\n
"
"</BODY></HTML>
\n
"
;
#ifdef SIGPIPE
static
volatile
int
sigpipe
;
static
volatile
int
sigpipe
;
/* Why? It's not used */
#endif
static
void
logmsg
(
const
char
*
msg
,
...)
...
...
@@ -197,7 +208,23 @@ static void sigpipe_handler(int sig)
}
#endif
#define END_OF_HEADERS "\r\n\r\n"
#if defined(WIN32) && !defined(__CYGWIN__)
#undef perror
#define perror(m) win32_perror(m)
static
void
win32_perror
(
const
char
*
msg
)
{
char
buf
[
256
];
DWORD
err
=
WSAGetLastError
();
if
(
!
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
err
,
LANG_NEUTRAL
,
buf
,
sizeof
(
buf
),
NULL
))
snprintf
(
buf
,
sizeof
(
buf
),
"Unknown error %lu (%#lx)"
,
err
,
err
);
if
(
msg
)
fprintf
(
stderr
,
"%s: "
,
msg
);
fprintf
(
stderr
,
"%s
\n
"
,
buf
);
}
#endif
static
char
*
test2file
(
int
testno
)
{
...
...
@@ -267,7 +294,7 @@ int ProcessRequest(struct httprequest *req)
else
req
->
partno
=
0
;
sprintf
(
logbuf
,
"Reqested test number %ld part %ld"
,
sprintf
(
logbuf
,
"Req
u
ested test number %ld part %ld"
,
req
->
testno
,
req
->
partno
);
logmsg
(
logbuf
);
...
...
@@ -577,7 +604,7 @@ static int send_doc(int sock, struct httprequest *req)
client... */
if
(
strstr
(
buffer
,
"swsclose"
)
||
!
count
)
{
persistant
=
FALSE
;
logmsg
(
"connection close instruction swsclose found in response"
);
logmsg
(
"connection close instruction
\"
swsclose
\"
found in response"
);
}
if
(
strstr
(
buffer
,
"swsbounce"
))
{
prevbounce
=
TRUE
;
...
...
@@ -635,7 +662,7 @@ static int send_doc(int sock, struct httprequest *req)
return
0
;
}
#if defined(WIN32) && !defined(__
GNUC__) || defined(__MINGW32
__)
#if defined(WIN32) && !defined(__
CYGWIN
__)
static
void
win32_init
(
void
)
{
WORD
wVersionRequested
;
...
...
@@ -647,7 +674,7 @@ static void win32_init(void)
if
(
err
!=
0
)
{
perror
(
"Winsock init failed"
);
logmsg
(
"Error initiali
z
ing winsock -- aborting
\n
"
);
logmsg
(
"Error initiali
s
ing winsock -- aborting
\n
"
);
exit
(
1
);
}
...
...
@@ -684,7 +711,8 @@ int main(int argc, char *argv[])
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
win32_init
();
#endif
atexit
(
win32_cleanup
);
#else
#ifdef SIGPIPE
#ifdef HAVE_SIGNAL
...
...
@@ -693,6 +721,7 @@ int main(int argc, char *argv[])
#ifdef HAVE_SIGINTERRUPT
siginterrupt
(
SIGPIPE
,
1
);
#endif
#endif
#endif
sock
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
...
...
@@ -776,10 +805,6 @@ int main(int argc, char *argv[])
sclose
(
sock
);
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
win32_cleanup
();
#endif
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment