\section{uri.c File Reference}
\label{uri_8c}\index{uri.c@{uri.c}}
Utilities for uri handling and launching. 

{\tt \#include \char`\"{}rox-clib.h\char`\"{}}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$unistd.h$>$}\par
{\tt \#include $<$gtk/gtk.h$>$}\par
{\tt \#include \char`\"{}rox.h\char`\"{}}\par
{\tt \#include \char`\"{}uri.h\char`\"{}}\par
{\tt \#include \char`\"{}choices.h\char`\"{}}\par
{\tt \#include \char`\"{}basedir.h\char`\"{}}\par
{\tt \#include \char`\"{}rox\_\-debug.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
gchar $\ast$ {\bf rox\_\-escape\_\-uri\_\-path} (const char $\ast$path)
\item 
const gchar $\ast$ {\bf rox\_\-hostname} (void)
\item 
gchar $\ast$ {\bf rox\_\-encode\_\-path\_\-as\_\-uri} (const guchar $\ast$path)
\item 
gchar $\ast$ {\bf rox\_\-unescape\_\-uri} (const char $\ast$uri)
\item 
int {\bf rox\_\-uri\_\-launch} (const char $\ast$uri)
\item 
gchar $\ast$ {\bf rox\_\-uri\_\-get\_\-handler} (const char $\ast$scheme)
\item 
int {\bf rox\_\-uri\_\-launch\_\-handler} (const char $\ast$uri, gboolean block, GError $\ast$$\ast$err)
\end{CompactItemize}


\subsection{Detailed Description}
Utilities for uri handling and launching. 

\begin{Desc}
\item[Author:]Stephen Watson \end{Desc}
\begin{Desc}
\item[Version:]\begin{Desc}
\item[Id]\doxyref{uri.c}{p.}{uri_8c},v 1.5 2007/01/29 12:41:10 stephen Exp \end{Desc}
\end{Desc}


\subsection{Function Documentation}
\index{uri.c@{uri.c}!rox_encode_path_as_uri@{rox\_\-encode\_\-path\_\-as\_\-uri}}
\index{rox_encode_path_as_uri@{rox\_\-encode\_\-path\_\-as\_\-uri}!uri.c@{uri.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}gchar$\ast$ rox\_\-encode\_\-path\_\-as\_\-uri (const guchar $\ast$ {\em path})}\label{uri_8c_11082d8197fecfb7c37c81afb04b0cb2}


Convert a local path into a file: URI with problematic characters replaced with \%xx escapes.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[\mbox{$\leftarrow$} {\em path}]to encode \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]the converted URI, pass to g\_\-free() when done. \end{Desc}
\index{uri.c@{uri.c}!rox_escape_uri_path@{rox\_\-escape\_\-uri\_\-path}}
\index{rox_escape_uri_path@{rox\_\-escape\_\-uri\_\-path}!uri.c@{uri.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}gchar$\ast$ rox\_\-escape\_\-uri\_\-path (const char $\ast$ {\em path})}\label{uri_8c_bd133e1d0e9af7365c8177682ba2d000}


Escape path for future use in URI by replacing problematic characters with a \%xx escape sequence.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[\mbox{$\leftarrow$} {\em path}]path to be escaped \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]escaped path, pass to g\_\-free() when done. \end{Desc}
\index{uri.c@{uri.c}!rox_hostname@{rox\_\-hostname}}
\index{rox_hostname@{rox\_\-hostname}!uri.c@{uri.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const gchar$\ast$ rox\_\-hostname (void)}\label{uri_8c_cff3d5fdc09c391537797d6e0b138806}


Return the canonical hostname for use in drag and drop.

\begin{Desc}
\item[Returns:]host name \end{Desc}
\index{uri.c@{uri.c}!rox_unescape_uri@{rox\_\-unescape\_\-uri}}
\index{rox_unescape_uri@{rox\_\-unescape\_\-uri}!uri.c@{uri.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}gchar$\ast$ rox\_\-unescape\_\-uri (const char $\ast$ {\em uri})}\label{uri_8c_d887cb2a8b843cacd3a8b0b2d66f50b0}


Convert a URI with \%xx escapes into one without

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[\mbox{$\leftarrow$} {\em uri}]URI to be converted. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]converted URI, pass to g\_\-free() when done. \end{Desc}
\index{uri.c@{uri.c}!rox_uri_get_handler@{rox\_\-uri\_\-get\_\-handler}}
\index{rox_uri_get_handler@{rox\_\-uri\_\-get\_\-handler}!uri.c@{uri.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}gchar$\ast$ rox\_\-uri\_\-get\_\-handler (const char $\ast$ {\em scheme})}\label{uri_8c_2d0cf0d043e86ddbafa57971938322d1}


Return the handler for URI's of the named scheme (e.g. http, file, ftp, etc.) The handler for file is always rox, otherwise it obtained from the configuration directory rox.sourceforge.net/URI.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[\mbox{$\leftarrow$} {\em scheme}]URI scheme to get handler for (do not include trailing ':' character)\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Command to execute. The returned string may contain \%s in which case it should be replaced with the URI, otherwise append the URI (after a space). Pass the string to g\_\-free() when done. {\tt NULL} is returned if no handler is defined. \end{Desc}
\index{uri.c@{uri.c}!rox_uri_launch@{rox\_\-uri\_\-launch}}
\index{rox_uri_launch@{rox\_\-uri\_\-launch}!uri.c@{uri.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int rox\_\-uri\_\-launch (const char $\ast$ {\em uri})}\label{uri_8c_600d9d74224900548e10188f1e4cd384}


Launch a URI. If there is a handler for the MIME type text/x-uri then that is executed with '-' as a single argument and the URI pass in on standard input. If there is no such handler then each of the following commands is tried in turn:\begin{itemize}
\item gnome-moz-remote --newwin {\em uri\/} \item mozilla {\em uri\/} \item netscape {\em uri\/} \end{itemize}


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[\mbox{$\leftarrow$} {\em uri}]URI to launch \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]exit status of the last attempted command (0 for success).\end{Desc}
\begin{Desc}
\item[{\bf Deprecated}]use \doxyref{rox\_\-uri\_\-launch\_\-handler()}{p.}{uri_8c_e449ddb2f42e701753a2d0726f00d6b8} instead. \end{Desc}
\index{uri.c@{uri.c}!rox_uri_launch_handler@{rox\_\-uri\_\-launch\_\-handler}}
\index{rox_uri_launch_handler@{rox\_\-uri\_\-launch\_\-handler}!uri.c@{uri.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int rox\_\-uri\_\-launch\_\-handler (const char $\ast$ {\em uri}, gboolean {\em block}, GError $\ast$$\ast$ {\em err})}\label{uri_8c_e449ddb2f42e701753a2d0726f00d6b8}


For a given URI pass it to the appropriate launcher. \doxyref{rox\_\-uri\_\-get\_\-handler()}{p.}{uri_8c_2d0cf0d043e86ddbafa57971938322d1} is used to look up the launcher command which is executed.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[\mbox{$\leftarrow$} {\em uri}]the URI to launch \item[\mbox{$\leftarrow$} {\em block}]if {\tt FALSE} then do not wait for command to complete, otherwise block until so. \item[\mbox{$\leftrightarrow$} {\em err}]location to store error message when launching fails, or {\tt NULL} to discard it\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]When {\em block\/} is true the process id of the command otherwise the exit status of the command, {\tt -1} if no launcher is defined or {\tt -2} if an error occured (check {\em err\/}). \end{Desc}
