113498266Sopenharmony_ci#ifndef HEADER_CURL_TOOL_OPERATE_H
213498266Sopenharmony_ci#define HEADER_CURL_TOOL_OPERATE_H
313498266Sopenharmony_ci/***************************************************************************
413498266Sopenharmony_ci *                                  _   _ ____  _
513498266Sopenharmony_ci *  Project                     ___| | | |  _ \| |
613498266Sopenharmony_ci *                             / __| | | | |_) | |
713498266Sopenharmony_ci *                            | (__| |_| |  _ <| |___
813498266Sopenharmony_ci *                             \___|\___/|_| \_\_____|
913498266Sopenharmony_ci *
1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
1113498266Sopenharmony_ci *
1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which
1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms
1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html.
1513498266Sopenharmony_ci *
1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell
1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is
1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file.
1913498266Sopenharmony_ci *
2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2113498266Sopenharmony_ci * KIND, either express or implied.
2213498266Sopenharmony_ci *
2313498266Sopenharmony_ci * SPDX-License-Identifier: curl
2413498266Sopenharmony_ci *
2513498266Sopenharmony_ci ***************************************************************************/
2613498266Sopenharmony_ci#include "tool_setup.h"
2713498266Sopenharmony_ci#include "tool_cb_hdr.h"
2813498266Sopenharmony_ci#include "tool_cb_prg.h"
2913498266Sopenharmony_ci#include "tool_sdecls.h"
3013498266Sopenharmony_ci
3113498266Sopenharmony_cistruct per_transfer {
3213498266Sopenharmony_ci  /* double linked */
3313498266Sopenharmony_ci  struct per_transfer *next;
3413498266Sopenharmony_ci  struct per_transfer *prev;
3513498266Sopenharmony_ci  struct OperationConfig *config; /* for this transfer */
3613498266Sopenharmony_ci  struct curl_certinfo *certinfo;
3713498266Sopenharmony_ci  CURL *curl;
3813498266Sopenharmony_ci  long retry_numretries;
3913498266Sopenharmony_ci  long retry_sleep_default;
4013498266Sopenharmony_ci  long retry_sleep;
4113498266Sopenharmony_ci  struct timeval start; /* start of this transfer */
4213498266Sopenharmony_ci  struct timeval retrystart;
4313498266Sopenharmony_ci  char *this_url;
4413498266Sopenharmony_ci  unsigned int urlnum; /* the index of the given URL */
4513498266Sopenharmony_ci  char *outfile;
4613498266Sopenharmony_ci  bool infdopen; /* TRUE if infd needs closing */
4713498266Sopenharmony_ci  int infd;
4813498266Sopenharmony_ci  bool noprogress;
4913498266Sopenharmony_ci  struct ProgressData progressbar;
5013498266Sopenharmony_ci  struct OutStruct outs;
5113498266Sopenharmony_ci  struct OutStruct heads;
5213498266Sopenharmony_ci  struct OutStruct etag_save;
5313498266Sopenharmony_ci  struct HdrCbData hdrcbdata;
5413498266Sopenharmony_ci  long num_headers;
5513498266Sopenharmony_ci  bool was_last_header_empty;
5613498266Sopenharmony_ci
5713498266Sopenharmony_ci  bool added; /* set TRUE when added to the multi handle */
5813498266Sopenharmony_ci  time_t startat; /* when doing parallel transfers, this is a retry transfer
5913498266Sopenharmony_ci                     that has been set to sleep until this time before it
6013498266Sopenharmony_ci                     should get started (again) */
6113498266Sopenharmony_ci  bool abort; /* when doing parallel transfers and this is TRUE then a critical
6213498266Sopenharmony_ci                 error (eg --fail-early) has occurred in another transfer and
6313498266Sopenharmony_ci                 this transfer will be aborted in the progress callback */
6413498266Sopenharmony_ci
6513498266Sopenharmony_ci  /* for parallel progress bar */
6613498266Sopenharmony_ci  curl_off_t dltotal;
6713498266Sopenharmony_ci  curl_off_t dlnow;
6813498266Sopenharmony_ci  curl_off_t ultotal;
6913498266Sopenharmony_ci  curl_off_t ulnow;
7013498266Sopenharmony_ci  curl_off_t uploadfilesize; /* expected total amount */
7113498266Sopenharmony_ci  curl_off_t uploadedsofar; /* amount delivered from the callback */
7213498266Sopenharmony_ci  bool dltotal_added; /* if the total has been added from this */
7313498266Sopenharmony_ci  bool ultotal_added;
7413498266Sopenharmony_ci
7513498266Sopenharmony_ci  /* NULL or malloced */
7613498266Sopenharmony_ci  char *uploadfile;
7713498266Sopenharmony_ci  char *errorbuffer; /* allocated and assigned while this is used for a
7813498266Sopenharmony_ci                        transfer */
7913498266Sopenharmony_ci};
8013498266Sopenharmony_ci
8113498266Sopenharmony_ciCURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[]);
8213498266Sopenharmony_civoid single_transfer_cleanup(struct OperationConfig *config);
8313498266Sopenharmony_ci
8413498266Sopenharmony_ciextern struct per_transfer *transfers; /* first node */
8513498266Sopenharmony_ci
8613498266Sopenharmony_ci#endif /* HEADER_CURL_TOOL_OPERATE_H */
87