33 #ifndef GENLIB_NET_URI_H
34 #define GENLIB_NET_URI_H
42 #include <sys/param.h>
56 #include <sys/socket.h>
58 #include <sys/types.h>
64 #include <arpa/inet.h>
70 #define strncasecmp strnicmp
81 #define HTTP_DATE_LENGTH 37 // length for HTTP DATE:
83 #define SEPARATORS "()<>@,;:\\\"/[]?={} \t"
84 #define MARK "-_.!~*'()"
85 #define RESERVED ";/?:@&=+$,{}" //added {} for compatibility
86 #define HTTP_SUCCESS 1
93 #define SOCKET_BUFFER_SIZE 5000
141 struct sockaddr_storage IPaddress;
151 enum pathType path_type;
428 #define HTTP_E_BAD_URL UPNP_E_INVALID_URL
429 #define HTTP_E_READ_SOCKET UPNP_E_SOCKET_READ
430 #define HTTP_E_BIND_SOCKET UPNP_E_SOCKET_BIND
431 #define HTTP_E_WRITE_SOCKET UPNP_E_SOCKET_WRITE
432 #define HTTP_E_CONNECT_SOCKET UPNP_E_SOCKET_CONNECT
433 #define HTTP_E_SOCKET UPNP_E_OUTOF_SOCKET
434 #define HTTP_E_BAD_RESPONSE UPNP_E_BAD_RESPONSE
435 #define HTTP_E_BAD_REQUEST UPNP_E_BAD_REQUEST
436 #define HTTP_E_BAD_IP_ADDRESS UPNP_E_INVALID_URL
438 #define RESPONSE_TIMEOUT 30
446 typedef struct SOCKET_BUFFER{
447 char buff[SOCKET_BUFFER_SIZE];
449 struct SOCKET_BUFFER *next;
453 typedef struct HTTP_HEADER {
456 struct HTTP_HEADER * next;
460 typedef struct HTTP_STATUS_LINE{
467 typedef struct HTTP_REQUEST_LINE {
477 typedef struct HTTP_MESSAGE {
479 http_request request;
480 http_header * header_list;
505 int transferHTTPparsedURL(
518 void currentTmToHttpDate(
522 int parse_http_response(
528 int parse_http_request(
534 void print_http_message(
535 http_message *message);
538 int search_for_header(
544 void print_status_line(
548 void print_request_line(
575 void free_http_message(
576 http_message *message);
int token_string_casecmp(token *in1, char *in2)
Compares buffer in the token object with the buffer in in2.
Definition: uri.c:292
int copy_URL_list(URL_list *in, URL_list *out)
Copies one URL_list into another.
Definition: uri.c:212
int parse_uri_and_unescape(char *in, int max, uri_type *out)
Same as parse_uri(), except that all strings are unescaped (XX replaced by chars).
Definition: uri.c:759
int parse_uri(const char *in, int max, uri_type *out)
Parses a uri as defined in http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs).
Definition: uri.c:708
char * URLs
Definition: uri.h:166
Represents a host port: e.g. "127.127.0.1:80" text is a token pointing to the full string representat...
Definition: uri.h:137
Represents a URI used in parse_uri and elsewhere.
Definition: uri.h:148
int remove_dots(char *in, size_t size)
Removes ".", and ".." from a path.
Definition: uri.c:530
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA. "char *" URLs holds dynamic memory.
Definition: uri.h:162
int token_string_cmp(token *in1, char *in2)
Compares a null terminated string to a token (exact).
Definition: uri.c:304
void print_uri(uri_type *in)
Function useful in debugging for printing a parsed uri.
Definition: uri.c:268
token text
Definition: uri.h:139
struct TOKEN token
Buffer used in parsinghttp messages, urls, etc. generally this simply holds a pointer into a larger a...
Provides a platform independent way to include TCP/IP types and functions.
Buffer used in parsinghttp messages, urls, etc. generally this simply holds a pointer into a larger a...
Definition: uri.h:127
struct URI uri_type
Represents a URI used in parse_uri and elsewhere.
int token_cmp(token *in1, token *in2)
Compares two tokens.
Definition: uri.c:316
int replace_escaped(char *in, int index, size_t *max)
Replaces an escaped sequence with its unescaped version as in http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs)
Definition: uri.c:132
struct HOSTPORT hostport_type
Represents a host port: e.g. "127.127.0.1:80" text is a token pointing to the full string representat...
void print_token(token *in)
Function useful in debugging for printing a token.
Definition: uri.c:279
char * resolve_rel_url(char *base_url, char *rel_url)
resolves a relative url with a base url returning a NEW (dynamically allocated with malloc) full url...
Definition: uri.c:596
int parse_token(char *in, token *out, int max_size)
struct URL_LIST URL_list
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA. "char *" URLs holds dynamic memory.
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:91
int parse_hostport(const char *in, int max, hostport_type *out)
Parses a string representing a host and port (e.g. "127.127.0.1:80" or "localhost") and fills out a h...
Definition: uri.c:326
Defines constants that for some reason are not defined on some systems.
void free_URL_list(URL_list *list)
Frees the memory associated with a URL_list.
Definition: uri.c:255
int remove_escaped_chars(char *in, size_t *size)
Removes http escaped characters such as: "%20" and replaces them with their character representation...