Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 117 lines (104 sloc) 3.639 kB
ba4e69b @bagder updated source code boilerplate/header
authored
1 /***************************************************************************
efe2ce3 If building with CURLDEBUG, sprintf() is defined away. So use curl_ms…
Gisle Vanem authored
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
6 * \___|\___/|_| \_\_____|
7 *
919c97f @yangtse curl tool: use configuration files from lib directory
yangtse authored
8 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
9 *
ba4e69b @bagder updated source code boilerplate/header
authored
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.
efe2ce3 If building with CURLDEBUG, sprintf() is defined away. So use curl_ms…
Gisle Vanem authored
13 *
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
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
ba4e69b @bagder updated source code boilerplate/header
authored
16 * furnished to do so, under the terms of the COPYING file.
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
ba4e69b @bagder updated source code boilerplate/header
authored
21 ***************************************************************************/
919c97f @yangtse curl tool: use configuration files from lib directory
yangtse authored
22 #include "tool_setup.h"
9c4e5dc @bagder removed compiler warnings, made it conditional on USE_ENVIRONMENT
authored
23
24 #ifdef USE_ENVIRONMENT
25
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
26 #ifdef __riscos__
f7bfdba @yangtse curl tool: reviewed code moved to tool_*.[ch] files
yangtse authored
27 # include <kernel.h>
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
28 #endif
29
417bac4 @yangtse add missing header inclusions
yangtse authored
30 #define _MPRINTF_REPLACE /* use our functions only */
31 #include <curl/mprintf.h>
32
f7bfdba @yangtse curl tool: reviewed code moved to tool_*.[ch] files
yangtse authored
33 #include "tool_writeenv.h"
90080da @yangtse curl tool: re-enable MemoryTracking capability on 'src' subdirectory …
yangtse authored
34
35 #include "memdebug.h" /* keep this as LAST include */
ccfe279 @yangtse Constantine Sapuntzakis enhancements to make memory tracking log file…
yangtse authored
36
1ba47e7 @dfandrich Add 'const' to immutable arrays.
dfandrich authored
37 static const struct
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
38 {
39 const char * name;
40 CURLINFO id;
41 enum {
9c4e5dc @bagder removed compiler warnings, made it conditional on USE_ENVIRONMENT
authored
42 writeenv_NONE,
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
43 writeenv_DOUBLE,
44 writeenv_LONG,
45 writeenv_STRING
46 } type;
47 } variables[14] =
48 {
49 {"curl_url_effective", CURLINFO_EFFECTIVE_URL, writeenv_STRING},
5974309 @bagder CURLINFO_RESPONSE_CODE replaces CURLINFO_HTTP_CODE
authored
50 {"curl_http_code", CURLINFO_RESPONSE_CODE, writeenv_LONG},
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
51 {"curl_time_total", CURLINFO_TOTAL_TIME, writeenv_DOUBLE},
52 {"curl_time_namelookup", CURLINFO_NAMELOOKUP_TIME, writeenv_DOUBLE},
53 {"curl_time_connect", CURLINFO_CONNECT_TIME, writeenv_DOUBLE},
54 {"curl_time_pretransfer", CURLINFO_PRETRANSFER_TIME, writeenv_DOUBLE},
55 {"curl_time_starttransfer", CURLINFO_STARTTRANSFER_TIME, writeenv_DOUBLE},
56 {"curl_size_header", CURLINFO_HEADER_SIZE, writeenv_LONG},
57 {"curl_size_request", CURLINFO_REQUEST_SIZE, writeenv_LONG},
58 {"curl_size_download", CURLINFO_SIZE_DOWNLOAD, writeenv_DOUBLE},
59 {"curl_size_upload", CURLINFO_SIZE_UPLOAD, writeenv_DOUBLE},
60 {"curl_speed_download", CURLINFO_SPEED_DOWNLOAD, writeenv_DOUBLE},
61 {"curl_speed_upload", CURLINFO_SPEED_UPLOAD, writeenv_DOUBLE},
9c4e5dc @bagder removed compiler warnings, made it conditional on USE_ENVIRONMENT
authored
62 {NULL, 0, writeenv_NONE}
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
63 };
64
65 static void internalSetEnv(const char * name, char * value)
66 {
67 /* Add your OS-specific code here. */
68 #ifdef __riscos__
69 _kernel_setenv(name, value);
126ed14 @bagder Gisle Vanem's djgpp/MS-DOS updates
authored
70 #elif defined (CURLDEBUG)
ccfe279 @yangtse Constantine Sapuntzakis enhancements to make memory tracking log file…
yangtse authored
71 curl_memlog("ENV %s = %s\n", name, value);
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
72 #endif
73 return;
74 }
75
76 void ourWriteEnv(CURL *curl)
77 {
78 unsigned int i;
79 char *string, numtext[10];
80 long longinfo;
81 double doubleinfo;
efe2ce3 If building with CURLDEBUG, sprintf() is defined away. So use curl_ms…
Gisle Vanem authored
82
aa87f0a @bagder checksrc: whitespace and code style cleanup
authored
83 for(i=0; variables[i].name; i++) {
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
84 switch (variables[i].type) {
85 case writeenv_STRING:
aa87f0a @bagder checksrc: whitespace and code style cleanup
authored
86 if(curl_easy_getinfo(curl, variables[i].id, &string) == CURLE_OK)
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
87 internalSetEnv(variables[i].name, string);
88 else
89 internalSetEnv(variables[i].name, NULL);
90 break;
91
92 case writeenv_LONG:
aa87f0a @bagder checksrc: whitespace and code style cleanup
authored
93 if(curl_easy_getinfo(curl, variables[i].id, &longinfo) == CURLE_OK) {
efe2ce3 If building with CURLDEBUG, sprintf() is defined away. So use curl_ms…
Gisle Vanem authored
94 curl_msprintf(numtext, "%5ld", longinfo);
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
95 internalSetEnv(variables[i].name, numtext);
96 }
97 else
98 internalSetEnv(variables[i].name, NULL);
99 break;
100 case writeenv_DOUBLE:
aa87f0a @bagder checksrc: whitespace and code style cleanup
authored
101 if(curl_easy_getinfo(curl, variables[i].id, &doubleinfo) == CURLE_OK) {
efe2ce3 If building with CURLDEBUG, sprintf() is defined away. So use curl_ms…
Gisle Vanem authored
102 curl_msprintf(numtext, "%6.2f", doubleinfo);
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
103 internalSetEnv(variables[i].name, numtext);
104 }
105 else
106 internalSetEnv(variables[i].name, NULL);
107 break;
126ed14 @bagder Gisle Vanem's djgpp/MS-DOS updates
authored
108 default:
109 break;
c3c8bbd @bagder Added writeenv.c and writeenv.h for RISCOS usage (and others?)
authored
110 }
111 }
112
113 return;
114 }
9c4e5dc @bagder removed compiler warnings, made it conditional on USE_ENVIRONMENT
authored
115
116 #endif
Something went wrong with that request. Please try again.