Dillo v3.1.1-119-g140d9ebd
Loading...
Searching...
No Matches
dpip.h File Reference
#include "../dlib/dlib.h"
Include dependency graph for dpip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Dsh
 Dpip socket handler type. More...
 

Macros

#define DPIP_TAG   1
 Dpip tags in the socket.
 
#define DPIP_LAST_TAG   2
 Dpip mode-switching tag.
 
#define DPIP_RAW   4
 Raw data in the socket

 
#define DPIP_NONBLOCK   8
 Nonblocking IO

 
#define a_Dpip_dsh_printf(sh, flush, ...)
 

Enumerations

enum  DpipDshStatus { DPIP_EAGAIN , DPIP_ERROR , DPIP_EOF }
 

Functions

char * a_Dpip_build_cmd (const char *format,...)
 Printf like function for building dpip commands.
 
char * a_Dpip_get_attr (const char *tag, const char *attrname)
 Task: given a tag and an attribute name, return its value.
 
char * a_Dpip_get_attr_l (const char *tag, size_t tagsize, const char *attrname)
 Task: given a tag, its size and an attribute name, return the attribute value (stuffing of ' is removed here).
 
int a_Dpip_check_auth (const char *auth)
 Check whether the given 'auth' string equals what dpid saved.
 
Dsha_Dpip_dsh_new (int fd_in, int fd_out, int flush_sz)
 Create and initialize a dpip socket handler.
 
int a_Dpip_dsh_write (Dsh *dsh, int flush, const char *Data, int DataSize)
 Streamed write to socket.
 
int a_Dpip_dsh_write_str (Dsh *dsh, int flush, const char *str)
 Convenience function.
 
int a_Dpip_dsh_tryflush (Dsh *dsh)
 
int a_Dpip_dsh_trywrite (Dsh *dsh, const char *Data, int DataSize)
 
char * a_Dpip_dsh_read_token (Dsh *dsh, int blocking)
 Return a newlly allocated string with the next dpip token in the socket.
 
char * a_Dpip_dsh_read_token2 (Dsh *dsh, int blocking, int *DataSize)
 Return a newlly allocated string with the next dpip token in the socket.
 
void a_Dpip_dsh_close (Dsh *dsh)
 Close this socket for reading and writing.
 
void a_Dpip_dsh_free (Dsh *dsh)
 Free the SockHandler structure.
 

Macro Definition Documentation

◆ a_Dpip_dsh_printf

#define a_Dpip_dsh_printf (   sh,
  flush,
  ... 
)
Value:
Dstr *dstr = dStr_sized_new(128); \
dStr_sprintf(dstr, __VA_ARGS__); \
a_Dpip_dsh_write(sh, flush, dstr->str, dstr->len); \
dStr_free(dstr, 1); \
static Dsh * sh
Definition datauri.c:39
Dstr * dStr_sized_new(int sz)
Create a new string with a given size.
Definition dlib.c:254
#define D_STMT_START
Definition dlib.h:62
#define D_STMT_END
Definition dlib.h:63
Definition dlib.h:102
Dstr_char_t * str
Definition dlib.h:105
int len
Definition dlib.h:104

Definition at line 77 of file dpip.h.

◆ DPIP_LAST_TAG

#define DPIP_LAST_TAG   2

Dpip mode-switching tag.

Definition at line 18 of file dpip.h.

◆ DPIP_NONBLOCK

#define DPIP_NONBLOCK   8

Nonblocking IO

Definition at line 20 of file dpip.h.

◆ DPIP_RAW

#define DPIP_RAW   4

Raw data in the socket

Definition at line 19 of file dpip.h.

◆ DPIP_TAG

#define DPIP_TAG   1

Dpip tags in the socket.

Definition at line 17 of file dpip.h.

Enumeration Type Documentation

◆ DpipDshStatus

Enumerator
DPIP_EAGAIN 
DPIP_ERROR 
DPIP_EOF 

Definition at line 22 of file dpip.h.

Function Documentation

◆ a_Dpip_build_cmd()

◆ a_Dpip_check_auth()

int a_Dpip_check_auth ( const char *  auth_tag)

Check whether the given 'auth' string equals what dpid saved.

Return value: 1 if equal, -1 otherwise

Definition at line 201 of file dpip.c.

References a_Dpip_get_attr(), dFree(), dGethomedir(), dGetline(), dStrconcat(), dStrerror, and MSG_ERR.

Referenced by File_serve_client(), main(), main(), read_req_cb(), and srv_parse_tok().

◆ a_Dpip_dsh_close()

void a_Dpip_dsh_close ( Dsh dsh)

Close this socket for reading and writing.

(flush pending data)

Definition at line 504 of file dpip.c.

References a_Dpip_dsh_write(), dClose(), dStrerror, Dsh::fd_in, Dsh::fd_out, and MSG_ERR.

Referenced by File_remove_client(), main(), main(), and read_req_cb().

◆ a_Dpip_dsh_free()

void a_Dpip_dsh_free ( Dsh dsh)

Free the SockHandler structure.

Definition at line 525 of file dpip.c.

References dFree(), dReturn_if, dStr_free(), Dsh::rdbuf, and Dsh::wrbuf.

Referenced by File_remove_client(), main(), main(), and read_req_cb().

◆ a_Dpip_dsh_new()

Dsh * a_Dpip_dsh_new ( int  fd_in,
int  fd_out,
int  flush_sz 
)

Create and initialize a dpip socket handler.

Definition at line 247 of file dpip.c.

References dNew, DPIP_NONBLOCK, DPIP_TAG, dStr_sized_new(), Dsh::fd_in, Dsh::fd_out, Dsh::flush_sz, Dsh::mode, Dsh::rdbuf, Dsh::status, and Dsh::wrbuf.

Referenced by File_add_client(), main(), main(), and read_req_cb().

◆ a_Dpip_dsh_read_token()

char * a_Dpip_dsh_read_token ( Dsh dsh,
int  blocking 
)

Return a newlly allocated string with the next dpip token in the socket.

Return value: token string on success, NULL otherwise

Definition at line 493 of file dpip.c.

References a_Dpip_dsh_read_token2().

Referenced by File_serve_client(), get_request(), main(), main(), and read_req_cb().

◆ a_Dpip_dsh_read_token2()

char * a_Dpip_dsh_read_token2 ( Dsh dsh,
int  blocking,
int *  DataSize 
)

Return a newlly allocated string with the next dpip token in the socket.

Return value: token string and length on success, NULL otherwise. (useful for handling null characters in the data stream)

Definition at line 438 of file dpip.c.

References Dpip_dsh_read(), DPIP_EOF, DPIP_ERROR, DPIP_LAST_TAG, DPIP_MODE_SWITCH_TAG, DPIP_RAW, DPIP_TAG, DPIP_TAG_END, dStr_erase(), dStr_truncate(), dStrndup(), Dstr::len, Dsh::mode, Dsh::rdbuf, Dsh::status, and Dstr::str.

Referenced by a_Dpip_dsh_read_token(), send_html_text(), send_numbered_text(), and send_plain_text().

◆ a_Dpip_dsh_tryflush()

int a_Dpip_dsh_tryflush ( Dsh dsh)

Definition at line 340 of file dpip.c.

References Dpip_dsh_write(), dStr_erase(), Dstr::len, Dstr::str, and Dsh::wrbuf.

Referenced by File_send_file().

◆ a_Dpip_dsh_trywrite()

int a_Dpip_dsh_trywrite ( Dsh dsh,
const char *  Data,
int  DataSize 
)

Definition at line 359 of file dpip.c.

References Dpip_dsh_write(), dStr_append_l(), and Dsh::wrbuf.

Referenced by File_send_file().

◆ a_Dpip_dsh_write()

int a_Dpip_dsh_write ( Dsh dsh,
int  flush,
const char *  Data,
int  DataSize 
)

Streamed write to socket.

Return: 0 on success, 1 on error.

Definition at line 317 of file dpip.c.

References Dpip_dsh_write(), dStr_append_l(), dStr_truncate(), Dstr::len, Dstr::str, and Dsh::wrbuf.

Referenced by a_Dpip_dsh_close(), a_Dpip_dsh_write_str(), main(), send_decoded_data(), send_html_text(), send_numbered_text(), send_plain_text(), and try_ftp_transfer().

◆ a_Dpip_dsh_write_str()

◆ a_Dpip_get_attr()

char * a_Dpip_get_attr ( const char *  tag,
const char *  attrname 
)

Task: given a tag and an attribute name, return its value.

(dpip character escaping is removed here) Return value: the attribute value, or NULL if not present or malformed.

Return value: the attribute value, or NULL if not present or malformed.

Definition at line 192 of file dpip.c.

References a_Dpip_get_attr_l().

Referenced by a_Cookies_get_query(), a_Cookies_get_query(), a_Dpip_check_auth(), Dpi_get_server_port(), Dpi_get_server_port(), File_serve_client(), get_command(), get_message(), main(), main(), and read_req_cb().

◆ a_Dpip_get_attr_l()

char * a_Dpip_get_attr_l ( const char *  tag,
size_t  tagsize,
const char *  attrname 
)

Task: given a tag, its size and an attribute name, return the attribute value (stuffing of ' is removed here).

Return value: the attribute value, or NULL if not present or malformed.

Definition at line 134 of file dpip.c.

References dStrndup(), FOUND, MATCH_NAME, Quote, SEEK_NAME, SKIP_QUOTE, and SKIP_VALUE.

Referenced by a_Dpiapi_dialog(), a_Dpip_get_attr(), Bmsrv_parse_token(), Dpi_parse_token(), and srv_parse_tok().