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