aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog9
-rw-r--r--util/Makefile.am2
-rw-r--r--util/http.c40
-rw-r--r--util/simple-gettext.c14
4 files changed, 50 insertions, 15 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index 9d2220540..965bc71a0 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,12 @@
+Fri Oct 8 20:32:01 CEST 1999 Werner Koch <[email protected]>
+
+ * w32reg.c: New.
+ * simple-gettext.c: Use the Registry to locate the mo file.
+
+ * http.c (send_request): Add support for proxys; suggested by
+ Walter Hofmann.
+ (http_open_document): Pass flags to http_open.
+
Fri Sep 17 12:56:42 CEST 1999 Werner Koch <[email protected]>
diff --git a/util/Makefile.am b/util/Makefile.am
index 95096c7e7..3098ba671 100644
--- a/util/Makefile.am
+++ b/util/Makefile.am
@@ -8,7 +8,7 @@ noinst_LTLIBRARIES = libutil.la
libutil_la_LDFLAGS =
libutil_la_SOURCES = g10u.c logger.c fileutil.c miscutil.c strgutil.c \
ttyio.c argparse.c memory.c secmem.c errors.c iobuf.c \
- dotlock.c http.c simple-gettext.c
+ dotlock.c http.c simple-gettext.c w32reg.c
http-test: http.c
diff --git a/util/http.c b/util/http.c
index 4bac8d845..d3bc44fe3 100644
--- a/util/http.c
+++ b/util/http.c
@@ -74,7 +74,7 @@ http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
{
int rc;
- if( flags || !(reqtype == HTTP_REQ_GET || reqtype == HTTP_REQ_POST) )
+ if( !(reqtype == HTTP_REQ_GET || reqtype == HTTP_REQ_POST) )
return G10ERR_INV_ARG;
/* initialize the handle */
@@ -82,6 +82,7 @@ http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
hd->sock = -1;
hd->initialized = 1;
hd->req_type = reqtype;
+ hd->flags = flags;
rc = parse_uri( &hd->uri, url );
if( !rc ) {
@@ -148,10 +149,7 @@ http_open_document( HTTP_HD hd, const char *document, unsigned int flags )
{
int rc;
- if( flags )
- return G10ERR_INV_ARG;
-
- rc = http_open( hd, HTTP_REQ_GET, document, 0 );
+ rc = http_open( hd, HTTP_REQ_GET, document, flags );
if( rc )
return rc;
@@ -427,21 +425,47 @@ send_request( HTTP_HD hd )
byte *request, *p;
ushort port;
int rc;
+ const char *http_proxy = NULL;
server = *hd->uri->host? hd->uri->host : "localhost";
port = hd->uri->port? hd->uri->port : 80;
- hd->sock = connect_server( server, port );
+ if( (hd->flags & HTTP_FLAG_TRY_PROXY)
+ && (http_proxy = getenv( "http_proxy" )) ) {
+ PARSED_URI uri;
+
+ rc = parse_uri( &uri, http_proxy );
+ if (rc) {
+ log_error("invalid $http_proxy: %s\n", g10_errstr(rc));
+ release_parsed_uri( uri );
+ return G10ERR_NETWORK;
+ }
+ hd->sock = connect_server( *uri->host? uri->host : "localhost",
+ uri->port? uri->port : 80 );
+ release_parsed_uri( uri );
+ }
+ else
+ hd->sock = connect_server( server, port );
+
if( hd->sock == -1 )
return G10ERR_NETWORK;
p = build_rel_path( hd->uri );
- request = m_alloc( strlen(p) + 20 );
- sprintf( request, "%s %s%s HTTP/1.0\r\n",
+ request = m_alloc( strlen(server) + strlen(p) + 50 );
+ if( http_proxy ) {
+ sprintf( request, "%s http://%s:%hu%s%s HTTP/1.0\r\n",
+ hd->req_type == HTTP_REQ_GET ? "GET" :
+ hd->req_type == HTTP_REQ_HEAD? "HEAD":
+ hd->req_type == HTTP_REQ_POST? "POST": "OOPS",
+ server, port, *p == '/'? "":"/", p );
+ }
+ else {
+ sprintf( request, "%s %s%s HTTP/1.0\r\n",
hd->req_type == HTTP_REQ_GET ? "GET" :
hd->req_type == HTTP_REQ_HEAD? "HEAD":
hd->req_type == HTTP_REQ_POST? "POST": "OOPS",
*p == '/'? "":"/", p );
+ }
m_free(p);
rc = write_server( hd->sock, request, strlen(request) );
diff --git a/util/simple-gettext.c b/util/simple-gettext.c
index 21f39382d..a45ecb2b2 100644
--- a/util/simple-gettext.c
+++ b/util/simple-gettext.c
@@ -242,19 +242,21 @@ set_gettext_file( const char *filename )
#endif
) {
/* absolute path - use it as is */
- log_info("trying `%s'\n", filename );
domain = load_domain( filename );
}
- else { /* relative path - append ".mo" and get DIR from env */
+ else { /* relative path - append ".mo" and get dir from the environment */
char *buf = NULL;
- const char *s;
+ char *dir;
- s = getenv("MINGW32_NLS_DIR");
- if( s && (buf=malloc(strlen(s)+strlen(filename)+1+3+1)) ) {
- strcpy(stpcpy(stpcpy(stpcpy( buf, s),"/"), filename),".mo");
+ dir = read_w32_registry_string( NULL,
+ "Control Panel\\Mingw32\\NLS",
+ "MODir" );
+ if( dir && (buf=malloc(strlen(dir)+strlen(filename)+1+3+1)) ) {
+ strcpy(stpcpy(stpcpy(stpcpy( buf, dir),"/"), filename),".mo");
domain = load_domain( buf );
free(buf);
}
+ free(dir);
}
if( !domain )
return -1;