tool_sdecls.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #ifndef HEADER_CURL_TOOL_SDECLS_H
  2. #define HEADER_CURL_TOOL_SDECLS_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. #include "tool_setup.h"
  27. /*
  28. * OutStruct variables keep track of information relative to curl's
  29. * output writing, which may take place to a standard stream or a file.
  30. *
  31. * 'filename' member is either a pointer to a filename string or NULL
  32. * when dealing with a standard stream.
  33. *
  34. * 'alloc_filename' member is TRUE when string pointed by 'filename' has been
  35. * dynamically allocated and 'belongs' to this OutStruct, otherwise FALSE.
  36. *
  37. * 'is_cd_filename' member is TRUE when string pointed by 'filename' has been
  38. * set using a server-specified Content-Disposition filename, otherwise FALSE.
  39. *
  40. * 's_isreg' member is TRUE when output goes to a regular file, this also
  41. * implies that output is 'seekable' and 'appendable' and also that member
  42. * 'filename' points to filename's string. For any standard stream member
  43. * 's_isreg' will be FALSE.
  44. *
  45. * 'fopened' member is TRUE when output goes to a regular file and it
  46. * has been fopen'ed, requiring it to be closed later on. In any other
  47. * case this is FALSE.
  48. *
  49. * 'stream' member is a pointer to a stream controlling object as returned
  50. * from a 'fopen' call or a standard stream.
  51. *
  52. * 'config' member is a pointer to associated 'OperationConfig' struct.
  53. *
  54. * 'bytes' member represents amount written so far.
  55. *
  56. * 'init' member holds original file size or offset at which truncation is
  57. * taking place. Always zero unless appending to a non-empty regular file.
  58. *
  59. * [Windows]
  60. * 'utf8seq' member holds an incomplete UTF-8 sequence destined for the console
  61. * until it can be completed (1-4 bytes) + NUL.
  62. */
  63. struct OutStruct {
  64. char *filename;
  65. bool alloc_filename;
  66. bool is_cd_filename;
  67. bool s_isreg;
  68. bool fopened;
  69. FILE *stream;
  70. curl_off_t bytes;
  71. curl_off_t init;
  72. #ifdef _WIN32
  73. unsigned char utf8seq[5];
  74. #endif
  75. };
  76. /*
  77. * A linked list of these 'getout' nodes contain URL's to fetch,
  78. * as well as information relative to where URL contents should
  79. * be stored or which file should be uploaded.
  80. */
  81. struct getout {
  82. struct getout *next; /* next one */
  83. char *url; /* the URL we deal with */
  84. char *outfile; /* where to store the output */
  85. char *infile; /* file to upload, if GETOUT_UPLOAD is set */
  86. int flags; /* options - composed of GETOUT_* bits */
  87. int num; /* which URL number in an invocation */
  88. };
  89. #define GETOUT_OUTFILE (1<<0) /* set when outfile is deemed done */
  90. #define GETOUT_URL (1<<1) /* set when URL is deemed done */
  91. #define GETOUT_USEREMOTE (1<<2) /* use remote filename locally */
  92. #define GETOUT_UPLOAD (1<<3) /* if set, -T has been used */
  93. #define GETOUT_NOUPLOAD (1<<4) /* if set, -T "" has been used */
  94. /*
  95. * 'trace' enumeration represents curl's output look'n feel possibilities.
  96. */
  97. typedef enum {
  98. TRACE_NONE, /* no trace/verbose output at all */
  99. TRACE_BIN, /* tcpdump inspired look */
  100. TRACE_ASCII, /* like *BIN but without the hex output */
  101. TRACE_PLAIN /* -v/--verbose type */
  102. } trace;
  103. /*
  104. * 'HttpReq' enumeration represents HTTP request types.
  105. */
  106. typedef enum {
  107. HTTPREQ_UNSPEC, /* first in list */
  108. HTTPREQ_GET,
  109. HTTPREQ_HEAD,
  110. HTTPREQ_MIMEPOST,
  111. HTTPREQ_SIMPLEPOST,
  112. HTTPREQ_PUT
  113. } HttpReq;
  114. /*
  115. * Complete struct declarations which have OperationConfig struct members,
  116. * just in case this header is directly included in some source file.
  117. */
  118. #include "tool_cfgable.h"
  119. #endif /* HEADER_CURL_TOOL_SDECLS_H */