aboutsummaryrefslogtreecommitdiffstats
path: root/lib/url.c
diff options
context:
space:
mode:
authorIndent <please@skip.me>2015-02-19 02:47:20 -0300
committerdequis <dx@dxzone.com.ar>2015-02-20 19:50:54 -0300
commit5ebff60479fc7a9f7f50ac03b124c91d4e6ebe11 (patch)
tree9fc0d50cb1f4bc9768d9f00de94eafd876bb55b0 /lib/url.c
parentaf359b4316f9d392c6b752495a1b2ed631576ed8 (diff)
Reindent everything to K&R style with tabs
Used uncrustify, with the configuration file in ./doc/uncrustify.cfg Commit author set to "Indent <please@skip.me>" so that it's easier to skip while doing git blame.
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c94
1 files changed, 42 insertions, 52 deletions
diff --git a/lib/url.c b/lib/url.c
index 1c7ff656..38515669 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1,4 +1,4 @@
- /********************************************************************\
+/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
* Copyright 2001-2005 Wilmer van der Gaast and others *
@@ -26,84 +26,74 @@
#include "url.h"
/* Convert an URL to a url_t structure */
-int url_set( url_t *url, const char *set_url )
+int url_set(url_t *url, const char *set_url)
{
- char s[MAX_STRING+1];
+ char s[MAX_STRING + 1];
char *i;
-
- memset( url, 0, sizeof( url_t ) );
- memset( s, 0, sizeof( s ) );
-
+
+ memset(url, 0, sizeof(url_t));
+ memset(s, 0, sizeof(s));
+
/* protocol:// */
- if( ( i = strstr( set_url, "://" ) ) == NULL )
- {
+ if ((i = strstr(set_url, "://")) == NULL) {
url->proto = PROTO_DEFAULT;
- strncpy( s, set_url, MAX_STRING );
- }
- else
- {
- if( g_strncasecmp( set_url, "http", i - set_url ) == 0 )
+ strncpy(s, set_url, MAX_STRING);
+ } else {
+ if (g_strncasecmp(set_url, "http", i - set_url) == 0) {
url->proto = PROTO_HTTP;
- else if( g_strncasecmp( set_url, "https", i - set_url ) == 0 )
+ } else if (g_strncasecmp(set_url, "https", i - set_url) == 0) {
url->proto = PROTO_HTTPS;
- else if( g_strncasecmp( set_url, "socks4", i - set_url ) == 0 )
+ } else if (g_strncasecmp(set_url, "socks4", i - set_url) == 0) {
url->proto = PROTO_SOCKS4;
- else if( g_strncasecmp( set_url, "socks5", i - set_url ) == 0 )
+ } else if (g_strncasecmp(set_url, "socks5", i - set_url) == 0) {
url->proto = PROTO_SOCKS5;
- else
+ } else {
return 0;
-
- strncpy( s, i + 3, MAX_STRING );
+ }
+
+ strncpy(s, i + 3, MAX_STRING);
}
-
+
/* Split */
- if( ( i = strchr( s, '/' ) ) == NULL )
- {
- strcpy( url->file, "/" );
- }
- else
- {
- strncpy( url->file, i, MAX_STRING );
+ if ((i = strchr(s, '/')) == NULL) {
+ strcpy(url->file, "/");
+ } else {
+ strncpy(url->file, i, MAX_STRING);
*i = 0;
}
- strncpy( url->host, s, MAX_STRING );
-
+ strncpy(url->host, s, MAX_STRING);
+
/* Check for username in host field */
- if( strrchr( url->host, '@' ) != NULL )
- {
- strncpy( url->user, url->host, MAX_STRING );
- i = strrchr( url->user, '@' );
+ if (strrchr(url->host, '@') != NULL) {
+ strncpy(url->user, url->host, MAX_STRING);
+ i = strrchr(url->user, '@');
*i = 0;
- strcpy( url->host, i + 1 );
+ strcpy(url->host, i + 1);
*url->pass = 0;
}
/* If not: Fill in defaults */
- else
- {
+ else {
*url->user = *url->pass = 0;
}
-
+
/* Password? */
- if( ( i = strchr( url->user, ':' ) ) != NULL )
- {
+ if ((i = strchr(url->user, ':')) != NULL) {
*i = 0;
- strcpy( url->pass, i + 1 );
+ strcpy(url->pass, i + 1);
}
/* Port number? */
- if( ( i = strchr( url->host, ':' ) ) != NULL )
- {
+ if ((i = strchr(url->host, ':')) != NULL) {
*i = 0;
- sscanf( i + 1, "%d", &url->port );
- }
- else
- {
- if( url->proto == PROTO_HTTP )
+ sscanf(i + 1, "%d", &url->port);
+ } else {
+ if (url->proto == PROTO_HTTP) {
url->port = 80;
- else if( url->proto == PROTO_HTTPS )
+ } else if (url->proto == PROTO_HTTPS) {
url->port = 443;
- else if( url->proto == PROTO_SOCKS4 || url->proto == PROTO_SOCKS5 )
+ } else if (url->proto == PROTO_SOCKS4 || url->proto == PROTO_SOCKS5) {
url->port = 1080;
+ }
}
-
- return( url->port > 0 );
+
+ return(url->port > 0);
}