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