#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
Go to the source code of this file.
Data Structures |
struct | hg_header |
| This structure contains the variables for the header. More...
|
struct | hg_handle |
| This structure will be use to handle the connection with the server. More...
|
Typedefs |
typedef struct hg_header | hg_header |
| This structure contains the variables for the header.
|
typedef struct hg_handle | hg_handle |
| This structure will be use to handle the connection with the server.
|
Functions |
hg_handle * | hg_open (const char *path, char *encoding) |
| Open the connection with the mercurial command server.
|
int | hg_close (hg_handle **handle) |
| Close the connection for the given handle.
|
int | hg_rawcommand (hg_handle *handle, char *const command[], size_t cmd_size) |
| Sending a command to the mercurial command server, through the given handle.
|
int | hg_rawread (hg_handle *handle, char *buffer, size_t sizebuff) |
| Reading some unparse data from the server.
|
int | hg_rawwrite (hg_handle *handle, const char *buffer, size_t sizebuff) |
| Will write the buffer to server for the connection establish by the handle.
|
char | hg_channel (hg_handle *handle) |
| Reading the current channel.
|
hg_header | hg_head (hg_handle *handle) |
| Return the current header.
|
int | hg_exitcode (hg_handle *handle) |
| The exitcode for the current command.
|
Typedef Documentation
This structure contains the variables for the header.
- Parameters
-
channel | The channel will stock a letter that will indicate the type of channel. |
length | The length will stock the size of data that will be send or the maxim data that can be received by the server. |
This structure will be use to handle the connection with the server.
- Parameters
-
p_read p_write | Contains 2 fd for parent for the bidirectional connection. |
childpid | The pid of the process that will open the connection. |
header | The header that will contain the current header-action (channel, length). |
Function Documentation
hg_handle* hg_open |
( |
const char * |
path, |
|
|
char * |
encoding |
|
) |
| |
Open the connection with the mercurial command server.
The handle structure will be allocated.
- Parameters
-
path | The path to the repository wherewith I want to create a connection NULL argument means the repository in which I am. |
encoding | Will set HGENCODING to the given encoding NULL argument means the default encoding. (UTF-8) |
- Return values
-
handle | - A handle for this connection. |
NULL | Indicate an error, with errno set appropriately. |
errno can be :
- execl(2) command errors
- dup2(2) command errors
- fork(2) command errors
- pipe(2) command errors
- EFAULT - for a bad path address
- EINVAL - for a bad encoding
Definition at line 103 of file client.c.
Close the connection for the given handle.
Erase the handle and free the memory
- Parameters
-
handle | The handle of the connection that I want to close |
- Return values
-
0 | if successful |
-1 | to indicate an error, with errno set appropriately. |
errno can be:
- EINVAL - Invalid argument ( handle it's set to a null pointer)
- kill(2) command errors
Definition at line 159 of file client.c.
int hg_rawcommand |
( |
hg_handle * |
handle, |
|
|
char *const |
command[], |
|
|
size_t |
cmd_size |
|
) |
| |
Sending a command to the mercurial command server, through the given handle.
- Parameters
-
handle | The handle of the connection, wherewith I want to communicate |
command | An array of pointers to null-terminated strings that represent the argument list available to the new command. |
cmd_size | The length of command array. |
- Return values
-
0 | if successful |
-1 | to indicate an error, with errno set appropriately. |
errno can be:
- EINVAL - Invalid argument ( handle it's set to a null pointer)
- write(2) command errors
Definition at line 224 of file client.c.
int hg_rawread |
( |
hg_handle * |
handle, |
|
|
char * |
buffer, |
|
|
size_t |
sizebuff |
|
) |
| |
Reading some unparse data from the server.
Will read just a 'line', the header that is received from server and the data that comes after the header
- Parameters
-
handle | The handle of the connection, wherewith I want to communicate |
buffer | A character array where the read content will be stored. |
sizebuff | The number of bytes to read. |
- Return values
-
Number | the number of bytes that were read. |
-1 | to indicate an error, with errno set appropriately. |
errno can be:
- EINVAL - Invalid argument (handle it's set to a null pointer)
- read(2) command errors
Definition at line 259 of file client.c.
int hg_rawwrite |
( |
hg_handle * |
handle, |
|
|
const char * |
buffer, |
|
|
size_t |
sizebuff |
|
) |
| |
Will write the buffer to server for the connection establish by the handle.
This function will be used when one of the input channels will be received from the command server. ('I' or 'L' channels)
- Parameters
-
handle | The handle of the connection, wherewith I want to communicate |
buffer | A null terminated character string of the content to write. |
sizebuff | The number of bytes to write |
- Return values
-
Number | the number of bytes that were written |
-1 | to indicate an error, with errno set appropriately. |
errno can be:
- EINVAL - Invalid argument (handle it's set to a null pointer)
- write(2) command errors
Definition at line 292 of file client.c.
Reading the current channel.
Before you read or write data, you will want to know for what kind of data is server waiting, an input data or an output data. This function will return the current channel for the connection established by the handle.
- Parameters
-
handle | The handle of the connection, wherewith I want to communicate |
- Return values
-
0 | if successful |
-1 | to indicate an error, with errno set appropriately. |
errno can be:
- EINVAL - Invalid argument (handle it's set to a null pointer)
Definition at line 319 of file client.c.
Return the current header.
Sometimes, the user needs the entire header. This is a way to do that.
- Parameters
-
handle | The handle of the connection, wherewith I want to communicate |
- Return values
-
hg_header | the header stucture for the given handle. |
NULL | to indicate an error, with errno set appropriately. |
errno can be:
- EINVAL - Invalid argument (handle it's set to a null pointer)
Definition at line 332 of file client.c.
The exitcode for the current command.
The server tell use that he finished his action when the 'r' channel is send. This function will get the exitcode from the server, in as a measure to tell that the command was finished.
- Parameters
-
handle | The handle of the connection, wherewith I want to communicate |
- Return values
-
exitcode | if successful |
-1 | to indicate an error, with errno set appropriately. |
errno can be:
- EINVAL - Invalid argument (handle it's set to a null pointer)
- read(2) command errors
Definition at line 340 of file client.c.