tool_sdecls.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 file name 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 file name'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. */
  60. struct OutStruct {
  61. char *filename;
  62. bool alloc_filename;
  63. bool is_cd_filename;
  64. bool s_isreg;
  65. bool fopened;
  66. FILE *stream;
  67. curl_off_t bytes;
  68. curl_off_t init;
  69. };
  70. /*
  71. * InStruct variables keep track of information relative to curl's
  72. * input reading, which may take place from stdin or from some file.
  73. *
  74. * 'fd' member is either 'stdin' file descriptor number STDIN_FILENO
  75. * or a file descriptor as returned from an 'open' call for some file.
  76. *
  77. * 'config' member is a pointer to associated 'OperationConfig' struct.
  78. */
  79. struct InStruct {
  80. int fd;
  81. struct OperationConfig *config;
  82. struct per_transfer *per;
  83. };
  84. /*
  85. * A linked list of these 'getout' nodes contain URL's to fetch,
  86. * as well as information relative to where URL contents should
  87. * be stored or which file should be uploaded.
  88. */
  89. struct getout {
  90. struct getout *next; /* next one */
  91. char *url; /* the URL we deal with */
  92. char *outfile; /* where to store the output */
  93. char *infile; /* file to upload, if GETOUT_UPLOAD is set */
  94. int flags; /* options - composed of GETOUT_* bits */
  95. int num; /* which URL number in an invocation */
  96. };
  97. #define GETOUT_OUTFILE (1<<0) /* set when outfile is deemed done */
  98. #define GETOUT_URL (1<<1) /* set when URL is deemed done */
  99. #define GETOUT_USEREMOTE (1<<2) /* use remote file name locally */
  100. #define GETOUT_UPLOAD (1<<3) /* if set, -T has been used */
  101. #define GETOUT_NOUPLOAD (1<<4) /* if set, -T "" has been used */
  102. /*
  103. * 'trace' enumeration represents curl's output look'n feel possibilities.
  104. */
  105. typedef enum {
  106. TRACE_NONE, /* no trace/verbose output at all */
  107. TRACE_BIN, /* tcpdump inspired look */
  108. TRACE_ASCII, /* like *BIN but without the hex output */
  109. TRACE_PLAIN /* -v/--verbose type */
  110. } trace;
  111. /*
  112. * 'HttpReq' enumeration represents HTTP request types.
  113. */
  114. typedef enum {
  115. HTTPREQ_UNSPEC, /* first in list */
  116. HTTPREQ_GET,
  117. HTTPREQ_HEAD,
  118. HTTPREQ_MIMEPOST,
  119. HTTPREQ_SIMPLEPOST,
  120. HTTPREQ_PUT
  121. } HttpReq;
  122. /*
  123. * Complete struct declarations which have OperationConfig struct members,
  124. * just in case this header is directly included in some source file.
  125. */
  126. #include "tool_cfgable.h"
  127. #endif /* HEADER_CURL_TOOL_SDECLS_H */