HTML_COLORSTYLE = LIGHT
PROJECT_LOGO = w3.png
PROJECT_BRIEF = WWW Library
+GENERATE_MAN = YES
+GENERATE_LATEX = NO
+EXAMPLE_PATH = Example
+EXAMPLE_RECURSIVE = YES
+EXAMPLE_PATTERNS = *.c
#include "W3Version.h"
+/**
+ * @warning
+ * This struct is not intended to be used directly!
+ */
struct W3 {
int sock;
int port;
* @param hostname Hostname
* @param port Port
* @return
- * - `struct W3*` if successful.
+ * - non-`NULL` if successful.
* - `NULL` if not.
*/
struct W3* W3_Create(const char* protocol, const char* hostname, int port);
/**
* @brief Sets the method, or the command name.
- * @param w3 Pointer to the struct.
- * @param method Method, or command name.
+ * @param w3 Pointer to the struct
+ * @param method Method, or command name
*/
void W3_Set_Method(struct W3* w3, const char* method);
/**
* @brief Sets the path, or the argument.
- * @param w3 Pointer to the struct.
- * @param path Path, or argument.
+ * @param w3 Pointer to the struct
+ * @param path Path, or argument
*/
void W3_Set_Path(struct W3* w3, const char* path);
+
+/**
+ * @brief Sends the request, or just handshake.
+ * @param w3 Pointer to the struct
+ */
void W3_Send_Request(struct W3* w3);
+
+/**
+ * @brief Sets the header.
+ * @param w3 Pointer to the struct
+ * @param key Header key
+ * @param value Header value
+ */
void W3_Set_Header(struct W3* w3, const char* key, const char* value);
+
+/**
+ * @brief Frees the struct.
+ * @param w3 Pointer to the struct
+ */
void W3_Free(struct W3* w3);
+
+/**
+ * @brief Sets the event handler.
+ * @param w3 Pointer to the struct
+ * @param eventname Event name
+ * @param func Function pointer
+ */
void W3_On(struct W3* w3, const char* eventname, void* func);
+
+/**
+ * @brief Force-disconnects from the server.
+ * @param w3 Pointer to the struct
+ */
void W3_Disconnect(struct W3* w3);
+
+/**
+ * @brief Sets the data to be sent.
+ * @param w3 Pointer to the struct
+ * @param data Data
+ * @param size Size of the data
+ */
void W3_Set_Data(struct W3* w3, char* data, size_t size);
+
+/**
+ * @brief Sets the read buffer size.
+ * @param w3 Pointer to the struct
+ * @param size Size of the read buffer
+ * @note This method must be called before the W3_Send_Request.
+ */
void W3_Set_Read_Size(struct W3* w3, size_t size);
#ifdef __cplusplus
#ifndef __W3FTP_H__
#define __W3FTP_H__
+/**
+ * @file W3FTP.h
+ * @brief FTP part of LibW3
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
#include "W3Core.h"
void __W3_FTP_Request(struct W3* w3);
+
+/**
+ * @brief Sets the username of the FTP connection.
+ * @param w3 Pointer to the struct
+ * @param username FTP username
+ */
void W3_FTP_Set_Username(struct W3* w3, const char* username);
+
+/**
+ * @brief Sets the password of the FTP connection.
+ * @param w3 Pointer to the struct
+ * @param password FTP password
+ */
void W3_FTP_Set_Password(struct W3* w3, const char* password);
+
+/**
+ * @brief Sends the FTP command.
+ * @param w3 Pointer to the struct
+ * @note This function is different with W3_Send_Request!
+ * @note When W3_Send_Request just handshakes, this function sends the FTP command!
+ */
void W3_FTP_Send_Request(struct W3* w3);
+
+/**
+ * @brief Disconnects from the FTP.
+ * @param w3 Pointer to the struct
+ */
void W3_FTP_Disconnect(struct W3* w3);
#ifdef __cplusplus
#ifndef __W3HTTP_H__
#define __W3HTTP_H__
+/**
+ * @file W3HTTP.h
+ * @brief HTTP part of LibW3
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
#include "W3Core.h"
void __W3_HTTP_Request(struct W3* w3);
+
+/**
+ * @brief Enables the redirect.
+ * @param w3 Pointer to the struct
+ */
void W3_HTTP_Enable_Redirect(struct W3* w3);
#ifdef __cplusplus
#ifndef __W3IRC_H__
#define __W3IRC_H__
+/**
+ * @file W3IRC.h
+ * @brief IRC part of LibW3
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
#include "W3Core.h"
void __W3_IRC_Request(struct W3* w3);
+
+/**
+ * @brief Sets the username of the IRC connection.
+ * @param w3 Pointer to the struct
+ * @param username IRC username
+ */
void W3_IRC_Set_Username(struct W3* w3, const char* username);
+
+/**
+ * @brief Sets the hostname of the IRC connection.
+ * @param w3 Pointer to the struct
+ * @param hostname IRC hostname
+ */
void W3_IRC_Set_Hostname(struct W3* w3, const char* hostname);
+
+/**
+ * @brief Sets the realname of the IRC connection.
+ * @param w3 Pointer to the struct
+ * @param realname IRC realname
+ */
void W3_IRC_Set_Realname(struct W3* w3, const char* realname);
+
+/**
+ * @brief Sets the servername of the IRC connection.
+ * @param w3 Pointer to the struct
+ * @param servername IRC servername
+ */
void W3_IRC_Set_Servername(struct W3* w3, const char* servername);
+
+/**
+ * @brief Sets the nickname of the IRC connection.
+ * @param w3 Pointer to the struct
+ * @param nickname IRC nickname
+ */
void W3_IRC_Set_Nickname(struct W3* w3, const char* nickname);
+
+/**
+ * @brief Sets the password of the IRC connection.
+ * @param w3 Pointer to the struct
+ * @param password IRC password
+ */
void W3_IRC_Set_Password(struct W3* w3, const char* password);
+
+/**
+ * @brief Sends the IRC command.
+ * @param w3 Pointer to the struct
+ * @note This function is different with W3_Send_Request!
+ * @note When W3_Send_Request just handshakes, this function sends the IRC command!
+ */
void W3_IRC_Send_Request(struct W3* w3);
+
+/**
+ * @brief Disconnects from the IRC.
+ * @param w3 Pointer to the struct
+ */
void W3_IRC_Disconnect(struct W3* w3);
#ifdef __cplusplus
#ifndef __W3NNTP_H__
#define __W3NNTP_H__
+/**
+ * @file W3NNTP.h
+ * @brief NNTP part of LibW3
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
#include "W3Core.h"
void __W3_NNTP_Request(struct W3* w3);
+
+/**
+ * @brief Sends the NNTP command.
+ * @param w3 Pointer to the struct
+ * @note This function is different with W3_Send_Request!
+ * @note When W3_Send_Request just handshakes, this function sends the NNTP command!
+ */
void W3_NNTP_Send_Request(struct W3* w3);
+
+/**
+ * @brief Disconnects from the NNTP.
+ * @param w3 Pointer to the struct
+ */
void W3_NNTP_Disconnect(struct W3* w3);
#ifdef __cplusplus
#ifndef __W3POP3_H__
#define __W3POP3_H__
+/**
+ * @file W3POP3.h
+ * @brief POP3 part of LibW3
+ * @deprecated Nishi might abandon this
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
#include "W3Core.h"
void __W3_POP3_Request(struct W3* w3);
+
+/**
+ * @brief Sets the username of the POP3 connection.
+ * @param w3 Pointer to the struct
+ * @param username POP3 username
+ */
void W3_POP3_Set_Username(struct W3* w3, const char* username);
+
+/**
+ * @brief Sets the username of the POP3 connection.
+ * @param w3 Pointer to the struct
+ * @param username POP3 username
+ */
void W3_POP3_Set_Password(struct W3* w3, const char* password);
+
+/**
+ * @brief Sends the POP3 command.
+ * @param w3 Pointer to the struct
+ * @note This function is different with W3_Send_Request!
+ * @note When W3_Send_Request just handshakes, this function sends the POP3 command!
+ */
void W3_POP3_Send_Request(struct W3* w3);
+
+/**
+ * @brief Disconnects from the POP3.
+ * @param w3 Pointer to the struct
+ */
void W3_POP3_Disconnect(struct W3* w3);
#ifdef __cplusplus
#ifndef __W3TAG_H__
#define __W3TAG_H__
+/**
+ * @file W3Tag.h
+ * @brief Tag parser
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
+/**
+ * @brief Parses the data.
+ * @param data Data to be parsed
+ * @param size Size of the data
+ * @param tagfunc Function to be called when the parser hits a tag
+ * @param tagfunc.tagname Tag name
+ * @param tagfunc.attr Tag attributes
+ * @param textfunc Function to be called when the parser hits a text
+ * @param textfunc.data Text
+ */
void W3_Tag_Parse(char* data, size_t size, void (*tagfunc)(char* tagname, char* attr), void (*textfunc)(char* data));
+
+/**
+ * @brief Gets the attribute.
+ * @param data Data to be parsed
+ * @param name Attribute name
+ * @return
+ * - non-`NULL` if it could find the attribute
+ * - `NULL` if it couldn't
+ */
char* W3_Tag_Attr(char* data, const char* name);
#ifdef __cplusplus
#ifndef __W3URL_H__
#define __W3URL_H__
+/**
+ * @file W3Tcl.h
+ * @brief Tcl binding
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
#include <tcl.h>
+/**
+ * @brief Initializes LibW3 for Tcl
+ * @param interp Tcl interpreter
+ * @return Tcl error code
+ */
int W3_Init(Tcl_Interp* interp);
#ifdef __cplusplus
#ifndef __W3URL_H__
#define __W3URL_H__
+/**
+ * @file W3URL.h
+ * @brief URL parser
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
+/**
+ * @brief URL struct
+ */
struct W3URL {
+ /**
+ * @brief Protocol
+ */
char* protocol;
+
+ /**
+ * @brief Host
+ */
char* host;
+
+ /**
+ * @brief Port
+ */
int port;
+
+ /**
+ * @brief Path
+ */
char* path;
+
+ /**
+ * @brief Username
+ * @note `NULL` if the parser could not find the username.
+ */
char* username;
+
+ /**
+ * @brief Password
+ * @note `NULL` if the parser could not find the password.
+ */
char* password;
};
+/**
+ * @brief Parses the URL.
+ * @param url URL
+ * @return
+ * - non-`NULL` if successful.
+ * - `NULL` if not.
+ */
struct W3URL* W3_Parse_URL(const char* url);
+
+/**
+ * @brief Frees the struct.
+ * @param url Pointer to the struct
+ */
void W3_Free_URL(struct W3URL* url);
#ifdef __cplusplus
#ifndef __W3UTIL_H__
#define __W3UTIL_H__
+/**
+ * @file W3Util.h
+ * @brief LibW3 utilities
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
+/**
+ * @brief Turn on/off debugging.
+ * @param do_debug Do debugging or not
+ */
void W3_Do_Debug(bool do_debug);
void __W3_Debug(const char* title, const char* message);
char* __W3_Concat(const char* str1, const char* str2);