• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /*
29  * OutStruct variables keep track of information relative to curl's
30  * output writing, which may take place to a standard stream or a file.
31  *
32  * 'filename' member is either a pointer to a file name string or NULL
33  * when dealing with a standard stream.
34  *
35  * 'alloc_filename' member is TRUE when string pointed by 'filename' has been
36  * dynamically allocated and 'belongs' to this OutStruct, otherwise FALSE.
37  *
38  * 'is_cd_filename' member is TRUE when string pointed by 'filename' has been
39  * set using a server-specified Content-Disposition filename, otherwise FALSE.
40  *
41  * 's_isreg' member is TRUE when output goes to a regular file, this also
42  * implies that output is 'seekable' and 'appendable' and also that member
43  * 'filename' points to file name's string. For any standard stream member
44  * 's_isreg' will be FALSE.
45  *
46  * 'fopened' member is TRUE when output goes to a regular file and it
47  * has been fopen'ed, requiring it to be closed later on. In any other
48  * case this is FALSE.
49  *
50  * 'stream' member is a pointer to a stream controlling object as returned
51  * from a 'fopen' call or a standard stream.
52  *
53  * 'config' member is a pointer to associated 'OperationConfig' struct.
54  *
55  * 'bytes' member represents amount written so far.
56  *
57  * 'init' member holds original file size or offset at which truncation is
58  * taking place. Always zero unless appending to a non-empty regular file.
59  *
60  */
61 
62 struct OutStruct {
63   char *filename;
64   bool alloc_filename;
65   bool is_cd_filename;
66   bool s_isreg;
67   bool fopened;
68   FILE *stream;
69   curl_off_t bytes;
70   curl_off_t init;
71 };
72 
73 
74 /*
75  * InStruct variables keep track of information relative to curl's
76  * input reading, which may take place from stdin or from some file.
77  *
78  * 'fd' member is either 'stdin' file descriptor number STDIN_FILENO
79  * or a file descriptor as returned from an 'open' call for some file.
80  *
81  * 'config' member is a pointer to associated 'OperationConfig' struct.
82  */
83 
84 struct InStruct {
85   int fd;
86   struct OperationConfig *config;
87   struct per_transfer *per;
88 };
89 
90 
91 /*
92  * A linked list of these 'getout' nodes contain URL's to fetch,
93  * as well as information relative to where URL contents should
94  * be stored or which file should be uploaded.
95  */
96 
97 struct getout {
98   struct getout *next;      /* next one */
99   char          *url;       /* the URL we deal with */
100   char          *outfile;   /* where to store the output */
101   char          *infile;    /* file to upload, if GETOUT_UPLOAD is set */
102   int            flags;     /* options - composed of GETOUT_* bits */
103   int            num;       /* which URL number in an invocation */
104 };
105 
106 #define GETOUT_OUTFILE    (1<<0)  /* set when outfile is deemed done */
107 #define GETOUT_URL        (1<<1)  /* set when URL is deemed done */
108 #define GETOUT_USEREMOTE  (1<<2)  /* use remote file name locally */
109 #define GETOUT_UPLOAD     (1<<3)  /* if set, -T has been used */
110 #define GETOUT_NOUPLOAD   (1<<4)  /* if set, -T "" has been used */
111 
112 /*
113  * 'trace' enumeration represents curl's output look'n feel possibilities.
114  */
115 
116 typedef enum {
117   TRACE_NONE,  /* no trace/verbose output at all */
118   TRACE_BIN,   /* tcpdump inspired look */
119   TRACE_ASCII, /* like *BIN but without the hex output */
120   TRACE_PLAIN  /* -v/--verbose type */
121 } trace;
122 
123 
124 /*
125  * 'HttpReq' enumeration represents HTTP request types.
126  */
127 
128 typedef enum {
129   HTTPREQ_UNSPEC,  /* first in list */
130   HTTPREQ_GET,
131   HTTPREQ_HEAD,
132   HTTPREQ_MIMEPOST,
133   HTTPREQ_SIMPLEPOST,
134   HTTPREQ_PUT
135 } HttpReq;
136 
137 
138 /*
139  * Complete struct declarations which have OperationConfig struct members,
140  * just in case this header is directly included in some source file.
141  */
142 
143 #include "tool_cfgable.h"
144 
145 #endif /* HEADER_CURL_TOOL_SDECLS_H */
146