#ifndef URI_H
#define URI_H
#include "dstring.h" /* for DString arg in URI_Convert() */

/* Last one has zero pointers. */
typedef struct uri_nv_t {
  char *name;
  char *value;
} uri_nv_t;

/* All URI components have % encodings removed */
typedef struct {
  char *scheme;   /* URI scheme: http, rtsp, ... (converted to lowercase) */
  char *user;     /* user */
  char *password; /* password */
  char *host;     /* host name (converted to lowercase) */
  int port;       /* port number */
  char *path;     /* path name */
  char *param;
  char *search;   /* search path (after ?) */
  uri_nv_t *parameters;
  uri_nv_t *headers;
} uri_t;

extern uri_t URI_Parse(char *url);
extern int   URI_Equal(uri_t u1, uri_t u2);
extern uri_t URI_Copy(uri_t u);
extern void  URI_Free(uri_t *u);
extern void  URI_Print(uri_t u);
extern void  URI_Convert(const char *u_orig, DString *u_dstr, int ip);
extern void  URI_SPrint(uri_t *u, DString *u_dstr, int ip);
extern char *URI_Parameter(uri_t u, char *pname);
#endif
