Client


Data Structures

struct  clientGlobalStruct
struct  w3Mail
struct  w3URI
struct  w3ClientConnection
struct  w3Document

Defines

#define true   1
#define false   0
#define CR   13
#define LF   10

Typedefs

typedef int boolean

Functions

void w3ClientInit ()
boolean w3ClientConnect (w3ClientConnection *con)
boolean w3ClientGetDocument (w3Document *doc)
boolean w3ClientDisconnect (w3ClientConnection *con)
boolean w3ClientGetImagePath (char *uriString, boolean withoutHostname)
boolean w3ClientDocToFile (const char *uriString, const char *filename, int port)
boolean w3ClientDocToFileMT (const char *uriString, const char *filename, int port)
boolean w3ClientJoinAllThreads ()
boolean w3ClientDestroyAllThreads ()
boolean w3SendData (const void *data, size_t size, int sock)
 Send data through a connection.
void * w3ReceiveData (unsigned int *size, int sock)
 Receive data through a connection.
void w3Error (const char *message)
w3Mailw3CreateMail (char *rcpt, char *sender, char *data)
boolean w3DestroyMail (w3Mail *mail)
boolean w3SendMail (w3Mail *mail, const char *mailer, int port)
boolean w3SendMailFile (const char *path)
char * composeString (char *str1, char *str2)
char * copyString (char *str)
boolean w3ParseURI (const char *uristr, w3URI *uri)

Define Documentation

#define CR   13
 

#define false   0
 

#define LF   10
 

#define true   1
 


Typedef Documentation

typedef int boolean
 


Function Documentation

char* composeString char *  str1,
char *  str2
 

Concatenates str1 and str2.

Returns:
A new string containing the concatenation of str1</CODE and str2.
Author:
Christian Gosch

char* copyString char *  str  ) 
 

Copies str.

Returns:
A new string.
Author:
Christian Gosch

boolean w3ClientConnect w3ClientConnection con  ) 
 

Sets up a connection to con. The following members of con have to be set correctly:
hostname port

Author:
Christian Gosch

boolean w3ClientDestroyAllThreads  ) 
 

Kills all pending threads and frees the taken memory.

boolean w3ClientDisconnect w3ClientConnection con  ) 
 

Closes the connection con.

Returns:
true if successful, otherwise false.
Author:
Christian Gosch

boolean w3ClientDocToFile const char *  uriString,
const char *  filename,
int  port
 

Retrieves the URI described in uriString to file filename. Also retrieves all images using the lexical analyzer for images (img.lex). The html file is stored in filenamey and in the cache directory defined by W3_CLIENT_CACHE_DIR. Downloaded html files are stored flatly in the cache by using the whole URI and substituting slashes by underscores ("/" --> "_"). So,
www.goschs.de/hund/katze/maus.html would be cache/www.goschs.de_hund_katze_maus.html
All images are stored in subdirectories, starting with the hostname. E.g.,
www.goschs.de/www/images/hund.gif would be
cache/www.goschs.de/www/images/hund.gif

boolean w3ClientDocToFileMT const char *  uriString,
const char *  filename,
int  port
 

This is not supporting the cache structure yet. It is not maintained since it is not yet needed for the assignment in CNS. Opens a thread and returns immediately, without joining the thread. Use w3ClientJoin- od DestroyAllThreads () to join them. Be sure to always call one of the latter two to free the memory used by the thread structures, as soon as you have no more threads pending.

boolean w3ClientGetDocument w3Document doc  ) 
 

Gets a document described by doc. All fields in doc except data and dataLength have to be set correctly. The latter two are filled by this function, data contains the received data of length dataLength.

Returns:
true if successful, otherwise false.
Author:
Christian Gosch

boolean w3ClientGetImagePath char *  uriString,
boolean  withoutHostname
 

void w3ClientInit  ) 
 

Initialization of global data structures. Call this before doing anything with the client functions !

boolean w3ClientJoinAllThreads  ) 
 

Joins all pending threads and frees the taken memory.

w3Mail* w3CreateMail char *  rcpt,
char *  sender,
char *  data
 

Takes recipient, sender and mail body and allocates a new w3Mail structure of it.

boolean w3DestroyMail w3Mail mail  ) 
 

Destroys the given mail.

void w3Error const char *  message  ) 
 

Prints an error message.

boolean w3ParseURI const char *  uristr,
w3URI uri
 

Parses the URI given in uristr and stores the corresponding values is uri. No error checking or checks for malformed URIs is done so far. This has to be added.

void* w3ReceiveData unsigned int *  size,
int  sock
 

Receive data through a connection.

Receives data from con into void *data. The size of the received block is stored in size.

Author:
Christian Gosch

boolean w3SendData const void *  data,
size_t  size,
int  sock
 

Send data through a connection.

Sends data in void *data of size size_t size to con.

Author:
Christian Gosch

boolean w3SendMail w3Mail mail,
const char *  mailer,
int  port
 

Sends the given mail to the SMTP server given by mailer running on port port.

boolean w3SendMailFile const char *  path  ) 
 

Sends the file path, containing a mail message.
The file must conform to the following specification:
First line: Recipient
Second line: Sender
Third line: mailer
Fourth line: port number on which the mailer accepts connections
The following lines contain the mail body, including ALL headers the sender wants to be sent (including sender and recipient headers).


Generated on Thu Jul 6 15:37:32 2006 for w3server by  doxygen 1.4.6