[PATCH 13 of 14 RFC c-hglib:level0] hg_exitcode: the exitcode for the current command

Iulian Stana julian.stana at gmail.com
Tue Sep 3 15:30:52 CDT 2013


# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1378237146 -10800
#      Tue Sep 03 22:39:06 2013 +0300
# Node ID 000e97597b0ae4871fdec76cec095df11f202995
# Parent  d3cc7fddee1bdaef3a6e6b098688afb9140d35b8
hg_exitcode: the exitcode for the current command

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -363,3 +363,24 @@
 {
 	return handle->next_header;
 }
+
+/*
+ * The exitcode for the current command.
+ * */
+int hg_exitcode(hg_handle *handle)
+{
+	int exitcode;
+
+	if(handle == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	if(read(handle->p_read, &exitcode, sizeof(int)) < 0){
+		return -1;
+	}
+	handle->protect = 0;
+	return swap_uint32(exitcode);
+}
+
+
diff --git a/client.h b/client.h
--- a/client.h
+++ b/client.h
@@ -181,4 +181,20 @@
  * */
 hg_header hg_head(hg_handle *handle);
 
+/**
+ * \brief 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.
+ * \param handle The handle of the connection, wherewith I want to communicate
+ * \retval   exitcode if successful
+ * \retval   -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
+ * */
+int hg_exitcode(hg_handle *handle);
+
 #endif


More information about the Mercurial-devel mailing list