branches/gmyth-0.1b/src/gmyth_uri.h
author rosfran
Wed Feb 14 21:28:49 2007 +0000 (2007-02-14)
branchtrunk
changeset 360 6d5596b9eb95
permissions -rwxr-xr-x
[svn r362] Some fixes in the GIOWatcher clean-ups, and changed the API version number.
     1 /**
     2  * GMyth Library
     3  *
     4  * @file gmyth/gmyth_uri.h
     5  * 
     6  * @brief <p> GMythURI utils
     7  *  - Extracts and parses a URI char string, in according with the RFC 2396 
     8  *    [http://www.ietf.org/rfc/rfc2396.txt]
     9  * 
    10  * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    11  * @author Rosfran Borges <rosfran.borges@indt.org.br>
    12  *
    13  *//*
    14  * 
    15  * This program is free software; you can redistribute it and/or modify
    16  * it under the terms of the GNU Lesser General Public License as published by
    17  * the Free Software Foundation; either version 2 of the License, or
    18  * (at your option) any later version.
    19  *
    20  * This program is distributed in the hope that it will be useful,
    21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23  * GNU General Public License for more details.
    24  *
    25  * You should have received a copy of the GNU Lesser General Public License
    26  * along with this program; if not, write to the Free Software
    27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    28  */
    29 
    30 #ifndef _GMYTH_URI_H_
    31 #define _GMYTH_URI_H_
    32 
    33 #include <glib.h>
    34 #include <glib-object.h>
    35 
    36 #include <stdlib.h>
    37 #include <stdio.h>
    38 #include <string.h>
    39 
    40 G_BEGIN_DECLS
    41 
    42 #define GMYTH_URI_TYPE               (gmyth_uri_get_type ())
    43 #define GMYTH_URI(obj)          		 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_URI_TYPE, GMythURI))
    44 #define GMYTH_URI_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_URI_TYPE, GMythURIClass))
    45 #define IS_GMYTH_URI(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_URI_TYPE))
    46 #define IS_GMYTH_URI_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_URI_TYPE))
    47 #define GMYTH_URI_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_URI_TYPE, GMythURIClass))
    48 
    49 typedef struct _GMythURI         GMythURI;
    50 typedef struct _GMythURIClass    GMythURIClass;
    51 
    52 /****************************************
    53 * Define
    54 ****************************************/
    55 
    56 #define GMYTH_URI_KNKOWN_PORT 				(-1)
    57 #define GMYTH_URI_DEFAULT_HTTP_PORT 	80
    58 #define GMYTH_URI_DEFAULT_FTP_PORT 		21
    59 #define GMYTH_URI_DEFAULT_PATH 				"/"
    60 #define GMYTH_URI_MAXLEN 							256
    61 
    62 #define GMYTH_URI_PROTOCOL_DELIM 			"://"
    63 #define GMYTH_URI_USER_DELIM 					"@"
    64 #define GMYTH_URI_COLON_DELIM 				":"
    65 #define GMYTH_URI_SLASH_DELIM 				"/"
    66 #define GMYTH_URI_SBLACET_DELIM 			"["
    67 #define GMYTH_URI_EBLACET_DELIM 			"]"
    68 #define GMYTH_URI_SHARP_DELIM 				"#"
    69 #define GMYTH_URI_QUESTION_DELIM 			"?"
    70 #define GMYTH_URI_E_DELIM 						"&"
    71 #define GMYTH_URI_ESCAPING_CHAR 			"%"
    72 
    73 #define GMYTH_URI_PROTOCOL_MYTH 			"myth"
    74 #define GMYTH_URI_PROTOCOL_HTTP 			"http"
    75 #define GMYTH_URI_PROTOCOL_FTP 				"ftp"
    76 
    77 /****************************************
    78 * Data Type
    79 ****************************************/
    80 
    81 struct _GMythURIClass
    82 {
    83   GObjectClass parent_class;
    84 
    85   /* callbacks */
    86   /* no one for now */
    87 };
    88 
    89 struct _GMythURI {
    90 	
    91 	GObject parent;
    92 	
    93 	GString *uri;
    94 	GString *host;
    95 	gint port;
    96 	GString *protocol;
    97 	GString *path;
    98 	GString *fragment;
    99 	GString *user;
   100 	GString *password;
   101 	GString *query;
   102 	
   103 };
   104 
   105 GType       gmyth_uri_get_type (void);
   106 GMythURI*   gmyth_uri_new (void);
   107 GMythURI*   gmyth_uri_new_with_value (const gchar *value);
   108 gboolean 		gmyth_uri_is_equals ( GMythURI* uri1, GMythURI* uri2 );
   109 gboolean		gmyth_uri_is_livetv ( GMythURI* uri );
   110 gint				gmyth_uri_get_channel_num( GMythURI* uri );
   111 gchar*			gmyth_uri_get_channel_name( GMythURI* uri );
   112 
   113 
   114 #define 		gmyth_uri_get_host(urip) 			( urip->host != NULL ? urip->host->str : "" )
   115 #define 		gmyth_uri_get_port(urip) 			( urip->port )
   116 #define 		gmyth_uri_get_protocol(urip) 	( urip->protocol != NULL ? urip->protocol->str : "" )
   117 #define 		gmyth_uri_get_path(urip) 			( urip->path != NULL ? urip->path->str : "" )
   118 #define 		gmyth_uri_get_user(urip) 			( urip->user != NULL ? urip->user->str : "" )
   119 #define    	gmyth_uri_get_password(urip) 	( urip->password != NULL ? urip->password->str : "" )
   120 #define 		gmyth_uri_get_fragment(urip) 	( urip->fragment != NULL ? urip->fragment->str : "" )
   121 #define 		gmyth_uri_get_query(urip) 		( urip->query != NULL ? urip->query->str : "" )
   122 
   123 G_END_DECLS
   124 
   125 #endif /* _GMYTH_URI_H_ */