4040#include "tool_msgs.h"
4141#include "tool_paramhlp.h"
4242#include "tool_parsecfg.h"
43+ #include "tool_main.h"
4344
4445#include "memdebug.h" /* keep this as LAST include */
4546
@@ -316,6 +317,8 @@ static const struct LongShort aliases[]= {
316317 {"Y" , "speed-limit" , ARG_STRING },
317318 {"y" , "speed-time" , ARG_STRING },
318319 {"z" , "time-cond" , ARG_STRING },
320+ {"Z" , "parallel" , ARG_BOOL },
321+ {"Zb" , "parallel-max" , ARG_STRING },
319322 {"#" , "progress-bar" , ARG_BOOL },
320323 {":" , "next" , ARG_NONE },
321324};
@@ -1104,7 +1107,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
11041107 break ;
11051108 case 'L' : /* --test-event */
11061109#ifdef CURLDEBUG
1107- config -> test_event_based = toggle ;
1110+ global -> test_event_based = toggle ;
11081111#else
11091112 warnf (global , "--test-event is ignored unless a debug build!\n" );
11101113#endif
@@ -1356,7 +1359,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
13561359 size = 0 ;
13571360 }
13581361 else {
1359- char * enc = curl_easy_escape (config -> easy , postdata , (int )size );
1362+ char * enc = curl_easy_escape (NULL , postdata , (int )size );
13601363 Curl_safefree (postdata ); /* no matter if it worked or not */
13611364 if (enc ) {
13621365 /* now make a string with the name from above and append the
@@ -2127,6 +2130,21 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
21272130 if (!config -> low_speed_time )
21282131 config -> low_speed_time = 30 ;
21292132 break ;
2133+ case 'Z' :
2134+ switch (subletter ) {
2135+ case '\0' : /* --parallel */
2136+ global -> parallel = toggle ;
2137+ break ;
2138+ case 'b' : /* --parallel-max */
2139+ err = str2unum (& global -> parallel_max , nextarg );
2140+ if (err )
2141+ return err ;
2142+ if ((global -> parallel_max > MAX_PARALLEL ) ||
2143+ (global -> parallel_max < 1 ))
2144+ global -> parallel_max = PARALLEL_DEFAULT ;
2145+ break ;
2146+ }
2147+ break ;
21302148 case 'z' : /* time condition coming up */
21312149 switch (* nextarg ) {
21322150 case '+' :
@@ -2176,14 +2194,14 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
21762194 return PARAM_OK ;
21772195}
21782196
2179- ParameterError parse_args (struct GlobalConfig * config , int argc ,
2197+ ParameterError parse_args (struct GlobalConfig * global , int argc ,
21802198 argv_item_t argv [])
21812199{
21822200 int i ;
21832201 bool stillflags ;
21842202 char * orig_opt = NULL ;
21852203 ParameterError result = PARAM_OK ;
2186- struct OperationConfig * operation = config -> first ;
2204+ struct OperationConfig * config = global -> first ;
21872205
21882206 for (i = 1 , stillflags = TRUE; i < argc && !result ; i ++ ) {
21892207 orig_opt = argv [i ];
@@ -2199,31 +2217,28 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
21992217 else {
22002218 char * nextarg = (i < (argc - 1 )) ? argv [i + 1 ] : NULL ;
22012219
2202- result = getparameter (flag , nextarg , & passarg , config , operation );
2220+ result = getparameter (flag , nextarg , & passarg , global , config );
22032221 if (result == PARAM_NEXT_OPERATION ) {
22042222 /* Reset result as PARAM_NEXT_OPERATION is only used here and not
22052223 returned from this function */
22062224 result = PARAM_OK ;
22072225
2208- if (operation -> url_list && operation -> url_list -> url ) {
2226+ if (config -> url_list && config -> url_list -> url ) {
22092227 /* Allocate the next config */
2210- operation -> next = malloc (sizeof (struct OperationConfig ));
2211- if (operation -> next ) {
2228+ config -> next = malloc (sizeof (struct OperationConfig ));
2229+ if (config -> next ) {
22122230 /* Initialise the newly created config */
2213- config_init (operation -> next );
2214-
2215- /* Copy the easy handle */
2216- operation -> next -> easy = config -> easy ;
2231+ config_init (config -> next );
22172232
22182233 /* Set the global config pointer */
2219- operation -> next -> global = config ;
2234+ config -> next -> global = global ;
22202235
2221- /* Update the last operation pointer */
2222- config -> last = operation -> next ;
2236+ /* Update the last config pointer */
2237+ global -> last = config -> next ;
22232238
22242239 /* Move onto the new config */
2225- operation -> next -> prev = operation ;
2226- operation = operation -> next ;
2240+ config -> next -> prev = config ;
2241+ config = config -> next ;
22272242 }
22282243 else
22292244 result = PARAM_NO_MEM ;
@@ -2237,8 +2252,8 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
22372252 bool used ;
22382253
22392254 /* Just add the URL please */
2240- result = getparameter ((char * )"--url" , argv [i ], & used , config ,
2241- operation );
2255+ result = getparameter ((char * )"--url" , argv [i ], & used , global ,
2256+ config );
22422257 }
22432258 }
22442259
@@ -2249,9 +2264,9 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
22492264 const char * reason = param2text (result );
22502265
22512266 if (orig_opt && strcmp (":" , orig_opt ))
2252- helpf (config -> errors , "option %s: %s\n" , orig_opt , reason );
2267+ helpf (global -> errors , "option %s: %s\n" , orig_opt , reason );
22532268 else
2254- helpf (config -> errors , "%s\n" , reason );
2269+ helpf (global -> errors , "%s\n" , reason );
22552270 }
22562271
22572272 return result ;
0 commit comments