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
45fdb481
Commit
45fdb481
authored
24 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
uses Curl_read() and Curl_write()
unfolded telwrite() instead of being a separate single function
parent
3fcc9677
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
lib/telnet.c
+40
-77
40 additions, 77 deletions
lib/telnet.c
with
40 additions
and
77 deletions
lib/telnet.c
+
40
−
77
View file @
45fdb481
...
...
@@ -73,8 +73,6 @@
#include
<curl/curl.h>
#include
"transfer.h"
#include
"sendf.h"
#include
"formdata.h"
#include
"progress.h"
#define _MPRINTF_REPLACE
/* use our functions only */
#include
<curl/mprintf.h>
...
...
@@ -97,11 +95,6 @@
#define SB_EOF() (subpointer >= subend)
#define SB_LEN() (subend - subpointer)
static
void
telwrite
(
struct
UrlData
*
data
,
unsigned
char
*
buffer
,
/* Data to write */
int
count
);
/* Number of bytes to write */
static
void
telrcv
(
struct
UrlData
*
data
,
unsigned
char
*
inbuf
,
/* Data received from socket */
...
...
@@ -826,36 +819,6 @@ void telrcv(struct UrlData *data,
}
}
static
void
telwrite
(
struct
UrlData
*
data
,
unsigned
char
*
buffer
,
/* Data to write */
int
count
)
/* Number of bytes to write */
{
unsigned
char
outbuf
[
2
];
int
out_count
=
0
;
int
bytes_written
;
while
(
count
--
)
{
outbuf
[
0
]
=
*
buffer
++
;
out_count
=
1
;
if
(
outbuf
[
0
]
==
IAC
)
outbuf
[
out_count
++
]
=
IAC
;
#ifndef USE_SSLEAY
bytes_written
=
swrite
(
data
->
firstsocket
,
outbuf
,
out_count
);
#else
if
(
data
->
ssl
.
use
)
{
bytes_written
=
SSL_write
(
data
->
ssl
.
handle
,
(
char
*
)
outbuf
,
out_count
);
}
else
{
bytes_written
=
swrite
(
data
->
firstsocket
,
outbuf
,
out_count
);
}
#endif
/* USE_SSLEAY */
}
}
CURLcode
Curl_telnet_done
(
struct
connectdata
*
conn
)
{
return
CURLE_OK
;
...
...
@@ -870,7 +833,7 @@ CURLcode Curl_telnet(struct connectdata *conn)
bool
keepon
=
TRUE
;
char
*
buf
=
data
->
buffer
;
in
t
nread
;
size_
t
nread
;
init_telnet
(
data
);
...
...
@@ -880,49 +843,49 @@ CURLcode Curl_telnet(struct connectdata *conn)
keepfd
=
readfd
;
while
(
keepon
)
{
readfd
=
keepfd
;
/* set this every lap in the loop */
while
(
keepon
)
{
readfd
=
keepfd
;
/* set this every lap in the loop */
switch
(
select
(
sockfd
+
1
,
&
readfd
,
NULL
,
NULL
,
NULL
))
{
case
-
1
:
/* error, stop reading */
keepon
=
FALSE
;
continue
;
case
0
:
/* timeout */
break
;
default:
/* read! */
if
(
FD_ISSET
(
1
,
&
readfd
))
{
nread
=
read
(
1
,
buf
,
255
);
telwrite
(
data
,
(
unsigned
char
*
)
buf
,
nread
);
}
if
(
FD_ISSET
(
sockfd
,
&
readfd
))
{
#ifndef USE_SSLEAY
nread
=
sread
(
sockfd
,
buf
,
BUFSIZE
-
1
);
#else
if
(
data
->
ssl
.
use
)
{
nread
=
SSL_read
(
data
->
ssl
.
handle
,
buf
,
BUFSIZE
-
1
);
}
else
{
nread
=
sread
(
sockfd
,
buf
,
BUFSIZE
-
1
);
}
#endif
/* USE_SSLEAY */
}
switch
(
select
(
sockfd
+
1
,
&
readfd
,
NULL
,
NULL
,
NULL
))
{
case
-
1
:
/* error, stop reading */
keepon
=
FALSE
;
continue
;
case
0
:
/* timeout */
break
;
default:
/* read! */
if
(
FD_ISSET
(
1
,
&
readfd
))
{
/* read from stdin */
unsigned
char
outbuf
[
2
];
int
out_count
=
0
;
size_t
bytes_written
;
char
*
buffer
=
buf
;
nread
=
read
(
1
,
buf
,
255
);
while
(
nread
--
)
{
outbuf
[
0
]
=
*
buffer
++
;
out_count
=
1
;
if
(
outbuf
[
0
]
==
IAC
)
outbuf
[
out_count
++
]
=
IAC
;
Curl_write
(
conn
,
data
->
firstsocket
,
outbuf
,
out_count
,
&
bytes_written
);
}
}
/* if we receive 0 or less here, the server closed the connection and
we bail out from this! */
if
(
nread
<=
0
)
{
keepon
=
FALSE
;
break
;
}
if
(
FD_ISSET
(
sockfd
,
&
readfd
))
Curl_read
(
conn
,
sockfd
,
buf
,
BUFSIZE
-
1
,
&
nread
);
telrcv
(
data
,
(
unsigned
char
*
)
buf
,
nread
);
/* if we receive 0 or less here, the server closed the connection and
we bail out from this! */
if
(
nread
<=
0
)
{
keepon
=
FALSE
;
break
;
}
}
return
CURLE_OK
;
telrcv
(
data
,
(
unsigned
char
*
)
buf
,
nread
);
}
}
return
CURLE_OK
;
}
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