|
From: <ren...@us...> - 2007-10-08 18:18:35
|
Revision: 864
http://gmyth.svn.sourceforge.net/gmyth/?rev=864&view=rev
Author: renatofilho
Date: 2007-10-08 11:17:47 -0700 (Mon, 08 Oct 2007)
Log Message:
-----------
fixed bug on uri without port
Modified Paths:
--------------
trunk/gmyth/src/gmyth_backendinfo.c
trunk/gmyth/src/gmyth_backendinfo.h
trunk/gmyth/src/gmyth_uri.c
trunk/gmyth/src/gmyth_uri.h
Modified: trunk/gmyth/src/gmyth_backendinfo.c
===================================================================
--- trunk/gmyth/src/gmyth_backendinfo.c 2007-09-26 18:04:24 UTC (rev 863)
+++ trunk/gmyth/src/gmyth_backendinfo.c 2007-10-08 18:17:47 UTC (rev 864)
@@ -152,14 +152,13 @@
GMythBackendInfo *
gmyth_backend_info_new_with_uri(const gchar * uri_str)
{
- GMythBackendInfo *backend_info =
- GMYTH_BACKEND_INFO(g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
+ GMythBackendInfo *backend_info;
+ GMythURI *uri;
+ gchar **path_parts;
- GMythURI *uri = gmyth_uri_new_with_value(uri_str);
-
- gchar **path_parts =
- g_strsplit(gmyth_uri_get_path(uri), "&", -1);
-
+ backend_info = GMYTH_BACKEND_INFO(g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
+ uri = gmyth_uri_new_with_value (uri_str);
+ path_parts = g_strsplit(gmyth_uri_get_path(uri), "&", -1);
gmyth_backend_info_set_hostname(backend_info, gmyth_uri_get_host(uri));
gmyth_backend_info_set_username(backend_info, gmyth_uri_get_user(uri));
gmyth_backend_info_set_password(backend_info,
Modified: trunk/gmyth/src/gmyth_backendinfo.h
===================================================================
--- trunk/gmyth/src/gmyth_backendinfo.h 2007-09-26 18:04:24 UTC (rev 863)
+++ trunk/gmyth/src/gmyth_backendinfo.h 2007-10-08 18:17:47 UTC (rev 864)
@@ -100,9 +100,9 @@
const gchar *password);
void gmyth_backend_info_set_db_name (GMythBackendInfo *backend_info,
const gchar *db_name);
-void gmyth_backend_info_set_db_port (GMythBackendInfo *backend_info,
- gint db_port);
-void gmyth_backend_info_set_port (GMythBackendInfo *backend_info,
+void gmyth_backend_info_set_db_port (GMythBackendInfo *backend_info,
+ gint db_port);
+void gmyth_backend_info_set_port (GMythBackendInfo *backend_info,
gint port);
void gmyth_backend_info_set_status_port (GMythBackendInfo *backend_info,
gint port);
Modified: trunk/gmyth/src/gmyth_uri.c
===================================================================
--- trunk/gmyth/src/gmyth_uri.c 2007-09-26 18:04:24 UTC (rev 863)
+++ trunk/gmyth/src/gmyth_uri.c 2007-10-08 18:17:47 UTC (rev 864)
@@ -39,6 +39,33 @@
#include "gmyth_debug.h"
+/****************************************
+* Define
+****************************************/
+
+#define GMYTH_URI_KNKOWN_PORT (-1)
+#define GMYTH_URI_DEFAULT_HTTP_PORT 80
+#define GMYTH_URI_DEFAULT_FTP_PORT 21
+#define GMYTH_URI_DEFAULT_MYTH_PORT 6543
+#define GMYTH_URI_DEFAULT_PATH "/"
+#define GMYTH_URI_MAXLEN 256
+
+#define GMYTH_URI_PROTOCOL_DELIM "://"
+#define GMYTH_URI_USER_DELIM "@"
+#define GMYTH_URI_COLON_DELIM ":"
+#define GMYTH_URI_SLASH_DELIM "/"
+#define GMYTH_URI_SBLACET_DELIM "["
+#define GMYTH_URI_EBLACET_DELIM "]"
+#define GMYTH_URI_SHARP_DELIM "#"
+#define GMYTH_URI_QUESTION_DELIM "?"
+#define GMYTH_URI_E_DELIM "&"
+#define GMYTH_URI_ESCAPING_CHAR "%"
+
+#define GMYTH_URI_PROTOCOL_MYTH "myth"
+#define GMYTH_URI_PROTOCOL_HTTP "http"
+#define GMYTH_URI_PROTOCOL_FTP "ftp"
+
+
static void gmyth_uri_class_init(GMythURIClass * klass);
static void gmyth_uri_init(GMythURI * object);
@@ -248,6 +275,21 @@
return "";
}
+static gint
+gmyth_uri_get_default_port (GMythURI * uri)
+{
+ const gchar *protocol = gmyth_uri_get_protocol(uri);
+
+ if (strcmp(protocol, GMYTH_URI_PROTOCOL_HTTP) == 0)
+ return GMYTH_URI_DEFAULT_HTTP_PORT;
+ if (strcmp(protocol, GMYTH_URI_PROTOCOL_FTP) == 0)
+ return GMYTH_URI_DEFAULT_FTP_PORT;
+ if (strcmp(protocol, GMYTH_URI_PROTOCOL_MYTH) == 0)
+ return GMYTH_URI_DEFAULT_MYTH_PORT;
+
+ return GMYTH_URI_KNKOWN_PORT;
+}
+
/**
* Parses a URI string into a GMythURI instance.
*
@@ -327,21 +369,15 @@
uri->host =
g_string_new_len(hostStr->str + 1, colonIdx - 2);
}
+
/**** port ****/
- portStr =
- g_string_new_len(hostStr->str + colonIdx + 1,
- hostLen - colonIdx - 1);
+ portStr = g_string_new_len(hostStr->str + colonIdx + 1,
+ hostLen - colonIdx - 1);
uri->port = (gint) g_ascii_strtoull(portStr->str, NULL, 10);
g_string_free(portStr, TRUE);
g_string_free(hostStr, TRUE);
} else {
- const gchar *protocol = gmyth_uri_get_protocol(uri);
-
- uri->port = GMYTH_URI_KNKOWN_PORT;
- if (strcmp(protocol, GMYTH_URI_PROTOCOL_HTTP) == 0)
- uri->port = GMYTH_URI_DEFAULT_HTTP_PORT;
- if (strcmp(protocol, GMYTH_URI_PROTOCOL_FTP) == 0)
- uri->port = GMYTH_URI_DEFAULT_FTP_PORT;
+ uri->port = gmyth_uri_get_default_port (uri);
}
if (shashIdx > 0)
Modified: trunk/gmyth/src/gmyth_uri.h
===================================================================
--- trunk/gmyth/src/gmyth_uri.h 2007-09-26 18:04:24 UTC (rev 863)
+++ trunk/gmyth/src/gmyth_uri.h 2007-10-08 18:17:47 UTC (rev 864)
@@ -46,31 +46,7 @@
typedef struct _GMythURI GMythURI;
typedef struct _GMythURIClass GMythURIClass;
- /****************************************
- * Define
- ****************************************/
-#define GMYTH_URI_KNKOWN_PORT (-1)
-#define GMYTH_URI_DEFAULT_HTTP_PORT 80
-#define GMYTH_URI_DEFAULT_FTP_PORT 21
-#define GMYTH_URI_DEFAULT_PATH "/"
-#define GMYTH_URI_MAXLEN 256
-
-#define GMYTH_URI_PROTOCOL_DELIM "://"
-#define GMYTH_URI_USER_DELIM "@"
-#define GMYTH_URI_COLON_DELIM ":"
-#define GMYTH_URI_SLASH_DELIM "/"
-#define GMYTH_URI_SBLACET_DELIM "["
-#define GMYTH_URI_EBLACET_DELIM "]"
-#define GMYTH_URI_SHARP_DELIM "#"
-#define GMYTH_URI_QUESTION_DELIM "?"
-#define GMYTH_URI_E_DELIM "&"
-#define GMYTH_URI_ESCAPING_CHAR "%"
-
-#define GMYTH_URI_PROTOCOL_MYTH "myth"
-#define GMYTH_URI_PROTOCOL_HTTP "http"
-#define GMYTH_URI_PROTOCOL_FTP "ftp"
-
/****************************************
* Data Type
****************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|