branches/gmyth-0.1b/src/gmyth_uri.h
branchtrunk
changeset 331 f32837103d17
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/branches/gmyth-0.1b/src/gmyth_uri.h	Wed Feb 07 18:30:15 2007 +0000
     1.3 @@ -0,0 +1,125 @@
     1.4 +/**
     1.5 + * GMyth Library
     1.6 + *
     1.7 + * @file gmyth/gmyth_uri.h
     1.8 + * 
     1.9 + * @brief <p> GMythURI utils
    1.10 + *  - Extracts and parses a URI char string, in according with the RFC 2396 
    1.11 + *    [http://www.ietf.org/rfc/rfc2396.txt]
    1.12 + * 
    1.13 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    1.14 + * @author Rosfran Borges <rosfran.borges@indt.org.br>
    1.15 + *
    1.16 + *//*
    1.17 + * 
    1.18 + * This program is free software; you can redistribute it and/or modify
    1.19 + * it under the terms of the GNU Lesser General Public License as published by
    1.20 + * the Free Software Foundation; either version 2 of the License, or
    1.21 + * (at your option) any later version.
    1.22 + *
    1.23 + * This program is distributed in the hope that it will be useful,
    1.24 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.25 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.26 + * GNU General Public License for more details.
    1.27 + *
    1.28 + * You should have received a copy of the GNU Lesser General Public License
    1.29 + * along with this program; if not, write to the Free Software
    1.30 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.31 + */
    1.32 +
    1.33 +#ifndef _GMYTH_URI_H_
    1.34 +#define _GMYTH_URI_H_
    1.35 +
    1.36 +#include <glib.h>
    1.37 +#include <glib-object.h>
    1.38 +
    1.39 +#include <stdlib.h>
    1.40 +#include <stdio.h>
    1.41 +#include <string.h>
    1.42 +
    1.43 +G_BEGIN_DECLS
    1.44 +
    1.45 +#define GMYTH_URI_TYPE               (gmyth_uri_get_type ())
    1.46 +#define GMYTH_URI(obj)          		 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_URI_TYPE, GMythURI))
    1.47 +#define GMYTH_URI_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_URI_TYPE, GMythURIClass))
    1.48 +#define IS_GMYTH_URI(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_URI_TYPE))
    1.49 +#define IS_GMYTH_URI_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_URI_TYPE))
    1.50 +#define GMYTH_URI_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_URI_TYPE, GMythURIClass))
    1.51 +
    1.52 +typedef struct _GMythURI         GMythURI;
    1.53 +typedef struct _GMythURIClass    GMythURIClass;
    1.54 +
    1.55 +/****************************************
    1.56 +* Define
    1.57 +****************************************/
    1.58 +
    1.59 +#define GMYTH_URI_KNKOWN_PORT 				(-1)
    1.60 +#define GMYTH_URI_DEFAULT_HTTP_PORT 	80
    1.61 +#define GMYTH_URI_DEFAULT_FTP_PORT 		21
    1.62 +#define GMYTH_URI_DEFAULT_PATH 				"/"
    1.63 +#define GMYTH_URI_MAXLEN 							256
    1.64 +
    1.65 +#define GMYTH_URI_PROTOCOL_DELIM 			"://"
    1.66 +#define GMYTH_URI_USER_DELIM 					"@"
    1.67 +#define GMYTH_URI_COLON_DELIM 				":"
    1.68 +#define GMYTH_URI_SLASH_DELIM 				"/"
    1.69 +#define GMYTH_URI_SBLACET_DELIM 			"["
    1.70 +#define GMYTH_URI_EBLACET_DELIM 			"]"
    1.71 +#define GMYTH_URI_SHARP_DELIM 				"#"
    1.72 +#define GMYTH_URI_QUESTION_DELIM 			"?"
    1.73 +#define GMYTH_URI_E_DELIM 						"&"
    1.74 +#define GMYTH_URI_ESCAPING_CHAR 			"%"
    1.75 +
    1.76 +#define GMYTH_URI_PROTOCOL_MYTH 			"myth"
    1.77 +#define GMYTH_URI_PROTOCOL_HTTP 			"http"
    1.78 +#define GMYTH_URI_PROTOCOL_FTP 				"ftp"
    1.79 +
    1.80 +/****************************************
    1.81 +* Data Type
    1.82 +****************************************/
    1.83 +
    1.84 +struct _GMythURIClass
    1.85 +{
    1.86 +  GObjectClass parent_class;
    1.87 +
    1.88 +  /* callbacks */
    1.89 +  /* no one for now */
    1.90 +};
    1.91 +
    1.92 +struct _GMythURI {
    1.93 +	
    1.94 +	GObject parent;
    1.95 +	
    1.96 +	GString *uri;
    1.97 +	GString *host;
    1.98 +	gint port;
    1.99 +	GString *protocol;
   1.100 +	GString *path;
   1.101 +	GString *fragment;
   1.102 +	GString *user;
   1.103 +	GString *password;
   1.104 +	GString *query;
   1.105 +	
   1.106 +};
   1.107 +
   1.108 +GType       gmyth_uri_get_type (void);
   1.109 +GMythURI*   gmyth_uri_new (void);
   1.110 +GMythURI*   gmyth_uri_new_with_value (const gchar *value);
   1.111 +gboolean 		gmyth_uri_is_equals ( GMythURI* uri1, GMythURI* uri2 );
   1.112 +gboolean		gmyth_uri_is_livetv ( GMythURI* uri );
   1.113 +gint				gmyth_uri_get_channel_num( GMythURI* uri );
   1.114 +gchar*			gmyth_uri_get_channel_name( GMythURI* uri );
   1.115 +
   1.116 +
   1.117 +#define 		gmyth_uri_get_host(urip) 			( urip->host != NULL ? urip->host->str : "" )
   1.118 +#define 		gmyth_uri_get_port(urip) 			( urip->port )
   1.119 +#define 		gmyth_uri_get_protocol(urip) 	( urip->protocol != NULL ? urip->protocol->str : "" )
   1.120 +#define 		gmyth_uri_get_path(urip) 			( urip->path != NULL ? urip->path->str : "" )
   1.121 +#define 		gmyth_uri_get_user(urip) 			( urip->user != NULL ? urip->user->str : "" )
   1.122 +#define    	gmyth_uri_get_password(urip) 	( urip->password != NULL ? urip->password->str : "" )
   1.123 +#define 		gmyth_uri_get_fragment(urip) 	( urip->fragment != NULL ? urip->fragment->str : "" )
   1.124 +#define 		gmyth_uri_get_query(urip) 		( urip->query != NULL ? urip->query->str : "" )
   1.125 +
   1.126 +G_END_DECLS
   1.127 +
   1.128 +#endif /* _GMYTH_URI_H_ */