[PATCH 01 of 11 c-hglib:level0 V2] hg_handle:hg_header: typedef structures

Iulian Stana julian.stana at gmail.com
Fri Sep 13 15:31:51 CDT 2013


# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379102572 -10800
#      Fri Sep 13 23:02:52 2013 +0300
# Node ID 61c230dad6595f35cf22d2b3c0f64df039e8fb18
# Parent  0000000000000000000000000000000000000000
hg_handle:hg_header: typedef structures

diff --git a/client.h b/client.h
new file mode 100644
--- /dev/null
+++ b/client.h
@@ -0,0 +1,91 @@
+#ifndef _CLIENT_H_
+#define _CLIENT_H_
+
+#include <errno.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+/**
+ * \brief The channel enumeration, contains all the possible channels that
+ * command server could send.
+ **/
+enum channel{
+	o = 'o',
+	e = 'e',
+	r = 'r',
+	I = 'I',
+	L = 'L',
+	wrong_channel
+};
+
+/**
+ * \struct hg_header 
+ * \brief This structure contains the variables for the header. 
+ *
+ * \var hg_header::channel 
+ * The channel will stock a letter that will indicate the type of channel.
+ * \var hg_header::length 
+ * The length will stock the size of data that will be send or the maxim data 
+ * that can be received by the server.
+ * 
+ * \typedef hg_header 
+ * \brief This structure contains the variables for the header. 
+ * 
+ * \param channel
+ * The channel will stock a letter that will indicate the type of channel.
+ * \param length
+ * The length will stock the size of data that will be send or the maxim data 
+ * that can be received by the server.
+ * */
+typedef struct hg_header{
+	uint32_t length;
+	enum channel channel;
+} hg_header;
+
+/**
+ * \struct hg_handle
+ * \brief This structure will be use to handle the connection with the server.
+ *
+ * \var hg_handle::p_read  Read file description that will read from cmdsrv.
+ * \var hg_handle::p_write Write file description that will write to cmdsrv.
+ * \var hg_handle::childpid 
+ *      The pid of the process that will open the connection with cmdsrv.
+ * \var hg_handle::header 
+ *      The header that will contain the header for the next action
+ *      (channel, length).
+ *      Through this header, the user will know on what channel the server will
+ *      send his data.
+ * \var hg_handle::protect
+ *      Create a protection mechanism to block calling rawcommand(new hg
+ *      command) until the exitcode for the last command is not received.
+ * \var hg_handle::bytes_on_pipe This field will tell how much data is still in
+ *                               the pipe
+ * \var hg_handle::out_data_size The size of output data stored in the out_data
+ *                               pointer.
+ * \var hg_handle::out_data Place where data will be stored.
+ *
+ * \typedef hg_handle
+ * \brief This structure will be use to handle the connection with the server.
+ *
+ * \param "p_read p_write" Contains 2 fd for parent for the bidirectional 
+ *                         connection.
+ * \param childpid The pid of the process that will open the connection.
+ * \param header The header that will contain the header for the next action
+ *               (channel, length).
+ * \param protect A protection mechanism.
+ * \param bytes_on_pipe This field will tell how much data is still in the pipe
+ * \param out_data_size The size of output data stored in the out_data pointer.
+ * \param out_data Place where data will be stored.
+ */
+typedef struct hg_handle{
+	pid_t childpid;
+	hg_header *header;
+	int bytes_on_pipe;
+	int p_read;
+	int p_write;
+	int protect;
+	int out_data_size;
+	char *out_data;
+} hg_handle;
+
+#endif


More information about the Mercurial-devel mailing list