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
d073ec0a
Commit
d073ec0a
authored
25 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
Supports the -w/--write-out feature
parent
b61b1180
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/writeout.c
+143
-0
143 additions, 0 deletions
lib/writeout.c
lib/writeout.h
+43
-0
43 additions, 0 deletions
lib/writeout.h
with
186 additions
and
0 deletions
lib/writeout.c
0 → 100644
+
143
−
0
View file @
d073ec0a
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Curl.
*
* The Initial Developer of the Original Code is Daniel Stenberg.
*
* Portions created by the Initial Developer are Copyright (C) 1999.
* All Rights Reserved.
*
* ------------------------------------------------------------
* Main author:
* - Daniel Stenberg <Daniel.Stenberg@haxx.nu>
*
* http://curl.haxx.nu
*
* $Source$
* $Revision$
* $Date$
* $Author$
* $State$
* $Locker$
*
* ------------------------------------------------------------
****************************************************************************/
#include
<stdio.h>
#include
<string.h>
#include
"writeout.h"
typedef
enum
{
VAR_NONE
,
/* must be the first */
VAR_TOTAL_TIME
,
VAR_SIZE_DOWNLOAD
,
VAR_SIZE_UPLOAD
,
VAR_SPEED_DOWNLOAD
,
VAR_SPEED_UPLOAD
,
VAR_NUM_OF_VARS
/* must be the last */
}
replaceid
;
struct
variable
{
char
*
name
;
replaceid
id
;
};
static
struct
variable
replacements
[]
=
{
{
"total_time"
,
VAR_TOTAL_TIME
},
{
"size_download"
,
VAR_SIZE_DOWNLOAD
},
{
"size_upload"
,
VAR_SIZE_UPLOAD
},
{
"speed_download"
,
VAR_SPEED_DOWNLOAD
},
{
"speed_upload"
,
VAR_SPEED_UPLOAD
},
{
NULL
}
};
void
WriteOut
(
struct
UrlData
*
data
)
{
FILE
*
stream
=
stdout
;
char
*
ptr
=
data
->
writeinfo
;
while
(
*
ptr
)
{
if
(
'%'
==
*
ptr
)
{
if
(
'%'
==
ptr
[
1
])
{
/* an escaped %-letter */
fputc
(
'%'
,
stream
);
ptr
+=
2
;
}
else
{
/* this is meant as a variable to output */
char
*
end
;
int
i
;
if
((
'{'
==
ptr
[
1
])
&&
(
end
=
strchr
(
ptr
,
'}'
)))
{
ptr
+=
2
;
/* pass the % and the { */
*
end
=
0
;
/* zero terminate */
for
(
i
=
0
;
replacements
[
i
].
name
;
i
++
)
{
if
(
strequal
(
ptr
,
replacements
[
i
].
name
))
{
switch
(
replacements
[
i
].
id
)
{
case
VAR_TOTAL_TIME
:
fprintf
(
stream
,
"%.3f"
,
data
->
progress
.
timespent
);
break
;
case
VAR_SIZE_UPLOAD
:
fprintf
(
stream
,
"%.0f"
,
data
->
progress
.
uploaded
);
break
;
case
VAR_SIZE_DOWNLOAD
:
fprintf
(
stream
,
"%.0f"
,
data
->
progress
.
downloaded
);
break
;
case
VAR_SPEED_DOWNLOAD
:
fprintf
(
stream
,
"%.2f"
,
data
->
progress
.
dlspeed
);
break
;
case
VAR_SPEED_UPLOAD
:
fprintf
(
stream
,
"%.2f"
,
data
->
progress
.
ulspeed
);
break
;
}
break
;
}
}
ptr
=
end
+
1
;
/* pass the end */
}
else
{
/* illegal syntax, then just output the characters that are used */
fputc
(
'%'
,
stream
);
fputc
(
ptr
[
1
],
stream
);
ptr
+=
2
;
}
}
}
else
if
(
'\\'
==
*
ptr
)
{
switch
(
ptr
[
1
])
{
case
'n'
:
fputc
(
'\n'
,
stream
);
break
;
case
't'
:
fputc
(
'\t'
,
stream
);
break
;
default:
/* unknown, just output this */
fputc
(
*
ptr
,
stream
);
fputc
(
ptr
[
1
],
stream
);
break
;
}
ptr
+=
2
;
}
else
{
fputc
(
*
ptr
,
stream
);
ptr
++
;
}
}
}
This diff is collapsed.
Click to expand it.
lib/writeout.h
0 → 100644
+
43
−
0
View file @
d073ec0a
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Curl.
*
* The Initial Developer of the Original Code is Daniel Stenberg.
*
* Portions created by the Initial Developer are Copyright (C) 1999.
* All Rights Reserved.
*
* ------------------------------------------------------------
* Main author:
* - Daniel Stenberg <Daniel.Stenberg@haxx.nu>
*
* http://curl.haxx.nu
*
* $Source$
* $Revision$
* $Date$
* $Author$
* $State$
* $Locker$
*
* ------------------------------------------------------------
****************************************************************************/
#include
"urldata.h"
void
WriteOut
(
struct
UrlData
*
data
);
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