1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
22 #include "tool_setup.h"
30 #define ENABLE_CURLX_PRINTF
31 /* use our own printf() functions */
34 #include "tool_cfgable.h"
35 #include "tool_convert.h"
36 #include "tool_operate.h"
37 #include "tool_panykey.h"
39 #include "tool_main.h"
42 * This is low-level hard-hacking memory leak tracking and similar. Using
43 * the library level code from this client-side is ugly, but we do this
44 * anyway for convenience.
46 #include "memdebug.h" /* keep this as LAST include */
49 static int vms_show = 0;
53 * Ensure that file descriptors 0, 1 and 2 (stdin, stdout, stderr) are
54 * open before starting to run. Otherwise, the first three network
55 * sockets opened by curl could be used for input sources, downloaded data
56 * or error logs as they will effectively be stdin, stdout and/or stderr.
58 static void main_checkfds(void)
61 int fd[2] = { STDIN_FILENO, STDIN_FILENO };
62 while(fd[0] == STDIN_FILENO ||
63 fd[0] == STDOUT_FILENO ||
64 fd[0] == STDERR_FILENO ||
65 fd[1] == STDIN_FILENO ||
66 fd[1] == STDOUT_FILENO ||
67 fd[1] == STDERR_FILENO)
69 return; /* Out of handles. This isn't really a big problem now, but
70 will be when we try to create a socket later. */
77 ** curl tool main function.
79 int main(int argc, char *argv[])
82 struct Configurable config;
84 memset(&config, 0, sizeof(struct Configurable));
86 config.errors = stderr; /* default errors to stderr */
90 res = operate(&config, argc, argv);
97 free_config_fields(&config);
99 #ifdef __NOVELL_LIBC__
100 if(getenv("_IN_NETWARE_BASH_") == NULL)
105 vms_special_exit(res, vms_show);