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