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
c35d05aa
Commit
c35d05aa
authored
11 years ago
by
Steve Holme
Browse files
Options
Downloads
Patches
Plain Diff
tool_operate: Moved command line argument parsing into separate function
parent
8034b08e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/tool_getparam.c
+44
-0
44 additions, 0 deletions
src/tool_getparam.c
src/tool_getparam.h
+4
-1
4 additions, 1 deletion
src/tool_getparam.h
src/tool_operate.c
+8
-39
8 additions, 39 deletions
src/tool_operate.c
with
56 additions
and
40 deletions
src/tool_getparam.c
+
44
−
0
View file @
c35d05aa
...
...
@@ -1847,3 +1847,47 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
return
PARAM_OK
;
}
ParameterError
parse_args
(
struct
Configurable
*
config
,
int
argc
,
argv_item_t
argv
[])
{
int
i
;
bool
stillflags
;
char
*
orig_opt
;
ParameterError
result
=
PARAM_OK
;
for
(
i
=
1
,
stillflags
=
TRUE
;
i
<
argc
&&
!
result
;
i
++
)
{
orig_opt
=
argv
[
i
];
if
(
stillflags
&&
(
'-'
==
argv
[
i
][
0
]))
{
char
*
nextarg
;
bool
passarg
;
char
*
flag
=
argv
[
i
];
if
(
curlx_strequal
(
"--"
,
argv
[
i
]))
/* This indicates the end of the flags and thus enables the
following (URL) argument to start with -. */
stillflags
=
FALSE
;
else
{
nextarg
=
(
i
<
(
argc
-
1
))
?
argv
[
i
+
1
]
:
NULL
;
result
=
getparameter
(
flag
,
nextarg
,
&
passarg
,
config
);
if
(
!
result
&&
passarg
)
i
++
;
/* we're supposed to skip this */
}
}
else
{
bool
used
;
/* Just add the URL please */
result
=
getparameter
((
char
*
)
"--url"
,
argv
[
i
],
&
used
,
config
);
}
}
if
(
result
&&
result
!=
PARAM_HELP_REQUESTED
)
{
const
char
*
reason
=
param2text
(
result
);
helpf
(
config
->
errors
,
"option %s: %s
\n
"
,
orig_opt
,
reason
);
}
return
result
;
}
This diff is collapsed.
Click to expand it.
src/tool_getparam.h
+
4
−
1
View file @
c35d05aa
...
...
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 201
2
, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 201
4
, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
...
...
@@ -51,5 +51,8 @@ void parse_cert_parameter(const char *cert_parameter,
char
**
passphrase
);
#endif
ParameterError
parse_args
(
struct
Configurable
*
config
,
int
argc
,
argv_item_t
argv
[]);
#endif
/* HEADER_CURL_TOOL_GETPARAM_H */
This diff is collapsed.
Click to expand it.
src/tool_operate.c
+
8
−
39
View file @
c35d05aa
...
...
@@ -199,9 +199,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
CURL
*
curl
=
NULL
;
char
*
httpgetfields
=
NULL
;
bool
stillflags
;
int
res
=
0
;
int
i
;
unsigned
long
li
;
bool
orig_noprogress
;
...
...
@@ -251,44 +249,15 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
}
}
/* Parse options */
for
(
i
=
1
,
stillflags
=
TRUE
;
i
<
argc
;
i
++
)
{
char
*
orig_opt
=
argv
[
i
];
if
(
stillflags
&&
(
'-'
==
argv
[
i
][
0
]))
{
char
*
nextarg
;
bool
passarg
;
char
*
flag
=
argv
[
i
];
if
(
curlx_strequal
(
"--"
,
argv
[
i
]))
/* this indicates the end of the flags and thus enables the
following (URL) argument to start with -. */
stillflags
=
FALSE
;
else
{
nextarg
=
(
i
<
(
argc
-
1
))
?
argv
[
i
+
1
]
:
NULL
;
res
=
getparameter
(
flag
,
nextarg
,
&
passarg
,
config
);
if
(
!
res
&&
passarg
)
/* we're supposed to skip this */
i
++
;
}
}
else
{
bool
used
;
/* just add the URL please */
res
=
getparameter
((
char
*
)
"--url"
,
argv
[
i
],
&
used
,
config
);
}
/* Parse the command line arguments */
res
=
parse_args
(
config
,
argc
,
argv
);
if
(
res
)
{
if
(
res
!=
PARAM_HELP_REQUESTED
)
res
=
CURLE_FAILED_INIT
;
else
res
=
CURLE_OK
;
if
(
res
)
{
int
retval
=
CURLE_OK
;
if
(
res
!=
PARAM_HELP_REQUESTED
)
{
const
char
*
reason
=
param2text
(
res
);
helpf
(
config
->
errors
,
"option %s: %s
\n
"
,
orig_opt
,
reason
);
retval
=
CURLE_FAILED_INIT
;
}
res
=
retval
;
goto
quit_curl
;
}
goto
quit_curl
;
}
if
(
config
->
userpwd
&&
!
config
->
xoauth2_bearer
)
{
...
...
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